Skip to content

Commit

Permalink
check if product is an instance of WC_Product in add_prices_in_posts
Browse files Browse the repository at this point in the history
  • Loading branch information
therocket-gr committed Feb 17, 2024
1 parent 1345c02 commit ff7f096
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -753,8 +753,9 @@ protected function add_prices_in_posts( $posts ) {
continue;
}
$product = wc_get_product( $item['ID'] );
if ( $product ) {

if ( ! $product || ! $product instanceof WC_Product ) {
$posts[ $key ]['price'] = '';
} else {
$price = $product->get_price();
$decimal_separator = wc_get_price_decimal_separator();
$thousand_separator = wc_get_price_thousand_separator();
Expand All @@ -770,8 +771,6 @@ protected function add_prices_in_posts( $posts ) {
$formatted_price = sprintf( $price_format, $currency_symbol, $price );

$posts[ $key ]['price'] = html_entity_decode( $formatted_price, ENT_COMPAT );
} else {
$posts[ $key ]['price'] = '';
}
}
return $posts;
Expand Down

0 comments on commit ff7f096

Please sign in to comment.