Tax lines won't automatically generate in Shop

2019-09-14 16:12发布

问题:

I am posting the following to the Shopify API order endpoint:

    {
  "order": {
    "email": "some@email.com",
    "financial_status": "paid",
    "fulfillment_status": null,
    "send_receipt": true,
    "send_fulfillment_receipt": true,
    "note": "Created by somename",
    "line_items": [
      {
        "variant_id": 21718275463,
        "quantity": 1,
        "price": 99,
        "requires_shipping": true,
        "product_id": 6820646151
      },
      {
        "variant_id": 21717700871,
        "quantity": 1,
        "price": 1000,
        "requires_shipping": true,
        "product_id": 6820646151
      },
      {
        "variant_id": 21717690055,
        "quantity": 1,
        "price": 555,
        "requires_shipping": true,
        "product_id": 6821668807
      }
    ],
    "processing_method": "offsite",
    "shipping_address": {
      "first_name": "Chris",
      "address1": "10101 Musick Road",
      "phone": "9999999999",
      "city": "St. Louis",
      "zip": "63123",
      "province": "MO",
      "country": "United States",
      "last_name": "Becker",
      "name": "Chris Becker",
      "country_code": "US",
      "province_code": "MO"
    },
    "source_name": "somename",
    "taxes_included": false,
    "shipping_lines": [
      {
        "title": "standard",
        "price": 0.00,
        "code": null,
        "source": "brand owner on shopify",
        "carrier_identifier": null,
        "tax_lines": null
      }
    ],
    "tags": "some Order"
  }
}

and receiving a response without tax lines that are filled. I have seen on the shopify forum that the taxlines are supposed to then be automatically calculated and filled by shopify. I tried doing it with a customer as well but that didn't work either.

回答1:

The Orders API will not auto-calculate the taxes but if your app knows how much they are then you can include this data using tax_lines and total_tax:

{
  "order": {
    "line_items": [{
      "title": "Big Brown Bear Boots",
      "price": 74.99,
      "quantity": 3,
      "tax_lines": [{
        "price": 13.50,
        "rate": 0.06,
        "title": "State tax"
      }]
    }],
    "total_tax": 13.50
  }
}


标签: rest shopify