Saturday 23 April 2016

Magento : STOCK QUANTITY ON MAGENTO PRODUCT PAGE

Warning: This is a quick-n-dirty hack and will not work on all product types.

Instead of just showing the “in stock” and “out of stock” messages, we want to have an in-between message to show that stock levels are running low. This is easily done, by editing the following file:

app/design/frontend/base/default/template/catalog/product/view/type/default.phtml

We change the contents of the file to the following:

<?php
$_product = $this->getProduct();
$_quantity = intval(Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty());
?>

<?php if ($_product->isAvailable()): ?>
  <?php if ( intval($_quantity) < 10 ): ?>
    <p class="availability last-stock"><?php echo $this->__('Availability:') ?>
      <span><?php echo $this->__('Only '); echo $_quantity; echo $this->__(" left"); ?></span>
    </p>
  <?php else : ?>
    <p class="availability in-stock"><?php echo $this->__('Availability:') ?>
      <span><?php echo $this->__('In stock') ?></span>
    </p>
  <?php endif; ?>
<?php else: ?>
  <p class="availability out-of-stock"><?php echo $this->__('Availability:') ?>
    <span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>

<?php echo $this->getChildHtml('product_type_data_extra') ?>
<?php echo $this->getPriceHtml($_product) ?>


That’s it!

We just created a warning-type level once stock drops to less than 10 items. Meanwhile, both the “in-stock” and “out-of-stock” messages are preserved. This can be easily styled using CSS. Note we added the class “last-stock” to our new p-tag

Magento : Disable/ Remove “Estimate Shipping and Tax”

We can solve this issue two way.
First way :
Create local.xml file with below code and upload your theme layout folder
<?xml version=”1.0″ encoding=”UTF-8″ ?>
<layout>
<checkout_cart_index>
<reference name=”content”>
<block name=”checkout.cart”>
<remove name=”checkout.cart.shipping”/>
</block>
</reference>
</checkout_cart_index>
</layout>
Second way :
Remove the following code from /app/design/frontend/yourtheme/layout/checkout.xml
<block type=”checkout/cart_shipping” name=”checkout.cart.shipping” as=”shipping” template=”checkout/cart/shipping.phtml”/>
Done! :)