Viewing 11 replies - 16 through 26 (of 26 total)
  • Glad it helped. I am sure that there are a more elegant solution – but I could not find any.

    Lars

    Ha, in this instance I’m not too worried about elegance ??

    Thanks @larsbuur. The only thing I’d add to the hack is to make the schema.org URL https:

    'availability'  => 'https://schema.org/' . $stock = ( $product->is_in_stock() ? 'InStock' : 'OutOfStock' ),
    <strong>'itemCondition' => 'https://schema.org/NewCondition',</strong>
    sku'           => $product->get_sku(),
    • This reply was modified 7 years, 6 months ago by davidtrebacz.

    That′s very interesting and valuable feedback @davidtrebacz. I certainly makes sense to point to a https resource to not have mixed content.

    Comparing https://schema.org/NewCondition and https://schema.org/NewCondition they do not seem to show the same content which seems very strange to me.

    Any idea why?

    No idea why. I can confirm that either pass Google Structured Data Testing tool.

    Well, i can confirm the code is working, on the http version after just over a day on both my merchant accounts I’ve dropped from 100% with missing microdata to 21% and 14% respectively. I expect them to fall further soon ??
    Cheers

    Paul

    WC 3.1 broke it again and can’t figure out how to add the schema for the item condition. Anyone know how?

    Not sure why this is not supported in base WC because the item condition is a very important declaration for any product offering and is throwing errors in adwords. ??

    There is a bug in the initial release of WC 3.1 that turned off most micodata. That bug was reported by me here:

    https://github.com/woocommerce/woocommerce/issues/15873

    The fix is:
    1. Wait for 3.1.1 to be released that will revert the change. The fix has been tested and committed, but no release date has been set.

    or

    2. Change your includes/class-wc-structured-data.php to add the line that was accidently removed in the last release. Line 235$markup['offers'] = array( apply_filters( 'woocommerce_structured_data_product_offer', $markup_offer, $product ) );

    I did #2 and the microdata that was showing on the page before 3.1 is appearing again.

    • This reply was modified 7 years, 4 months ago by davidtrebacz.

    @davidtrebacz

    But even after restoring default microdata using the updated github file, WC still does not add itemcondition. Any idea how to add it? I tried adding it in two spots and it did not output the schema for the item condition (being new).

    In my case all our products are new. I “solved” the item condition issue using the following code in functions.php in a child theme.

    add_filter('woocommerce_structured_data_product_offer','trebacz_add_offer_meta');
    
    function trebacz_add_offer_meta($markup_offer_trebacz) {
                    if ( ! isset( $product ) ) {
                            global $product;
                    }
                    if ( ! is_a( $product, 'WC_Product' ) ) {
                            return;
                    }
                    if ( '' !== $product->get_price() ) {
                            $markup_offer_trebacz['itemCondition'] = 'https://schema.org/NewCondition';
                            $markup_offer_trebacz['description'] = $product->get_short_description().' '.$product->get_description();
                    }
                    return $markup_offer_trebacz;
    }

    This also concatenates the description meta data. The full question and solution are documented here:

    https://github.com/woocommerce/woocommerce/issues/15045

    It’s much more complicated if you have a mixture of new and old items. If you have a more complicated solution, there is a very full featured charge plug-in here:

    https://www.schemaapp.com/product/schema-woocommerce-plugin/

    It seems to address the full challenges of good product meta data in WooCommerce, but I have not tried it yet. My situation is just not that complicated yet.

    David, thank you so much for the code. It works and solved the problem! And thanks for the link to the schema plugin for WC. Seems like that offers a lot, probably much more than I knew even existed. LOL Thanks again for the help!

Viewing 11 replies - 16 through 26 (of 26 total)
  • The topic ‘How to add 'Missing microdata for condition' to Products.’ is closed to new replies.