Sửa lỗi shippingDetails và hasMerchantReturnPolicy

Lỗi trường “shippingDetails” và “hasMerchantReturnPolicy” được Google thông báo qua một bản cập nhật vào khoảng giữa tháng 4 năm 2023, cho bảng điều khiển Google Search Console liên quan đến thông tin Vận chuyển và Trả hàng.

Lỗi shippingDetails

Thông tin lỗi “shippingDetails” và “hasMerchantReturnPolicy”

Cảnh báo (Thiếu trường “shippingDetails”) có liên quan đến người bán trong trường hợp người bán đã được xác minh trên Google Shop chỉ ở khu vực Hoa Kỳ.

Tính năng này không dành cho đoạn mã sản phẩm và chỉ được hỗ trợ cho danh sách người bán. Vì vậy, nếu bạn chưa được xác minh là người bán ở khu vực Hoa Kỳ, bạn có thể bỏ qua cảnh báo về việc thiếu trường này trên dashboard của mình.

cảnh báo "shippingDetails" và "hasMerchantReturnPolicy"

Cách khắc phục

Mặc dù cảnh báo này cần thiết cho người bán ở Hoa Kỳ, hoàn toàn vô hại nếu website bạn target đến khu vực khác, ví dụ Việt Nam. Bạn có thể ignore nó đi hoặc nếu không muốn thấy cảnh báo này nữa thì có thể khắc phục bằng cách thêm đoạn code dưới đây vào tệp tin functions.php trong website của mình.

Đối với plugin Rank Math SEO

add_filter('rank_math/snippet/rich_snippet_product_entity', function($data) {
    global $product;
    if (! is_a($product, 'WC_Product')) {
        return $data;
    }
    if (empty($data['offers']['hasMerchantReturnPolicy'])) {
        $data['offers']['hasMerchantReturnPolicy'] = array(
            '@type' => 'MerchantReturnPolicy',
            'applicableCountry' => 'VN',
            'returnPolicyCategory' => 'https://schema.org/MerchantReturnFiniteReturnWindow',
            'merchantReturnDays' => '30',
            'returnMethod' => 'https://schema.org/ReturnByMail',
            'returnFees' => 'https://schema.org/FreeReturn',
        );
    }
    if (empty($data['offers']['shippingDetails'])) {
        $data['offers']['shippingDetails'] = array(
            '@type' => 'OfferShippingDetails',
            'shippingRate' => array(
                'value' => '0',
                'currency' => 'VND',
            ),
            'shippingDestination' => array(
                '@type' => 'DefinedRegion',
                'addressCountry' => 'VN',
            ),
            'deliveryTime' => array(
                '@type' => 'ShippingDeliveryTime',
                'handlingTime' => array(
                    '@type' => 'QuantitativeValue',
                    'minValue' => '0',
                    'maxValue' => '1',
                    'unitCode' => 'DAY'
                ),
                'transitTime' => array(
                    '@type' => 'QuantitativeValue',
                    'minValue' => '1',
                    'maxValue' => '5',
                    'unitCode' => 'DAY',
                ),
            ),
        );
    }
    return $data;
});

Đối với plugin YoastSEO

add_filter('wpseo_schema_product', 'gbol_reset_price_valid_until');
function gbol_reset_price_valid_until($data) {
    global $product;
	if ( ! empty( $data['offers'] ) ) {  
		foreach ( $data['offers'] as $key => $offer ) {
			if (! isset($offer['hasMerchantReturnPolicy'])) {
				$data['offers'][$key]['hasMerchantReturnPolicy'] = array(
					'@type' => 'MerchantReturnPolicy',
					'applicableCountry' => 'VN',
					'returnPolicyCategory' => 'https://schema.org/MerchantReturnFiniteReturnWindow',
					'merchantReturnDays' => '30',
					'returnMethod' => 'https://schema.org/ReturnByMail',
					'returnFees' => 'https://schema.org/FreeReturn',
				);
			}
			if (! isset($offer['shippingDetails'])) {
				$data['offers'][$key]['shippingDetails'] = array(
					'@type' => 'OfferShippingDetails',
					'shippingRate' => array(
						'value' => '0',
						'currency' => 'VND',
					),
					'shippingDestination' => array(
						'@type' => 'DefinedRegion',
						'addressCountry' => 'VN',
					),
					'deliveryTime' => array(
						'@type' => 'ShippingDeliveryTime',
						'handlingTime' => array(
							'@type' => 'QuantitativeValue',
							'minValue' => '0',
							'maxValue' => '1',
							'unitCode' => 'DAY'
						),
						'transitTime' => array(
							'@type' => 'QuantitativeValue',
							'minValue' => '1',
							'maxValue' => '5',
							'unitCode' => 'DAY',
						),
					),
				);
			}			
		}
	}
    return $data;
}

Lời kết

shippingDetailshasMerchantReturnPolicy là 2 tùy chọn liên quan đến thương mại điện tử qua WooCommerce. Nếu bạn nhận được cảnh báo về lỗi này, hoàn toàn có thể bỏ qua nó nếu bạn không sinh sống tại Mỹ. Nếu muốn ẩn vĩnh viễn thông báo lỗi, hãy tham khảo hướng dẫn phía trên.

Đừng quên đọc thêm về chính sách vận chuyển liên quan: https://developers.google.com/search/docs/appearance/structured-data/product#shipping

Hy vọng bài viết của ITquocdan.net hữu ích với bạn. Hãy để lại bình luận và chia sẻ nếu thấy hứng thú.

Lỗi trường "shippingDetails"

5/5 - (2 bình chọn)

Bình luận (1)

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *