Tagged: ismael
-
AuthorPosts
-
April 19, 2017 at 5:28 pm #780070
Hello,
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
April 19, 2017 at 9:10 pm #780145Hey blinkerart!
Can you please provide a link of your page for us?
Best regards,
BasilisApril 19, 2017 at 10:15 pm #780176Yes sure,
thank youApril 21, 2017 at 10:04 am #781073Hi Basilis,
do you have any news about this issue?
thank youApril 24, 2017 at 7:03 am #782169Hi,
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,
IsmaelApril 24, 2017 at 10:38 am #782229Sorry 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
April 24, 2017 at 10:48 am #782232Enfold uses its own html markup in the layout elements and not the markup provided by woocommerce.
April 24, 2017 at 11:41 am #782249I 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 jsonIn my opinion the layout builder disable some function that is responsible for the output of the json LD for products.
April 25, 2017 at 8:40 am #782700Hey!
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 == '' ) { return; } $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 ) ); return; } $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(), ); } if(is_singular('product')) { echo '<script type="application/ld+json">' . wp_json_encode( $markup ) . '</script>'; } }
Cheers!
IsmaelApril 25, 2017 at 2:40 pm #782897Hello Ismael,
I have a lot of errors, do you?
Fatal error: Uncaught Error: Call to undefined method WC_Product_Simple::get_name()
Stack trace: …
…April 26, 2017 at 6:27 am #783248Hey!
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.
Regards,
IsmaelMay 2, 2017 at 8:27 am #786214Updated to WC 3.0.5. Now it looks like everything is ok.
Thanks for support.May 2, 2017 at 3:57 pm #786468Hi blinkerart,
Glad you got it working for you! :)
If you need further assistance please let us know.
Best regards,
VictoriaMay 5, 2017 at 5:48 am #788188Hello 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?
thanks
May 7, 2017 at 7:15 pm #789144Hi,
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,
BasilisMay 7, 2017 at 8:18 pm #789166Sorry 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.May 8, 2017 at 4:28 am #789290Hi,
Thanks for the feedback, so everything is working as it should now?
Best regards,
RikardMay 8, 2017 at 7:14 am #789334Yes thanks
May 8, 2017 at 9:51 am #789365Hi,
We glad that your problem was solved :)
Best regards,
John TorvikMay 25, 2017 at 6:17 am #799369Hello 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
May 26, 2017 at 11:04 am #800067Hi,
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,
AndyMay 26, 2017 at 11:32 am #800087Hello 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,
thanksMay 27, 2017 at 8:57 pm #800640Hi,
If you are looking for your schema, it should be pointing there yes, as that is what been called.
Best regards,
BasilisJune 28, 2017 at 7:15 am #813695Hello,
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.Thanks
June 29, 2017 at 10:39 pm #814721Hi,
Happy you got it solved and we do appreciate for sharing it.
Thank you
Best regards,
BasilisJune 30, 2017 at 7:06 am #814828Hello Basilis,
I didn’t solved it, I’ve just found the problem.
thanksJune 30, 2017 at 4:28 pm #815030Hi 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,
VictoriaJuly 1, 2017 at 7:34 am #815280The 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.thanks
July 7, 2017 at 5:29 am #817604Hi!
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,
IsmaelJuly 7, 2017 at 5:44 am #817616I saw the errore in the log.
I will test the new code and I will let you know.
Thanks -
AuthorPosts
- The topic ‘application/ld+json not present in WooCommerce Product built with Layout Builder’ is closed to new replies.