Viewing 30 posts - 1 through 30 (of 35 total)
  • Author
  • #780070

    I noticed that if I make the page product with the Layout Builder, the schema for the product in the application/ld+json format is not present in the product page.

    Do you know how to solve this problem?

    Thanks for support


    Hey blinkerart!

    Can you please provide a link of your page for us?

    Best regards,


    Yes sure,
    thank you


    Hi Basilis,
    do you have any news about this issue?
    thank you



    That markup is not available in the theme or in the Woocommerce plugin by default so you need to use a plugin or add the script manually. Please try the following plugins. You need to install both.

    // https://wordpress.org/plugins/wpsso/
    // https://wordpress.org/plugins/wpsso-schema-json-ld/

    Best regards,


    Sorry Ismael,
    I think you are wrong.

    I’ve just tested a new WordPress installation with Enfold and WooCommerce only, not other plugins installed.
    If on the product page I am not using the layout builder, in the html page there is the correct output of the json

    <script type="application/ld+json">{"@graph":[{"@context":"http:\/\/schema.org\/","@type":"Product","@id":"http:\/\/localhost\/wordpress\/prodotto\/flying-ninja\/","url":"http:\/\/localhost\/wordpress\/prodotto\/flying-ninja....

    Instead using the layout builder there is no the <script type=”application/ld+json”>.
    Is this a bug?

    thank you for support


    Enfold uses its own html markup in the layout elements and not the markup provided by woocommerce.


    I know it, but you are talking about the microdata markup on the single element.
    I am talking about the <script type=”application/ld+json”> that is in the <head>.

    With layout builder > no json
    Without layout builder > yes json

    In my opinion the layout builder disable some function that is responsible for the output of the json LD for products.



    Ah. Yes, you’re right. Please add this hook in the functions.php file. This is based on the plugin’s WC_Structured_Data class.

    add_action( 'wp_footer', 'ava_product_schema_markup' );
    function ava_product_schema_markup() {
    	global $post, $product;
    	$builder = get_post_meta($post->ID, '_avia_builder_shortcode_tree', true);
    	if ( ! is_object( $product ) ) {
    		global $product;
    	if ( ! is_a( $product, 'WC_Product' ) ||  $builder == '' ) {
    	$shop_name       = get_bloginfo( 'name' );
    	$shop_url        = home_url();
    	$currency        = get_woocommerce_currency();
    	$markup          = array();
    	$markup['@type'] = 'Product';
    	$markup['@id']   = get_permalink( $product->get_id() );
    	$markup['url']   = $markup['@id'];
    	$markup['name']  = $product->get_name();
    	if ( apply_filters( 'woocommerce_structured_data_product_limit', is_product_taxonomy() || is_shop() ) ) {
    		WC_Structured_Data::set_data( apply_filters( 'woocommerce_structured_data_product_limited', $markup, $product ) );
    	$markup_offer = array(
    		'@type'         => 'Offer',
    		'priceCurrency' => $currency,
    		'availability'  => 'http://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,
    	if ( $product->is_type( 'variable' ) ) {
    		$prices = $product->get_variation_prices();
    		$markup_offer['priceSpecification'] = array(
    			'price'         => wc_format_decimal( $product->get_price(), wc_get_price_decimals() ),
    			'minPrice'      => wc_format_decimal( current( $prices['price'] ), wc_get_price_decimals() ),
    			'maxPrice'      => wc_format_decimal( end( $prices['price'] ), wc_get_price_decimals() ),
    			'priceCurrency' => $currency,
    	} else {
    		$markup_offer['price']    = wc_format_decimal( $product->get_price(), wc_get_price_decimals() );
    	$markup['offers'] = array( apply_filters( 'woocommerce_structured_data_product_offer', $markup_offer, $product ) );
    	if ( $product->get_rating_count() ) {
    		$markup['aggregateRating'] = array(
    			'@type'       => 'AggregateRating',
    			'ratingValue' => $product->get_average_rating(),
    			'ratingCount' => $product->get_rating_count(),
    			'reviewCount' => $product->get_review_count(),
    			echo '<script type="application/ld+json">' . wp_json_encode( $markup ) . '</script>';



    Hello Ismael,

    I have a lot of errors, do you?

    Fatal error: Uncaught Error: Call to undefined method WC_Product_Simple::get_name()
    Stack trace: …



    I don’t see any errors when I add the filter and the JSON-LD markup is being applied to the product page when using the advance layout builder. Please make sure that you have the latest version of the plugin and that there is no syntax error in the filter.



    Updated to WC 3.0.5. Now it looks like everything is ok.
    Thanks for support.


    Hi blinkerart,

    Glad you got it working for you! :)

    If you need further assistance please let us know.
    Best regards,


    Hello Ismael,
    the hook you give us breaks the functionality of the search tool in the WooCommerce > Orders page.
    It breaks both the filter and the search.

    I don’t really know why, but this is.

    Do you have any idea because of what?




    The hook is braking the backend search?
    Are you sure about that?
    It is strange as it shouldnt it is supposed to work only on front end.

    Can u share us access please?

    Best regards,


    Sorry Basilis,
    my bad… I completely screw up.
    I’ve just debugged line by line. The code responsible for that was another that hooks into the pre_get_posts.
    Really sorry again and thanks for being so gentle.



    Thanks for the feedback, so everything is working as it should now?

    Best regards,


    Yes thanks



    We glad that your problem was solved :)

    Best regards,
    John Torvik


    Hello guys,

    sorry to disturb again, but is it correct to have in my search console all the structured data with “Markup: schema.org”, instead for the products are “Markup: mydomain.com”

    Of course mydomain is an example… there it goes the domain of the site I installed your code above.

    Thanks for support



    is your last post related to thread’s title? if not please always open a new ticket for a new question, cause otherwise it gets quite confusing for us.

    What you see inside your console should be pretty normal and default behavior. However, you can use a plugin like Yoast SEO to have better results.

    Best regards,


    Hello Andy,

    it is related to the thread, because the structured data are generated from the code that Ismael wrote.
    And about Yoast SEO, it has nothing to do about the WooCommerce Product structured data.
    So please let me know about my question,



    If you are looking for your schema, it should be pointing there yes, as that is what been called.

    Best regards,



    I found an error in the Ismael code.
    Where there is $this->set_data at line 24, we are no in object context.
    This will cause a fatal error.




    Happy you got it solved and we do appreciate for sharing it.

    Thank you

    Best regards,


    Hello Basilis,

    I didn’t solved it, I’ve just found the problem.


    Hi blinkerart,

    Do you still need our help or you can take it from here? If you need help, please specify your question in more detail.

    Best regards,


    The code that Ismael give us make a fatal error!
    $this->set_data at line 24, we are no in object context.
    Can not use $this if you are not inside a class.




    Thank you for the info. Where do you see the error? Is it on the actual product or the product archive pages? We modified the code a bit.

    Best regards,


    I saw the errore in the log.
    I will test the new code and I will let you know.

Viewing 30 posts - 1 through 30 (of 35 total)
  • The topic ‘application/ld+json not present in WooCommerce Product built with Layout Builder’ is closed to new replies.