Nayati_ProductGift - Version 1.0.0

Version Notes

This is Stable version

Download this release

Release Info

Developer Benjamin
Extension Nayati_ProductGift
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (30) hide show
  1. app/code/community/Nayati/ProductGift/Adminhtml/Block/Catalog/Product/Grid.php +144 -0
  2. app/code/community/Nayati/ProductGift/Adminhtml/Block/Catalog/Product/Grid/Skus.php +33 -0
  3. app/code/community/Nayati/ProductGift/Block/Giftview.php +9 -0
  4. app/code/community/Nayati/ProductGift/Helper/Data.php +20 -0
  5. app/code/community/Nayati/ProductGift/Model/Giftskus.php +13 -0
  6. app/code/community/Nayati/ProductGift/Model/Observer.php +377 -0
  7. app/code/community/Nayati/ProductGift/Model/Resource/Eav/Mysql4/Setup.php +11 -0
  8. app/code/community/Nayati/ProductGift/Model/Resource/Giftskus.php +12 -0
  9. app/code/community/Nayati/ProductGift/Model/Resource/Giftskus/Collection.php +15 -0
  10. app/code/community/Nayati/ProductGift/Model/System/Config/Source/Dropdown/Values.php +21 -0
  11. app/code/community/Nayati/ProductGift/Model/System/Config/Source/Enabledisable.php +17 -0
  12. app/code/community/Nayati/ProductGift/controllers/CartController.php +272 -0
  13. app/code/community/Nayati/ProductGift/etc/adminhtml.xml +23 -0
  14. app/code/community/Nayati/ProductGift/etc/config.xml +210 -0
  15. app/code/community/Nayati/ProductGift/etc/system.xml +41 -0
  16. app/code/community/Nayati/ProductGift/sql/productgift_setup/mysql4-install-1.0.0.php +8 -0
  17. app/code/community/Nayati/ProductGift/sql/productgift_setup/mysql4-upgrade-1.0.0-1.1.0.php +152 -0
  18. app/design/adminhtml/default/default/layout/salesitem.xml +28 -0
  19. app/design/adminhtml/default/default/template/freegift/default.phtml +236 -0
  20. app/design/adminhtml/default/default/template/freegift/items.phtml +54 -0
  21. app/design/frontend/base/default/layout/cataloggift.xml +59 -0
  22. app/design/frontend/base/default/template/freegift/catalog/product/image.phtml +23 -0
  23. app/design/frontend/base/default/template/freegift/catalog/product/list.phtml +118 -0
  24. app/design/frontend/base/default/template/freegift/default.phtml +276 -0
  25. app/design/frontend/base/default/template/freegift/gifts.phtml +94 -0
  26. app/etc/modules/Nayati_ProductGift.xml +10 -0
  27. package.xml +22 -0
  28. skin/frontend/default/default/css/giftproduct.css +14 -0
  29. skin/frontend/default/default/images/free.png +0 -0
  30. skin/frontend/default/default/images/gift_list.png +0 -0
app/code/community/Nayati/ProductGift/Adminhtml/Block/Catalog/Product/Grid.php ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @author Nayati
5
+ *
6
+ */
7
+ ?>
8
+ <?php
9
+ class Nayati_ProductGift_Adminhtml_Block_Catalog_Product_Grid extends Mage_Adminhtml_Block_Catalog_Product_Grid
10
+ {
11
+ protected function _prepareCollection()
12
+ {
13
+ /* To override the admin product grid */
14
+ $store = $this->_getStore();
15
+ $collection = Mage::getModel('catalog/product')->getCollection()
16
+ ->addAttributeToSelect('sku')
17
+ ->addAttributeToSelect('name')
18
+ ->addAttributeToSelect('attribute_set_id')
19
+ ->addAttributeToSelect('type_id')
20
+ ->addAttributeToSelect('sku_of_product_gift')
21
+ ->addAttributeToSelect('is_product_gift_enabled');
22
+ // ->addAttributeToSelect('sku_of_product_gift');
23
+
24
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
25
+ $collection->joinField('qty',
26
+ 'cataloginventory/stock_item',
27
+ 'qty',
28
+ 'product_id=entity_id',
29
+ '{{table}}.stock_id=1',
30
+ 'left');
31
+ }
32
+ if ($store->getId()) {
33
+ $adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
34
+ $collection->addStoreFilter($store);
35
+ $collection->joinAttribute(
36
+ 'name',
37
+ 'catalog_product/name',
38
+ 'entity_id',
39
+ null,
40
+ 'inner',
41
+ $adminStore
42
+ );
43
+ $collection->joinAttribute(
44
+ 'custom_name',
45
+ 'catalog_product/name',
46
+ 'entity_id',
47
+ null,
48
+ 'inner',
49
+ $store->getId()
50
+ );
51
+ $collection->joinAttribute(
52
+ 'status',
53
+ 'catalog_product/status',
54
+ 'entity_id',
55
+ null,
56
+ 'inner',
57
+ $store->getId()
58
+ );
59
+ $collection->joinAttribute(
60
+ 'visibility',
61
+ 'catalog_product/visibility',
62
+ 'entity_id',
63
+ null,
64
+ 'inner',
65
+ $store->getId()
66
+ );
67
+ $collection->joinAttribute(
68
+ 'price',
69
+ 'catalog_product/price',
70
+ 'entity_id',
71
+ null,
72
+ 'left',
73
+ $store->getId()
74
+ );
75
+ }
76
+ else {
77
+ $collection->addAttributeToSelect('price');
78
+ $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner');
79
+ $collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');
80
+ }
81
+
82
+ $this->setCollection($collection);
83
+ /* To make the admin product grid filters work - start*/
84
+ if ($this->getCollection()) {
85
+
86
+ $this->_preparePage();
87
+
88
+ $columnId = $this->getParam($this->getVarNameSort(), $this->_defaultSort);
89
+ $dir = $this->getParam($this->getVarNameDir(), $this->_defaultDir);
90
+ $filter = $this->getParam($this->getVarNameFilter(), null);
91
+
92
+ if (is_null($filter)) {
93
+ $filter = $this->_defaultFilter;
94
+ }
95
+
96
+ if (is_string($filter)) {
97
+ $data = array();
98
+ $filter = base64_decode($filter);
99
+ parse_str(urldecode($filter), $data);
100
+ $this->_setFilterValues($data);
101
+ } else if ($filter && is_array($filter)) {
102
+ $this->_setFilterValues($filter);
103
+ } else if(0 !== sizeof($this->_defaultFilter)) {
104
+ $this->_setFilterValues($this->_defaultFilter);
105
+ }
106
+
107
+ if (isset($this->_columns[$columnId]) && $this->_columns[$columnId]->getIndex()) {
108
+ $dir = (strtolower($dir)=='desc') ? 'desc' : 'asc';
109
+ $this->_columns[$columnId]->setDir($dir);
110
+ $column = $this->_columns[$columnId]->getFilterIndex() ?
111
+ $this->_columns[$columnId]->getFilterIndex() : $this->_columns[$columnId]->getIndex();
112
+ $this->getCollection()->setOrder($column , $dir);
113
+ }
114
+
115
+ $this->getCollection()->load();
116
+ $this->_afterLoadCollection();
117
+ }
118
+ /* To make the admin product grid filters work - end */
119
+ $this->getCollection()->addWebsiteNamesToResult();
120
+ return $this;
121
+
122
+ }
123
+ protected function _prepareColumns()
124
+ {
125
+ if(Mage::helper('core')->isModuleOutputEnabled('Nayati_ProductGift') && Mage::getStoreConfigFlag('productgiftsection/productgiftgroup/productgiftstatus'))
126
+ {
127
+ $this->addColumnAfter('is_product_gift_enabled', array(
128
+ 'header' => Mage::helper('catalog')->__('Gift Product'),
129
+ 'width' => '80px',
130
+ 'type' => 'options',
131
+ 'index' => 'is_product_gift_enabled',
132
+ 'options' => array( 0 => 'No', 1 => 'Yes')
133
+ ),'name');
134
+
135
+ $this->addColumnAfter('sku_of_product_gift', array(
136
+ 'header' => Mage::helper('catalog')->__("Gift Product Sku's"),
137
+ 'width' => '80px',
138
+ 'index' => 'sku_of_product_gift',
139
+ 'renderer' => 'Nayati_ProductGift_Adminhtml_Block_Catalog_Product_Grid_Skus'
140
+ ),'name');
141
+ }
142
+ parent::_prepareColumns();
143
+ }
144
+ }
app/code/community/Nayati/ProductGift/Adminhtml/Block/Catalog/Product/Grid/Skus.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @author Nayati
5
+ *
6
+ */
7
+ ?>
8
+ <?php
9
+ class Nayati_ProductGift_Adminhtml_Block_Catalog_Product_Grid_Skus extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
10
+ {
11
+ public function render(Varien_Object $row)
12
+ {
13
+ $value = $row->getData($this->getColumn()->getIndex());
14
+ if($value == "") {
15
+ return 0;
16
+ } else {
17
+ $skus = explode(",", $value);
18
+ // $Skus = implode("<br/>", $skus);
19
+ $Skus = "";
20
+ $count = 1;
21
+ foreach($skus as $sku) {
22
+ $Skus .= $count . ". " . $sku ."<br/>";
23
+ $count++;
24
+ }
25
+ return $Skus;
26
+ }
27
+ }
28
+ public function filter(Varien_Data_Collection_Db $collection, Mage_Adminhtml_Block_Widget_Grid_Column $column)
29
+ {
30
+ Mage::log('My log entry', null, 'mylogfile.log');
31
+ }
32
+ }
33
+ ?>
app/code/community/Nayati/ProductGift/Block/Giftview.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @author Nayati
5
+ *
6
+ */
7
+ class Nayati_ProductGift_Block_Giftview extends Mage_Catalog_Block_Product_View
8
+ {
9
+ }
app/code/community/Nayati/ProductGift/Helper/Data.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @Description : Create Block of All Gift Products to display on product detail page
4
+ * @author Nayati
5
+ *
6
+ */
7
+
8
+ class Nayati_ProductGift_Helper_Data extends Mage_Core_Helper_Abstract
9
+ {
10
+ /**
11
+ * Create Gift Block to Display on frontend
12
+ * Get All Gift product SKU
13
+ *
14
+ * @return Gift Block to display on Frontend
15
+ */
16
+ public function getBlockGift($skuGift) {
17
+ return;
18
+ }
19
+ }
20
+
app/code/community/Nayati/ProductGift/Model/Giftskus.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @author Nayati
5
+ */
6
+ class Nayati_ProductGift_Model_Giftskus extends Mage_Core_Model_Abstract
7
+ {
8
+ public function _construct()
9
+ {
10
+ parent::_construct();
11
+ $this->_init('productgift/giftskus');
12
+ }
13
+ }
app/code/community/Nayati/ProductGift/Model/Observer.php ADDED
@@ -0,0 +1,377 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @author Nayati
5
+ * @description : this is the observer file for checkout events
6
+ *
7
+ */
8
+
9
+ class Nayati_ProductGift_Model_Observer extends Mage_Core_Model_Abstract{
10
+ protected $_dsr=null;
11
+ const XML_PATH_ENABLED = 'productgiftsection/productgiftgroup/productgiftstatus';
12
+
13
+ /**
14
+ * Get id of gift added
15
+ *
16
+ * @return Mage_Checkout_Model_Session
17
+ */
18
+ public function addGift($observer)
19
+ {
20
+ if(Mage::helper('core')->isModuleOutputEnabled('Nayati_ProductGift') && Mage::getStoreConfigFlag(self::XML_PATH_ENABLED)){
21
+ $productData = $observer->getEvent()->getProduct();
22
+ $quoteData = $observer->getEvent()->getQuoteItem();
23
+
24
+ if (!$productData->getData('is_product_gift_enabled')) return $this;
25
+ // Checking if Gift Active time is expired
26
+ $giftActiveFrom = $productData->getData('product_gift_active_from');
27
+ $giftActiveTo = $productData->getData('product_gift_active_to');
28
+ $timestamp1 = strtotime($giftActiveFrom);
29
+ $timeNow = time();
30
+ $timestamp2 = strtotime($giftActiveTo);
31
+
32
+ if(empty($timestamp1) && empty($timestamp2))
33
+ {
34
+
35
+ }
36
+ elseif(!($timeNow > $timestamp1 && $timeNow < $timestamp2)){
37
+ return $this;
38
+ }
39
+ // Fetch all cart items
40
+ $obj=Mage::getSingleton('checkout/cart');
41
+ $quoteItem = $obj->getQuote();
42
+ // Get All Gift options available
43
+ $skuGift=$productData->getData('sku_of_product_gift');
44
+ $skuOfGiftItem = explode(',',$skuGift);
45
+ //Check the Quantity of free gift added to cart
46
+ if ($quoteData->getParentItem()){
47
+ $qtyCurrent=$quoteData->getParentItem()->getQty();
48
+ $qtyActual=$quoteData->getParentItem()->getQtyToAdd();
49
+ }else{
50
+ $qtyCurrent=$quoteData->getQty();
51
+ $qtyActual=$quoteData->getQtyToAdd();
52
+ }
53
+ //Get the selected gift product From Session
54
+ $giftCustomId = Mage::getSingleton('core/session')->getMyGiftId();
55
+ $cartItems = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
56
+
57
+
58
+ if(isset($giftCustomId)){
59
+ $prodGift = Mage::getModel('catalog/product')->load($giftCustomId);
60
+ }
61
+ else{
62
+ $prodGift = Mage::getModel('catalog/product')->loadByAttribute('sku', $skuOfGiftItem[0]);
63
+ }
64
+
65
+
66
+
67
+ if ($qtyCurrent != $qtyActual) {
68
+ foreach ($quoteItem->getItemsCollection() as $it) {
69
+ $ops=$it->getOptionByCode('gift_for_product_id');
70
+ if($ops) {
71
+ if ($ops->getValue()==$quoteData->getProduct()->getId()) {
72
+ $it->setQty($qtyCurrent);
73
+ $quoteItem->save();
74
+ return $this;
75
+ }
76
+ }
77
+ }
78
+ }
79
+
80
+ $prodGiftId = array($prodGift->getId());
81
+ $oldi=$quoteItem->getItemByProduct($prodGift);
82
+ if ($oldi) {
83
+ $option = Mage::getModel('sales/quote_item_option')
84
+ ->setProductId($prodGift->getId())
85
+ ->setCode('gift_for_product_id')
86
+ ->setProduct($prodGift)
87
+ ->setValue(null);
88
+ $oldi->addOption($option);
89
+ $quoteItem->save();
90
+ }
91
+
92
+ $gicu=$obj->addProductsByIds($prodGiftId);
93
+ $giftItem = $quoteItem->getItemByProduct($prodGift);
94
+
95
+ $option = Mage::getModel('sales/quote_item_option')
96
+ ->setProductId($prodGift->getId())
97
+ ->setCode('gift_for_product_id')
98
+ ->setProduct($prodGift)
99
+ ->setValue($quoteData->getProduct()->getId());
100
+
101
+ $giftItem->addOption($option);
102
+ $item = $giftItem;
103
+ $additionalOptions = array(
104
+ array(
105
+ 'code' => 'my_code',
106
+ 'label' => 'Gift of '.$productData->getName(),
107
+ 'value' => 'Free Product!!!'
108
+ )
109
+ );
110
+ $item->addOption(
111
+ array(
112
+ 'code' => 'additional_options',
113
+ 'value' => serialize($additionalOptions),
114
+ )
115
+ );
116
+ $options=$giftItem->getOptionsByCode();
117
+ // Updating the price of free Gift product to Zero
118
+ $giftItem->setCustomPrice(0);
119
+ $giftItem->setOriginalCustomPrice(0);
120
+ $giftItem->getProduct()->setIsSuperMode(true);
121
+ $giftItem->setQty($qtyCurrent);
122
+ $quoteItem->save();
123
+ Mage::getSingleton('core/session')->unsMyGiftId();
124
+ unset($giftCustomId);
125
+ return $this;
126
+ }
127
+ }
128
+ /**
129
+ * Update the products in Cart
130
+ * Get id of gift added
131
+ *
132
+ * @return Mage_Checkout_Model_Session
133
+ */
134
+ public function updatePGift($observer) {
135
+ if(Mage::helper('core')->isModuleOutputEnabled('Nayati_ProductGift') && Mage::getStoreConfigFlag(self::XML_PATH_ENABLED)){
136
+ $productData = $observer->getEvent()->getProduct();
137
+ $free_product = Mage::getSingleton('core/session')->getMyGiftId();
138
+ $quoteId= Mage::getSingleton('checkout/session')->getQuoteId();//add ltr
139
+ $productId=$productData->getId();
140
+ $quoteItemId=Mage::getSingleton('core/session')->getItemIdSession()+1;
141
+ $giftQty=Mage::getSingleton('core/session')->getGiftQty();
142
+ $write = Mage::getSingleton("core/resource")->getConnection("core_write");
143
+ $querySelect = Mage::getModel('productgift/giftskus')->getCollection()
144
+ ->addFieldToFilter('product_id',$productId)
145
+ ->addFieldToFilter('quote_id',$quoteId)
146
+ ->getFirstItem();
147
+ $isModelSet=$querySelect->getId();
148
+
149
+ if(!empty($isModelSet)){
150
+ $queryUpdate="UPDATE `sales_flat_quote_item` SET `product_id`=$free_product,`qty`=$giftQty WHERE `item_id`=$quoteItemId";
151
+ $write->query($queryUpdate);
152
+ }
153
+
154
+ return $this;
155
+ }
156
+ }
157
+ /**
158
+ * Delete the products in Cart
159
+ * Get id of gift added
160
+ *
161
+ * @return Mage_Checkout_Model_
162
+ */
163
+ public function deletePGift($observer) {
164
+
165
+ $quoteItem=$observer->getEvent()->getQuoteItem();
166
+ $productId= Mage::getModel('catalog/product')->load($quoteItem->getProduct()->getId() );
167
+ $cil=$quoteItem->getChildren();
168
+ if (!empty($cil)) {
169
+ $idd= current($quoteItem->getChildren())->getProduct()->getId() ;
170
+ }
171
+ else {
172
+ $idd=$quoteItem->getProduct()->getId() ;
173
+ }
174
+ $is = $productId->getData('is_product_gift_enabled');
175
+ if (!$is) return $this;
176
+
177
+ $obj=Mage::getSingleton('checkout/cart');
178
+ $quoteItemNew=$obj->getQuote();
179
+ foreach ($quoteItemNew->getItemsCollection() as $it) {
180
+ $ops=$it->getOptionByCode('gift_for_product_id');
181
+ if($ops) {
182
+ if ($ops->getValue()==$idd) {
183
+ $obj->removeItem($it->getItemId());
184
+ $quoteItemNew->save();
185
+ return $this;
186
+ }
187
+ }
188
+ }
189
+ return $this;
190
+ }
191
+ /**
192
+ * Check SKU are valid in Admin
193
+ * Get id of gift added
194
+ *
195
+ * @return Mage_Checkout_Model_Session
196
+ */
197
+ public function checkSKU($observer) {
198
+ if(Mage::helper('core')->isModuleOutputEnabled('Nayati_ProductGift') && Mage::getStoreConfigFlag(self::XML_PATH_ENABLED)){
199
+ $productItem = $observer->getEvent()->getProduct();
200
+ $productsku =$productItem->getSku();
201
+ $productEnabled =$productItem->getIsProductGiftEnabled();
202
+ if($productEnabled){
203
+ $skuGift=$productItem->getData('sku_of_product_gift');
204
+ if(empty($skuGift))
205
+ {
206
+ $productItem->setData('is_product_gift_enabled','0');
207
+ $productItem->save();
208
+
209
+ return;
210
+
211
+ }
212
+ $productSkus = explode(',',$skuGift);
213
+ $productSkusUnique = array_unique($productSkus);
214
+ if(count($productSkus)!=count($productSkusUnique))
215
+ {
216
+ Mage::throwException("Duplicate Sku's are not allowed");
217
+ }
218
+ $collection = Mage::getModel('catalog/product')->getCollection();
219
+ $collection->addAttributeToSelect('is_product_gift_enabled');
220
+ $collection->addAttributeToSelect('sku_of_product_gift');
221
+ $collection->addFieldToFilter(array(
222
+ array('attribute'=>'is_product_gift_enabled','eq'=>'1'),
223
+ ));
224
+ $collection->addFieldToFilter(array(
225
+ array('attribute'=>'sku_of_product_gift','like'=>'%'.$productsku.'%'),
226
+ ));
227
+
228
+ foreach($collection->getData() as $dataSku)
229
+ {
230
+ $collectionSkus = explode(',',$dataSku['sku_of_product_gift']);
231
+ if(in_array($productsku,$collectionSkus))
232
+ {
233
+ Mage::throwException('This product is already a gift product');
234
+ }
235
+ }
236
+
237
+ if (!$productItem->getData('is_product_gift_enabled')) return $this;
238
+
239
+ $FromGift=strtotime($productItem->getData('product_gift_active_from'));
240
+ $ToGift=strtotime($productItem->getData('product_gift_active_to'));
241
+
242
+ foreach($productSkus as $sku):
243
+ $skuLoad=Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
244
+ if(!empty($skuLoad) && Mage::getModel('catalog/product')->loadByAttribute('sku', $sku)->getData('type_id')!='simple'){Mage::throwException('Only simple products are allowed as a gift'); }
245
+ if (!Mage::getModel('catalog/product')->loadByAttribute('sku', $sku)) Mage::throwException('SKU for gift is invalid!');
246
+ if(Mage::getModel('catalog/product')->loadByAttribute('sku', $sku)->getData('is_product_gift_enabled'))
247
+ {
248
+ Mage::throwException('SKU : '.$sku.' is having a gift product');
249
+ }
250
+ endforeach;
251
+ if($FromGift>$ToGift){
252
+ Mage::throwException('Invalid From and To Dates.');
253
+ }
254
+ elseif((empty($FromGift) && !empty($ToGift)) || (!empty($FromGift) && empty($ToGift))){
255
+ Mage::throwException('Invalid Dates.');
256
+ }
257
+ }
258
+ }
259
+ }
260
+
261
+ public function updtatePGiftA($observer) {
262
+ if(Mage::helper('core')->isModuleOutputEnabled('Nayati_ProductGift') && Mage::getStoreConfigFlag(self::XML_PATH_ENABLED)){
263
+ $dat=$observer->getEvent()->getInfo();
264
+ $itemList=array();
265
+ $read = Mage::getSingleton("core/resource")->getConnection("core_read");
266
+ $querySelect=$read->fetchAll("select gift_product_item_id from giftskus");
267
+ foreach($querySelect as $testData){
268
+ array_push($itemList,$testData[gift_product_item_id]-1);
269
+ }
270
+
271
+ $prev_i=null;
272
+ foreach ($dat as $itemId => $itemInfo){
273
+
274
+ if(in_array($itemId,$itemList)){
275
+
276
+ $write = Mage::getSingleton("core/resource")->getConnection("core_write");
277
+ $giftQty=$itemInfo['qty'];
278
+ $itemIdNext=(int)$itemId+1;
279
+ $queryUpdate="UPDATE `sales_flat_quote_item` SET `qty`=$giftQty WHERE `item_id`=$itemIdNext";
280
+ $write->query($queryUpdate);
281
+ }
282
+
283
+
284
+ }
285
+
286
+ return $this;
287
+ }
288
+ }
289
+ public function noUpdateGift($observer)
290
+ {
291
+ $controllerAction = $observer->getControllerAction();
292
+ $request = $controllerAction->getRequest();
293
+ $controllerName = $request->getControllerName();
294
+ $actionName = $request->getActionName();
295
+ $itemid = $request->getParam('id');
296
+ if($controllerName=='cart' && ($actionName == 'configure' || $actionName == 'delete'))
297
+ {
298
+ $giftItem = Mage::getModel('productgift/giftskus')->getCollection()
299
+ ->addFieldToFilter('gift_product_item_id',$itemid)
300
+ ->getFirstItem();
301
+ $giftItemId=$giftItem->getId();
302
+ if(!empty($giftItemId))
303
+ {
304
+
305
+ Mage::app()->getResponse()->setRedirect(Mage::getUrl('checkout/cart'));
306
+ Mage::app()->getResponse()->sendResponse();
307
+ exit;
308
+ }
309
+ }
310
+ if($controllerName=='order' && ($actionName == 'reorder'))
311
+ {
312
+ $orderId = $request->getParam('order_id');
313
+ $order = Mage::getModel('sales/order')->load($orderId);
314
+ $items = $order->getAllItems();
315
+ $flagSimple='';
316
+ foreach ($items as $itemId => $item)
317
+ {
318
+ if(number_format($item->getPrice(), 2, '.', '')=="0.00" && $item->getProductType()=="simple" && $flagSimple!=NULL && $item->getParentItemId()==NULL)
319
+ {
320
+ Mage::getSingleton('checkout/session')->addError("Order having free product(s). Please add products manually.");
321
+ Mage::app()->getResponse()->setRedirect(Mage::getUrl(''));
322
+ Mage::app()->getResponse()->sendResponse();
323
+ exit;
324
+ }
325
+
326
+ $flagSimple=$item->getName();
327
+ }
328
+
329
+ }
330
+
331
+ }
332
+ public function checkoutValidation($observer)
333
+ {
334
+ $cart = Mage::getModel('checkout/cart')->getQuote();
335
+ $flag='';
336
+ $flagName='';
337
+ foreach ($cart->getAllItems() as $item)
338
+ {
339
+ $giftItemId=array();
340
+ $giftItem = Mage::getModel('productgift/giftskus')->getCollection()
341
+ ->addFieldToFilter('gift_product_item_id',$item->getId())
342
+ ->getFirstItem();
343
+ $productId=$giftItem->getProductId();
344
+ if(!empty($productId))
345
+ {
346
+ if($flag==$productId)
347
+ {
348
+ $giftSkus=Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'sku_of_product_gift',Mage::app()->getStore()->getStoreId());
349
+ $isGiftEn=Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'is_product_gift_enabled',Mage::app()->getStore()->getStoreId());
350
+ $isGiftFrom=strtotime(Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'product_gift_active_from',Mage::app()->getStore()->getStoreId()));
351
+ $isGiftTo= strtotime(Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'product_gift_active_to',Mage::app()->getStore()->getStoreId()));
352
+ $skus = explode(',',$giftSkus);
353
+ if(in_array($item->getSku(),$skus)!=1 || !$isGiftEn || ($isGiftTo<time() && !empty($isGiftTo)) || ($isGiftFrom>time() && !empty($isGiftFrom)) || !Mage::helper('core')->isModuleOutputEnabled('Nayati_ProductGift') || !Mage::getStoreConfigFlag(self::XML_PATH_ENABLED))
354
+ {
355
+ Mage::throwException($flagName.' - Gift product offer is expired. Please remove it from your cart.');
356
+ }
357
+ }
358
+ }
359
+ $giftItemId[]=$giftItem->getProductId();
360
+ $flag=$item->getProductId();
361
+ $flagName=$item->getName();
362
+ }
363
+
364
+ return;
365
+ }
366
+
367
+ public function salesConvertQuoteItemToOrderItem(Varien_Event_Observer $observer)
368
+ {
369
+ $quoteItem = $observer->getItem();
370
+ if ($additionalOptions = $quoteItem->getOptionByCode('additional_options')) {
371
+ $orderItem = $observer->getOrderItem();
372
+ $options = $orderItem->getProductOptions();
373
+ $options['additional_options'] = unserialize($additionalOptions->getValue());
374
+ $orderItem->setProductOptions($options);
375
+ }
376
+ }
377
+ }
app/code/community/Nayati/ProductGift/Model/Resource/Eav/Mysql4/Setup.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Nayati
4
+ */
5
+ class Nayati_ProductGift_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup {
6
+
7
+ public function getDefaultEntities() {
8
+ return;
9
+
10
+ }
11
+ }
app/code/community/Nayati/ProductGift/Model/Resource/Giftskus.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @author Nayati
5
+ */
6
+ class Nayati_ProductGift_Model_Resource_Giftskus extends Mage_Core_Model_Mysql4_Abstract
7
+ {
8
+ public function _construct()
9
+ {
10
+ $this->_init('productgift/giftskus', 'id');
11
+ }
12
+ }
app/code/community/Nayati/ProductGift/Model/Resource/Giftskus/Collection.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @author Nayati
5
+ */
6
+ class Nayati_ProductGift_Model_Resource_Giftskus_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
7
+ {
8
+ public function _construct()
9
+ {
10
+ parent::_construct();
11
+ $this->_init('productgift/giftskus');
12
+ }
13
+ }
14
+
15
+ ?>
app/code/community/Nayati/ProductGift/Model/System/Config/Source/Dropdown/Values.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @author Nayati
5
+ */
6
+ class Nayati_ProductGift_Model_System_Config_Source_Dropdown_Values
7
+ {
8
+ public function toOptionArray()
9
+ {
10
+ return array(
11
+ array(
12
+ 'value' => 'key1',
13
+ 'label' => 'Value 1',
14
+ ),
15
+ array(
16
+ 'value' => 'key2',
17
+ 'label' => 'Value 2',
18
+ ),
19
+ );
20
+ }
21
+ }
app/code/community/Nayati/ProductGift/Model/System/Config/Source/Enabledisable.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @author Nayati
5
+ */
6
+
7
+
8
+ class Nayati_ProductGift_Model_System_Config_Source_Enabledisable
9
+ {
10
+ public function toOptionArray()
11
+ {
12
+ return array(
13
+ array('value'=>1, 'label'=>Mage::helper('adminhtml')->__('Enable')),
14
+ array('value'=>0, 'label'=>Mage::helper('adminhtml')->__('Disable')),
15
+ );
16
+ }
17
+ }
app/code/community/Nayati/ProductGift/controllers/CartController.php ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Product Gift cart controller
4
+ * @author Nayati
5
+ */
6
+ require_once 'Mage/Checkout/controllers/CartController.php';
7
+ class Nayati_ProductGift_CartController extends Mage_Checkout_CartController
8
+ {
9
+ const XML_PATH_ENABLED = 'productgiftsection/productgiftgroup/productgiftstatus';
10
+
11
+ public function addAction()
12
+ {
13
+ $cart = $this->_getCart();
14
+ $params = $this->getRequest()->getParams();
15
+ try {
16
+ if (isset($params['qty'])) {
17
+ $filter = new Zend_Filter_LocalizedToNormalized(
18
+ array('locale' => Mage::app()->getLocale()->getLocaleCode())
19
+ );
20
+ $params['qty'] = $filter->filter($params['qty']);
21
+ }
22
+
23
+ $product = $this->_initProduct();
24
+ $related = $this->getRequest()->getParam('related_product');
25
+
26
+
27
+
28
+ if (!$product) {
29
+ $this->_goBack();
30
+ return;
31
+ }
32
+
33
+ $cart->addProduct($product, $params);
34
+ if (!empty($related)) {
35
+ $cart->addProductsByIds(explode(',', $related));
36
+ }
37
+
38
+ $cart->save();
39
+
40
+ $this->_getSession()->setCartWasUpdated(true);
41
+
42
+ $free_product = $this->getRequest()->getParam('free_gift');
43
+
44
+ $isGiftAvl=Mage::getResourceModel('catalog/product')->getAttributeRawValue($product->getId(), 'sku_of_product_gift',Mage::app()->getStore()->getStoreId());
45
+ $isGiftEn=Mage::getResourceModel('catalog/product')->getAttributeRawValue($product->getId(), 'is_product_gift_enabled',Mage::app()->getStore()->getStoreId());
46
+ $isGiftFrom=strtotime(Mage::getResourceModel('catalog/product')->getAttributeRawValue($product->getId(), 'product_gift_active_from',Mage::app()->getStore()->getStoreId()));
47
+ $isGiftTo= strtotime(Mage::getResourceModel('catalog/product')->getAttributeRawValue($product->getId(), 'product_gift_active_to',Mage::app()->getStore()->getStoreId()));
48
+
49
+ if(empty($free_product) && $isGiftEn && !empty($isGiftAvl))
50
+ {
51
+ $allSku = explode(",", $isGiftAvl);
52
+ $firstSku = $allSku[0];
53
+ //$free_product = $this->getRequest()->getParam('free_gift');
54
+ $firstProductId = Mage::getModel("catalog/product")->getIdBySku($firstSku);
55
+ Mage::getSingleton('core/session')->setMyGiftId($firstProductId);
56
+ $free_product=$firstProductId;
57
+
58
+ }
59
+ elseif(empty($isGiftFrom) && empty($isGiftTo) && $isGiftEn && !empty($isGiftAvl))
60
+ {
61
+
62
+ }
63
+
64
+
65
+ if(!empty($free_product) && Mage::helper('core')->isModuleOutputEnabled('Nayati_ProductGift') && Mage::getStoreConfigFlag(self::XML_PATH_ENABLED))
66
+ {
67
+ Mage::getSingleton('core/session')->setMyGiftId($free_product);
68
+ $productAddId=$product->getId();
69
+ $quoteId= Mage::getSingleton('checkout/session')->getQuoteId();//add ltr
70
+ $read1 = Mage::getSingleton("core/resource")->getConnection("core_read");
71
+ $quoteSelect=$read1->fetchAll("select item_id,MAX(updated_at) from sales_flat_quote_item where quote_id='$quoteId' and product_id='$productAddId'");
72
+ $itemQuoteGift=(int)$quoteSelect[0]['item_id']+1;
73
+ $productId=$product->getId();
74
+
75
+ $write = Mage::getSingleton("core/resource")->getConnection("core_write");
76
+ $read = Mage::getSingleton("core/resource")->getConnection("core_read");
77
+ $querySelect=$read->fetchAll("select * from giftskus where quote_id='$quoteId' and product_id='$productId'");
78
+
79
+ if($querySelect==NULL){
80
+
81
+ $query = "insert into giftskus (quote_id, product_id, gift_product_id, gift_product_item_id) values (:quote_id, :product_id, :gift_product_id, :gift_product_item_id)";
82
+
83
+ $binds = array(
84
+ 'quote_id' => $quoteId,
85
+ 'product_id' => $productId,
86
+ 'gift_product_id' => $free_product,
87
+ 'gift_product_item_id' => $itemQuoteGift
88
+ );
89
+
90
+ $write->query($query, $binds);
91
+ }
92
+
93
+ $queryUpdate="UPDATE `sales_flat_quote_item` SET `product_id`=$free_product WHERE `item_id`=$itemQuoteGift";
94
+ //print_r($queryUpdate);exit;
95
+ $write->query($queryUpdate);
96
+
97
+ }
98
+ /**
99
+ * @todo remove wishlist observer processAddToCart
100
+ */
101
+ Mage::dispatchEvent('checkout_cart_add_product_complete',
102
+ array('product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse())
103
+ );
104
+
105
+ if (!$this->_getSession()->getNoCartRedirect(true)) {
106
+ if (!$cart->getQuote()->getHasError()) {
107
+ $message = $this->__('%s was added to your shopping cart.', Mage::helper('core')->escapeHtml($product->getName()));
108
+ $this->_getSession()->addSuccess($message);
109
+ }
110
+ $this->_goBack();
111
+ }
112
+ } catch (Mage_Core_Exception $e) {
113
+ if ($this->_getSession()->getUseNotice(true)) {
114
+ $this->_getSession()->addNotice(Mage::helper('core')->escapeHtml($e->getMessage()));
115
+ } else {
116
+ $messages = array_unique(explode("\n", $e->getMessage()));
117
+ foreach ($messages as $message) {
118
+ $this->_getSession()->addError(Mage::helper('core')->escapeHtml($message));
119
+ }
120
+ }
121
+
122
+ $url = $this->_getSession()->getRedirectUrl(true);
123
+ if ($url) {
124
+ $this->getResponse()->setRedirect($url);
125
+ } else {
126
+ $this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());
127
+ }
128
+ } catch (Exception $e) {
129
+ $this->_getSession()->addException($e, $this->__('Cannot add the item to shopping cart.'));
130
+ Mage::logException($e);
131
+ $this->_goBack();
132
+ }
133
+ }
134
+ /**
135
+ * Update product configuration for a cart item
136
+ */
137
+ public function updateItemOptionsAction()
138
+ {
139
+ $cart = $this->_getCart();
140
+ $id = (int) $this->getRequest()->getParam('id');
141
+ $params = $this->getRequest()->getParams();
142
+
143
+ $sessionItemId = (int) $this->getRequest()->getParam('id');
144
+ Mage::getSingleton('core/session')->setItemIdSession($sessionItemId);
145
+ $free_product = $this->getRequest()->getParam('free_gift');
146
+ Mage::getSingleton('core/session')->setMyGiftId($free_product);
147
+
148
+ Mage::getSingleton('core/session')->setGiftQty($params['qty']);
149
+ if (!isset($params['options'])) {
150
+ $params['options'] = array();
151
+ }
152
+ try {
153
+ if (isset($params['qty'])) {
154
+ $filter = new Zend_Filter_LocalizedToNormalized(
155
+ array('locale' => Mage::app()->getLocale()->getLocaleCode())
156
+ );
157
+ $params['qty'] = $filter->filter($params['qty']);
158
+ }
159
+
160
+ $quoteItem = $cart->getQuote()->getItemById($id);
161
+ if (!$quoteItem) {
162
+ Mage::throwException($this->__('Quote item is not found.'));
163
+ }
164
+
165
+ $item = $cart->updateItem($id, new Varien_Object($params));
166
+ if (is_string($item)) {
167
+ Mage::throwException($item);
168
+ }
169
+ if ($item->getHasError()) {
170
+ Mage::throwException($item->getMessage());
171
+ }
172
+
173
+ $related = $this->getRequest()->getParam('related_product');
174
+ if (!empty($related)) {
175
+ $cart->addProductsByIds(explode(',', $related));
176
+ }
177
+
178
+ $cart->save();
179
+
180
+ $this->_getSession()->setCartWasUpdated(true);
181
+
182
+ Mage::dispatchEvent('checkout_cart_update_item_complete',
183
+ array('item' => $item, 'request' => $this->getRequest(), 'response' => $this->getResponse())
184
+ );
185
+ if (!$this->_getSession()->getNoCartRedirect(true)) {
186
+ if (!$cart->getQuote()->getHasError()) {
187
+ $message = $this->__('%s was updated in your shopping cart.', Mage::helper('core')->escapeHtml($item->getProduct()->getName()));
188
+ $this->_getSession()->addSuccess($message);
189
+ }
190
+ $this->_goBack();
191
+ }
192
+ } catch (Mage_Core_Exception $e) {
193
+ if ($this->_getSession()->getUseNotice(true)) {
194
+ $this->_getSession()->addNotice($e->getMessage());
195
+ } else {
196
+ $messages = array_unique(explode("\n", $e->getMessage()));
197
+ foreach ($messages as $message) {
198
+ $this->_getSession()->addError($message);
199
+ }
200
+ }
201
+
202
+ $url = $this->_getSession()->getRedirectUrl(true);
203
+ if ($url) {
204
+ $this->getResponse()->setRedirect($url);
205
+ } else {
206
+ $this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());
207
+ }
208
+ } catch (Exception $e) {
209
+ $this->_getSession()->addException($e, $this->__('Cannot update the item.'));
210
+ Mage::logException($e);
211
+ $this->_goBack();
212
+ }
213
+ $this->_redirect('*/*');
214
+ }
215
+
216
+ public function deleteAction()
217
+ {
218
+ $id = (int) $this->getRequest()->getParam('id');
219
+ $write = Mage::getSingleton("core/resource")->getConnection("core_write");
220
+ $giftId=$id+1;
221
+ $queryDelete="delete from giftskus where gift_product_item_id =$giftId";
222
+ $write->query($queryDelete);
223
+ if ($id) {
224
+ try {
225
+ $this->_getCart()->removeItem($id)
226
+ ->save();
227
+ } catch (Exception $e) {
228
+ $this->_getSession()->addError($this->__('Cannot remove the item.'));
229
+ Mage::logException($e);
230
+ }
231
+ }
232
+ $this->_redirectReferer(Mage::getUrl('*/*'));
233
+ }
234
+ public function updatePostAction()
235
+ {
236
+
237
+ $updateAction = (string)$this->getRequest()->getParam('update_cart_action');
238
+
239
+ switch ($updateAction) {
240
+ case 'empty_cart':
241
+ $this->_emptyShoppingCart();
242
+
243
+ break;
244
+ case 'update_qty':
245
+ $this->_updateShoppingCart();
246
+ break;
247
+ default:
248
+ $this->_updateShoppingCart();
249
+ }
250
+
251
+ $this->_goBack();
252
+ }
253
+ protected function _emptyShoppingCart()
254
+ {
255
+ try {
256
+ $this->_getCart()->truncate()->save();
257
+ $this->_getSession()->setCartWasUpdated(true);
258
+ $quoteId= Mage::getSingleton('checkout/session')->getQuoteId();
259
+ $write = Mage::getSingleton("core/resource")->getConnection("core_write");
260
+ $queryDelete="delete from giftskus where quote_id=".$quoteId;
261
+ //print_r($queryUpdate);exit;
262
+ $write->query($queryDelete);
263
+ } catch (Mage_Core_Exception $exception) {
264
+ $this->_getSession()->addError($exception->getMessage());
265
+ } catch (Exception $exception) {
266
+ $this->_getSession()->addException($exception, $this->__('Cannot update shopping cart.'));
267
+ }
268
+ }
269
+
270
+ }
271
+
272
+
app/code/community/Nayati/ProductGift/etc/adminhtml.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <productgiftsection translate="title" module="productgift">
12
+ <title>Product Gift Section</title>
13
+ <sort_order>0</sort_order>
14
+ </productgiftsection>
15
+ </children>
16
+ </config>
17
+ </children>
18
+ </system>
19
+ </children>
20
+ </admin>
21
+ </resources>
22
+ </acl>
23
+ </config>
app/code/community/Nayati/ProductGift/etc/config.xml ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @author Nayati
5
+ */
6
+ -->
7
+ <config>
8
+ <modules>
9
+ <Nayati_ProductGift>
10
+ <version>1.1.0</version>
11
+ </Nayati_ProductGift>
12
+ </modules>
13
+ <global>
14
+ <models>
15
+ <productgift>
16
+ <class>Nayati_ProductGift_Model</class>
17
+ <resourceModel>productgift_resource</resourceModel>
18
+ </productgift>
19
+ <productgift_resource>
20
+ <class>Nayati_ProductGift_Model_Resource</class>
21
+ <entities>
22
+ <giftskus>
23
+ <table>giftskus</table>
24
+ </giftskus>
25
+ </entities>
26
+ </productgift_resource>
27
+ </models>
28
+ <blocks>
29
+ <productgift>
30
+ <class>Nayati_ProductGift_Block</class>
31
+ </productgift>
32
+ </blocks>
33
+ <resources>
34
+ <productgift_setup>
35
+ <setup>
36
+ <module>Nayati_ProductGift</module>
37
+ <class>Nayati_ProductGift_Model_Resource_Eav_Mysql4_Setup</class>
38
+ </setup>
39
+ <connection>
40
+ <use>core_setup</use>
41
+ </connection>
42
+ </productgift_setup>
43
+ <productgift_write>
44
+ <connection>
45
+ <use>core_write</use>
46
+ </connection>
47
+ </productgift_write>
48
+ <productgift_read>
49
+ <connection>
50
+ <use>core_read</use>
51
+ </connection>
52
+ </productgift_read>
53
+ </resources>
54
+ <helpers>
55
+ <productgift>
56
+ <class>Nayati_ProductGift_Helper</class>
57
+ </productgift>
58
+ <!--catalog>
59
+ <rewrite>
60
+ <output>Nayati_ProductGift_Helper_Output</output>
61
+ <image>Nayati_ProductGift_Helper_Image</image>
62
+ </rewrite>
63
+ </catalog-->
64
+
65
+ </helpers>
66
+ <events>
67
+ <catalog_product_save_before>
68
+ <observers>
69
+ <productgift_observer>
70
+ <type>singleton</type>
71
+ <class>Nayati_ProductGift_Model_Observer</class>
72
+ <method>checkSKU</method>
73
+ </productgift_observer>
74
+ </observers>
75
+ </catalog_product_save_before>
76
+ </events>
77
+ <blocks>
78
+ <adminhtml>
79
+ <rewrite>
80
+ <catalog_product_grid>Nayati_ProductGift_Adminhtml_Block_Catalog_Product_Grid</catalog_product_grid>
81
+ </rewrite>
82
+ </adminhtml>
83
+ </blocks>
84
+ <sales_convert_order_to_quote>
85
+ <observers>
86
+ <productgift_observer>
87
+ <type>singleton</type>
88
+ <class>Nayati_ProductGift_Model_Observer</class>
89
+ <method>reorder</method>
90
+ </productgift_observer>
91
+ </observers>
92
+ </sales_convert_order_to_quote>
93
+ </global>
94
+ <adminhtml>
95
+ <layout>
96
+ <updates>
97
+ <Nayati_productgift>
98
+ <file>salesitem.xml</file>
99
+ </Nayati_productgift>
100
+ </updates>
101
+ </layout>
102
+ </adminhtml>
103
+ <resources>
104
+ <productgift_setup>
105
+ <setup>
106
+ <module>Nayati_ProductGift</module>
107
+ </setup>
108
+ <connection>
109
+ <use>default_setup</use>
110
+ </connection>
111
+ </productgift_setup>
112
+ <productgift_write>
113
+ <connection>
114
+ <use>default_write</use>
115
+ </connection>
116
+ </productgift_write>
117
+ <productgift_read>
118
+ <connection>
119
+ <use>default_read</use>
120
+ </connection>
121
+ </productgift_read>
122
+ </resources>
123
+ <frontend>
124
+ <events>
125
+ <checkout_cart_product_add_after>
126
+ <observers>
127
+ <productgift_observer>
128
+ <type>singleton</type>
129
+ <class>Nayati_ProductGift_Model_Observer</class>
130
+ <method>addGift</method>
131
+ </productgift_observer>
132
+ </observers>
133
+ </checkout_cart_product_add_after>
134
+ <checkout_cart_product_update_after>
135
+ <observers>
136
+ <productgift_observer>
137
+ <type>singleton</type>
138
+ <class>Nayati_ProductGift_Model_Observer</class>
139
+ <method>updatePGift</method>
140
+ </productgift_observer>
141
+ </observers>
142
+ </checkout_cart_product_update_after>
143
+ <controller_action_predispatch>
144
+ <observers>
145
+ <productgift_observer>
146
+ <type>singleton</type>
147
+ <class>Nayati_ProductGift_Model_Observer</class>
148
+ <method>noUpdateGift</method>
149
+ </productgift_observer>
150
+ </observers>
151
+ </controller_action_predispatch>
152
+ <sales_quote_remove_item>
153
+ <observers>
154
+ <productgift_observer>
155
+ <type>singleton</type>
156
+ <class>Nayati_ProductGift_Model_Observer</class>
157
+ <method>deletePGift</method>
158
+ </productgift_observer>
159
+ </observers>
160
+ </sales_quote_remove_item>
161
+ <checkout_cart_update_items_after>
162
+ <observers>
163
+ <productgift_observer>
164
+ <type>singleton</type>
165
+ <class>Nayati_ProductGift_Model_Observer</class>
166
+ <method>updtatePGiftA</method>
167
+ </productgift_observer>
168
+ </observers>
169
+ </checkout_cart_update_items_after>
170
+ <checkout_type_onepage_save_order>
171
+ <observers>
172
+ <productgift_observer>
173
+ <type>singleton</type>
174
+ <class>Nayati_ProductGift_Model_Observer</class>
175
+ <method>checkoutValidation</method>
176
+ </productgift_observer>
177
+ </observers>
178
+ </checkout_type_onepage_save_order>
179
+ <sales_convert_quote_item_to_order_item>
180
+ <observers>
181
+ <productgift_observer>
182
+ <type>singleton</type>
183
+ <class>Nayati_ProductGift_Model_Observer</class>
184
+ <method>salesConvertQuoteItemToOrderItem</method>
185
+ </productgift_observer>
186
+ </observers>
187
+ </sales_convert_quote_item_to_order_item>
188
+
189
+ </events>
190
+ <routers>
191
+ <checkout>
192
+ <args>
193
+ <modules>
194
+ <Nayati_ProductGift before="Mage_Checkout">Nayati_ProductGift</Nayati_ProductGift>
195
+ </modules>
196
+ </args>
197
+ </checkout>
198
+ </routers>
199
+ <layout>
200
+ <updates>
201
+ <Nayati_productgift>
202
+ <file>cataloggift.xml</file>
203
+ </Nayati_productgift>
204
+ </updates>
205
+
206
+ </layout>
207
+
208
+ </frontend>
209
+
210
+ </config>
app/code/community/Nayati/ProductGift/etc/system.xml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <productgift translate="label" module="productgift">
5
+ <label>Product Gift</label>
6
+ <sort_order>50</sort_order>
7
+ </productgift>
8
+ </tabs>
9
+ <sections>
10
+ <productgiftsection translate="label" module="productgift">
11
+ <label>Product Gift</label>
12
+ <tab>productgift</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>0</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <productgiftgroup translate="label">
20
+ <label>Product Gift</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>0</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <productgiftstatus translate="label">
28
+ <label>Enable this feature</label>
29
+ <frontend_type>select</frontend_type>
30
+ <source_model>adminhtml/system_config_source_yesno</source_model>
31
+ <sort_order>0</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </productgiftstatus>
36
+ </fields>
37
+ </productgiftgroup>
38
+ </groups>
39
+ </productgiftsection>
40
+ </sections>
41
+ </config>
app/code/community/Nayati/ProductGift/sql/productgift_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Nayati
4
+ */
5
+ $installer = $this;
6
+ $installer->startSetup();
7
+ $installer->installEntities();
8
+
app/code/community/Nayati/ProductGift/sql/productgift_setup/mysql4-upgrade-1.0.0-1.1.0.php ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Nayati
4
+ */
5
+ $installer = $this;
6
+ $connection = $installer->getConnection();
7
+ $installer->startSetup();
8
+ $installer->run("
9
+
10
+ CREATE TABLE IF NOT EXISTS {$installer->getTable('giftskus')} (
11
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
12
+ `quote_id` bigint(20) NOT NULL,
13
+ `product_id` bigint(20) NOT NULL,
14
+ `gift_product_id` bigint(20) NOT NULL,
15
+ `gift_product_item_id` bigint(20) NOT NULL,
16
+ `status` char(1) NOT NULL default '0',
17
+ `created_time` datetime NOT NULL default '0000-00-00 00:00:00',
18
+ `update_time` datetime NOT NULL default '0000-00-00 00:00:00',
19
+ PRIMARY KEY (`id`)
20
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=35 ;
21
+ ");
22
+
23
+
24
+ $installer->endSetup();
25
+
26
+
27
+
28
+
29
+ $installerAttributes = Mage::getResourceModel('catalog/setup', 'catalog_setup');
30
+ $connection = $installerAttributes->getConnection();
31
+ $installerAttributes->startSetup();
32
+
33
+ if (!$installerAttributes->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'sku_of_product_gift')) {
34
+ $installerAttributes->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'sku_of_product_gift', array(
35
+ 'label' => 'SKU of products offered',
36
+ 'group' => 'Gift Product',
37
+ 'backend' => '',
38
+ 'type' => 'text',
39
+ 'frontend' => '',
40
+ 'note' => 'comma separated SKU(s)',
41
+ 'default' => '',
42
+ 'input' => 'text',
43
+ 'input_renderer' => '',
44
+ 'source' => '',
45
+ 'required' => false,
46
+ 'user_defined' => false,
47
+ 'unique' => false,
48
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
49
+ 'visible' => true,
50
+ 'visible_on_front' => false,
51
+ 'used_in_product_listing' => false,
52
+ 'searchable' => false,
53
+ 'visible_in_advanced_search' => false,
54
+ 'filterable' => false,
55
+ 'filterable_in_search' => false,
56
+ 'comparable' => false,
57
+ 'apply_to' => 'simple,downloadable',
58
+ 'is_configurable' => false,
59
+ 'used_for_sort_by' => false,
60
+ 'position' => 0,
61
+ 'used_for_promo_rules' => false,
62
+ ));
63
+ }
64
+ if (!$installerAttributes->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'is_product_gift_enabled')) {
65
+ $installerAttributes->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'is_product_gift_enabled', array(
66
+ 'label' => 'Having Gifts',
67
+ 'group' => 'Gift Product',
68
+ 'backend' => '',
69
+ 'type' => 'int',
70
+ 'frontend' => '',
71
+ 'default' => '',
72
+ 'input' => 'boolean',
73
+ 'source' => '',
74
+ 'required' => false,
75
+ 'user_defined' => false,
76
+ 'unique' => false,
77
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
78
+ 'visible' => true,
79
+ 'visible_on_front' => false,
80
+ 'used_in_product_listing' => false,
81
+ 'searchable' => false,
82
+ 'visible_in_advanced_search' => false,
83
+ 'filterable' => false,
84
+ 'filterable_in_search' => false,
85
+ 'comparable' => true,
86
+ 'apply_to' => 'simple,downloadable',
87
+ 'is_configurable' => false,
88
+ 'used_for_sort_by' => false,
89
+ 'position' => 0,
90
+ 'used_for_promo_rules' => false,
91
+ ));
92
+ }
93
+ if (!$installerAttributes->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'product_gift_active_from')) {
94
+ $installerAttributes->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'product_gift_active_from', array(
95
+ 'label' => 'Active From',
96
+ 'group' => 'Gift Product',
97
+ 'backend' => '',
98
+ 'type' => 'datetime',
99
+ 'frontend' => '',
100
+ 'default' => '',
101
+ 'input' => 'date',
102
+ 'source' => '',
103
+ 'required' => false,
104
+ 'user_defined' => false,
105
+ 'unique' => false,
106
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
107
+ 'visible' => true,
108
+ 'visible_on_front' => false,
109
+ 'used_in_product_listing' => false,
110
+ 'searchable' => false,
111
+ 'visible_in_advanced_search' => false,
112
+ 'filterable' => false,
113
+ 'filterable_in_search' => false,
114
+ 'comparable' => false,
115
+ 'apply_to' => 'simple,downloadable',
116
+ 'is_configurable' => false,
117
+ 'used_for_sort_by' => false,
118
+ 'position' => 0,
119
+ 'used_for_promo_rules' => false,
120
+ ));
121
+ }
122
+ if (!$installerAttributes->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'product_gift_active_to')) {
123
+ $installerAttributes->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'product_gift_active_to', array(
124
+ 'label' => 'Active To',
125
+ 'group' => 'Gift Product',
126
+ 'backend' => '',
127
+ 'type' => 'datetime',
128
+ 'frontend' => '',
129
+ 'default' => '',
130
+ 'input' => 'date',
131
+ 'source' => '',
132
+ 'required' => false,
133
+ 'user_defined' => false,
134
+ 'unique' => false,
135
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
136
+ 'visible' => true,
137
+ 'visible_on_front' => false,
138
+ 'used_in_product_listing' => false,
139
+ 'searchable' => false,
140
+ 'visible_in_advanced_search' => false,
141
+ 'filterable' => false,
142
+ 'filterable_in_search' => false,
143
+ 'comparable' => false,
144
+ 'apply_to' => 'simple,downloadable',
145
+ 'is_configurable' => false,
146
+ 'used_for_sort_by' => false,
147
+ 'position' => 0,
148
+ 'used_for_promo_rules' => false,
149
+ ));
150
+ }
151
+
152
+ $installerAttributes->endSetup();
app/design/adminhtml/default/default/layout/salesitem.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ *
5
+ * @author Nayati
6
+ *
7
+ */
8
+ -->
9
+ <layout version="0.1.0">
10
+ <adminhtml_sales_order_view>
11
+ <reference name="left">
12
+ <reference name="sales_order_tabs">
13
+ <reference name="order_tab_info">
14
+ <reference name="order_items">
15
+ <action method="setTemplate"> <template>freegift/items.phtml</template></action>
16
+
17
+ <action method="addItemRender">
18
+ <type>default</type>
19
+ <block>adminhtml/sales_order_view_items_renderer_default</block>
20
+ <template>freegift/default.phtml</template>
21
+ </action>
22
+ </reference>
23
+ </reference>
24
+ </reference>
25
+ </reference>
26
+ </adminhtml_sales_order_view>
27
+
28
+ </layout>
app/design/adminhtml/default/default/template/freegift/default.phtml ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @author Nayati
5
+ *
6
+ */
7
+ ?>
8
+ <?php $_item = $this->getItem() ?>
9
+ <?php $this->setPriceDataObject($_item) ?>
10
+ <tr<?php if (!$this->canDisplayGiftmessage()): ?> class="border"<?php endif; ?>>
11
+ <td>
12
+ <?php if ($this->canDisplayContainer()): ?>
13
+ <div id="<?php echo $this->getHtmlId() ?>" class="item-container">
14
+ <?php endif; ?>
15
+ <div class="item-text">
16
+ <?php echo $this->getColumnHtml($_item, 'name') ?>
17
+ </div>
18
+ <?php if ($this->canDisplayContainer()): ?>
19
+ </div>
20
+ <?php endif ?>
21
+ </td>
22
+ <td class="a-center"><?php echo $_item->getStatus() ?></td>
23
+ <?php if($_item->getPrice()!=0): ?>
24
+ <?php Mage::getSingleton('core/session')->setFlagGiftId($this->getColumnHtml($_item, 'name')) ?>
25
+ <td class="a-center"></td>
26
+ <?php else: ?>
27
+ <?php if(Mage::helper('core')->isModuleOutputEnabled('Nayati_ProductGift') && Mage::getStoreConfigFlag('productgiftsection/productgiftgroup/productgiftstatus')): ?>
28
+ <td class="a-center"><?php echo Mage::getSingleton('core/session')->getFlagGiftId(); ?></td>
29
+ <?php endif; ?>
30
+ <?php endif; ?>
31
+
32
+ <td class="a-right"><?php echo $this->displayPriceAttribute('original_price') ?></td>
33
+ <td class="a-right">
34
+ <?php if ($this->helper('tax')->displaySalesBothPrices() || $this->helper('tax')->displaySalesPriceExclTax()): ?>
35
+ <span class="price-excl-tax">
36
+ <?php if ($this->helper('tax')->displaySalesBothPrices()): ?>
37
+ <span class="label"><?php echo $this->__('Excl. Tax'); ?>:</span>
38
+ <?php endif; ?>
39
+
40
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?>
41
+ <?php
42
+ echo $this->displayPrices(
43
+ $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(),
44
+ $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()
45
+ );
46
+ ?>
47
+ <?php else: ?>
48
+ <?php echo $this->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?>
49
+ <?php endif; ?>
50
+
51
+
52
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
53
+ <br />
54
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?>
55
+ <small>
56
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
57
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span>
58
+ <?php endforeach; ?>
59
+ </small>
60
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
61
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
62
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></small></span>
63
+ <?php endforeach; ?>
64
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?>
65
+ <small>
66
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
67
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span>
68
+ <?php endforeach; ?>
69
+ </small>
70
+ <?php endif; ?>
71
+
72
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
73
+ <br />
74
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br />
75
+ <?php
76
+ echo $this->displayPrices(
77
+ $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(),
78
+ $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()
79
+ );
80
+ ?>
81
+ </span>
82
+ <?php endif; ?>
83
+ <?php endif; ?>
84
+ </span>
85
+ <br />
86
+ <?php endif; ?>
87
+ <?php if ($this->helper('tax')->displaySalesBothPrices() || $this->helper('tax')->displaySalesPriceInclTax()): ?>
88
+ <span class="price-incl-tax">
89
+ <?php if ($this->helper('tax')->displaySalesBothPrices()): ?>
90
+ <span class="label"><?php echo $this->__('Incl. Tax'); ?>:</span>
91
+ <?php endif; ?>
92
+ <?php $_incl = $this->helper('checkout')->getPriceInclTax($_item); ?>
93
+ <?php $_baseIncl = $this->helper('checkout')->getBasePriceInclTax($_item); ?>
94
+
95
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?>
96
+ <?php echo $this->displayPrices($_baseIncl + Mage::helper('weee')->getBaseWeeeTaxInclTax($_item), $_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?>
97
+ <?php else: ?>
98
+ <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?>
99
+ <?php endif; ?>
100
+
101
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
102
+ <br />
103
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?>
104
+ <small>
105
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
106
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span>
107
+ <?php endforeach; ?>
108
+ </small>
109
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
110
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
111
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span>
112
+ <?php endforeach; ?>
113
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?>
114
+ <small>
115
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
116
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span>
117
+ <?php endforeach; ?>
118
+ </small>
119
+ <?php endif; ?>
120
+
121
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
122
+ <br />
123
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl + Mage::helper('weee')->getBaseWeeeTaxInclTax($_item) , $_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?></span>
124
+ <?php endif; ?>
125
+ <?php endif; ?>
126
+ </span>
127
+ <?php endif; ?>
128
+
129
+ </td>
130
+ <td><?php echo $this->getColumnHtml($_item, 'qty') ?></td>
131
+
132
+ <td class="a-right">
133
+ <?php if ($this->helper('tax')->displaySalesBothPrices() || $this->helper('tax')->displaySalesPriceExclTax()): ?>
134
+ <span class="price-excl-tax">
135
+ <?php if ($this->helper('tax')->displaySalesBothPrices()): ?>
136
+ <span class="label"><?php echo $this->__('Excl. Tax'); ?>:</span>
137
+ <?php endif; ?>
138
+
139
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?>
140
+ <?php
141
+ echo $this->displayPrices(
142
+ $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmount()+$_item->getBaseWeeeTaxRowDisposition(),
143
+ $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()
144
+ );
145
+ ?>
146
+ <?php else: ?>
147
+ <?php echo $this->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?>
148
+ <?php endif; ?>
149
+
150
+
151
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
152
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?>
153
+ <small>
154
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
155
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span>
156
+ <?php endforeach; ?>
157
+ </small>
158
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
159
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
160
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></small></span>
161
+ <?php endforeach; ?>
162
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?>
163
+ <small>
164
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
165
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span>
166
+ <?php endforeach; ?>
167
+ </small>
168
+ <?php endif; ?>
169
+
170
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
171
+ <br />
172
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br />
173
+ <?php
174
+ echo $this->displayPrices(
175
+ $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmount()+$_item->getBaseWeeeTaxRowDisposition(),
176
+ $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()
177
+ );
178
+ ?>
179
+ </span>
180
+ <?php endif; ?>
181
+ <?php endif; ?>
182
+ </span>
183
+ <br />
184
+ <?php endif; ?>
185
+ <?php if ($this->helper('tax')->displaySalesBothPrices() || $this->helper('tax')->displaySalesPriceInclTax()): ?>
186
+ <span class="price-incl-tax">
187
+ <?php if ($this->helper('tax')->displaySalesBothPrices()): ?>
188
+ <span class="label"><?php echo $this->__('Incl. Tax'); ?>:</span>
189
+ <?php endif; ?>
190
+ <?php $_incl = $this->helper('checkout')->getSubtotalInclTax($_item); ?>
191
+ <?php $_baseIncl = $this->helper('checkout')->getBaseSubtotalInclTax($_item); ?>
192
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?>
193
+ <?php echo $this->displayPrices($_baseIncl + Mage::helper('weee')->getBaseRowWeeeTaxInclTax($_item), $_incl + Mage::helper('weee')->getRowWeeeTaxInclTax($_item)); ?>
194
+ <?php else: ?>
195
+ <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?>
196
+ <?php endif; ?>
197
+
198
+
199
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
200
+
201
+ <br />
202
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?>
203
+ <small>
204
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
205
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span>
206
+ <?php endforeach; ?>
207
+ </small>
208
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
209
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
210
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span>
211
+ <?php endforeach; ?>
212
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?>
213
+ <small>
214
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
215
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span>
216
+ <?php endforeach; ?>
217
+ </small>
218
+ <?php endif; ?>
219
+
220
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
221
+ <br /><span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl + Mage::helper('weee')->getBaseRowWeeeTaxInclTax($_item),$_incl + Mage::helper('weee')->getRowWeeeTaxInclTax($_item)); ?></span>
222
+ <?php endif; ?>
223
+ <?php endif; ?>
224
+ </span>
225
+ <?php endif; ?>
226
+ </td>
227
+ <td class="a-right"><?php echo $this->displayPriceAttribute('tax_amount') ?></td>
228
+ <td class="a-right"><?php echo $this->displayTaxPercent($_item) ?></td>
229
+ <td class="a-right"><?php echo $this->displayPriceAttribute('discount_amount') ?></td>
230
+ <td class="a-right last">
231
+ <?php echo $this->displayPrices(
232
+ $_item->getBaseRowTotal() + $_item->getBaseTaxAmount() + $_item->getBaseHiddenTaxAmount() + $_item->getBaseWeeeTaxAppliedRowAmount() - $_item->getBaseDiscountAmount(),
233
+ $_item->getRowTotal() + $_item->getTaxAmount() + $_item->getHiddenTaxAmount() + $_item->getWeeeTaxAppliedRowAmount() - $_item->getDiscountAmount()
234
+ ); ?>
235
+ </td>
236
+ </tr>
app/design/adminhtml/default/default/template/freegift/items.phtml ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @author Nayati
5
+ *
6
+ */
7
+ ?>
8
+ <?php $_order = $this->getOrder() ?>
9
+ <div class="grid np">
10
+ <div class="hor-scroll">
11
+ <table cellspacing="0" class="data order-tables">
12
+ <col />
13
+ <col width="1" />
14
+ <col width="1" />
15
+ <col width="1" />
16
+ <col width="1" />
17
+ <col width="1" />
18
+ <col width="1" />
19
+ <col width="1" />
20
+ <col width="1" />
21
+ <col width="1" />
22
+ <thead>
23
+ <tr class="headings">
24
+ <th><?php echo $this->helper('sales')->__('Product') ?></th>
25
+ <th><span class="nobr"><?php echo $this->helper('sales')->__('Item Status') ?></span></th>
26
+ <?php if(Mage::helper('core')->isModuleOutputEnabled('Nayati_ProductGift') && Mage::getStoreConfigFlag('productgiftsection/productgiftgroup/productgiftstatus')): ?>
27
+ <th><span class="nobr">Gift of Product</span></th>
28
+ <?php endif; ?>
29
+ <th><span class="nobr"><?php echo $this->helper('sales')->__('Original Price') ?></span></th>
30
+ <th><?php echo $this->helper('sales')->__('Price') ?></th>
31
+ <th class="a-center"><?php echo $this->helper('sales')->__('Qty') ?></th>
32
+ <th><?php echo $this->helper('sales')->__('Subtotal') ?></th>
33
+ <th><span class="nobr"><?php echo $this->helper('sales')->__('Tax Amount') ?></span></th>
34
+ <th><span class="nobr"><?php echo $this->helper('sales')->__('Tax Percent') ?></span></th>
35
+ <th><span class="nobr"><?php echo $this->helper('sales')->__('Discount Amount') ?></span></th>
36
+ <th class="last"><span class="nobr"><?php echo $this->helper('sales')->__('Row Total') ?></span></th>
37
+ </tr>
38
+ </thead>
39
+ <?php if(Mage::helper('core')->isModuleOutputEnabled('Nayati_ProductGift') && Mage::getStoreConfigFlag('productgiftsection/productgiftgroup/productgiftstatus')): ?>
40
+ <?php Mage::getSingleton('core/session')->setFlagGiftId(''); ?>
41
+ <?php endif; ?>
42
+ <?php $_items = $this->getItemsCollection() ?>
43
+ <?php $i=0;foreach ($_items as $_item): ?>
44
+ <?php if ($_item->getParentItem()) continue; else $i++;?>
45
+ <tbody class="<?php echo $i%2?'even':'odd' ?>">
46
+ <?php echo $this->getItemHtml($_item) ?>
47
+ <?php echo $this->getItemExtraInfoHtml($_item) ?>
48
+ </tbody>
49
+ <?php endforeach; ?>
50
+ <?php Mage::getSingleton('core/session')->setFlagGiftId(''); ?>
51
+ </table>
52
+ </div>
53
+ </div>
54
+ <br />
app/design/frontend/base/default/layout/cataloggift.xml ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ *
5
+ * @author Nayati
6
+ *
7
+ */
8
+ -->
9
+ <layout version="0.1.0">
10
+ <default>
11
+ </default>
12
+ <catalog_category_layered>
13
+ <reference name="product_list">
14
+ <action method="setTemplate"><template>freegift/catalog/product/list.phtml</template></action>
15
+ </reference>
16
+ </catalog_category_layered>
17
+
18
+ <catalog_category_default>
19
+ <reference name="product_list">
20
+ <action method="setTemplate"><template>freegift/catalog/product/list.phtml</template></action>
21
+ </reference>
22
+ </catalog_category_default>
23
+
24
+ <catalogsearch_result_index>
25
+ <reference name="product_list">
26
+ <action method="setTemplate"><template>freegift/catalog/product/list.phtml</template></action>
27
+ </reference>
28
+ </catalogsearch_result_index>
29
+
30
+ <checkout_cart_index>
31
+ <reference name="checkout.cart">
32
+ <action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>freegift/default.phtml</template></action>
33
+ <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>freegift/default.phtml</template></action>
34
+ <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>freegift/default.phtml</template></action>
35
+ </reference>
36
+ </checkout_cart_index>
37
+
38
+ <wishlist_index_index>
39
+
40
+ <reference name="customer.wishlist.item.image">
41
+ <action method="setTemplate"><template>freegift/catalog/product/image.phtml</template></action>
42
+ </reference>
43
+ </wishlist_index_index>
44
+
45
+ <catalog_product_view>
46
+ <reference name="content">
47
+ <reference name="product.info.extrahint">
48
+ <block type="productgift/giftview" name="free_block" as="free" after="-" template="freegift/gifts.phtml"/>
49
+ </reference>
50
+ </reference>
51
+ </catalog_product_view>
52
+ <default translate="label" module="page">
53
+ <reference name="head">
54
+ <action method="addCss">
55
+ <stylesheet>css/giftproduct.css</stylesheet>
56
+ </action>
57
+ </reference>
58
+ </default>
59
+ </layout>
app/design/frontend/base/default/template/freegift/catalog/product/image.phtml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @Description : Wishlist image FREE tag
4
+ * @author Nayati
5
+ *
6
+ */
7
+ $item = $this->getItem();
8
+ $product = $item->getProduct();
9
+ ?>
10
+ <?php
11
+ $isGiftAvl=Mage::getResourceModel('catalog/product')->getAttributeRawValue($product->getId(), 'sku_of_product_gift',Mage::app()->getStore()->getStoreId());
12
+ $isGiftEnbl=Mage::getResourceModel('catalog/product')->getAttributeRawValue($product->getId(), 'is_product_gift_enabled',Mage::app()->getStore()->getStoreId());
13
+ $FromGift=strtotime(Mage::getResourceModel('catalog/product')->getAttributeRawValue($product->getId(), 'product_gift_active_from',Mage::app()->getStore()->getStoreId()));
14
+ $ToGift=strtotime(Mage::getResourceModel('catalog/product')->getAttributeRawValue($product->getId(), 'product_gift_active_to',Mage::app()->getStore()->getStoreId()));
15
+
16
+ if((Mage::helper('core')->isModuleOutputEnabled('Nayati_ProductGift')) && !empty($isGiftAvl) && $isGiftEnbl && (empty($FromGift) || $FromGift<time()) && (empty($ToGift) || $ToGift>time()) && Mage::helper('core')->isModuleOutputEnabled('Nayati_ProductGift') && Mage::getStoreConfigFlag('productgiftsection/productgiftgroup/productgiftstatus')){
17
+ echo '<img src="'.Mage::getDesign()->getSkinUrl('images/gift_list.png').'" style="z-index: 999;width: 49px;position: absolute;"/>';
18
+
19
+ }
20
+ ?>
21
+ <a class="product-image" href="<?php echo $this->getProductUrl($item) ?>" title="<?php echo $this->escapeHtml($product->getName()) ?>">
22
+ <img src="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(113, 113); ?>" width="113" height="113" alt="<?php echo $this->escapeHtml($product->getName()) ?>" />
23
+ </a>
app/design/frontend/base/default/template/freegift/catalog/product/list.phtml ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @Description : List products FREE tag
4
+ * @author Nayati
5
+ *
6
+ */
7
+ ?>
8
+ <?php
9
+ $_productCollection=$this->getLoadedProductCollection();
10
+ $_helper = $this->helper('catalog/output');
11
+ ?>
12
+ <?php if(!$_productCollection->count()): ?>
13
+ <p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
14
+ <?php else: ?>
15
+ <div class="category-products">
16
+ <?php echo $this->getToolbarHtml() ?>
17
+ <?php // List mode ?>
18
+ <?php if($this->getMode()!='grid'): ?>
19
+ <?php $_iterator = 0; ?>
20
+ <ol class="products-list" id="products-list">
21
+ <?php foreach ($_productCollection as $_product): ?>
22
+ <?php $isGiftAvl=Mage::getResourceModel('catalog/product')->getAttributeRawValue($_product->getId(), 'sku_of_product_gift',Mage::app()->getStore()->getStoreId());
23
+ $isGiftEnbl=Mage::getResourceModel('catalog/product')->getAttributeRawValue($_product->getId(), 'is_product_gift_enabled',Mage::app()->getStore()->getStoreId());
24
+
25
+ ?>
26
+ <li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
27
+ <?php // Product Image ?>
28
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
29
+ </a>
30
+ <?php // Product description ?>
31
+ <div class="product-shop">
32
+ <div class="f-fix">
33
+ <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
34
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></h2>
35
+ <?php if($_product->getRatingSummary()): ?>
36
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
37
+ <?php endif; ?>
38
+ <?php echo $this->getPriceHtml($_product, true) ?>
39
+ <?php if($_product->isSaleable()): ?>
40
+ <p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
41
+ <?php else: ?>
42
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
43
+ <?php endif; ?>
44
+ <div class="desc std">
45
+ <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
46
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a>
47
+ </div>
48
+ <ul class="add-to-links">
49
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
50
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
51
+ <?php endif; ?>
52
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
53
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
54
+ <?php endif; ?>
55
+ </ul>
56
+ </div>
57
+ </div>
58
+ </li>
59
+ <?php endforeach; ?>
60
+ </ol>
61
+ <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
62
+
63
+ <?php else: ?>
64
+
65
+ <?php // Grid Mode ?>
66
+
67
+ <?php $_collectionSize = $_productCollection->count() ?>
68
+ <?php $_columnCount = $this->getColumnCount(); ?>
69
+ <?php $i=0; foreach ($_productCollection as $_product):
70
+ $isGiftAvl=Mage::getResourceModel('catalog/product')->getAttributeRawValue($_product->getId(), 'sku_of_product_gift',Mage::app()->getStore()->getStoreId());
71
+ $isGiftEnbl=Mage::getResourceModel('catalog/product')->getAttributeRawValue($_product->getId(), 'is_product_gift_enabled',Mage::app()->getStore()->getStoreId());
72
+ $FromGift=strtotime(Mage::getResourceModel('catalog/product')->getAttributeRawValue($_product->getId(), 'product_gift_active_from',Mage::app()->getStore()->getStoreId()));
73
+ $ToGift=strtotime(Mage::getResourceModel('catalog/product')->getAttributeRawValue($_product->getId(), 'product_gift_active_to',Mage::app()->getStore()->getStoreId()));
74
+ ?>
75
+ <?php if ($i++%$_columnCount==0): ?>
76
+ <ul class="products-grid">
77
+ <?php endif ?>
78
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
79
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
80
+ <?php if(Mage::helper('core')->isModuleOutputEnabled('Nayati_ProductGift') && !empty($isGiftAvl) && $isGiftEnbl && (empty($FromGift) || $FromGift<time()) && (empty($ToGift) || $ToGift>time()) && Mage::helper('core')->isModuleOutputEnabled('Nayati_ProductGift') && Mage::getStoreConfigFlag('productgiftsection/productgiftgroup/productgiftstatus'))
81
+ {echo '<img src="'.Mage::getDesign()->getSkinUrl('images/gift_list.png').'" style="z-index: 999;width: 49px;position: absolute;"/>';} ?>
82
+
83
+ <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
84
+
85
+ </a>
86
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
87
+ <?php if($_product->getRatingSummary()): ?>
88
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
89
+ <?php endif; ?>
90
+ <?php echo $this->getPriceHtml($_product, true) ?>
91
+ <div class="actions">
92
+ <?php if($_product->isSaleable()): ?>
93
+ <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
94
+ <?php else: ?>
95
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
96
+ <?php endif; ?>
97
+ <ul class="add-to-links">
98
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
99
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
100
+ <?php endif; ?>
101
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
102
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
103
+ <?php endif; ?>
104
+ </ul>
105
+ </div>
106
+ </li>
107
+ <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
108
+ </ul>
109
+ <?php endif ?>
110
+ <?php endforeach ?>
111
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
112
+ <?php endif; ?>
113
+
114
+ <div class="toolbar-bottom">
115
+ <?php echo $this->getToolbarHtml() ?>
116
+ </div>
117
+ </div>
118
+ <?php endif; ?>
app/design/frontend/base/default/template/freegift/default.phtml ADDED
@@ -0,0 +1,276 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * @author Nayati
5
+ *
6
+ */
7
+ ?>
8
+ <?php
9
+ $_item = $this->getItem();
10
+ $isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility();
11
+ $canApplyMsrp = Mage::helper('catalog')->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM);
12
+ ?>
13
+ <tr>
14
+ <td><?php if ($this->hasProductUrl()):?><a href="<?php echo $this->getProductUrl() ?>" title="<?php echo $this->escapeHtml($this->getProductName()) ?>" class="product-image"><?php endif;?><img src="<?php echo $this->getProductThumbnail()->resize(75); ?>" width="75" height="75" alt="<?php echo $this->escapeHtml($this->getProductName()) ?>" /><?php if ($this->hasProductUrl()):?></a><?php endif;?></td>
15
+ <td>
16
+ <h2 class="product-name">
17
+ <?php if ($this->hasProductUrl()):?>
18
+ <a href="<?php echo $this->getProductUrl() ?>"><?php echo $this->escapeHtml($this->getProductName()) ?></a>
19
+ <?php else: ?>
20
+ <?php echo $this->escapeHtml($this->getProductName()) ?>
21
+ <?php endif; ?>
22
+ </h2>
23
+ <?php if ($_options = $this->getOptionList()):?>
24
+ <dl class="item-options">
25
+ <?php foreach ($_options as $_option) : ?>
26
+ <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
27
+ <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
28
+ <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
29
+ <?php if (isset($_formatedOptionValue['full_view'])): ?>
30
+ <div class="truncated_full_value">
31
+ <dl class="item-options">
32
+ <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
33
+ <dd><?php echo $_formatedOptionValue['full_view'] ?></dd>
34
+ </dl>
35
+ </div>
36
+ <?php endif; ?>
37
+ </dd>
38
+ <?php endforeach; ?>
39
+ </dl>
40
+ <?php endif;?>
41
+ <?php if ($messages = $this->getMessages()): ?>
42
+ <?php foreach ($messages as $message): ?>
43
+ <p class="item-msg <?php echo $message['type'] ?>">* <?php echo $this->escapeHtml($message['text']) ?></p>
44
+ <?php endforeach; ?>
45
+ <?php endif; ?>
46
+ <?php $addInfoBlock = $this->getProductAdditionalInformationBlock(); ?>
47
+ <?php if ($addInfoBlock): ?>
48
+ <?php echo $addInfoBlock->setItem($_item)->toHtml() ?>
49
+ <?php endif;?>
50
+ </td>
51
+ <td class="a-center">
52
+ <?php if($this->helper('checkout')->getPriceInclTax($_item)!=0){ ?>
53
+ <?php if ($isVisibleProduct): ?>
54
+ <a href="<?php echo $this->getConfigureUrl() ?>" title="<?php echo $this->__('Edit item parameters') ?>"><?php echo $this->__('Edit') ?></a>
55
+ <?php endif ?>
56
+ <?php } ?>
57
+
58
+ </td>
59
+ <?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
60
+ <td class="a-center">
61
+ <?php if($this->helper('checkout')->getPriceInclTax($_item)!=0){ ?>
62
+ <?php if ($isVisibleProduct): ?>
63
+ <a href="<?php echo $this->helper('wishlist')->getMoveFromCartUrl($_item->getId()); ?>" class="link-wishlist use-ajax"><?php echo $this->__('Move'); ?></a>
64
+ <?php endif ?>
65
+ <?php } ?>
66
+ </td>
67
+ <?php endif ?>
68
+
69
+ <?php if ($canApplyMsrp): ?>
70
+ <td class="a-right"<?php if ($this->helper('tax')->displayCartBothPrices()): ?> colspan="2"<?php endif; ?>>
71
+ <span class="cart-price">
72
+ <span class="cart-msrp-unit"><?php echo $this->__('See price before order confirmation.'); ?></span>
73
+ <?php $helpLinkId = 'cart-msrp-help-' . $_item->getId(); ?>
74
+ <a id="<?php echo $helpLinkId ?>" href="#" class="map-help-link"><?php echo $this->__("What's this?"); ?></a>
75
+ <script type="text/javascript">
76
+ Catalog.Map.addHelpLink($('<?php echo $helpLinkId ?>'), "<?php echo $this->__("What's this?") ?>");
77
+ </script>
78
+ </span>
79
+ </td>
80
+ <?php else: ?>
81
+
82
+ <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
83
+ <td class="a-right">
84
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
85
+ <span class="cart-tax-total" onclick="taxToggle('eunit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
86
+ <?php else: ?>
87
+ <span class="cart-price">
88
+ <?php endif; ?>
89
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
90
+ <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
91
+ <?php else: ?>
92
+ <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()) ?>
93
+ <?php endif; ?>
94
+
95
+ </span>
96
+
97
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
98
+
99
+ <div class="cart-tax-info" id="eunit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
100
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
101
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
102
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
103
+ <?php endforeach; ?>
104
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
105
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
106
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
107
+ <?php endforeach; ?>
108
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
109
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
110
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
111
+ <?php endforeach; ?>
112
+ <?php endif; ?>
113
+ </div>
114
+
115
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
116
+ <div class="cart-tax-total" onclick="taxToggle('eunit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
117
+ <span class="weee"><?php echo Mage::helper('weee')->__('Total'); ?>: <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?></span>
118
+ </div>
119
+ <?php endif; ?>
120
+ <?php endif; ?>
121
+ </td>
122
+ <?php endif; ?><!-- inclusive price starts here -->
123
+ <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
124
+ <td>
125
+ <?php $_incl = $this->helper('checkout')->getPriceInclTax($_item); ?>
126
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
127
+ <span class="cart-tax-total" onclick="taxToggle('unit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
128
+ <?php else: ?>
129
+ <span class="cart-price">
130
+ <?php endif; ?>
131
+
132
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
133
+ <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?>
134
+ <?php else: ?>
135
+ <?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?>
136
+ <?php endif; ?>
137
+
138
+ </span>
139
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
140
+
141
+ <div class="cart-tax-info" id="unit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
142
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
143
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
144
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
145
+ <?php endforeach; ?>
146
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
147
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
148
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
149
+ <?php endforeach; ?>
150
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
151
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
152
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
153
+ <?php endforeach; ?>
154
+ <?php endif; ?>
155
+ </div>
156
+
157
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
158
+ <div class="cart-tax-total" onclick="taxToggle('unit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
159
+ <span class="weee"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>: <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?></span>
160
+ </div>
161
+ <?php endif; ?>
162
+ <?php endif; ?>
163
+ </td>
164
+ <?php endif; ?>
165
+ <?php endif; ?>
166
+
167
+ <td class="a-center">
168
+ <?php if($this->helper('checkout')->getPriceInclTax($_item)!=0){ ?>
169
+ <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" />
170
+ <?php }
171
+ else
172
+ { ?>
173
+ <?php echo $this->getQty(); ?>
174
+ <?php } ?>
175
+ </td>
176
+
177
+ <!--Sub total starts here -->
178
+ <?php if (($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) && !$_item->getNoSubtotal()): ?>
179
+ <td class="a-right">
180
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
181
+ <span class="cart-tax-total" onclick="taxToggle('esubtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
182
+ <?php else: ?>
183
+ <span class="cart-price">
184
+ <?php endif; ?>
185
+
186
+ <?php if ($canApplyMsrp): ?>
187
+ <span class="cart-msrp-subtotal">--</span>
188
+ <?php else: ?>
189
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
190
+ <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?>
191
+ <?php else: ?>
192
+ <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()) ?>
193
+ <?php endif; ?>
194
+ <?php endif; ?>
195
+
196
+ </span>
197
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
198
+
199
+ <div class="cart-tax-info" id="esubtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
200
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
201
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
202
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
203
+ <?php endforeach; ?>
204
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
205
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
206
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
207
+ <?php endforeach; ?>
208
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
209
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
210
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
211
+ <?php endforeach; ?>
212
+ <?php endif; ?>
213
+ </div>
214
+
215
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
216
+ <div class="cart-tax-total" onclick="taxToggle('esubtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
217
+ <span class="weee"><?php echo Mage::helper('weee')->__('Total'); ?>: <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span>
218
+ </div>
219
+ <?php endif; ?>
220
+ <?php endif; ?>
221
+ </td>
222
+ <?php endif; ?>
223
+ <?php if (($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) && !$_item->getNoSubtotal()): ?>
224
+ <td>
225
+ <?php $_incl = $this->helper('checkout')->getSubtotalInclTax($_item); ?>
226
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
227
+ <span class="cart-tax-total" onclick="taxToggle('subtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
228
+ <?php else: ?>
229
+ <span class="cart-price">
230
+ <?php endif; ?>
231
+
232
+ <?php if ($canApplyMsrp): ?>
233
+ <span class="cart-msrp-subtotal">--</span>
234
+ <?php else: ?>
235
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
236
+ <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getRowWeeeTaxInclTax($_item)); ?>
237
+ <?php else: ?>
238
+ <?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?>
239
+ <?php endif; ?>
240
+ <?php endif; ?>
241
+
242
+ </span>
243
+
244
+
245
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
246
+
247
+ <div class="cart-tax-info" id="subtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
248
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
249
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
250
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
251
+ <?php endforeach; ?>
252
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
253
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
254
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
255
+ <?php endforeach; ?>
256
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
257
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
258
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
259
+ <?php endforeach; ?>
260
+ <?php endif; ?>
261
+ </div>
262
+
263
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
264
+ <div class="cart-tax-total" onclick="taxToggle('subtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
265
+ <span class="weee"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>: <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getRowWeeeTaxInclTax($_item)); ?></span>
266
+ </div>
267
+ <?php endif; ?>
268
+ <?php endif; ?>
269
+ </td>
270
+ <?php endif; ?>
271
+ <td class="a-center">
272
+ <?php if($this->helper('checkout')->getPriceInclTax($_item)!=0){ ?>
273
+ <a href="<?php echo $this->getDeleteUrl()?>" title="<?php echo $this->__('Remove item')?>" class="btn-remove btn-remove2"><?php echo $this->__('Remove item')?></a>
274
+ <?php } ?>
275
+ </td>
276
+ </tr>
app/design/frontend/base/default/template/freegift/gifts.phtml ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @Description : Block of free products in product detail page
4
+ * @author Nayati
5
+ *
6
+ */
7
+ ?>
8
+ <?php
9
+ $productId=$this->getProduct()->getId();
10
+ $product = Mage::getModel('catalog/product')->load($productId);
11
+ $giftOptionEnable = $product->getIsProductGiftEnabled();
12
+ $FromGift=strtotime($product->getProductGiftActiveFrom());
13
+ $ToGift=strtotime($product->getProductGiftActiveTo());
14
+ if($giftOptionEnable && ($FromGift<=time() || empty($FromGift)) && ($ToGift>=time() || empty($ToGift)) && Mage::helper('core')->isModuleOutputEnabled('Nayati_ProductGift') && Mage::getStoreConfigFlag('productgiftsection/productgiftgroup/productgiftstatus'))
15
+ {
16
+ $skuGift=$product->getSkuOfProductGift();
17
+ $productSkus = explode(',',$skuGift);
18
+ $currency=Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); ?>
19
+ <div class="product_gift_wrapper"><h3 class="gift_title"><span>Select Gift</span></h3>
20
+ <div class="product_gift">
21
+ <img class="free-image-tag" src="<?php echo Mage::getDesign()->getSkinUrl('images/free.png') ?>"/>
22
+ <?php $count = 1;
23
+ $countProducts = 0;
24
+ /*
25
+ * loop to create html for all gift products
26
+ */
27
+ foreach($productSkus as $sku):
28
+ $prodGift = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
29
+ //print_r($prodGift);exit;
30
+ $giftName = $prodGift->getName(); // Gift Name
31
+ $giftPrice = $prodGift->getPrice(); // Gift Name
32
+ $giftImage = $prodGift->getImageUrl();// Gift Image
33
+ $stocklevel = (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($prodGift)->getQty();
34
+ $productIsSalable=(int)$prodGift->isSalable();
35
+ $productInStock=(int)$prodGift->getStockItem()->getIsInStock();
36
+ $productInStock1 = (int)$productInStock;
37
+ if($stocklevel!=0 && $productInStock1!=0)
38
+ {
39
+
40
+ $giftUrl=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
41
+ $giftUrl.=$prodGift->getUrlPath();
42
+
43
+ if($count==1){ ?>
44
+ <div class="free_product_selector">
45
+ <input type="radio" name="free_gift" value="<?php echo $prodGift->getId() ?>" checked= "checked"/></div>
46
+ <?php }else{ ?>
47
+ <div class="free_product_selector">
48
+ <input type="radio" name="free_gift" value="<?php echo $prodGift->getId() ?>" /></div>
49
+ <?php } ?>
50
+
51
+ <div class="free_product_name">
52
+ <table>
53
+ <tr>
54
+ <td class="td-first">
55
+ <a href="<?php echo $giftUrl ?>"><img class="select-gift-img" attr="<?php echo $giftName ?>" title="<?php echo $giftName ?>" src="<?php echo $giftImage ?>"/></a>
56
+ </td>
57
+ <td class="td-first">
58
+ <table>
59
+ <tr>
60
+ <td class="td-second"><h3><a href="<?php echo $giftUrl ?>"><?php echo substr($giftName,0,20); ?>
61
+ <?php if(strlen($giftName)>20){
62
+
63
+ echo "...";
64
+ }
65
+ ?>
66
+ </a></h3></td>
67
+ </tr>
68
+ <tr>
69
+ <td class="td-second td-pname"><b><strike><?php echo $currency.number_format((float)$giftPrice, 2, '.', '') ?></strike></b><br/>
70
+ <b><?php echo $currency.number_format((float)0, 2, '.', '') ?></b>
71
+ </td>
72
+ </tr>
73
+ </table>
74
+ </td>
75
+
76
+ </tr>
77
+ </table>
78
+
79
+ </div>
80
+ <?php
81
+ $countProducts++;
82
+ }
83
+ $count++;
84
+ endforeach;
85
+
86
+ if($countProducts==0){
87
+ echo "Free Gifts will come soon";
88
+ }
89
+ ?>
90
+ </div></div>
91
+ <?php
92
+ }
93
+
94
+ ?>
app/etc/modules/Nayati_ProductGift.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Nayati_ProductGift>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <version>0.1.0</version>
8
+ </Nayati_ProductGift>
9
+ </modules>
10
+ </config>
package.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Nayati_ProductGift</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>GNU General Public License (GPL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>The Buy X for Y extension will surely improve sales and motivate the customers to come back!</summary>
10
+ <description>A common requirement for an eCommerce store is the Buy X Get Y free sales product.&#xD;
11
+ This extension allows the customers to choose bonus product Y in the pool of option if customer buys a quantity of product X. &#xD;
12
+ We have built our module in the way that allows the admin to assign any number of gift products Y by using SKU to a single product X. The customer can choose one gift product from many options provided. &#xD;
13
+ &#xD;
14
+ The Buy X for Y extension will surely improve sales and motivate the customers to come back!</description>
15
+ <notes>This is Stable version</notes>
16
+ <authors><author><name>Benjamin</name><user>nayatisolutions</user><email>ben@nayatisolutions.com</email></author></authors>
17
+ <date>2014-05-09</date>
18
+ <time>10:01:16</time>
19
+ <contents><target name="magecommunity"><dir name="Nayati"><dir name="ProductGift"><dir name="Adminhtml"><dir name="Block"><dir name="Catalog"><dir name="Product"><dir name="Grid"><file name="Skus.php" hash="2cffb4d9ff84feb258e44e6f81a7af5c"/></dir><file name="Grid.php" hash="9dacc248161c1985d02b24c3ca95f7f7"/></dir></dir></dir></dir><dir name="Block"><file name="Giftview.php" hash="66096778a92d9ec46b70d9ae0eed5d72"/></dir><dir name="Helper"><file name="Data.php" hash="fabf29f39cc45d615a0b3d2beafd9eec"/></dir><dir name="Model"><file name="Giftskus.php" hash="74fb3fd8fe1c7352a4034889602b24a2"/><file name="Observer.php" hash="4a1260eff1184ef1ba5a1227b62a4c7d"/><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="bdf001c2941783efbbc55894d74be170"/></dir></dir><dir name="Giftskus"><file name="Collection.php" hash="f1ec565d652a490a3de37fa475163569"/></dir><file name="Giftskus.php" hash="8febc9e54613a7561de5edae6b741f92"/></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Dropdown"><file name="Values.php" hash="cc6f76d5fff904610c1299fbe30aab8a"/></dir><file name="Enabledisable.php" hash="5cceddb4306dbcc0f4e5cd665544c41e"/></dir></dir></dir></dir><dir name="controllers"><file name="CartController.php" hash="b26a0396a250cebc916d16b23ee1a8f9"/></dir><dir name="etc"><file name="adminhtml.xml" hash="8a78147e11cb9c319c03f19bb16da795"/><file name="config.xml" hash="697dbb9781c75311283abb37f445f8fa"/><file name="system.xml" hash="90ce6df8d6b1585eaea7a8225c95e8a2"/></dir><dir name="sql"><dir name="productgift_setup"><file name="mysql4-install-1.0.0.php" hash="8510e5d748b3098c0c41536a54f22132"/><file name="mysql4-upgrade-1.0.0-1.1.0.php" hash="795e5faedc9662d5a2aff4aad7f5c937"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="cataloggift.xml" hash="8d90e34666a5c49dc2780ae2f606cdf0"/></dir><dir name="template"><dir name="freegift"><dir name="catalog"><dir name="product"><file name="image.phtml" hash="94f0fc1877adf2d50591dab6c4128798"/><file name="list.phtml" hash="e9015609d993e3ff2bf61d75bba4db44"/></dir></dir><file name="default.phtml" hash="3931771a6f171242131e516eb3607e1b"/><file name="gifts.phtml" hash="6d4b578fbca7117def8240f8fb1c80b6"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="salesitem.xml" hash="66010bfb7e6f303364fa4a127bea9a1d"/></dir><dir name="template"><dir name="freegift"><file name="default.phtml" hash="637976dfbbe2df106255ad84a39d1f68"/><file name="items.phtml" hash="47d4bb042f7106d9960a4fbe5e81b835"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Nayati_ProductGift.xml" hash="d9e3807267cac7fda81300722a58ddb0"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="images"><file name="free.png" hash="800e606e2c9104dd6d5375f887f6d939"/><file name="gift_list.png" hash="e2a00524603dd69933243ee97741ea37"/></dir><dir name="css"><file name="giftproduct.css" hash="85e8bb49e54aeb5a47840cb94891900e"/></dir></dir></dir></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies><required><php><min>5.2.0</min><max>5.3.28</max></php></required></dependencies>
22
+ </package>
skin/frontend/default/default/css/giftproduct.css ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @Description : Frontend Styles
3
+ * @author Nayati
4
+ *
5
+ */
6
+ .product_gift{min-width: 286px;width: 87%;float: left;padding: 10px 20px;position: relative;border: 2px solid #182E43;border-radius: 16px 16px;margin-bottom: 10px;}
7
+ .product_gift .free-image-tag{position: absolute;z-index: 999;width: 60px;left: 287px;top: -25px;}
8
+ .product_gift .free_product_selector{float: left;width: 8%;margin-top: 50px;}
9
+ .product_gift .free_product_name{float: left;width: 85%;}
10
+ .product_gift .free_product_name table{width: 100%;text-align: center;}
11
+ .product_gift .free_product_name table .td-first{width:50%;vertical-align: middle;}
12
+ .product_gift .free_product_name table .td-first .select-gift-img{width: 120px;height: auto;}
13
+ .product_gift .free_product_name table .td-second{text-align: center;}
14
+ .product_gift .free_product_name table .td-pname{text-align: center;color: #c76200;}
skin/frontend/default/default/images/free.png ADDED
Binary file
skin/frontend/default/default/images/gift_list.png ADDED
Binary file