Magento – New customers in wrong group with valid VAT id

ce-1.7.0.2taxtax-classvalidationvat

Customers who have registered with a valid VAT id are put in the general group by default.

Customer configuration:
– Enable Automatic Assignment to Customer Group is set to Yes
– Group for valid VAT id – intra Union is set to 'B2B – no vat'

When i debug the code, isValid method for Tax validation returns true

So all params are ok but still the person go's into the wrong group (general)

What is more bizarre to me is, when i go the customer in the backend and save the customer without changing anything, the customer goes into the correct group.

Any feedback on this would be really appreciated.

Thanks

Edit: Apparently the customer gets in the general group initially even with a valid VAT id. After success the customer gets the following message:

"Your VAT ID was successfully validated. You will not be charged tax.
Thank you for registering with ….
If you are a registered VAT customer, please click here to enter your billing address for proper VAT calculation"

If the customer doesn't click the link he stays in general group, if he clicks the link and re enters the information with his VAT, he will be in the B2B group.

Is there a workaround for this so people get in the right group initially?

Best Answer

Try to go to checkout/onepage.html:

For testing purposes add code:

    <?php 
    if(Mage::getSingleton('customer/session')->isLoggedIn()){
    // Get group Id 
        $customerGroup = Mage::getSingleton('customer/session')->getCustomerGroupId();                          
        switch($customerGroup) { //Check if user VIES validation was successfull
            case 16: 
                $htmlMessage='<div style="margin-top: 20px;">';
                $vatMessage='';
                break;
            case 22: 
                $htmlMessage='<div class="alert alert-success sucess fade-in" style="margin-top: 20px;">';
                $vatMessage='Your VIES VAT Number has been verified. 0% tax rate applied.';
                break;
            case 23:
                $htmlMessage='<div class="alert alert-warning warning fade-in" style="margin-top: 20px;">';
                $vatMessage='There was an error during validation of your UE VAT Number. Probably the VIES verification services are currently unavailable. Normal tax rate has been applied.';
                break;
            case 24:
                $htmlMessage='<div class="alert alert-error error fade-in" style="margin-top: 20px;">';
                $vatMessage='Your UE VAT Number is invalid! Please verify your account information and contact our customer support.';
                break;
        } ?>

<?php if(Mage::getSingleton('customer/session')->isLoggedIn()){
   //Get group Id - for testing purpose
      $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
  //Get customer Group name - for testing purpose
      $group = Mage::getModel('customer/group')->load($groupId);
      echo  $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
      echo $group->getCode(); } ?>
     <?php echo $htmlMessage;  ?>
     <?php echo $this->__($vatMessage); ?>
     <?php echo '</div>'; ?>
     <?php }    ?>

Now try to change into valid and invalid vat id. You will see that after editing customer account when he gets into checkout page he's assigned to right customer group. Im currently thinking of solution to validate vies vat number on customer logging in. It has to be related to the observer that's triggering vat validation – when it is triggered.

Did you setup Validation on Each Transaction?

Check my question (as it is 100% same behaviour): maybe we can think of something together. Automatic Customer Group change based on VAT-ID: Force Magento to check and display message when customer gets to checkout page

Related Topic