26

$appliedRuleIds = Mage::getSingleton('checkout/session')->getQuote()->getAppliedRuleIds(); This will give you the ids of the rules applied to the quote separated by comma. you can turn them into an array like this: $appliedRuleIds = explode(',', $appliedRuleIds); if you want to get the rules applied as objects you can do this: //$rules = Mage::...


15

I'll create a module which does this in order to give more insight into how it's done. We're going to use setup scripts (for attribute setup), event observers, condition model and a helper class. I'm assuming you know basics of how modules work/are done in Magento so I'll skip some of the code in the answer to make it shorter and post it as a public ...


14

In your custom module, add the following to config.xml: <models> <salesrule> <rewrite> <quote_discount>Namespace_Module_Rewrite_SalesRule_Model_Quote_Discount</quote_discount> </rewrite> </salesrule> </models> <frontend> <routers> <checkout> ...


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 ...


7

Mage_SalesRule_Model_Resource_Coupon protected function _construct() { $this->_init('salesrule/coupon', 'coupon_id'); $this->addUniqueField(array( 'field' => 'code', 'title' => Mage::helper('salesrule')->__('Coupon with the same code') )); } Remove the addUniqueField call. Don't modify the core file, override ...


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

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

You can use just the Magento core URL for coupon posting: http://example.com/checkout/cart/couponPost/coupon_code/MY_COUPON_CODE You can also add on ?return_url=http... if you want a specific return url or let it just redirect to the cart by default.


5

Take a look at the class Magento\SalesRule\Model\Utility located at the vendor/magento/module-sales-rule/Model/Utility.php. Coupon code validation starts in the method canProcessRule() where it can mark the rule as invalid if coupon code does not match conditions like usage per customer etc.


5

try to manually process queue with this command bin/magento queue:consumers:list view a list of all consumers bin/magento queue:consumers:start <queue_name> pass queue_name for process the queue


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

Please do take a backup of code: Go to file lib/Varien/Data/Collection.php Modify this method public function addItem With the following code public function addItem(Varien_Object $item) { $itemId = $this->_getItemId($item); if (!is_null($itemId)) { if (isset($this->_items[$itemId])) { // throw new ...


4

protected $_coupon; in construct add this public function __construct( \Magento\SalesRule\Model\Coupon $coupon ) { $this->_coupon = $coupon; } Now you can use like this, $ruleId= $this->_coupon->loadByCode($couponCode)->getRuleId(); if (empty($ruleId)) { // generate coupon code } ...


3

No, this is not possible. The table salesrule_coupon has a unique index on the coupon code, so only one global coupon code is possible.


3

As per as magento system,you cannot apply multiple coupon on a cart. If you want then need to use 3rd partly extension like amasty Or you can use this answer: Magento Multiple coupon apply on cart


3

Eventually, I've been able to come up with a method that does exactly what I need. private function getSkuForOptions($product, $options) { $usedProducts = $product->getTypeInstance(true)->getUsedProducts(null, $product); $sku = -1; foreach ($usedProducts as $childProduct) { if (!$childProduct->isSaleable()) { ...


3

Start by building your own module. This tutorial will explain how. Now we'll need 3 things. A block class, template file and a layout XML. The config app/code/local/[Namespace]/[Module]/etc/config.xml <?xml version="1.0"?> <config> <modules> <[Namespace]_[Module]> <version>1.0.0</version> ...


3

Check Coupon * field in edit rule action in admin. You can find it in General Information tab Coupon * should be specific coupon not no coupon Also Use Auto Generation checkbox should be check. Let me know if you have any issue.


3

We need to know: \Magento\SalesRule\Api\CouponManagementInterface - \Magento\SalesRule\Model\Service\CouponManagementService to generate coupon code. \Magento\SalesRule\Api\Data\CouponGenerationSpecInterface - \Magento\SalesRule\Model\Data\CouponGenerationSpec to define a coupon code generator. Remember to inject these classes in your constructor. /** @...


3

For getting the coupon code of an order, you should use $order->getCouponCode();


3

TL;DR Get the order collection on success page and filter it by the recent order increment id and get the coupon code of the order e.g. $order->getCouponCode(); Good Luck!


3

You can call coupon code at checkout by following code: <div class="custom-coupan"> <?php echo $this->getLayout()->createBlock('checkout/cart_coupon') ->setTemplate('checkout/cart/coupon.phtml')->toHtml(); ?> </div> You need to add code at: mag1Root/app/design/frontend/{package}/{theme}/template/checkout/onepage/...


3

Yes, you can get rule_id by coupon_code Try this to get the rule id using helper In your helper <?php namespace {Vendor}\{ModuleName}\Helper; class Data extends \Magento\Framework\App\Helper\AbstractHelper { public function __construct( ...


3

Yes this is possible with magento. You can make a coupon code specific for products, In admin panel Store -> Attributes -> product Search SKU in default label and edit the attribute. In Storefront Properties set Yes to Use for Promo Rule Conditions. Now Go to Marketing -> Cart price rules and edit/add a rule. In Actions Tab under the Apply the ...


3

You can just create a cart price rule that does not have a coupon code and it's valid for orders over 1000. It will not apply a coupon code (because there is none) but the user will see in the checkout the discount applied.


2

Just change your JS a little bit(change ajax post url) var url = jQuery('#discountcode-form').attr('action'); url = url.replace("checkout/cart", "CouponProcessor/cart"); jQuery.ajax({ url: url, type: 'POST', data: 'ajax=true&' + jQuery('#discountcode-form').serialize(), success: function(data){ ...


2

<?php $mageFilename = 'app/Mage.php'; require_once $mageFilename; Varien_Profiler::enable(); Mage::setIsDeveloperMode(true); ini_set('display_errors', 1); umask(0); Mage::app('default'); Mage::register('isSecureArea', 1); function generateUniqueId($length = null){ $rndId = crypt(uniqid(rand(),1)); $rndId = strip_tags(stripslashes($rndId)); $rndId =...


2

Firstly you should never make changes to the core files. This includes your layout and template files located in the base folders. This would be considered a core hack, and will lead to issues down the road, especially when you upgrade. The correct way to remove the coupon is via your local theme. There are a few different ways to apply this. One is via ...


2

I can recommend this extension which changes the error message so that it tells you why the discount could not be applied. My guess would be something in the "conditions" tab that did not match, since I cannot see a problem with the configuration that you show.


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