Skip to content

Merchant Return Policy #45

@zenexpert

Description

@zenexpert

I kinda hacked into this because I needed multiple countries included in the returns policy, but in my case the same policy applied to all, there were no differences. This would need further modifications if different policies applied to different countries.

So, here's my solution - in the jscript_plugin_structured_data.php:
if(!empty(PLUGIN_SDATA_RETURNS_POLICY_COUNTRY)) { // Get the defined applicable countries $applicableCountries = PLUGIN_SDATA_RETURNS_APPLICABLE_COUNTRY; // Check if there are multiple countries if (strpos($applicableCountries, ',') !== false) { // If comma-separated, convert to an array and output as a JSON array $countriesArray = explode(',', $applicableCountries); $formattedCountries = json_encode(array_map('trim', $countriesArray)); // Ensure the array is JSON-encoded } else { // If single country, just output it as a string $formattedCountries = '"' . trim($applicableCountries) . '"'; } $hasMerchantReturnPolicy = '"hasMerchantReturnPolicy": { "@type": "MerchantReturnPolicy", "returnPolicyCountry": '.$formattedCountries.', "returnPolicyCategory": "' . $returnPolicyCategory[PLUGIN_SDATA_RETURNS_POLICY] . '",' . (PLUGIN_SDATA_RETURNS_POLICY === 'finite' ? ' "merchantReturnDays": "' . (int)PLUGIN_SDATA_RETURNS_DAYS . '",' : '') . ' "returnMethod": "' . $returnMethod[PLUGIN_SDATA_RETURNS_METHOD] . '", ' . (PLUGIN_SDATA_RETURNS_FEES === '0' ? ' "returnFees": "https://schema.org/FreeReturn"' : '"returnShippingFeesAmount": { "currency" : "' . PLUGIN_SDATA_PRICE_CURRENCY . '", "value": "' . PLUGIN_SDATA_RETURNS_FEES . '" }') . ', "applicableCountry": ' . $formattedCountries . ' },' . "\n"; }

It's passing validation on Rich Results Test so I'm assuming it's OK...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions