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

Commit

Permalink
Revert "Add to Cart with Options Block > Remove global variable overw…
Browse files Browse the repository at this point in the history
…rite. (#9457)"

This reverts commit fae7af0.
  • Loading branch information
mikejolley committed May 24, 2023
1 parent 67a830f commit be6edb1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/BlockTypes/AddToCartForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,23 @@ 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 ) {
return '';
$product = wc_get_product( $post_id );
if ( ! $product instanceof \WC_Product ) {
return '';
}
}

ob_start();

/**
* Trigger the single product add to cart action for each product type.
*
Expand Down

0 comments on commit be6edb1

Please sign in to comment.