From 4dd38a4bad6def9a5972a6dcb23559d93d0db346 Mon Sep 17 00:00:00 2001 From: bao Date: Wed, 19 Apr 2023 21:35:22 +0700 Subject: [PATCH] improve --- .../includes/class-wc-structured-data.php | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/plugins/woocommerce/includes/class-wc-structured-data.php b/plugins/woocommerce/includes/class-wc-structured-data.php index 306142f2399..a2cabfa47c8 100644 --- a/plugins/woocommerce/includes/class-wc-structured-data.php +++ b/plugins/woocommerce/includes/class-wc-structured-data.php @@ -257,20 +257,10 @@ class WC_Structured_Data { ); } - $stock_status = $product->get_stock_status(); - - switch ( $stock_status ) { - case 'instock': - $stock_status_schema = 'InStock'; - break; - case 'outofstock': - $stock_status_schema = 'OutOfStock'; - break; - case "onbackorder": - $stock_status_schema = 'BackOrder'; - break; - default: - $stock_status_schema = ''; + if ( $product->is_in_stock() ) { + $stock_status_schema = ( 'onbackorder' === $product->get_stock_status() ) ? 'BackOrder' : 'InStock'; + } else { + $stock_status_schema = 'OutOfStock'; } $markup_offer += array(