Magento – check if coupon code used
Once on the Onepage Checkout page, I need to track if the customer has used any specific coupon code. This can be checked by the checkout session.
Use this code to hunt up the coupon code. This code will return the coupon code if used or empty result.
<?php $coupon_code = Mage::getSingleton('checkout/session')->getQuote()->getCouponCode(); if($coupon_code){ echo "coupon used"; }else{ echo "coupon not used"; } ?>
Magento – get the block class name
Magento Blocks are the view classes of modules that handle the front-end interface of the website.
To get the block class name of any block, use the following code.
<?php //assuming the block code is "catalog/product" $block = “catalog/product”; //retrieve the class name $block_class_name = Mage::getConfig()->getBlockClassName($block); echo $block_class_name; //now this will be the output - Mage_Catalog_Block_Product ?>
Leave a comment