Product added to "Checkout" through API is not persisting
in Development
Hello API team,
I have developed a solution for a client. On checkout page our script sends "checkout id" to our back end, and then our back end makes a POST request to API to add a specific product to checkout.
This functionality used to work. However it started not working. I inspected situation and concluded this is happening. When we send the request it indeed adds the product to "checkout". However when ever anything else is updated, email, shipment method etc. the product is removed.
I am unable to fix this issue. Can someone assist me or point me to a document which would explain why some products would not persist in "checkout" entity.
Thanks.
3 comments
Hi @Malipetek, Could you could share an example of a payload (including URL) that would lead to a product being subsequently removed from the checkout, this would be helpful in diagnosing. Could you also PM me the shopID and variantID of any affected products so I can look into this?
Thanks!
Lightspeed HQ
Hi @Leah thanks for the response!
Below is load of POST to add product
I am attaching loads of consequent 2 GET requests to check checkout data. I did not interact with checkout in between 2 GET requests this time.
---------------- Request ---------------
=== URL ===
https://api_key:[email protected]/us/checkouts/6913***/products.json
=== Request Type ===
POST
=== Payload ===
{
"variant_id": "4059***",
"special_price_incl": 10,
"quantity": 1
}
---------------- Response ---------------
=== Header ===
date: Fri, 05 Jun 2020 21:38:11 GMT
content-type: application/json; charset=utf-8
x-ratelimit-limit: 1000/12000/288000
x-ratelimit-remaining: 993/11975/287202
x-ratelimit-reset: 110/1310/8510
cf-cache-status: DYNAMIC
cf-request-id: 03280493110000a798010ae200000001
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
cf-ray: 59ed09fe8e8ca798-IST
alt-svc: h3-27=":443"; ma=86400
=== Body ===
{
"id": 57055***,
"cart_id": 34883***,
"created_at": "2020-06-05T21:38:10+00:00",
"updated_at": "2020-06-05T21:38:11+00:00",
"product_id": 24357***,
"variant_id": 40596***,
"is_custom": null,
"custom_checksum": null,
"custom_data": [],
"quantity": 1,
"has_discount": false,
"discount_percentage": "0",
"tax_rate": 0,
"base_weight": 1587,
"base_volume": 0,
"base_colli": 0,
"base_price_excl": 10,
"base_price_incl": 10,
"base_price_cost": 0,
"special_price_excl": 10,
"special_price_incl": 10,
"special_discount_value": null,
"special_discount_type": null,
"custom_excl": "0",
"custom_incl": "0",
"unit_price": null,
"unit_unit": null,
"weight": 1587,
"volume": "0",
"colli": 0,
"price_tax": "0",
"price_excl": 10,
"price_incl": 10,
"price_cost": "0",
"discount_excl": "0",
"discount_incl": "0",
"additional_cost_base_incl": null,
"additional_cost_base_excl": null,
"additional_cost_price_incl": null,
"additional_cost_price_excl": null,
"title": "Delivery Tip",
"fulltitle": "Delivery Tip",
"variant": null,
"brand_name": null,
"description": null,
"article_code": 24357***,
"ean": null,
"sku": null,
"size_x": 0,
"size_y": 0,
"size_z": 0,
"image_id": 0,
"image_thumb": "https:\/\/cdn.shoplightspeed.com\/assets\/blank.gif?2019-08-16",
"image_src": "https:\/\/cdn.shoplightspeed.com\/assets\/blank.gif?2019-08-16",
"url": "driver-tip.html",
"stock_available": true,
"stock_on_stock": false,
"stock_track": false,
"stock_level": 0,
"stock_minimum": 1,
"stock_maximum": 10000
}
Hi,
After a long search I found out why it went wrong in the checkout that was because the product you wanted to add the “delivery tip” was a hidden product. It is not possible to work with hidden products hidden is hidden, so they cannot be bought at first. You can add the product to the checkout(via API) but when the checkout is refreshed it recognizes that the product is hidden and it is removed. You can test this easily by set the product(24357492) to visible and test it again.
I hope this helps.