Missing Schema Fields

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #30431
    Chris Hayes
    Participant

        Hi Aizaz, quick question for you, I’m getting some errors because these fields aren’t populating:

        Missing field “hasMerchantReturnPolicy” (in “offers”)
        Missing field “shippingDetails” (in “offers”)

        What’s the best way to get them to populate with data? I tried putting code into child theme functions.php but it didn’t work

        [restrict userlevel="author"]get('Version')); } add_action('wp_enqueue_scripts', 'my_theme_enqueue_styles'); function custom_add_to_cart_text() { return 'ADD TO CART NOW >'; } add_filter('woocommerce_product_single_add_to_cart_text', 'custom_add_to_cart_text'); /** * Add missing structured data fields for Google Merchant */ function add_missing_structured_data_fields($markup, $product) { if (!isset($markup['offers']) || !is_array($markup['offers'])) { return $markup; } // Loop through all offers and add the missing fields foreach ($markup['offers'] as $key => $offer) { // Add shippingDetails $markup['offers'][$key]['shippingDetails'] = [ '@type' => 'OfferShippingDetails', 'shippingRate' => [ '@type' => 'MonetaryAmount', 'value' => '0', 'currency' => 'CAD' ], 'deliveryTime' => [ '@type' => 'ShippingDeliveryTime', 'handlingTime' => [ '@type' => 'QuantitativeValue', 'minValue' => '1', 'maxValue' => '14', 'unitCode' => 'DAY' ], 'transitTime' => [ '@type' => 'QuantitativeValue', 'minValue' => '2', 'maxValue' => '10', 'unitCode' => 'DAY' ] ] ]; // Add hasMerchantReturnPolicy $markup['offers'][$key]['hasMerchantReturnPolicy'] = [ '@type' => 'MerchantReturnPolicy', 'returnPolicyCategory' => 'https://schema.org/MerchantReturnFiniteReturnWindow', 'merchantReturnDays' => 0, 'returnMethod' => 'https://schema.org/ReturnByMail', 'returnShippingFeesAmount' => [ '@type' => 'MonetaryAmount', 'value' => '0', 'currency' => 'CAD' ] ]; } return $markup; } // Hook into the WooCommerce product structured data add_filter('woocommerce_structured_data_product', 'add_missing_structured_data_fields', 10, 2); /** * Debug function to check the schema markup if needed * Uncomment to debug the structured data */ /* function debug_structured_data($markup) { if (current_user_can('administrator') && is_singular('product')) { echo '
        ';
                print_r($markup);
                echo '
        '; } return $markup; } add_filter('woocommerce_structured_data_product', 'debug_structured_data', 20, 1); */[/restrict]
        #30432
        Chris Hayes
        Participant

            hm it maybe woocommerce issue now that I think about it.. not a porto related issue

            #30471
            Aizaz Awan
            Keymaster

                Hello, @chrishayes,

                Yes you are right, this issue seems to be related to the WooCommerce plugin, please try to contact the WooCommerce support and ask for further assistance from them on this issue.

                Best Regards,
                PThemes Team.

              Viewing 3 posts - 1 through 3 (of 3 total)
              • You must be logged in to reply to this topic.
              Customize Icon
              Need Customization? We specialize in delivering high-quality web and mobile design/development services to our clientele. Should you require customization services, please do not hesitate to reach out to us at your convenience.