Title: Plugin does not add &#8220;availability&#8221; field
Last modified: September 14, 2019

---

# Plugin does not add “availability” field

 *  Resolved [amitramani](https://wordpress.org/support/users/amitramani/)
 * (@amitramani)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/plugin-does-not-add-availability-field/)
 * Hello
    Let me begin my congratulating you on creating this very valuable plugin.
   I have been using it for a while now and it works just as promised.
 * However, after reviewing my Google Search Console (GSC), I noticed the following
   errors for every product :
    Missing field ‘availability’
 * After digging deeper, I discovered that the “availability” field is being excluded
   by Lines 1197-1219 of file woocommerce-sea.php
 *     ```
                                       if ( $lowest === $highest ) {
   
                                               $markup_offer = array(
                                                       '@type' => 'Offer',
                                                       'price' => wc_format_decimal( $lowest, wc_get_price_decimals() ),
       				               	'priceValidUntil'    => $price_valid_until,
       					        'priceCurrency' => $shop_currency,
                                               );
   
                                       } 
       ```
   
 * It seems like that is the only clause that is missing the “availability” field.
 * If I disable the “woocommerce_structured_data_product_offer” filter by commenting
   out Line 1251 of the woocommerce-sea.php, all is well. i.e. Availability is added
   to the schema.
 * I just wanted to bring this bug to your attention. Hope you can fix it in the
   next iteration.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fplugin-does-not-add-availability-field%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 8 replies - 1 through 8 (of 8 total)

 *  [evavangelooven](https://wordpress.org/support/users/evavangelooven/)
 * (@evavangelooven)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/plugin-does-not-add-availability-field/#post-11933139)
 * Hi amitramani,
 * The snippet of code you copied and pasted is the default normal WooCommerce structured
   data which is far from optimal. The code was giving a hint already:
 * `// Just use the old WooCommerce buggy setting`
 * We build an Elite feature in our plugin that actually improves the standard WooCommerce
   structured data:
    [https://adtribes.io/woocommerce-structured-data-bug/](https://adtribes.io/woocommerce-structured-data-bug/)
 * Depending on the product type the structured data we insert then looks like this:
 *     ```
                                                               $markup_offer = array(
                                                                       '@type'     => 'AggregateOffer',
                                                                       'lowPrice'  => wc_format_decimal( $lowest, wc_get_price_decimals() ),
                                                                       'highPrice' => wc_format_decimal( $highest, wc_get_price_decimals() ),
                                                                       'priceCurrency' => $shop_currency,
                                                                       'itemCondition' => 'https://schema.org/'.$json_condition.'',
                                                                       'availability'  => 'https://schema.org/' . $stock = ( $product->is_in_stock() ? 'InStock' : 'OutOfStock' ),
                                                                       'sku'           => $product->get_sku(),
                                                                       'image'         => wp_get_attachment_url( $product->get_image_id() ),
                                                                       'description'   => $product->get_description(),
                                                                       'seller'        => array(
                                                                               '@type' => 'Organization',
                                                                               'name'  => $shop_name,
                                                                               'url'   => $shop_url,
                                                                       ),
                                                                       'url'           => $link
                                                               );
       ```
   
 * All the best,
    Eva
 *  Thread Starter [amitramani](https://wordpress.org/support/users/amitramani/)
 * (@amitramani)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/plugin-does-not-add-availability-field/#post-11955512)
 * Hello
    Thank you for the fast response. It appears that Woocommerce (version 
   3.7.0) has corrected the problem.
 * I double checked the default WooCommerce code ([https://github.com/woocommerce/woocommerce/blob/master/includes/class-wc-structured-data.php#L261](https://github.com/woocommerce/woocommerce/blob/master/includes/class-wc-structured-data.php#L261)).
   As you can see below, the Woocommerce codes adds the “availability” feed to all
   the variations.
 *     ```
       			$markup_offer += array(
       				'priceCurrency' => $currency,
       				'availability'  => 'http://schema.org/' . ( $product->is_in_stock() ? 'InStock' : 'OutOfStock' ),
       				'url'           => $permalink,
       				'seller'        => array(
       					'@type' => 'Organization',
       					'name'  => $shop_name,
       					'url'   => $shop_url,
       				),
       			);
       			$markup['offers'] = array( apply_filters( 'woocommerce_structured_data_product_offer', $markup_offer, $product ) );
       		}
       ```
   
 * Also, notice that your plugin is overwriting the “availability” field because
   it uses the ‘woocommerce_structured_data_product_offer’ filter.
 * I hope that you will review this and make the appropriate changes to your plugin
   and release an update.
    I look forward to it! Thank you for a very valuable plugin!
 *  Thread Starter [amitramani](https://wordpress.org/support/users/amitramani/)
 * (@amitramani)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/plugin-does-not-add-availability-field/#post-11994710)
 * Hello [@evavangelooven](https://wordpress.org/support/users/evavangelooven/)
   
   I did not hear back from you. Any advise ?
 * Thanks
 *  [evavangelooven](https://wordpress.org/support/users/evavangelooven/)
 * (@evavangelooven)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/plugin-does-not-add-availability-field/#post-11997634)
 * Hi,
 * My apologies for the late reply we somehow missed this issue. I believe we have
   actually made the change you requested shortly after you raised this issue.
 * This is the piece of code in our plugin that is used:
 *     ```
                       // Just use the old WooCommerce buggy setting
                       if ( '' !== $product->get_price() ) {
   
                               $price_valid_until = date( 'Y-12-31', current_time( 'timestamp', true ) + YEAR_IN_SECONDS );
   
                               if ( $product->is_type( 'variable' ) ) {
                                       $prices  = $product->get_variation_prices();
                                       $lowest  = reset( $prices['price'] );
                                       $highest = end( $prices['price'] );
   
                                       if ( $lowest === $highest ) {
   
                                               $markup_offer = array(
                                                       '@type' => 'Offer',
                                                       'price' => wc_format_decimal( $lowest, wc_get_price_decimals() ),
                                                       'priceValidUntil'    => $price_valid_until,
                                                       'priceCurrency' => $shop_currency,
                                               );
   
                                       } else {
                                               $markup_offer = array(
                                                        '@type'     => 'AggregateOffer',
                                                       'lowPrice'  => wc_format_decimal( $lowest, wc_get_price_decimals() ),
                                                       'highPrice' => wc_format_decimal( $highest, wc_get_price_decimals() ),
                                                       'priceValidUntil'    => $price_valid_until,
                                                       'priceCurrency' => $shop_currency,
                                                       'availability'  => 'https://schema.org/' . ( $product->is_in_stock() ? 'InStock' : 'OutOfStock' ),
                                                       'seller'        => array(
                                                               '@type' => 'Organization',
                                                               'name'  => $shop_name,
                                                               'url'   => $shop_url,
                                                       ),
                                               );
                                       }
                               } else {
                                       if ( $product->is_on_sale() && $product->get_date_on_sale_to() ) {
                                               $price_valid_until = date( 'Y-m-d', $product->get_date_on_sale_to()->getTimestamp() );
                                       }
   
                                       $permalink = get_permalink( $product->get_id() );
                                       $markup_offer = array(
                                               '@type' => 'Offer',
                                               'price' => wc_format_decimal( $product->get_price(), wc_get_price_decimals() ),
                                               'priceValidUntil'    => $price_valid_until,
                                               'priceCurrency' => $shop_currency,
                                               'availability'  => 'https://schema.org/' . ( $product->is_in_stock() ? 'InStock' : 'OutOfStock' ),
                                               'url'           => $permalink,
                                               'seller'        => array(
                                                       '@type' => 'Organization',
                                                       'name'  => $shop_name,
                                                       'url'   => $shop_url,
                                               ),
                                       );
                               }
                       }
       ```
   
 * As you can see the availability part is in. The only pages were it is not is 
   on variable pages where the price of all variants is the same. Would that happen
   to be the case you are referring too? In all other instances it should work just
   fine.
 * All the best,
    Eva
 *  Thread Starter [amitramani](https://wordpress.org/support/users/amitramani/)
 * (@amitramani)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/plugin-does-not-add-availability-field/#post-12088569)
 * Hi Eva
    Sorry for the late reply.
 * Yes, in my case, the variations of a product are all the same price. Therefore,
   the availability field would not be added. For example, if a shirt is available
   in 3 sizes and 2 colors, all 6 variations have the same price.
 * Is that something you plan to address in the plugin?
 *  [JDTravel](https://wordpress.org/support/users/jdtravel/)
 * (@jdtravel)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/plugin-does-not-add-availability-field/#post-12282556)
 * Hi,
    We found that in Google Serps our Woocommerce product pages stopped displaying
   the “In stock/Out of stock” message. When we tested an example product page in
   Google structured data testing tool we found that there were warnings in the 
   Offers -> availability and Offers -> URL fields. These warning disappeared when
   we when the Product Feed Pro for Woocommerce plugin was disabled. We’ve temporarily
   keeping the plugin disabled to see if the “In stock/Out of stock” messages reappear
   in Google. Do you have more information about this issue? Just to mention that
   all our products have the same prices for all variations to the Woocommerce problem
   is not an issue for us. Thanks
 *  Thread Starter [amitramani](https://wordpress.org/support/users/amitramani/)
 * (@amitramani)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/plugin-does-not-add-availability-field/#post-12283606)
 * Hello [@jdtravel](https://wordpress.org/support/users/jdtravel/)
    Have you tried
   disabling the “woocommerce_structured_data_product_offer” filter by commenting
   out Line 1251 of the woocommerce-sea.php?
 * You can do this without editing the woocommerce-sea.php by simply disabling the“
   woocommerce_structured_data_product_offer” filter in your functions.php.
 * Thanks
    Amit
 *  [evavangelooven](https://wordpress.org/support/users/evavangelooven/)
 * (@evavangelooven)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/plugin-does-not-add-availability-field/#post-12283810)
 * Hi jdtravel,
 * When you have disabled our structured data feature ([https://adtribes.io/woocommerce-structured-data-bug/](https://adtribes.io/woocommerce-structured-data-bug/))
   the plugin doesn’t do anything with the existing availability structured data
   snippet. It uses the default WooCommerce structured data in those cases.
 * Best,
    Eva

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Plugin does not add “availability” field’ is closed to new replies.

 * ![](https://ps.w.org/woo-product-feed-pro/assets/icon-256x256.png?rev=3111496)
 * [Product Feed PRO for WooCommerce by AdTribes – Product Feeds for WooCommerce](https://wordpress.org/plugins/woo-product-feed-pro/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woo-product-feed-pro/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woo-product-feed-pro/)
 * [Active Topics](https://wordpress.org/support/plugin/woo-product-feed-pro/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woo-product-feed-pro/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woo-product-feed-pro/reviews/)

## Tags

 * [errors](https://wordpress.org/support/topic-tag/errors/)
 * [GSC](https://wordpress.org/support/topic-tag/gsc/)

 * 8 replies
 * 3 participants
 * Last reply from: [evavangelooven](https://wordpress.org/support/users/evavangelooven/)
 * Last activity: [6 years, 5 months ago](https://wordpress.org/support/topic/plugin-does-not-add-availability-field/#post-12283810)
 * Status: resolved