Blog

How to Implement "See Price in Cart" Feature in Magento
Ever wonder why online stores like Amazon.com make you add a product to your cart in order to see the sale price? Learn why the 'see price in cart' feature is a valuable tool for online retailers and we'll show you how to implement this feature in Magento using only Mageneto's built in functionality.
Why do online stores make me add a product to my cart to see the sale price?
Believe it or not, when online retailers make you add a product to your cart to see the sale price, it's not a ploy to trick you into buying the product. Rather, by agreement with the manufacturer, the retailer is prohibited from advertising a sale price below a minimum price. The retailer, however, is allowed to sell the product for whatever price they well. The price in the shopping cart does not count as an advertised price, but rather the final price the retailer is willing to sell the product at.
A brief history on Minimum Advertised Price (MAP) policies
Many manufacturers set a Minimum Advertised Pricing (MAP) policy that prevent retailers from advertising the manufacturer's products below a certain price. In the 2006 Supreme Court case Leegin Creative Leather Products Inc. vs. PSKS Inc., the Court ruled that minimum advertised pricing policies are legal and do not break antitrust laws. As part of this ruling, however, the Supreme Court clarified that while retailers must abide by MAP policies, they may sell products for whatever price they choose. By requiring the customer to see the sale price in the cart, the online retailer may sell the product for whatever price they wish, effectively circumventing MAP policies.
Why do companies set MAP policies if there is clearly demand for their product at lower prices?
Companies set MAP policies in order to protect their brands. A Lexus wouldn't be a Lexus if it cost the same as a Toyota. By setting MAP policies, companies can maintain peoples' perceptions of their brand as a high quality brand, while letting authorized retailers sell the products for below the minimum advertised price.
So, if you're a online retailer bound by MAP policies with your manufacturers, you can use the 'see price in cart' trick to effectively sell your products at whatever prices you wish. By having the freedom to sell your inventory at whatever price you want, you can increase sales and maximize your revenue.
How to implement 'see price in cart' in Magento eCommerce
Magento is an open-source eCommerce platform being used by big and small companies alike including Samsung, The North Face, Lenovo, and 3M. We develop eCommerce websites with Magento, so we'll show you how to implement a 'see price in cart' feature using just the built-in functionality and some theming.
What you'll need to get started
All you'll need to get started is an installation of a current version of Magneto's community edition (we're using Magento ver. 1.3.2.4)
Step 1 — Create the attribute that will switch 'see price in cart' on or off
In order to add, manage, and edit attributes in Magento, navigate to the "Catalog" menu, then the "Attributes" sub-menu, then the "Manage Attributes" item.

Catalog > Attributes > Manage Attributes
Once you're in the Manage Attributes section, click the "Add New Attribute" button.

Add new attribute
In the "Properties" tab, set your attribute's options to your liking. Here's what I used in the "Front End Properties" and "Attribute Properties" areas:

Frontend Properties

Attribute Properties
Under the "Manage Label / Options" section, choose the attribute's lable that will appear in the administrator section. I chose: "special price displayed in cart only."
Once you've added your attribute you can use the Manage Attribute Sets section in Catalog > Attributes to rearrange the attribute to display next to the price attributes when adding a product. I rearranged my new attribute to display right after the special price field.

You can see our new 'see price in cart' attribute right below the 'special price' attribute.
Step 2 — Tell your theme what to do with this attribute
So now you've got your attribute set up. A value of one indicates that you want to only display the special price in the cart. A value of zero for this attribute indicates that you want Magento to display the special price as usual. Making one quick edit to the price theme file, you can make this attribute effective in doing just that.
Locate your price theme file:
/public_html/app/design/frontend/[your-theme]/default/template/catalog/product/price.phtml
Edit this file and add the highlighted code below the helper variables and functions:
<?php
/**
* Template for displaying product price in different places (products grid, product view page etc)
*
* @see Mage_Catalog_Block_Product_Abstract
*/
?>
<?php
$_coreHelper = $this->helper('core');
$_weeeHelper = $this->helper('weee');
$_taxHelper = $this->helper('tax');
/* @var $_coreHelper Mage_Core_Helper_Data */
/* @var $_weeeHelper Mage_Weee_Helper_Data */
/* @var $_taxHelper Mage_Tax_Helper_Data */
$_product = $this->getProduct();
$_id = $_product->getId();
$_weeeSeparator = '';
$_simplePricesTax = ($_taxHelper->displayPriceIncludingTax() || $_taxHelper->displayBothPrices());
$_minimalPriceValue = $_product->getMinimalPrice();
$_minimalPrice = $_taxHelper->getPrice($_product, $_minimalPriceValue, $_simplePricesTax);
?>
<?php if ($_product->getCartPrice() == 1): ?>
<div class="price-box">
<p class="old-price">
<span class="price-label"><?php echo $this->__('Reg:') ?></span>
<span class="price" id="old-price<?php echo $this->getIdSuffix() ?>">
<?php echo $_coreHelper->currency($_product->getPrice()) ?></span>
</p>
<p class="special-price">
<span class="price" id="product-price">
<span class='too-low-to-display'>see sale price in cart <span class='cartprice-why tt'><a href="/help/cartprice.php" class="why" target="blank">(why?)</a></span></span></span>
</p>
</div>
<?php else: ?>Finally, be sure to close up your PHP if statement at the very end of the template file:
<?php endif; ?>
In order to hide the price in the grid/list view, there's one more template file to edit:
/public_html/app/design/frontend/[your-theme]/default/template/catalog/product/list.phtml
At the top of the list.phtml file:
<?php
$_coreHelper = $this->helper('core');
?>
And:
... <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?> <?php endif; ?> <?php if ($_product->getCartPrice() == 1): ?><div class="price-box"><p class="old-price"> <span class="price-label">Reg:</span> <span class="price" id="old-price-1"><?php echo $_coreHelper->currency($_product->getPrice()) ?></span></p><p class="special-price"> <span class="price-label">Sale:</span> <span class="price too-low-to-display" id="product-price-1">SEE IN CART</span></p></div> <?php elseif($_product->getSpecialPrice() == 0): ?><div class="price-box"><p class="regular-price"> <span class="price-label">Reg: </span><?php echo $_coreHelper->currency($_product->getPrice()) ?></p></div><?php else: ?><?php echo $this->getPriceHtml($_product, true) ?> <?php endif; ?> <?php if($_product->isSaleable()): ?> ...
You've now successfully implemented rules for displaying prices based on the attribute you created. You can edit the output code to suit your liking and use some css styling to make everything look great. In our version, we made the explanation "why" link popup inline with the page using ThickBox. We also added a hover over pop-up encouraging customers to add the product to their cart.
Check out the final product (no pun intended!)

The 'see price in cart' feature has been successfully and easily implemented.
Subscribe
Search
Addoa on Twitter
Addoa Excellence
We know your vision is important to you. That's why our vision is to help you share yours. When you use Addoa for your creative needs, you'll see the difference excellence makes on your project. Our superior quality, strong communication, attitude and unbeatable value make Addoa the right choice for any project.
Client Testimonials

Free project estimates anytime

Comments
Isaac: Great tutorial and looks like it'll save $169 (the cost of the only MAP mod available for Magento. Nice work.
Dave
Hi - thanks for documenting this!
Unfortunately it's not working for me (nothing happens, just displays the special price), how does Magento know to link getCartPrice in the phtml to the attribute cart_price that you created?
This should be pulled in by the helper functions:
<?php $_coreHelper = $this->helper('core'); $_weeeHelper = $this->helper('weee'); $_taxHelper = $this->helper('tax'); /* @var $_coreHelper Mage_Core_Helper_Data */ /* @var $_weeeHelper Mage_Weee_Helper_Data */ /* @var $_taxHelper Mage_Tax_Helper_Data */ $_product = $this->getProduct(); $_id = $_product->getId(); $_weeeSeparator = ''; $_simplePricesTax = ($_taxHelper->displayPriceIncludingTax() || $_taxHelper->displayBothPrices()); $_minimalPriceValue = $_product->getMinimalPrice(); $_minimalPrice = $_taxHelper->getPrice($_product, $_minimalPriceValue, $_simplePricesTax); ?>How can you change the prices displayed on the homepage and category pages?
Apply the same technique, except in the list.phtml template file in the same directory as the price.phtml file. I'll try to post some code later.
Excellent! Thank you. I tried looking at the list.phtml but I can't seem to figure out where to post the code.
Thanks again!
I updated the post to include the changes to the list.phtml file. Take a look above and let me know if you have any questions.
Great tutorial, but I've found myself having to apply this to an Enterprise installation, but it seems the price and list phtml files are different that your demonstration for the Community version. Is there any chance you could comment on how to apply this solution to the default enterprise template?
Thanks.
Hey Oren, unfortunately I'm not familiar with the enterprise version of Magento. You might show one of the coders at Magento my blog post and see if they can help you from there.
Thank you for this article. I've found something similar, but it didn't help me much. Your article was of more help to me.
How did you do the hover thing? That is really nice.
Thanks!
Hi Traci,
I simply nested a span with the hover-over content inside another span. By default, the span with the hover-over content is hidden with CSS (i.e. "display: none;" for the span element you want to hide). Then you can use the "span.parent:hover span.child" to set rules for what to do with the parent element is hovered over. One of the CSS rules needs to tell the object to display ("display: block;"). The other rules will define the position, style, etc. to your liking.
Note that this does not work for IE6 without adding extra javascript. Because the hover-over is not an essential feature, I opted to exclude the javascript. IE6 users simply won't see the hover-over, which is an acceptable and graceful degradation.
Additional question - How do I require users to be logged in to view the price in the cart?
You could make it so the entire product doesn't appear unless the user is logged in. But other than that, I'm not sure.
Post new comment