Automattic\WooCommerce\Internal\Features\ProductBlockEditor\ProductTemplates
SimpleProductTemplate::add_linked_products_group_blocks
Adds the linked products group blocks to the template.
Method of the class: SimpleProductTemplate{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->add_linked_products_group_blocks();
SimpleProductTemplate::add_linked_products_group_blocks() SimpleProductTemplate::add linked products group blocks code WC 10.3.3
private function add_linked_products_group_blocks() {
$linked_products_group = $this->get_group_by_id( $this::GROUP_IDS['LINKED_PRODUCTS'] );
if ( ! isset( $linked_products_group ) ) {
return;
}
$linked_products_group->add_section(
array(
'id' => 'product-linked-upsells-section',
'order' => 10,
'attributes' => array(
'title' => __( 'Upsells', 'woocommerce' ),
'description' => sprintf(
/* translators: %1$s: "Learn more about linked products" link opening tag. %2$s: "Learn more about linked products" link closing tag. */
__( 'Upsells are typically products that are extra profitable or better quality or more expensive. Experiment with combinations to boost sales. %1$sLearn more about linked products%2$s', 'woocommerce' ),
'<br /><a href="https://woocommerce.com/document/related-products-up-sells-and-cross-sells/" target="_blank" rel="noreferrer">',
'</a>'
),
),
)
)->add_block(
array(
'id' => 'product-linked-upsells',
'blockName' => 'woocommerce/product-linked-list-field',
'order' => 10,
'attributes' => array(
'property' => 'upsell_ids',
'emptyState' => array(
'image' => 'ShoppingBags',
'tip' => __(
'Tip: Upsells are products that are extra profitable or better quality or more expensive. Experiment with combinations to boost sales.',
'woocommerce'
),
'isDismissible' => true,
),
),
)
);
$linked_products_group->add_section(
array(
'id' => 'product-linked-cross-sells-section',
'order' => 20,
'attributes' => array(
'title' => __( 'Cross-sells', 'woocommerce' ),
'description' => sprintf(
/* translators: %1$s: "Learn more about linked products" link opening tag. %2$s: "Learn more about linked products" link closing tag. */
__( 'By suggesting complementary products in the cart using cross-sells, you can significantly increase the average order value. %1$sLearn more about linked products%2$s', 'woocommerce' ),
'<br /><a href="https://woocommerce.com/document/related-products-up-sells-and-cross-sells/" target="_blank" rel="noreferrer">',
'</a>'
),
),
'hideConditions' => array(
array(
'expression' => 'editedProduct.type === "external" || editedProduct.type === "grouped"',
),
),
)
)->add_block(
array(
'id' => 'product-linked-cross-sells',
'blockName' => 'woocommerce/product-linked-list-field',
'order' => 10,
'attributes' => array(
'property' => 'cross_sell_ids',
'emptyState' => array(
'image' => 'CashRegister',
'tip' => __(
'Tip: By suggesting complementary products in the cart using cross-sells, you can significantly increase the average order value.',
'woocommerce'
),
'isDismissible' => true,
),
),
)
);
}