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

Add to Cart with Options Block: Remove global variable overwrite. #9457

Merged
merged 3 commits into from
May 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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