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

Commit be6edb1

Browse files
committed
Revert "Add to Cart with Options Block > Remove global variable overwrite. (#9457)"
This reverts commit fae7af0.
1 parent 67a830f commit be6edb1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/BlockTypes/AddToCartForm.php

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

3032
if ( ! isset( $post_id ) ) {
3133
return '';
3234
}
3335

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

3943
ob_start();
44+
4045
/**
4146
* Trigger the single product add to cart action for each product type.
4247
*

0 commit comments

Comments
 (0)