Hi all, just a quick update!
These filters used together ultimately did not result in any improvement in Google Merchant Centre – our variation listings were still rejected after resampling:
add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
$product = wc_get_product( get_the_ID() );
if ( $product->is_type('variable') ) {
return [];
}
return $entity;
});
add_filter( "rank_math/opengraph/facebook/product_price_amount", function( $price ) {
$product = wc_get_product( get_the_ID() );
if ( $product->is_type('variable') ) {
return false;
}
return $price;
});
add_filter( "rank_math/opengraph/facebook/product_price_currency", function( $currency ) {
$product = wc_get_product( get_the_ID() );
if ( $product->is_type('variable') ) {
return false;
}
return $currency;
});
As an experiment, I replaced them all with this instead (from Michael Davis here https://support.rankmath.com/ticket/woocommerce-variants-vs-google-shopping/):
add_filter( 'rank_math/woocommerce/og_price', 'my_custom_og_tags' );
function my_custom_og_tags(){
global $product;
if($product->is_type('variable')){
return false;
}
}
And now our variations are finally being accepted by Google Merchant Centre!
Just to understand better so we can all learn something, @rankmath could you tell us please what the difference is between these two sets of code?
Thanks a lot @rankmath for your excellent support ??
Chris