Support » Plugin: Woocommerce Google Feed Manager » Does this plugin solve the JSON-LD bug in woocommerce?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Michel Jongbloed

    (@michel-jongbloed)

    Hello @jumper,

    No our plugin does not solve this issue and as far as I can see it has not been fixed in the latest WooCommerce version.

    But if you’re a bit familiar with coding you could use the “woocommerce_structured_data_product_offer” filter that WooCommerce offers. I think something like this should work (not tested):

    function add_price_to_variable_products( $markup_offer, $product = null ) {
    
    	if ( ! isset( $product ) ) {
    		global $product;
    	}
    
    	if ( ! is_a( $product, 'WC_Product' ) ) {
    		return $markup_offer;
    	}
    
    	if ( $product->is_type( 'variable' || $product->is_type( 'variation' ) ) ) {
    		$markup_offer['price'] = wc_format_decimal( $product->get_price(), wc_get_price_decimals() );
    	}
    
    	return $markup_offer;
    }
    
    add_filter( 'woocommerce_structured_data_product_offer', 'add_price_to_variable_products', 10, 2 );

    This code is based on the third response of https://github.com/woocommerce/woocommerce/issues/15045

    Thank you! I will check it out!

    Plugin Contributor Michel Jongbloed

    (@michel-jongbloed)

    @jumper,

    I’ll close your topic for now, should you still like some support don’t hesitate to reopen it again.

    Have a nice day!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.