• Resolved markd21

    (@markd21)


    Hello,

    We’re trying to fix some issues with the Schema on our pages.
    We followed the instruction in https://www.ads-software.com/support/topic/product-schema-issue/ with these codes

    add_filter( 'site-reviews/schema/Product', function( $schema ) {
        $postId = get_the_ID();
        $schema['sku'] = get_post_meta( $postId, 'schema_sku', true );
        $schema['brand'] = get_post_meta( $postId, 'schema_brand', true );
        $schema['offercount'] = get_post_meta( $postId, 'schema_offercount', true );
        return $schema;
    });

    Other fields are okay, but the offercount does not work. Here is the screenshot of the error: https://prnt.sc/1ckvrso
    It seems that the code couldn’t get the offerCount field in the right position (under “offers” meta data)

    offerCount
    1 (The property offerCount is not recognised by the schema (e.g. schema.org) for an object of type Product.)

    offerCount
    The offerCount field is recommended. Please provide a value if available.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    Try adding it like this:

    if (array_key_exists('offers', $schema)) {
        $schema['offers']['offerCount'] = get_post_meta($postId, 'schema_offercount', true);
    }
    Plugin Author Gemini Labs

    (@geminilabs)

    Also, if you are using Woocommerce then you shouldn’t need to add these extra schema fields since Site Reviews will link its schema with the existing Woocommerce Product schema.

    Thread Starter markd21

    (@markd21)

    Hello,

    Thanks for your response. I’ve tried adding your code but it seems didn’t work.
    The error of “offercount” is still there https://prnt.sc/1dgyvli

    The code is:

    add_filter( 'site-reviews/schema/Product', function( $schema ) {
        $postId = get_the_ID();
        $schema['sku'] = get_post_meta( $postId, 'schema_sku', true );
        $schema['brand'] = get_post_meta( $postId, 'schema_brand', true );
        $schema['description'] = get_post_meta( $postId, 'schema_description', true );
        $schema['gtin8'] = get_post_meta( $postId, 'schema_gtin8', true );
        return $schema;
        
        if (array_key_exists('offers', $schema)) {
        $schema['offers']['offerCount'] = get_post_meta($postId, 'schema_offercount', true);
    }
    });

    Already tried to add the “if” part inside and outside the old add_fitler code. I also recheck to make sure that we added schema_offercount custom field https://prnt.sc/1dgzowq.

    We use this to implement reviews on a Page (Service), so I guess that’s why it couldn’t pick up the existing Woocommerce Product schema.
    Please help to take a look to see what we could do.
    Thank you!

    Plugin Author Gemini Labs

    (@geminilabs)

    return $schema; needs to be at the very end.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Product Schema Error – OfferCount is not working’ is closed to new replies.