Showing posts with label cart. Show all posts
Showing posts with label cart. Show all posts

Wednesday, October 5, 2011

How to remove the Discount Code / Coupon Code box in Magento My cart page?

Solution 1:
Edit your theme's "/layout/checkout.xml" file. Find and Comment the below lines.

Solution 2:
Add new local.xml file under your theme's layout folder.

   
      
   
 
Here, You no need to search for any template or layout file. This code will do the trick. After making changes dont forget to refresh the cache. That's it. You are done.

How to remove the Estimate Shipping and Tax box in Magento My cart page?

Solution 1:
Edit your theme's "/layout/checkout.xml" file. Find and Comment the below lines.

Solution 2:
Add new "local.xml" file under your theme's layout folder.

   
      
   
 
Here, You no need to search for any template or layout file. This code will do the trick. After making changes dont forget to refresh the cache. That's it. You are done.

How to remove a block from just one page cart, cms or product page?

For page specific layout updates, either you can use backend layout updates sections(category, product, cms pages) or the following code in the "app/etc/local.xml"

    

for instance, use this code to remove the sidebar cart from the product view page.

     

Tuesday, September 20, 2011

How to remove an item from magento shopping cart automatically?

$cartHelper = Mage::helper('checkout/cart');
$items = $cartHelper->getCart()->getItems();
foreach ($items as $item) {
    if ($item->getProduct()->getId() == $productId) {
        $itemId = $item->getItemId();
        $cartHelper->getCart()->removeItem($itemId)->save();
        break;
    }
} 
Note:
The ItemId (ID of an item in the cart) is not the same as the ProductId of the product it represents. Try iterating through the items in the cart until you find the one with the ProductId you want to remove.

How to hide shopping cart sidebar when it is empty?

Displaying the shopping cart when the user has nothing in it is not necessary. To hide the cart in the sidebar, try the following steps.
Step 1: Edit your "/template/checkout/cart/sidebar.phtml" and look for line
<div class="box base-mini mini-cart"> 
Step 2: Add these lines before the opening div tag
<?php $_cartQty1 = $this->getSummaryCount() ?>
<?php if ($_cartQty1 >0): ?>
Step 3: Add this line to the bottom of the file
<?php endif ?> 
Thats it. You are done.

Add a custom "add to cart" button on Magento CMS pages

Sometimes you'll want to show your products or introduce it on a CMS page for some reason. If you want to do that it's actually not so complicated, in your cms page editor, just add the following HTML code where you want it to appear in the page.
<button onclick="location.href ='{{config path="web/unsecure/base_url"}}/checkout/cart/add?product=1&qty=1′">Buy It Now</button> 
Save the page and refresh the cache. Now if you open the page in you should be able to see "Buy It Now" button. When clicked it adds 1 product with ID=1 to your shopping cart.
To make it a little more advanced, you can add the quantity of products you want to let the customers add, in that case use this code (example for five products).
<button onclick="location.href ='{{config path="web/unsecure/base_url"}}/checkout/cart/add?product=1&qty=5'">Buy 4 Get 1 Free</button> 

Monday, September 12, 2011

Configurable products options are empty after moving my cart side bar to header?

I have explained Moving Cart from Right Sidebar to Header in this tutorial. After moving my cart to header I have noticed configurable options are not shown up in header. To display configurable product options do the following.

Edit your "template/checkout/cart/sidebar/default.phtml" file.
Find the line if ($_options = $this->getOptionList()):

Replace with the following
$_product = Mage::getModel('catalog/product')->load($this->getProduct()->getId());
$config = new Mage_Catalog_Helper_Product_Configuration();  
if ($_options = $config->getConfigurableOptions($_item)): 
Thats it. You are done.