How can i apply Coupon code in magento2 using REST API. which order should i call the rest apis in order to get totals after applying coupon codes.
Solved! Go to Solution.
Hello @pratap_penmetsa
If you are not aware with API's Kindly refer to Swagger from Magento2
http://devdocs.magento.com/swagger/#/
Here you can find
quoteCouponManagementV1
Coupon management service interface.
PUT /V1/carts/{cartId}/coupons/{couponCode}
You can use this API once your quote is ready you can apply after that.
Hello @pratap_penmetsa
If you are not aware with API's Kindly refer to Swagger from Magento2
http://devdocs.magento.com/swagger/#/
Here you can find
quoteCouponManagementV1
Coupon management service interface.
PUT /V1/carts/{cartId}/coupons/{couponCode}
You can use this API once your quote is ready you can apply after that.
I am using the same PUT /V1/carts/{cartId}/coupons/{couponCode} Api to apply coupon for a cart. But I am getting below error.
{
"message": "No such entity with %fieldName = %fieldValue",
"parameters": {
"fieldName": "cartId",
"fieldValue": 2
}
}
As mentioned by you, I should be using this api only once the quote is ready. How can I check or which API response will show me that the quote is ready?
@Manish Mittal Any update on this?
@sarita_furtado wrote:
I am using the same PUT /V1/carts/{cartId}/coupons/{couponCode} Api to apply coupon for a cart. But I am getting below error.
{
"message": "No such entity with %fieldName = %fieldValue",
"parameters": {
"fieldName": "cartId",
"fieldValue": 2
}
}
As mentioned by you, I should be using this api only once the quote is ready. How can I check or which API response will show me that the quote is ready?
Hello @pratap_penmetsa
The Magento 2 REST API identifies various functions which can be used to perform requests and receive responses. A developer can perform these interactions by using the HTTP protocol.
To apply Coupon code in Magento 2, Firstly you will have to set up a new cart price rule that is used to count the discount.
- Create the new cart price rule and set it up in Marketing > Promotions > Cart Price Rules.
- Open the Rule Information and select the particular Coupon.
- Enter the value in Coupon Code.
- Specify how much time the coupon can be used.
- Configure the rest of the Cart Price Rule and save all the changes that you have made.