curl -X POST https://example.com/wp-json/cocart/v2/cart/add-item \ -H "Content-Type: application/json" \ -d '{ "id": "129", "quantity": "1", "price": 24 }'
This is the most simplest way of adding a product to the cart with a custom price.
The price is not changing, what am I doing wrong?
You may have restricted the product or all products from being able to add the product to cart with a custom price. Or you have set a salt key and have not passed it via the headers.
How do I add the salt key to the request?
Simply modify the request by adding the salt key to the header. Make sure that the header includes x-cocart-salt
followed by your unique salt key.
curl -X POST https://example.com/wp-json/cocart/v2/cart/add-item \ -H "Content-Type: application/json" \ -H "x-cocart-salt: cbb03bc3fc55dc75d39b2f20cc5b6071" \ -d '{ "id": "129", "quantity": "1", "price": 24 }'
Was this helpful to you?
Did you like the article/guide or would you like to give some feedback? Click on one of the buttons and let us know your opinion!