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

Commit

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

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

* Rename single_product to product.
  • Loading branch information
nefeline authored May 16, 2023
1 parent 3c2b83c commit fae7af0
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/BlockTypes/AddToCartForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit fae7af0

Please sign in to comment.