Magento Themes and Magento Extensions

How to Implement “See Price in Cart” Feature in Magento

Share

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.

How to Implement Once you’re in the Manage Attributes section, click the “Add New Attribute” button.

Feature in MagentoIn 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

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.

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:

01 <?php
02 /**
03 * Template for displaying product price in different places (products grid, product view page etc)
04 *
05 * @see Mage_Catalog_Block_Product_Abstract
06 */
07 ?>
08 <?php
09 $_coreHelper = $this->helper('core');
10 $_weeeHelper = $this->helper('weee');
11 $_taxHelper = $this->helper('tax');
12 /* @var $_coreHelper Mage_Core_Helper_Data */
13 /* @var $_weeeHelper Mage_Weee_Helper_Data */
14 /* @var $_taxHelper Mage_Tax_Helper_Data */
15 $_product = $this->getProduct();
16 $_id = $_product->getId();
17 $_weeeSeparator = '';
18 $_simplePricesTax = ($_taxHelper->displayPriceIncludingTax() || $_taxHelper->displayBothPrices());
19 $_minimalPriceValue = $_product->getMinimalPrice();
20 $_minimalPrice = $_taxHelper->getPrice($_product, $_minimalPriceValue, $_simplePricesTax);
21 ?>
22 <?php if ($_product->getCartPrice() == 1): ?>
23 <div class="price-box">
24 <p class="old-price">
25 <span class="price-label"><?php echo $this->__('Reg:') ?></span>
26 <span class="price" id="old-price<?php echo $this->getIdSuffix() ?>">
27 <?php echo $_coreHelper->currency($_product->getPrice()) ?></span>
28 </p>
29 <p class="special-price">
30 <span class="price" id="product-price">
31 <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>
32 </p>
33 </div>
34 <?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

1 <?php
2 $_coreHelper = $this->helper('core');
3 ?>
And:
01 ...
02 <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
03 <?php endif; ?>
04 <?php if ($_product->getCartPrice() == 1): ?><div class="price-box"><p class="old-price">
05 <span class="price-label">Reg:</span>
06 <span class="price" id="old-price-1"><?php echo $_coreHelper->currency($_product->getPrice()) ?></span></p><p class="special-price">
07 <span class="price-label">Sale:</span>
08 <span class="price too-low-to-display" id="product-price-1">SEE IN CART</span></p></div>
09 <?php elseif($_product->getSpecialPrice() == 0): ?><div class="price-box"><pclass="regular-price">
10 <span class="price-label">Reg: </span><?php echo $_coreHelper->currency($_product->getPrice()) ?></p></div><?php else: ?><?php echo $this->getPriceHtml($_product, true) ?>
11 <?php endif; ?>
12 <?php if($_product->isSaleable()): ?>
13 ...

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!)


Leave a Reply

You must be logged in to post a comment.