Hot answers tagged

18

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/layout/checkout_index_index.xml or app/design/frontend/Vendor/theme/Magento_Checkout/layout/checkout_index_index.xml you can also remove discount block using '...


17

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 sort totals based on this data * * @return array */ protected function _getSortedCollectorCodes() { if (Mage::app()->useCache('...


12

$quote2 = Mage::getSingleton('checkout/session')->getQuote(); $discountTotal = 0; foreach ($quote2->getAllItems() as $item){ $discountTotal += $item->getDiscountAmount(); }


12

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 external file is in root folder */ require __DIR__ . '/app/bootstrap.php'; $params = $_SERVER; $bootstrap = Bootstrap::create(BP, $params); $obj = $bootstrap->...


11

Magento has this facility in-built since 1.7CE. The class Mage_SalesRule_Model_Coupon_Massgenerator. To make use of it on your own you can instantiate the class: $generator = Mage::getModel('salesrule/coupon_massgenerator'); You need to set some options: $data = array( 'max_probability' => .25, 'max_attempts' => 10, '...


10

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 session, try the below code $totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); $totalDiscount = $totals["discount"]->getValue(); ...


9

The only way to solve this problem is to either require users to create a customer account prior to using this coupon or implement custom logic to validate against billing and/or shipping information to try and accomplish the same thing. Anything else would be unreliably flakey. Checking for orders placed with the same info is already pretty flaky, ...


9

Which customers used which coupons: I usually shy away from raw db queries, but in this case I will make an exception: select customer_email, group_concat(distinct sfo.coupon_code) from sales_flat_order sfo where coupon_code is not null group by customer_email; You could do the same with the Magento ORM - will formulate a writeup on how to do that and ...


9

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 Mage_SalesRule_Model_Observer (copy to local of course) from // use each rule (and apply to customer, if applicable) if ($order->getDiscountAmount() !=...


8

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 yourself or someone in a similar Mage 'tax boat': Example - Cart subtotal w/o tax £100 My Cart discount promotion was 30% discount. £100 - 30% = £70 ...


8

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 encountered, all the other rules that should come after that are ignored. When you apply coupon A you get 1 ore more valid rules for the current cart. But this does ...


8

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 © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="...


6

Reports > Sales > Coupons in your admin area will let you see how many times a particular discount code was used, the amount of sales generated for and the amount of total discount given for each as well. You can filter it down by day, month, year etc. You can also filter by order status and for a certain date period.


6

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


6

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 called. As this is the same event for both add and remove you can add the following code at the top of your observer method to check if this is a remove action: $...


6

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 googling gave me f/e: http://magetechno.com/cancel-order-coupon-code-reuse.html Here's description for the situation: http://magebase.com/magento-tutorials/...


6

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/carts/mine/coupons/:couponCode" method="PUT"> <service class="Magento\Quote\Api\CouponManagementInterface" method="set"/> <resources> ...


5

davidalger is right. Another solution would be to "Use Auto Generation" and give out custom codes that are only usable once (Uses per Coupon). This would work even for "Not Logged In" users.


5

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 discount by overriding process function of Mage_SalesRule_Model_Validator In the process function, you will find switch case as follows switch ($rule->...


5

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" for example. Basically, if you want to create a new module you can define a new action, similar to "fixed discount to whole cart" then observe event ...


5

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 look like: Change GIFT to whatever SKU your "free" product uses.


5

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 coupons on a successful subscription confirmation. So lets start: The first step is to go create a Shopping Cart Price Rule, and in the configuration, you set it ...


5

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')->getQuote()->getItemsCount()) { $result['valid']=0; $result['message']='YOUR ERROR Message'; } $couponCode = (string) $this->getRequest()->getParam('...


5

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 products x and z: 1. Click the + sign and pick the option "Product Attribute Combination". 2. Then below the text "If an item is FOUND in the cart with ALL ...


5

To get the last generated coupon code you will have to modify your collection like this: $couponCode = Mage::getResourceModel('salesrule/coupon_collection') ->addRuleToFilter($salesRule) ->addGeneratedCouponsFilter() ->getLastItem() ->getData('code'); The two lines I've added get ...


5

Use Checkout model session to get quote data. /** @var \Magento\Checkout\Model\Session $checkoutSession**/ $this->checkoutSession->getQuote()->setCouponCode($couponCode) ->collectTotals() ->save(); Remember to inject \Magento\Checkout\Model\Session in your constructor. ...


5

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/quote' ], function (cartCache, totalsProcessor, quote) { cartCache.clear('cartVersion'); totalsProcessor.estimateTotals(quote....


4

The following answer is just theoretical. I haven't tested it, but it seams the way to go. You can get the cart rules that were applied to the order you cancel like this: $ruleIds = explode(',', $order->getAppliedRuleIds()); Then you need to get the rules applied: $rules = Mage::getModel('salesrule/rule')->getCollection() ->...


4

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 cannot use it directly like that because $_data is a protected member (I just wrote it here as a proof of concept). The clean way to check is this: $data = $...


4

The event salesrule_validator_process passes most of the objects that you are looking for. Mage::dispatchEvent('salesrule_validator_process', array( 'rule' => $rule, 'item' => $item, 'address' => $address, 'quote' => $quote, 'qty' => $qty, 'result' => $result, )); Here you have the quote (which is the ...


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