Check for the existence of productId before using it (https://github.com/woocommerce/woocommerce-blocks/pull/480)

This commit is contained in:
Kelly Dwan 2019-03-07 17:01:53 -05:00 committed by GitHub
parent 0f473aaa07
commit 7dc5187b4b
1 changed files with 1 additions and 1 deletions

View File

@ -46,7 +46,7 @@ class WGPB_Block_Featured_Product {
* @return string Rendered block type output.
*/
public static function render( $attributes, $content ) {
$id = (int) $attributes['productId'];
$id = isset( $attributes['productId'] ) ? (int) $attributes['productId'] : 0;
$product = wc_get_product( $id );
if ( ! $product ) {
return '';