چطور Merchant Return و Shipping Policy رو به وردپرس اضافه کنم؟
بعد که نصب کردید مراحل زیر رو برید
Note: Before you get started, ensure that you have your Schema module enabled at Rank Math → Dashboard → Modules.
Start by heading over to Rank Math SEO → Schema Templates and then click the Add New Schema button here. In the popup that appears on the screen, choose Custom Schema Builder.
Next, in the Schema Builder, use the Add Property and Add Property Group options to add the MerchantReturnPolicy Schema, as shown below.
Please feel free to adjust the values according to your website. You can also refer to the documentation from Google for configuring this Schema.
Then head over to the Display Conditions tab, where you can choose to Insert this custom Schema into the Organization Schema, as shown below. Finally, click the Save button.
حل ارور Merchant Return و Shipping Policy به وردپرس
در هسته قالب و در پوشه theme و در پوشه قالب فایلی با نام rank-math.php
ایجاد کنید و کدها و دستورات زیر را درج کنید
add_filter( "rank_math/snippet/rich_snippet_product_entity", function( $entity ) {
// Return policy
$entity['offers']['hasMerchantReturnPolicy']['@type'] = 'MerchantReturnPolicy';
$entity['offers']['hasMerchantReturnPolicy']['applicableCountry'] = 'US';
$entity['offers']['hasMerchantReturnPolicy']['returnPolicyCountry'] = 'US';
$entity['offers']['hasMerchantReturnPolicy']['returnPolicyCategory'] = 'https://schema.org/MerchantReturnFiniteReturnWindow';
$entity['offers']['hasMerchantReturnPolicy']['merchantReturnDays'] = 7;
$entity['offers']['hasMerchantReturnPolicy']['returnMethod'] = 'https://schema.org/ReturnByMail';
$entity['offers']['hasMerchantReturnPolicy']['returnFees'] = 'https://schema.org/FreeReturn';
$entity['offers']['hasMerchantReturnPolicy']['refundType'] = 'https://schema.org/FullRefund';
// Shipping details
$entity['offers']['shippingDetails']['@type'] = 'OfferShippingDetails';
$entity['offers']['shippingDetails']['shippingRate']['@type'] = 'MonetaryAmount';
$entity['offers']['shippingDetails']['shippingRate']['value'] = 5;
$entity['offers']['shippingDetails']['shippingRate']['currency'] = 'USD';
$entity['offers']['shippingDetails']['shippingDestination']['@type'] = 'DefinedRegion';
$entity['offers']['shippingDetails']['shippingDestination']['addressCountry'] = 'US';
$entity['offers']['shippingDetails']['deliveryTime']['@type'] = 'ShippingDeliveryTime';
$entity['offers']['shippingDetails']['deliveryTime']['handlingTime']['@type'] = 'QuantitativeValue';
$entity['offers']['shippingDetails']['deliveryTime']['handlingTime']['minValue'] = 0;
$entity['offers']['shippingDetails']['deliveryTime']['handlingTime']['maxValue'] = 1;
$entity['offers']['shippingDetails']['deliveryTime']['handlingTime']['unitCode'] = 'DAY';
$entity['offers']['shippingDetails']['deliveryTime']['transitTime']['@type'] = 'QuantitativeValue';
$entity['offers']['shippingDetails']['deliveryTime']['transitTime']['minValue'] = 0;
$entity['offers']['shippingDetails']['deliveryTime']['transitTime']['maxValue'] = 3;
$entity['offers']['shippingDetails']['deliveryTime']['transitTime']['unitCode'] = 'DAY';
return $entity;
});
However, if you have variable products, you can use the following filter to add this Merchant Return and Shipping policy to them. You can still customize this filter specifically.
add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
if ( empty( $data['richSnippet'] ) || ! in_array( $data['richSnippet']['@type'], [ 'Product', 'ProductGroup' ] ) ) {
return $data;
}
$data['shippingDetails'] = [
'@context' => 'https://schema.org/',
'@type' => 'OfferShippingDetails',
'@id' => '#shipping_policy',
'deliveryTime' => [
'@type' => 'ShippingDeliveryTime',
'handlingTime' => [
'@type' => 'QuantitativeValue',
'minValue' => 0,
'maxValue' => 1,
'unitCode' => 'DAY',
],
'transitTime' => [
'@type' => 'QuantitativeValue',
'minValue' => 1,
'maxValue' => 5,
'unitCode' => 'DAY'
],
],
'shippingRate' => [
'@type' => 'MonetaryAmount',
'value' => 200,
'currency' => 'PKR',
],
'shippingDestination' => [
'@type' => 'DefinedRegion',
'addressCountry' => 'PK'
]
];
$data['hasMerchantReturnPolicy'] = [
'@context' => 'https://schema.org/',
'@type' => 'MerchantReturnPolicy',
'@id' => '#merchant_policy',
'applicableCountry' => 'PK',
'returnPolicyCategory' => 'https://schema.org/MerchantReturnFiniteReturnWindow',
'merchantReturnDays' => 7,
'returnMethod' => 'https://schema.org/ReturnByMail',
'returnFees' => 'https://schema.org/FreeReturn'
];
if ( 'Product' === $data['richSnippet']['@type'] ) {
$data['richSnippet']['offers']['shippingDetails'] = [ '@id' => '#shipping_policy' ];
$data['richSnippet']['offers']['hasMerchantReturnPolicy'] = ['@id' => '#merchant_policy'];
return $data;
}
if ( empty( $data['richSnippet']['hasVariant'] ) ) {
return $data;
}
foreach ( $data['richSnippet']['hasVariant'] as $key => $value ) {
if ( empty( $value['offers'] ) ) {
continue;
}
$data['richSnippet']['hasVariant'][ $key ]['offers']['shippingDetails'] = [ '@id' => '#shipping_policy' ];
$data['richSnippet']['hasVariant'][ $key ]['offers']['hasMerchantReturnPolicy'] = [ '@id' => '#merchant_policy' ];
}
return $data;
}, 99, 2);
And that’s it! If you have absolutely any questions about adding Merchant Return and Shipping policy, please open a support ticket here and our support team would be more than happy to assist you.
Still not using Rank Math?
Setup takes less than 5 minutes including the import from your old SEO Plugin!
Still need help?
- ۰۳/۰۸/۳۰