cancel
Showing results for 
Search instead for 
Did you mean: 

Get list of available coupons on a cart id

Get list of available coupons on a cart id

Is there any api in magento to get list of all coupons appreciable to a corresponding cart id. can we get rules for a cart id abd then find coupon through it

12 REPLIES 12

Re: Get list of available coupons on a cart id

@gelanivishal Do you know any solution for this?

Re: Get list of available coupons on a cart id

Hello @Sahil_coder ,

 

I need to check it, I'll let you know once find a solution for it.

 

--
If my answer is useful, please Accept as Solution & give Kudos

 

Re: Get list of available coupons on a cart id

Hello @Sahil_coder ,

 

I'm not sure, You want get list of order in which coupon code is applied. If you want like this then please check below api call

 

 

 

Method: GET

URL: {{website.url}}/index.php/rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=coupon_code&searchCriteria[filter_groups][0][filters][0][value]&searchCriteria[filter_groups][0][filters][0][condition_type]=notnull

 

Headers: 
Authorization: bearer {{token}}

 

Please check more information here https://www.screencast.com/t/mhFUYmsKo

 

In response, You get all orders in coupon code applied.

 

--
If my answer is useful, please Accept as Solution & give Kudos
 

 

--
If my answer is useful, please Accept as Solution & give Kudos

Re: Get list of available coupons on a cart id

 

@gelanivishal 

I want when person add items in cart and go to checkout page show all coupons that can be applied to that cart , it can contains multiple items

 

For example -  As you got to checkout page in zomato,myntra they show you a list of coupons that can be applied on your order . so you can pick one and place order. 

Re: Get list of available coupons on a cart id

@gelanivishal any solution you got?

Re: Get list of available coupons on a cart id

Hello @Sahil_coder ,

 

I have checked in that case but didn't find any solution for now.

By default Magento, didn't provide this type functionality, You need to create custom functionality in that case.

 

--
If my answer is useful, please Accept as Solution & give Kudos

 

Re: Get list of available coupons on a cart id

@gelanivishal 

Is there any way like ,this gives rules applied on cart 

 

$appliedRuleIds = Mage::getSingleton('checkout/session')->getQuote()->getAppliedRuleIds();

 

is there some way to get all applicable rules on a cart ?

Re: Get list of available coupons on a cart id

Hello @Sahil_coder ,

 

We can use \Magento\Quote\Model\Quote\Item $item to check the applied rules.

vendor/magento/module-sales-rule/Model/Quote/Discount.php

$item->getAppliedRuleIds();
$item->getDiscountAmount();

See a good example here: vendor/magento/module-sales-rule/Observer/SalesOrderAfterPlaceObserver.php

In database, we should take a look at quote_item table

 

--
If my answer is useful, please Accept as Solution & give Kudos

Re: Get list of available coupons on a cart id

its shows list of applied rule , i need to get list of applicable rules