Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit fae7af0

Browse files
authored
Add to Cart with Options Block > Remove global variable overwrite. (#9457)
* Remove global variable overwrite from Add to Cart Form block. * Rename single_product to product.
1 parent 3c2b83c commit fae7af0

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/BlockTypes/AddToCartForm.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,18 @@ class AddToCartForm extends AbstractBlock {
2525
* @return string | void Rendered block output.
2626
*/
2727
protected function render( $attributes, $content, $block ) {
28-
global $product;
29-
3028
$post_id = $block->context['postId'];
3129

3230
if ( ! isset( $post_id ) ) {
3331
return '';
3432
}
3533

34+
$product = wc_get_product( $post_id );
3635
if ( ! $product instanceof \WC_Product ) {
37-
$product = wc_get_product( $post_id );
38-
if ( ! $product instanceof \WC_Product ) {
39-
return '';
40-
}
36+
return '';
4137
}
4238

4339
ob_start();
44-
4540
/**
4641
* Trigger the single product add to cart action for each product type.
4742
*

0 commit comments

Comments
 (0)