Charles Delfs
Charles Delfs

Reputation: 11

BigCommerce API creates repeating Order-Products lines when Updating an Order

I'm finding that when I update an order with the BigCommerce API that the Product line items of the Order are getting duplicated. It seems that even though I pass a single line item within my Order update JSON Object, I would get two Lines back (Order Products).

I am placing the update call as documented here: https://developer.bigcommerce.com/api/stores/v2/orders#update-an-order

The update is successful but my original product is now two product lines. It appears as though BC is interpreting what I am sending as new Product lines and not replacing / updating the existing ones.

I am passing the 'id' for the orderProducts.

Is there something I need to pass to indicate the line items are to be updated and not created new?enter code here

Here is the JSON I am sending:

{
  "customer_id": 1,
  "date_created": "Mon, 14 Sep 2015 19:28:01 +0000",
  "status_id": 11,
  "base_shipping_cost": "0.0000",
  "shipping_cost_ex_tax": "0.0000",
  "shipping_cost_inc_tax": "0.0000",
  "base_handling_cost": "0.0000",
  "handling_cost_ex_tax": "0.0000",
  "handling_cost_inc_tax": "0.0000",
  "base_wrapping_cost": "0.0000",
  "wrapping_cost_ex_tax": "0.0000",
  "wrapping_cost_inc_tax": "0.0000",
  "total_ex_tax": "34.0000",
  "total_inc_tax": "34.0000",
  "items_total": 16,
  "items_shipped": 0,
  "payment_method": "Manual",
  "refunded_amount": "0.0000",
  "order_is_digital": "false",
  "ip_address": "64.231.103.57",
  "geoip_country": "Canada",
  "geoip_country_iso2": "CA",
  "discount_amount": "0.0000",
  "ebay_order_id": 0,
  "billing_address": {
    "first_name": "Charles",
    "last_name": "Delfs",
    "company": "Delfs Eng",
    "street_1": "50 Moore St.",
    "street_2": "Box 1428",
    "city": "Bradford",
    "state": "Ontario",
    "zip": "L3Z 2B7",
    "country": "Canada",
    "country_iso2": "CA",
    "phone": "",
    "email": "[email protected]"
  },
  "products": [{
    "id": 253,
    "product_id": 113,
    "name": "Hammer and Anvils 6",
    "sku": "",
    "price_ex_tax": "24.0000",
    "price_inc_tax": "24.0000",
    "quantity": 1,
    "ebay_item_id": "",
    "product_options": []
  }, {
    "id": 254,
    "product_id": 113,
    "name": "Hammer and Anvils 6",
    "sku": "",
    "price_ex_tax": "24.0000",
    "price_inc_tax": "24.0000",
    "quantity": 1,
    "ebay_item_id": "",
    "product_options": []
  }],
  "shipping_addresses": []
}

Response from BC Support ...

"Thank you for contacting Bigcommerce!

"I hate to say that details of updating of order line items is sparse because it is not fully built out at this time. There are ways to update existing line items - similar to what you have tried but you would need to include an "id" parameter for an existing product in the order if you wanted to overwrite an existing line item. The problem though is the totals calculations do not appear to come out correct when making updates to things like existing products. I have seen similar strangeness making changes to existing shipping addresses. Now you are able to additionally update "total_inc_tax" and "total_ex_tax" to make that accurate but the "total_tax" line item still seems to come out incorrect in some cases.

It really is something that was not properly addressed with the v2 API and needs work in the next version that is going to be coming out. In the meantime my advice would be to not update existing orders in this way and instead create a new order and trash the original if you need to update products or the shipping address. Updating other details on the order do not seem to have these same negative consequences.

I am sorry as I am sure this is not what you wanted to hear. Please let me know if you have any questions about the above and I will do what I can to assist."

Upvotes: 1

Views: 416

Answers (1)

Charles Delfs
Charles Delfs

Reputation: 11

Solution: My code was not mapping the returned BC Line information to the correct record and subsequently creating duplicates.

A fundamental problem still exists: The API allows line item editing but NOT deleting of line items. Their recommendation of deleting and recreating the order will break all the 3rd party apps that connect via the orders id!

Upvotes: 0

Related Questions