Hello,
Thank you for your query, and we are so sorry about the trouble this must have caused.
Please try the code provided below to see if that works for you ?
add_filter( "rank_math/snippet/rich_snippet_product_entity", function( $entity ) {
// Helper function to ensure array keys exist
function set_nested_array_value(&$array, $path, $value) {
$temp = &$array;
foreach ($path as $key) {
$temp = &$temp[$key];
}
$temp = $value;
}
// Helper function to create a schema section
function create_schema_section($type, $properties = []) {
$section = ['@type' => $type];
foreach ($properties as $key => $value) {
$section[$key] = $value;
}
return $section;
}
// Add return policy
$returnPolicy = create_schema_section('MerchantReturnPolicy', [
'applicableCountry' => 'US',
'returnPolicyCategory' => 'https://schema.org/MerchantReturnFiniteReturnWindow',
'merchantReturnDays' => 30,
'returnMethod' => 'https://schema.org/ReturnByMail',
'returnFees' => 'https://schema.org/FreeReturn'
]);
set_nested_array_value($entity, ['offers', 'hasMerchantReturnPolicy'], $returnPolicy);
// Add shipping details
$shippingDetails = create_schema_section('OfferShippingDetails', [
'shippingRate' => create_schema_section('MonetaryAmount', [
'value' => 5,
'currency' => 'USD'
]),
'shippingDestination' => create_schema_section('DefinedRegion', [
'addressCountry' => 'US'
])
]);
$deliveryTime = create_schema_section('ShippingDeliveryTime', [
'handlingTime' => create_schema_section('QuantitativeValue', [
'minValue' => 1,
'maxValue' => 2,
'unitCode' => 'DAY'
]),
'transitTime' => create_schema_section('QuantitativeValue', [
'minValue' => 4,
'maxValue' => 5,
'unitCode' => 'DAY'
])
]);
set_nested_array_value($shippingDetails, ['deliveryTime'], $deliveryTime);
set_nested_array_value($entity, ['offers', 'shippingDetails'], $shippingDetails);
return $entity;
});
Here’s how you can add filter/hook to your WordPress site:
https://rankmath.com/kb/wordpress-hooks-actions-filters/
Please ensure that you adjust the values in the code for applicableCountry , returnPolicyCategory , merchantReturnDays , returnMethod , returnFees , value , currency , addressCountry , minValue , maxValue , unitCode , minValue , maxValue , unitCode .
You can also refer to the screenshot below, for what can be customised:

The values can be customised as per your speciific needs and business rules.
We hope that helps, and please don’t hesitate to get in touch if you have any other questions.
Thank you.