ภาษีและการจัดส่งระดับบัญชี

Content API ช่วยให้คุณระบุภาษีและการจัดส่งที่จะมีผลกับผลิตภัณฑ์ทั้งหมดภายในบัญชีผ่านบริการ shippingsettings และ accounttax หากต้องการความแม่นยำมากขึ้น คุณสามารถระบุภาษีและการจัดส่งในระดับสินค้าผ่านบริการ products ได้

ดูข้อมูลเกี่ยวกับนโยบายของ Google และตัวเลือกทั้งหมดสำหรับการระบุภาษีและการจัดส่งได้ในบทความในศูนย์ช่วยเหลือต่อไปนี้

โปรดทราบว่าแอตทริบิวต์ tax และการใช้บริการภาษีของบัญชีจึงใช้ได้กับผลิตภัณฑ์ที่กำหนดเป้าหมายเป็นสหรัฐอเมริกาเท่านั้น

บริการ Content API ของ accounttax และ shippingsettings จะจำลองฟังก์ชันการทำงานของ UI ของ Merchant Center

ตัวอย่างง่ายๆ

สำหรับค่าจัดส่ง 8 ยูโรในฝรั่งเศส และอิงตามอัตราของผู้ให้บริการขนส่งในสหรัฐอเมริกา ซึ่งบริการจัดส่งแต่ละรายการใช้เวลา 3-7 วันในการนำส่ง

PUT /content/v2.1/<merchant_id>/shippingsettings/<account_id>
{
  "accountId": <account_id>,
  "services": [
    {
      "name": "Livraison Prioritaire",
      "deliveryCountry": "FR",
      "currency": "EUR",
      "rateGroups": [
        {
          "singleValue": {
            "flatRate": { "currency": "EUR", "value": "8" }
          }
        }
      ],
      "active": true,
      "deliveryTime": { "minTransitTimeInDays": 3, "maxTransitTimeInDays": 7 }
    },
    {
      "name": "UPS in US",
      "deliveryCountry": "US",
      "currency": "USD"
      "rateGroups": [
        {
          "singleValue": { "carrierRateName": "ups" },
          "carrierRates": [
            {
              "name": "ups",
              "carrierName": "UPS",
              "carrierService": "Ground",
              "originPostalCode": "10011"
            }
          ]
        }
      ],
      "active": true,
      "deliveryTime": { "minTransitTimeInDays": 3, "maxTransitTimeInDays": 7 },
    }
  ]
}

หากต้องการดึงชื่อผู้ให้บริการและบริการที่มี ให้ใช้วิธี getsupportedcarriers

ตัวอย่างที่ซับซ้อน

หากต้องการสร้างโปรโมชันจัดส่งฟรีในรัฐต่างๆ รอบนิวยอร์ก (โดยไม่เรียกเก็บค่าจัดส่ง) ให้ใช้ UPS สำหรับส่วนที่เหลือของสหรัฐอเมริกา และหากต้องการใช้ภาษีที่แตกต่างกันสำหรับแต่ละรัฐในสหรัฐอเมริกา ให้ใช้คำขอไปยังบริการ accounttax และ shippingsettings ของ Content API ดังนี้ ก่อนอื่นให้กำหนดค่าการตั้งค่าการจัดส่งโดยทำดังนี้

PUT /content/v2.1/<merchant_id>/shippingsettings/<account_id>
{
  "accountId": <account_id>,
  "services": [
    {
      "name": "Eligible for free shipping",
      "deliveryCountry": "US",
      "rateGroups": [
        {
          "mainTable": {
            "rowHeaders": {
              "locations": [
                { "locationIds": ["21167"] }, // NY
                { "locationIds": ["21164", "21139"] }  // NJ, CT
              ]
            },
            "rows": [
              {
                "cells": [
                  {
                    "flatRate": { "currency": "USD", "value": "0" }
                  }
                ]
              },
              {
                "cells": [
                  {
                    "flatRate": { "currency": "USD", "value": "0" }
                  }
                ]
              }
            ]
          }
        }
      ],
      "active": true,
      "deliveryTime": { "minTransitTimeInDays": 3, "maxTransitTimeInDays": 7 },
      "currency": "USD"
    },
    {
      "name": "UPS in US",
      "deliveryCountry": "US",
      "rateGroups": [
        {
          "singleValue": { "carrierRateName": "UPS mainland" },
          "carrierRates": [
            {
              "name": "UPS mainland",
              "carrierName": "UPS",
              "carrierService": "Ground",
              "originPostalCode": "10011",  // currently only US, AU, and DE postal codes
              "percentageAdjustment": "1.05",
              "flatAdjustment": { "currency": "USD", "value": "0.75" }
            }
          ]
        }
      ],
      "active": true,
      "deliveryTime": { "minTransitTimeInDays": 3, "maxTransitTimeInDays": 7 },
      "currency": "USD"
    }
   ],
  "postalCodeGroups": [
    {
      "name": "More cities",  // An alternative using postal codes
      "country": "US",
      "postalCodeRanges": [
        { "postalCodeRangeBegin": "94041" },
        { "postalCodeRangeBegin": "94042" },
        { "postalCodeRangeBegin": "94043", "postalCodeRangeEnd": "94045" },
        { "postalCodeRangeBegin": "9405*" },
        { "postalCodeRangeBegin": "9406*", "postalCodeRangeEnd": "9408*" }
      ]
    }
  ]
}

โปรดทราบว่าคุณใช้รหัสสถานที่เพื่อแสดงพื้นที่การบริหารได้

จากนั้นกำหนดค่าการเรียกเก็บภาษีโดยทำดังนี้

PUT /content/v2.1/<merchant_id>/accounttax/<account_id>
{
  "accountId": <account_id>,
  "rules": [
    {
      "country": "US",  // currently only US is supported, may be omitted
      "locationId": 21167,
      "useGlobalRate": true,
      "shippingTaxed": false
    },
    {
      "locationId": 21137,
      "useGlobalRate": false,
      "shippingTaxed": true,
      "ratePercent": "2.15"
    }
    // ...
  ]
}

หมายเหตุ: อัตราของผู้ให้บริการขนส่งมีให้บริการเฉพาะในสหรัฐอเมริกา เยอรมนี และออสเตรเลียเท่านั้น ปัจจุบันกลุ่มสถานที่ตั้งรองรับในสหรัฐอเมริกาและออสเตรเลีย

กฎการจัดส่งที่ซับซ้อน: ตาราง 2 มิติและตารางย่อย

หากต้องการกำหนดโปรโมชันการจัดส่งที่ $7 ในสหรัฐอเมริกา, $3 หรือ $5 สำหรับคำสั่งซื้อที่มีน้ำหนักมากกว่า 10 ปอนด์ในนิวยอร์กซิตี้ โดยขึ้นอยู่กับราคาของคำสั่งซื้อ และจัดส่งฟรีสำหรับคำสั่งซื้อที่มีน้ำหนักต่ำกว่านั้น ให้ใช้ค่าต่อไปนี้

PUT /content/v2.1/<merchant_id>/shippingsettings/<account_id>
{
  "accountId": <account_id>,
  "services": [
    {
      "name": "Custom shipping rules",
      "deliveryCountry": "US",
      "rateGroups": [
        {
          "mainTable": {
            "rowHeaders": {
              "postalCodeGroupNames": [ "NYC", "all other locations" ]
            },
            "columnHeaders": {
              "weights": [
                { "unit": "lb", "value": "10" },
                { "unit": "lb", "value": "infinity" }
              ]
            },
            "rows": [
              {
                "cells": [
                  { "flatRate": { "value": "0", "currency": "USD" } },
                  { "subtableName": "NYC large packages" }
                ]
              },
              {
                "cells": [
                  { "flatRate": { "value": "7", "currency": "USD" } },
                  { "flatRate": { "value": "7", "currency": "USD" } }
                ]
              }
            ]
          },
          "subtables": [
            {
              "name": "NYC large packages",
              "rowHeaders": {
                "prices": [
                  {"value": "100", "currency": "USD"},
                  {"value": "infinity", "currency": "USD"}]
              },
              "rows": [
                {
                  "cells": [
                    { "flatRate": { "value": "3", "currency": "USD" } }
                  ]
                },
                {
                  "cells": [
                    { "flatRate": { "value": "5", "currency": "USD" } }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "active": true,
      "currency": "USD",
      "deliveryTime": { "minTransitTimeInDays": 3, "maxTransitTimeInDays": 7 }
    }
  ],
  "postalCodeGroups": [
    {
      "name": "NYC",  // Approximation of NYC using postal codes
      "country": "US",
      "postalCodeRanges": [
        { "postalCodeRangeBegin": "10000", postalCodeRangeEnd: "11999" }
      ]
    }
  ]
}

กฎการจัดส่งที่ซับซ้อน: การแยกป้ายกำกับการจัดส่งในบริการต่างๆ

ใน shippingsettings บริการจัดส่งแต่ละรายการจะมีกลุ่มอัตราค่าจัดส่งได้สูงสุด 20 กลุ่ม เนื่องจากใช้กลุ่มอัตราค่าจัดส่งเพื่อแยกความแตกต่าง อัตราค่าจัดส่งผ่านป้ายกำกับการจัดส่ง จึงอาจดูเหมือนว่าบังคับใช้อัตราค่าจัดส่งที่ไม่ซ้ำกันได้เพียง 20 รายการ ผ่านป้ายกำกับการจัดส่ง อย่างไรก็ตาม คุณมีบริการจัดส่งได้สูงสุด 20 รายการต่อประเทศ การแยกอัตราค่าจัดส่ง ซึ่งแยกตามป้ายกำกับการจัดส่งในบริการหลายรายการสำหรับประเทศเดียวกัน จะช่วยให้คุณแยกอัตราค่าจัดส่งที่ไม่ซ้ำกันได้สูงสุด 400 รายการผ่านป้ายกำกับการจัดส่ง

หมายเหตุ: หากมีบริการหลายรายการ ระบบจะตรวจสอบผลิตภัณฑ์แต่ละรายการสำหรับประเทศหนึ่งๆ กับบริการจัดส่งทั้งหมดของประเทศนั้นเพื่อคำนวณอัตราค่าจัดส่งที่เป็นไปได้ หากบริการหลายรายการแสดงอัตราค่าจัดส่งที่แตกต่างกันสำหรับผลิตภัณฑ์เดียวกัน ระบบจะใช้อัตราค่าจัดส่งที่ต่ำที่สุด

ตัวอย่างด้านล่างจะแบ่งป้ายกำกับการจัดส่ง 40 รายการโดยใช้อัตราที่ไม่ซ้ำกันในบริการ 2 รายการที่แตกต่างกัน ตัวอย่างนี้ซ่อนรายละเอียดอื่นๆ ของทรัพยากรการจัดส่ง เช่น อัตราค่าจัดส่งจริง ไว้หลังเครื่องหมายจุดไข่ปลา

PUT /content/v2.1/<merchant_id>/shippingsettings/<account_id>
{
  "accountId": <account_id>,
  "services": [
    {
      "name": "labels_0_19",
      "deliveryCountry": "US",
      "active": true,
      "currency": "USD",
      "deliveryTime": { "minTransitTimeInDays": 3, "maxTransitTimeInDays": 7 }
      "rateGroups": [
        { "applicableShippingLabels": ["shipping_label_0"], ... }
        { "applicableShippingLabels": ["shipping_label_1"], ... }
        { "applicableShippingLabels": ["shipping_label_2"], ... }
        { "applicableShippingLabels": ["shipping_label_3"], ... }
        { "applicableShippingLabels": ["shipping_label_4"], ... }
        { "applicableShippingLabels": ["shipping_label_5"], ... }
        { "applicableShippingLabels": ["shipping_label_6"], ... }
        { "applicableShippingLabels": ["shipping_label_7"], ... }
        { "applicableShippingLabels": ["shipping_label_8"], ... }
        { "applicableShippingLabels": ["shipping_label_9"], ... }
        { "applicableShippingLabels": ["shipping_label_10"], ... }
        { "applicableShippingLabels": ["shipping_label_11"], ... }
        { "applicableShippingLabels": ["shipping_label_12"], ... }
        { "applicableShippingLabels": ["shipping_label_13"], ... }
        { "applicableShippingLabels": ["shipping_label_14"], ... }
        { "applicableShippingLabels": ["shipping_label_15"], ... }
        { "applicableShippingLabels": ["shipping_label_16"], ... }
        { "applicableShippingLabels": ["shipping_label_17"], ... }
        { "applicableShippingLabels": ["shipping_label_18"], ... }
        { "applicableShippingLabels": ["shipping_label_19"], ... }
      ]
    },
    {
      "name": "labels_20_39",
      "deliveryCountry": "US",
      "active": true,
      "currency": "USD",
      "deliveryTime": { "minTransitTimeInDays": 3, "maxTransitTimeInDays": 7 }
      "rateGroups": [
        { "applicableShippingLabels": ["shipping_label_20"], ... }
        { "applicableShippingLabels": ["shipping_label_21"], ... }
        { "applicableShippingLabels": ["shipping_label_22"], ... }
        { "applicableShippingLabels": ["shipping_label_23"], ... }
        { "applicableShippingLabels": ["shipping_label_24"], ... }
        { "applicableShippingLabels": ["shipping_label_25"], ... }
        { "applicableShippingLabels": ["shipping_label_26"], ... }
        { "applicableShippingLabels": ["shipping_label_27"], ... }
        { "applicableShippingLabels": ["shipping_label_28"], ... }
        { "applicableShippingLabels": ["shipping_label_29"], ... }
        { "applicableShippingLabels": ["shipping_label_30"], ... }
        { "applicableShippingLabels": ["shipping_label_31"], ... }
        { "applicableShippingLabels": ["shipping_label_32"], ... }
        { "applicableShippingLabels": ["shipping_label_33"], ... }
        { "applicableShippingLabels": ["shipping_label_34"], ... }
        { "applicableShippingLabels": ["shipping_label_35"], ... }
        { "applicableShippingLabels": ["shipping_label_36"], ... }
        { "applicableShippingLabels": ["shipping_label_37"], ... }
        { "applicableShippingLabels": ["shipping_label_38"], ... }
        { "applicableShippingLabels": ["shipping_label_39"], ... }
      ]
    }
  ],
  "postalCodeGroups": [ ... ]
}

การแยกป้ายกำกับการจัดส่งในกลุ่มอัตราค่าจัดส่งอาจจำเป็น แม้ว่าป้ายกำกับการจัดส่งจะใช้อัตราค่าจัดส่งเดียวกัน เนื่องจากแต่ละกลุ่มอัตราค่าจัดส่ง จะมีป้ายกำกับการจัดส่งได้เพียง 30 รายการภายใน ฟิลด์ applicableShippingLabels ตัวอย่างเช่น หากป้ายกำกับการจัดส่งทั้งหมดมีโครงสร้างอัตราเดียวกัน shippingsettings จะรองรับป้ายกำกับการจัดส่งได้สูงสุด 12,000 รายการสำหรับประเทศเดียว โดยมีป้ายกำกับการจัดส่ง 30 รายการต่อกลุ่มอัตรา 20 กลุ่มอัตราต่อบริการจัดส่ง และ 20 บริการจัดส่งต่อประเทศ

ดูข้อมูลเพิ่มเติมได้ที่เอกสารอ้างอิงสำหรับ accounttax และ shippingsettings