Hot answers tagged

21 votes
Accepted

How can i hide Discount Code form checkout payment page in Magento 2?

Use below CSS for hiding discount block. .checkout-index-index .payment-option._collapsible.opc-payment-additional.discount-code { display: none; } Edit app/code/vendor/Module/view/frontend/...
user avatar
17 votes
Accepted

Grand Total not updated when discount code is applied

Please follow the below steps might be useful. Path:- app/code/core/Mage/Sales/Model/Config/Ordered.php Comment this code /** * Aggregate before/after information from all items and ...
user avatar
13 votes
Accepted

magento2.2 - programmatically create coupon

Create CouponCode.php file at magento root and add below code in this file. After run this file in browser and check admin side. <?php use Magento\Framework\App\Bootstrap; /** * If your ...
user avatar
  • 9,522
12 votes
Accepted

How to get total discount amount of Coupon Code for all items in the cart

$quote2 = Mage::getSingleton('checkout/session')->getQuote(); $discountTotal = 0; foreach ($quote2->getAllItems() as $item){ $discountTotal += $item->getDiscountAmount(); }
user avatar
  • 195k
10 votes

How to get total discount amount of Coupon Code for all items in the cart

Magento saves each item respective discount on sales_flat_quote_item table at column discount_amount. This Discount Amount is stored incurrent currency. For getting total discount of current ...
user avatar
  • 75.7k
9 votes
Accepted

Magento Coupons limit per use o per customer not working

It's a known magento bug. Magento does not track coupons with empty discount (as in your case) Correct settings are: Use per coupon = 0 or empty, Use per client = 1, And modify the code in the ...
user avatar
  • 6,500
8 votes

Tax calculation after discount on Magento incorrect

Stumbled across this whilst trying to find a solution to a similar issue. Anyway, I resolved my problem and this seemed like the most relevant place to share my solution. Hopefully it will help ...
user avatar
  • 399
8 votes
Accepted

"Stop Further Rules Processing" not working on coupons?

I think you misunderstood what "Stop Further Rules Processing" means. It means that if there are multiple discount rules valid for one cart and your rule with "Stop further rules processing" is ...
user avatar
  • 195k
8 votes

Magento 2 - There is an event or method to "plug-in" when the coupon is removed from the cart/quote in the checkout flow?

Yes there is. The event you're looking for is controller_action_predispatch_checkout_cart_couponPost This is generic event that is dispatched before the action class that adds/removes the coupon is ...
user avatar
8 votes

How can i hide Discount Code form checkout payment page in Magento 2?

Add checkout_index_index.xml at your custom module app/code/vendor/Module/view/frontend/layout/checkout_index_index.xml Add below code to it. <?xml version="1.0"?> <!-- /** * Copyright © ...
user avatar
6 votes

Grand Total not updated when discount code is applied

Had this same exact problem (#1) on CE 1.9 running PHP 7, applying the Inchoo "PHP 7 compatibility extension for Magento 1" solved the issue! https://github.com/Inchoo/Inchoo_PHP7
user avatar
  • 562
6 votes
Accepted

coupon code should apply once we cancel the order

This is default Magento behaviour - if the payment fails / the order is canceled before it, then the coupon code will not be free to be reused. There're few modules that change this behaviour. Quick ...
user avatar
  • 2,069
6 votes
Accepted

Working of discount coupons on the checkout page in Magento 2.2.2

1) For customer account: /V1/carts/mine/coupons/:couponCode I just explain how sale rules work for customer logged a) Set coupon: vendor/magento/module-quote/etc/webapi.xml <route url="/V1/...
user avatar
5 votes

How can I give first time customers a discount on their next order?

I would suggest to create a new discount type "cashback". This can be done using this observer "adminhtml_block_salesrule_actions_prepareform". Once this option is added then you can apply the ...
user avatar
  • 1,481
5 votes
Accepted

Apply discount to only 1 item in the cart via Shopping Cart Price Rules

Yes, there is no corresponding condition in the default magento shopping cart rules. And yes, there are some extensions at the magento connect. Search for "special promotions" or "advanced promotions" ...
user avatar
  • 6,500
5 votes

How to create a shopping cart rule - Get an certain item free if you spend over $50

You'll want your rule to match both of these conditions: The cart contains $50+ of other products The cart contains at least one of those "free" items Here's a screenshot of what the rule should ...
user avatar
  • 1,215
5 votes
Accepted

Issue coupon on newsletter signup

This is not available out the box, and no rule would make this happen. You would need to do some custom code to make this work, as well as utilize mailchimps callback hooks to allow you to issue ...
user avatar
  • 9,796
5 votes
Accepted

checking if coupon code is valid

On custom controller add an action which is check current coupen is validate and and apply. public function couponPostAction() { $result=array(); if (!Mage::getSingleton('checkout/cart')->...
user avatar
  • 75.7k
5 votes
Accepted

Buy 2 specific products and get one specific product free

In the admin section go to Promotions > Shopping Cart Rules Fill in the basic rule information. Go to the tab "Conditions" Add a new rule with the following conditions. You have to do this for both ...
user avatar
5 votes
Accepted

how to generate and get the coupon code?

To get the last generated coupon code you will have to modify your collection like this: $couponCode = Mage::getResourceModel('salesrule/coupon_collection') ->addRuleToFilter($...
user avatar
5 votes
Accepted

How to apply an existing coupon code programmatically in Magento 2

Use Checkout model session to get quote data. /** @var \Magento\Checkout\Model\Session $checkoutSession**/ $this->checkoutSession->getQuote()->setCouponCode($couponCode) ...
user avatar
5 votes
Accepted

How to update checkout/cart/ orders total when promo code is applied dynamically without page reload

You can use an action like this: require( [ 'Magento_Checkout/js/model/cart/cache', 'Magento_Checkout/js/model/cart/totals-processor/default', 'Magento_Checkout/js/model/...
user avatar
4 votes
Accepted

Why there is $address->hasCouponCode() in qoute's _validateCouponCode() function?

There is no such method. It is called "magically" through the use of __call. Calling $address->hasCouponCode() translates into calling: isset($address->_data['coupon_code']) of course you ...
user avatar
  • 195k
4 votes

Apply coupon observer to set message in cart view

The event salesrule_validator_process passes most of the objects that you are looking for. Mage::dispatchEvent('salesrule_validator_process', array( 'rule' => $rule, 'item' => $...
user avatar
4 votes
Accepted

Discount coupon is not working for minimum subtotal

I solved it myself! Strangely, I had to put the current currency sign before amount. We are using INR (Rs.). So I needed to use "Rs. 2000" instead of "2000". So my condition is changed from (emphasis ...
user avatar
  • 183
4 votes

Disable tier pricing when applying coupon code

There is no way to do this in standard Magento. First off, coupons can be added after the product is added to cart (with the discount from tier pricing already in place). You will have to revert it ...
user avatar
4 votes

Customize "apply coupon" action when a particular coupon is applied and then re-update shipping in cart & checkout

If you check the HTML of the form you'll see it posts to http://domain.com/checkout/cart/couponPost/. Magento works with a router that breaks down the URL in [module]/[controller]/[action] which ...
user avatar
  • 37.4k
4 votes
Accepted

find all applied coupon code/rules for an order

Try this code <?php $order_id = 101; $items = Mage::getModel('sales/order_item')->getCollection() ->addFilter('order_id',array('eq'=>$order_id)); foreach($items as $item){ if($...
user avatar
  • 9,522
4 votes

find all applied coupon code/rules for an order

You find only one code, because you can only have one code applied to the order. You can have multiple discount rules but only one of them can have a code. You can get the coupon code applied like ...
user avatar
  • 195k
4 votes

Magento 2 - There is an event or method to "plug-in" when the coupon is removed from the cart/quote in the checkout flow?

The coupon code is attached or removed from the quote in this action \Magento\Checkout\Controller\Cart\CouponPost::execute(). The code $couponCode = $this->getRequest()->getParam('remove') == ...
user avatar
  • 195k

Only top scored, non community-wiki answers of a minimum length are eligible