While debugging the shopping cart price rule calculation i found out that the system uses the default_group configured in backend instead of the actual customer group on this customer group sensitive rule.

It seems to me that this is a bug. But i have never heard of this. I am quite sure there is no custom code responsible for this. When i look into sales_flat_quote db table the customer group id is correctly set with the actual customers group id.

Any hints on this topic?

I checked this in class


in method


This is the proof:

        Mage::log("BEFORE ENTERING CALCULATOR WE SEE default_group ID");
        $this->_calculator->init($store->getWebsiteId(), $quote->getCustomerGroupId(), $quote->getCouponCode());

I am still debugging but maybe you guys have some hint from experiencing same problems...thank you so much!

P.S.: this is found in EE 1.12 but i am sure its in too.

  • I'm also on, same here. I need the vat check for my B2B website, but can not use de VAT check because this is buged like mentioned. When I put auto VAT-check to YES then cartrules won't apply If set to NO there's no problem whith the rules. Would be happy whith an solution too. Anybody on the right track? KR Jerry (NL)
    – user5213
    Commented Feb 12, 2014 at 19:11

4 Answers 4


We experienced the same problem with a Magento webshop.

Fortunately this bug was fixed in Magento (I didn't check and can easily by ported over to Magento 1.7.

You have to take a look at the difference between the method changeQuoteCustomerGroupId of the class Mage_Sales_Model_Observer from Magento and Those differences are the fix for the bug.

➜ diff ~/Projects/magento1702/app/code/core/Mage/Sales/Model/Observer.php ~/Projects/magento1810/app/code/core/Mage/Sales/Model/Observer.php
<  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
>  * @copyright   Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
>         $isDisableAutoGroupChange = $customerInstance->getDisableAutoGroupChange();
<         if (empty($customerVatNumber) || !Mage::helper('core')->isCountryInEU($customerCountryCode)) {
>         if ((empty($customerVatNumber) || !Mage::helper('core')->isCountryInEU($customerCountryCode))
>             && !$isDisableAutoGroupChange
>         ) {
<         $groupId = $customerHelper->getCustomerGroupIdBasedOnVatNumber(
<             $customerCountryCode, $gatewayResponse, $customerInstance->getStore()
<         );
>         if (!$isDisableAutoGroupChange) {
>             $groupId = $customerHelper->getCustomerGroupIdBasedOnVatNumber(
>                 $customerCountryCode, $gatewayResponse, $customerInstance->getStore()
>             );
>         } else {
>             $groupId = $quoteInstance->getCustomerGroupId();
>         }

Found the problem. Some magento inc. coder does the following in the core:

if (empty($customerVatNumber) || !Mage::helper('core')->isCountryInEU($customerCountryCode)) { $groupId = ($customerInstance->getId()) ? $customerHelper->getDefaultCustomerGroupId($storeId) : Mage_Customer_Model_Group::NOT_LOGGED_IN_ID;

You find this in class:


line 440

The result is that during sales shopping cart rules processing the quote will always have default group or not logged in group. This is definitely a core bug!


This Do you have Enable Automatic Assignment to Customer Group turned on (under System=>Configuration=>Customer Configuration)? If so then Magento checks to see if the VAT number entered is valid and assign the configured default group.

  • VAT Settings should not conflict with SalesRules. Its ok to check Customers and set them dynamically in VAT related logic, but if SalesRules cannot be applied based on customer groups its obviously a bug. Commented Aug 25, 2013 at 17:06
  • The VAT settings override the customergroup before the salesrules are checked. As the option states is changes the customergroup automatically, does the salesrule work when you disable the Automatic group assignment? Commented Aug 25, 2013 at 17:36
  • Thanks for trying to help, but i solved it already. I try one more time to explain the problem: 1. Customers are set to my configured group "Special Member" as default, which is working correct and needed. 2. If you enter a new salesrule to be enabled for another customer group it doesnt get applied, because in any case the default group is used while checking if the rule has to be applied. So any configuration in the salesrule concerning customer groups is completely useless and overriden. Its crap and not usable. Commented Aug 25, 2013 at 17:50

I have the same problem on my system ( and it looks like a bug to me. Under Customer configuration, if "Enable Automatic Customer Assignment to Group" is set to Yes, any discounts setup for special groups show OK in the Catalog, but are calculated incorrectly for the Cart.

It would appear that, somewhere, Magento checks for a valid VAT number, and when it does not validate, it temporarily sets the Customer's group to the default (General in my case) and uses it to do the Cart calculation, this is despite the Customer account being explicitly set to "Disable Automatic Group Change Based on VAT ID"

In the VAT number validation doesn't appear to work anyway, so I disabled it and the Cart prices are now shown correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.