auguriainsurance - Version 0.0.1

Version Notes

Compatibility with magento 1.9

Download this release

Release Info

Developer Auguria
Extension auguriainsurance
Version 0.0.1
Comparing to
See all releases


Version 0.0.1

Files changed (41) hide show
  1. app/code/community/Auguria/Core/Helper/Data.php +9 -0
  2. app/code/community/Auguria/Core/Model/Attribute/Backend/Image/Abstract.php +59 -0
  3. app/code/community/Auguria/Core/Model/Customer/Attribute/Source/Group.php +22 -0
  4. app/code/community/Auguria/Core/Model/System/Config/Source/Config.php +35 -0
  5. app/code/community/Auguria/Core/Model/System/Config/Source/Customer/Group/Multiselect.php +34 -0
  6. app/code/community/Auguria/Core/etc/config.xml +50 -0
  7. app/code/community/Auguria/Core/etc/system.xml +17 -0
  8. app/code/community/Auguria/Insurance/Block/Checkout/Cart/Total/Insurance.php +63 -0
  9. app/code/community/Auguria/Insurance/Block/Checkout/Insurance.php +83 -0
  10. app/code/community/Auguria/Insurance/Block/Sales/Order/Total/Insurance.php +157 -0
  11. app/code/community/Auguria/Insurance/Helper/Config.php +47 -0
  12. app/code/community/Auguria/Insurance/Helper/Data.php +33 -0
  13. app/code/community/Auguria/Insurance/Model/Catalog/Product/Type/Insurance.php +25 -0
  14. app/code/community/Auguria/Insurance/Model/Observer.php +89 -0
  15. app/code/community/Auguria/Insurance/Model/Sales/Order/Pdf/Items/Default.php +19 -0
  16. app/code/community/Auguria/Insurance/Model/Sales/Order/Pdf/Total/Insurance.php +70 -0
  17. app/code/community/Auguria/Insurance/Model/Sales/Quote/Address/Total/Insurance.php +31 -0
  18. app/code/community/Auguria/Insurance/controllers/IndexController.php +98 -0
  19. app/code/community/Auguria/Insurance/etc/adminhtml.xml +30 -0
  20. app/code/community/Auguria/Insurance/etc/config.xml +185 -0
  21. app/code/community/Auguria/Insurance/etc/system.xml +81 -0
  22. app/code/community/Auguria/Insurance/sql/auguria_insurance_setup/install-0.0.1.php +129 -0
  23. app/design/adminhtml/default/default/layout/auguria/core.xml +19 -0
  24. app/design/adminhtml/default/default/template/auguria/insurance/checkout/cart/total/insurance.phtml +23 -0
  25. app/design/adminhtml/default/default/template/auguria/insurance/sales/order/total/insurance.phtml +22 -0
  26. app/design/frontend/base/default/layout/auguria/insurance.xml +338 -0
  27. app/design/frontend/base/default/template/auguria/insurance/checkout/cart/item/insurance.phtml +11 -0
  28. app/design/frontend/base/default/template/auguria/insurance/checkout/cart/total/insurance.phtml +23 -0
  29. app/design/frontend/base/default/template/auguria/insurance/checkout/insurance.phtml +65 -0
  30. app/design/frontend/base/default/template/auguria/insurance/sales/order/total/insurance.phtml +22 -0
  31. app/etc/modules/Auguria_Core.xml +17 -0
  32. app/etc/modules/Auguria_Insurance.xml +20 -0
  33. app/locale/en_US/Auguria_Core.csv +0 -0
  34. app/locale/en_US/Auguria_Insurance.csv +0 -0
  35. app/locale/fr_FR/Auguria_Core.csv +0 -0
  36. app/locale/fr_FR/Auguria_Insurance.csv +13 -0
  37. package.xml +25 -0
  38. skin/adminhtml/default/default/auguria/core.css +17 -0
  39. skin/adminhtml/default/default/auguria/images/section-header.png +0 -0
  40. skin/adminhtml/default/default/auguria/images/tab-header.png +0 -0
  41. skin/frontend/base/default/css/auguria/insurance/style.css +19 -0
app/code/community/Auguria/Core/Helper/Data.php ADDED
@@ -0,0 +1,9 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Core
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_Core_Helper_Data extends Mage_Core_Helper_Abstract {}
app/code/community/Auguria/Core/Model/Attribute/Backend/Image/Abstract.php ADDED
@@ -0,0 +1,59 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Core
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ abstract class Auguria_Core_Model_Attribute_Backend_Image_Abstract extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract
10
+ {
11
+ /**
12
+ * Save uploaded file
13
+ *
14
+ * @param Varien_Object $object
15
+ */
16
+ public function afterSave($object)
17
+ {
18
+ $value = $object->getData($this->getAttribute()->getName());
19
+
20
+ if (is_array($value) && !empty($value['delete'])) {
21
+ $object->setData($this->getAttribute()->getName(), '');
22
+ $this->getAttribute()->getEntity()
23
+ ->saveAttribute($object, $this->getAttribute()->getName());
24
+ return;
25
+ }
26
+
27
+ try {
28
+ $uploader = new Mage_Core_Model_File_Uploader($this->getAttribute()->getName());
29
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
30
+ $uploader->setAllowRenameFiles(true);
31
+ $result = $uploader->save($this->_getPath());
32
+
33
+ $object->setData($this->getAttribute()->getName(), $this->_getPrefix() . $result['file']);
34
+ $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
35
+ } catch (Exception $e) {
36
+ if ($e->getCode() != Mage_Core_Model_File_Uploader::TMP_NAME_EMPTY) {
37
+ Mage::logException($e);
38
+ }
39
+ return;
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Get path to save file
45
+ *
46
+ * @return string
47
+ */
48
+ abstract protected function _getPath();
49
+
50
+ /**
51
+ * Get prefix when save path file in attribute value
52
+ *
53
+ * @return string
54
+ */
55
+ protected function _getPrefix()
56
+ {
57
+ return;
58
+ }
59
+ }
app/code/community/Auguria/Core/Model/Customer/Attribute/Source/Group.php ADDED
@@ -0,0 +1,22 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Core
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_Core_Model_Customer_Attribute_Source_Group extends Mage_Eav_Model_Entity_Attribute_Source_Table
10
+ {
11
+ public function getAllOptions()
12
+ {
13
+ if (!$this->_options) {
14
+ $this->_options = Mage::getResourceModel('customer/group_collection')
15
+ //->setRealGroupsFilter() GET NOT LOGGED IN GROUP
16
+ ->load()
17
+ ->toOptionArray()
18
+ ;
19
+ }
20
+ return $this->_options;
21
+ }
22
+ }
app/code/community/Auguria/Core/Model/System/Config/Source/Config.php ADDED
@@ -0,0 +1,35 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Core
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ abstract class Auguria_Core_Model_System_Config_Source_Config
10
+ {
11
+
12
+ const CONFIG_OPTIONS_PATH = '';
13
+
14
+ /**
15
+ * Options getter
16
+ *
17
+ * @return array
18
+ */
19
+ public function toOptionArray()
20
+ {
21
+ $nodes = Mage::getConfig()->getNode(static::CONFIG_OPTIONS_PATH);
22
+ $translator = (string)$nodes->getAttribute('translator'); // used to translate label
23
+
24
+ $options = array();
25
+
26
+ foreach($nodes as $_node){
27
+ foreach ($_node as $_option){
28
+ $options[] = array('value' => (string)$_option->value, 'label' => Mage::helper($translator)->__((string)$_option->label));
29
+ }
30
+ }
31
+
32
+ return $options;
33
+ }
34
+
35
+ }
app/code/community/Auguria/Core/Model/System/Config/Source/Customer/Group/Multiselect.php ADDED
@@ -0,0 +1,34 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Core
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_Core_Model_System_Config_Source_Customer_Group_Multiselect
10
+ {
11
+
12
+ /**
13
+ * Customer groups options array
14
+ *
15
+ * @var null|array
16
+ */
17
+ protected $_options;
18
+
19
+ /**
20
+ * Retrieve customer groups as array
21
+ *
22
+ * @return array
23
+ */
24
+ public function toOptionArray()
25
+ {
26
+ if (!$this->_options) {
27
+ $this->_options = Mage::getResourceModel('customer/group_collection')
28
+ //->setRealGroupsFilter() Get the NOT LOGGED IN GROUP TOO
29
+ ->loadData()->toOptionArray();
30
+ }
31
+ return $this->_options;
32
+ }
33
+
34
+ }
app/code/community/Auguria/Core/etc/config.xml ADDED
@@ -0,0 +1,50 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * @category Auguria
5
+ * @package Auguria_Core
6
+ * @author Auguria
7
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
8
+ */
9
+ -->
10
+ <config>
11
+
12
+ <modules>
13
+ <Auguria_Core>
14
+ <version/>
15
+ </Auguria_Core>
16
+ </modules>
17
+
18
+ <global>
19
+ <helpers>
20
+ <auguria_core>
21
+ <class>Auguria_Core_Helper</class>
22
+ </auguria_core>
23
+ </helpers>
24
+ <models>
25
+ <auguria_core>
26
+ <class>Auguria_Core_Model</class>
27
+ </auguria_core>
28
+ </models>
29
+ </global>
30
+
31
+ <adminhtml>
32
+ <layout>
33
+ <updates>
34
+ <auguria_core>
35
+ <file>auguria/core.xml</file>
36
+ </auguria_core>
37
+ </updates>
38
+ </layout>
39
+ <translate>
40
+ <modules>
41
+ <Auguria_Core>
42
+ <files>
43
+ <default>Auguria_Core.csv</default>
44
+ </files>
45
+ </Auguria_Core>
46
+ </modules>
47
+ </translate>
48
+ </adminhtml>
49
+
50
+ </config>
app/code/community/Auguria/Core/etc/system.xml ADDED
@@ -0,0 +1,17 @@
1
+ <!--
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Core
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+ -->
9
+ <config>
10
+ <tabs>
11
+ <auguria>
12
+ <label></label>
13
+ <sort_order>150</sort_order>
14
+ <class>auguria-tab</class>
15
+ </auguria>
16
+ </tabs>
17
+ </config>
app/code/community/Auguria/Insurance/Block/Checkout/Cart/Total/Insurance.php ADDED
@@ -0,0 +1,63 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Insurance
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_Insurance_Block_Checkout_Cart_Total_Insurance extends Mage_Checkout_Block_Total_Default
10
+ {
11
+ protected $_insurances = null;
12
+
13
+ /**
14
+ * Custom template
15
+ *
16
+ * @var string
17
+ */
18
+ protected $_template = 'auguria/insurance/checkout/cart/total/insurance.phtml';
19
+
20
+ /**
21
+ * Get products insurances
22
+ *
23
+ * @return array
24
+ */
25
+ public function getInsurances()
26
+ {
27
+ if(is_null($this->_insurances)){
28
+ $this->_insurances = array();
29
+
30
+ foreach ($this->getQuote()->getItemsCollection() as $_item){
31
+ /* @var $_item Mage_Sales_Model_Quote_Item*/
32
+ if($_item->getProductType() == Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID){
33
+ $this->_insurances[] = $_item;
34
+ }
35
+ }
36
+ }
37
+
38
+ return $this->_insurances;
39
+ }
40
+
41
+ /**
42
+ * Get formated price with insurance configuration
43
+ *
44
+ * @param Mage_Sales_Model_Quote_Item $insurance
45
+ * @return string
46
+ */
47
+ public function getFormatedPrice(Mage_Sales_Model_Quote_Item $insurance)
48
+ {
49
+ $displayType = Mage::helper('auguria_insurance/config')->getInsuranceCartDisplayType();
50
+
51
+ if($displayType == Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX){ // Excl. Tax
52
+ return Mage::helper('checkout')->formatPrice($insurance->getPrice());
53
+
54
+ }elseif($displayType == Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX){ // Incl. Tax
55
+ return Mage::helper('checkout')->formatPrice($insurance->getPriceInclTax());
56
+
57
+ }else{ // Both
58
+ return $this->__('Excl. Tax ') . Mage::helper('checkout')->formatPrice($insurance->getPrice())
59
+ . '<br>' . $this->__('Incl. Tax ') . Mage::helper('checkout')->formatPrice($insurance->getPriceInclTax());
60
+ }
61
+ }
62
+
63
+ }
app/code/community/Auguria/Insurance/Block/Checkout/Insurance.php ADDED
@@ -0,0 +1,83 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Insurance
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_Insurance_Block_Checkout_Insurance extends Mage_Catalog_Block_Product
10
+ {
11
+ /**
12
+ * Retrieve shopping cart model object
13
+ *
14
+ * @return Mage_Checkout_Model_Cart
15
+ */
16
+ protected function _getCart()
17
+ {
18
+ return Mage::getSingleton('checkout/cart');
19
+ }
20
+
21
+ /**
22
+ * Check if the cart is empty
23
+ *
24
+ * @return bool
25
+ */
26
+ public function isNotEmptyCart()
27
+ {
28
+ return (bool)Mage::getSingleton('checkout/session')->getQuote()->getItemsCount();
29
+ }
30
+
31
+ /**
32
+ * Get assurances associated to the current store
33
+ *
34
+ * return Mage_Catalog_Model_Resource_Product_Collection
35
+ */
36
+ public function getInsurances()
37
+ {
38
+ return Mage::getResourceModel('catalog/product_collection')
39
+ ->addAttributeToSelect('name')
40
+ ->addAttributeToSelect('short_description')
41
+ ->addAttributeToFilter('type_id', Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID)
42
+ ->addStoreFilter()
43
+ ->addPriceData();
44
+ }
45
+
46
+ /**
47
+ * Check if insurance is in cart
48
+ *
49
+ * @param Mage_Catalog_Model_Product $insurance
50
+ * @return bool
51
+ */
52
+ public function isInsuranceInCart(Mage_Catalog_Model_Product $insurance)
53
+ {
54
+ $items = $this->_getCart()->getItems();
55
+
56
+ if ($items && $items->getSize()) {
57
+ foreach ($items as $item) { // compare all items in cart
58
+ if ($item->getProductId() == $insurance->getId()) {
59
+ return true; // insurance exists in cart
60
+ }
61
+ }
62
+ }
63
+
64
+ return false;
65
+ }
66
+
67
+ /**
68
+ * FOR 1.8 BUG (get special price attribute in price template)
69
+ * bug in catalog/product/price.phml line 50
70
+ *
71
+ * Retrieve attribute instance by name, id or config node
72
+ *
73
+ * If attribute is not found false is returned
74
+ *
75
+ * @param string|integer|Mage_Core_Model_Config_Element $attribute
76
+ * @return Mage_Eav_Model_Entity_Attribute_Abstract || false
77
+ */
78
+ public function getProductAttribute($attribute)
79
+ {
80
+ return $this->getProduct()->getResource()->getAttribute($attribute);
81
+ }
82
+
83
+ }
app/code/community/Auguria/Insurance/Block/Sales/Order/Total/Insurance.php ADDED
@@ -0,0 +1,157 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Insurance
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_Insurance_Block_Sales_Order_Total_Insurance extends Mage_Core_Block_Template
10
+ {
11
+ protected $_source;
12
+ protected $_items = array();
13
+ protected $_colspan = 4;
14
+ protected $_colspanCreditmemo = 6;
15
+ protected $_additionnalAttributes;
16
+ protected $_additionnalStyles;
17
+ protected $_store;
18
+
19
+ /**
20
+ * Get data (totals) source model
21
+ *
22
+ * @return Varien_Object
23
+ */
24
+ public function getSource()
25
+ {
26
+ return $this->_source;
27
+ }
28
+
29
+ public function initTotals()
30
+ {
31
+ $parent = $this->getParentBlock();
32
+ $this->_source = $parent->getSource();
33
+ $this->_store = Mage::app()->getStore($this->_source->getStoreId());
34
+
35
+ if ($this->_source && $this->_hasInsurances($this->_source)) {
36
+ $this->_addInsurance();
37
+ }
38
+
39
+ return $this;
40
+ }
41
+
42
+ protected function _hasInsurances($source)
43
+ {
44
+ foreach ($source->getItemsCollection() as $_item){
45
+ if($_item instanceof Mage_Sales_Model_Order_Item){ // Order
46
+ $productType = $_item->getProductType();
47
+ }else{ // Invoice, Creditmemo
48
+ $productType = $_item->getOrderItem()->getProductType();
49
+ }
50
+
51
+ if($productType == Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID){ // is insurance
52
+ $this->_items[] = $_item;
53
+ }
54
+ }
55
+
56
+ return $this->_items;
57
+ }
58
+
59
+ /**
60
+ * Add insurance total string
61
+ *
62
+ * @param string $after
63
+ * @return Auguria_Insurance_Block_Sales_Order_Insurance
64
+ */
65
+ protected function _addInsurance($after = 'last')
66
+ {
67
+ $amount = 1;
68
+
69
+ $total = new Varien_Object(array(
70
+ 'code' => 'auguria_insurance',
71
+ 'field' => 'auguria_insurance_amount',
72
+ 'block_name' => $this->getNameInLayout(),
73
+ 'value' => $amount,
74
+ 'label' => $this->helper('auguria_insurance')->__('Insurances')
75
+ ));
76
+
77
+ $this->getParentBlock()->addTotal($total, $after);
78
+
79
+ return $this;
80
+ }
81
+
82
+ public function getTotal()
83
+ {
84
+ return $this->getParentBlock()->getTotal('auguria_insurance');
85
+ }
86
+
87
+ public function getInsurances()
88
+ {
89
+ return $this->_items;
90
+ }
91
+
92
+ /**
93
+ * Set colspan (in layout)
94
+ *
95
+ * @param string $code
96
+ * @param int $number
97
+ */
98
+ public function setColspan($code = 'default', $number)
99
+ {
100
+ if($code == 'default'){
101
+ $this->_colspan = $number;
102
+ }elseif($code == 'creditmemo'){
103
+ $this->_colspanCreditmemo = $number;
104
+ }
105
+ }
106
+
107
+ public function getColspan()
108
+ {
109
+ if($this->_source instanceof Mage_Sales_Model_Order_Creditmemo){
110
+ return $this->_colspanCreditmemo;
111
+ }
112
+
113
+ return $this->_colspan;
114
+ }
115
+
116
+ public function setAdditionnalAttributes($attributes)
117
+ {
118
+ $this->_additionnalAttributes = $attributes;
119
+ }
120
+
121
+ public function getAdditionnalAttributes()
122
+ {
123
+ return $this->_additionnalAttributes;
124
+ }
125
+
126
+ public function setAdditionnalStyles($styles)
127
+ {
128
+ $this->_additionnalStyles = $styles;
129
+ }
130
+
131
+ public function getAdditionnalStyles()
132
+ {
133
+ return $this->_additionnalStyles;
134
+ }
135
+
136
+ /**
137
+ * Get formated price with insurance configuration
138
+ *
139
+ * @param mixed $insurance
140
+ * @return string
141
+ */
142
+ public function getFormatedPrice($insurance)
143
+ {
144
+ $displayType = Mage::helper('auguria_insurance/config')->getInsuranceCartDisplayType();
145
+
146
+ if($displayType == Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX){ // Excl. Tax
147
+ return $this->_store->formatPrice($insurance->getPrice());
148
+
149
+ }elseif($displayType == Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX){ // Incl. Tax
150
+ return $this->_store->formatPrice($insurance->getPriceInclTax());
151
+
152
+ }else{ // Both
153
+ return $this->__('Excl. Tax ') . $this->_store->formatPrice($insurance->getPrice())
154
+ . '<br>' . $this->__('Incl. Tax ') . $this->_store->formatPrice($insurance->getPriceInclTax());
155
+ }
156
+ }
157
+ }
app/code/community/Auguria/Insurance/Helper/Config.php ADDED
@@ -0,0 +1,47 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Insurance
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_Insurance_Helper_Config extends Mage_Core_Helper_Abstract
10
+ {
11
+ /* PATH TO CONFIGURATION */
12
+ const XML_PATH_INSURANCE_ACTIVE = 'auguria_insurance/general/active';
13
+
14
+ const XML_PATH_INSURANCE_CART_DISPLAY_PRICE = 'auguria_insurance/cart/display_price';
15
+
16
+ const XML_PATH_INSURANCE_SALES_DISPLAY_PRICE = 'auguria_insurance/sales/display_price';
17
+
18
+ /**
19
+ * Check if insurance extension is active for the current store
20
+ *
21
+ * @return bool
22
+ */
23
+ public function isInsuranceActive()
24
+ {
25
+ return Mage::getStoreConfigFlag(self::XML_PATH_INSURANCE_ACTIVE);
26
+ }
27
+
28
+ /**
29
+ * Check if cart price must be displayed Excl. Tax, Incl. Tax...
30
+ *
31
+ * @return int
32
+ */
33
+ public function getInsuranceCartDisplayType()
34
+ {
35
+ return Mage::getStoreConfig(self::XML_PATH_INSURANCE_CART_DISPLAY_PRICE);
36
+ }
37
+
38
+ /**
39
+ * Check if sales price must be displayed Excl. Tax, Incl. Tax...
40
+ *
41
+ * @return int
42
+ */
43
+ public function getInsuranceSalesDisplayType()
44
+ {
45
+ return Mage::getStoreConfig(self::XML_PATH_INSURANCE_SALES_DISPLAY_PRICE);
46
+ }
47
+ }
app/code/community/Auguria/Insurance/Helper/Data.php ADDED
@@ -0,0 +1,33 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Insurance
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_Insurance_Helper_Data extends Mage_Core_Helper_Abstract
10
+ {
11
+ /**
12
+ * Get all insurances
13
+ *
14
+ * @return array
15
+ */
16
+ public function getInsuranceIds()
17
+ {
18
+ return Mage::getResourceModel('catalog/product_collection')
19
+ ->addAttributeToFilter('type_id', Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID)
20
+ ->addStoreFilter()
21
+ ->getAllIds();
22
+ }
23
+
24
+ public function setInsuranceExcluded($id, $value)
25
+ {
26
+ Mage::getSingleton('checkout/session')->setData("auguria_insurance_{$id}_excluded", $value);
27
+ }
28
+
29
+ public function getInsuranceExcluded($id)
30
+ {
31
+ return Mage::getSingleton('checkout/session')->getData("auguria_insurance_{$id}_excluded");
32
+ }
33
+ }
app/code/community/Auguria/Insurance/Model/Catalog/Product/Type/Insurance.php ADDED
@@ -0,0 +1,25 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Insurance
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_Insurance_Model_Catalog_Product_Type_Insurance extends Mage_Catalog_Model_Product_Type_Abstract
10
+ {
11
+ const AUGURIA_INSURANCE_PRODUCT_TYPE_ID = 'auguria_insurance';
12
+
13
+ /**
14
+ * Check is virtual product
15
+ * BUG with label cart rule ?
16
+ *
17
+ * @param Mage_Catalog_Model_Product $product
18
+ * @return bool
19
+ */
20
+ // public function isVirtual($product = null)
21
+ // {
22
+ // return true;
23
+ // }
24
+
25
+ }
app/code/community/Auguria/Insurance/Model/Observer.php ADDED
@@ -0,0 +1,89 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Insurance
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_Insurance_Model_Observer
10
+ {
11
+ /**
12
+ * Update quote qty informations
13
+ *
14
+ * Event : sales_quote_collect_totals_after
15
+ *
16
+ * @param Varien_Event_Observer $observer
17
+ * @return Auguria_Insurance_Model_Observer
18
+ */
19
+ public function initQuoteQty(Varien_Event_Observer $observer)
20
+ {
21
+ /* @var Mage_Sales_Model_Quote $quote */
22
+ $quote = $observer->getEvent()->getQuote();
23
+
24
+ $insuranceCount = 0;
25
+ $insuranceQty = 0;
26
+
27
+ // get insurance product type qty
28
+ foreach ($quote->getAllVisibleItems() as $_item){
29
+ if($_item->getProductType() == Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID){
30
+ $insuranceCount ++;
31
+ $insuranceQty += $_item->getQty();
32
+ }
33
+ }
34
+
35
+ // update quote qty informations
36
+ $quote->setItemsCount($quote->getItemsCount() - $insuranceCount);
37
+ $quote->setItemsQty((float) $quote->getItemsQty() - $insuranceQty);
38
+
39
+ return $this;
40
+ }
41
+
42
+ /**
43
+ * Update item qty
44
+ *
45
+ * Event : sales_quote_item_qty_set_after
46
+ *
47
+ * @param Varien_Event_Observer $observer
48
+ * @return Auguria_Insurance_Model_Observer
49
+ */
50
+ public function initItemQty(Varien_Event_Observer $observer)
51
+ {
52
+ /* @var Mage_Sales_Model_Quote_Item $item */
53
+ $item = $observer->getEvent()->getItem();
54
+
55
+ if($item->getProductType() == Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID){
56
+ $item->setData('qty', 1); // force qty (bug when reorder if not forced)
57
+ }
58
+
59
+ return $this;
60
+ }
61
+
62
+ /**
63
+ * Init insurances in quote
64
+ *
65
+ * Event : controller_action_predispatch_checkout_cart_index
66
+ *
67
+ * @param Varien_Event_Observer $observer
68
+ * @return Auguria_Insurance_Model_Observer
69
+ */
70
+ public function initQuoteInsurances(Varien_Event_Observer $observer)
71
+ {
72
+ /* @var Mage_Sales_Model_Quote $quote */
73
+ $quote = Mage::getSingleton('checkout/cart')->getQuote();
74
+
75
+ foreach (Mage::helper('auguria_insurance')->getInsuranceIds() as $_id){
76
+ if(!Mage::helper('auguria_insurance')->getInsuranceExcluded($_id)){
77
+
78
+ try {
79
+ $_insurance = Mage::getModel('catalog/product')->load($_id);
80
+ if($_insurance->getAuguriaInsuranceIsDefault()){ // insurance is added by default
81
+ $quote->addProduct($_insurance);
82
+ }
83
+ } catch (Exception $e) {
84
+ Mage::logException($e);
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
app/code/community/Auguria/Insurance/Model/Sales/Order/Pdf/Items/Default.php ADDED
@@ -0,0 +1,19 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Insurance
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_Insurance_Model_Sales_Order_Pdf_Items_Default extends Mage_Sales_Model_Order_Pdf_Items_Abstract
10
+ {
11
+ /**
12
+ * Draw item line
13
+ *
14
+ */
15
+ public function draw()
16
+ {
17
+ return $this;
18
+ }
19
+ }
app/code/community/Auguria/Insurance/Model/Sales/Order/Pdf/Total/Insurance.php ADDED
@@ -0,0 +1,70 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Insurance
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_Insurance_Model_Sales_Order_Pdf_Total_Insurance extends Mage_Sales_Model_Order_Pdf_Total_Default
10
+ {
11
+ /**
12
+ * Get array of arrays with totals information for display in PDF
13
+ * array(
14
+ * $index => array(
15
+ * 'amount' => $amount,
16
+ * 'label' => $label,
17
+ * 'font_size'=> $font_size
18
+ * )
19
+ * )
20
+ * @return array
21
+ */
22
+ public function getTotalsForDisplay()
23
+ {
24
+ $label = Mage::helper('sales')->__($this->getTitle()) . ':';
25
+ $fontSize = $this->getFontSize() ? $this->getFontSize() : 7;
26
+
27
+ $totals = array(); // multiple totals
28
+
29
+ foreach ($this->getSource()->getItemsCollection() as $_item){
30
+ if($_item instanceof Mage_Sales_Model_Order_Item){ // Order
31
+ $productType = $_item->getProductType();
32
+ }else{ // Invoice, Creditmemo
33
+ $productType = $_item->getOrderItem()->getProductType();
34
+ }
35
+
36
+ if($productType == Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID){ // is insurance
37
+ // add the insurance total
38
+ $totals[] = array(
39
+ 'amount' => $this->getFormatedPrice($_item, $this->getSource()->getStore()),
40
+ 'label' => $_item->getName() . ' ' . Mage::helper('auguria_insurance')->__('(included in total amount)'),
41
+ 'font_size' => $fontSize
42
+ );
43
+ }
44
+ }
45
+
46
+ return $totals;
47
+ }
48
+
49
+ /**
50
+ * Get formated price with insurance configuration
51
+ *
52
+ * @param mixed $insurance
53
+ * @return string
54
+ */
55
+ public function getFormatedPrice($insurance, $store)
56
+ {
57
+ $displayType = Mage::helper('auguria_insurance/config')->getInsuranceCartDisplayType();
58
+
59
+ if($displayType == Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX){ // Excl. Tax
60
+ return $store->formatPrice($insurance->getPrice(), false);
61
+
62
+ }elseif($displayType == Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX){ // Incl. Tax
63
+ return $store->formatPrice($insurance->getPriceInclTax(), false);
64
+
65
+ }else{ // Both
66
+ return $this->__('Excl. Tax ') . $store->formatPrice($insurance->getPrice(), false)
67
+ . "\n" . $this->__('Incl. Tax ') . $store->formatPrice($insurance->getPriceInclTax(), false);
68
+ }
69
+ }
70
+ }
app/code/community/Auguria/Insurance/Model/Sales/Quote/Address/Total/Insurance.php ADDED
@@ -0,0 +1,31 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Insurance
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_Insurance_Model_Sales_Quote_Address_Total_Insurance extends Mage_Sales_Model_Quote_Address_Total_Abstract
10
+ {
11
+ public function collect(Mage_Sales_Model_Quote_Address $address)
12
+ {
13
+ return $this;
14
+ }
15
+
16
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
17
+ {
18
+ $title = Mage::helper('auguria_insurance')->__('Insurances');
19
+
20
+ $address->addTotal(array(
21
+ 'code' => $this->getCode(),
22
+ 'title' => $title,
23
+ 'value' => 1,
24
+ 'style' => 'insurance',
25
+ 'area' => 'footer',
26
+ ));
27
+
28
+ return $this;
29
+ }
30
+
31
+ }
app/code/community/Auguria/Insurance/controllers/IndexController.php ADDED
@@ -0,0 +1,98 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Insurance
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_Insurance_IndexController extends Mage_Core_Controller_Front_Action
10
+ {
11
+ /**
12
+ * Retrieve shopping cart model object
13
+ *
14
+ * @return Mage_Checkout_Model_Cart
15
+ */
16
+ protected function _getCart()
17
+ {
18
+ return Mage::getSingleton('checkout/cart');
19
+ }
20
+
21
+ /**
22
+ * Get checkout session model instance
23
+ *
24
+ * @return Mage_Checkout_Model_Session
25
+ */
26
+ protected function _getSession()
27
+ {
28
+ return Mage::getSingleton('checkout/session');
29
+ }
30
+
31
+ /**
32
+ * Initialize product instance from request data
33
+ *
34
+ * @return Mage_Catalog_Model_Product || false
35
+ */
36
+ protected function _initProduct()
37
+ {
38
+ $productId = (int) $this->getRequest()->getParam('insurance_id');
39
+ if ($productId) {
40
+ $product = Mage::getModel('catalog/product')
41
+ ->setStoreId(Mage::app()->getStore()->getId())
42
+ ->load($productId);
43
+
44
+ if ($product->getId()) {
45
+ return $product;
46
+ }
47
+ }
48
+ return false;
49
+ }
50
+
51
+ /**
52
+ * Add/Remove insurance to/from the cart
53
+ */
54
+ public function updateInsuranceAction()
55
+ {
56
+ try {
57
+
58
+ if(!$this->getRequest()->getParam('is_in_cart')){ // insurance to add
59
+ if($insurance = $this->_initProduct()){ // init product insurance and check id
60
+ $cart = $this->_getCart();
61
+ $session = $this->_getSession();
62
+
63
+ $cart->addProduct($insurance); // qty forced in observer
64
+ $cart->save();
65
+
66
+ $session->setCartWasUpdated(true);
67
+ $session->addSuccess($this->__('The insurance has been added to the cart'));
68
+ }
69
+ }else{ // remove insurance
70
+ if($insuranceId = $this->getRequest()->getParam('insurance_id')){ // check insurance id
71
+ $cart = $this->_getCart();
72
+ $session = $this->_getSession();
73
+ $items = $cart->getItems();
74
+
75
+ if($items && $items->getSize()){ // if cart is not empty
76
+ foreach ($items as $_item){
77
+ if($_item->getProductId() == $insuranceId){
78
+ $cart->removeItem($_item->getId()); // remove assurance
79
+ }
80
+ }
81
+
82
+ $cart->save();
83
+
84
+ $session->setCartWasUpdated(true);
85
+ Mage::helper('auguria_insurance')->setInsuranceExcluded($insuranceId, 1); // for not adding it to cart automatically
86
+ $session->addSuccess($this->__('The insurance has been removed from the cart'));
87
+ }
88
+ }
89
+ }
90
+ } catch (Exception $e) {
91
+ $this->_getSession()->addError($this->__("An error occurs while updating the insurance in the cart"));
92
+ Mage::logException($e);
93
+ }
94
+
95
+ $this->_redirect('checkout/cart');
96
+ }
97
+
98
+ }
app/code/community/Auguria/Insurance/etc/adminhtml.xml ADDED
@@ -0,0 +1,30 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Auguria
5
+ * @package Auguria_Insurance
6
+ * @author Auguria
7
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
8
+ */
9
+ -->
10
+ <config>
11
+ <acl>
12
+ <resources>
13
+ <admin>
14
+ <children>
15
+ <system>
16
+ <children>
17
+ <config>
18
+ <children>
19
+ <auguria_insurance translate="title" module="auguria_insurance">
20
+ <title>Auguria insurance</title>
21
+ </auguria_insurance>
22
+ </children>
23
+ </config>
24
+ </children>
25
+ </system>
26
+ </children>
27
+ </admin>
28
+ </resources>
29
+ </acl>
30
+ </config>
app/code/community/Auguria/Insurance/etc/config.xml ADDED
@@ -0,0 +1,185 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * @category Auguria
5
+ * @package Auguria_Insurance
6
+ * @author Auguria
7
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
8
+ */
9
+ -->
10
+ <config>
11
+
12
+ <modules>
13
+ <Auguria_Insurance>
14
+ <version>0.0.1</version>
15
+ </Auguria_Insurance>
16
+ </modules>
17
+
18
+ <global>
19
+ <resources>
20
+ <auguria_insurance_setup>
21
+ <setup>
22
+ <module>Auguria_Insurance</module>
23
+ <class>Mage_Catalog_Model_Resource_Setup</class>
24
+ </setup>
25
+ </auguria_insurance_setup>
26
+ </resources>
27
+ <blocks>
28
+ <auguria_insurance>
29
+ <class>Auguria_Insurance_Block</class>
30
+ </auguria_insurance>
31
+ </blocks>
32
+ <helpers>
33
+ <auguria_insurance>
34
+ <class>Auguria_Insurance_Helper</class>
35
+ </auguria_insurance>
36
+ </helpers>
37
+ <models>
38
+ <auguria_insurance>
39
+ <class>Auguria_Insurance_Model</class>
40
+ </auguria_insurance>
41
+ </models>
42
+ <events>
43
+ <sales_quote_collect_totals_after>
44
+ <observers>
45
+ <auguria_insurance_quote_summary_qty>
46
+ <class>auguria_insurance/observer</class>
47
+ <method>initQuoteQty</method>
48
+ </auguria_insurance_quote_summary_qty>
49
+ </observers>
50
+ </sales_quote_collect_totals_after>
51
+ <sales_quote_item_qty_set_after>
52
+ <observers>
53
+ <auguria_insurance_quote_item_qty>
54
+ <class>auguria_insurance/observer</class>
55
+ <method>initItemQty</method>
56
+ </auguria_insurance_quote_item_qty>
57
+ </observers>
58
+ </sales_quote_item_qty_set_after>
59
+ <controller_action_predispatch_checkout_cart_index>
60
+ <observers>
61
+ <auguria_insurance_init_quote_insurances>
62
+ <class>auguria_insurance/observer</class>
63
+ <method>initQuoteInsurances</method>
64
+ </auguria_insurance_init_quote_insurances>
65
+ </observers>
66
+ </controller_action_predispatch_checkout_cart_index>
67
+ </events>
68
+
69
+ <catalog>
70
+ <product>
71
+ <type>
72
+ <auguria_insurance translate="label" module="auguria_insurance">
73
+ <label>Insurance product</label>
74
+ <model>auguria_insurance/catalog_product_type_insurance</model>
75
+ <composite>0</composite>
76
+ <index_priority>0</index_priority>
77
+ </auguria_insurance>
78
+ </type>
79
+ </product>
80
+ </catalog>
81
+ <sales>
82
+ <quote>
83
+ <totals>
84
+ <auguria_insurance>
85
+ <class>auguria_insurance/sales_quote_address_total_insurance</class>
86
+ <after>-</after>
87
+ <renderer>auguria_insurance/checkout_cart_total_insurance</renderer>
88
+ <admin_renderer>auguria_insurance/adminhtml_checkout_cart_total_insurance</admin_renderer>
89
+ </auguria_insurance>
90
+ </totals>
91
+ </quote>
92
+ </sales>
93
+ <pdf>
94
+ <totals>
95
+ <auguria_insurance translate="title">
96
+ <title>Insurances</title>
97
+ <model>auguria_insurance/sales_order_pdf_total_insurance</model>
98
+ <font_size>7</font_size>
99
+ <display_zero>1</display_zero>
100
+ <sort_order>800</sort_order>
101
+ </auguria_insurance>
102
+ </totals>
103
+ <invoice>
104
+ <auguria_insurance>auguria_insurance/sales_order_pdf_items_default</auguria_insurance>
105
+ </invoice>
106
+ <shipment>
107
+ <auguria_insurance>auguria_insurance/sales_order_pdf_items_default</auguria_insurance>
108
+ </shipment>
109
+ <creditmemo>
110
+ <auguria_insurance>auguria_insurance/sales_order_pdf_items_default</auguria_insurance>
111
+ </creditmemo>
112
+ </pdf>
113
+ </global>
114
+
115
+ <frontend>
116
+ <routers>
117
+ <auguria_insurance>
118
+ <use>standard</use>
119
+ <args>
120
+ <module>Auguria_Insurance</module>
121
+ <frontName>insurance</frontName>
122
+ </args>
123
+ </auguria_insurance>
124
+ </routers>
125
+ <layout>
126
+ <updates>
127
+ <auguria_insurance>
128
+ <file>auguria/insurance.xml</file>
129
+ </auguria_insurance>
130
+ </updates>
131
+ </layout>
132
+ <translate>
133
+ <modules>
134
+ <Auguria_Insurance>
135
+ <files>
136
+ <default>Auguria_Insurance.csv</default>
137
+ </files>
138
+ </Auguria_Insurance>
139
+ </modules>
140
+ </translate>
141
+ </frontend>
142
+
143
+ <adminhtml>
144
+ <layout>
145
+ <updates>
146
+ <auguria_insurance>
147
+ <file>auguria/insurance.xml</file>
148
+ </auguria_insurance>
149
+ </updates>
150
+ </layout>
151
+ <translate>
152
+ <modules>
153
+ <Auguria_Insurance>
154
+ <files>
155
+ <default>Auguria_Insurance.csv</default>
156
+ </files>
157
+ </Auguria_Insurance>
158
+ </modules>
159
+ </translate>
160
+ <sales>
161
+ <order>
162
+ <create>
163
+ <available_product_types>
164
+ <auguria_insurance/>
165
+ </available_product_types>
166
+ </create>
167
+ </order>
168
+ </sales>
169
+ </adminhtml>
170
+
171
+ <default>
172
+ <auguria_insurance>
173
+ <general>
174
+ <active>1</active>
175
+ </general>
176
+ <cart>
177
+ <display_price>2</display_price>
178
+ </cart>
179
+ <sales>
180
+ <display_price>2</display_price>
181
+ </sales>
182
+ </auguria_insurance>
183
+ </default>
184
+
185
+ </config>
app/code/community/Auguria/Insurance/etc/system.xml ADDED
@@ -0,0 +1,81 @@
1
+ <!--
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Insurance
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+ -->
9
+ <config>
10
+ <sections>
11
+ <auguria_insurance translate="label" module="auguria_insurance">
12
+ <label>Insurance</label>
13
+ <tab>auguria</tab>
14
+ <header_css>auguria-header</header_css>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>1100</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>0</show_in_store>
20
+ <groups>
21
+ <general translate="label">
22
+ <label>General</label>
23
+ <frontend_type>text</frontend_type>
24
+ <sort_order>10</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>1</show_in_store>
28
+ <fields>
29
+ <active translate="label">
30
+ <label>Is active</label>
31
+ <frontend_type>select</frontend_type>
32
+ <source_model>adminhtml/system_config_source_yesno</source_model>
33
+ <sort_order>1</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ </active>
38
+ </fields>
39
+ </general>
40
+ <cart tanslate="label">
41
+ <label>Cart</label>
42
+ <frontend_type>text</frontend_type>
43
+ <sort_order>20</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>1</show_in_store>
47
+ <fields>
48
+ <display_price translate="label">
49
+ <label>Display prices</label>
50
+ <frontend_type>select</frontend_type>
51
+ <source_model>tax/system_config_source_tax_display_type</source_model>
52
+ <sort_order>10</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>1</show_in_store>
56
+ </display_price>
57
+ </fields>
58
+ </cart>
59
+ <sales tanslate="label">
60
+ <label>Orders, invoices, creditmemos</label>
61
+ <frontend_type>text</frontend_type>
62
+ <sort_order>30</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>1</show_in_store>
66
+ <fields>
67
+ <display_price translate="label">
68
+ <label>Display prices</label>
69
+ <frontend_type>select</frontend_type>
70
+ <source_model>tax/system_config_source_tax_display_type</source_model>
71
+ <sort_order>10</sort_order>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>1</show_in_website>
74
+ <show_in_store>1</show_in_store>
75
+ </display_price>
76
+ </fields>
77
+ </sales>
78
+ </groups>
79
+ </auguria_insurance>
80
+ </sections>
81
+ </config>
app/code/community/Auguria/Insurance/sql/auguria_insurance_setup/install-0.0.1.php ADDED
@@ -0,0 +1,129 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_ProductMatrix
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ /* @var $this Mage_Catalog_Model_Resource_Setup */
10
+
11
+ $entityTypeId = $this->getEntityTypeId('catalog_product');
12
+
13
+ # add price attribute for insurance product
14
+
15
+ /* @var $attribute array */
16
+ $attribute = $this->getAttribute($entityTypeId, 'price');
17
+
18
+ $applyTo = $attribute['apply_to']; // get existing apply to product type for attribute
19
+ $applyToAsArray = explode(',', $applyTo);
20
+
21
+ $applyToAsArray[] = Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID; // add insurance produc type
22
+ $applyToAsArray = array_unique($applyToAsArray); // prevent doublon
23
+ $applyTo = join(',', $applyToAsArray);
24
+
25
+ $this->updateAttribute($entityTypeId, 'price', 'apply_to', $applyTo); // update attribute
26
+
27
+ # add tax class id attribute for insurance product
28
+
29
+ /* @var $attribute Mage_Catalog_Model_Entity_Attribute */
30
+ $attribute = $this->getAttribute($entityTypeId, 'tax_class_id');
31
+
32
+ $applyTo = $attribute['apply_to']; // get existing apply to product type for attribute
33
+ $applyToAsArray = explode(',', $applyTo);
34
+
35
+ $applyToAsArray[] = Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID; // add insurance produc type
36
+ $applyToAsArray = array_unique($applyToAsArray); // prevent doublon
37
+ $applyTo = join(',', $applyToAsArray);
38
+
39
+ $this->updateAttribute($entityTypeId, 'tax_class_id', 'apply_to', $applyTo); // update attribute
40
+
41
+ # add group price id attribute for insurance product
42
+
43
+ /* @var $attribute Mage_Catalog_Model_Entity_Attribute */
44
+ $attribute = $this->getAttribute($entityTypeId, 'group_price');
45
+
46
+ $applyTo = $attribute['apply_to']; // get existing apply to product type for attribute
47
+ $applyToAsArray = explode(',', $applyTo);
48
+
49
+ $applyToAsArray[] = Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID; // add insurance produc type
50
+ $applyToAsArray = array_unique($applyToAsArray); // prevent doublon
51
+ $applyTo = join(',', $applyToAsArray);
52
+
53
+ $this->updateAttribute($entityTypeId, 'group_price', 'apply_to', $applyTo); // update attribute
54
+
55
+ # add special price id attribute for insurance product
56
+
57
+ /* @var $attribute Mage_Catalog_Model_Entity_Attribute */
58
+ $attribute = $this->getAttribute($entityTypeId, 'special_price');
59
+
60
+ $applyTo = $attribute['apply_to']; // get existing apply to product type for attribute
61
+ $applyToAsArray = explode(',', $applyTo);
62
+
63
+ $applyToAsArray[] = Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID; // add insurance produc type
64
+ $applyToAsArray = array_unique($applyToAsArray); // prevent doublon
65
+ $applyTo = join(',', $applyToAsArray);
66
+
67
+ $this->updateAttribute($entityTypeId, 'special_price', 'apply_to', $applyTo); // update attribute
68
+
69
+ # add special from date
70
+
71
+ $attribute = $this->getAttribute($entityTypeId, 'special_from_date');
72
+
73
+ $applyTo = $attribute['apply_to']; // get existing apply to product type for attribute
74
+ $applyToAsArray = explode(',', $applyTo);
75
+
76
+ $applyToAsArray[] = Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID; // add insurance produc type
77
+ $applyToAsArray = array_unique($applyToAsArray); // prevent doublon
78
+ $applyTo = join(',', $applyToAsArray);
79
+
80
+ $this->updateAttribute($entityTypeId, 'special_from_date', 'apply_to', $applyTo); // update attribute
81
+
82
+ # add special to date
83
+
84
+ $attribute = $this->getAttribute($entityTypeId, 'special_to_date');
85
+
86
+ $applyTo = $attribute['apply_to']; // get existing apply to product type for attribute
87
+ $applyToAsArray = explode(',', $applyTo);
88
+
89
+ $applyToAsArray[] = Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID; // add insurance produc type
90
+ $applyToAsArray = array_unique($applyToAsArray); // prevent doublon
91
+ $applyTo = join(',', $applyToAsArray);
92
+
93
+ $this->updateAttribute($entityTypeId, 'special_to_date', 'apply_to', $applyTo); // update attribute
94
+
95
+ # add insurance group for each existing attribute set
96
+
97
+ $groupLabel = 'Insurance';
98
+
99
+ $attributeSets = $this->_conn->fetchAll('select * from '.$this->getTable('eav/attribute_set').' where entity_type_id=?', $entityTypeId);
100
+ foreach ($attributeSets as $attributeSet) {
101
+ $setId = $attributeSet['attribute_set_id'];
102
+ $this->addAttributeGroup($entityTypeId, $setId, $groupLabel);
103
+ }
104
+
105
+ # add auguria_insurance_is_default attribute for insurance product
106
+
107
+ // only for insurance products
108
+ $productTypes = array(
109
+ Auguria_Insurance_Model_Catalog_Product_Type_Insurance::AUGURIA_INSURANCE_PRODUCT_TYPE_ID
110
+ );
111
+ $productTypes = join(',', $productTypes);
112
+
113
+ // auguria_insurance_is_default : define if the insurance is added by default in cart
114
+ $this->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'auguria_insurance_is_default', array(
115
+ 'group' => $groupLabel,
116
+ 'backend' => 'catalog/product_attribute_backend_boolean',
117
+ 'frontend' => '',
118
+ 'label' => 'Insurance is added by default in cart',
119
+ 'input' => 'select',
120
+ 'source' => 'eav/entity_attribute_source_boolean',
121
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
122
+ 'visible' => true,
123
+ 'required' => false,
124
+ 'user_defined' => false,
125
+ 'default' => '',
126
+ 'apply_to' => $productTypes,
127
+ 'visible_on_front' => false,
128
+ 'used_in_product_listing' => true
129
+ ));
app/design/adminhtml/default/default/layout/auguria/core.xml ADDED
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Auguria
5
+ * @package Auguria_Core
6
+ * @author Auguria
7
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
8
+ */
9
+ -->
10
+
11
+ <layout>
12
+
13
+ <default>
14
+ <reference name="head">
15
+ <action method="addCss"><link>auguria/core.css</link></action>
16
+ </reference>
17
+ </default>
18
+
19
+ </layout>
app/design/adminhtml/default/default/template/auguria/insurance/checkout/cart/total/insurance.phtml ADDED
@@ -0,0 +1,23 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Insurance
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ /* @var $this Auguria_Insurance_Block_Checkout_Cart_Total_Insurance */
10
+ ?>
11
+ <?php
12
+ foreach($this->getInsurances() as $_insurance):
13
+ /* @var $_insurance Mage_Sales_Model_Quote_Item */
14
+ ?>
15
+ <tr>
16
+ <td colspan="<?php echo $this->getColspan(); ?>" <?php echo $this->getAdditionnalAttributes()?> style="<?php echo $this->getTotal()->getStyle() . $this->getAdditionnalStyles() ?>" class="a-right">
17
+ <?php echo $_insurance->getName() . ' ' . $this->__('(included in total amount)') ?>
18
+ </td>
19
+ <td <?php echo $this->getAdditionnalAttributes()?> style="<?php echo $this->getTotal()->getStyle() . $this->getAdditionnalStyles()?>" class="a-right">
20
+ <?php echo $this->getFormatedPrice($_insurance)?>
21
+ </td>
22
+ </tr>
23
+ <?php endforeach;?>
app/design/adminhtml/default/default/template/auguria/insurance/sales/order/total/insurance.phtml ADDED
@@ -0,0 +1,22 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Insurance
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ /* @var $this Auguria_Insurance_Block_Sales_Order_Total_Insurance */
10
+ ?>
11
+ <?php
12
+ foreach($this->getInsurances() as $_insurance):
13
+ ?>
14
+ <tr>
15
+ <td colspan="<?php echo $this->getColspan(); ?>" <?php echo $this->getAdditionnalAttributes()?> style="<?php echo $this->getTotal()->getStyle() . $this->getAdditionnalStyles() ?>" class="a-right">
16
+ <?php echo $_insurance->getName() . ' ' . $this->__('(included in total amount)') ?>
17
+ </td>
18
+ <td <?php echo $this->getAdditionnalAttributes()?> style="<?php echo $this->getTotal()->getStyle() . $this->getAdditionnalStyles()?>" class="a-right">
19
+ <?php echo $this->getFormatedPrice($_insurance)?>
20
+ </td>
21
+ </tr>
22
+ <?php endforeach;?>
app/design/frontend/base/default/layout/auguria/insurance.xml ADDED
@@ -0,0 +1,338 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Auguria
5
+ * @package Auguria_Insurance
6
+ * @author Auguria
7
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
8
+ */
9
+ -->
10
+ <layout version="0.1.0">
11
+
12
+ <default>
13
+ <reference name="cart_sidebar">
14
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>checkout/cart_item_renderer</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
15
+ </reference>
16
+ </default>
17
+
18
+ <!-- Catalog -->
19
+
20
+ <PRODUCT_TYPE_auguria_insurance translate="label">
21
+ <label>Catalog Product View (Insurance)</label>
22
+ <reference name="product.info">
23
+ <block type="catalog/product_view_type_simple" name="product.info.simple" as="product_type_data" template="catalog/product/view/type/default.phtml">
24
+ <block type="core/text_list" name="product.info.simple.extra" as="product_type_data_extra" translate="label">
25
+ <label>Product Extra Info</label>
26
+ </block>
27
+ </block>
28
+ </reference>
29
+ </PRODUCT_TYPE_auguria_insurance>
30
+
31
+ <!-- Checkout -->
32
+
33
+ <checkout_cart_index>
34
+ <reference name="head">
35
+ <action ifconfig="auguria_insurance/general/active" method="addCss"><link>css/auguria/insurance/style.css</link></action>
36
+ </reference>
37
+
38
+ <reference name="checkout.cart">
39
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>checkout/cart_item_renderer</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
40
+ </reference>
41
+
42
+ <block type="auguria_insurance/checkout_insurance" name="auguria_insurance" template="auguria/insurance/checkout/insurance.phtml" />
43
+
44
+ <reference name="content">
45
+ <action ifconfig="auguria_insurance/general/active" method="append"><block>auguria_insurance</block></action>
46
+ </reference>
47
+ </checkout_cart_index>
48
+
49
+ <checkout_onepage_review>
50
+ <reference name="root">
51
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>checkout/cart_item_renderer</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
52
+ </reference>
53
+ </checkout_onepage_review>
54
+
55
+ <!-- Multishipping -->
56
+
57
+ <checkout_multishipping_addresses>
58
+ <reference name="checkout_addresses">
59
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>checkout/cart_item_renderer</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
60
+ </reference>
61
+ </checkout_multishipping_addresses>
62
+
63
+ <checkout_multishipping_shipping>
64
+ <reference name="checkout_shipping">
65
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>checkout/cart_item_renderer</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
66
+ </reference>
67
+ <reference name="checkout_billing_items">
68
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>checkout/cart_item_renderer</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
69
+ </reference>
70
+ </checkout_multishipping_shipping>
71
+
72
+ <checkout_multishipping_overview>
73
+ <reference name="checkout_overview">
74
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>checkout/cart_item_renderer</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
75
+ </reference>
76
+ </checkout_multishipping_overview>
77
+
78
+ <!-- Paypal -->
79
+
80
+ <paypal_express_review>
81
+ <reference name="paypal.express.review.details">
82
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>checkout/cart_item_renderer</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
83
+ </reference>
84
+ </paypal_express_review>
85
+
86
+ <paypal_express_review_details>
87
+ <reference name="root">
88
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>checkout/cart_item_renderer</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
89
+ </reference>
90
+ </paypal_express_review_details>
91
+
92
+ <paypaluk_express_review>
93
+ <reference name="paypal.express.review.details">
94
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>checkout/cart_item_renderer</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
95
+ </reference>
96
+ </paypaluk_express_review>
97
+
98
+ <paypaluk_express_review_details>
99
+ <reference name="root">
100
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>checkout/cart_item_renderer</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
101
+ </reference>
102
+ </paypaluk_express_review_details>
103
+
104
+ <!-- Sales -->
105
+
106
+ <sales_order_view>
107
+ <reference name="order_items">
108
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>sales/order_item_renderer_default</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
109
+ </reference>
110
+
111
+ <block type="auguria_insurance/sales_order_total_insurance" name="auguria_insurance.sales.order.totals.insurance" template="auguria/insurance/checkout/cart/total/insurance.phtml" />
112
+
113
+ <reference name="order_totals">
114
+ <action ifconfig="auguria_insurance/general/active" method="append"><block>auguria_insurance.sales.order.totals.insurance</block></action>
115
+ </reference>
116
+
117
+ <reference name="invoice_totals">
118
+ <block type="auguria_insurance/sales_order_total_insurance" name="auguria_insurance.sales.order.totals.insurance" template="auguria/insurance/checkout/cart/total/insurance.phtml" />
119
+ </reference>
120
+ </sales_order_view>
121
+
122
+ <sales_order_invoice>
123
+ <reference name="invoice_items">
124
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>sales/order_item_renderer_default</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
125
+ </reference>
126
+
127
+ <block type="auguria_insurance/sales_order_total_insurance" name="auguria_insurance.sales.order.totals.insurance" template="auguria/insurance/checkout/cart/total/insurance.phtml" />
128
+
129
+ <reference name="invoice_totals">
130
+ <action ifconfig="auguria_insurance/general/active" method="append"><block>auguria_insurance.sales.order.totals.insurance</block></action>
131
+ </reference>
132
+ </sales_order_invoice>
133
+
134
+ <sales_order_shipment>
135
+ <reference name="shipment_items">
136
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>sales/order_item_renderer_default</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
137
+ </reference>
138
+ </sales_order_shipment>
139
+
140
+ <sales_order_creditmemo>
141
+ <reference name="creditmemo_items">
142
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>sales/order_item_renderer_default</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
143
+ </reference>
144
+
145
+ <block type="auguria_insurance/sales_order_total_insurance" name="auguria_insurance.sales.order.totals.insurance" template="auguria/insurance/checkout/cart/total/insurance.phtml" />
146
+
147
+ <reference name="creditmemo_totals">
148
+ <action ifconfig="auguria_insurance/general/active" method="append"><block>auguria_insurance.sales.order.totals.insurance</block></action>
149
+ </reference>
150
+ </sales_order_creditmemo>
151
+
152
+ <!-- Print -->
153
+
154
+ <sales_order_print>
155
+ <reference name="sales.order.print">
156
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>sales/order_item_renderer_default</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
157
+ </reference>
158
+
159
+ <block type="auguria_insurance/sales_order_total_insurance" name="auguria_insurance.sales.order.totals.insurance" template="auguria/insurance/checkout/cart/total/insurance.phtml" />
160
+
161
+ <reference name="order_totals">
162
+ <action ifconfig="auguria_insurance/general/active" method="append"><block>auguria_insurance.sales.order.totals.insurance</block></action>
163
+ </reference>
164
+ </sales_order_print>
165
+
166
+ <sales_order_printinvoice>
167
+ <reference name="sales.order.print.invoice">
168
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>sales/order_item_renderer_default</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
169
+ </reference>
170
+
171
+ <block type="auguria_insurance/sales_order_total_insurance" name="auguria_insurance.sales.order.totals.insurance" template="auguria/insurance/checkout/cart/total/insurance.phtml" />
172
+
173
+ <reference name="invoice_totals">
174
+ <action ifconfig="auguria_insurance/general/active" method="append"><block>auguria_insurance.sales.order.totals.insurance</block></action>
175
+ </reference>
176
+ </sales_order_printinvoice>
177
+
178
+ <sales_order_printshipment>
179
+ <reference name="sales.order.print.shipment">
180
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>sales/order_item_renderer_default</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
181
+ </reference>
182
+ </sales_order_printshipment>
183
+
184
+ <sales_order_printcreditmemo>
185
+ <reference name="sales.order.print.creditmemo">
186
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>sales/order_item_renderer_default</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
187
+ </reference>
188
+
189
+ <block type="auguria_insurance/sales_order_total_insurance" name="auguria_insurance.sales.order.totals.insurance" template="auguria/insurance/checkout/cart/total/insurance.phtml" />
190
+
191
+ <reference name="creditmemo_totals">
192
+ <action ifconfig="auguria_insurance/general/active" method="append"><block>auguria_insurance.sales.order.totals.insurance</block></action>
193
+ </reference>
194
+ </sales_order_printcreditmemo>
195
+
196
+ <!-- Guest -->
197
+
198
+ <sales_guest_view>
199
+ <reference name="order_items">
200
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>sales/order_item_renderer_default</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
201
+ </reference>
202
+
203
+ <block type="auguria_insurance/sales_order_total_insurance" name="auguria_insurance.sales.order.totals.insurance" template="auguria/insurance/checkout/cart/total/insurance.phtml" />
204
+
205
+ <reference name="order_totals">
206
+ <action ifconfig="auguria_insurance/general/active" method="append"><block>auguria_insurance.sales.order.totals.insurance</block></action>
207
+ </reference>
208
+ </sales_guest_view>
209
+
210
+ <sales_guest_invoice>
211
+ <reference name="invoice_items">
212
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>sales/order_item_renderer_default</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
213
+ </reference>
214
+
215
+ <block type="auguria_insurance/sales_order_total_insurance" name="auguria_insurance.sales.order.totals.insurance" template="auguria/insurance/checkout/cart/total/insurance.phtml" />
216
+
217
+ <reference name="invoice_totals">
218
+ <action ifconfig="auguria_insurance/general/active" method="append"><block>auguria_insurance.sales.order.totals.insurance</block></action>
219
+ </reference>
220
+ </sales_guest_invoice>
221
+
222
+ <sales_guest_shipment>
223
+ <reference name="shipment_items">
224
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>sales/order_item_renderer_default</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
225
+ </reference>
226
+ </sales_guest_shipment>
227
+
228
+ <sales_guest_creditmemo>
229
+ <reference name="creditmemo_items">
230
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>sales/order_item_renderer_default</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
231
+ </reference>
232
+
233
+ <block type="auguria_insurance/sales_order_total_insurance" name="auguria_insurance.sales.order.totals.insurance" template="auguria/insurance/checkout/cart/total/insurance.phtml" />
234
+
235
+ <reference name="creditmemo_totals">
236
+ <action ifconfig="auguria_insurance/general/active" method="append"><block>auguria_insurance.sales.order.totals.insurance</block></action>
237
+ </reference>
238
+ </sales_guest_creditmemo>
239
+
240
+ <sales_guest_print>
241
+ <reference name="sales.order.print">
242
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>sales/order_item_renderer_default</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
243
+ </reference>
244
+
245
+ <block type="auguria_insurance/sales_order_total_insurance" name="auguria_insurance.sales.order.totals.insurance" template="auguria/insurance/checkout/cart/total/insurance.phtml" />
246
+
247
+ <reference name="order_totals">
248
+ <action ifconfig="auguria_insurance/general/active" method="append"><block>auguria_insurance.sales.order.totals.insurance</block></action>
249
+ </reference>
250
+ </sales_guest_print>
251
+
252
+ <sales_guest_printinvoice>
253
+ <reference name="sales.order.print.invoice">
254
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>sales/order_item_renderer_default</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
255
+ </reference>
256
+
257
+ <block type="auguria_insurance/sales_order_total_insurance" name="auguria_insurance.sales.order.totals.insurance" template="auguria/insurance/checkout/cart/total/insurance.phtml" />
258
+
259
+ <reference name="invoice_totals">
260
+ <action ifconfig="auguria_insurance/general/active" method="append"><block>auguria_insurance.sales.order.totals.insurance</block></action>
261
+ </reference>
262
+ </sales_guest_printinvoice>
263
+
264
+ <sales_guest_printshipment>
265
+ <reference name="sales.order.print.shipment">
266
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>sales/order_item_renderer_default</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
267
+ </reference>
268
+ </sales_guest_printshipment>
269
+
270
+ <sales_guest_printcreditmemo>
271
+ <reference name="sales.order.print.creditmemo">
272
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>sales/order_item_renderer_default</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
273
+ </reference>
274
+
275
+ <block type="auguria_insurance/sales_order_total_insurance" name="auguria_insurance.sales.order.totals.insurance" template="auguria/insurance/checkout/cart/total/insurance.phtml" />
276
+
277
+ <reference name="creditmemo_totals">
278
+ <action ifconfig="auguria_insurance/general/active" method="append"><block>auguria_insurance.sales.order.totals.insurance</block></action>
279
+ </reference>
280
+ </sales_guest_printcreditmemo>
281
+
282
+ <!-- Emails -->
283
+
284
+ <sales_email_order_items>
285
+ <reference name="items">
286
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>sales/order_item_renderer_default</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
287
+ </reference>
288
+
289
+ <block type="auguria_insurance/sales_order_total_insurance" name="auguria_insurance.sales.order.totals.insurance" template="auguria/insurance/checkout/cart/total/insurance.phtml">
290
+ <action method="setColspan"><code>default</code><number>3</number></action>
291
+ <action method="setAdditionnalAttributes"><attributes>align="right"</attributes></action>
292
+ <action method="setAdditionnalStyles"><attributes>padding:3px 9px</attributes></action>
293
+ </block>
294
+
295
+ <reference name="order_totals">
296
+ <action ifconfig="auguria_insurance/general/active" method="append"><block>auguria_insurance.sales.order.totals.insurance</block></action>
297
+ </reference>
298
+ </sales_email_order_items>
299
+
300
+ <sales_email_order_invoice_items>
301
+ <reference name="items">
302
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>sales/order_item_renderer_default</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
303
+ </reference>
304
+
305
+ <block type="auguria_insurance/sales_order_total_insurance" name="auguria_insurance.sales.order.totals.insurance" template="auguria/insurance/checkout/cart/total/insurance.phtml">
306
+ <action method="setColspan"><code>default</code><number>3</number></action>
307
+ <action method="setAdditionnalAttributes"><attributes>align="right"</attributes></action>
308
+ <action method="setAdditionnalStyles"><attributes>padding:3px 9px</attributes></action>
309
+ </block>
310
+
311
+ <reference name="invoice_totals">
312
+ <action ifconfig="auguria_insurance/general/active" method="append"><block>auguria_insurance.sales.order.totals.insurance</block></action>
313
+ </reference>
314
+ </sales_email_order_invoice_items>
315
+
316
+ <sales_email_order_shipment_items>
317
+ <reference name="items">
318
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>sales/order_item_renderer_default</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
319
+ </reference>
320
+ </sales_email_order_shipment_items>
321
+
322
+ <sales_email_order_creditmemo_items>
323
+ <reference name="items">
324
+ <action ifconfig="auguria_insurance/general/active" method="addItemRender"><type>auguria_insurance</type><block>sales/order_item_renderer_default</block><template>auguria/insurance/checkout/cart/item/insurance.phtml</template></action>
325
+ </reference>
326
+
327
+ <block type="auguria_insurance/sales_order_total_insurance" name="auguria_insurance.sales.order.totals.insurance" template="auguria/insurance/checkout/cart/total/insurance.phtml">
328
+ <action method="setColspan"><code>creditmemo</code><number>3</number></action>
329
+ <action method="setAdditionnalAttributes"><attributes>align="right"</attributes></action>
330
+ <action method="setAdditionnalStyles"><attributes>padding:3px 9px</attributes></action>
331
+ </block>
332
+
333
+ <reference name="creditmemo_totals">
334
+ <action ifconfig="auguria_insurance/general/active" method="append"><block>auguria_insurance.sales.order.totals.insurance</block></action>
335
+ </reference>
336
+ </sales_email_order_creditmemo_items>
337
+
338
+ </layout>
app/design/frontend/base/default/template/auguria/insurance/checkout/cart/item/insurance.phtml ADDED
@@ -0,0 +1,11 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Insurance
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+ ?>
9
+ <?php
10
+ // no display for item cart
11
+ ?>
app/design/frontend/base/default/template/auguria/insurance/checkout/cart/total/insurance.phtml ADDED
@@ -0,0 +1,23 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Insurance
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ /* @var $this Auguria_Insurance_Block_Checkout_Cart_Total_Insurance */
10
+ ?>
11
+ <?php
12
+ foreach($this->getInsurances() as $_insurance):
13
+ /* @var $_insurance Mage_Sales_Model_Quote_Item */
14
+ ?>
15
+ <tr>
16
+ <td colspan="<?php echo $this->getColspan(); ?>" <?php echo $this->getAdditionnalAttributes()?> style="<?php echo $this->getTotal()->getStyle() . $this->getAdditionnalStyles() ?>" class="a-right">
17
+ <?php echo $_insurance->getName() . ' ' . $this->__('(included in total amount)') ?>
18
+ </td>
19
+ <td <?php echo $this->getAdditionnalAttributes()?> style="<?php echo $this->getTotal()->getStyle() . $this->getAdditionnalStyles()?>" class="a-right">
20
+ <?php echo $this->getFormatedPrice($_insurance)?>
21
+ </td>
22
+ </tr>
23
+ <?php endforeach;?>
app/design/frontend/base/default/template/auguria/insurance/checkout/insurance.phtml ADDED
@@ -0,0 +1,65 @@
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Insurance
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ /* @var $this Auguria_Insurance_Block_Checkout_Insurance */
10
+ ?>
11
+ <?php if($this->isNotEmptyCart()):?>
12
+
13
+ <?php
14
+ /* @var $insurances Mage_Catalog_Model_Resource_Product_Collection */
15
+ $insurances = $this->getInsurances();
16
+ ?>
17
+
18
+ <?php
19
+ if($insurances->getSize()):
20
+ ?>
21
+ <div class="insurances">
22
+ <?php
23
+ foreach($insurances as $_insurance):
24
+ /* @var $_insurance Mage_Catalog_Model_Product */
25
+ $insuranceIsInCart = $this->isInsuranceInCart($_insurance);
26
+ ?>
27
+ <div class="insurance">
28
+ <form id="form-insurance-<?php echo $_insurance->getId()?>" class="form" action="<?php echo Mage::getUrl('auguria_insurance/index/updateInsurance')?>" method="post">
29
+ <label for="insurance-<?php echo $_insurance->getId()?>">
30
+ <?php echo $_insurance->getName()?>
31
+ <?php echo $this->getPriceHtml($_insurance)?>
32
+ </label>
33
+ <input type="checkbox" id="insurance-<?php echo $_insurance->getId()?>" name="insurance" value="1" <?php echo $insuranceIsInCart ? 'checked="checked"' : '' ?>>
34
+ <input type="hidden" name="is_in_cart" value="<?php echo $insuranceIsInCart ? '1' : '0' ?>">
35
+ <input type="hidden" name="insurance_id" value="<?php echo $_insurance->getId() ?>">
36
+ </form>
37
+
38
+ <div class="clearer"></div>
39
+
40
+ <div class="description">
41
+ <?php echo $_insurance->getShortDescription()?>
42
+ </div>
43
+ </div>
44
+ <?php
45
+ endforeach;
46
+ ?>
47
+ </div>
48
+
49