Prevent warning if there was no post ID available in some product elements (#45675)
* Prevent warning if there was no post ID available in some product elements * Add changelog
This commit is contained in:
parent
55cd1982dc
commit
a6500aa572
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Product Elements: fix some warning thrown when there was no post ID available
|
|
@ -111,7 +111,7 @@ class ProductRating extends AbstractBlock {
|
|||
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 ) {
|
||||
|
|
|
@ -54,7 +54,7 @@ class ProductSKU extends AbstractBlock {
|
|||
return $content;
|
||||
}
|
||||
|
||||
$post_id = $block->context['postId'];
|
||||
$post_id = isset( $block->context['postId'] ) ? $block->context['postId'] : '';
|
||||
$product = wc_get_product( $post_id );
|
||||
|
||||
if ( ! $product ) {
|
||||
|
|
|
@ -97,7 +97,7 @@ class ProductSaleBadge extends AbstractBlock {
|
|||
return $content;
|
||||
}
|
||||
|
||||
$post_id = $block->context['postId'];
|
||||
$post_id = isset( $block->context['postId'] ) ? $block->context['postId'] : '';
|
||||
$product = wc_get_product( $post_id );
|
||||
|
||||
if ( ! $product ) {
|
||||
|
|
|
@ -84,7 +84,7 @@ class ProductStockIndicator extends AbstractBlock {
|
|||
return $content;
|
||||
}
|
||||
|
||||
$post_id = $block->context['postId'];
|
||||
$post_id = isset( $block->context['postId'] ) ? $block->context['postId'] : '';
|
||||
$product = wc_get_product( $post_id );
|
||||
|
||||
if ( ! $product ) {
|
||||
|
|
Loading…
Reference in New Issue