[Product Block Editor]: add Linked product sections. First approach. (#43013)

* add Linked products, Upsell section

* changelog

* add Cross-lens section

* add links to the Upsell sections

* changelog

* fix lint issues

* fix lint issus

* fix linting issue :-|

* check whether the linked product group is defined
This commit is contained in:
Damián Suárez 2023-12-22 18:44:44 -03:00 committed by GitHub
parent 7f2b1c42fd
commit 7be2481381
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: add
[Product Block Editor]: Add Linked Product sections

View File

@ -0,0 +1,4 @@
Significance: patch
Type: add
[Product Block Editor]: add Linked product sections. First approach.

View File

@ -36,6 +36,7 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ
$this->add_inventory_group_blocks();
$this->add_shipping_group_blocks();
$this->add_variation_group_blocks();
$this->add_linked_products_group_blocks();
}
/**
@ -1104,4 +1105,50 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ
)
);
}
/**
* Adds the linked products group blocks to the template.
*/
private function add_linked_products_group_blocks() {
if ( ! Features::is_enabled( 'product-virtual-downloadable' ) ) {
return;
}
$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. %2$s: Learn more about linked products.*/
__( '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://woo.com/document/related-products-up-sells-and-cross-sells/" target="_blank" rel="noreferrer">',
'</a>'
),
),
)
);
$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. %2$s: Learn more about linked products.*/
__( '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://woo.com/document/related-products-up-sells-and-cross-sells/" target="_blank" rel="noreferrer">',
'</a>'
),
),
)
);
}
}