Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent warning if there was no post ID available in some product elements #45675

Merged
merged 4 commits into from Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Product Elements: fix some warning thrown when there was no post ID available
Expand Up @@ -111,7 +111,7 @@ protected function render( $attributes, $content, $block ) {
return $content;
}

$post_id = $block->context['postId'];
$post_id = isset( $block->context['postId'] ) ? $block->context['postId'] : '';
$product = wc_get_product( $post_id );

if ( $product && $product->get_review_count() > 0 ) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/woocommerce/src/Blocks/BlockTypes/ProductSKU.php
Expand Up @@ -54,7 +54,7 @@ protected function render( $attributes, $content, $block ) {
return $content;
}

$post_id = $block->context['postId'];
$post_id = isset( $block->context['postId'] ) ? $block->context['postId'] : '';
$product = wc_get_product( $post_id );

if ( ! $product ) {
Expand Down
Expand Up @@ -97,7 +97,7 @@ protected function render( $attributes, $content, $block ) {
return $content;
}

$post_id = $block->context['postId'];
$post_id = isset( $block->context['postId'] ) ? $block->context['postId'] : '';
$product = wc_get_product( $post_id );

if ( ! $product ) {
Expand Down
Expand Up @@ -84,7 +84,7 @@ protected function render( $attributes, $content, $block ) {
return $content;
}

$post_id = $block->context['postId'];
$post_id = isset( $block->context['postId'] ) ? $block->context['postId'] : '';
$product = wc_get_product( $post_id );

if ( ! $product ) {
Expand Down