i want to look at the code in magento where the shopping cart rules are checked and applied to the items in the cart before the checkout, i can find in the templates where the information is displayed but i can't find where it is checked if the cart rule should be applied
EDIT 1: by "shopping cart rules are checked" i mean "shopping cart price rules are checked" (maybe there 2 different types of shopping cart rules), i'm looking for the code that goes
"these 3 items that are in the cart meet the conditions of the shopping cart rule with the id of 15, i know need to update the item information as described by the actions provided that the items meet the conditions in the actions"
In ver. 1.4.2.0 the main logic about aplying sales rules is in Mage_SalesRule_Model_Validator located in /app/code/core/Mage/SalesRule/Model/Validator.php
Also if you look for Mage::getModel('salesrule/validator') or Mage::getSingleton('salesrule/validator') statements in /app/code/ directory you can see where the rule processing is used:
/app/code/core/Mage/SalesRule/Model/Observer.php
/app/code/core/Mage/SalesRule/Model/Quote/Discount.php
/app/code/core/Mage/SalesRule/Model/Quote/Freeshipping.php
In the following module: Mage_Salesrule, specifically within app/code/core/Mage/SalesRule/Model/Rule.php
Related
I'm using Prestashop 1.6.1.18. I want to set up a cart rule to offer a carrier for purchases over 14 products with the same kind of attribute (grams of pigment: 2 grams). I want to display or hide this carrier on the cart page based on this cart rule.
I have created a cart rule, but I cannot do someting like this on the Actions tab.
How do I resolve this? Is there a module for this? or else, how should I modify the code, just to hide/display the carrier based on the cart rule?
Why hide a carrier, even if you offer it based on a cart rule, your customer must chose a carrier to be delivred.
I am looking to remove tax based on a product's selected custom option.
I want to have regular tax rules in place for my products. If, however, a visitor chooses option x from one of the custom options, then tax should not be applied.
I have considered using configurable products for this where the simple product representing the tax free option would not have taxes, but magento calculates taxes based on the parent product for configurable products.
Given this article, I can create custom rules that apply to a products' 'sku-modifier'. Meaning I can add a sku modifier for the custom option, then create a shopping cart rule that has a condition containing that sku-modifier.
The only part left is to create an action that would eliminate tax. I can't simply add a discount that is the same amount as my tax rate since the tax rate varies by region.
I have poked around in \app\code\core\Mage\Rule\Model\Action\Abstract.php but I'm not sure how to go about adding the code that would enable this functionality. Any help would be appreciated.
Thanks.
I have set up some cart price rules that provide a bulk discount for products in a certain category. It works fine for simple products but unfortunately it seems to ignore configurable products. My rules are:
Is there a setting I need to change to include configurable products?
Based on the comments I think we both agree this is irregular. Double check that the configurable and the simple products are in the same category, and then (you are probably doing this already) add a simple product to the cart and add the same simple product via a configured product and take a look at the results.
But before you do that, follow carefully my (paranoid) process for applying sale rules (this is what I do for Catalog Price Rules and shouldn't really be necessary for shopping cart rules but when Magento-based paranoia creeps in I turn to my obsessive-compulsive behaviour):
Re-index everything
Refresh the caches
'Save and apply' the rule to apply it to the fresh indexes
Re-index again
Refresh the caches again
Now test the sales rules. The process is paranoid because for sure not everything needs re-indexed nor cache-refreshed and I haven't read all the code to understand from which tables or caches Magento build's its sale rule information from, but from real-life practice I know it can be difficult to get Magento to apply the rules.
I am not aware of a setting to explicitly include configurable products.
Check that there are not other rules with logic that excludes the configurable product.
If it remains a mystery, maybe creating a new configurable with only one simple item would help flush out the setting or glitch that is causing this behaviour - I think that would be a good point to start debugging if you need to roll up your sleeves and get into the code.
i have been working trying to create an edit order system where when an order is bellow a given state the customer can edit the order
now i have everything working by adding a reorder like link which does the exact same as reorder but creates a session which identifies that your editing an order, in order to do this for out of stock products i had to turn backorders on
however i have found a glitch, if a customer was to add 5 hats to the cart and logs off, if when they come back the item's stock qty is now 0 they can still go into the cart, naturally this is because of the backorders being enabled.
i have made a CartController to pick up adding/updates to the shopping cart and manually check if the stock is less than what's in the cart, however if the customer had the item when there was ample stock, leave and returns when it's now out of stock, they bypass these checks
one suggestion that was made by a college was that we shorten the lifetime of the cart session for registered customers, while we could do this, there is more of a problem during a sale
originally, before backorders was turned on, if this same situation occurred the "Proceed to checkout" button would be missing and you would get an error message
now i've tried fixing up a new IndexController and using $this->_getSession()->addError('Some products in your cart have gone out of stock'); but i'm not getting the same results
so how do i create an error message that will prevent the customer from going into the checkout until they have fixed up their cart
I would suggest you to make a dedicated page let's call it edit_cart. When you are redirecting to checkout, check all products and validate their qty in magento. Push them to edit_cart and let them delete out of stock products from cart. After this redirect them to checkout.
I have a free shipping price rule which is configured like this:
All customer groups
No coupon
uses per customer: 0
Conditions: Cart total >= 100, Shipping country == NL or BE or DE
Free shipment: for shipment with matching items.
When I enter a coupon with a fixed discount amount however, the free shipment disappears.
Both price rules have Stop Further Rule Processing set to NO
This behaviour of Magento is driving me insane
Apparently Magento does not care about other shopping cart price rules if there is a valid coupon code entered in the Front-end.
Fix for this issue is in the comments of the following website:
http://magentoexpert.com/issue-with-cart-price-rules-coupon-code-discard-promotion-without-coupon-code/
As suggested in one of the comments it's best that you try and convert the current rule into a "Shopping Cart Price Rule".
In a Shopping Cart Price rule you can also set conditions that depend on the subtotal of the cart, the shipping region, shipping country, ...
In the action tab you can easily Free shipping option to "For shipment with matching items"
This should solve it ;)
Go through all your other rules which might be triggered as well (make sure they have "further rule processing" on "no").
Set the priority to "1"
Try again if the rule is applied and let us know.
If we are talking for Magento CE 1.9 and above, the code is corrected as long as the database is concerned but you might encounter the same problem! If so, then there is another cause.
One also usual bug is * user not being able to update the cart quantities* or users not able to login. This has to do with formKey and the answer that was given here.
Apparently, the same solution fixes the problem of vanished shipment or payment method after applying a coupon, that we are discussing here.
Hope this helps users of newer versions...
so be it - manemoi