0

I'm writing a feed from an e-shop, to give to facebook.

So far so good. The feed is in XML format, and the reference provides a sample, and the format for the shipping field in the item, within the feed, is:

<g:shipping>
    <g:country>UK</g:country>
    <g:service>Standard</g:service>
    <g:price>4.95 GBP</g:price>
</g:shipping>

However, the reference states that the format should be a comma-separated string, like this:

Blob with different prices for each country and region. 
Different regions are comma-separated. 
The format should be COUNTRY:STATE:SHIPPING_TYPE:PRICE.

e.g.

US:CA:Ground:9.99 USD, US:NY:Air:15.99 USD

Do you catch the contradiction?

If I try in my feed:

<g:shipping>US:CA:Ground:9.99 USD, US:NY:Air:15.99 USD</g:shipping>

I get errors, that country or price is missing.

So, I will have to stick to the sample.

The question is:

Which is the right way to provide multiple shipping zones in the feed?

The debugging tool here is not helping at all...

Do I repeat the g:shipping fieldset?

<g:shipping>
    <g:country>UK</g:country>
    <g:service>Standard</g:service>
    <g:price>4.95 GBP</g:price>
</g:shipping>
<g:shipping>
    <g:country>US</g:country>
    <g:service>Standard</g:service>
    <g:price>5.30 GBP</g:price>
</g:shipping>

Do I iterate within the fieldset?

<g:shipping>
    <g:country>UK</g:country>
    <g:service>Standard</g:service>
    <g:price>4.95 GBP</g:price>
    <g:country>US</g:country>
    <g:service>Standard</g:service>
    <g:price>5.30 GBP</g:price>
</g:shipping>

Or what, if anything, do I have to do to have multiple zones, before switching to CSV (which I don't want to do, but I will if I have to: CSV supports the comma-separated format for multiple zones)?

Ruby Racer
  • 5,690
  • 1
  • 26
  • 43
  • I found the answer [here](https://support.google.com/merchants/answer/6324484?hl=en). It is the first case: iterate the fieldset. – Ruby Racer Nov 18 '17 at 23:00

2 Answers2

0

I'm answering this here for future reference.

The template used by Facebook is the one provided by Google Merchant Center.

As stated here

Include the optional sub-attributes if you need them. 
To specify a shipping cost for different delivery locations, 
submit multiple shipping attributes including the relevant sub-attributes.

<g:shipping>
  <g:country>US</g:country>
  <g:region>MA</g:region>
  <g:service>Ground</g:service>
  <g:price>6.49 USD</g:price>
</g:shipping>
<g:shipping>
  <g:country>US</g:country>
  <g:region>MA</g:region>
  <g:service>Express</g:service>
  <g:price>15.99 USD</g:price>
</g:shipping>
Ruby Racer
  • 5,690
  • 1
  • 26
  • 43
  • Doesn't seem to be the case anymore - I get warnings about "missing information" such as "shipping_price_currency" when I use this format - and no, it still doesn't actually match their documentation - it sorta wants the above format, but needs "shipping_country", "shipping_price_value" and "shipping_price_currency". Checking to see if it's an *old* validation that doesn't actually affect the product (what! Update documentation? As a modern bleeding edge technology company? Why would we do that? Only those "in the know" [i.e. my buddy] should be able to use my code!) – LeadDreamer Oct 26 '20 at 20:38
0

For anyone gets warnings about shipping_price_value, shipping_price; If you are using php and SimpleXMLElement add xmlns:g: to define xml namespace otherwise facebook throws warnings.

Interestingly this only affects shipping fields.

$shipping = $item->addChild('xmlns:g:shipping');
$shipping->addChild('xmlns:g:country', 'TR');
$shipping->addChild('xmlns:g:service', 'Karayolu');
$shipping->addChild('xmlns:g:price', '14.90 TRY');
Peter Csala
  • 17,736
  • 16
  • 35
  • 75