Add to Cart with Options Block > Remove global variable overwrite. (https://github.com/woocommerce/woocommerce-blocks/pull/9457)

* Remove global variable overwrite from Add to Cart Form block.

* Rename single_product to product.
This commit is contained in:
Patricia Hillebrandt 2023-05-16 10:18:36 +02:00 committed by GitHub
parent 6e3b1ac7fb
commit d26936bad7
1 changed files with 2 additions and 7 deletions

View File

@ -25,23 +25,18 @@ class AddToCartForm extends AbstractBlock {
* @return string | void Rendered block output.
*/
protected function render( $attributes, $content, $block ) {
global $product;
$post_id = $block->context['postId'];
if ( ! isset( $post_id ) ) {
return '';
}
$product = wc_get_product( $post_id );
if ( ! $product instanceof \WC_Product ) {
$product = wc_get_product( $post_id );
if ( ! $product instanceof \WC_Product ) {
return '';
}
return '';
}
ob_start();
/**
* Trigger the single product add to cart action for each product type.
*