RankMath Pro does not inherit shipping information from Products in Woocommerce.
In order to get shipping information into the schema markup, it currently must be done via code.
Since WooCommerce has Shipping Classes that you can define (WooCommerce → Settings → Shipping → Shipping Classes) and then use in the products, we can use those to determine shipping fees in Schema markup too.
Here’s how it works for Free Shipping:
// Hook into RankMath Pro Schema to display shipping info based on class
add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
global $product;
if ( ! is_product() || ! $product instanceof WC_Product ) {
return $entity;
}
// Get shipping class slug
$shipping_class_id = $product->get_shipping_class_id();
$shipping_class_term = get_term( $shipping_class_id, 'product_shipping_class' );
if ( $shipping_class_term && $shipping_class_term->slug === 'free-shipping' ) {
$entity['offers']['shippingDetails'] = [
'@type' => 'OfferShippingDetails',
'shippingRate' => [
'@type' => 'MonetaryAmount',
'value' => '0.00',
'currency' => 'USD',
],
'shippingDestination' => [
'@type' => 'DefinedRegion',
'addressCountry' => 'US',
],
];
}
return $entity;
});