fix stock status is not correct in JSON structure data if product is onbackorder

This commit is contained in:
bao 2023-04-19 19:36:38 +07:00
parent 950bf937d7
commit 4f59b717d4
2 changed files with 21 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
fix stock status is not correct in JSON structure data if product is onbackorder

View File

@ -257,9 +257,25 @@ 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 = "";
}
$markup_offer += array(
'priceCurrency' => $currency,
'availability' => 'http://schema.org/' . ( $product->is_in_stock() ? 'InStock' : 'OutOfStock' ),
'availability' => 'http://schema.org/' . $stock_status_schema,
'url' => $permalink,
'seller' => array(
'@type' => 'Organization',