# Shipping and Return Policy in Product Structured Data

> Adds your shipping cost, delivery time and return policy to the product structured data WooCommerce outputs, which Google can show in shopping results.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, seo, schema, structured-data
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-schema-shipping-returns/

## Code

```php
$wpide_schema_policy = array(
    'country'        => 'GB',  // Two-letter country code you ship to.
    'shipping_cost'  => '3.95',
    'handling_days'  => array( 0, 1 ),
    'transit_days'   => array( 1, 3 ),
    'return_days'    => 30,
    'free_returns'   => true,
);

add_filter( 'woocommerce_structured_data_product', function ( $markup, $product ) use ( $wpide_schema_policy ) {
    if ( empty( $markup['offers'] ) || ! $product->needs_shipping() ) {
        return $markup;
    }

    $currency = get_woocommerce_currency();
    $shipping = array(
        '@type'               => 'OfferShippingDetails',
        'shippingRate'        => array( '@type' => 'MonetaryAmount', 'value' => $wpide_schema_policy['shipping_cost'], 'currency' => $currency ),
        'shippingDestination' => array( '@type' => 'DefinedRegion', 'addressCountry' => $wpide_schema_policy['country'] ),
        'deliveryTime'        => array(
            '@type'        => 'ShippingDeliveryTime',
            'handlingTime' => array( '@type' => 'QuantitativeValue', 'minValue' => $wpide_schema_policy['handling_days'][0], 'maxValue' => $wpide_schema_policy['handling_days'][1], 'unitCode' => 'DAY' ),
            'transitTime'  => array( '@type' => 'QuantitativeValue', 'minValue' => $wpide_schema_policy['transit_days'][0], 'maxValue' => $wpide_schema_policy['transit_days'][1], 'unitCode' => 'DAY' ),
        ),
    );
    $returns  = array(
        '@type'                => 'MerchantReturnPolicy',
        'applicableCountry'    => $wpide_schema_policy['country'],
        'returnPolicyCategory' => 'https://schema.org/MerchantReturnFiniteReturnWindow',
        'merchantReturnDays'   => $wpide_schema_policy['return_days'],
        'returnMethod'         => 'https://schema.org/ReturnByMail',
        'returnFees'           => $wpide_schema_policy['free_returns'] ? 'https://schema.org/FreeReturn' : 'https://schema.org/ReturnFeesCustomerResponsibility',
    );

    foreach ( $markup['offers'] as $i => $offer ) {
        $markup['offers'][ $i ]['shippingDetails']         = $shipping;
        $markup['offers'][ $i ]['hasMerchantReturnPolicy'] = $returns;
    }

    return $markup;
}, 10, 2 );
```

## Notes

Describe your main market in $wpide_schema_policy, and keep the values true to your real offer or Google may ignore them.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Shipping and Return Policy in Product Structured Data" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
