<?php
add_filter( 'aioseo_schema_output', function ( $schema ) {
foreach ( $schema as &$schemaItem ) {
if ( isset( $schemaItem['@type'] ) && 'Product' === $schemaItem['@type'] ) {
if(!empty($schemaItem["offers"]["shippingDetails"])){
// Loop inside the Offers > shippingDetails schema
foreach( $schemaItem["offers"]["shippingDetails"] as &$schemaItemChild ){
// Check for OfferShippingDetails schema where we need to add the deliveryTime schema
if( isset( $schemaItemChild['@type'] ) && 'OfferShippingDetails' === $schemaItemChild['@type'] ){
// Adding the deliveryTime schema
$schemaItemChild["deliveryTime"] = [
"@type" => "ShippingDeliveryTime",
"handlingTime" => [
"@type" => "QuantitativeValue",
"minValue" => 1,
"maxValue" => 2,
"unitCode" => "d"
],
"transitTime" => [
"maxValue" => 3,
]
];
}
return $schema;
}, 10, 2 );