Try the Demo

Magento

eCommerce Software for Online Growth

Magento Forum

Our new hosted solution for small & emerging businesses
   
How to display price including tax for customer ‘not logged in’
 
Mislav Kašner
Jr. Member
 
Total Posts:  2
Joined:  2010-01-19
 

Hi

I have a problem with displaying product price with tax.
In admin I have configured to display price excluding and including taxes (screenshot 1)

When my customer is logged in it works fine (screenshot 2).

But when customer is not logged in it displays price without taxes (screenshot 3).
I have configured taxes for customer group NOT LOGGED IN and they are calculated correct in the cart (screenshot 4).

How can I diplay product price excluding and including taxes for customer group NOT LOGGED IN?

Magento version: 1.3.2.4

Image Attachments
screenshot_1.jpgscreenshot_2.jpgscreenshot_3.jpgscreenshot_4.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
 
ksolaro
Guru
 
Avatar
Total Posts:  448
Joined:  2008-11-19
 

Hi Mislav,

Just a guess here, but do you have the information in “default tax destination calculation” filled out accurately? Remember that the website doesn’t know the location of a not logged in customer, so it needs some sort of default location value to make a best guess…

 Signature 

CloudQuarry LLC
Custom Magento Development
Check out our latest store: Poetrie.com: Online Boutique for Independent Designers

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mislav Kašner
Jr. Member
 
Total Posts:  2
Joined:  2010-01-19
 

Thank you for your reply,

Default tax destination is set.
As you can see in the screenshot, tax is calculated correctly when you view the cart.
I don’t understand why it doesn’t calculate tax on the product page.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ksolaro
Guru
 
Avatar
Total Posts:  448
Joined:  2008-11-19
 

It looks like you have a custom theme. Have you checked to see whether the code for price calculation is different in your theme vs. the default theme?

 Signature 

CloudQuarry LLC
Custom Magento Development
Check out our latest store: Poetrie.com: Online Boutique for Independent Designers

 
Magento Community Magento Community
Magento Community
Magento Community
 
jazkat
Sr. Member
 
Total Posts:  148
Joined:  2009-07-09
 

EDIT: SEE MUCH BETTER SOLUTION HERE:
http://www.magentocommerce.com/boards/viewthread/24969/P15/#t234699

Hi Mislav,
I guess I’m too late for you,
but this is my solution:

In file \app\design\frontend\[default]\[default]\template\catalog\product\price.phtml
I added the code which checked the status of the customer (if it’s logged-out or if it should see Tax anyway).
add the code on line 50

<?php 
  
// **************************************************************** //

  // if customer is logged-in, we get ID of the customer's group
  
if ($this->helper('customer')->isLoggedIn())
      
$customerGroupTemp Mage::getSingleton('customer/session')->getCustomerGroupId();     
  
$setPercentageFlagTemp false;

  
// Tax is shown if:                                           //
  // -customer isn't logged-in         OR                                     //
  // -customer IS logged-in AND needs to see Tax (customers in groups: 1,5,6) //
  
if ( (!$this->helper('customer')->isLoggedIn())  ||
       ( (
$this->helper('customer')->isLoggedIn()) && (
            (
$customerGroupTemp == 1) || ($customerGroupTemp == 5) || ($customerGroupTemp == 6) ) ) )  {
  
      $ctcTemp 
3//int Customer Tax Class - "3 =with Tax", "5 = no Tax"
      
$storeTemp null;
      
$includingTaxTemp true;
      
$shippingAddressTemp null;
      
$billingAddressTemp null;
      
$priceIncludesTaxTemp null;
      
      
$percentOLDTemp $_product->getTaxPercent();
      
$requestTemp Mage::getSingleton('tax/calculation')->getRateRequest($shippingAddressTemp$billingAddressTemp$ctcTemp$storeTemp);
      
$percentTemp Mage::getSingleton('tax/calculation')->getRate($requestTemp->setProductClassId($_product->getTaxClassId()));
      
$_product->setTaxPercent($percentTemp);
      
      
$setPercentageFlagTemp true;
  
}

  
// **************************************************************** //
?>
and at the bottom of the file, after:
<?php endif; /* if (!$_product->isGrouped()): */ ?>

I added this code to reset the tax for that product (just in case)

<?php 
  
// **************************************************************** //
  // Set Tax % back to what it was                              //
  
if($setPercentageFlagTemp{
      $_product
->setTaxPercent($percentOLDTemp);
      
$setPercentageFlagTemp false;
  

  
// **************************************************************** //
?>

So far it seems to be working for simple products, I haven’t tested for others.
I see both prices now on 1 product details, and products in grid/list (and some other modules that us this price.phtml file).

I used the same code for the issue when cart also displays prices without tax until My Cart or Checkout is clicked (see that post here:
http://www.magentocommerce.com/boards/viewthread/24969/). I used it in files
\app\design\frontend\[default]\[default]\template\catalog\product\view\addtocart.phtml
\app\design\frontend\[default]\[default]\template\catalog\product\list.phtml
before and after

<fieldset class="add-to-cart-box"> ............... </fieldset>

Good luck

 
Magento Community Magento Community
Magento Community
Magento Community
 
Nitin me Cool
Jr. Member
 
Total Posts:  8
Joined:  2009-09-15
Ahmedabad, India
 

I have changed above code and instead of doing changes on multiple phtml file you can also achieve this through change in single file.

Override app/code/core/Mage/Tax/Helper/Data.php into your app/code/local folder.

You will have to change in getPrice function.

Put

// **************************************************************** //
        
        
$session Mage::getSingleton('customer/session');
  
// if customer is logged-in, we get ID of the customer's group
  
if ($session->isLoggedIn())
      
$customerGroupTemp Mage::getSingleton('customer/session')->getCustomerGroupId();     
 

  
// Tax is shown if:                                           //
  // -customer isn't logged-in         OR                                     //
  // -customer IS logged-in AND needs to see Tax (customers in groups: 1,5,6) //
  
if ( (!$session->isLoggedIn())  ||
       ( (
$session->isLoggedIn()) && (
            (
$customerGroupTemp == 1) || ($customerGroupTemp == 5) || ($customerGroupTemp == 6) ) ) )  {
  
    
      $ctcTemp 
3//int Customer Tax Class - "3 =with Tax", "5 = no Tax"
      
$storeTemp null;
      
$includingTaxTemp true;
      
$shippingAddressTemp null;
      
$billingAddressTemp null;
      
$priceIncludesTaxTemp null;
      
      
      
$requestTemp Mage::getSingleton('tax/calculation')->getRateRequest($shippingAddressTemp$billingAddressTemp$ctcTemp$storeTemp);
      
      
$percentTemp Mage::getSingleton('tax/calculation')->getRate($requestTemp->setProductClassId($taxClassId));
    
    
    
$priceIncludesTax null;
    
$includingPercent $percentTemp;
    
$percent $percentTemp;
      
  
}

  
// **************************************************************** //

After

if ($taxClassId && $priceIncludesTax{
            $request 
Mage::getSingleton('tax/calculation')->getRateRequest(falsefalsefalse$store);
            
$includingPercent Mage::getSingleton('tax/calculation')->getRate($request->setProductClassId($taxClassId));
        
}

I hope this technique would help!!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
 
© Copyright 2012 Magento Inc.
Privacy Policy|Terms of Service
Magento Community Count
701238 users|867 users currently online|497293 forum posts