Interfejs Content API umożliwia określenie podatku i dostawy, które będą miały zastosowanie do wszystkich produktów na koncie, za pomocą usług shippingsettings i accounttax. Jeśli chcesz podać dokładniejsze informacje, możesz określić podatek i dostawę na poziomie produktu za pomocą usługi products.
Informacje o zasadach Google i pełnym zakresie opcji określania podatku i dostawy znajdziesz w tych artykułach w Centrum pomocy:
Pamiętaj, że atrybut tax
, a co za tym idzie korzystanie z usługi accounttax, dotyczy tylko produktów kierowanych na Stany Zjednoczone.
Usługi accounttax i shippingsettings Content API odzwierciedlają funkcje interfejsu użytkownika Merchant Center.
Prosty przykład
W przypadku opłat za dostawę w wysokości 8 euro we Francji i na podstawie stawek przewoźników w Stanach Zjednoczonych, gdzie każda usługa dostawy zajmuje 3–7 dni:
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 }, } ] }
Aby pobrać nazwy dostępnych przewoźników i usług, użyj metody getsupportedcarriers.
Złożony przykład
Aby utworzyć promocję bezpłatnej dostawy w stanach sąsiadujących z Nowym Jorkiem (bez naliczania opłat za dostawę), korzystać z UPS w pozostałych stanach USA i stosować różne podatki w poszczególnych stanach USA, użyj żądań do usług accounttax i shippingsettings interfejsu Content API w ten sposób: Najpierw skonfiguruj ustawienia dostawy:
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*" } ] } ] }
Uwaga: identyfikatory lokalizacji mogą reprezentować obszary administracyjne.
Następnie skonfiguruj opłaty podatkowe:
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" } // ... ] }
Uwaga: stawki przewoźnika są dostępne tylko w Stanach Zjednoczonych, Niemczech i Australii. Grupy lokalizacji są obecnie obsługiwane w Stanach Zjednoczonych i Australii.
Złożone reguły dostawy: tabele dwuwymiarowe i podtabele
Aby zdefiniować promocję dostawy w wysokości 7 PLN w Stanach Zjednoczonych, 3 PLN lub 5 PLN w przypadku zamówień o wadze powyżej 10 funtów w Nowym Jorku (w zależności od ceny zamówienia) oraz bezpłatną dostawę w przypadku zamówień o wadze poniżej 10 funtów, użyj tych wartości:
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" } ] } ] }
Złożone reguły dostawy: dzielenie etykiet wysyłki między usługami
W ustawieniach dostawy każda usługa dostawy może zawierać maksymalnie 20 grup stawek dostawy. Grupy stawek dostawy służą do rozróżniania stawek dostawy za pomocą etykiet wysyłki, co może sugerować, że za pomocą etykiet wysyłki można wymusić tylko 20 unikalnych stawek dostawy. Możesz jednak mieć maksymalnie 20 usług dostawy na kraj. Dzieląc stawki rozróżniane przez etykiety wysyłki na wiele usług w tym samym kraju, możesz rozróżnić do 400 unikalnych stawek dostawy za pomocą etykiet wysyłki.
Uwaga: jeśli masz kilka usług, każdy produkt w danym kraju jest sprawdzany pod kątem wszystkich usług dostawy w tym kraju, aby obliczyć możliwe stawki dostawy. Jeśli kilka usług zwraca różne stawki za ten sam produkt, zostanie użyta najniższa stawka.
Poniższy przykład dzieli 40 etykiet wysyłkowych z unikalnymi stawkami na 2 różne usługi. W tym przykładzie inne szczegóły zasobu dostawy, takie jak rzeczywiste stawki, są ukryte za wielokropkiem.
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": [ ... ] }
Podział etykiet wysyłki na grupy stawek może być konieczny nawet wtedy, gdy etykiety wysyłki mają taką samą stawkę za dostawę, ponieważ każda grupa stawek może mieć tylko 30 etykiet wysyłki w polu applicableShippingLabels
. Na przykład, jeśli wszystkie etykiety wysyłki mają taką samą strukturę stawek, shippingsettings
może obsługiwać do 12 000 etykiet wysyłki w jednym kraju: 30 etykiet wysyłki na grupę stawek, 20 grup stawek na usługę dostawy i 20 usług dostawy na kraj.
Więcej informacji znajdziesz w dokumentacji referencyjnej dotyczącej parametrów accounttax i shippingsettings.