app/code/community/Techievolve/Freeproduct/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Techievolve_Freeproduct>
<version>1.1.4</version>
</Techievolve_Freeproduct>
</modules>
<global>
<models>
<freeproduct>
<class>Techievolve_Freeproduct_Model</class>
</freeproduct>
</models>
<helpers>
<freeproduct>
<class>Techievolve_Freeproduct_Helper</class>
</freeproduct>
</helpers>
<resources>
<freeproduct_setup>
<setup>
<module>Techievolve_Freeproduct</module>
<class>Mage_Eav_Model_Entity_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</freeproduct_setup>
</resources>
<fieldsets>
<sales_convert_quote_item>
<is_free_product>
<to_order_item>is_free_product</to_order_item>
</is_free_product>
</sales_convert_quote_item>
</fieldsets>
</global>
<adminhtml>
<events>
<adminhtml_block_salesrule_actions_prepareform>
<observers>
<freeproduct>
<type>model</type>
<class>freeproduct/observer</class>
<method>adminhtmlBlockSalesruleActionsPrepareform</method>
</freeproduct>
</observers>
</adminhtml_block_salesrule_actions_prepareform>
<adminhtml_controller_salesrule_prepare_save>
<observers>
<freeproduct>
<type>model</type>
<class>freeproduct/observer</class>
<method>adminhtmlControllerSalesrulePrepareSave</method>
</freeproduct>
</observers>
</adminhtml_controller_salesrule_prepare_save>
</events>
<translate>
<modules>
<Techievolve_Freeproduct>
<files>
<default>Techievolve_Freeproduct.csv</default>
</files>
</Techievolve_Freeproduct>
</modules>
</translate>
</adminhtml>
<frontend>
<layout>
<updates>
<freeproduct>
<file>freeproduct.xml</file>
</freeproduct>
</updates>
</layout>
<events>
<salesrule_validator_process>
<observers>
<freeproduct>
<type>model</type>
<class>freeproduct/observer</class>
<method>salesruleValidatorProcess</method>
</freeproduct>
</observers>
</salesrule_validator_process>
<sales_quote_load_after>
<observers>
<freeproduct>
<type>model</type>
<class>freeproduct/observer</class>
<method>salesQuoteCollectTotalsBefore</method>
</freeproduct>
</observers>
</sales_quote_load_after>
<catalog_product_type_prepare_full_options>
<observers>
<freeproduct>
<class>freeproduct/observer</class>
<method>catalogProductTypePrepareFullOptions</method>
</freeproduct>
</observers>
</catalog_product_type_prepare_full_options>
<sales_quote_product_add_after>
<observers>
<freeproduct>
<class>freeproduct/observer</class>
<method>salesQuoteProductAddAfter</method>
</freeproduct>
</observers>
</sales_quote_product_add_after>
</events>
</frontend>
</config>
app/code/community/Techievolve/Freeproduct/Exception/InvalidQuantity.php
<?php
/**
* Freeproduct Module
*
* @category Techievolve
* @package Techievolve_Freeproduct
* @author Sushant <sushant.vishwas1990@gmail.com>
* @version 1.1.4
*/
class Techievolve_Freeproduct_Exception_InvalidQuantity extends RuntimeException {
}
app/code/community/Techievolve/Freeproduct/Exception/ProductNotFound.php
<?php
/**
* Freeproduct Module
*
* @category Techievolve
* @package Techievolve_Freeproduct
* @author Sushant <sushant.vishwas1990@gmail.com>
* @version 1.1.4
*/
class Techievolve_Freeproduct_Exception_ProductNotFound extends RuntimeException {
}
app/code/community/Techievolve/Freeproduct/Exception/ProductNotSalable.php
<?php
/**
* Freeproduct Module
*
* @category Techievolve
* @package Techievolve_Freeproduct
* @author Sushant <sushant.vishwas1990@gmail.com>
* @version 1.1.4
*/
class Techievolve_Freeproduct_Exception_ProductNotSalable extends RuntimeException {
}
app/code/community/Techievolve/Freeproduct/Helper/Data.php
<?php
/**
* Freeproduct Module
*
* @category Techievolve
* @package Techievolve_Freeproduct
* @author Sushant <sushant.vishwas1990@gmail.com>
* @version 1.1.4
*/
class Techievolve_Freeproduct_Helper_Data extends Mage_Core_Helper_Abstract {
}
app/code/community/Techievolve/Freeproduct/Model/Consts.php
<?php
/**
* Freeproduct Module
*
* @category Techievolve
* @package Techievolve_Freeproduct
* @author Sushant <sushant.vishwas1990@gmail.com>
* @version 1.1.4
*/
class Techievolve_Freeproduct_Model_Consts {
const ADD_GIFT_ACTION = 'add_gift';
}
app/code/community/Techievolve/Freeproduct/Model/Observer.php
<?php
/**
* Freeproduct Module
*
* @category Techievolve
* @package Techievolve_Freeproduct
* @author Sushant <sushant.vishwas1990@gmail.com>
* @version 1.1.4
*/
class Techievolve_Freeproduct_Model_Observer {
/**
* @param $giftSku
* @return string[]
*/
protected static function _getSkuList($giftSku) {
return array_map('trim', explode(',', $giftSku));
}
/**
* Delete all free products that have been added through this module before.
* This is done before discounts are given in on the event
* 'sales_quote_collect_totals_before'.
*
* @param Varien_Event_Observer $observer
*/
public function salesQuoteCollectTotalsBefore(Varien_Event_Observer $observer) {
/** @var Mage_Sales_Model_Quote $quote */
$quote = $observer->getEvent()->getQuote();
/**
* The quote store is set to current store temporarily because of a possible problem in Enterprise v1.14.2.4.
* If the following conditions are true:
* - Multiple stores
* - The store is being switched from A to B
* - the product flat index is not set as build (see table core_flag) in store A but it is in store B (or vice-versa)
*
* When the quote_item collection is loaded, products are assigned to it. When the collection is instantiated, either flat
* or EAV resource is set based on availability of the index per store. Here, the current store is being used to determine
* flat availability. The Flat/EAV resource models are not interface-compatible, once it is set it should not change
* otherwise there will be missing methods which cause fatal errors.
* After instantiation, the store of the quote is being set which might have different flat availability and the collection
* model will try to use the wrong resource model which will result in fatal errors.
*
* @see Flat and EAV product resource models are not interface compatible
* @see Mage_Sales_Model_Resource_Quote_Item_Collection::_assignProducts()
* @see Mage_Catalog_Model_Resource_Product_Collection:::_construct()
* @see Mage_Catalog_Model_Resource_Product_Collection::isEnabledFlat()
*/
$originalStore = $quote->getStoreId();
$quote->setStoreId(Mage::app()->getStore()->getId());
foreach ($quote->getAllItems() as $item) {
if ($item->getIsFreeProduct()) {
$quote->removeItem($item->getId());
}
}
$quote->setStoreId($originalStore);
}
/**
* Add gifts to the cart, if the current salesrule is of simple action
* ADD_GIFT_ACTION. The rule has been validated before the event
* 'salesrule_validator_process' is thrown that we catch.
*
* @param Varien_Event_Observer $observer
*/
public function salesruleValidatorProcess(Varien_Event_Observer $observer) {
/* @var $quote Mage_Sales_Model_Quote */
$quote = $observer->getEvent()->getQuote();
/* @var $item Mage_Sales_Model_Quote_Item */
$item = $observer->getEvent()->getItem();
/* @var $rule Mage_SalesRule_Model_Rule */
$rule = $observer->getEvent()->getRule();
if ($rule->getSimpleAction() != Techievolve_Freeproduct_Model_Consts::ADD_GIFT_ACTION || $item->getIsFreeProduct() || $rule->getIsApplied()) {
return;
}
try {
$qty = (int)$rule->getDiscountAmount();
$skus = static::_getSkuList($rule->getGiftSku());
foreach ($skus as $sku) {
/** @var Mage_Sales_Model_Quote_Item $freeItem */
$freeItem = static::_getFreeQuoteItem($rule->getId(), $sku, $quote->getStoreId(), $qty);
$quote->addItem($freeItem);
static::_setQuoteItemTaxPercent($freeItem);
$freeItem->setApplyingRule($rule);
}
$rule->setData('is_applied', true);
} catch (RuntimeException $e) {
Mage::logException($e);
}
}
/**
* Add a new simple action to the salesrule in the backen. In the combo-box
* you can now select 'Add a Gift' as one possible result of the given rule
* evaluation positive. Additionally you have to enter a sku of the gift that
* you want to make.
*
* @param Varien_Event_Observer $observer
*/
public function adminhtmlBlockSalesruleActionsPrepareform($observer) {
$field = $observer->getForm()->getElement('simple_action');
$options = $field->getValues();
$options[] = array(
'value' => Techievolve_Freeproduct_Model_Consts::ADD_GIFT_ACTION,
'label' => Mage::helper('freeproduct')->__('Add a Gift')
);
$field->setValues($options);
$fieldset = $observer->getForm()->getElement('action_fieldset');
$fieldset->addField('gift_sku', 'text', array(
'name' => 'gift_sku',
'label' => Mage::helper('freeproduct')->__('Gift SKU'),
'title' => Mage::helper('freeproduct')->__('Gift SKU'),
'note' => Mage::helper('freeproduct')->__('Enter the SKU of the gift that should be added to the cart. You can enter a comma separated list for multiple gifts.'),
));
}
/*
* Check if the given free product SKU is not empty and references a valid product.
* @param Varien_Event_Observer $observer
* @throws Mage_Core_Exception
*/
public function adminhtmlControllerSalesrulePrepareSave($observer) {
$request = $observer->getRequest();
if ($request->getParam('simple_action') == Techievolve_Freeproduct_Model_Consts::ADD_GIFT_ACTION) {
$giftSku = $request->getParam('gift_sku');
if (! static::_isValidGiftSku($giftSku)) {
// make sure that unsaved data is not lost
$data = $request->getPost();
Mage::getSingleton('adminhtml/session')->setPageData($data);
// just throw an exception, Mage_Adminhtml_Promo_QuoteController::saveAction will do the rest
throw new Mage_Core_Exception('The free product SKU must be a valid product.');
}
}
}
/**
* Detect free products based on buyRequest object and set it as temporary attribute to
* the product. Relevant for reordering. See also: salesQuoteProductAddAfter()
*
* @param Varien_Event_Observer $observer
*/
public function catalogProductTypePrepareFullOptions(Varien_Event_Observer $observer)
{
if ($observer->getBuyRequest()->getData('is_free_product')) {
$observer->getProduct()->setIsFreeProduct(true);
}
}
/**
* Adds is_free_product attribute to quote model if set to product. Relevant for reordering.
* See also: catalogProductTypePrepareFullOptions()
*
* @param Varien_Event_Observer $observer
*/
public function salesQuoteProductAddAfter(Varien_Event_Observer $observer)
{
foreach ($observer->getEvent()->getItems() as $quoteItem) {
$quoteItem->setIsFreeProduct($quoteItem->getProduct()->getIsFreeProduct());
}
}
/**
* Create a free item. It has a value of 0$ in the cart no matter what the price was
* originally. The flag is_free_product gets saved in the buy request to read it on
* reordering, because fieldset conversion does not work from order item to quote item.
*
* @param int $ruleId
* @param string $sku
* @param int $storeId
* @param int $qty
* @return bool|Mage_Sales_Model_Quote_Item
* @throws Techievolve_Freeproduct_Exception_InvalidQuantity
* @throws Techievolve_Freeproduct_Exception_ProductNotSalable
* @throws Techievolve_Freeproduct_Exception_ProductNotFound
*/
protected static function _getFreeQuoteItem($ruleId, $sku, $storeId, $qty)
{
if ($qty < 1) {
throw new Techievolve_Freeproduct_Exception_InvalidQuantity(sprintf(
'Techievolve_Freeproduct: Invalid Gift product qty. Rule ID: %d, Gift Qty: %d',
$ruleId, $qty
));
}
/** @var Mage_Catalog_Model_Product $product */
$product = Mage::getModel('catalog/product');
$product->setStoreId($storeId);
$product->load($product->getIdBySku($sku));
if ($product == false) {
throw new Techievolve_Freeproduct_Exception_ProductNotFound(sprintf(
'Techievolve_Freeproduct: Gift product not found. Rule ID: %d, Gift SKU: %s, Store ID: %d',
$ruleId, $sku, $storeId
));
}
Mage::getModel('cataloginventory/stock_item')->assignProduct($product);
if ($product->isSalable() == false) {
throw new Techievolve_Freeproduct_Exception_ProductNotSalable(sprintf(
'Techievolve_Freeproduct: Gift product not saleable. Rule ID: %d, Gift SKU: %s, Store ID: %d',
$ruleId, $sku, $storeId
));
}
$quoteItem = Mage::getModel('sales/quote_item')->setProduct($product);
$quoteItem
->setQty($qty)
->setCustomPrice(0.0)
->setOriginalCustomPrice($product->getPrice())
->setIsFreeProduct(true)
->setWeeeTaxApplied('a:0:{}') // Set WeeTaxApplied Value by default so there are no "warnings" later on during invoice creation
->setStoreId($storeId);
$quoteItem->addOption(new Varien_Object(array(
'product' => $product,
'code' => 'info_buyRequest',
'value' => serialize(array('qty' => $qty, 'is_free_product' => true))
)));
// With the freeproduct_uniqid option, items of the same free product won't get combined.
$quoteItem->addOption(new Varien_Object(array(
'product' => $product,
'code' => 'freeproduct_uniqid',
'value' => uniqid(null, true)
)));
return $quoteItem;
}
/**
* @param $storeId
* @param $quoteItem
*/
protected static function _setQuoteItemTaxPercent(Mage_Sales_Model_Quote_Item $quoteItem)
{
$taxCalculationModel = Mage::getSingleton('tax/calculation');
$quote = $quoteItem->getQuote();
/* @var $taxCalculationModel Mage_Tax_Model_Calculation */
$request = $taxCalculationModel->getRateRequest(
$quote->getShippingAddress(),
$quote->getBillingAddress(),
$quote->getCustomerTaxClassId(),
$quoteItem->getStore()
);
$rate = $taxCalculationModel->getRate(
$request->setProductClassId($quoteItem->getProduct()->getTaxClassId())
);
$quoteItem->setTaxPercent($rate);
}
/**
* @param $giftSku
* @return bool
*/
protected static function _isValidGiftSku($giftSku)
{
if (trim($giftSku) === '') {
return false;
}
$skus = self::_getSkuList($giftSku);
foreach ($skus as $sku) {
if (! Mage::getModel('catalog/product')->getIdBySku($sku)) {
return false;
}
}
return true;
}
}
app/code/community/Techievolve/Freeproduct/sql/freeproduct_setup/mysql4-install-0.1.0.php
<?php
/**
* Freeproduct Module
*
* @category Techievolve
* @package Techievolve_Freeproduct
* @author Sushant <sushant.vishwas1990@gmail.com>
* @version 1.1.4
*/
/**
* @var $installer Mage_Sales_Model_Mysql4_Setup
*/
$installer = $this;
$installer->startSetup();
$installer->getConnection()->addColumn(
$installer->getTable('sales/quote_item'), 'is_free_product', "tinyint(4) NOT NULL default '0'"
);
$installer->getConnection()->addColumn(
$installer->getTable('sales/order_item'), 'is_free_product', "tinyint(4) NOT NULL default '0'"
);
$installer->getConnection()->addColumn(
$installer->getTable('salesrule'), 'gift_sku', "varchar(255) NOT NULL default ''"
);
$installer->endSetup();
app/etc/modules/Techievolve_Freeproduct.xml
<?xml version="1.0"?>
<config>
<modules>
<Techievolve_Freeproduct>
<active>false</active>
<codePool>community</codePool>
<depends>
<Mage_Sales />
</depends>
</Techievolve_Freeproduct>
</modules>
</config>
app/design/frontend/smartwave/porto/layout/freeproduct.xml
<?xml version="1.0" encoding="UTF-8"?>
<layout version="1.0.0">
<checkout_cart_index>
<reference name="checkout.cart">
<action method="addItemRender">
<type>simple</type>
<block>checkout/cart_item_renderer</block>
<template>freeproduct/checkout/cart/item/default.phtml</template>
</action>
<action method="addItemRender">
<type>virtual</type>
<block>checkout/cart_item_renderer</block>
<template>freeproduct/checkout/cart/item/default.phtml</template>
</action>
</reference>
</checkout_cart_index>
</layout>
app/design/frontend/smartwave/porto/template/freeproduct/checkout/cart/item/default.phtml
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category design
* @package base_default
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
<?php
$_item = $this->getItem();
// BEGIN CHANGE Techievolve_Freeproduct: Set gift items to not visible, so edit and wishlist are hidden
$isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility() && $_item->getIsFreeProduct() == false;
// END CHANGE Techievolve_Freeproduct
$canApplyMsrp = Mage::helper('catalog')->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM);
$store = Mage::app()->getStore();
$code = $store->getCode();
$aspect_ratio = Mage::getStoreConfig("porto_settings/category/aspect_ratio",$code);
$ratio = ($aspect_ratio || (!$aspect_ratio && Mage::getStoreConfig("porto_settings/category/ratio_width",$code) == 0))?1:(Mage::getStoreConfig("porto_settings/category/ratio_height",$code)/Mage::getStoreConfig("porto_settings/category/ratio_width",$code));
?>
<tr>
<!--BEGIN CHANGE Techievolve_Freeproduct: Gift items are not deletable-->
<td class="action-td">
<?php if (!$_item->getIsFreeProduct()) : ?>
<a href="<?php echo $this->getDeleteUrl()?>" title="<?php echo $this->__('Remove item')?>" class="btn-remove btn-remove2"><?php echo $this->__('Remove item')?></a>
<?php endif; ?>
</td>
<td class="pr-img-td"><?php if ($this->hasProductUrl()):?><a href="<?php echo $this->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getProductName()) ?>" class="product-image"><?php endif;?><img src="<?php echo $this->getProductThumbnail()->resize(80,80*$ratio); ?>" width="80" height="<?php echo 80*$ratio ?>" alt="<?php echo $this->htmlEscape($this->getProductName()) ?>" /><?php if ($this->hasProductUrl()):?></a><?php endif;?></td>
<td class="product-name-td">
<h2 class="product-name">
<?php if ($this->hasProductUrl()):?>
<a href="<?php echo $this->getProductUrl() ?>"><?php echo $this->htmlEscape($this->getProductName()) ?></a>
<?php else: ?>
<?php echo $this->htmlEscape($this->getProductName()) ?>
<?php endif; ?>
</h2>
<?php if ($_options = $this->getOptionList()):?>
<dl class="item-options">
<?php foreach ($_options as $_option) : ?>
<?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
<dt><?php echo $this->htmlEscape($_option['label']) ?></dt>
<dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
<?php if (isset($_formatedOptionValue['full_view'])): ?>
<div class="truncated_full_value">
<dl class="item-options">
<dt><?php echo $this->htmlEscape($_option['label']) ?></dt>
<dd><?php echo $_formatedOptionValue['full_view'] ?></dd>
</dl>
</div>
<?php endif; ?>
</dd>
<?php endforeach; ?>
</dl>
<?php endif;?>
<?php if ($messages = $this->getMessages()): ?>
<?php foreach ($messages as $message): ?>
<p class="item-msg <?php echo $message['type'] ?>">* <?php echo $message['text'] ?></p>
<?php endforeach; ?>
<?php endif; ?>
<?php if ($addtInfoBlock = $this->getProductAdditionalInformationBlock()):?>
<?php echo $addtInfoBlock->setItem($_item)->toHtml() ?>
<?php endif;?>
</td>
<?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
<td>
<?php if ($isVisibleProduct): ?>
<a href="<?php echo $this->helper('wishlist')->getMoveFromCartUrl($_item->getId()); ?>" class="link-wishlist use-ajax"><?php echo $this->__('Move'); ?></a>
<?php endif ?>
</td>
<?php endif ?>
<?php if ($canApplyMsrp): ?>
<td<?php if ($this->helper('tax')->displayCartBothPrices()): ?> colspan="2"<?php endif; ?>>
<span class="cart-price">
<span class="cart-msrp-unit"><?php echo $this->__('See price before order confirmation.'); ?></span>
<?php $helpLinkId = 'cart-msrp-help-' . $_item->getId(); ?>
<a id="<?php echo $helpLinkId ?>" href="#" class="map-help-link"><?php echo $this->__("What's this?"); ?></a>
<script type="text/javascript">
Catalog.Map.addHelpLink($('<?php echo $helpLinkId ?>'), "<?php echo $this->__("What's this?") ?>");
</script>
</span>
</td>
<?php else: ?>
<?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
<td>
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<span class="cart-tax-total" onclick="taxToggle('eunit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
<?php else: ?>
<span class="cart-price">
<?php endif; ?>
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
<?php else: ?>
<?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()) ?>
<?php endif; ?>
</span>
<?php if (Mage::helper('weee')->getApplied($_item)): ?>
<div class="cart-tax-info" id="eunit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
<?php endforeach; ?>
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
<?php endforeach; ?>
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
<?php endforeach; ?>
<?php endif; ?>
</div>
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<div class="cart-tax-total" onclick="taxToggle('eunit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
<span class="weee"><?php echo Mage::helper('weee')->__('Total'); ?>: <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?></span>
</div>
<?php endif; ?>
<?php endif; ?>
</td>
<?php endif; ?>
<?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
<td>
<?php $_incl = $this->helper('checkout')->getPriceInclTax($_item); ?>
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<span class="cart-tax-total" onclick="taxToggle('unit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
<?php else: ?>
<span class="cart-price">
<?php endif; ?>
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<?php echo $this->helper('checkout')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?>
<?php else: ?>
<?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?>
<?php endif; ?>
</span>
<?php if (Mage::helper('weee')->getApplied($_item)): ?>
<div class="cart-tax-info" id="unit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
<?php endforeach; ?>
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
<?php endforeach; ?>
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
<?php endforeach; ?>
<?php endif; ?>
</div>
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<div class="cart-tax-total" onclick="taxToggle('unit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
<span class="weee"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>: <?php echo $this->helper('checkout')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?></span>
</div>
<?php endif; ?>
<?php endif; ?>
</td>
<?php endif; ?>
<?php endif; ?>
<td>
<?php // BEGIN CHANGE Techievolve_Freeproduct: The qty of gift items is not editable ?>
<?php if ($_item->getIsFreeProduct()) : ?>
<?php echo $this->getQty() ?>
<?php else: ?>
<div class="qty-holder">
<a href="javascript:void(0)" class="table_qty_dec">-</a><input name="cart[<?php echo $_item->getId() ?>][qty]" value="<?php echo $this->getQty() ?>" size="4" title="<?php echo $this->__('Qty') ?>" class="input-text qty" maxlength="12" /><a href="javascript:void(0)" class="table_qty_inc">+</a>
<?php if ($isVisibleProduct): ?>
<a class="edit-qty" href="<?php echo $this->getConfigureUrl() ?>" title="<?php echo $this->__('Edit item parameters') ?>"><i class="icon-pencil"></i></a>
<?php endif ?>
</div>
<?php /* <input name="cart[<?php echo $_item->getId() ?>][qty]" value="<?php echo $this->getQty() ?>" size="4" title="<?php echo $this->__('Qty') ?>" class="input-text qty" maxlength="12" /> */ ?>
<?php endif; ?>
<?php // END CHANGE Techievolve_Freeproduct ?>
</td>
<?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
<td class="td-total">
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<span class="cart-tax-total" onclick="taxToggle('esubtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
<?php else: ?>
<span class="cart-price">
<?php endif; ?>
<?php if ($canApplyMsrp): ?>
<span class="cart-msrp-subtotal">--</span>
<?php else: ?>
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?>
<?php else: ?>
<?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()) ?>
<?php endif; ?>
<?php endif; ?>
</span>
<?php if (Mage::helper('weee')->getApplied($_item)): ?>
<div class="cart-tax-info" id="esubtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
<?php endforeach; ?>
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
<?php endforeach; ?>
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
<?php endforeach; ?>
<?php endif; ?>
</div>
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<div class="cart-tax-total" onclick="taxToggle('esubtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
<span class="weee"><?php echo Mage::helper('weee')->__('Total'); ?>: <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span>
</div>
<?php endif; ?>
<?php endif; ?>
</td>
<?php endif; ?>
<?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
<td>
<?php $_incl = $this->helper('checkout')->getSubtotalInclTax($_item); ?>
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<span class="cart-tax-total" onclick="taxToggle('subtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
<?php else: ?>
<span class="cart-price">
<?php endif; ?>
<?php if ($canApplyMsrp): ?>
<span class="cart-msrp-subtotal">--</span>
<?php else: ?>
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<?php echo $this->helper('checkout')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
<?php else: ?>
<?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?>
<?php endif; ?>
<?php endif; ?>
</span>
<?php if (Mage::helper('weee')->getApplied($_item)): ?>
<div class="cart-tax-info" id="subtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
<?php endforeach; ?>
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
<?php endforeach; ?>
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
<?php endforeach; ?>
<?php endif; ?>
</div>
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<div class="cart-tax-total" onclick="taxToggle('subtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
<span class="weee"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>: <?php echo $this->helper('checkout')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span>
</div>
<?php endif; ?>
<?php endif; ?>
</td>
<?php endif; ?>
<?php // END CHANGE Techievolve_Freeproduct ?>
</tr>
![]()
0 Comments