Automattic\WooCommerce\Internal\Features\ProductBlockEditor\ProductTemplates
ProductVariationTemplate::add_inventory_group_blocks() │ protected │ WC 1.0
Adds the inventory group blocks to the template.
Метод класса: ProductVariationTemplate{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->add_inventory_group_blocks();
Код ProductVariationTemplate::add_inventory_group_blocks() ProductVariationTemplate::add inventory group blocks WC 9.7.1
protected function add_inventory_group_blocks() { $inventory_group = $this->get_group_by_id( $this::GROUP_IDS['INVENTORY'] ); $inventory_group->add_block( array( 'id' => 'inventory-single-variation-notice', 'blockName' => 'woocommerce/product-single-variation-notice', 'order' => 10, 'attributes' => array( 'content' => __( '<strong>You’re editing details specific to this variation.</strong> Some information, like description and images, will be inherited from the main product, <noticeLink><parentProductName/></noticeLink>.', 'woocommerce' ), 'type' => 'info', 'isDismissible' => true, 'name' => $this::SINGLE_VARIATION_NOTICE_DISMISSED_OPTION, ), ) ); // Product Inventory Section. $product_inventory_section = $inventory_group->add_section( array( 'id' => 'product-variation-inventory-section', 'order' => 20, 'attributes' => array( 'title' => __( 'Inventory', 'woocommerce' ), 'description' => sprintf( /* translators: %1$s: Inventory settings link opening tag. %2$s: Inventory settings link closing tag.*/ __( 'Set up and manage inventory for this product, including status and available quantity. %1$sManage store inventory settings%2$s', 'woocommerce' ), '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=products§ion=inventory' ) . '" target="_blank" rel="noreferrer">', '</a>' ), 'blockGap' => 'unit-40', ), ) ); $product_inventory_inner_section = $product_inventory_section->add_subsection( array( 'id' => 'product-variation-inventory-inner-section', 'order' => 10, ) ); $inventory_columns = $product_inventory_inner_section->add_block( array( 'id' => 'product-inventory-inner-columns', 'blockName' => 'core/columns', ) ); $inventory_columns->add_block( array( 'id' => 'product-inventory-inner-column1', 'blockName' => 'core/column', ) )->add_block( array( 'id' => 'product-variation-sku-field', 'blockName' => 'woocommerce/product-sku-field', 'order' => 10, ) ); $inventory_columns->add_block( array( 'id' => 'product-inventory-inner-column2', 'blockName' => 'core/column', ) )->add_block( array( 'id' => 'product-unique-id-field', 'blockName' => 'woocommerce/product-text-field', 'order' => 20, 'attributes' => array( 'property' => 'global_unique_id', // translators: %1$s GTIN %2$s UPC %3$s EAN %4$s ISBN. 'label' => sprintf( __( '%1$s, %2$s, %3$s, or %4$s', 'woocommerce' ), '<abbr title="' . esc_attr__( 'Global Trade Item Number', 'woocommerce' ) . '">' . esc_html__( 'GTIN', 'woocommerce' ) . '</abbr>', '<abbr title="' . esc_attr__( 'Universal Product Code', 'woocommerce' ) . '">' . esc_html__( 'UPC', 'woocommerce' ) . '</abbr>', '<abbr title="' . esc_attr__( 'European Article Number', 'woocommerce' ) . '">' . esc_html__( 'EAN', 'woocommerce' ) . '</abbr>', '<abbr title="' . esc_attr__( 'International Standard Book Number', 'woocommerce' ) . '">' . esc_html__( 'ISBN', 'woocommerce' ) . '</abbr>' ), 'tooltip' => __( 'Enter a barcode or any other identifier unique to this product. It can help you list this product on other channels or marketplaces.', 'woocommerce' ), 'pattern' => array( 'value' => '[0-9\-]*', 'message' => __( 'Please enter only numbers and hyphens (-).', 'woocommerce' ), ), ), ) ); $product_inventory_inner_section->add_block( array( 'id' => 'product-variation-track-stock', 'blockName' => 'woocommerce/product-toggle-field', 'order' => 20, 'attributes' => array( 'label' => __( 'Track inventory', 'woocommerce' ), 'property' => 'manage_stock', 'disabled' => 'yes' !== get_option( 'woocommerce_manage_stock' ), 'disabledCopy' => sprintf( /* translators: %1$s: Learn more link opening tag. %2$s: Learn more link closing tag.*/ __( 'Per your %1$sstore settings%2$s, inventory management is <strong>disabled</strong>.', 'woocommerce' ), '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=products§ion=inventory' ) . '" target="_blank" rel="noreferrer">', '</a>' ), ), ) ); $product_inventory_inner_section->add_block( array( 'id' => 'product-variation-inventory-quantity', 'blockName' => 'woocommerce/product-inventory-quantity-field', 'order' => 10, 'hideConditions' => array( array( 'expression' => 'editedProduct.manage_stock === false', ), ), ) ); $product_inventory_section->add_block( array( 'id' => 'product-variation-stock-status', 'blockName' => 'woocommerce/product-radio-field', 'order' => 10, 'attributes' => array( 'title' => __( 'Stock status', 'woocommerce' ), 'property' => 'stock_status', 'options' => array( array( 'label' => __( 'In stock', 'woocommerce' ), 'value' => 'instock', ), array( 'label' => __( 'Out of stock', 'woocommerce' ), 'value' => 'outofstock', ), array( 'label' => __( 'On backorder', 'woocommerce' ), 'value' => 'onbackorder', ), ), ), 'hideConditions' => array( array( 'expression' => 'editedProduct.manage_stock === true', ), ), ) ); }