/**
* Purrissime - Product Offer structured data.
* Add shipping and return policy to Yoast Offer schema.
*/
add_filter( 'wpseo_schema_offer', 'purrissime_offer_schema', 20, 3 );
function purrissime_offer_schema( $offer, $variation, $product ) {
if ( ! is_array( $offer ) || ! ( $product instanceof WC_Product ) ) {
return $offer;
}
// Standard shipping: 40 MAD throughout Morocco.
$offer['shippingDetails'] = array(
'@type' => 'OfferShippingDetails',
'shippingRate' => array(
'@type' => 'MonetaryAmount',
'value' => 40,
'currency' => 'MAD',
),
'shippingDestination' => array(
'@type' => 'DefinedRegion',
'addressCountry' => 'MA',
),
'deliveryTime' => array(
'@type' => 'ShippingDeliveryTime',
'handlingTime' => array(
'@type' => 'QuantitativeValue',
'minValue' => 0,
'maxValue' => 1,
'unitCode' => 'DAY',
),
'transitTime' => array(
'@type' => 'QuantitativeValue',
'minValue' => 1,
'maxValue' => 5,
'unitCode' => 'DAY',
),
),
);
// Return policy: 7 days, subject to applicable legal exceptions.
$offer['hasMerchantReturnPolicy'] = array(
'@type' => 'MerchantReturnPolicy',
'applicableCountry' => 'MA',
'returnPolicyCategory' =>
'https://schema.org/MerchantReturnFiniteReturnWindow',
'merchantReturnDays' => 7,
);
return $offer;
}