Page 1 of 1

Question about SCHEMA / header Module Offer or Product

Posted: Tue May 09, 2023 1:55 pm
by loop
Hi All
At the moment i use the headermodule for schema, with type=product for the snippet. i received a email from google that on my site is missing shippingdetails on the schema after a lot of googling i found out that there exist a tag "shippingdetail" but not in the schema for products, it's only in offer.

at the moment i don't get it what is correct, do i need to have a snippet for product or for offer? can anybody help me here? thanks!

Code: Select all

"shippingDetails": {
      "@type": "ShippingDetails",
      "shippingRate": {
        "@type": "MonetaryAmount",
        "currency": "CHF",
        "value": "Hier Versandpreis einfügen"
      },
      "shippingDestination": {
        "@type": "DefinedRegion",
        "name": "Hier Region einfügen"
      },
      "shippingDestinationDescription": "Der Preis ist für die gesamte Region gleich."
    }

Re: Question about SCHEMA / header Module Offer or Product

Posted: Tue May 09, 2023 2:32 pm
by burt
Would not be possible in most sites as shipping is worked out in the checkout process.
Shipping prices is (usually) unavailable before the checkout.

Re: Question about SCHEMA / header Module Offer or Product

Posted: Tue May 09, 2023 2:49 pm
by Pierre_P
@loop

I'm busy looking into this as well, but not getting any further with this and will need some help :D
I have seen Burt's comment about shipping, currently free shipping or fixed shipping can do

I'm getting 2 errors for merchant listings(snippets part 100% correct)
1: missing field "delivery time"
2: Either "returnFees" or "returnShippingFeesAmount" should be specified (optional)

Not to sure what is missing required to get 100% going
Obviously this settings needs customization to your own store and country.

Code: Select all

        
        // Added NewCondition - all items is new
          $schema_product['offers']['itemCondition'] = 'https://schema.org/NewCondition';

          $schema_product['offers']['shippingDetails'] = [
              '@type' => 'OfferShippingDetails',
                  'shippingRate' => [
                  '@type' => 'MonetaryAmount',
                  'value' => '0',
                  'currency' => 'ZAR',
              ],
              'shippingDestination' =>  [
                  '@type'  => 'DefinedRegion',
                  'addressCountry' => 'ZA',
              ],
          ];

          $schema_product['offers']['deliveryTime'] = [
                  '@type' => 'ShippingDeliveryTime',
                  'handlingTime' => [
                  '@type' => 'QuantitativeValue',
                  'minValue' => '0',
                  'maxValue' => '1',
                  'unitCode' => 'DAY',
              ],
              'transitTime' => [
                  '@type' => 'QuantitativeValue',
                  'minValue' => '1',
                  'maxValue' => '5',
                  'unitCode' => 'DAY',
              ],
          ];

          $schema_product['offers']['seller'] = [
              '@type' => 'Organization',
              'name' => STORE_NAME,
          ];

          $schema_product['offers']['hasMerchantReturnPolicy'] = [
              '@type' => 'MerchantReturnPolicy',
              'applicableCountry' => 'ZA',
              'returnPolicyCategory' => 'MerchantReturnFiniteReturnWindow',
              'merchantReturnDays' => '14',
              'returnMethod' => 'ReturnInStore',
              // 'returnFees' => 'ReturnFeesCustomerResponsibility',
          ];
And reviews was also complaining about author so i did this to solved it

Code: Select all

          $schema_product['review'] = [];
          foreach ($product->get('reviews') as $review) {
              $schema_product['review'][] = [
                '@type'         => 'Review',
               // 'author'        => htmlspecialchars($review['customers_name']),
                'datePublished' => htmlspecialchars($review['date_added']),
                'description'   => htmlspecialchars($review['text']),
                // 'name'          => htmlspecialchars($product->get('name')),
                'author'  => [
                      '@type'       => 'Person',
                      'name'        => htmlspecialchars($review['customers_name']),
                  ],
                  'reviewRating'  => [
                  '@type'       => 'Rating',
                  'bestRating'  => '5',
                  'ratingValue' => (int)$review['rating'],
                  'worstRating' => '1',
                ],
              ];
Also normal products now requires priceValidUntil

Code: Select all

              $schema_product['offers']['price'] = $product->format_raw();
              $date = date('Y-m-d');
              $nextweek = date('Y-m-d',strtotime('+7 day',strtotime($date)));
              $schema_product['offers']['priceValidUntil'] = $nextweek;

Re: Question about SCHEMA / header Module Offer or Product

Posted: Tue May 09, 2023 2:50 pm
by burt

Re: Question about SCHEMA / header Module Offer or Product

Posted: Tue May 09, 2023 3:00 pm
by burt
Pierre_P wrote: Tue May 09, 2023 2:49 pm 1: missing field "delivery time"
https://schema.org/ShippingDeliveryTime - scroll to "instances of ShippingDeliveryTime may appear as a value for the following properties", which says that https://schema.org/deliveryTime should be
The total delay between the receipt of the order and the goods reaching the final customer.
However, do note that these are warnings not errors. Core Team is probably never going to look at a warning in terms of fixing up for Core.

I do remember having a conversation about making these schema modules extendable more easily. Not sure how to approach that yet, even so, making it more easily extendable would not really solve future warnings and errors - code would still be needed.

Re: Question about SCHEMA / header Module Offer or Product

Posted: Tue May 09, 2023 4:05 pm
by Pierre_P
Thanks @burt
This solves the shipping part

Code: Select all

          $schema_product['offers']['shippingDetails'] = [
              '@type' => 'OfferShippingDetails',
              'shippingDestination' =>  [
                  '@type'  => 'DefinedRegion',
                  'addressCountry' => 'ZA',
              ],
          'deliveryTime' => [
                  '@type' => 'ShippingDeliveryTime',
              'handlingTime' => [
                  '@type' => 'QuantitativeValue',
                  'minValue' => '0',
                  'maxValue' => '1',
                  'unitCode' => 'd',
              ],
              'transitTime' => [
                  '@type' => 'QuantitativeValue',
                  'minValue' => '1',
                  'maxValue' => '5',
                  'unitCode' => 'd',
              ],
          ],
              'businessDays' => [
                  '@type' => 'OpeningHoursSpecification',
                  ],
                  'dayOfWeek' => [
              'https://schema.org/Monday',
              'https://schema.org/Tuesday',
              'https://schema.org/Wednesday',
              'https://schema.org/Thursday',
              'https://schema.org/Friday',
                  ],
              'cutoffTime' => '09:00:15Z',
              'shippingRate' => [
                  '@type' => 'MonetaryAmount',
                  'value' => '0',
                  'currency' => 'ZAR',
              ],
          ];

Re: Question about SCHEMA / header Module Offer or Product

Posted: Wed May 10, 2023 7:26 am
by lecarlb
@Pierre_P,

Are you willing to share the file where you made those changes and the version of stores you applied them to?

I'm experiencing the same issues including No global identifier provided (e.g., gtin, brand)

Thanks.

Re: Question about SCHEMA / header Module Offer or Product

Posted: Wed May 10, 2023 7:50 am
by Pierre_P
lecarlb wrote: Wed May 10, 2023 7:26 am I'm experiencing the same issues including No global identifier provided (e.g., gtin, brand)
Phoenix v1.0.8.21
If no gtin is specified then you will get this warning, Google will accept mpn instead(manufacterer part number).
mpn and brand are already specified in existing code.

We can certainly play around this for now as it could boost product performence and apearance in search
I think best is that a certified developer work on this, it becomes a rabit hole to accurately specify all the details required that will work for all users.

Re: Question about SCHEMA / header Module Offer or Product

Posted: Wed May 10, 2023 11:54 am
by Omar_one
Pierre_P wrote: Tue May 09, 2023 4:05 pm Thanks @burt
This solves the shipping part

Code: Select all

          $schema_product['offers']['shippingDetails'] = [
              '@type' => 'OfferShippingDetails',
              'shippingDestination' =>  [
                  '@type'  => 'DefinedRegion',
                  'addressCountry' => 'ZA',
              ],
          'deliveryTime' => [
                  '@type' => 'ShippingDeliveryTime',
              'handlingTime' => [
                  '@type' => 'QuantitativeValue',
                  'minValue' => '0',
                  'maxValue' => '1',
                  'unitCode' => 'd',
              ],
              'transitTime' => [
                  '@type' => 'QuantitativeValue',
                  'minValue' => '1',
                  'maxValue' => '5',
                  'unitCode' => 'd',
              ],
          ],
              'businessDays' => [
                  '@type' => 'OpeningHoursSpecification',
                  ],
                  'dayOfWeek' => [
              'https://schema.org/Monday',
              'https://schema.org/Tuesday',
              'https://schema.org/Wednesday',
              'https://schema.org/Thursday',
              'https://schema.org/Friday',
                  ],
              'cutoffTime' => '09:00:15Z',
              'shippingRate' => [
                  '@type' => 'MonetaryAmount',
                  'value' => '0',
                  'currency' => 'ZAR',
              ],
          ];
Hello @Pierre_P
as I have same issue
did you add the code above on ht_product_schema.php?
product_schema.JPG


Br
Omar

Re: Question about SCHEMA / header Module Offer or Product

Posted: Wed May 10, 2023 2:45 pm
by Pierre_P
Omar_one wrote: Wed May 10, 2023 11:54 am did you add the code above on ht_product_schema.php?
Yes i did, just below

Code: Select all

$schema_product['offers']['availability'] = $availability;
Pls, you need to customize to your region!

Code: Select all

          $schema_product['offers']['shippingDetails'] = [
              '@type' => 'OfferShippingDetails',
              'shippingDestination' =>  [
                  '@type'  => 'DefinedRegion',
                  'addressCountry' => 'ZA',
              ],
          'deliveryTime' => [
                  '@type' => 'ShippingDeliveryTime',
              'cutoffTime' => '09:00:2Z',
              'businessDays' => [
                  '@type' => 'OpeningHoursSpecification',
                  'dayOfWeek' => [
                      'Monday',
                      'Tuesday',
                      'Wednesday',
                      'Thursday',
                      'Friday',
                  ],
              ],
              'handlingTime' => [
                  '@type' => 'QuantitativeValue',
                  'minValue' => '0',
                  'maxValue' => '1',
                  'unitCode' => 'd',
              ],
              'transitTime' => [
                  '@type' => 'QuantitativeValue',
                  'minValue' => '1',
                  'maxValue' => '5',
                  'unitCode' => 'd',
              ],
          ],
              'shippingRate' => [
                  '@type' => 'MonetaryAmount',
                  'value' => '0',
                  'currency' => 'ZAR',
              ],
          ];