<?php
$couponCode = Mage::getSingleton('checkout/session')->getQuote()->getCouponCode();
//echo '<pre>'; print_r($productModel); echo '</pre>';
$couponarray = array();
if($couponCode){
$couponarray = explode(',', $couponCode);
}
$rules = Mage::getResourceModel('salesrule/rule_collection')->load();
$havecoupon = 0;
foreach ($rules as $rule) {
if ($rule->getIsActive()) {
$rule = Mage::getModel('salesrule/rule')->load($rule->getId());
$conditions = $rule->getActions()->asArray();
foreach($conditions['conditions'] as $_conditions ):
if($_conditions['attribute'] == 'sku' && $_item->getSku() == $_conditions['value']){
if(in_array($rule->getCouponCode(), $couponarray)){
$havecoupon = 1;
echo 'Yes i have '.$rule->getCouponCode();
?>
<a href="#" onclick="javascript: $('amcoupon_code_cancel_cus').value = '<?php echo $rule->getCouponCode() ?>'; $('canceldiscount').submit(); return false;">
<?php echo $this->__('Cancel'); ?>
</a>
<?php
}
}
endforeach;
}
}
if($havecoupon == 0){
?>
<input value="" name="coupon_code" id="coupon_code_<?php echo $_item->getId() ?>" class="input-text">
<a href="#" class="button" onclick="javascript: $('amcoupon_code_cancel_cus').value = ''; $('canceldiscount').submit(); return false;">
<?php echo $this->__('Submit'); ?>
</a>
<?php
}
?>
Shopify, Shopify Apps, Magento, WordPress, Codeigniter, Joomla, Big Commerce | PHP
Showing posts with label Shopping. Show all posts
Showing posts with label Shopping. Show all posts
Tuesday, 26 January 2016
Get Shopping cart rule coupon code SKU Magento
Subscribe to:
Posts (Atom)