• Resolved wjnpk

    (@wjnpk)


    How to change schema type for product to book, I did and it doesn’t show when change type for Book.

    function filter_woocommerce_structured_data( $markup ) {
    	$markup['@type'] = "Product"; // change Book
    }
    
    add_filter( 'woocommerce_structured_data_product', 'filter_woocommerce_structured_data', 10, 2 );
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Kaushik S. a11n

    (@kaushiksomaiya)

    Hi there!

    Thank you for contacting us!

    I understand the filter for modifying the product schema is not working for you.

    I am not too sure about this, but it might need adding a new structured data type before you can add it.

    
    add_filter( 'woocommerce_structured_data_type_for_page', 'add_book_type', 10, 1);
    
    function add_book_type(){
    		$types[] = is_shop() || is_product_category() || is_product() ? 'book' : '';
    }
    										   
    add_filter( 'woocommerce_structured_data_product', 'filter_woocommerce_structured_data', 10, 2 );
    
    function filter_woocommerce_structured_data( $markup, $product ) {
    	$markup['@type'] = 'Book';
    	return $markup;
    }
    

    If you still have any issues, I recommend checking the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Thread Starter wjnpk

    (@wjnpk)

    Thanks Rp, I did it the above way, and the structure check doesn’t show up

    Plugin Support con

    (@conschneider)

    Engineer

    Hi there,

    We could try and test this with you.
    When you say “and the structure check doesn’t show up” – how do you test this exactly?

    Kind regards,

    Thread Starter wjnpk

    (@wjnpk)

    I check with tool https://search.google.com/test/rich-results
    Do not show the product structure

    Plugin Support Kaushik S. a11n

    (@kaushiksomaiya)

    Hi there!

    Could you share the URL of your product page so that we can see it in the Google Rich Results tool?

    Do not show the product structure

    Do you mean you are unable to see the additional data related to the product, such as name, image, URL, description, etc?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Changing Schema Type for Product to Book’ is closed to new replies.