Product SKU: no render the prefix when the SKU isn't defined (https://github.com/woocommerce/woocommerce-blocks/pull/8837)
This commit is contained in:
parent
48fde013ea
commit
d5cb9b0248
|
@ -55,14 +55,22 @@ class ProductSKU extends AbstractBlock {
|
|||
$post_id = $block->context['postId'];
|
||||
$product = wc_get_product( $post_id );
|
||||
|
||||
if ( $product ) {
|
||||
return sprintf(
|
||||
'<div class="wc-block-components-product-sku wc-block-grid__product-sku">
|
||||
SKU:
|
||||
<strong>%s</strong>
|
||||
</div>',
|
||||
$product->get_sku()
|
||||
);
|
||||
if ( ! $product ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$product_sku = $product->get_sku();
|
||||
|
||||
if ( ! $product_sku ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
'<div class="wc-block-components-product-sku wc-block-grid__product-sku">
|
||||
SKU:
|
||||
<strong>%s</strong>
|
||||
</div>',
|
||||
$product_sku
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue