Remove Variable product template from the product template list (#43422)

* Remove variable-product-template from the product template list

* Add changelog files

* Redirect the variable product to the new experience now that is does not have a product template anymore

* Fix php linter error
This commit is contained in:
Maikel Perez 2024-01-12 18:47:15 -03:00 committed by GitHub
parent ec85c4bd4a
commit 4f8922aa0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 17 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: add
Always fallback to the standard product template in case the given product type is variable

View File

@ -0,0 +1,4 @@
Significance: minor
Type: add
Remove Variable product from the product template list

View File

@ -282,19 +282,6 @@ class Init {
), ),
) )
); );
$templates[] = new ProductTemplate(
array(
'id' => 'variable-product-template',
'title' => __( 'Variable product', 'woocommerce' ),
'description' => __( 'A product with variations like color or size.', 'woocommerce' ),
'order' => 40,
'icon' => null,
'layout_template_id' => 'simple-product',
'product_data' => array(
'type' => 'variable',
),
)
);
return $templates; return $templates;
} }

View File

@ -71,10 +71,13 @@ class RedirectionController {
continue; continue;
} }
$product_data = $product_template->get_product_data(); $product_data = $product_template->get_product_data();
$product_type = $product_data['type']; $product_data_type = $product_data['type'];
// Treat a variable product as a simple product since there is not a product template
// for variable products.
$product_type = $product->get_type() === 'variable' ? 'simple' : $product->get_type();
if ( isset( $product_type ) && $product_type !== $product->get_type() ) { if ( isset( $product_data_type ) && $product_data_type !== $product_type ) {
continue; continue;
} }
@ -82,7 +85,7 @@ class RedirectionController {
return true; return true;
} }
if ( isset( $product_type ) ) { if ( isset( $product_data_type ) ) {
if ( Features::is_enabled( 'product-virtual-downloadable' ) ) { if ( Features::is_enabled( 'product-virtual-downloadable' ) ) {
return true; return true;
} }