Created
January 26, 2026 09:45
-
-
Save wp-seopress/335474786ea9dd128b79000f23ab7478 to your computer and use it in GitHub Desktop.
Filter the shipping properties in product schema
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter('seopress_pro_wc_schema_shipping_details', 'sp_wc_schema_shipping_details', 10, 2); | |
| function sp_wc_schema_shipping_details($shipping_offers, $wc_product) { | |
| // Example: add/override a shipping destination + delivery times. | |
| $shipping_offers['shippingDestination'] = [ | |
| '@type' => 'DefinedRegion', | |
| 'addressCountry' => 'US', | |
| ]; | |
| $shipping_offers['deliveryTime'] = [ | |
| '@type' => 'ShippingDeliveryTime', | |
| 'handlingTime' => [ | |
| '@type' => 'QuantitativeValue', | |
| 'minValue' => 0, | |
| 'maxValue' => 1, | |
| 'unitCode' => 'DAY', | |
| ], | |
| 'transitTime' => [ | |
| '@type' => 'QuantitativeValue', | |
| 'minValue' => 2, | |
| 'maxValue' => 5, | |
| 'unitCode' => 'DAY', | |
| ], | |
| ]; | |
| // Example: set a custom shipping rate (if the schema uses a MonetaryAmount). | |
| $shipping_offers['shippingRate'] = [ | |
| '@type' => 'MonetaryAmount', | |
| 'value' => '9.99', | |
| 'currency' => get_woocommerce_currency(), | |
| ]; | |
| // You can also use product data if needed: | |
| // $product_id = $wc_product instanceof WC_Product ? $wc_product->get_id() : 0; | |
| return $shipping_offers; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment