SKYBOZ456 - Version 1.2.11

Version Notes

Skybox Checkout enables a Magento ecommerce site to sell instantly to 180 countries & territories and accept payment in 140 local currencies. SkyBOX Checkout is a combination of technology tools & services to help retailers expand overseas while offering a localized full landed cost calculation to international shoppers. SkyBOX Checkout takes on full risk of fraud screening & international payments while providing competitive international shipping with full tracking via its proprietary logistics network.

Download this release

Release Info

Developer Emilio Lizarraga
Extension SKYBOZ456
Version 1.2.11
Comparing to
See all releases


Code changes from version 1.2.10 to 1.2.11

Files changed (104) hide show
  1. app/code/community/Skybox/Catalog/Block/Bundle/Price.php +149 -149
  2. app/code/community/Skybox/Catalog/Block/Catalog/Category/Tab/Skyboxcheckout.php +125 -125
  3. app/code/community/Skybox/Catalog/Block/Product/List.php +184 -184
  4. app/code/community/Skybox/Catalog/Block/Product/Price.php +256 -256
  5. app/code/community/Skybox/Catalog/Block/Product/Widget/New.php +202 -202
  6. app/code/community/Skybox/Catalog/Model/Api/Product.php +940 -940
  7. app/code/community/Skybox/Catalog/Model/Observer.php +270 -270
  8. app/code/community/Skybox/Catalog/Model/Product/Attribute/Source/Categories.php +38 -38
  9. app/code/community/Skybox/Catalog/Model/Product/Type/Price.php +64 -64
  10. app/code/community/Skybox/Catalog/Model/Resource/Setup.php +11 -11
  11. app/code/community/Skybox/Catalog/etc/config.xml +1 -1
  12. app/code/community/Skybox/Catalog/sql/skyboxcatalog_setup/mysql4-install-0.1.0.php +70 -70
  13. app/code/community/Skybox/Checkout/Block/Cart/Item/Renderer.php +11 -11
  14. app/code/community/Skybox/Checkout/Block/Cart/Sidebar.php +32 -32
  15. app/code/community/Skybox/Checkout/Block/Cart/Totals.php +157 -157
  16. app/code/community/Skybox/Checkout/Block/Checkout/Cart.php +45 -45
  17. app/code/community/Skybox/Checkout/Block/Checkout/Cart/Sidebar.php +30 -16
  18. app/code/community/Skybox/Checkout/Block/Checkout/Links.php +26 -26
  19. app/code/community/Skybox/Checkout/Block/Checkout/Onepage/Link.php +43 -43
  20. app/code/community/Skybox/Checkout/Block/Sales/Order/Total.php +92 -71
  21. app/code/community/Skybox/Checkout/Helper/Data.php +156 -156
  22. app/code/community/Skybox/Checkout/Helper/Url.php +58 -58
  23. app/code/community/Skybox/Checkout/Model/Api/Checkout.php +222 -222
  24. app/code/community/Skybox/Checkout/Model/Carrier.php +36 -36
  25. app/code/community/Skybox/Checkout/Model/Cart.php +717 -717
  26. app/code/community/Skybox/Checkout/Model/Creditmemo/Total.php +17 -17
  27. app/code/community/Skybox/Checkout/Model/Invoice/Total.php +18 -18
  28. app/code/community/Skybox/Checkout/Model/Observer.php +328 -328
  29. app/code/community/Skybox/Checkout/Model/Pay.php +11 -11
  30. app/code/community/Skybox/Checkout/Model/Quote/Address/Total/Rmt.php +112 -112
  31. app/code/community/Skybox/Checkout/Model/Quote/Address/Total/Tax.php +5 -5
  32. app/code/community/Skybox/Checkout/Model/Quote/Item.php +68 -68
  33. app/code/community/Skybox/Checkout/Model/Quote/SubTotal.php +136 -136
  34. app/code/community/Skybox/Checkout/Model/Quote/Total.php +304 -304
  35. app/code/community/Skybox/Checkout/Model/Quote/Total10.php +7 -0
  36. app/code/community/Skybox/Checkout/Model/Quote/Total11.php +7 -0
  37. app/code/community/Skybox/Checkout/Model/Quote/Total12.php +7 -0
  38. app/code/community/Skybox/Checkout/Model/Quote/Total13.php +7 -0
  39. app/code/community/Skybox/Checkout/Model/Quote/Total14.php +7 -0
  40. app/code/community/Skybox/Checkout/Model/Quote/Total15.php +7 -0
  41. app/code/community/Skybox/Checkout/Model/Quote/Total2.php +7 -7
  42. app/code/community/Skybox/Checkout/Model/Quote/Total3.php +6 -6
  43. app/code/community/Skybox/Checkout/Model/Quote/Total4.php +6 -6
  44. app/code/community/Skybox/Checkout/Model/Quote/Total5.php +6 -6
  45. app/code/community/Skybox/Checkout/Model/Quote/Total6.php +6 -6
  46. app/code/community/Skybox/Checkout/Model/Quote/Total7.php +6 -6
  47. app/code/community/Skybox/Checkout/Model/Quote/Total8.php +7 -7
  48. app/code/community/Skybox/Checkout/Model/Quote/Total9.php +7 -0
  49. app/code/community/Skybox/Checkout/controllers/CalculateController.php +138 -138
  50. app/code/community/Skybox/Checkout/controllers/InternationalController.php +89 -89
  51. app/code/community/Skybox/Checkout/controllers/ProcessController.php +354 -364
  52. app/code/community/Skybox/Checkout/etc/config.xml +75 -40
  53. app/code/community/Skybox/Checkout/etc/system.xml +127 -127
  54. app/code/community/Skybox/Checkout/sql/skyboxcheckout_setup/mysql4-install-0.1.0.php +132 -132
  55. app/code/community/Skybox/Checkout/sql/skyboxcheckout_setup/mysql4-upgrade-0.1.0-0.1.1.php +68 -68
  56. app/code/community/Skybox/Checkout/sql/skyboxcheckout_setup/mysql4-upgrade-0.1.0-0.1.2.php +16 -16
  57. app/code/community/Skybox/Checkout/sql/skyboxcheckout_setup/mysql4-upgrade-1.2.5-1.2.5.2.php +138 -138
  58. app/code/community/Skybox/Checkout/sql/skyboxcheckout_setup/mysql4-upgrade-1.2.5.2-1.2.6.php +138 -138
  59. app/code/community/Skybox/Core/Exception.php +19 -19
  60. app/code/community/Skybox/Core/Helper/Allow.php +236 -236
  61. app/code/community/Skybox/Core/Helper/Data.php +11 -11
  62. app/code/community/Skybox/Core/Helper/Email.php +52 -52
  63. app/code/community/Skybox/Core/Model/Api/Abstract.php +440 -440
  64. app/code/community/Skybox/Core/Model/Api/Restful.php +365 -365
  65. app/code/community/Skybox/Core/Model/Config.php +251 -251
  66. app/code/community/Skybox/Core/Model/Logservice.php +16 -16
  67. app/code/community/Skybox/Core/Model/Mysql4.php +16 -16
  68. app/code/community/Skybox/Core/Model/Mysql4/Logservice.php +22 -22
  69. app/code/community/Skybox/Core/Model/Mysql4/Logservice/Collection.php +17 -17
  70. app/code/community/Skybox/Core/Model/Session.php +29 -29
  71. app/code/community/Skybox/Core/Model/Standard.php +292 -292
  72. app/code/community/Skybox/Core/etc/config.xml +1 -1
  73. app/code/community/Skybox/Core/sql/skyboxcore_setup/mysql4-install-0.1.0.php +67 -67
  74. app/code/community/Skybox/International/Helper/Data.php +77 -77
  75. app/code/community/Skybox/International/Model/Config.php +15 -15
  76. app/code/community/Skybox/International/Model/StoreType.php +12 -12
  77. app/code/community/Skybox/International/etc/adminhtml.xml +39 -39
  78. app/code/community/Skybox/International/etc/config.xml +1 -1
  79. app/code/community/Skybox/International/etc/system.xml +135 -135
  80. app/code/community/Skybox/Services/Model/Api.php +354 -310
  81. app/code/community/Skybox/Services/Model/Api/V2.php +11 -11
  82. app/code/community/Skybox/Services/etc/api.xml +37 -37
  83. app/code/community/Skybox/Services/etc/config.xml +1 -1
  84. app/code/community/Skybox/Services/etc/wsdl.xml +141 -141
  85. app/code/community/Skybox/Services/etc/wsi.xml +159 -159
  86. app/design/adminhtml/default/default/layout/skyboxcatalog.xml +7 -7
  87. app/design/adminhtml/default/default/layout/skyboxinternational.xml +14 -14
  88. app/design/frontend/base/default/layout/skyboxcheckout.xml +204 -204
  89. app/design/frontend/base/default/template/skybox/checkout/cart.phtml +157 -177
  90. app/design/frontend/base/default/template/skybox/checkout/cart/item/default.phtml +294 -294
  91. app/design/frontend/base/default/template/skybox/checkout/cart/shipping.phtml +11 -11
  92. app/design/frontend/base/default/template/skybox/checkout/cart/sidebar.phtml +80 -80
  93. app/design/frontend/base/default/template/skybox/checkout/cart/sidebar/default.phtml +146 -146
  94. app/design/frontend/base/default/template/skybox/checkout/cart_list.phtml +195 -195
  95. app/design/frontend/base/default/template/skybox/checkout/multishipping/link.phtml +8 -8
  96. app/design/frontend/base/default/template/skybox/checkout/onepage.phtml +3 -3
  97. app/design/frontend/base/default/template/skybox/checkout/onepage/link.phtml +37 -37
  98. app/design/frontend/base/default/template/skybox/checkout/pagecheckout.phtml +31 -31
  99. app/design/frontend/base/default/template/skybox/checkout/skyboxcheckout.phtml +222 -358
  100. app/design/frontend/base/default/template/skybox/checkout/skyboxsuccess.phtml +59 -29
  101. app/etc/modules/Skybox_All.xml +37 -37
  102. js/skybox/adminhtml.category.js +10 -10
  103. js/skybox/jquery.ba-resize.min.js +8 -8
  104. js/skybox/jquery.fancybox.js +1601 -2019
app/code/community/Skybox/Catalog/Block/Bundle/Price.php CHANGED
@@ -1,150 +1,150 @@
1
- <?php
2
- /**
3
- * Skybox Checkout
4
- *
5
- * @category Mage
6
- * @package Skybox_Catalog
7
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
8
- */
9
-
10
- /**
11
- * Bundle product price block
12
- *
13
- * @category Skybox
14
- * @package Skybox_Catalog
15
- */
16
- class Skybox_Catalog_Block_Bundle_Price extends Mage_Bundle_Block_Catalog_Product_Price
17
- {
18
- /*
19
- * @var string $_cache_code
20
- */
21
- public $_cache_code = null;
22
-
23
- public function getCacheCode()
24
- {
25
- if ($this->_cache_code == null) {
26
- /* @var $config Skybox_Core_Model_Config */
27
- $config = Mage::getModel("skyboxcore/config");
28
- $skyboxUser = $config->getSession()->getSkyboxUser();
29
- $cache_code = $skyboxUser->CartCountryISOCode . $skyboxUser->CartCityId . $skyboxUser->CartCurrencyISOCode;
30
- $this->_cache_code = $cache_code;
31
- }
32
- Mage::log("[bundle/price] Cache Code: " . $cache_code, null, 'cache.log', true);
33
- return $this->_cache_code;
34
- }
35
-
36
- /*
37
- protected function _construct()
38
- {
39
- //parent::__construct();
40
- $this->addData(array(
41
- 'cache_lifetime' => 120 //seconds
42
- ));
43
- }
44
- */
45
-
46
- public function getCacheKey()
47
- {
48
- $cache_key = "B_PRODUCT_" . $this->getProduct()->getId() . "_" . $this->getCacheCode();
49
- return $cache_key;
50
- }
51
-
52
- public function getCacheTags()
53
- {
54
- $cache_tag = $this->getProduct()->getId() . "_B_" . $this->getCacheCode();
55
- return array(Mage_Catalog_Model_Product::CACHE_TAG . $cache_tag);
56
- }
57
-
58
- /**
59
- * Retrieve API Product
60
- *
61
- * @return Skybox_Catalog_Model_Api_Product
62
- */
63
- protected function _getApi()
64
- {
65
- if (null === $this->_api) {
66
- $this->_api = Mage::getModel('skyboxcatalog/api_product');
67
- }
68
- return $this->_api;
69
- }
70
-
71
- /**
72
- * Convert block to html string
73
- *
74
- * @return string
75
- */
76
- public function _toHtml()
77
- {
78
- //return parent::_toHtml();
79
- Mage::log("CatalogBlockPrice__toHtmlbundle ", null, 'orden.log', true);
80
- if ($this->_getApi()->getErrorAuthenticate() && !$this->_getApi()->getLocationAllow() && $this->_getApi()->HasError()) {
81
- return '';
82
- } elseif ($this->_getApi()->HasError()) {
83
- //$error_code = $this->_getApi()->getStatusCode();
84
- $message = $this->_getApi()->getStatusMessage();
85
- //return '<div style="color:#FF0000;">' . $message . '</div>';
86
- Mage::log("[bundle/price] Some parameter doesn't given to Calculate Price: " . $this->_getApi()->getStatusMessage(), null, 'skyboxcheckout.log', true);
87
- }
88
-
89
- /* @var $product Mage_Catalog_Model_Product */
90
- $product = $this->getProduct();
91
- $type = $product->getTypeId();
92
- $route_name = Mage::app()->getRequest()->getRouteName();
93
- //Mage::log("ROUTER; ". $route_name, null, 'cart.log', true);
94
-
95
- if ($type == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE && $this->getTemplate() == 'bundle/catalog/product/price.phtml') {
96
- if ($route_name == 'catalog') {
97
- return $this->calculatePrice($product);
98
- }
99
-
100
- // Note: we can't get the "Final Price".
101
- // Moreover, we show "From XXX to XXX" price Block.
102
- //return parent::_toHtml();
103
-
104
- // Note: We make a product type: 'bundle_fixed' to calculate Price and Weight dynamically
105
- return $this->calculatePrice($product, 'bundle_fixed');
106
- }
107
- }
108
-
109
- /**
110
- * Calculate Price HTML output
111
- *
112
- * @param Mage_Catalog_Model_Product $product
113
- * @return string
114
- */
115
- protected function calculatePrice($product, $bundleType = 'bundle')
116
- {
117
- //Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter calculatePrice', null, 'tracer.log', true);
118
- $stockItem = $product->getStockItem();
119
- if (!$stockItem->getIsInStock()) {
120
- return ''; // Out of Stock
121
- }
122
-
123
- $finalPrice = $product->getFinalPrice();
124
- $finalPrice = ($finalPrice > 0) ? $finalPrice : null;
125
-
126
- /*
127
- //$weight = $product->getWeight();
128
- $weight = $product->getTypeInstance(true)->getWeight($product);
129
- Mage::log("[Bundle] " . $product->getName() . " : " . $finalPrice . " - [weight] " . $weight, null, 'cart.log', true);
130
- */
131
-
132
- //$template = $this->_getApi()->CalculatePrice($product, null, null, 'bundle')
133
- //$template = $this->_getApi()->CalculatePrice($product, null, $finalPrice, 'bundle')
134
- $template = $this->_getApi()->CalculatePrice($product, null, $finalPrice, $bundleType)
135
- ->GetTemplateProduct();
136
-
137
- $extraHtml = '<p class="label" id="skybox-configurable-price-from-'
138
- . $product->getId()
139
- . $this->getIdSuffix()
140
- . '">'
141
- . $template
142
- . '</p>'
143
- . '<div style="clear:both"></div>';
144
- //$priceHtml = parent::_toHtml();
145
- #manually insert extra html needed by the extension into the normal price html
146
-
147
- //substr_replace($priceHtml, $extraHtml, strpos($priceHtml, $htmlToInsertAfter)+strlen($htmlToInsertAfter),0);
148
- return $extraHtml;
149
- }
150
  }
1
+ <?php
2
+ /**
3
+ * Skybox Checkout
4
+ *
5
+ * @category Mage
6
+ * @package Skybox_Catalog
7
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
8
+ */
9
+
10
+ /**
11
+ * Bundle product price block
12
+ *
13
+ * @category Skybox
14
+ * @package Skybox_Catalog
15
+ */
16
+ class Skybox_Catalog_Block_Bundle_Price extends Mage_Bundle_Block_Catalog_Product_Price
17
+ {
18
+ /*
19
+ * @var string $_cache_code
20
+ */
21
+ public $_cache_code = null;
22
+
23
+ public function getCacheCode()
24
+ {
25
+ if ($this->_cache_code == null) {
26
+ /* @var $config Skybox_Core_Model_Config */
27
+ $config = Mage::getModel("skyboxcore/config");
28
+ $skyboxUser = $config->getSession()->getSkyboxUser();
29
+ $cache_code = $skyboxUser->CartCountryISOCode . $skyboxUser->CartCityId . $skyboxUser->CartCurrencyISOCode;
30
+ $this->_cache_code = $cache_code;
31
+ }
32
+ Mage::log("[bundle/price] Cache Code: " . $cache_code, null, 'cache.log', true);
33
+ return $this->_cache_code;
34
+ }
35
+
36
+ /*
37
+ protected function _construct()
38
+ {
39
+ //parent::__construct();
40
+ $this->addData(array(
41
+ 'cache_lifetime' => 120 //seconds
42
+ ));
43
+ }
44
+ */
45
+
46
+ public function getCacheKey()
47
+ {
48
+ $cache_key = "B_PRODUCT_" . $this->getProduct()->getId() . "_" . $this->getCacheCode();
49
+ return $cache_key;
50
+ }
51
+
52
+ public function getCacheTags()
53
+ {
54
+ $cache_tag = $this->getProduct()->getId() . "_B_" . $this->getCacheCode();
55
+ return array(Mage_Catalog_Model_Product::CACHE_TAG . $cache_tag);
56
+ }
57
+
58
+ /**
59
+ * Retrieve API Product
60
+ *
61
+ * @return Skybox_Catalog_Model_Api_Product
62
+ */
63
+ protected function _getApi()
64
+ {
65
+ if (null === $this->_api) {
66
+ $this->_api = Mage::getModel('skyboxcatalog/api_product');
67
+ }
68
+ return $this->_api;
69
+ }
70
+
71
+ /**
72
+ * Convert block to html string
73
+ *
74
+ * @return string
75
+ */
76
+ public function _toHtml()
77
+ {
78
+ //return parent::_toHtml();
79
+ Mage::log("CatalogBlockPrice__toHtmlbundle ", null, 'orden.log', true);
80
+ if ($this->_getApi()->getErrorAuthenticate() && !$this->_getApi()->getLocationAllow() && $this->_getApi()->HasError()) {
81
+ return '';
82
+ } elseif ($this->_getApi()->HasError()) {
83
+ //$error_code = $this->_getApi()->getStatusCode();
84
+ $message = $this->_getApi()->getStatusMessage();
85
+ //return '<div style="color:#FF0000;">' . $message . '</div>';
86
+ Mage::log("[bundle/price] Some parameter doesn't given to Calculate Price: " . $this->_getApi()->getStatusMessage(), null, 'skyboxcheckout.log', true);
87
+ }
88
+
89
+ /* @var $product Mage_Catalog_Model_Product */
90
+ $product = $this->getProduct();
91
+ $type = $product->getTypeId();
92
+ $route_name = Mage::app()->getRequest()->getRouteName();
93
+ //Mage::log("ROUTER; ". $route_name, null, 'cart.log', true);
94
+
95
+ if ($type == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE && $this->getTemplate() == 'bundle/catalog/product/price.phtml') {
96
+ if ($route_name == 'catalog') {
97
+ return $this->calculatePrice($product);
98
+ }
99
+
100
+ // Note: we can't get the "Final Price".
101
+ // Moreover, we show "From XXX to XXX" price Block.
102
+ //return parent::_toHtml();
103
+
104
+ // Note: We make a product type: 'bundle_fixed' to calculate Price and Weight dynamically
105
+ return $this->calculatePrice($product, 'bundle_fixed');
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Calculate Price HTML output
111
+ *
112
+ * @param Mage_Catalog_Model_Product $product
113
+ * @return string
114
+ */
115
+ protected function calculatePrice($product, $bundleType = 'bundle')
116
+ {
117
+ //Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter calculatePrice', null, 'tracer.log', true);
118
+ $stockItem = $product->getStockItem();
119
+ if (!$stockItem->getIsInStock()) {
120
+ return ''; // Out of Stock
121
+ }
122
+
123
+ $finalPrice = $product->getFinalPrice();
124
+ $finalPrice = ($finalPrice > 0) ? $finalPrice : null;
125
+
126
+ /*
127
+ //$weight = $product->getWeight();
128
+ $weight = $product->getTypeInstance(true)->getWeight($product);
129
+ Mage::log("[Bundle] " . $product->getName() . " : " . $finalPrice . " - [weight] " . $weight, null, 'cart.log', true);
130
+ */
131
+
132
+ //$template = $this->_getApi()->CalculatePrice($product, null, null, 'bundle')
133
+ //$template = $this->_getApi()->CalculatePrice($product, null, $finalPrice, 'bundle')
134
+ $template = $this->_getApi()->CalculatePrice($product, null, $finalPrice, $bundleType)
135
+ ->GetTemplateProduct();
136
+
137
+ $extraHtml = '<p class="label" id="skybox-configurable-price-from-'
138
+ . $product->getId()
139
+ . $this->getIdSuffix()
140
+ . '">'
141
+ . $template
142
+ . '</p>'
143
+ . '<div style="clear:both"></div>';
144
+ //$priceHtml = parent::_toHtml();
145
+ #manually insert extra html needed by the extension into the normal price html
146
+
147
+ //substr_replace($priceHtml, $extraHtml, strpos($priceHtml, $htmlToInsertAfter)+strlen($htmlToInsertAfter),0);
148
+ return $extraHtml;
149
+ }
150
  }
app/code/community/Skybox/Catalog/Block/Catalog/Category/Tab/Skyboxcheckout.php CHANGED
@@ -1,126 +1,126 @@
1
- <?php
2
- /**
3
- * Skybox Catalog
4
- *
5
- * @category Skybox
6
- * @package Skybox_Catalog
7
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
8
- */
9
-
10
- /**
11
- * Admin form widget
12
- *
13
- * @category Skybox
14
- * @package Skybox_Catalog
15
- */
16
- class Skybox_Catalog_Block_Catalog_Category_Tab_Skyboxcheckout extends Mage_Adminhtml_Block_Widget_Form
17
- {
18
- public $_commodities = null;
19
-
20
- private function _getCommoditiesData()
21
- {
22
- if ($this->_commodities == null) {
23
-
24
- /* var @api_checkout Skybox_Checkout_Model_Api_Checkout*/
25
- $api_checkout = Mage::getModel('skyboxcheckout/api_checkout');
26
- $categories = $api_checkout->GetCategories();
27
-
28
- $options = array('' => '');
29
-
30
- foreach ($categories as $obj) {
31
- $item = array(
32
- $obj->IdCommoditie => $obj->Description,
33
- );
34
- //$options = array_merge($options, $item);
35
- $options = array_replace($options, $item);
36
- }
37
- $this->_commodities = $options;
38
- }
39
- return $this->_commodities;
40
- }
41
-
42
- protected function _prepareForm()
43
- {
44
- $model = Mage::registry('category');
45
-
46
- $form = new Varien_Data_Form(array(
47
- 'id' => 'edit_form',
48
- 'action' => $this->getData('action'),
49
- 'method' => 'post',
50
- 'enctype' => 'multipart/form-data'
51
- ));
52
-
53
- // Form 1
54
- // -----------------------------------------------------------------
55
-
56
- $fieldset = $form->addFieldset('form1_fieldset',
57
- array('legend' => Mage::helper('catalog')->__('For New Products'))
58
- );
59
-
60
- if ($model->getId()) {
61
- $fieldset->addField('attribute_id', 'hidden', array(
62
- 'name' => 'attribute_id',
63
- ));
64
- }
65
-
66
- $options = $this->_getCommoditiesData();
67
-
68
- $fieldset->addField('skybox_category_id', 'select', array(
69
- 'name' => 'skybox_category_id',
70
- 'label' => Mage::helper('catalog')->__('Default commodity'),
71
- 'title' => Mage::helper('catalog')->__('Default commodity'),
72
- //'note' => Mage::helper('catalog')->__('Custom Attribute note'),
73
- 'values' => $options
74
- ));
75
-
76
- // Form 2
77
- // -----------------------------------------------------------------
78
-
79
- $fieldset = $form->addFieldset('form2_fieldset',
80
- array('legend' => Mage::helper('catalog')->__('For Existing Products in Category')));
81
-
82
- // Buttons
83
- $buttons = ' <br/>';
84
- $buttons .= '<br/><button type="button" onclick = "categorySubmit2(\'' . $this->getSaveUrl() . '\', true)" > Apply All Products </button>';
85
- $buttons .= '<br/><br/><button type="button" onclick = "categorySubmit3(\'' . $this->getSaveUrl() . '\', true)" > Apply All Products without Commodities </button>';
86
-
87
- $fieldset->addField('skybox_category_id_select', 'select', array(
88
- 'name' => 'skybox_category_id_select',
89
- 'label' => Mage::helper('catalog')->__('Select commodity'),
90
- 'title' => Mage::helper('catalog')->__('Select commodity'),
91
- 'values' => $options,
92
- 'after_element_html' => $buttons
93
- ));
94
-
95
- $fieldset->addField('apply_button', 'hidden', array(
96
- 'name' => 'apply_button',
97
- ));
98
-
99
- //Mage::log("category->getData()", null, 'skyboxcheckout.log', false);
100
- //Mage::log(print_r($model->getData(), true), null, 'skyboxcheckout.log', false);
101
-
102
- // Set Values
103
- $values = Mage::registry('category')->getData();
104
- $values['apply_button'] = 'nothing';
105
-
106
- $form->setValues($values);
107
- $this->setForm($form);
108
- return parent::_prepareForm();
109
- }
110
-
111
- protected function _getAdditionalElementTypes()
112
- {
113
- return array(
114
- 'apply' => Mage::getConfig()->getBlockClassName('adminhtml / catalog_product_helper_form_apply')
115
- );
116
- }
117
-
118
- public function getSaveUrl(array $args = array())
119
- {
120
- //$params = array('_current' => true);
121
- //$params = array_merge($params, $args);
122
- $params = array();
123
- return $this->getUrl('*/*/save', $params);
124
- }
125
-
126
  }
1
+ <?php
2
+ /**
3
+ * Skybox Catalog
4
+ *
5
+ * @category Skybox
6
+ * @package Skybox_Catalog
7
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
8
+ */
9
+
10
+ /**
11
+ * Admin form widget
12
+ *
13
+ * @category Skybox
14
+ * @package Skybox_Catalog
15
+ */
16
+ class Skybox_Catalog_Block_Catalog_Category_Tab_Skyboxcheckout extends Mage_Adminhtml_Block_Widget_Form
17
+ {
18
+ public $_commodities = null;
19
+
20
+ private function _getCommoditiesData()
21
+ {
22
+ if ($this->_commodities == null) {
23
+
24
+ /* var @api_checkout Skybox_Checkout_Model_Api_Checkout*/
25
+ $api_checkout = Mage::getModel('skyboxcheckout/api_checkout');
26
+ $categories = $api_checkout->GetCategories();
27
+
28
+ $options = array('' => '');
29
+
30
+ foreach ($categories as $obj) {
31
+ $item = array(
32
+ $obj->IdCommoditie => $obj->Description,
33
+ );
34
+ //$options = array_merge($options, $item);
35
+ $options = array_replace($options, $item);
36
+ }
37
+ $this->_commodities = $options;
38
+ }
39
+ return $this->_commodities;
40
+ }
41
+
42
+ protected function _prepareForm()
43
+ {
44
+ $model = Mage::registry('category');
45
+
46
+ $form = new Varien_Data_Form(array(
47
+ 'id' => 'edit_form',
48
+ 'action' => $this->getData('action'),
49
+ 'method' => 'post',
50
+ 'enctype' => 'multipart/form-data'
51
+ ));
52
+
53
+ // Form 1
54
+ // -----------------------------------------------------------------
55
+
56
+ $fieldset = $form->addFieldset('form1_fieldset',
57
+ array('legend' => Mage::helper('catalog')->__('For New Products'))
58
+ );
59
+
60
+ if ($model->getId()) {
61
+ $fieldset->addField('attribute_id', 'hidden', array(
62
+ 'name' => 'attribute_id',
63
+ ));
64
+ }
65
+
66
+ $options = $this->_getCommoditiesData();
67
+
68
+ $fieldset->addField('skybox_category_id', 'select', array(
69
+ 'name' => 'skybox_category_id',
70
+ 'label' => Mage::helper('catalog')->__('Default commodity'),
71
+ 'title' => Mage::helper('catalog')->__('Default commodity'),
72
+ //'note' => Mage::helper('catalog')->__('Custom Attribute note'),
73
+ 'values' => $options
74
+ ));
75
+
76
+ // Form 2
77
+ // -----------------------------------------------------------------
78
+
79
+ $fieldset = $form->addFieldset('form2_fieldset',
80
+ array('legend' => Mage::helper('catalog')->__('For Existing Products in Category')));
81
+
82
+ // Buttons
83
+ $buttons = ' <br/>';
84
+ $buttons .= '<br/><button type="button" onclick = "categorySubmit2(\'' . $this->getSaveUrl() . '\', true)" > Apply All Products </button>';
85
+ $buttons .= '<br/><br/><button type="button" onclick = "categorySubmit3(\'' . $this->getSaveUrl() . '\', true)" > Apply All Products without Commodities </button>';
86
+
87
+ $fieldset->addField('skybox_category_id_select', 'select', array(
88
+ 'name' => 'skybox_category_id_select',
89
+ 'label' => Mage::helper('catalog')->__('Select commodity'),
90
+ 'title' => Mage::helper('catalog')->__('Select commodity'),
91
+ 'values' => $options,
92
+ 'after_element_html' => $buttons
93
+ ));
94
+
95
+ $fieldset->addField('apply_button', 'hidden', array(
96
+ 'name' => 'apply_button',
97
+ ));
98
+
99
+ //Mage::log("category->getData()", null, 'skyboxcheckout.log', false);
100
+ //Mage::log(print_r($model->getData(), true), null, 'skyboxcheckout.log', false);
101
+
102
+ // Set Values
103
+ $values = Mage::registry('category')->getData();
104
+ $values['apply_button'] = 'nothing';
105
+
106
+ $form->setValues($values);
107
+ $this->setForm($form);
108
+ return parent::_prepareForm();
109
+ }
110
+
111
+ protected function _getAdditionalElementTypes()
112
+ {
113
+ return array(
114
+ 'apply' => Mage::getConfig()->getBlockClassName('adminhtml / catalog_product_helper_form_apply')
115
+ );
116
+ }
117
+
118
+ public function getSaveUrl(array $args = array())
119
+ {
120
+ //$params = array('_current' => true);
121
+ //$params = array_merge($params, $args);
122
+ $params = array();
123
+ return $this->getUrl('*/*/save', $params);
124
+ }
125
+
126
  }
app/code/community/Skybox/Catalog/Block/Product/List.php CHANGED
@@ -1,184 +1,184 @@
1
- <?php
2
- /**
3
- * Skybox Checkout
4
- *
5
- * @category Skybox
6
- * @package Skybox_Catalog
7
- * @copyright Copyright (c) 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
8
- */
9
-
10
- /**
11
- * Product list
12
- */
13
- class Skybox_Catalog_Block_Product_List extends Mage_Catalog_Block_Product_List
14
- {
15
- public $_sky_cache_code = null;
16
-
17
- /**
18
- * Retrieve API Product
19
- *
20
- * @return Skybox_Catalog_Model_Api_Product
21
- */
22
- protected function _getApi()
23
- {
24
- if (null === $this->_api) {
25
- $this->_api = Mage::getModel('skyboxcatalog/api_product');
26
- }
27
- return $this->_api;
28
- }
29
-
30
- /**
31
- * Need use as _prepareLayout - but problem in declaring collection from
32
- * another block (was problem with search result)
33
- */
34
- protected function _beforeToHtml()
35
- {
36
- $result = parent::_beforeToHtml();
37
-
38
- if (!$this->isEnable()) {
39
- return $result;
40
- }
41
-
42
- $api_checkout = Mage::getModel('skyboxcheckout/api_checkout');
43
- $api_checkout->InitializeBarSkybox();
44
-
45
- // $session = Mage::getSingleton("core/session", array("name" => "frontend"));
46
- // $sky = $session->getData("skyBox");
47
-
48
- $data = $api_checkout->getValueAccessService();
49
-
50
- $skyBoxUrlClient = Mage::helper('skyboxinternational/data')->getSkyBoxUrlAPI();
51
- $skyBoxUrlClient = $skyBoxUrlClient . ("multiplecalculate");
52
-
53
- $dataJson = null;
54
- $multiCalculate = 1;
55
-
56
- try {
57
- $products = $this->getToolbarBlock()->getCollection();
58
- if (empty($products)) { // foff
59
- $products = $this->_getProductCollection();
60
- }
61
-
62
- foreach ($products as $prod) {
63
- $product = Mage::getModel('catalog/product')->load($prod->getId());
64
- $data['listproducts'][] = $this->getUrlService($product);
65
- $dataJson = json_encode($data);
66
- }
67
-
68
- $response = $this->multiCalculatePrice($skyBoxUrlClient, $dataJson);
69
- // Mage::log(print_r($response, true), null, 'multicalculate.log', true);
70
- // Mage::log(print_r($dataJson, true), null, 'multicalculate.log', true);
71
-
72
- } catch (\Exception $e) {
73
- $multiCalculate = 0;
74
- // Mage::log(print_r($dataJson, true), null, 'multicalculate.log', true);
75
- // Mage::log("[multicalculate] " . $e->getMessage(), null, 'multicalculate.log', true);
76
- }
77
-
78
- Mage::unregister('skybox_multicalculate');
79
- Mage::register('skybox_multicalculate', $multiCalculate);
80
- // Mage::registry('skybox_multicalculate');
81
-
82
- return $result;
83
- }
84
-
85
- /**
86
- * Return the Skybox Cache code
87
- *
88
- * @param $productId
89
- * @return mixed
90
- */
91
- public function getSkyboxCacheCode($productId)
92
- {
93
- if ($this->_sky_cache_code == null) {
94
- /* @var $config Skybox_Core_Model_Config */
95
- $config = Mage::getModel("skyboxcore/config");
96
- $skyboxUser = $config->getSession()->getSkyboxUser();
97
- $country_iso_code = strtoupper($skyboxUser->CartCountryISOCode);
98
- $cache_code = $country_iso_code . "[REPLACE]" . $skyboxUser->CartCurrencyISOCode;
99
- $this->_sky_cache_code = $cache_code;
100
- }
101
-
102
- $result = str_replace('[REPLACE]', $productId, $this->_sky_cache_code);
103
- return $result;
104
- }
105
-
106
- /**
107
- * @param $product
108
- * @return array|string
109
- */
110
- public function getUrlService($product)
111
- {
112
- $type = $product->getTypeId();
113
- $template = '';
114
-
115
- switch ($type) {
116
- case 'simple':
117
- $template = $this->_getApi()->getUrl($product->getId(), null, $product->getFinalPrice(),
118
- $product->getTypeId());
119
- break;
120
- case 'configurable':
121
- $template = $this->_getApi()->getUrl($product->getId(), null, $product->getFinalPrice(),
122
- $product->getTypeId());
123
- break;
124
- case 'bundle':
125
- $template = $this->_getApi()->getUrl($product, null, $product->getFinalPrice(), 'simple');
126
- break;
127
- }
128
-
129
- if (is_array($template)) {
130
- $productId = $template['htmlobjectid'];
131
- $cache_code = $this->getSkyboxCacheCode($productId);
132
- $template['htmlobjectid'] = $cache_code;
133
- }
134
- return $template;
135
- }
136
-
137
- /**
138
- * Return Multi CalculatePrice
139
- *
140
- * @param $url
141
- * @param $data
142
- * @return mixed
143
- * @throws Exception
144
- */
145
- function multiCalculatePrice($url, $data)
146
- {
147
- $ch = curl_init();
148
- curl_setopt($ch, CURLOPT_URL, $url);
149
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
150
- curl_setopt($ch, CURLOPT_POST, 1);
151
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
152
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
153
- $response = curl_exec($ch);
154
-
155
- $response = json_decode($response, true);
156
-
157
- if ($response['StatusCode'] != 'Success') {
158
- throw new \Exception('Missing or invalid data send to MultiCalculate');
159
- }
160
- return $response;
161
- }
162
-
163
- /**
164
- * is Enable?
165
- *
166
- * @return bool
167
- */
168
- private function isEnable()
169
- {
170
- $isModuleEnable = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
171
- if (!$isModuleEnable) {
172
- return false;
173
- }
174
-
175
- /** @var Skybox_Core_Helper_Allow $allowHelper */
176
- $allowHelper = Mage::helper('skyboxcore/allow');
177
-
178
- if (!$allowHelper->isPriceEnabled()) {
179
- return false;
180
- }
181
-
182
- return true;
183
- }
184
- }
1
+ <?php
2
+ /**
3
+ * Skybox Checkout
4
+ *
5
+ * @category Skybox
6
+ * @package Skybox_Catalog
7
+ * @copyright Copyright (c) 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
8
+ */
9
+
10
+ /**
11
+ * Product list
12
+ */
13
+ class Skybox_Catalog_Block_Product_List extends Mage_Catalog_Block_Product_List
14
+ {
15
+ public $_sky_cache_code = null;
16
+
17
+ /**
18
+ * Retrieve API Product
19
+ *
20
+ * @return Skybox_Catalog_Model_Api_Product
21
+ */
22
+ protected function _getApi()
23
+ {
24
+ if (null === $this->_api) {
25
+ $this->_api = Mage::getModel('skyboxcatalog/api_product');
26
+ }
27
+ return $this->_api;
28
+ }
29
+
30
+ /**
31
+ * Need use as _prepareLayout - but problem in declaring collection from
32
+ * another block (was problem with search result)
33
+ */
34
+ protected function _beforeToHtml()
35
+ {
36
+ $result = parent::_beforeToHtml();
37
+
38
+ if (!$this->isEnable()) {
39
+ return $result;
40
+ }
41
+
42
+ $api_checkout = Mage::getModel('skyboxcheckout/api_checkout');
43
+ $api_checkout->InitializeBarSkybox();
44
+
45
+ // $session = Mage::getSingleton("core/session", array("name" => "frontend"));
46
+ // $sky = $session->getData("skyBox");
47
+
48
+ $data = $api_checkout->getValueAccessService();
49
+
50
+ $skyBoxUrlClient = Mage::helper('skyboxinternational/data')->getSkyBoxUrlAPI();
51
+ $skyBoxUrlClient = $skyBoxUrlClient . ("multiplecalculate");
52
+
53
+ $dataJson = null;
54
+ $multiCalculate = 1;
55
+
56
+ try {
57
+ $products = $this->getToolbarBlock()->getCollection();
58
+ if (empty($products)) { // foff
59
+ $products = $this->_getProductCollection();
60
+ }
61
+
62
+ foreach ($products as $prod) {
63
+ $product = Mage::getModel('catalog/product')->load($prod->getId());
64
+ $data['listproducts'][] = $this->getUrlService($product);
65
+ $dataJson = json_encode($data);
66
+ }
67
+
68
+ $response = $this->multiCalculatePrice($skyBoxUrlClient, $dataJson);
69
+ // Mage::log(print_r($response, true), null, 'multicalculate.log', true);
70
+ // Mage::log(print_r($dataJson, true), null, 'multicalculate.log', true);
71
+
72
+ } catch (\Exception $e) {
73
+ $multiCalculate = 0;
74
+ // Mage::log(print_r($dataJson, true), null, 'multicalculate.log', true);
75
+ // Mage::log("[multicalculate] " . $e->getMessage(), null, 'multicalculate.log', true);
76
+ }
77
+
78
+ Mage::unregister('skybox_multicalculate');
79
+ Mage::register('skybox_multicalculate', $multiCalculate);
80
+ // Mage::registry('skybox_multicalculate');
81
+
82
+ return $result;
83
+ }
84
+
85
+ /**
86
+ * Return the Skybox Cache code
87
+ *
88
+ * @param $productId
89
+ * @return mixed
90
+ */
91
+ public function getSkyboxCacheCode($productId)
92
+ {
93
+ if ($this->_sky_cache_code == null) {
94
+ /* @var $config Skybox_Core_Model_Config */
95
+ $config = Mage::getModel("skyboxcore/config");
96
+ $skyboxUser = $config->getSession()->getSkyboxUser();
97
+ $country_iso_code = strtoupper($skyboxUser->CartCountryISOCode);
98
+ $cache_code = $country_iso_code . "[REPLACE]" . $skyboxUser->CartCurrencyISOCode;
99
+ $this->_sky_cache_code = $cache_code;
100
+ }
101
+
102
+ $result = str_replace('[REPLACE]', $productId, $this->_sky_cache_code);
103
+ return $result;
104
+ }
105
+
106
+ /**
107
+ * @param $product
108
+ * @return array|string
109
+ */
110
+ public function getUrlService($product)
111
+ {
112
+ $type = $product->getTypeId();
113
+ $template = '';
114
+
115
+ switch ($type) {
116
+ case 'simple':
117
+ $template = $this->_getApi()->getUrl($product->getId(), null, $product->getFinalPrice(),
118
+ $product->getTypeId());
119
+ break;
120
+ case 'configurable':
121
+ $template = $this->_getApi()->getUrl($product->getId(), null, $product->getFinalPrice(),
122
+ $product->getTypeId());
123
+ break;
124
+ case 'bundle':
125
+ $template = $this->_getApi()->getUrl($product, null, $product->getFinalPrice(), 'simple');
126
+ break;
127
+ }
128
+
129
+ if (is_array($template)) {
130
+ $productId = $template['htmlobjectid'];
131
+ $cache_code = $this->getSkyboxCacheCode($productId);
132
+ $template['htmlobjectid'] = $cache_code;
133
+ }
134
+ return $template;
135
+ }
136
+
137
+ /**
138
+ * Return Multi CalculatePrice
139
+ *
140
+ * @param $url
141
+ * @param $data
142
+ * @return mixed
143
+ * @throws Exception
144
+ */
145
+ function multiCalculatePrice($url, $data)
146
+ {
147
+ $ch = curl_init();
148
+ curl_setopt($ch, CURLOPT_URL, $url);
149
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
150
+ curl_setopt($ch, CURLOPT_POST, 1);
151
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
152
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
153
+ $response = curl_exec($ch);
154
+
155
+ $response = json_decode($response, true);
156
+
157
+ if ($response['StatusCode'] != 'Success') {
158
+ throw new \Exception('Missing or invalid data send to MultiCalculate');
159
+ }
160
+ return $response;
161
+ }
162
+
163
+ /**
164
+ * is Enable?
165
+ *
166
+ * @return bool
167
+ */
168
+ private function isEnable()
169
+ {
170
+ $isModuleEnable = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
171
+ if (!$isModuleEnable) {
172
+ return false;
173
+ }
174
+
175
+ /** @var Skybox_Core_Helper_Allow $allowHelper */
176
+ $allowHelper = Mage::helper('skyboxcore/allow');
177
+
178
+ if (!$allowHelper->isPriceEnabled()) {
179
+ return false;
180
+ }
181
+
182
+ return true;
183
+ }
184
+ }
app/code/community/Skybox/Catalog/Block/Product/Price.php CHANGED
@@ -1,256 +1,256 @@
1
- <?php
2
- /**
3
- * Skybox Checkout
4
- *
5
- * @category Mage
6
- * @package Skybox_Catalog
7
- * @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
8
- */
9
-
10
- /**
11
- *
12
- * Product Price Block
13
- */
14
- class Skybox_Catalog_Block_Product_Price extends Mage_Catalog_Block_Product_Price
15
- {
16
- public $_cache_code = null;
17
- public $_sky_cache_code = null;
18
-
19
- public function getCacheCode()
20
- {
21
- Mage::log("cache ", null, 'orden.log', true);
22
- if ($this->_cache_code == null) {
23
- /* @var $config Skybox_Core_Model_Config */
24
- $config = Mage::getModel("skyboxcore/config");
25
- $skyboxUser = $config->getSession()->getSkyboxUser();
26
- $cache_code = $skyboxUser->CartCountryISOCode . $skyboxUser->CartCityId . $skyboxUser->CartCurrencyISOCode;
27
- $this->_cache_code = $cache_code;
28
- }
29
- Mage::log("[product/price] Cache Code: " . $cache_code, null, 'cache.log', true);
30
- return $this->_cache_code;
31
- }
32
-
33
- /*
34
- protected function _construct()
35
- {
36
- //parent::__construct();
37
- $this->addData(array(
38
- 'cache_lifetime' => 120 //seconds
39
- ));
40
- }
41
- */
42
-
43
- public function getCacheKey()
44
- {
45
- $cache_key = "PRODUCT_" . $this->getProduct()->getId() . "_" . $this->getCacheCode();
46
- return $cache_key;
47
- }
48
-
49
- public function getCacheTags()
50
- {
51
- $cache_tag = $this->getProduct()->getId() . "_" . $this->getCacheCode();
52
- return array(Mage_Catalog_Model_Product::CACHE_TAG . $cache_tag);
53
- }
54
-
55
- /**
56
- * Retrieve API Product
57
- *
58
- * @return Skybox_Catalog_Model_Api_Product
59
- */
60
- protected function _getApi()
61
- {
62
- if (null === $this->_api) {
63
- $this->_api = Mage::getModel('skyboxcatalog/api_product');
64
- }
65
- return $this->_api;
66
- }
67
-
68
- /**
69
- * Render block HTML
70
- *
71
- * @return string
72
- */
73
- public function _toHtml()
74
- {
75
- $isModuleEnable = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
76
-
77
- if (!$isModuleEnable) {
78
- return parent::_toHtml();
79
- }
80
-
81
- /** @var Skybox_Core_Helper_Allow $allowHelper */
82
- $allowHelper = Mage::helper('skyboxcore/allow');
83
-
84
- if ($allowHelper->isPriceEnabled()) {
85
-
86
- if ($this->_getApi()->getErrorAuthenticate() && !$this->_getApi()->getLocationAllow() && $this->_getApi()->HasError()) {
87
- return '';
88
- } elseif ($this->_getApi()->HasError()) {
89
- //$error_code = $this->_getApi()->getStatusCode();
90
- $message = $this->_getApi()->getStatusMessage();
91
-
92
- if ($this->_getApi()->_getApi()->ErrorRatesNotFound()) {
93
- $message = $this->_getApi()->_getApi()->getErrorRatesNotFoundMessage($this->getLanguageId());
94
- return '<div style="color:#FF0000;">' . $message . '</div>';
95
- }
96
-
97
- // return '<div style="color:#FF0000;">' . $message . '</div>';
98
- return '';
99
- }
100
-
101
- /* @var Mage_Catalog_Model_Product $product */
102
- $product = $this->getProduct();
103
- $type = $product->getTypeId();
104
- $route_name = Mage::app()->getRequest()->getRouteName();
105
-
106
- // Simple Product
107
- if ($type == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE && $this->getTemplate() == 'catalog/product/price.phtml') {
108
- return $this->calculatePrice($product);
109
- }
110
-
111
- if ($type == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE && $this->getTemplate() == 'catalog/product/view/price_clone.phtml') {
112
- return '';
113
- }
114
-
115
- // Configurable Product
116
- if ($type == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE && $this->getTemplate() == 'catalog/product/price.phtml') {
117
-
118
- if (Mage::registry('current_product')) {
119
- return "";
120
- }
121
-
122
- return $this->calculatePrice($product);
123
- }
124
-
125
- if ($type == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE && $this->getTemplate() == 'catalog/product/view/tierprices.phtml') {
126
- if ($route_name == 'catalog') {
127
- return $this->calculatePrice($product);
128
- }
129
- return '';
130
- }
131
-
132
- }
133
-
134
- return parent::_toHtml();
135
- }
136
-
137
- /**
138
- * Calculate Price HTML output
139
- *
140
- * @param Mage_Catalog_Model_Product $product
141
- * @return string
142
- */
143
- protected function calculatePrice($product)
144
- {
145
- //Mage::log('Entro calcular producto', null, 'tracer.log', true);
146
- $stockItem = $product->getStockItem();
147
- // if (!$stockItem->getIsInStock()) {
148
- // Mage::log('sin stock', null, 'tracer.log', true);
149
- // return ''; // Out of Stock
150
- // }
151
-
152
- $type = $product->getTypeId();
153
- //Mage::log(print_r('product\Price: '.$type, true), null, 'tracer.log', true);
154
-
155
- $multiCalculate = Mage::registry('skybox_multicalculate');
156
-
157
- // if ($multiCalculate and Mage::registry('current_category') and (!(Mage::registry('current_product')))) {
158
-
159
- // if ($multiCalculate && Mage::registry('current_category')) {
160
- if ($multiCalculate) {
161
- /**
162
- * Apply multiple calculate start
163
- * When: is different to product detail and you are on catalog category
164
- */
165
- // $template = '<div class="skybox-price-set" product-id="' . $product->getId() . '" id="product-' . $product->getId() . '"></div>';
166
-
167
- $cache_code = $this->getSkyboxCacheCode($product->getId());
168
- $template = '<div class="skybox-price-set" product-id="' . $cache_code . '" id="product-' . $product->getId() . '"></div>';
169
-
170
- /**
171
- * Apply multiple calculate end
172
- */
173
- } else {
174
- switch ($type) {
175
- case 'simple':
176
- $template = $this->_getApi()->CalculatePrice($product->getId(), null, $product->getFinalPrice(),
177
- $product->getTypeId())
178
- ->GetTemplateProduct();
179
- break;
180
- case 'configurable':
181
- $template = $this->_getApi()->CalculatePrice($product->getId(), null, $product->getFinalPrice(),
182
- $product->getTypeId())
183
- ->GetTemplateProduct();
184
- break;
185
- case 'bundle':
186
- $template = $this->_getApi()->CalculatePrice($product, null, $product->getFinalPrice(), 'simple')
187
- ->GetTemplateProduct();
188
- break;
189
- }
190
- }
191
-
192
- // Mage::log(print_r('##Product template##', true), null, 'tracer.log', true);
193
- // Mage::log(print_r($template, true), null, 'tracer.log', true);
194
- /*
195
- $extraHtml = ''
196
- . '<div class="price-box">'
197
- . '<p class="label" id="skybox-configurable-price-from-'
198
- . $product->getId()
199
- . $this->getIdSuffix()
200
- . '">'
201
- . $template
202
- . '</p>'
203
- . '</div>'
204
- . '<div style="clear:both"></div>';
205
-
206
- */
207
- $extraHtml = ''
208
- . '<div class="price-box">'
209
- . '<p class="label" id="skybox-configurable-price-from-'
210
- . $product->getId()
211
- . $this->getIdSuffix()
212
- . '">'
213
- . $template
214
- . '</p>'
215
- . '</div>'
216
- . '<div style="clear:both"></div>';
217
- //$priceHtml = parent::_toHtml();
218
- #manually insert extra html needed by the extension into the normal price html
219
-
220
- //substr_replace($priceHtml, $extraHtml, strpos($priceHtml, $htmlToInsertAfter)+strlen($htmlToInsertAfter),0);
221
- return $extraHtml;
222
- }
223
-
224
- /**
225
- * Return the Language Id
226
- * @return int
227
- */
228
- private function getLanguageId()
229
- {
230
- $_config = Mage::getModel('skyboxcore/config');
231
- $cart = $_config->getSession()->getCartSkybox();
232
- $id = $cart->{'LanguageId'};
233
- return intval($id);
234
- }
235
-
236
- /**
237
- * Return the Skybox Cache code
238
- *
239
- * @param $productId
240
- * @return mixed
241
- */
242
- public function getSkyboxCacheCode($productId)
243
- {
244
- if ($this->_sky_cache_code == null) {
245
- /* @var $config Skybox_Core_Model_Config */
246
- $config = Mage::getModel("skyboxcore/config");
247
- $skyboxUser = $config->getSession()->getSkyboxUser();
248
- $country_iso_code = strtoupper($skyboxUser->CartCountryISOCode);
249
- $cache_code = $country_iso_code . "[REPLACE]" . $skyboxUser->CartCurrencyISOCode;
250
- $this->_sky_cache_code = $cache_code;
251
- }
252
-
253
- $result = str_replace('[REPLACE]', $productId, $this->_sky_cache_code);
254
- return $result;
255
- }
256
- }
1
+ <?php
2
+ /**
3
+ * Skybox Checkout
4
+ *
5
+ * @category Mage
6
+ * @package Skybox_Catalog
7
+ * @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
8
+ */
9
+
10
+ /**
11
+ *
12
+ * Product Price Block
13
+ */
14
+ class Skybox_Catalog_Block_Product_Price extends Mage_Catalog_Block_Product_Price
15
+ {
16
+ public $_cache_code = null;
17
+ public $_sky_cache_code = null;
18
+
19
+ public function getCacheCode()
20
+ {
21
+ Mage::log("cache ", null, 'orden.log', true);
22
+ if ($this->_cache_code == null) {
23
+ /* @var $config Skybox_Core_Model_Config */
24
+ $config = Mage::getModel("skyboxcore/config");
25
+ $skyboxUser = $config->getSession()->getSkyboxUser();
26
+ $cache_code = $skyboxUser->CartCountryISOCode . $skyboxUser->CartCityId . $skyboxUser->CartCurrencyISOCode;
27
+ $this->_cache_code = $cache_code;
28
+ }
29
+ Mage::log("[product/price] Cache Code: " . $cache_code, null, 'cache.log', true);
30
+ return $this->_cache_code;
31
+ }
32
+
33
+ /*
34
+ protected function _construct()
35
+ {
36
+ //parent::__construct();
37
+ $this->addData(array(
38
+ 'cache_lifetime' => 120 //seconds
39
+ ));
40
+ }
41
+ */
42
+
43
+ public function getCacheKey()
44
+ {
45
+ $cache_key = "PRODUCT_" . $this->getProduct()->getId() . "_" . $this->getCacheCode();
46
+ return $cache_key;
47
+ }
48
+
49
+ public function getCacheTags()
50
+ {
51
+ $cache_tag = $this->getProduct()->getId() . "_" . $this->getCacheCode();
52
+ return array(Mage_Catalog_Model_Product::CACHE_TAG . $cache_tag);
53
+ }
54
+
55
+ /**
56
+ * Retrieve API Product
57
+ *
58
+ * @return Skybox_Catalog_Model_Api_Product
59
+ */
60
+ protected function _getApi()
61
+ {
62
+ if (null === $this->_api) {
63
+ $this->_api = Mage::getModel('skyboxcatalog/api_product');
64
+ }
65
+ return $this->_api;
66
+ }
67
+
68
+ /**
69
+ * Render block HTML
70
+ *
71
+ * @return string
72
+ */
73
+ public function _toHtml()
74
+ {
75
+ $isModuleEnable = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
76
+
77
+ if (!$isModuleEnable) {
78
+ return parent::_toHtml();
79
+ }
80
+
81
+ /** @var Skybox_Core_Helper_Allow $allowHelper */
82
+ $allowHelper = Mage::helper('skyboxcore/allow');
83
+
84
+ if ($allowHelper->isPriceEnabled()) {
85
+
86
+ if ($this->_getApi()->getErrorAuthenticate() && !$this->_getApi()->getLocationAllow() && $this->_getApi()->HasError()) {
87
+ return '';
88
+ } elseif ($this->_getApi()->HasError()) {
89
+ //$error_code = $this->_getApi()->getStatusCode();
90
+ $message = $this->_getApi()->getStatusMessage();
91
+
92
+ if ($this->_getApi()->_getApi()->ErrorRatesNotFound()) {
93
+ $message = $this->_getApi()->_getApi()->getErrorRatesNotFoundMessage($this->getLanguageId());
94
+ return '<div style="color:#FF0000;">' . $message . '</div>';
95
+ }
96
+
97
+ // return '<div style="color:#FF0000;">' . $message . '</div>';
98
+ return '';
99
+ }
100
+
101
+ /* @var Mage_Catalog_Model_Product $product */
102
+ $product = $this->getProduct();
103
+ $type = $product->getTypeId();
104
+ $route_name = Mage::app()->getRequest()->getRouteName();
105
+
106
+ // Simple Product
107
+ if ($type == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE && $this->getTemplate() == 'catalog/product/price.phtml') {
108
+ return $this->calculatePrice($product);
109
+ }
110
+
111
+ if ($type == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE && $this->getTemplate() == 'catalog/product/view/price_clone.phtml') {
112
+ return '';
113
+ }
114
+
115
+ // Configurable Product
116
+ if ($type == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE && $this->getTemplate() == 'catalog/product/price.phtml') {
117
+
118
+ if (Mage::registry('current_product')) {
119
+ return "";
120
+ }
121
+
122
+ return $this->calculatePrice($product);
123
+ }
124
+
125
+ if ($type == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE && $this->getTemplate() == 'catalog/product/view/tierprices.phtml') {
126
+ if ($route_name == 'catalog') {
127
+ return $this->calculatePrice($product);
128
+ }
129
+ return '';
130
+ }
131
+
132
+ }
133
+
134
+ return parent::_toHtml();
135
+ }
136
+
137
+ /**
138
+ * Calculate Price HTML output
139
+ *
140
+ * @param Mage_Catalog_Model_Product $product
141
+ * @return string
142
+ */
143
+ protected function calculatePrice($product)
144
+ {
145
+ //Mage::log('Entro calcular producto', null, 'tracer.log', true);
146
+ $stockItem = $product->getStockItem();
147
+ // if (!$stockItem->getIsInStock()) {
148
+ // Mage::log('sin stock', null, 'tracer.log', true);
149
+ // return ''; // Out of Stock
150
+ // }
151
+
152
+ $type = $product->getTypeId();
153
+ //Mage::log(print_r('product\Price: '.$type, true), null, 'tracer.log', true);
154
+
155
+ $multiCalculate = Mage::registry('skybox_multicalculate');
156
+
157
+ // if ($multiCalculate and Mage::registry('current_category') and (!(Mage::registry('current_product')))) {
158
+
159
+ // if ($multiCalculate && Mage::registry('current_category')) {
160
+ if ($multiCalculate) {
161
+ /**
162
+ * Apply multiple calculate start
163
+ * When: is different to product detail and you are on catalog category
164
+ */
165
+ // $template = '<div class="skybox-price-set" product-id="' . $product->getId() . '" id="product-' . $product->getId() . '"></div>';
166
+
167
+ $cache_code = $this->getSkyboxCacheCode($product->getId());
168
+ $template = '<div class="skybox-price-set" product-id="' . $cache_code . '" id="product-' . $product->getId() . '"></div>';
169
+
170
+ /**
171
+ * Apply multiple calculate end
172
+ */
173
+ } else {
174
+ switch ($type) {
175
+ case 'simple':
176
+ $template = $this->_getApi()->CalculatePrice($product->getId(), null, $product->getFinalPrice(),
177
+ $product->getTypeId())
178
+ ->GetTemplateProduct();
179
+ break;
180
+ case 'configurable':
181
+ $template = $this->_getApi()->CalculatePrice($product->getId(), null, $product->getFinalPrice(),
182
+ $product->getTypeId())
183
+ ->GetTemplateProduct();
184
+ break;
185
+ case 'bundle':
186
+ $template = $this->_getApi()->CalculatePrice($product, null, $product->getFinalPrice(), 'simple')
187
+ ->GetTemplateProduct();
188
+ break;
189
+ }
190
+ }
191
+
192
+ // Mage::log(print_r('##Product template##', true), null, 'tracer.log', true);
193
+ // Mage::log(print_r($template, true), null, 'tracer.log', true);
194
+ /*
195
+ $extraHtml = ''
196
+ . '<div class="price-box">'
197
+ . '<p class="label" id="skybox-configurable-price-from-'
198
+ . $product->getId()
199
+ . $this->getIdSuffix()
200
+ . '">'
201
+ . $template
202
+ . '</p>'
203
+ . '</div>'
204
+ . '<div style="clear:both"></div>';
205
+
206
+ */
207
+ $extraHtml = ''
208
+ . '<div class="price-box">'
209
+ . '<p class="label" id="skybox-configurable-price-from-'
210
+ . $product->getId()
211
+ . $this->getIdSuffix()
212
+ . '">'
213
+ . $template
214
+ . '</p>'
215
+ . '</div>'
216
+ . '<div style="clear:both"></div>';
217
+ //$priceHtml = parent::_toHtml();
218
+ #manually insert extra html needed by the extension into the normal price html
219
+
220
+ //substr_replace($priceHtml, $extraHtml, strpos($priceHtml, $htmlToInsertAfter)+strlen($htmlToInsertAfter),0);
221
+ return $extraHtml;
222
+ }
223
+
224
+ /**
225
+ * Return the Language Id
226
+ * @return int
227
+ */
228
+ private function getLanguageId()
229
+ {
230
+ $_config = Mage::getModel('skyboxcore/config');
231
+ $cart = $_config->getSession()->getCartSkybox();
232
+ $id = $cart->{'LanguageId'};
233
+ return intval($id);
234
+ }
235
+
236
+ /**
237
+ * Return the Skybox Cache code
238
+ *
239
+ * @param $productId
240
+ * @return mixed
241
+ */
242
+ public function getSkyboxCacheCode($productId)
243
+ {
244
+ if ($this->_sky_cache_code == null) {
245
+ /* @var $config Skybox_Core_Model_Config */
246
+ $config = Mage::getModel("skyboxcore/config");
247
+ $skyboxUser = $config->getSession()->getSkyboxUser();
248
+ $country_iso_code = strtoupper($skyboxUser->CartCountryISOCode);
249
+ $cache_code = $country_iso_code . "[REPLACE]" . $skyboxUser->CartCurrencyISOCode;
250
+ $this->_sky_cache_code = $cache_code;
251
+ }
252
+
253
+ $result = str_replace('[REPLACE]', $productId, $this->_sky_cache_code);
254
+ return $result;
255
+ }
256
+ }
app/code/community/Skybox/Catalog/Block/Product/Widget/New.php CHANGED
@@ -1,203 +1,203 @@
1
- <?php
2
- /**
3
- * Skybox Checkout
4
- *
5
- * @category Skybox
6
- * @package Skybox_Catalog
7
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
8
- */
9
-
10
- /**
11
- * New products widget
12
- *
13
- * @category Skybox
14
- * @package Skybox_Catalog
15
- */
16
- class Skybox_Catalog_Block_Product_Widget_New extends Mage_Catalog_Block_Product_Widget_New
17
- {
18
-
19
- /*
20
- * @var string $_cache_code
21
- */
22
- public $_cache_code = null;
23
-
24
- public $_sky_cache_code = null;
25
- // protected $_api;
26
-
27
- /**
28
- * Retrieve API Product
29
- *
30
- * @return Skybox_Catalog_Model_Api_Product
31
- */
32
- protected function _getApi()
33
- {
34
- if (null === $this->_api) {
35
- $this->_api = Mage::getModel('skyboxcatalog/api_product');
36
- }
37
- return $this->_api;
38
- }
39
-
40
-
41
- /**
42
- * Initialize block's cache and template settings
43
- */
44
- protected function _construct()
45
- {
46
- parent::_construct();
47
- $cache_key = Mage_Catalog_Model_Product::CACHE_TAG . "_" . $this->getCacheCode();
48
- $this->setAttribute("cache_key", $cache_key);
49
- if (Mage::getVersion() == '1.9.1') {
50
- $this->addData(array('cache_lifetime' => null)); // Skip cache generation
51
- }
52
- }
53
-
54
- public function getCacheCode()
55
- {
56
- if ($this->_cache_code == null) {
57
- /* @var $config Skybox_Core_Model_Config */
58
- $config = Mage::getModel("skyboxcore/config");
59
- $skyboxUser = $config->getSession()->getSkyboxUser();
60
- $cache_code = $skyboxUser->CartCountryISOCode . $skyboxUser->CartCityId . $skyboxUser->CartCurrencyISOCode;
61
- $this->_cache_code = $cache_code;
62
- }
63
- Mage::log("[widget/new] Cache Code: " . $cache_code, null, 'cache.log', true);
64
- return $this->_cache_code;
65
- }
66
-
67
- protected function _getProductCollection()
68
- {
69
-
70
- return parent::_getProductCollection();
71
- }
72
-
73
- protected function _beforeToHtml()
74
- {
75
- $result = parent::_beforeToHtml();
76
- if (!$this->isEnable()) {
77
- return $result;
78
- }
79
- $api_checkout = Mage::getModel('skyboxcheckout/api_checkout');
80
- $api_checkout->InitializeBarSkybox();
81
-
82
- $data = $api_checkout->getValueAccessService();
83
-
84
- $skyBoxUrlClient = Mage::helper('skyboxinternational/data')->getSkyBoxUrlAPI();
85
- $skyBoxUrlClient = $skyBoxUrlClient . "multiplecalculate";
86
-
87
- $dataJson = null;
88
- $multiCalculate = 1;
89
-
90
- try {
91
- $products = $this->_getProductCollection();
92
- foreach ($products as $prod) {
93
- $product = Mage::getModel('catalog/product')->load($prod->getId());
94
- $data['listproducts'][] = $this->getUrlService($product);
95
- $dataJson = json_encode($data);
96
- }
97
- $response = $this->multiCalculatePrice($skyBoxUrlClient, $dataJson);
98
- } catch (\Exception $e) {
99
- $multiCalculate = 0;
100
- }
101
-
102
- Mage::unregister('skybox_multicalculate');
103
- Mage::register('skybox_multicalculate', $multiCalculate);
104
- return $result;
105
- }
106
-
107
- /**
108
- * @param $product
109
- * @return array|string
110
- */
111
- public function getUrlService($product)
112
- {
113
- $type = $product->getTypeId();
114
- $template = '';
115
-
116
- switch ($type) {
117
- case 'simple':
118
- $template = $this->_getApi()->getUrl($product->getId(), null, $product->getFinalPrice(),
119
- $product->getTypeId());
120
- break;
121
- case 'configurable':
122
- $template = $this->_getApi()->getUrl($product->getId(), null, $product->getFinalPrice(),
123
- $product->getTypeId());
124
- break;
125
- case 'bundle':
126
- $template = $this->_getApi()->getUrl($product, null, $product->getFinalPrice(), 'simple');
127
- break;
128
- }
129
-
130
- if (is_array($template)) {
131
- $productId = $template['htmlobjectid'];
132
- $cache_code = $this->getSkyboxCacheCode($productId);
133
- $template['htmlobjectid'] = $cache_code;
134
- }
135
- return $template;
136
- }
137
-
138
- /**
139
- * Return the Skybox Cache code
140
- *
141
- * @param $productId
142
- * @return mixed
143
- */
144
- public function getSkyboxCacheCode($productId)
145
- {
146
- if ($this->_sky_cache_code == null) {
147
- /* @var $config Skybox_Core_Model_Config */
148
- $config = Mage::getModel("skyboxcore/config");
149
- $skyboxUser = $config->getSession()->getSkyboxUser();
150
- $country_iso_code = strtoupper($skyboxUser->CartCountryISOCode);
151
- $cache_code = $country_iso_code . "[REPLACE]" . $skyboxUser->CartCurrencyISOCode;
152
- $this->_sky_cache_code = $cache_code;
153
- }
154
-
155
- $result = str_replace('[REPLACE]', $productId, $this->_sky_cache_code);
156
- return $result;
157
- }
158
-
159
- /**
160
- * Return Multi CalculatePrice
161
- *
162
- * @param $url
163
- * @param $data
164
- * @return mixed
165
- * @throws Exception
166
- */
167
- function multiCalculatePrice($url, $data)
168
- {
169
- $ch = curl_init();
170
- curl_setopt($ch, CURLOPT_URL, $url);
171
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
172
- curl_setopt($ch, CURLOPT_POST, 1);
173
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
174
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
175
- $response = curl_exec($ch);
176
-
177
- $response = json_decode($response, true);
178
-
179
- if ($response['StatusCode'] != 'Success') {
180
- throw new \Exception('Missing or invalid data send to MultiCalculate');
181
- }
182
- return $response;
183
- }
184
-
185
- private function isEnable()
186
- {
187
- $isModuleEnable = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
188
- if (!$isModuleEnable) {
189
- return false;
190
- }
191
-
192
- /** @var Skybox_Core_Helper_Allow $allowHelper */
193
- $allowHelper = Mage::helper('skyboxcore/allow');
194
-
195
- if (!$allowHelper->isPriceEnabled()) {
196
- return false;
197
- }
198
-
199
- return true;
200
- }
201
-
202
-
203
  }
1
+ <?php
2
+ /**
3
+ * Skybox Checkout
4
+ *
5
+ * @category Skybox
6
+ * @package Skybox_Catalog
7
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
8
+ */
9
+
10
+ /**
11
+ * New products widget
12
+ *
13
+ * @category Skybox
14
+ * @package Skybox_Catalog
15
+ */
16
+ class Skybox_Catalog_Block_Product_Widget_New extends Mage_Catalog_Block_Product_Widget_New
17
+ {
18
+
19
+ /*
20
+ * @var string $_cache_code
21
+ */
22
+ public $_cache_code = null;
23
+
24
+ public $_sky_cache_code = null;
25
+ // protected $_api;
26
+
27
+ /**
28
+ * Retrieve API Product
29
+ *
30
+ * @return Skybox_Catalog_Model_Api_Product
31
+ */
32
+ protected function _getApi()
33
+ {
34
+ if (null === $this->_api) {
35
+ $this->_api = Mage::getModel('skyboxcatalog/api_product');
36
+ }
37
+ return $this->_api;
38
+ }
39
+
40
+
41
+ /**
42
+ * Initialize block's cache and template settings
43
+ */
44
+ protected function _construct()
45
+ {
46
+ parent::_construct();
47
+ $cache_key = Mage_Catalog_Model_Product::CACHE_TAG . "_" . $this->getCacheCode();
48
+ $this->setAttribute("cache_key", $cache_key);
49
+ if (Mage::getVersion() == '1.9.1') {
50
+ $this->addData(array('cache_lifetime' => null)); // Skip cache generation
51
+ }
52
+ }
53
+
54
+ public function getCacheCode()
55
+ {
56
+ if ($this->_cache_code == null) {
57
+ /* @var $config Skybox_Core_Model_Config */
58
+ $config = Mage::getModel("skyboxcore/config");
59
+ $skyboxUser = $config->getSession()->getSkyboxUser();
60
+ $cache_code = $skyboxUser->CartCountryISOCode . $skyboxUser->CartCityId . $skyboxUser->CartCurrencyISOCode;
61
+ $this->_cache_code = $cache_code;
62
+ }
63
+ Mage::log("[widget/new] Cache Code: " . $cache_code, null, 'cache.log', true);
64
+ return $this->_cache_code;
65
+ }
66
+
67
+ protected function _getProductCollection()
68
+ {
69
+
70
+ return parent::_getProductCollection();
71
+ }
72
+
73
+ protected function _beforeToHtml()
74
+ {
75
+ $result = parent::_beforeToHtml();
76
+ if (!$this->isEnable()) {
77
+ return $result;
78
+ }
79
+ $api_checkout = Mage::getModel('skyboxcheckout/api_checkout');
80
+ $api_checkout->InitializeBarSkybox();
81
+
82
+ $data = $api_checkout->getValueAccessService();
83
+
84
+ $skyBoxUrlClient = Mage::helper('skyboxinternational/data')->getSkyBoxUrlAPI();
85
+ $skyBoxUrlClient = $skyBoxUrlClient . "multiplecalculate";
86
+
87
+ $dataJson = null;
88
+ $multiCalculate = 1;
89
+
90
+ try {
91
+ $products = $this->_getProductCollection();
92
+ foreach ($products as $prod) {
93
+ $product = Mage::getModel('catalog/product')->load($prod->getId());
94
+ $data['listproducts'][] = $this->getUrlService($product);
95
+ $dataJson = json_encode($data);
96
+ }
97
+ $response = $this->multiCalculatePrice($skyBoxUrlClient, $dataJson);
98
+ } catch (\Exception $e) {
99
+ $multiCalculate = 0;
100
+ }
101
+
102
+ Mage::unregister('skybox_multicalculate');
103
+ Mage::register('skybox_multicalculate', $multiCalculate);
104
+ return $result;
105
+ }
106
+
107
+ /**
108
+ * @param $product
109
+ * @return array|string
110
+ */
111
+ public function getUrlService($product)
112
+ {
113
+ $type = $product->getTypeId();
114
+ $template = '';
115
+
116
+ switch ($type) {
117
+ case 'simple':
118
+ $template = $this->_getApi()->getUrl($product->getId(), null, $product->getFinalPrice(),
119
+ $product->getTypeId());
120
+ break;
121
+ case 'configurable':
122
+ $template = $this->_getApi()->getUrl($product->getId(), null, $product->getFinalPrice(),
123
+ $product->getTypeId());
124
+ break;
125
+ case 'bundle':
126
+ $template = $this->_getApi()->getUrl($product, null, $product->getFinalPrice(), 'simple');
127
+ break;
128
+ }
129
+
130
+ if (is_array($template)) {
131
+ $productId = $template['htmlobjectid'];
132
+ $cache_code = $this->getSkyboxCacheCode($productId);
133
+ $template['htmlobjectid'] = $cache_code;
134
+ }
135
+ return $template;
136
+ }
137
+
138
+ /**
139
+ * Return the Skybox Cache code
140
+ *
141
+ * @param $productId
142
+ * @return mixed
143
+ */
144
+ public function getSkyboxCacheCode($productId)
145
+ {
146
+ if ($this->_sky_cache_code == null) {
147
+ /* @var $config Skybox_Core_Model_Config */
148
+ $config = Mage::getModel("skyboxcore/config");
149
+ $skyboxUser = $config->getSession()->getSkyboxUser();
150
+ $country_iso_code = strtoupper($skyboxUser->CartCountryISOCode);
151
+ $cache_code = $country_iso_code . "[REPLACE]" . $skyboxUser->CartCurrencyISOCode;
152
+ $this->_sky_cache_code = $cache_code;
153
+ }
154
+
155
+ $result = str_replace('[REPLACE]', $productId, $this->_sky_cache_code);
156
+ return $result;
157
+ }
158
+
159
+ /**
160
+ * Return Multi CalculatePrice
161
+ *
162
+ * @param $url
163
+ * @param $data
164
+ * @return mixed
165
+ * @throws Exception
166
+ */
167
+ function multiCalculatePrice($url, $data)
168
+ {
169
+ $ch = curl_init();
170
+ curl_setopt($ch, CURLOPT_URL, $url);
171
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
172
+ curl_setopt($ch, CURLOPT_POST, 1);
173
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
174
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
175
+ $response = curl_exec($ch);
176
+
177
+ $response = json_decode($response, true);
178
+
179
+ if ($response['StatusCode'] != 'Success') {
180
+ throw new \Exception('Missing or invalid data send to MultiCalculate');
181
+ }
182
+ return $response;
183
+ }
184
+
185
+ private function isEnable()
186
+ {
187
+ $isModuleEnable = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
188
+ if (!$isModuleEnable) {
189
+ return false;
190
+ }
191
+
192
+ /** @var Skybox_Core_Helper_Allow $allowHelper */
193
+ $allowHelper = Mage::helper('skyboxcore/allow');
194
+
195
+ if (!$allowHelper->isPriceEnabled()) {
196
+ return false;
197
+ }
198
+
199
+ return true;
200
+ }
201
+
202
+
203
  }
app/code/community/Skybox/Catalog/Model/Api/Product.php CHANGED
@@ -1,940 +1,940 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Catalog
5
- *
6
- * @category Skybox
7
- * @package Skybox_Catalog
8
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
11
- {
12
-
13
- /**
14
- * Model instance
15
- * @var Skybox_Core_Model_Config
16
- */
17
- /*protected $_config = null;
18
-
19
- protected $_typeConfig = "skyboxcore/config";
20
-
21
- protected function getConfig()
22
- {
23
- if(null === $this->_config)
24
- $this->_config = Mage::getModel($this->_typeConfig);
25
- }*/
26
-
27
- /**
28
- * Model instance
29
- * @var Mage_Core_Catalog_Model_Product
30
- */
31
- protected $_product = null;
32
-
33
- protected $_productResult = null;
34
-
35
- protected $_typeProduct = "catalog/product";
36
-
37
- protected $_product_id = null;
38
- protected $_product_data = null;
39
-
40
- public function getProductId()
41
- {
42
- if ($this->_product_id != null) {
43
- return $this->_product_id;
44
- }
45
- return null;
46
- }
47
-
48
- public function getProductData()
49
- {
50
- if ($this->_product_data != null) {
51
- return $this->_product_data;
52
- }
53
- return null;
54
- }
55
-
56
-
57
- /**
58
- * Calculate Price
59
- *
60
- * @param int|Mage_Catalog_Model_Product $product
61
- * @param Varien_Object $request
62
- * @param float $finalPrice
63
- * @param string $type
64
- * @param int $objectId
65
- * @return Mage_Checkout_Model_Cart
66
- */
67
- public function CalculatePrice($product, $request, $finalPrice = null, $type = null, $objectId = 1)
68
- {
69
- // Mage::log("--------------------------------------", null, 'verify.log', true);
70
-
71
- //Mage::log(print_r('Product', true), null, 'tracer.log', true);
72
-
73
- //if ($this->getErrorAuthenticate() && !$this->getLocationAllow()) {
74
- if (!$this->getLocationAllow()) {
75
- return $this;
76
- }
77
-
78
- if (!is_object($product)) {
79
- $storeId = Mage::app()->getStore()->getStoreId();
80
- $product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($product);
81
- }
82
- // Mage::log("CalculatePrice '". $product->getTypeId()."'", null, 'verify.log', true);
83
- // Mage::log("CalculatePrice FinalPrice '". $product->getFinalPrice()."'", null, 'verify.log', true);
84
-
85
- $productId = $product->getId();
86
- $_data = null;
87
-
88
- if ($type == null) {
89
- $type = $product->getTypeId();
90
- }
91
-
92
- $defaultSwitch = false;
93
- switch ($type) {
94
- case 'simple':
95
- $finalPrice = isset($finalPrice) ? $finalPrice : $product->getFinalPrice();
96
- $category_id = $product->getSkyboxCategoryId();
97
- $category_id = isset($category_id) ? $category_id : $this->getCommodityFromCategory($product);
98
- $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
99
-
100
- $_data = array(
101
- 'object_id' => 1,
102
- 'name' => $product->getName(),
103
- 'sku' => $product->getSku(),
104
- 'category_id' => $category_id,
105
- 'final_price' => $finalPrice,
106
- 'weight' => ($product->getWeight()) ? $product->getWeight() : 1,
107
- 'image_url' => $product->getImageUrl(),
108
- 'typeProduct' => $type,
109
- 'VolWeight' => $volWeight,
110
- 'merchantproductid' => $productId
111
- );
112
- // $this->_calculatePrice($_data);
113
- break;
114
-
115
- case 'configurable':
116
-
117
- // $finalPrice = isset($finalPrice) ? $finalPrice : null;
118
- $finalPrice = isset($finalPrice) ? $finalPrice : $product->getFinalPrice();
119
- $weight = $product->getTypeInstance(true)->getWeight($product);
120
- $sku = $product->getSku();
121
-
122
- // Mage::log("CalculatePrice configurable: '" . $finalPrice."'", null, 'verify.log', true);
123
-
124
- if ($request) {
125
- $childProduct = Mage::getModel('catalog/product_type_configurable')
126
- ->getProductByAttributes($request->getData('super_attribute'), $product);
127
-
128
- $productId = $childProduct->getId();
129
- $sku = $childProduct->getSku();
130
-
131
- }
132
-
133
- $parentItem = null;
134
-
135
- if (isset($request) && !$finalPrice) {
136
- // Mage::log("CalculatePrice candidate INI ", null, 'verify.log', true);
137
- $_finalPrice = 0;
138
-
139
- $cartCandidates = $product->getTypeInstance(true)
140
- ->prepareForCartAdvanced($request, $product, 'full');
141
-
142
- foreach ($cartCandidates as $candidate) {
143
- // Child items can be sticked together only within their parent
144
- $stickWithinParent = $candidate->getParentProductId() ? $parentItem : null;
145
- $candidate->setStickWithinParent($stickWithinParent);
146
-
147
- $candidate_getFinalPrice = $candidate->getPriceModel()->getFinalPrice($request->getQty(),
148
- $product);
149
- // Mage::log("CalculatePrice candidate getFinalPrice: " . $candidate_getFinalPrice, null,
150
- // 'skyboxcheckout.log', false);
151
-
152
- $_finalPrice = $_finalPrice + $candidate_getFinalPrice;
153
- if ($_finalPrice) {
154
- break;
155
- }
156
- }
157
- $finalPrice = $_finalPrice;
158
- // Mage::log("CalculatePrice candidate FIN", null, 'verify.log', true);
159
- }
160
-
161
- /* Weight start*/
162
- /*
163
- $options = array();
164
- // Get any super_attribute settings we need
165
- $productAttributesOptions = $product->getTypeInstance(true)->getConfigurableOptions($product);
166
- foreach ($productAttributesOptions as $productAttributeOption) {
167
- $options[$product->getId()] = array();
168
- foreach ($productAttributeOption as $optionValues) {
169
- $val = ($optionValues['option_title']);
170
- $options[$product->getId()][] = array (
171
- $optionValues['sku'] => $optionValues['attribute_code']."=".$val
172
-
173
- ) ;
174
- }
175
-
176
- }
177
- $prod_weight = 1;
178
- if(!empty($optionValues)) {
179
- $a = Mage::getModel('catalog/product')->loadByAttribute('sku',$optionValues['sku']);
180
- //$product->load($product->getIdBySku($optionValues['sku']));
181
- $prod_weight = $a->getWeight();
182
- echo ":::".$prod_weight."::";
183
- }
184
- */
185
- /* Weight end*/
186
-
187
- $category_id = $product->getSkyboxCategoryId();
188
- $category_id = isset($category_id) ? $category_id : $this->getCommodityFromCategory($product);
189
-
190
- $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
191
- $_data = array(
192
- 'object_id' => 1,
193
- 'name' => $product->getName(),
194
- //'sku' => $product->getSku(),
195
- 'sku' => $sku,
196
- 'category_id' => $category_id,
197
- 'final_price' => $finalPrice,
198
- 'weight' => $weight ? $weight : 1,
199
- 'image_url' => $product->getImageUrl(),
200
- 'typeProduct' => $type,
201
- 'VolWeight' => $volWeight,
202
- 'merchantproductid' => $productId
203
- );
204
-
205
- // $this->_calculatePrice($_data);
206
- break;
207
-
208
- case 'bundle':
209
- //$_finalPrice = $product->getTotalBundleItemsPrice($product, $request->getQty());
210
- //$finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
211
-
212
- //Mage::log(print_r($product, true), null, 'cart.log', true);
213
- //Mage::log("Product: [" . $product->getId() . "] - Class: " . get_class($product), null, 'skyboxcheckout.log', false);
214
-
215
- //Mage::log(print_r($request, true), null, 'cart.log', true);
216
-
217
- $finalPrice = isset($finalPrice) ? $finalPrice : null;
218
- $weight = $product->getTypeInstance(true)->getWeight($product);
219
- $sku = $product->getSku();
220
-
221
- //if (isset($request) && !$finalPrice) {
222
- if (isset($request)) {
223
-
224
- $parentItem = null;
225
- $_finalPrice = null;
226
- $_weight = 0;
227
-
228
- $cartCandidates = $product->getTypeInstance(true)
229
- ->prepareForCartAdvanced($request, $product, 'full');
230
-
231
- foreach ($cartCandidates as $candidate) {
232
- // Child items can be sticked together only within their parent
233
- $stickWithinParent = $candidate->getParentProductId() ? $parentItem : null;
234
- $candidate->setStickWithinParent($stickWithinParent);
235
-
236
- if (!$_finalPrice) {
237
- $_finalPrice = $candidate->getPriceModel()->getFinalPrice($request->getQty(), $product);
238
- //break;
239
- }
240
- //$_weight = $_weight + $candidate->getPriceModel()->getWeight();
241
- $_weight = $_weight + $candidate->getWeight();
242
- }
243
-
244
- $finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
245
- if ($_weight > 0) {
246
- $weight = $_weight;
247
- }
248
- }
249
-
250
- //Mage::log("weight: " . $weight, null, 'cart.log', true);
251
- //Mage::log("sku: " . $sku, null, 'cart.log', true);
252
-
253
- $category_id = $product->getSkyboxCategoryId();
254
- $category_id = isset($category_id) ? $category_id : $this->getCommodityFromCategory($product);
255
-
256
- $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
257
- $_data = array(
258
- 'object_id' => 1,
259
- 'name' => $product->getName(),
260
- 'sku' => $sku,
261
- 'category_id' => $category_id,
262
- 'final_price' => $finalPrice,
263
- 'weight' => ($weight) ? $weight : 1,
264
- 'image_url' => $product->getImageUrl(),
265
- 'typeProduct' => $type,
266
- 'VolWeight' => $volWeight,
267
- 'merchantproductid' => $productId
268
- );
269
- // $this->_calculatePrice($_data);
270
- break;
271
-
272
- case 'bundle_fixed':
273
-
274
- // @Note: It should be rewrite!!
275
- $finalPrice = isset($finalPrice) ? $finalPrice : null;
276
- $skyboxCategoryId = $product->getSkyboxCategoryId();
277
- $weight = $product->getTypeInstance(true)->getWeight($product);
278
- $sku = $product->getSku();
279
-
280
- $selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection(
281
- $product->getTypeInstance(true)->getOptionsIds($product), $product
282
- );
283
-
284
- $_finalPrice = null;
285
- $_weight = 0;
286
- $_skyboxCategoryId = null;
287
-
288
- foreach ($selectionCollection as $option) {
289
- //if ($option->getData('is_default') == 0) continue;
290
-
291
- $product_simple = Mage::getModel('catalog/product')
292
- ->load($option->getId());
293
-
294
- $_finalPrice = $_finalPrice + $product_simple->getFinalPrice();
295
- $_weight = $_weight + $product_simple->getWeight();
296
-
297
- if (!$_skyboxCategoryId) { // Set SkyboxCategory from the first Simple Product
298
- // $_skyboxCategoryId = $product_simple->getSkyboxCategoryId();
299
- $_skyboxCategoryId = $product->getSkyboxCategoryId();
300
- $_skyboxCategoryId = isset($_skyboxCategoryId) ? $_skyboxCategoryId : $this->getCommodityFromCategory($product);
301
- }
302
- }
303
-
304
- $finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
305
-
306
- if (!$weight) {
307
- $weight = $_weight;
308
- }
309
-
310
- if (!$skyboxCategoryId) {
311
- $skyboxCategoryId = $_skyboxCategoryId;
312
- }
313
-
314
- /*Mage::log("-------------------------", null, 'cart.log', true);
315
- Mage::log("Product: " . $product->getName(), null, 'cart.log', true);
316
- Mage::log("Price: " . $finalPrice, null, 'cart.log', true);
317
- Mage::log("weight: " . $weight, null, 'cart.log', true);
318
- Mage::log("sku: " . $sku, null, 'cart.log', true);*/
319
-
320
-
321
- $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
322
- $_data = array(
323
- 'object_id' => 1,
324
- 'name' => $product->getName(),
325
- 'sku' => $sku,
326
- 'category_id' => $skyboxCategoryId,
327
- 'final_price' => $finalPrice,
328
- 'weight' => ($weight) ? $weight : 1,
329
- 'image_url' => $product->getImageUrl(),
330
- 'typeProduct' => $type,
331
- 'VolWeight' => $volWeight,
332
- 'merchantproductid' => $productId
333
- );
334
-
335
- // $this->_calculatePrice($_data);
336
- break;
337
-
338
- default:
339
- Mage::log("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice",
340
- null, 'verify.log', false);
341
- trigger_error("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice");
342
- $defaultSwitch = true;
343
- break;
344
- }
345
-
346
- if (!$defaultSwitch) {
347
- //Mage::log(print_r('EnableTax: ', true), null, 'tracer.log', true);
348
- //Mage::log(print_r($this->getEnabledAddSumTaxToPrice(), true), null, 'tracer.log', true);
349
- if ($this->getEnabledAddSumTaxToPrice()) {
350
- $store = Mage::app()->getStore('default');
351
- $taxCalculation = Mage::getModel('tax/calculation');
352
- $request = $taxCalculation->getRateRequest(null, null, null, $store);
353
- // $product = Mage::registry('current_product');
354
- $taxClassId = $product->getTaxClassId();
355
- $percentTax = $taxCalculation->getRate($request->setProductClassId($taxClassId));
356
-
357
- $taxPrice = $_data['final_price'] * ($percentTax / 100);
358
-
359
- //Mage::log(print_r('Id product: ' . $product->getId(), true), null, 'tracer.log', true);
360
- //Mage::log(print_r('$taxPrice: ' . $taxPrice, true), null, 'tracer.log', true);
361
- //Mage::log(print_r('price: ' . $_data['final_price'], true), null, 'tracer.log', true);
362
- //Mage::log(print_r('$taxPrice+price: ' . ($taxPrice + $_data['final_price']), true), null, 'tracer.log', true);
363
- $comissionSkybox = $_data['final_price'] * (10 / 100);
364
- //Mage::log(print_r('comision skybox: ' . ($comissionSkybox), true), null, 'tracer.log', true);
365
- //Mage::log(print_r('price+comision skybox: ' . ($_data['final_price'] + $comissionSkybox), true), null, 'tracer.log', true);
366
- //Mage::log(print_r('$taxPrice+price+comision: ' . ($taxPrice + $_data['final_price'] + $comissionSkybox), true), null, 'tracer.log', true);
367
- //Mage::log(print_r('comision true: ' . (($taxPrice + $_data['final_price']) * (10 / 100)), true), null, 'tracer.log', true);
368
- $priceReally = ($taxPrice + $_data['final_price']) + ($taxPrice + $_data['final_price']) * (10 / 100);
369
- //Mage::log(print_r('$taxPrice+price+comision true: ' . ($priceReally), true), null, 'tracer.log', true);
370
-
371
-
372
- $_data['final_price'] = $_data['final_price'] + $taxPrice;
373
- }
374
-
375
- //Mage::log(print_r('####################### Data produc params #######################', true), null, 'tracer.log', true);
376
- //Mage::log(print_r($_data, true), null, 'tracer.log', true);
377
- // $this->_calculatePrice($_data);
378
- try {
379
- $this->_calculatePrice($_data);
380
- } catch (\Exception $e) {
381
- Mage::log($e->getMessage(), null, 'skyboxcheckout.log', false);
382
- }
383
- }
384
-
385
- // Mage::log("Product Class: " . get_class($product), null, 'verify.log', false);
386
- // Mage::log("Product Type: " . $type, null, 'verify.log', false);
387
- // Mage::log(print_r($_data, true), null, 'verify.log', false);
388
-
389
- $this->_product_data = $_data;
390
- $this->_product_id = $productId;
391
- return $this;
392
- }
393
-
394
- private function _calculatePrice($data)
395
- {
396
- $msg = sprintf("CalculatePrice: [%s] - [%s] - [%s] - [Category_id: %s] - [Price: %s] - [weight: %s] - [typeProduct: %s]",
397
- $data['object_id'],
398
- $data['sku'],
399
- $data['name'],
400
- $data['category_id'],
401
- $data['final_price'],
402
- $data['weight'],
403
- $data['typeProduct']
404
- );
405
-
406
- Mage::log($msg, null, 'skyboxcheckout.log', false);
407
-
408
- $params = array(
409
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
410
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
411
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
412
- 'htmlobjectid' => $data['object_id'],
413
- 'storeproductcode' => $data['sku'],
414
- 'storeproductname' => $data['name'],
415
- 'storeproductcategory' => $data['category_id'],
416
- 'storeproductprice' => $data['final_price'],
417
- //'storeproductprice' => $product->getFinalPrice(),
418
- 'weight' => ($data['weight']) ? $data['weight'] : 1,
419
- 'weightunit' => $this->getWeightUnit(),
420
- 'storeproductimgurl' => $data['image_url'],
421
- 'merchantproductid' => $data['merchantproductid']
422
- );
423
- $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_CALCULATE, $params);
424
- }
425
-
426
- public function HtmlTemplateButton()
427
- {
428
- if (!$this->getErrorAuthenticate() && $this->_getApi()->getLocationAllow()) {
429
- $params = array(
430
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
431
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
432
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi()
433
- );
434
-
435
- $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_GET_TEMPLATE_BUTTON, $params);
436
- }
437
-
438
- return $this;
439
- }
440
-
441
- public function GetTemplateProduct()
442
- {
443
- Mage::log("ApiProduct ", null, 'orden.log', true);
444
- if (!$this->getErrorAuthenticate() && $this->_getApi()->getLocationAllow() && !$this->_getApi()->ErrorServiceNotController()) {
445
- //if (!$this->getErrorAuthenticate() && $this->_getApi()->getLocationAllow() && !$this->_getApi()->ErrorService()) {
446
- $_productResult = $this->getResponse();
447
- $template = $_productResult->TooltipButtonTemplate;
448
- return $template;
449
- // $templateButton = $this->getHtmlTemplateButton();
450
- // if (empty($templateButton))
451
- // $this->HtmlTemplateButton();
452
- //
453
- // /*if($_productResult->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_BUTTONERROR})
454
- // {*/
455
- // //Mage::log("_productResult--->" . json_decode($_productResult));
456
- // $templateButton = $this->getHtmlTemplateButton();
457
- // if (!empty($templateButton)) {
458
- // $template = $this->getHtmlTemplateButton();
459
- //// Mage::log(print_r('response template buttom', true), null, 'tracer.log', true);
460
- //// Mage::log(print_r($_productResult, true), null, 'tracer.log', true);
461
- // foreach ($_productResult as $key => $value) {
462
- // $template = str_replace('{' . $key . '}', $value, $template);
463
- // }
464
- //
465
- // // Just for {Block} crap
466
- // $template = str_replace('{Block}', '', $template);
467
- //
468
- // return $template;
469
- // }
470
- //
471
- // $displayUSD = "''"; //CartCountryIso
472
- // /*}else{
473
- // return "Plantilla de error";
474
- // }*/
475
- // //Mage::log(get_class($this) . " GetTemplateProduct() ", null, 'cart.log', true);
476
- } else {
477
- $template = '<div class="skx_content_button"></div>';
478
- return $template;
479
- }
480
- return "";
481
- }
482
-
483
- protected $_isUSD = null;
484
-
485
- public function IsUSD()
486
- {
487
- if (null == $this->_isUSD) {
488
- $this->_isUSD = ($this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_CART_CURRENCY_ISO,
489
- "") == Skybox_Core_Model_Config::SKYBOX_CURRENCY_USD);
490
- }
491
- return $this->_isUSD;
492
- }
493
-
494
- public function getCustoms()
495
- {
496
- return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_CUSTOMS, "0");
497
- }
498
-
499
- public function getShipping()
500
- {
501
- return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_SHIPPING, "0");
502
- }
503
-
504
- public function getInsurance()
505
- {
506
- return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_INSURANCE, "0");
507
- }
508
-
509
- public function getPrice()
510
- {
511
- return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_PRICE, "0");
512
- }
513
-
514
- public function getTotalPrice()
515
- {
516
- return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_TOTAL, "0");
517
- }
518
-
519
- public function getCustomsUSD()
520
- {
521
- return $this->IsUSD() ? $this->getCustoms() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_CUSTOMS_USD,
522
- "0");
523
- }
524
-
525
- public function getShippingUSD()
526
- {
527
- return $this->IsUSD() ? $this->getShipping() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_SHIPPING_USD,
528
- "0");
529
- }
530
-
531
- public function getInsuranceUSD()
532
- {
533
- return $this->IsUSD() ? $this->getInsurance() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_INSURANCE_USD,
534
- "0");
535
- }
536
-
537
- public function getPriceUSD()
538
- {
539
- return $this->IsUSD() ? $this->getPrice() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_PRICE_USD,
540
- "0");
541
- }
542
-
543
- public function getTotalPriceUSD()
544
- {
545
- return $this->IsUSD() ? $this->getTotalPrice() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_TOTAL_USD,
546
- "0");
547
- }
548
-
549
- public function getGuidSkybox()
550
- {
551
- return $this->_getApi()->getGuidApi();
552
- }
553
-
554
- public function getBasePrice()
555
- {
556
- return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_BASE_PRICE, "0");
557
- }
558
-
559
- public function getBasePriceUSD()
560
- {
561
- return $this->IsUSD() ? $this->getBasePrice() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_BASE_PRICE_USD,
562
- "0");
563
- }
564
-
565
- public function getAdjustPrice()
566
- {
567
- return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ADJUST_PRICE, "0");
568
- }
569
-
570
- public function getAdjustPriceUSD()
571
- {
572
- return $this->IsUSD() ? $this->getAdjustPrice() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ADJUST_PRICE_USD,
573
- "0");
574
- }
575
-
576
- public function getAdjustLabel()
577
- {
578
- return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_LABEL_ADJUST, "");
579
- }
580
-
581
- /*Async Ini*/
582
-
583
- public function getUrl($product, $request, $finalPrice = null, $type = null, $objectId = 1)
584
- {
585
- Mage::log("ApiProductCatalog ", null, 'orden.log', true);
586
-
587
- //Mage::log(print_r('Product', true), null, 'tracer.log', true);
588
-
589
- //if ($this->getErrorAuthenticate() && !$this->getLocationAllow()) {
590
- if (!$this->getLocationAllow()) {
591
- return $this;
592
- }
593
-
594
- if (!is_object($product)) {
595
- $storeId = Mage::app()->getStore()->getStoreId();
596
- $product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($product);
597
- }
598
-
599
- $productId = $product->getId();
600
- $_data = null;
601
-
602
- if ($type == null) {
603
- $type = $product->getTypeId();
604
- }
605
-
606
- $defaultSwitch = true;
607
- switch ($type) {
608
- case 'simple':
609
- $finalPrice = isset($finalPrice) ? $finalPrice : $product->getFinalPrice();
610
- $category_id = $product->getSkyboxCategoryId();
611
- $category_id = isset($category_id) ? $category_id : $this->getCommodityFromCategory($product);
612
- $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
613
-
614
- $_data = array(
615
- 'object_id' => $product->getId(),
616
- 'name' => $product->getName(),
617
- 'sku' => $product->getSku(),
618
- 'category_id' => $category_id,
619
- 'final_price' => $finalPrice,
620
- 'weight' => ($product->getWeight()) ? $product->getWeight() : 1,
621
- 'image_url' => $product->getImageUrl(),
622
- 'typeProduct' => $type,
623
- 'VolWeight' => $volWeight,
624
- 'merchantproductid' => $productId
625
- );
626
- // $this->_calculatePrice($_data);
627
- break;
628
-
629
- case 'configurable':
630
-
631
- $finalPrice = isset($finalPrice) ? $finalPrice : null;
632
- $weight = $product->getTypeInstance(true)->getWeight($product);
633
- $sku = $product->getSku();
634
-
635
- Mage::log("CalculatePrice configurable : " . $finalPrice, null, 'skyboxcheckout.log', false);
636
-
637
- if ($request) {
638
- $childProduct = Mage::getModel('catalog/product_type_configurable')
639
- ->getProductByAttributes($request->getData('super_attribute'), $product);
640
-
641
- $productId = $childProduct->getId();
642
- $sku = $childProduct->getSku();
643
-
644
- }
645
-
646
- $parentItem = null;
647
-
648
- if (isset($request) && !$finalPrice) {
649
- Mage::log("CalculatePrice candidate INI", null, 'skyboxcheckout.log', false);
650
- $_finalPrice = 0;
651
-
652
- $cartCandidates = $product->getTypeInstance(true)
653
- ->prepareForCartAdvanced($request, $product, 'full');
654
-
655
- foreach ($cartCandidates as $candidate) {
656
- // Child items can be sticked together only within their parent
657
- $stickWithinParent = $candidate->getParentProductId() ? $parentItem : null;
658
- $candidate->setStickWithinParent($stickWithinParent);
659
-
660
- $candidate_getFinalPrice = $candidate->getPriceModel()->getFinalPrice($request->getQty(),
661
- $product);
662
- Mage::log("CalculatePrice candidate getFinalPrice: " . $candidate_getFinalPrice, null,
663
- 'skyboxcheckout.log', false);
664
-
665
- $_finalPrice = $_finalPrice + $candidate_getFinalPrice;
666
- if ($_finalPrice) {
667
- break;
668
- }
669
- }
670
- $finalPrice = $_finalPrice;
671
- Mage::log("CalculatePrice candidate FIN", null, 'skyboxcheckout.log', false);
672
- }
673
-
674
- $category_id = $product->getSkyboxCategoryId();
675
- $category_id = isset($category_id) ? $category_id : $this->getCommodityFromCategory($product);
676
-
677
- $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
678
-
679
- $_data = array(
680
- 'object_id' => $product->getId(),
681
- 'name' => $product->getName(),
682
- //'sku' => $product->getSku(),
683
- 'sku' => $sku,
684
- 'category_id' => $category_id,
685
- 'final_price' => $finalPrice,
686
- 'weight' => $weight ? $weight : 1,
687
- 'image_url' => $product->getImageUrl(),
688
- 'typeProduct' => $type,
689
- 'VolWeight' => $volWeight,
690
- 'merchantproductid' => $productId
691
- );
692
-
693
- // $this->_calculatePrice($_data);
694
- break;
695
-
696
- case 'bundle':
697
- //$_finalPrice = $product->getTotalBundleItemsPrice($product, $request->getQty());
698
- //$finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
699
-
700
- //Mage::log(print_r($product, true), null, 'cart.log', true);
701
- //Mage::log("Product: [" . $product->getId() . "] - Class: " . get_class($product), null, 'skyboxcheckout.log', false);
702
-
703
- //Mage::log(print_r($request, true), null, 'cart.log', true);
704
-
705
- $finalPrice = isset($finalPrice) ? $finalPrice : null;
706
- $weight = $product->getTypeInstance(true)->getWeight($product);
707
- $sku = $product->getSku();
708
-
709
- //if (isset($request) && !$finalPrice) {
710
- if (isset($request)) {
711
-
712
- $parentItem = null;
713
- $_finalPrice = null;
714
- $_weight = 0;
715
-
716
- $cartCandidates = $product->getTypeInstance(true)
717
- ->prepareForCartAdvanced($request, $product, 'full');
718
-
719
- foreach ($cartCandidates as $candidate) {
720
- // Child items can be sticked together only within their parent
721
- $stickWithinParent = $candidate->getParentProductId() ? $parentItem : null;
722
- $candidate->setStickWithinParent($stickWithinParent);
723
-
724
- if (!$_finalPrice) {
725
- $_finalPrice = $candidate->getPriceModel()->getFinalPrice($request->getQty(), $product);
726
- //break;
727
- }
728
- //$_weight = $_weight + $candidate->getPriceModel()->getWeight();
729
- $_weight = $_weight + $candidate->getWeight();
730
- }
731
-
732
- $finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
733
- if ($_weight > 0) {
734
- $weight = $_weight;
735
- }
736
- }
737
-
738
- //Mage::log("weight: " . $weight, null, 'cart.log', true);
739
- //Mage::log("sku: " . $sku, null, 'cart.log', true);
740
-
741
- $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
742
- $_data = array(
743
- 'object_id' => $product->getId(),
744
- 'name' => $product->getName(),
745
- 'sku' => $sku,
746
- 'category_id' => $product->getSkyboxCategoryId(),
747
- 'final_price' => $finalPrice,
748
- 'weight' => ($weight) ? $weight : 1,
749
- 'image_url' => $product->getImageUrl(),
750
- 'typeProduct' => $type,
751
- 'VolWeight' => $volWeight,
752
- 'merchantproductid' => $productId
753
- );
754
- // $this->_calculatePrice($_data);
755
- break;
756
-
757
- case 'bundle_fixed':
758
- $finalPrice = isset($finalPrice) ? $finalPrice : null;
759
- $skyboxCategoryId = $product->getSkyboxCategoryId();
760
- $weight = $product->getTypeInstance(true)->getWeight($product);
761
- $sku = $product->getSku();
762
-
763
- $selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection(
764
- $product->getTypeInstance(true)->getOptionsIds($product), $product
765
- );
766
-
767
- $_finalPrice = null;
768
- $_weight = 0;
769
- $_skyboxCategoryId = null;
770
-
771
- foreach ($selectionCollection as $option) {
772
- //if ($option->getData('is_default') == 0) continue;
773
-
774
- $product_simple = Mage::getModel('catalog/product')
775
- ->load($option->getId());
776
-
777
- $_finalPrice = $_finalPrice + $product_simple->getFinalPrice();
778
- $_weight = $_weight + $product_simple->getWeight();
779
-
780
- if (!$_skyboxCategoryId) { // Set SkyboxCategory from the first Simple Product
781
- $_skyboxCategoryId = $product_simple->getSkyboxCategoryId();
782
- }
783
- }
784
-
785
- $finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
786
-
787
- if (!$weight) {
788
- $weight = $_weight;
789
- }
790
-
791
- if (!$skyboxCategoryId) {
792
- $skyboxCategoryId = $_skyboxCategoryId;
793
- }
794
-
795
- /*Mage::log("-------------------------", null, 'cart.log', true);
796
- Mage::log("Product: " . $product->getName(), null, 'cart.log', true);
797
- Mage::log("Price: " . $finalPrice, null, 'cart.log', true);
798
- Mage::log("weight: " . $weight, null, 'cart.log', true);
799
- Mage::log("sku: " . $sku, null, 'cart.log', true);*/
800
-
801
- $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
802
- $_data = array(
803
- 'object_id' => $product->getId(),
804
- 'name' => $product->getName(),
805
- 'sku' => $sku,
806
- 'category_id' => $skyboxCategoryId,
807
- 'final_price' => $finalPrice,
808
- 'weight' => ($weight) ? $weight : 1,
809
- 'image_url' => $product->getImageUrl(),
810
- 'typeProduct' => $type,
811
- 'VolWeight' => $volWeight,
812
- 'merchantproductid' => $productId
813
- );
814
-
815
- // $this->_calculatePrice($_data);
816
- break;
817
-
818
- default:
819
- Mage::log("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice",
820
- null, 'skyboxcheckout.log', false);
821
- trigger_error("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice");
822
- $defaultSwitch = true;
823
- break;
824
- }
825
-
826
- if (!$defaultSwitch) {
827
- //Mage::log(print_r('EnableTax: ', true), null, 'tracer.log', true);
828
- //Mage::log(print_r($this->getEnabledAddSumTaxToPrice(), true), null, 'tracer.log', true);
829
- if ($this->getEnabledAddSumTaxToPrice()) {
830
- $store = Mage::app()->getStore('default');
831
- $taxCalculation = Mage::getModel('tax/calculation');
832
- $request = $taxCalculation->getRateRequest(null, null, null, $store);
833
- // $product = Mage::registry('current_product');
834
- $taxClassId = $product->getTaxClassId();
835
- $percentTax = $taxCalculation->getRate($request->setProductClassId($taxClassId));
836
-
837
- $taxPrice = $_data['final_price'] * ($percentTax / 100);
838
-
839
- //Mage::log(print_r('Id product: ' . $product->getId(), true), null, 'tracer.log', true);
840
- //Mage::log(print_r('$taxPrice: ' . $taxPrice, true), null, 'tracer.log', true);
841
- //Mage::log(print_r('price: ' . $_data['final_price'], true), null, 'tracer.log', true);
842
- //Mage::log(print_r('$taxPrice+price: ' . ($taxPrice + $_data['final_price']), true), null, 'tracer.log', true);
843
- $comissionSkybox = $_data['final_price'] * (10 / 100);
844
- //Mage::log(print_r('comision skybox: ' . ($comissionSkybox), true), null, 'tracer.log', true);
845
- //Mage::log(print_r('price+comision skybox: ' . ($_data['final_price'] + $comissionSkybox), true), null, 'tracer.log', true);
846
- //Mage::log(print_r('$taxPrice+price+comision: ' . ($taxPrice + $_data['final_price'] + $comissionSkybox), true), null, 'tracer.log', true);
847
- //Mage::log(print_r('comision true: ' . (($taxPrice + $_data['final_price']) * (10 / 100)), true), null, 'tracer.log', true);
848
- $priceReally = ($taxPrice + $_data['final_price']) + ($taxPrice + $_data['final_price']) * (10 / 100);
849
- //Mage::log(print_r('$taxPrice+price+comision true: ' . ($priceReally), true), null, 'tracer.log', true);
850
- $_data['final_price'] = $_data['final_price'] + $taxPrice;
851
- }
852
-
853
- //Mage::log(print_r('####################### Data produc params #######################', true), null, 'tracer.log', true);
854
- //Mage::log(print_r($_data, true), null, 'tracer.log', true);
855
- try {
856
- $this->_calculatePrice($_data);
857
- } catch (\Exception $e) {
858
- Mage::log($e->getMessage(), null, 'skyboxcheckout.log', false);
859
- }
860
-
861
- }
862
-
863
- Mage::log("Product Class: " . get_class($product), null, 'skyboxcheckout.log', false);
864
- Mage::log("Product Type: " . $type, null, 'skyboxcheckout.log', false);
865
- Mage::log(print_r($_data, true), null, 'skyboxcheckout.log', false);
866
-
867
- $data = $this->_callServiceSky($_data);
868
- /*var_dump($this); exit;
869
- $this->_product_data = $_data;
870
- $this->_product_id = $productId;
871
- $apiData = $this->_api;
872
- var_dump($apiData); exit;*/
873
- return $data;
874
- }
875
-
876
- /**
877
- * Return the Commodity from Category or Root
878
- *
879
- * @param $product
880
- * @return int
881
- */
882
- public function getCommodityFromCategory($product)
883
- {
884
- $result = 0;
885
-
886
- try {
887
- $categoryIds = $product->getCategoryIds();
888
-
889
- if (count($categoryIds)) {
890
- $categoryId = $categoryIds[0];
891
- $category = Mage::getModel('catalog/category')->load($categoryId);
892
- $result = $category->getSkyboxCategoryIdSelect();
893
- }
894
-
895
- if (empty($result)) {
896
- $categoryId = Mage::app()->getStore()->getRootCategoryId();
897
- $category = Mage::getModel('catalog/category')->load($categoryId);
898
- $result = $category->getSkyboxCategoryIdSelect();
899
- }
900
-
901
- $result = isset($result) ? $result : 0;
902
-
903
- } catch (\Exception $e) {
904
- \error_log("catch exception product_: " . $product . PHP_EOL, 3, BP . '/var/log/magento19.trace.log');
905
- }
906
-
907
- return $result;
908
- }
909
-
910
- private function _callServiceSky($data)
911
- {
912
- $msg = sprintf("CalculatePrice: [%s] - [%s] - [%s] - [Category_id: %s] - [Price: %s] - [weight: %s] - [typeProduct: %s]",
913
- $data['object_id'],
914
- $data['sku'],
915
- $data['name'],
916
- $data['category_id'],
917
- $data['final_price'],
918
- $data['weight'],
919
- $data['typeProduct']
920
- );
921
-
922
- $params = array(
923
- 'htmlobjectid' => $data['object_id'],
924
- 'code' => $data['sku'],
925
- 'name' => $data['name'],
926
- 'category' => $data['category_id'],
927
- 'price' => $data['final_price'],
928
- //'storeproductprice' => $product->getFinalPrice(),
929
- 'weight' => ($data['weight']) ? $data['weight'] : 1,
930
- 'weightunit' => $this->getWeightUnit(),
931
- 'imgurl' => $data['image_url'],
932
- /*'volweight' => $data['VolWeight'],
933
- 'merchantproductid' => $data['merchantproductid']*/
934
- );
935
- //var_dump($params); exit;
936
- return $params;
937
- }
938
-
939
- /*Async End*/
940
- }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Catalog
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Catalog
8
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
11
+ {
12
+
13
+ /**
14
+ * Model instance
15
+ * @var Skybox_Core_Model_Config
16
+ */
17
+ /*protected $_config = null;
18
+
19
+ protected $_typeConfig = "skyboxcore/config";
20
+
21
+ protected function getConfig()
22
+ {
23
+ if(null === $this->_config)
24
+ $this->_config = Mage::getModel($this->_typeConfig);
25
+ }*/
26
+
27
+ /**
28
+ * Model instance
29
+ * @var Mage_Core_Catalog_Model_Product
30
+ */
31
+ protected $_product = null;
32
+
33
+ protected $_productResult = null;
34
+
35
+ protected $_typeProduct = "catalog/product";
36
+
37
+ protected $_product_id = null;
38
+ protected $_product_data = null;
39
+
40
+ public function getProductId()
41
+ {
42
+ if ($this->_product_id != null) {
43
+ return $this->_product_id;
44
+ }
45
+ return null;
46
+ }
47
+
48
+ public function getProductData()
49
+ {
50
+ if ($this->_product_data != null) {
51
+ return $this->_product_data;
52
+ }
53
+ return null;
54
+ }
55
+
56
+
57
+ /**
58
+ * Calculate Price
59
+ *
60
+ * @param int|Mage_Catalog_Model_Product $product
61
+ * @param Varien_Object $request
62
+ * @param float $finalPrice
63
+ * @param string $type
64
+ * @param int $objectId
65
+ * @return Mage_Checkout_Model_Cart
66
+ */
67
+ public function CalculatePrice($product, $request, $finalPrice = null, $type = null, $objectId = 1)
68
+ {
69
+ // Mage::log("--------------------------------------", null, 'verify.log', true);
70
+
71
+ //Mage::log(print_r('Product', true), null, 'tracer.log', true);
72
+
73
+ //if ($this->getErrorAuthenticate() && !$this->getLocationAllow()) {
74
+ if (!$this->getLocationAllow()) {
75
+ return $this;
76
+ }
77
+
78
+ if (!is_object($product)) {
79
+ $storeId = Mage::app()->getStore()->getStoreId();
80
+ $product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($product);
81
+ }
82
+ // Mage::log("CalculatePrice '". $product->getTypeId()."'", null, 'verify.log', true);
83
+ // Mage::log("CalculatePrice FinalPrice '". $product->getFinalPrice()."'", null, 'verify.log', true);
84
+
85
+ $productId = $product->getId();
86
+ $_data = null;
87
+
88
+ if ($type == null) {
89
+ $type = $product->getTypeId();
90
+ }
91
+
92
+ $defaultSwitch = false;
93
+ switch ($type) {
94
+ case 'simple':
95
+ $finalPrice = isset($finalPrice) ? $finalPrice : $product->getFinalPrice();
96
+ $category_id = $product->getSkyboxCategoryId();
97
+ $category_id = isset($category_id) ? $category_id : $this->getCommodityFromCategory($product);
98
+ $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
99
+
100
+ $_data = array(
101
+ 'object_id' => 1,
102
+ 'name' => $product->getName(),
103
+ 'sku' => $product->getSku(),
104
+ 'category_id' => $category_id,
105
+ 'final_price' => $finalPrice,
106
+ 'weight' => ($product->getWeight()) ? $product->getWeight() : 1,
107
+ 'image_url' => $product->getImageUrl(),
108
+ 'typeProduct' => $type,
109
+ 'VolWeight' => $volWeight,
110
+ 'merchantproductid' => $productId
111
+ );
112
+ // $this->_calculatePrice($_data);
113
+ break;
114
+
115
+ case 'configurable':
116
+
117
+ // $finalPrice = isset($finalPrice) ? $finalPrice : null;
118
+ $finalPrice = isset($finalPrice) ? $finalPrice : $product->getFinalPrice();
119
+ $weight = $product->getTypeInstance(true)->getWeight($product);
120
+ $sku = $product->getSku();
121
+
122
+ // Mage::log("CalculatePrice configurable: '" . $finalPrice."'", null, 'verify.log', true);
123
+
124
+ if ($request) {
125
+ $childProduct = Mage::getModel('catalog/product_type_configurable')
126
+ ->getProductByAttributes($request->getData('super_attribute'), $product);
127
+
128
+ $productId = $childProduct->getId();
129
+ $sku = $childProduct->getSku();
130
+
131
+ }
132
+
133
+ $parentItem = null;
134
+
135
+ if (isset($request) && !$finalPrice) {
136
+ // Mage::log("CalculatePrice candidate INI ", null, 'verify.log', true);
137
+ $_finalPrice = 0;
138
+
139
+ $cartCandidates = $product->getTypeInstance(true)
140
+ ->prepareForCartAdvanced($request, $product, 'full');
141
+
142
+ foreach ($cartCandidates as $candidate) {
143
+ // Child items can be sticked together only within their parent
144
+ $stickWithinParent = $candidate->getParentProductId() ? $parentItem : null;
145
+ $candidate->setStickWithinParent($stickWithinParent);
146
+
147
+ $candidate_getFinalPrice = $candidate->getPriceModel()->getFinalPrice($request->getQty(),
148
+ $product);
149
+ // Mage::log("CalculatePrice candidate getFinalPrice: " . $candidate_getFinalPrice, null,
150
+ // 'skyboxcheckout.log', false);
151
+
152
+ $_finalPrice = $_finalPrice + $candidate_getFinalPrice;
153
+ if ($_finalPrice) {
154
+ break;
155
+ }
156
+ }
157
+ $finalPrice = $_finalPrice;
158
+ // Mage::log("CalculatePrice candidate FIN", null, 'verify.log', true);
159
+ }
160
+
161
+ /* Weight start*/
162
+ /*
163
+ $options = array();
164
+ // Get any super_attribute settings we need
165
+ $productAttributesOptions = $product->getTypeInstance(true)->getConfigurableOptions($product);
166
+ foreach ($productAttributesOptions as $productAttributeOption) {
167
+ $options[$product->getId()] = array();
168
+ foreach ($productAttributeOption as $optionValues) {
169
+ $val = ($optionValues['option_title']);
170
+ $options[$product->getId()][] = array (
171
+ $optionValues['sku'] => $optionValues['attribute_code']."=".$val
172
+
173
+ ) ;
174
+ }
175
+
176
+ }
177
+ $prod_weight = 1;
178
+ if(!empty($optionValues)) {
179
+ $a = Mage::getModel('catalog/product')->loadByAttribute('sku',$optionValues['sku']);
180
+ //$product->load($product->getIdBySku($optionValues['sku']));
181
+ $prod_weight = $a->getWeight();
182
+ echo ":::".$prod_weight."::";
183
+ }
184
+ */
185
+ /* Weight end*/
186
+
187
+ $category_id = $product->getSkyboxCategoryId();
188
+ $category_id = isset($category_id) ? $category_id : $this->getCommodityFromCategory($product);
189
+
190
+ $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
191
+ $_data = array(
192
+ 'object_id' => 1,
193
+ 'name' => $product->getName(),
194
+ //'sku' => $product->getSku(),
195
+ 'sku' => $sku,
196
+ 'category_id' => $category_id,
197
+ 'final_price' => $finalPrice,
198
+ 'weight' => $weight ? $weight : 1,
199
+ 'image_url' => $product->getImageUrl(),
200
+ 'typeProduct' => $type,
201
+ 'VolWeight' => $volWeight,
202
+ 'merchantproductid' => $productId
203
+ );
204
+
205
+ // $this->_calculatePrice($_data);
206
+ break;
207
+
208
+ case 'bundle':
209
+ //$_finalPrice = $product->getTotalBundleItemsPrice($product, $request->getQty());
210
+ //$finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
211
+
212
+ //Mage::log(print_r($product, true), null, 'cart.log', true);
213
+ //Mage::log("Product: [" . $product->getId() . "] - Class: " . get_class($product), null, 'skyboxcheckout.log', false);
214
+
215
+ //Mage::log(print_r($request, true), null, 'cart.log', true);
216
+
217
+ $finalPrice = isset($finalPrice) ? $finalPrice : null;
218
+ $weight = $product->getTypeInstance(true)->getWeight($product);
219
+ $sku = $product->getSku();
220
+
221
+ //if (isset($request) && !$finalPrice) {
222
+ if (isset($request)) {
223
+
224
+ $parentItem = null;
225
+ $_finalPrice = null;
226
+ $_weight = 0;
227
+
228
+ $cartCandidates = $product->getTypeInstance(true)
229
+ ->prepareForCartAdvanced($request, $product, 'full');
230
+
231
+ foreach ($cartCandidates as $candidate) {
232
+ // Child items can be sticked together only within their parent
233
+ $stickWithinParent = $candidate->getParentProductId() ? $parentItem : null;
234
+ $candidate->setStickWithinParent($stickWithinParent);
235
+
236
+ if (!$_finalPrice) {
237
+ $_finalPrice = $candidate->getPriceModel()->getFinalPrice($request->getQty(), $product);
238
+ //break;
239
+ }
240
+ //$_weight = $_weight + $candidate->getPriceModel()->getWeight();
241
+ $_weight = $_weight + $candidate->getWeight();
242
+ }
243
+
244
+ $finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
245
+ if ($_weight > 0) {
246
+ $weight = $_weight;
247
+ }
248
+ }
249
+
250
+ //Mage::log("weight: " . $weight, null, 'cart.log', true);
251
+ //Mage::log("sku: " . $sku, null, 'cart.log', true);
252
+
253
+ $category_id = $product->getSkyboxCategoryId();
254
+ $category_id = isset($category_id) ? $category_id : $this->getCommodityFromCategory($product);
255
+
256
+ $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
257
+ $_data = array(
258
+ 'object_id' => 1,
259
+ 'name' => $product->getName(),
260
+ 'sku' => $sku,
261
+ 'category_id' => $category_id,
262
+ 'final_price' => $finalPrice,
263
+ 'weight' => ($weight) ? $weight : 1,
264
+ 'image_url' => $product->getImageUrl(),
265
+ 'typeProduct' => $type,
266
+ 'VolWeight' => $volWeight,
267
+ 'merchantproductid' => $productId
268
+ );
269
+ // $this->_calculatePrice($_data);
270
+ break;
271
+
272
+ case 'bundle_fixed':
273
+
274
+ // @Note: It should be rewrite!!
275
+ $finalPrice = isset($finalPrice) ? $finalPrice : null;
276
+ $skyboxCategoryId = $product->getSkyboxCategoryId();
277
+ $weight = $product->getTypeInstance(true)->getWeight($product);
278
+ $sku = $product->getSku();
279
+
280
+ $selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection(
281
+ $product->getTypeInstance(true)->getOptionsIds($product), $product
282
+ );
283
+
284
+ $_finalPrice = null;
285
+ $_weight = 0;
286
+ $_skyboxCategoryId = null;
287
+
288
+ foreach ($selectionCollection as $option) {
289
+ //if ($option->getData('is_default') == 0) continue;
290
+
291
+ $product_simple = Mage::getModel('catalog/product')
292
+ ->load($option->getId());
293
+
294
+ $_finalPrice = $_finalPrice + $product_simple->getFinalPrice();
295
+ $_weight = $_weight + $product_simple->getWeight();
296
+
297
+ if (!$_skyboxCategoryId) { // Set SkyboxCategory from the first Simple Product
298
+ // $_skyboxCategoryId = $product_simple->getSkyboxCategoryId();
299
+ $_skyboxCategoryId = $product->getSkyboxCategoryId();
300
+ $_skyboxCategoryId = isset($_skyboxCategoryId) ? $_skyboxCategoryId : $this->getCommodityFromCategory($product);
301
+ }
302
+ }
303
+
304
+ $finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
305
+
306
+ if (!$weight) {
307
+ $weight = $_weight;
308
+ }
309
+
310
+ if (!$skyboxCategoryId) {
311
+ $skyboxCategoryId = $_skyboxCategoryId;
312
+ }
313
+
314
+ /*Mage::log("-------------------------", null, 'cart.log', true);
315
+ Mage::log("Product: " . $product->getName(), null, 'cart.log', true);
316
+ Mage::log("Price: " . $finalPrice, null, 'cart.log', true);
317
+ Mage::log("weight: " . $weight, null, 'cart.log', true);
318
+ Mage::log("sku: " . $sku, null, 'cart.log', true);*/
319
+
320
+
321
+ $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
322
+ $_data = array(
323
+ 'object_id' => 1,
324
+ 'name' => $product->getName(),
325
+ 'sku' => $sku,
326
+ 'category_id' => $skyboxCategoryId,
327
+ 'final_price' => $finalPrice,
328
+ 'weight' => ($weight) ? $weight : 1,
329
+ 'image_url' => $product->getImageUrl(),
330
+ 'typeProduct' => $type,
331
+ 'VolWeight' => $volWeight,
332
+ 'merchantproductid' => $productId
333
+ );
334
+
335
+ // $this->_calculatePrice($_data);
336
+ break;
337
+
338
+ default:
339
+ Mage::log("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice",
340
+ null, 'verify.log', false);
341
+ trigger_error("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice");
342
+ $defaultSwitch = true;
343
+ break;
344
+ }
345
+
346
+ if (!$defaultSwitch) {
347
+ //Mage::log(print_r('EnableTax: ', true), null, 'tracer.log', true);
348
+ //Mage::log(print_r($this->getEnabledAddSumTaxToPrice(), true), null, 'tracer.log', true);
349
+ if ($this->getEnabledAddSumTaxToPrice()) {
350
+ $store = Mage::app()->getStore('default');
351
+ $taxCalculation = Mage::getModel('tax/calculation');
352
+ $request = $taxCalculation->getRateRequest(null, null, null, $store);
353
+ // $product = Mage::registry('current_product');
354
+ $taxClassId = $product->getTaxClassId();
355
+ $percentTax = $taxCalculation->getRate($request->setProductClassId($taxClassId));
356
+
357
+ $taxPrice = $_data['final_price'] * ($percentTax / 100);
358
+
359
+ //Mage::log(print_r('Id product: ' . $product->getId(), true), null, 'tracer.log', true);
360
+ //Mage::log(print_r('$taxPrice: ' . $taxPrice, true), null, 'tracer.log', true);
361
+ //Mage::log(print_r('price: ' . $_data['final_price'], true), null, 'tracer.log', true);
362
+ //Mage::log(print_r('$taxPrice+price: ' . ($taxPrice + $_data['final_price']), true), null, 'tracer.log', true);
363
+ $comissionSkybox = $_data['final_price'] * (10 / 100);
364
+ //Mage::log(print_r('comision skybox: ' . ($comissionSkybox), true), null, 'tracer.log', true);
365
+ //Mage::log(print_r('price+comision skybox: ' . ($_data['final_price'] + $comissionSkybox), true), null, 'tracer.log', true);
366
+ //Mage::log(print_r('$taxPrice+price+comision: ' . ($taxPrice + $_data['final_price'] + $comissionSkybox), true), null, 'tracer.log', true);
367
+ //Mage::log(print_r('comision true: ' . (($taxPrice + $_data['final_price']) * (10 / 100)), true), null, 'tracer.log', true);
368
+ $priceReally = ($taxPrice + $_data['final_price']) + ($taxPrice + $_data['final_price']) * (10 / 100);
369
+ //Mage::log(print_r('$taxPrice+price+comision true: ' . ($priceReally), true), null, 'tracer.log', true);
370
+
371
+
372
+ $_data['final_price'] = $_data['final_price'] + $taxPrice;
373
+ }
374
+
375
+ //Mage::log(print_r('####################### Data produc params #######################', true), null, 'tracer.log', true);
376
+ //Mage::log(print_r($_data, true), null, 'tracer.log', true);
377
+ // $this->_calculatePrice($_data);
378
+ try {
379
+ $this->_calculatePrice($_data);
380
+ } catch (\Exception $e) {
381
+ Mage::log($e->getMessage(), null, 'skyboxcheckout.log', false);
382
+ }
383
+ }
384
+
385
+ // Mage::log("Product Class: " . get_class($product), null, 'verify.log', false);
386
+ // Mage::log("Product Type: " . $type, null, 'verify.log', false);
387
+ // Mage::log(print_r($_data, true), null, 'verify.log', false);
388
+
389
+ $this->_product_data = $_data;
390
+ $this->_product_id = $productId;
391
+ return $this;
392
+ }
393
+
394
+ private function _calculatePrice($data)
395
+ {
396
+ $msg = sprintf("CalculatePrice: [%s] - [%s] - [%s] - [Category_id: %s] - [Price: %s] - [weight: %s] - [typeProduct: %s]",
397
+ $data['object_id'],
398
+ $data['sku'],
399
+ $data['name'],
400
+ $data['category_id'],
401
+ $data['final_price'],
402
+ $data['weight'],
403
+ $data['typeProduct']
404
+ );
405
+
406
+ Mage::log($msg, null, 'skyboxcheckout.log', false);
407
+
408
+ $params = array(
409
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
410
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
411
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
412
+ 'htmlobjectid' => $data['object_id'],
413
+ 'storeproductcode' => $data['sku'],
414
+ 'storeproductname' => $data['name'],
415
+ 'storeproductcategory' => $data['category_id'],
416
+ 'storeproductprice' => $data['final_price'],
417
+ //'storeproductprice' => $product->getFinalPrice(),
418
+ 'weight' => ($data['weight']) ? $data['weight'] : 1,
419
+ 'weightunit' => $this->getWeightUnit(),
420
+ 'storeproductimgurl' => $data['image_url'],
421
+ 'merchantproductid' => $data['merchantproductid']
422
+ );
423
+ $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_CALCULATE, $params);
424
+ }
425
+
426
+ public function HtmlTemplateButton()
427
+ {
428
+ if (!$this->getErrorAuthenticate() && $this->_getApi()->getLocationAllow()) {
429
+ $params = array(
430
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
431
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
432
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi()
433
+ );
434
+
435
+ $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_GET_TEMPLATE_BUTTON, $params);
436
+ }
437
+
438
+ return $this;
439
+ }
440
+
441
+ public function GetTemplateProduct()
442
+ {
443
+ Mage::log("ApiProduct ", null, 'orden.log', true);
444
+ if (!$this->getErrorAuthenticate() && $this->_getApi()->getLocationAllow() && !$this->_getApi()->ErrorServiceNotController()) {
445
+ //if (!$this->getErrorAuthenticate() && $this->_getApi()->getLocationAllow() && !$this->_getApi()->ErrorService()) {
446
+ $_productResult = $this->getResponse();
447
+ $template = $_productResult->TooltipButtonTemplate;
448
+ return $template;
449
+ // $templateButton = $this->getHtmlTemplateButton();
450
+ // if (empty($templateButton))
451
+ // $this->HtmlTemplateButton();
452
+ //
453
+ // /*if($_productResult->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_BUTTONERROR})
454
+ // {*/
455
+ // //Mage::log("_productResult--->" . json_decode($_productResult));
456
+ // $templateButton = $this->getHtmlTemplateButton();
457
+ // if (!empty($templateButton)) {
458
+ // $template = $this->getHtmlTemplateButton();
459
+ //// Mage::log(print_r('response template buttom', true), null, 'tracer.log', true);
460
+ //// Mage::log(print_r($_productResult, true), null, 'tracer.log', true);
461
+ // foreach ($_productResult as $key => $value) {
462
+ // $template = str_replace('{' . $key . '}', $value, $template);
463
+ // }
464
+ //
465
+ // // Just for {Block} crap
466
+ // $template = str_replace('{Block}', '', $template);
467
+ //
468
+ // return $template;
469
+ // }
470
+ //
471
+ // $displayUSD = "''"; //CartCountryIso
472
+ // /*}else{
473
+ // return "Plantilla de error";
474
+ // }*/
475
+ // //Mage::log(get_class($this) . " GetTemplateProduct() ", null, 'cart.log', true);
476
+ } else {
477
+ $template = '<div class="skx_content_button"></div>';
478
+ return $template;
479
+ }
480
+ return "";
481
+ }
482
+
483
+ protected $_isUSD = null;
484
+
485
+ public function IsUSD()
486
+ {
487
+ if (null == $this->_isUSD) {
488
+ $this->_isUSD = ($this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_CART_CURRENCY_ISO,
489
+ "") == Skybox_Core_Model_Config::SKYBOX_CURRENCY_USD);
490
+ }
491
+ return $this->_isUSD;
492
+ }
493
+
494
+ public function getCustoms()
495
+ {
496
+ return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_CUSTOMS, "0");
497
+ }
498
+
499
+ public function getShipping()
500
+ {
501
+ return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_SHIPPING, "0");
502
+ }
503
+
504
+ public function getInsurance()
505
+ {
506
+ return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_INSURANCE, "0");
507
+ }
508
+
509
+ public function getPrice()
510
+ {
511
+ return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_PRICE, "0");
512
+ }
513
+
514
+ public function getTotalPrice()
515
+ {
516
+ return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_TOTAL, "0");
517
+ }
518
+
519
+ public function getCustomsUSD()
520
+ {
521
+ return $this->IsUSD() ? $this->getCustoms() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_CUSTOMS_USD,
522
+ "0");
523
+ }
524
+
525
+ public function getShippingUSD()
526
+ {
527
+ return $this->IsUSD() ? $this->getShipping() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_SHIPPING_USD,
528
+ "0");
529
+ }
530
+
531
+ public function getInsuranceUSD()
532
+ {
533
+ return $this->IsUSD() ? $this->getInsurance() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_INSURANCE_USD,
534
+ "0");
535
+ }
536
+
537
+ public function getPriceUSD()
538
+ {
539
+ return $this->IsUSD() ? $this->getPrice() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_PRICE_USD,
540
+ "0");
541
+ }
542
+
543
+ public function getTotalPriceUSD()
544
+ {
545
+ return $this->IsUSD() ? $this->getTotalPrice() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_TOTAL_USD,
546
+ "0");
547
+ }
548
+
549
+ public function getGuidSkybox()
550
+ {
551
+ return $this->_getApi()->getGuidApi();
552
+ }
553
+
554
+ public function getBasePrice()
555
+ {
556
+ return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_BASE_PRICE, "0");
557
+ }
558
+
559
+ public function getBasePriceUSD()
560
+ {
561
+ return $this->IsUSD() ? $this->getBasePrice() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_BASE_PRICE_USD,
562
+ "0");
563
+ }
564
+
565
+ public function getAdjustPrice()
566
+ {
567
+ return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ADJUST_PRICE, "0");
568
+ }
569
+
570
+ public function getAdjustPriceUSD()
571
+ {
572
+ return $this->IsUSD() ? $this->getAdjustPrice() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ADJUST_PRICE_USD,
573
+ "0");
574
+ }
575
+
576
+ public function getAdjustLabel()
577
+ {
578
+ return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_LABEL_ADJUST, "");
579
+ }
580
+
581
+ /*Async Ini*/
582
+
583
+ public function getUrl($product, $request, $finalPrice = null, $type = null, $objectId = 1)
584
+ {
585
+ Mage::log("ApiProductCatalog ", null, 'orden.log', true);
586
+
587
+ //Mage::log(print_r('Product', true), null, 'tracer.log', true);
588
+
589
+ //if ($this->getErrorAuthenticate() && !$this->getLocationAllow()) {
590
+ if (!$this->getLocationAllow()) {
591
+ return $this;
592
+ }
593
+
594
+ if (!is_object($product)) {
595
+ $storeId = Mage::app()->getStore()->getStoreId();
596
+ $product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($product);
597
+ }
598
+
599
+ $productId = $product->getId();
600
+ $_data = null;
601
+
602
+ if ($type == null) {
603
+ $type = $product->getTypeId();
604
+ }
605
+
606
+ $defaultSwitch = true;
607
+ switch ($type) {
608
+ case 'simple':
609
+ $finalPrice = isset($finalPrice) ? $finalPrice : $product->getFinalPrice();
610
+ $category_id = $product->getSkyboxCategoryId();
611
+ $category_id = isset($category_id) ? $category_id : $this->getCommodityFromCategory($product);
612
+ $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
613
+
614
+ $_data = array(
615
+ 'object_id' => $product->getId(),
616
+ 'name' => $product->getName(),
617
+ 'sku' => $product->getSku(),
618
+ 'category_id' => $category_id,
619
+ 'final_price' => $finalPrice,
620
+ 'weight' => ($product->getWeight()) ? $product->getWeight() : 1,
621
+ 'image_url' => $product->getImageUrl(),
622
+ 'typeProduct' => $type,
623
+ 'VolWeight' => $volWeight,
624
+ 'merchantproductid' => $productId
625
+ );
626
+ // $this->_calculatePrice($_data);
627
+ break;
628
+
629
+ case 'configurable':
630
+
631
+ $finalPrice = isset($finalPrice) ? $finalPrice : null;
632
+ $weight = $product->getTypeInstance(true)->getWeight($product);
633
+ $sku = $product->getSku();
634
+
635
+ Mage::log("CalculatePrice configurable : " . $finalPrice, null, 'skyboxcheckout.log', false);
636
+
637
+ if ($request) {
638
+ $childProduct = Mage::getModel('catalog/product_type_configurable')
639
+ ->getProductByAttributes($request->getData('super_attribute'), $product);
640
+
641
+ $productId = $childProduct->getId();
642
+ $sku = $childProduct->getSku();
643
+
644
+ }
645
+
646
+ $parentItem = null;
647
+
648
+ if (isset($request) && !$finalPrice) {
649
+ Mage::log("CalculatePrice candidate INI", null, 'skyboxcheckout.log', false);
650
+ $_finalPrice = 0;
651
+
652
+ $cartCandidates = $product->getTypeInstance(true)
653
+ ->prepareForCartAdvanced($request, $product, 'full');
654
+
655
+ foreach ($cartCandidates as $candidate) {
656
+ // Child items can be sticked together only within their parent
657
+ $stickWithinParent = $candidate->getParentProductId() ? $parentItem : null;
658
+ $candidate->setStickWithinParent($stickWithinParent);
659
+
660
+ $candidate_getFinalPrice = $candidate->getPriceModel()->getFinalPrice($request->getQty(),
661
+ $product);
662
+ Mage::log("CalculatePrice candidate getFinalPrice: " . $candidate_getFinalPrice, null,
663
+ 'skyboxcheckout.log', false);
664
+
665
+ $_finalPrice = $_finalPrice + $candidate_getFinalPrice;
666
+ if ($_finalPrice) {
667
+ break;
668
+ }
669
+ }
670
+ $finalPrice = $_finalPrice;
671
+ Mage::log("CalculatePrice candidate FIN", null, 'skyboxcheckout.log', false);
672
+ }
673
+
674
+ $category_id = $product->getSkyboxCategoryId();
675
+ $category_id = isset($category_id) ? $category_id : $this->getCommodityFromCategory($product);
676
+
677
+ $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
678
+
679
+ $_data = array(
680
+ 'object_id' => $product->getId(),
681
+ 'name' => $product->getName(),
682
+ //'sku' => $product->getSku(),
683
+ 'sku' => $sku,
684
+ 'category_id' => $category_id,
685
+ 'final_price' => $finalPrice,
686
+ 'weight' => $weight ? $weight : 1,
687
+ 'image_url' => $product->getImageUrl(),
688
+ 'typeProduct' => $type,
689
+ 'VolWeight' => $volWeight,
690
+ 'merchantproductid' => $productId
691
+ );
692
+
693
+ // $this->_calculatePrice($_data);
694
+ break;
695
+
696
+ case 'bundle':
697
+ //$_finalPrice = $product->getTotalBundleItemsPrice($product, $request->getQty());
698
+ //$finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
699
+
700
+ //Mage::log(print_r($product, true), null, 'cart.log', true);
701
+ //Mage::log("Product: [" . $product->getId() . "] - Class: " . get_class($product), null, 'skyboxcheckout.log', false);
702
+
703
+ //Mage::log(print_r($request, true), null, 'cart.log', true);
704
+
705
+ $finalPrice = isset($finalPrice) ? $finalPrice : null;
706
+ $weight = $product->getTypeInstance(true)->getWeight($product);
707
+ $sku = $product->getSku();
708
+
709
+ //if (isset($request) && !$finalPrice) {
710
+ if (isset($request)) {
711
+
712
+ $parentItem = null;
713
+ $_finalPrice = null;
714
+ $_weight = 0;
715
+
716
+ $cartCandidates = $product->getTypeInstance(true)
717
+ ->prepareForCartAdvanced($request, $product, 'full');
718
+
719
+ foreach ($cartCandidates as $candidate) {
720
+ // Child items can be sticked together only within their parent
721
+ $stickWithinParent = $candidate->getParentProductId() ? $parentItem : null;
722
+ $candidate->setStickWithinParent($stickWithinParent);
723
+
724
+ if (!$_finalPrice) {
725
+ $_finalPrice = $candidate->getPriceModel()->getFinalPrice($request->getQty(), $product);
726
+ //break;
727
+ }
728
+ //$_weight = $_weight + $candidate->getPriceModel()->getWeight();
729
+ $_weight = $_weight + $candidate->getWeight();
730
+ }
731
+
732
+ $finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
733
+ if ($_weight > 0) {
734
+ $weight = $_weight;
735
+ }
736
+ }
737
+
738
+ //Mage::log("weight: " . $weight, null, 'cart.log', true);
739
+ //Mage::log("sku: " . $sku, null, 'cart.log', true);
740
+
741
+ $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
742
+ $_data = array(
743
+ 'object_id' => $product->getId(),
744
+ 'name' => $product->getName(),
745
+ 'sku' => $sku,
746
+ 'category_id' => $product->getSkyboxCategoryId(),
747
+ 'final_price' => $finalPrice,
748
+ 'weight' => ($weight) ? $weight : 1,
749
+ 'image_url' => $product->getImageUrl(),
750
+ 'typeProduct' => $type,
751
+ 'VolWeight' => $volWeight,
752
+ 'merchantproductid' => $productId
753
+ );
754
+ // $this->_calculatePrice($_data);
755
+ break;
756
+
757
+ case 'bundle_fixed':
758
+ $finalPrice = isset($finalPrice) ? $finalPrice : null;
759
+ $skyboxCategoryId = $product->getSkyboxCategoryId();
760
+ $weight = $product->getTypeInstance(true)->getWeight($product);
761
+ $sku = $product->getSku();
762
+
763
+ $selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection(
764
+ $product->getTypeInstance(true)->getOptionsIds($product), $product
765
+ );
766
+
767
+ $_finalPrice = null;
768
+ $_weight = 0;
769
+ $_skyboxCategoryId = null;
770
+
771
+ foreach ($selectionCollection as $option) {
772
+ //if ($option->getData('is_default') == 0) continue;
773
+
774
+ $product_simple = Mage::getModel('catalog/product')
775
+ ->load($option->getId());
776
+
777
+ $_finalPrice = $_finalPrice + $product_simple->getFinalPrice();
778
+ $_weight = $_weight + $product_simple->getWeight();
779
+
780
+ if (!$_skyboxCategoryId) { // Set SkyboxCategory from the first Simple Product
781
+ $_skyboxCategoryId = $product_simple->getSkyboxCategoryId();
782
+ }
783
+ }
784
+
785
+ $finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
786
+
787
+ if (!$weight) {
788
+ $weight = $_weight;
789
+ }
790
+
791
+ if (!$skyboxCategoryId) {
792
+ $skyboxCategoryId = $_skyboxCategoryId;
793
+ }
794
+
795
+ /*Mage::log("-------------------------", null, 'cart.log', true);
796
+ Mage::log("Product: " . $product->getName(), null, 'cart.log', true);
797
+ Mage::log("Price: " . $finalPrice, null, 'cart.log', true);
798
+ Mage::log("weight: " . $weight, null, 'cart.log', true);
799
+ Mage::log("sku: " . $sku, null, 'cart.log', true);*/
800
+
801
+ $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
802
+ $_data = array(
803
+ 'object_id' => $product->getId(),
804
+ 'name' => $product->getName(),
805
+ 'sku' => $sku,
806
+ 'category_id' => $skyboxCategoryId,
807
+ 'final_price' => $finalPrice,
808
+ 'weight' => ($weight) ? $weight : 1,
809
+ 'image_url' => $product->getImageUrl(),
810
+ 'typeProduct' => $type,
811
+ 'VolWeight' => $volWeight,
812
+ 'merchantproductid' => $productId
813
+ );
814
+
815
+ // $this->_calculatePrice($_data);
816
+ break;
817
+
818
+ default:
819
+ Mage::log("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice",
820
+ null, 'skyboxcheckout.log', false);
821
+ trigger_error("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice");
822
+ $defaultSwitch = true;
823
+ break;
824
+ }
825
+
826
+ if (!$defaultSwitch) {
827
+ //Mage::log(print_r('EnableTax: ', true), null, 'tracer.log', true);
828
+ //Mage::log(print_r($this->getEnabledAddSumTaxToPrice(), true), null, 'tracer.log', true);
829
+ if ($this->getEnabledAddSumTaxToPrice()) {
830
+ $store = Mage::app()->getStore('default');
831
+ $taxCalculation = Mage::getModel('tax/calculation');
832
+ $request = $taxCalculation->getRateRequest(null, null, null, $store);
833
+ // $product = Mage::registry('current_product');
834
+ $taxClassId = $product->getTaxClassId();
835
+ $percentTax = $taxCalculation->getRate($request->setProductClassId($taxClassId));
836
+
837
+ $taxPrice = $_data['final_price'] * ($percentTax / 100);
838
+
839
+ //Mage::log(print_r('Id product: ' . $product->getId(), true), null, 'tracer.log', true);
840
+ //Mage::log(print_r('$taxPrice: ' . $taxPrice, true), null, 'tracer.log', true);
841
+ //Mage::log(print_r('price: ' . $_data['final_price'], true), null, 'tracer.log', true);
842
+ //Mage::log(print_r('$taxPrice+price: ' . ($taxPrice + $_data['final_price']), true), null, 'tracer.log', true);
843
+ $comissionSkybox = $_data['final_price'] * (10 / 100);
844
+ //Mage::log(print_r('comision skybox: ' . ($comissionSkybox), true), null, 'tracer.log', true);
845
+ //Mage::log(print_r('price+comision skybox: ' . ($_data['final_price'] + $comissionSkybox), true), null, 'tracer.log', true);
846
+ //Mage::log(print_r('$taxPrice+price+comision: ' . ($taxPrice + $_data['final_price'] + $comissionSkybox), true), null, 'tracer.log', true);
847
+ //Mage::log(print_r('comision true: ' . (($taxPrice + $_data['final_price']) * (10 / 100)), true), null, 'tracer.log', true);
848
+ $priceReally = ($taxPrice + $_data['final_price']) + ($taxPrice + $_data['final_price']) * (10 / 100);
849
+ //Mage::log(print_r('$taxPrice+price+comision true: ' . ($priceReally), true), null, 'tracer.log', true);
850
+ $_data['final_price'] = $_data['final_price'] + $taxPrice;
851
+ }
852
+
853
+ //Mage::log(print_r('####################### Data produc params #######################', true), null, 'tracer.log', true);
854
+ //Mage::log(print_r($_data, true), null, 'tracer.log', true);
855
+ try {
856
+ $this->_calculatePrice($_data);
857
+ } catch (\Exception $e) {
858
+ Mage::log($e->getMessage(), null, 'skyboxcheckout.log', false);
859
+ }
860
+
861
+ }
862
+
863
+ Mage::log("Product Class: " . get_class($product), null, 'skyboxcheckout.log', false);
864
+ Mage::log("Product Type: " . $type, null, 'skyboxcheckout.log', false);
865
+ Mage::log(print_r($_data, true), null, 'skyboxcheckout.log', false);
866
+
867
+ $data = $this->_callServiceSky($_data);
868
+ /*var_dump($this); exit;
869
+ $this->_product_data = $_data;
870
+ $this->_product_id = $productId;
871
+ $apiData = $this->_api;
872
+ var_dump($apiData); exit;*/
873
+ return $data;
874
+ }
875
+
876
+ /**
877
+ * Return the Commodity from Category or Root
878
+ *
879
+ * @param $product
880
+ * @return int
881
+ */
882
+ public function getCommodityFromCategory($product)
883
+ {
884
+ $result = 0;
885
+
886
+ try {
887
+ $categoryIds = $product->getCategoryIds();
888
+
889
+ if (count($categoryIds)) {
890
+ $categoryId = $categoryIds[0];
891
+ $category = Mage::getModel('catalog/category')->load($categoryId);
892
+ $result = $category->getSkyboxCategoryIdSelect();
893
+ }
894
+
895
+ if (empty($result)) {
896
+ $categoryId = Mage::app()->getStore()->getRootCategoryId();
897
+ $category = Mage::getModel('catalog/category')->load($categoryId);
898
+ $result = $category->getSkyboxCategoryIdSelect();
899
+ }
900
+
901
+ $result = isset($result) ? $result : 0;
902
+
903
+ } catch (\Exception $e) {
904
+ \error_log("catch exception product_: " . $product . PHP_EOL, 3, BP . '/var/log/magento19.trace.log');
905
+ }
906
+
907
+ return $result;
908
+ }
909
+
910
+ private function _callServiceSky($data)
911
+ {
912
+ $msg = sprintf("CalculatePrice: [%s] - [%s] - [%s] - [Category_id: %s] - [Price: %s] - [weight: %s] - [typeProduct: %s]",
913
+ $data['object_id'],
914
+ $data['sku'],
915
+ $data['name'],
916
+ $data['category_id'],
917
+ $data['final_price'],
918
+ $data['weight'],
919
+ $data['typeProduct']
920
+ );
921
+
922
+ $params = array(
923
+ 'htmlobjectid' => $data['object_id'],
924
+ 'code' => $data['sku'],
925
+ 'name' => $data['name'],
926
+ 'category' => $data['category_id'],
927
+ 'price' => $data['final_price'],
928
+ //'storeproductprice' => $product->getFinalPrice(),
929
+ 'weight' => ($data['weight']) ? $data['weight'] : 1,
930
+ 'weightunit' => $this->getWeightUnit(),
931
+ 'imgurl' => $data['image_url'],
932
+ /*'volweight' => $data['VolWeight'],
933
+ 'merchantproductid' => $data['merchantproductid']*/
934
+ );
935
+ //var_dump($params); exit;
936
+ return $params;
937
+ }
938
+
939
+ /*Async End*/
940
+ }
app/code/community/Skybox/Catalog/Model/Observer.php CHANGED
@@ -1,271 +1,271 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Checkout
5
- *
6
- * @category Mage
7
- * @package Skybox_Catalog
8
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
-
11
- /**
12
- *
13
- * Catalog Model Observer
14
- *
15
- * Note: For Magento 1.8.x issues with Block Caching
16
- */
17
- class Skybox_Catalog_Model_Observer
18
- {
19
- private function getActive()
20
- {
21
- // $value = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
22
- $value = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
23
- return $value;
24
- }
25
-
26
- public function hookToControllerActionPreDispatch($observer)
27
- {
28
- $active = $this->getActive();
29
- if (!$active) {
30
- return;
31
- }
32
-
33
- //Mage::log('router tivoli: '.$observer->getEvent()->getControllerAction()->getFullActionName(), null, 'tracer.log', true);
34
- if (($observer->getEvent()->getControllerAction()->getFullActionName() == 'checkout_cart_add')) {
35
-
36
- //Mage::log('hookToControllerActionPreDispatch '.$observer->getEvent()->getControllerAction()->getFullActionName(),null, 'tracer.log', true);
37
- Mage::dispatchEvent("add_to_cart_before", array('request' => $observer->getControllerAction()->getRequest()));
38
- }
39
- }
40
-
41
- public function hookToControllerActionPostDispatch($observer)
42
- {
43
- $active = $this->getActive();
44
- if (!$active) {
45
- return;
46
- }
47
-
48
- //Mage::log('router tivoli: '.$observer->getEvent()->getControllerAction()->getFullActionName(), null, 'tracer.log', true);
49
- if (($observer->getEvent()->getControllerAction()->getFullActionName() == 'checkout_cart_add')) {
50
-
51
- //Mage::log('hookToControllerActionPostDispatch: '.$observer->getEvent()->getControllerAction()->getFullActionName(),null, 'tracer.log', true);
52
- Mage::dispatchEvent("add_to_cart_after", array('request' => $observer->getControllerAction()->getRequest()));
53
- }
54
- }
55
-
56
- public function hookToAddToCartBefore($observer)
57
- {
58
- $active = $this->getActive();
59
- if (!$active) {
60
- return;
61
- }
62
-
63
- //Mage::log('function hookToAddToCartBefore: ',null, 'tracer.log', true);
64
- $key = Mage::getSingleton('core/session')->getFormKey();
65
- $observer->getEvent()->getRequest()->setParam('form_key', $key);
66
- $request = $observer->getEvent()->getRequest()->getParams();
67
- }
68
-
69
- public function hookToAddToCartAfter($observer)
70
- {
71
- $active = $this->getActive();
72
- if (!$active) {
73
- return;
74
- }
75
-
76
- $request = $observer->getEvent()->getRequest()->getParams();
77
- // Mage::log("hookToAddToCartAfter " . print_r($request, true) . " is added to cart.", null, 'cart.log', true);
78
- }
79
-
80
- public function injectTab(Varien_Event_Observer $observer)
81
- {
82
- // $active = $this->getActive();
83
- // if (!$active) { return; }
84
-
85
- // core_block_abstract_prepare_layout_after
86
-
87
- /* $block Mage_Adminhtml_Block_Catalog_Category_Tabs */
88
- $block = $observer->getEvent()->getBlock();
89
-
90
- if ($block instanceof Mage_Adminhtml_Block_Catalog_Category_Tabs) {
91
-
92
- if ($this->_getRequest()->getActionName() == 'edit' || $this->_getRequest()->getParam('type')) {
93
-
94
- $tab_ids = $block->getTabsIds();
95
- $tab_name = $tab_ids[3]; // SkyboxCheckout position
96
-
97
- if ($tab_name) {
98
- $block->removeTab($tab_name);
99
- }
100
-
101
- // SkyboxCheckout Tab
102
- $block->addTab('custom_tab', array(
103
- 'label' => 'SkyboxCheckout',
104
- 'content' => $block->getLayout()
105
- ->createBlock('skyboxcatalog/catalog_category_tab_skyboxcheckout')
106
- ->toHtml()
107
- ));
108
- }
109
- }
110
- }
111
-
112
- public function saveCategory(Varien_Event_Observer $observer)
113
- {
114
- // catalog_category_prepare_save
115
-
116
- // Note: Already know. this is a piece of crap
117
-
118
- /* $category Mage_Catalog_Model_Category */
119
- $category = $observer->getEvent()->getCategory();
120
-
121
- $skybox_category_id = $this->_getRequest()->getPost('skybox_category_id');
122
- $skybox_category_id_select = $this->_getRequest()->getPost('skybox_category_id_select');
123
- $apply_button = $this->_getRequest()->getPost('apply_button');
124
-
125
- if ($skybox_category_id != $category->getData('skybox_category_id')) {
126
- //$category->setData('skybox_category_id', $skybox_category_id);
127
- $category->setSkyboxCategoryId($skybox_category_id);
128
- $msg = "[" . $category->getId() . "] saving skybox_category_id [" . $skybox_category_id . "]";
129
- Mage::log($msg, null, 'skyboxcheckout.log', true);
130
- }
131
-
132
- if ($skybox_category_id_select != $category->getData('skybox_category_id_select')) {
133
- //$category->setData('skybox_category_id_select', $skybox_category_id_select);
134
- $category->setSkyboxCategoryIdSelect($skybox_category_id_select);
135
- $msg = "[" . $category->getId() . "] saving skybox_category_id_select [" . $skybox_category_id_select . "]";
136
- Mage::log($msg, null, 'skyboxcheckout.log', true);
137
- }
138
-
139
- if ($skybox_category_id || $skybox_category_id_select) {
140
- Mage::log("Commodities saved!", null, 'skyboxcheckout.log', true);
141
- try {
142
- $category->getResource()->save($category);
143
- } catch (Exception $ex) {
144
- Mage::log("saveCategory() Exception: " . $ex->getMessage(), null, 'skyboxcheckout.log', true);
145
- }
146
- }
147
-
148
- if (isset($apply_button) && $apply_button != 'nothing') {
149
-
150
- $skybox_category_id_select = $this->_getRequest()->getPost('skybox_category_id_select');
151
- $skybox_category_id_select = ($skybox_category_id_select) ?
152
- $skybox_category_id_select :
153
- $category->getData('skybox_category_id_select');
154
-
155
- Mage::log("Apply Button: " . $apply_button, null, 'skyboxcheckout.log', true);
156
- switch ($apply_button) {
157
- case 'all_products':
158
- $categoryIds = array($category->getId());
159
- $this->_bulk_commodities($categoryIds, $skybox_category_id_select, true);
160
- break;
161
-
162
- case 'all_products_without_commoditites':
163
- $categoryIds = array($category->getId());
164
- $this->_bulk_commodities($categoryIds, $skybox_category_id_select, false);
165
- break;
166
- }
167
- }
168
- return $this;
169
- }
170
-
171
- public function setCommodityInForm(Varien_Event_Observer $observer)
172
- {
173
- // catalog_product_prepare_save
174
-
175
- Mage::log('catalog_product_prepare_save', null, 'skyboxcheckout.log', true);
176
-
177
- $product = $observer->getEvent()->getProduct();
178
- $skybox_category_id = $this->_getRequest()->getPost('skybox_category_id');
179
- $commodity = $product->getData('skybox_category_id');
180
-
181
- // If the user change commodity manually
182
- if ($skybox_category_id && ($skybox_category_id != $product->getData('skybox_category_id'))) {
183
- $product->setData('skybox_category_id', $skybox_category_id);
184
- $product->getResource()->save($product);
185
- return $this;
186
- }
187
-
188
- // If commodity already set
189
- if ($commodity) {
190
- Mage::log('commodity_exist_true', null, 'skyboxcheckout.log', true);
191
- return $this;
192
- } else {
193
- Mage::log('commodity_exist_false', null, 'skyboxcheckout.log', true);
194
- $categoryIds = $product->getCategoryIds();
195
-
196
- if (empty($categoryIds)) {
197
- return $this;
198
- }
199
-
200
- $categoryId = reset($categoryIds); // current
201
-
202
- /* $category Mage_Catalog_Model_Category */
203
- $category = Mage::getModel('catalog/category')->load($categoryId);
204
-
205
- $value = $category->getData('skybox_category_id');
206
-
207
- if ($value) {
208
- $product->setData('skybox_category_id', $value);
209
- $product->getResource()->save($product);
210
- } else {
211
- Mage::getSingleton('adminhtml/session')->addError(
212
- sprintf("The category %s doesn't have any associated commodity.", $category->getData('title'))
213
- );
214
- }
215
- }
216
- return $this;
217
- }
218
-
219
- /**
220
- * Shortcut to getRequest
221
- */
222
- protected function _getRequest()
223
- {
224
- return Mage::app()->getRequest();
225
- }
226
-
227
- private function _bulk_commodities($categoryIds, $value, $allProducts = true)
228
- {
229
- /* @var $collection Mage_Catalog_Model_Product */
230
- $collection = Mage::getModel('catalog/product')
231
- ->getCollection()
232
- ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
233
- ->addAttributeToSelect('*')
234
- ->addAttributeToFilter('category_id', array('in' => $categoryIds));
235
-
236
- if (!$allProducts) {
237
- $collection->addAttributeToFilter('skybox_category_id', array('null' => true));
238
- }
239
-
240
- $count = count($collection);
241
-
242
- foreach ($collection as $product) {
243
- try {
244
- /** @var Mage_Catalog_Model_Product $product */
245
- $product = $product;
246
-
247
- if ($product->getTypeId() == 'configurable') {
248
- /** @var Mage_Catalog_Model_Product $productChild */
249
- // $childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product);
250
- $childProducts = $product->getTypeInstance()->getUsedProductIds();
251
- foreach ($childProducts as $key => $child) {
252
- $productChild = Mage::getModel('catalog/product')->load($child);
253
- $productChild->setData('skybox_category_id', $value);
254
- $productChild->getResource()->save($productChild);
255
- }
256
- } else {
257
- // Only setData if product->getTypeId() is 'simple'
258
- $product->setData('skybox_category_id', $value);
259
- $product->getResource()->save($product);
260
- }
261
- } catch (\Exception $ex) {
262
- Mage::log("saveCategory() Exception: " . $ex->getMessage(), null, 'skyboxcheckout.log', true);
263
- }
264
- }
265
-
266
- Mage::getSingleton('adminhtml/session')->addSuccess(
267
- sprintf('%s products have been updated correctly.', $count)
268
- );
269
- }
270
-
271
  }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Checkout
5
+ *
6
+ * @category Mage
7
+ * @package Skybox_Catalog
8
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+
11
+ /**
12
+ *
13
+ * Catalog Model Observer
14
+ *
15
+ * Note: For Magento 1.8.x issues with Block Caching
16
+ */
17
+ class Skybox_Catalog_Model_Observer
18
+ {
19
+ private function getActive()
20
+ {
21
+ // $value = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
22
+ $value = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
23
+ return $value;
24
+ }
25
+
26
+ public function hookToControllerActionPreDispatch($observer)
27
+ {
28
+ $active = $this->getActive();
29
+ if (!$active) {
30
+ return;
31
+ }
32
+
33
+ //Mage::log('router tivoli: '.$observer->getEvent()->getControllerAction()->getFullActionName(), null, 'tracer.log', true);
34
+ if (($observer->getEvent()->getControllerAction()->getFullActionName() == 'checkout_cart_add')) {
35
+
36
+ //Mage::log('hookToControllerActionPreDispatch '.$observer->getEvent()->getControllerAction()->getFullActionName(),null, 'tracer.log', true);
37
+ Mage::dispatchEvent("add_to_cart_before", array('request' => $observer->getControllerAction()->getRequest()));
38
+ }
39
+ }
40
+
41
+ public function hookToControllerActionPostDispatch($observer)
42
+ {
43
+ $active = $this->getActive();
44
+ if (!$active) {
45
+ return;
46
+ }
47
+
48
+ //Mage::log('router tivoli: '.$observer->getEvent()->getControllerAction()->getFullActionName(), null, 'tracer.log', true);
49
+ if (($observer->getEvent()->getControllerAction()->getFullActionName() == 'checkout_cart_add')) {
50
+
51
+ //Mage::log('hookToControllerActionPostDispatch: '.$observer->getEvent()->getControllerAction()->getFullActionName(),null, 'tracer.log', true);
52
+ Mage::dispatchEvent("add_to_cart_after", array('request' => $observer->getControllerAction()->getRequest()));
53
+ }
54
+ }
55
+
56
+ public function hookToAddToCartBefore($observer)
57
+ {
58
+ $active = $this->getActive();
59
+ if (!$active) {
60
+ return;
61
+ }
62
+
63
+ //Mage::log('function hookToAddToCartBefore: ',null, 'tracer.log', true);
64
+ $key = Mage::getSingleton('core/session')->getFormKey();
65
+ $observer->getEvent()->getRequest()->setParam('form_key', $key);
66
+ $request = $observer->getEvent()->getRequest()->getParams();
67
+ }
68
+
69
+ public function hookToAddToCartAfter($observer)
70
+ {
71
+ $active = $this->getActive();
72
+ if (!$active) {
73
+ return;
74
+ }
75
+
76
+ $request = $observer->getEvent()->getRequest()->getParams();
77
+ // Mage::log("hookToAddToCartAfter " . print_r($request, true) . " is added to cart.", null, 'cart.log', true);
78
+ }
79
+
80
+ public function injectTab(Varien_Event_Observer $observer)
81
+ {
82
+ // $active = $this->getActive();
83
+ // if (!$active) { return; }
84
+
85
+ // core_block_abstract_prepare_layout_after
86
+
87
+ /* $block Mage_Adminhtml_Block_Catalog_Category_Tabs */
88
+ $block = $observer->getEvent()->getBlock();
89
+
90
+ if ($block instanceof Mage_Adminhtml_Block_Catalog_Category_Tabs) {
91
+
92
+ if ($this->_getRequest()->getActionName() == 'edit' || $this->_getRequest()->getParam('type')) {
93
+
94
+ $tab_ids = $block->getTabsIds();
95
+ $tab_name = $tab_ids[3]; // SkyboxCheckout position
96
+
97
+ if ($tab_name) {
98
+ $block->removeTab($tab_name);
99
+ }
100
+
101
+ // SkyboxCheckout Tab
102
+ $block->addTab('custom_tab', array(
103
+ 'label' => 'SkyboxCheckout',
104
+ 'content' => $block->getLayout()
105
+ ->createBlock('skyboxcatalog/catalog_category_tab_skyboxcheckout')
106
+ ->toHtml()
107
+ ));
108
+ }
109
+ }
110
+ }
111
+
112
+ public function saveCategory(Varien_Event_Observer $observer)
113
+ {
114
+ // catalog_category_prepare_save
115
+
116
+ // Note: Already know. this is a piece of crap
117
+
118
+ /* $category Mage_Catalog_Model_Category */
119
+ $category = $observer->getEvent()->getCategory();
120
+
121
+ $skybox_category_id = $this->_getRequest()->getPost('skybox_category_id');
122
+ $skybox_category_id_select = $this->_getRequest()->getPost('skybox_category_id_select');
123
+ $apply_button = $this->_getRequest()->getPost('apply_button');
124
+
125
+ if ($skybox_category_id != $category->getData('skybox_category_id')) {
126
+ //$category->setData('skybox_category_id', $skybox_category_id);
127
+ $category->setSkyboxCategoryId($skybox_category_id);
128
+ $msg = "[" . $category->getId() . "] saving skybox_category_id [" . $skybox_category_id . "]";
129
+ Mage::log($msg, null, 'skyboxcheckout.log', true);
130
+ }
131
+
132
+ if ($skybox_category_id_select != $category->getData('skybox_category_id_select')) {
133
+ //$category->setData('skybox_category_id_select', $skybox_category_id_select);
134
+ $category->setSkyboxCategoryIdSelect($skybox_category_id_select);
135
+ $msg = "[" . $category->getId() . "] saving skybox_category_id_select [" . $skybox_category_id_select . "]";
136
+ Mage::log($msg, null, 'skyboxcheckout.log', true);
137
+ }
138
+
139
+ if ($skybox_category_id || $skybox_category_id_select) {
140
+ Mage::log("Commodities saved!", null, 'skyboxcheckout.log', true);
141
+ try {
142
+ $category->getResource()->save($category);
143
+ } catch (Exception $ex) {
144
+ Mage::log("saveCategory() Exception: " . $ex->getMessage(), null, 'skyboxcheckout.log', true);
145
+ }
146
+ }
147
+
148
+ if (isset($apply_button) && $apply_button != 'nothing') {
149
+
150
+ $skybox_category_id_select = $this->_getRequest()->getPost('skybox_category_id_select');
151
+ $skybox_category_id_select = ($skybox_category_id_select) ?
152
+ $skybox_category_id_select :
153
+ $category->getData('skybox_category_id_select');
154
+
155
+ Mage::log("Apply Button: " . $apply_button, null, 'skyboxcheckout.log', true);
156
+ switch ($apply_button) {
157
+ case 'all_products':
158
+ $categoryIds = array($category->getId());
159
+ $this->_bulk_commodities($categoryIds, $skybox_category_id_select, true);
160
+ break;
161
+
162
+ case 'all_products_without_commoditites':
163
+ $categoryIds = array($category->getId());
164
+ $this->_bulk_commodities($categoryIds, $skybox_category_id_select, false);
165
+ break;
166
+ }
167
+ }
168
+ return $this;
169
+ }
170
+
171
+ public function setCommodityInForm(Varien_Event_Observer $observer)
172
+ {
173
+ // catalog_product_prepare_save
174
+
175
+ Mage::log('catalog_product_prepare_save', null, 'skyboxcheckout.log', true);
176
+
177
+ $product = $observer->getEvent()->getProduct();
178
+ $skybox_category_id = $this->_getRequest()->getPost('skybox_category_id');
179
+ $commodity = $product->getData('skybox_category_id');
180
+
181
+ // If the user change commodity manually
182
+ if ($skybox_category_id && ($skybox_category_id != $product->getData('skybox_category_id'))) {
183
+ $product->setData('skybox_category_id', $skybox_category_id);
184
+ $product->getResource()->save($product);
185
+ return $this;
186
+ }
187
+
188
+ // If commodity already set
189
+ if ($commodity) {
190
+ Mage::log('commodity_exist_true', null, 'skyboxcheckout.log', true);
191
+ return $this;
192
+ } else {
193
+ Mage::log('commodity_exist_false', null, 'skyboxcheckout.log', true);
194
+ $categoryIds = $product->getCategoryIds();
195
+
196
+ if (empty($categoryIds)) {
197
+ return $this;
198
+ }
199
+
200
+ $categoryId = reset($categoryIds); // current
201
+
202
+ /* $category Mage_Catalog_Model_Category */
203
+ $category = Mage::getModel('catalog/category')->load($categoryId);
204
+
205
+ $value = $category->getData('skybox_category_id');
206
+
207
+ if ($value) {
208
+ $product->setData('skybox_category_id', $value);
209
+ $product->getResource()->save($product);
210
+ } else {
211
+ Mage::getSingleton('adminhtml/session')->addError(
212
+ sprintf("The category %s doesn't have any associated commodity.", $category->getData('title'))
213
+ );
214
+ }
215
+ }
216
+ return $this;
217
+ }
218
+
219
+ /**
220
+ * Shortcut to getRequest
221
+ */
222
+ protected function _getRequest()
223
+ {
224
+ return Mage::app()->getRequest();
225
+ }
226
+
227
+ private function _bulk_commodities($categoryIds, $value, $allProducts = true)
228
+ {
229
+ /* @var $collection Mage_Catalog_Model_Product */
230
+ $collection = Mage::getModel('catalog/product')
231
+ ->getCollection()
232
+ ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
233
+ ->addAttributeToSelect('*')
234
+ ->addAttributeToFilter('category_id', array('in' => $categoryIds));
235
+
236
+ if (!$allProducts) {
237
+ $collection->addAttributeToFilter('skybox_category_id', array('null' => true));
238
+ }
239
+
240
+ $count = count($collection);
241
+
242
+ foreach ($collection as $product) {
243
+ try {
244
+ /** @var Mage_Catalog_Model_Product $product */
245
+ $product = $product;
246
+
247
+ if ($product->getTypeId() == 'configurable') {
248
+ /** @var Mage_Catalog_Model_Product $productChild */
249
+ // $childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product);
250
+ $childProducts = $product->getTypeInstance()->getUsedProductIds();
251
+ foreach ($childProducts as $key => $child) {
252
+ $productChild = Mage::getModel('catalog/product')->load($child);
253
+ $productChild->setData('skybox_category_id', $value);
254
+ $productChild->getResource()->save($productChild);
255
+ }
256
+ } else {
257
+ // Only setData if product->getTypeId() is 'simple'
258
+ $product->setData('skybox_category_id', $value);
259
+ $product->getResource()->save($product);
260
+ }
261
+ } catch (\Exception $ex) {
262
+ Mage::log("saveCategory() Exception: " . $ex->getMessage(), null, 'skyboxcheckout.log', true);
263
+ }
264
+ }
265
+
266
+ Mage::getSingleton('adminhtml/session')->addSuccess(
267
+ sprintf('%s products have been updated correctly.', $count)
268
+ );
269
+ }
270
+
271
  }
app/code/community/Skybox/Catalog/Model/Product/Attribute/Source/Categories.php CHANGED
@@ -1,39 +1,39 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Catalog
5
- *
6
- * @category Skybox
7
- * @package Skybox_Catalog
8
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Catalog_Model_Product_Attribute_Source_Categories extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
11
- {
12
- public $_options = null;
13
-
14
- public function getAllOptions()
15
- {
16
- if ($this->_options === null) {
17
- /* var @api_checkout Skybox_Checkout_Model_Api_Checkout */
18
- $api_checkout = Mage::getModel('skyboxcheckout/api_checkout');
19
- $categories = $api_checkout->GetCategories();
20
-
21
- $item = array(
22
- 'value' => '',
23
- 'label' => '',
24
- );
25
-
26
- $data[] = $item;
27
-
28
- foreach ($categories as $obj) {
29
- $item = array(
30
- 'value' => $obj->IdCommoditie,
31
- 'label' => $obj->Description,
32
- );
33
- $data[] = $item;
34
- }
35
- $this->_options = $data;
36
- }
37
- return $this->_options;
38
- }
39
  }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Catalog
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Catalog
8
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Catalog_Model_Product_Attribute_Source_Categories extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
11
+ {
12
+ public $_options = null;
13
+
14
+ public function getAllOptions()
15
+ {
16
+ if ($this->_options === null) {
17
+ /* var @api_checkout Skybox_Checkout_Model_Api_Checkout */
18
+ $api_checkout = Mage::getModel('skyboxcheckout/api_checkout');
19
+ $categories = $api_checkout->GetCategories();
20
+
21
+ $item = array(
22
+ 'value' => '',
23
+ 'label' => '',
24
+ );
25
+
26
+ $data[] = $item;
27
+
28
+ foreach ($categories as $obj) {
29
+ $item = array(
30
+ 'value' => $obj->IdCommoditie,
31
+ 'label' => $obj->Description,
32
+ );
33
+ $data[] = $item;
34
+ }
35
+ $this->_options = $data;
36
+ }
37
+ return $this->_options;
38
+ }
39
  }
app/code/community/Skybox/Catalog/Model/Product/Type/Price.php CHANGED
@@ -1,64 +1,64 @@
1
- <?php
2
- /**
3
- * Skybox Checkout
4
- *
5
- * @category Skybox
6
- * @package Skybox_Catalog
7
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
8
- */
9
-
10
- /**
11
- *
12
- * Skybox overriding product type price
13
- *
14
- * @author César Tapia M. <ctapia@skyworldint.com>
15
- */
16
- class Skybox_Catalog_Model_Product_Type_Price extends Mage_Catalog_Model_Product_Type_Price
17
- {
18
- protected $_typeApi = 'skyboxcatalog/api_product';
19
- protected $_api = null;
20
-
21
- protected function _getApi()
22
- {
23
- if(null === $this->_api)
24
- {
25
- $this->_api = Mage::getModel($this->_typeApi);
26
- }
27
-
28
- return $this->_api;
29
- }
30
-
31
- /**
32
- * Recupera el precio final del producto
33
- *
34
- * @param float|null $qty
35
- * @param Mage_Catalog_Model_Product $product
36
- * @return float
37
- */
38
- public function getFinalPrice($qty = null, $product)
39
- {
40
- /*if(!$this->_getApi()->getErrorAuthenticate() && $this->_getApi()->getLocationAllow())
41
- {
42
- if(is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
43
- return $product->getCalculatedFinalPrice();
44
- }
45
-
46
- $finalPrice= $this->getBasePrice($product, $qty);
47
- $product->setFinalPrice($finalPrice);
48
-
49
- Mage::dispatchEvent('catalog_product_get_final_price', array('product'=> $product, 'qty'=> $qty));
50
-
51
- $finalPrice = $product->getData('final_price');
52
- $finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
53
- $finalPrice = max(0, $finalPrice);
54
- //Call Calculate
55
- $this->_getApi()->CalculatePrice($product->getId(), $finalPrice);
56
- //Set final price for product
57
- $finalPrice = $this->_getApi()->getResponse()->TotalProduct;
58
- $product->setFinalPrice($finalPrice);
59
-
60
- return $finalPrice;
61
- }*/
62
- return parent::getFinalPrice($qty, $product);
63
- }
64
- }
1
+ <?php
2
+ /**
3
+ * Skybox Checkout
4
+ *
5
+ * @category Skybox
6
+ * @package Skybox_Catalog
7
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
8
+ */
9
+
10
+ /**
11
+ *
12
+ * Skybox overriding product type price
13
+ *
14
+ * @author César Tapia M. <ctapia@skyworldint.com>
15
+ */
16
+ class Skybox_Catalog_Model_Product_Type_Price extends Mage_Catalog_Model_Product_Type_Price
17
+ {
18
+ protected $_typeApi = 'skyboxcatalog/api_product';
19
+ protected $_api = null;
20
+
21
+ protected function _getApi()
22
+ {
23
+ if(null === $this->_api)
24
+ {
25
+ $this->_api = Mage::getModel($this->_typeApi);
26
+ }
27
+
28
+ return $this->_api;
29
+ }
30
+
31
+ /**
32
+ * Recupera el precio final del producto
33
+ *
34
+ * @param float|null $qty
35
+ * @param Mage_Catalog_Model_Product $product
36
+ * @return float
37
+ */
38
+ public function getFinalPrice($qty = null, $product)
39
+ {
40
+ /*if(!$this->_getApi()->getErrorAuthenticate() && $this->_getApi()->getLocationAllow())
41
+ {
42
+ if(is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
43
+ return $product->getCalculatedFinalPrice();
44
+ }
45
+
46
+ $finalPrice= $this->getBasePrice($product, $qty);
47
+ $product->setFinalPrice($finalPrice);
48
+
49
+ Mage::dispatchEvent('catalog_product_get_final_price', array('product'=> $product, 'qty'=> $qty));
50
+
51
+ $finalPrice = $product->getData('final_price');
52
+ $finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
53
+ $finalPrice = max(0, $finalPrice);
54
+ //Call Calculate
55
+ $this->_getApi()->CalculatePrice($product->getId(), $finalPrice);
56
+ //Set final price for product
57
+ $finalPrice = $this->_getApi()->getResponse()->TotalProduct;
58
+ $product->setFinalPrice($finalPrice);
59
+
60
+ return $finalPrice;
61
+ }*/
62
+ return parent::getFinalPrice($qty, $product);
63
+ }
64
+ }
app/code/community/Skybox/Catalog/Model/Resource/Setup.php CHANGED
@@ -1,12 +1,12 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Catalog
5
- *
6
- * @category Mage
7
- * @package Skybox_Catalog
8
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Catalog_Model_Resource_Setup extends Mage_Sales_Model_Mysql4_Setup
11
- {
12
  }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Catalog
5
+ *
6
+ * @category Mage
7
+ * @package Skybox_Catalog
8
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Catalog_Model_Resource_Setup extends Mage_Sales_Model_Mysql4_Setup
11
+ {
12
  }
app/code/community/Skybox/Catalog/etc/config.xml CHANGED
@@ -8,7 +8,7 @@
8
  </default>
9
  <modules>
10
  <Skybox_Catalog>
11
- <version>1.2.10</version>
12
  <codePool>community</codePool>
13
  </Skybox_Catalog>
14
  </modules>
8
  </default>
9
  <modules>
10
  <Skybox_Catalog>
11
+ <version>1.2.11</version>
12
  <codePool>community</codePool>
13
  </Skybox_Catalog>
14
  </modules>
app/code/community/Skybox/Catalog/sql/skyboxcatalog_setup/mysql4-install-0.1.0.php CHANGED
@@ -1,71 +1,71 @@
1
- <?php
2
-
3
- /* @var $installer Skybox_Catalog_Model_Resource_Setup */
4
- $installer = $this;
5
- $installer->startSetup();
6
-
7
- $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
8
-
9
- // Product
10
- $setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'skybox_category_id', array(
11
- 'group' => 'Prices',
12
- 'type' => Varien_Db_Ddl_Table::TYPE_VARCHAR,
13
- 'backend' => 'eav/entity_attribute_backend_array',
14
- 'frontend' => '',
15
- 'label' => 'SkyboxCheckout Category',
16
- 'input' => 'select',
17
- 'class' => '',
18
- 'source' => 'skyboxcatalog/product_attribute_source_categories',
19
- 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
20
- 'visible' => true,
21
- 'required' => false,
22
- 'user_defined' => true,
23
- 'default' => '',
24
- 'searchable' => false,
25
- 'filterable' => true,
26
- 'comparable' => false,
27
- 'visible_on_front' => true,
28
- 'unique' => false,
29
- 'apply_to' => 'simple,configurable,virtual',
30
- 'is_configurable' => false
31
- ));
32
-
33
- $setup->addAttributeToGroup(Mage_Catalog_Model_Product::ENTITY, 'Default', 'Prices', 'skybox_category_id', 100);
34
-
35
- // Category
36
- $setup->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'skybox_category_id', array(
37
- //$setup->updateAttribute('catalog_category', 'skybox_category_id', array(
38
- 'group' => 'SkyboxCheckout',
39
- 'type' => Varien_Db_Ddl_Table::TYPE_VARCHAR,
40
- 'backend' => 'eav/entity_attribute_backend_array',
41
- 'frontend' => '',
42
- 'label' => 'Default Commodity',
43
- 'input' => 'select',
44
- 'source' => 'skyboxcatalog/product_attribute_source_categories',
45
- 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
46
- 'visible' => true,
47
- 'required' => false,
48
- 'user_defined' => true,
49
- 'default' => ''
50
- ));
51
-
52
- // Category
53
- $setup->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'skybox_category_id_select', array(
54
- //$setup->updateAttribute('catalog_category', 'skybox_category_id', array(
55
- 'group' => 'SkyboxCheckout',
56
- 'type' => Varien_Db_Ddl_Table::TYPE_VARCHAR,
57
- 'backend' => 'eav/entity_attribute_backend_array',
58
- 'frontend' => '',
59
- 'label' => 'Select Commodity',
60
- 'input' => 'select',
61
- 'source' => 'skyboxcatalog/product_attribute_source_categories',
62
- 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
63
- 'visible' => true,
64
- 'required' => false,
65
- 'user_defined' => true,
66
- 'default' => ''
67
- ));
68
-
69
- $setup->addAttributeToGroup(Mage_Catalog_Model_Category::ENTITY, 'Default', 'SkyboxCheckout', 'skybox_category_id', 100);
70
-
71
  $installer->endSetup();
1
+ <?php
2
+
3
+ /* @var $installer Skybox_Catalog_Model_Resource_Setup */
4
+ $installer = $this;
5
+ $installer->startSetup();
6
+
7
+ $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
8
+
9
+ // Product
10
+ $setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'skybox_category_id', array(
11
+ 'group' => 'Prices',
12
+ 'type' => Varien_Db_Ddl_Table::TYPE_VARCHAR,
13
+ 'backend' => 'eav/entity_attribute_backend_array',
14
+ 'frontend' => '',
15
+ 'label' => 'SkyboxCheckout Category',
16
+ 'input' => 'select',
17
+ 'class' => '',
18
+ 'source' => 'skyboxcatalog/product_attribute_source_categories',
19
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
20
+ 'visible' => true,
21
+ 'required' => false,
22
+ 'user_defined' => true,
23
+ 'default' => '',
24
+ 'searchable' => false,
25
+ 'filterable' => true,
26
+ 'comparable' => false,
27
+ 'visible_on_front' => true,
28
+ 'unique' => false,
29
+ 'apply_to' => 'simple,configurable,virtual',
30
+ 'is_configurable' => false
31
+ ));
32
+
33
+ $setup->addAttributeToGroup(Mage_Catalog_Model_Product::ENTITY, 'Default', 'Prices', 'skybox_category_id', 100);
34
+
35
+ // Category
36
+ $setup->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'skybox_category_id', array(
37
+ //$setup->updateAttribute('catalog_category', 'skybox_category_id', array(
38
+ 'group' => 'SkyboxCheckout',
39
+ 'type' => Varien_Db_Ddl_Table::TYPE_VARCHAR,
40
+ 'backend' => 'eav/entity_attribute_backend_array',
41
+ 'frontend' => '',
42
+ 'label' => 'Default Commodity',
43
+ 'input' => 'select',
44
+ 'source' => 'skyboxcatalog/product_attribute_source_categories',
45
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
46
+ 'visible' => true,
47
+ 'required' => false,
48
+ 'user_defined' => true,
49
+ 'default' => ''
50
+ ));
51
+
52
+ // Category
53
+ $setup->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'skybox_category_id_select', array(
54
+ //$setup->updateAttribute('catalog_category', 'skybox_category_id', array(
55
+ 'group' => 'SkyboxCheckout',
56
+ 'type' => Varien_Db_Ddl_Table::TYPE_VARCHAR,
57
+ 'backend' => 'eav/entity_attribute_backend_array',
58
+ 'frontend' => '',
59
+ 'label' => 'Select Commodity',
60
+ 'input' => 'select',
61
+ 'source' => 'skyboxcatalog/product_attribute_source_categories',
62
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
63
+ 'visible' => true,
64
+ 'required' => false,
65
+ 'user_defined' => true,
66
+ 'default' => ''
67
+ ));
68
+
69
+ $setup->addAttributeToGroup(Mage_Catalog_Model_Category::ENTITY, 'Default', 'SkyboxCheckout', 'skybox_category_id', 100);
70
+
71
  $installer->endSetup();
app/code/community/Skybox/Checkout/Block/Cart/Item/Renderer.php CHANGED
@@ -1,12 +1,12 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Checkout
5
- *
6
- * @category Skybox
7
- * @package Skybox_Checkout
8
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Checkout_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_Item_Renderer
11
- {
12
  }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Checkout
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Checkout
8
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Checkout_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_Item_Renderer
11
+ {
12
  }
app/code/community/Skybox/Checkout/Block/Cart/Sidebar.php CHANGED
@@ -1,32 +1,32 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Checkout
5
- *
6
- * @category Skybox
7
- * @package Skybox_Checkout
8
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Checkout_Block_Cart_Sidebar extends Mage_Checkout_Block_Cart_Sidebar
11
- {
12
-
13
- /**
14
- * Get shopping cart subtotal.
15
- *
16
- * It will include tax, if required by config settings.
17
- *
18
- * @param bool $skipTax flag for getting price with tax or not. Ignored in case when we display just subtotal incl.tax
19
- * @return decimal
20
- */
21
- public function getSubtotal($skipTax = true)
22
- {
23
- $quote = $this->getQuote();
24
-
25
- /* $address Mage_Sales_Model_Quote_Address */
26
- $address = $quote->getShippingAddress();
27
-
28
- //$subtotal = $address->getSubtotalSkybox();
29
- $subtotal = $address->getSubtotal();
30
- return $subtotal;
31
- }
32
- }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Checkout
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Checkout
8
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Checkout_Block_Cart_Sidebar extends Mage_Checkout_Block_Cart_Sidebar
11
+ {
12
+
13
+ /**
14
+ * Get shopping cart subtotal.
15
+ *
16
+ * It will include tax, if required by config settings.
17
+ *
18
+ * @param bool $skipTax flag for getting price with tax or not. Ignored in case when we display just subtotal incl.tax
19
+ * @return decimal
20
+ */
21
+ public function getSubtotal($skipTax = true)
22
+ {
23
+ $quote = $this->getQuote();
24
+
25
+ /* $address Mage_Sales_Model_Quote_Address */
26
+ $address = $quote->getShippingAddress();
27
+
28
+ //$subtotal = $address->getSubtotalSkybox();
29
+ $subtotal = $address->getSubtotal();
30
+ return $subtotal;
31
+ }
32
+ }
app/code/community/Skybox/Checkout/Block/Cart/Totals.php CHANGED
@@ -1,157 +1,157 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Checkout
5
- *
6
- * @category Skybox
7
- * @package Skybox_Checkout
8
- * @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Checkout_Block_Cart_Totals extends Mage_Checkout_Block_Cart_Abstract
11
- {
12
- protected $_totalRenderers;
13
- protected $_defaultRenderer = 'checkout/total_default';
14
- protected $_totals = null;
15
-
16
- public function getTotals()
17
- {
18
- if (is_null($this->_totals)) {
19
- return parent::getTotals();
20
- }
21
- return $this->_totals;
22
- }
23
-
24
- public function setTotals($value)
25
- {
26
- $this->_totals = $value;
27
- return $this;
28
- }
29
-
30
- protected function _getTotalRenderer($code)
31
- {
32
- $blockName = $code . '_total_renderer';
33
- $block = $this->getLayout()->getBlock($blockName);
34
- if (!$block) {
35
- $block = $this->_defaultRenderer;
36
- $config = Mage::getConfig()->getNode("global/sales/quote/totals/{$code}/renderer");
37
- if ($config) {
38
- $block = (string)$config;
39
- }
40
-
41
- $block = $this->getLayout()->createBlock($block, $blockName);
42
- }
43
- /**
44
- * Transfer totals to renderer
45
- */
46
- $block->setTotals($this->getTotals());
47
- return $block;
48
- }
49
-
50
- public function renderTotal($total, $area = null, $colspan = 1)
51
- {
52
- $code = $total->getCode();
53
- /**
54
- * Integration 3 start, show price shop in cart*
55
- */
56
- $allowRunByIntegration3 = true;
57
- //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
58
- $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
59
- if ($typeIntegration == 3) {
60
- $allowRunByIntegration3 = false;
61
- }
62
-
63
- $locationAllow = Mage::getModel('skyboxcheckout/api_checkout')->getLocationAllow();
64
-
65
- /**
66
- * Integration 3 end, show price shop in cart*
67
- */
68
- if ($allowRunByIntegration3 && $locationAllow) {
69
- if ($code != "subtotal") {
70
- if ($total->getAs()) {
71
- $code = $total->getAs();
72
- }
73
- return $this->_getTotalRenderer($code)
74
- ->setTotal($total)
75
- ->setColspan($colspan)
76
- ->setRenderingArea(is_null($area) ? -1 : $area)
77
- ->toHtml();
78
- }
79
- } else {
80
- if ($total->getAs()) {
81
- $code = $total->getAs();
82
- }
83
- return $this->_getTotalRenderer($code)
84
- ->setTotal($total)
85
- ->setColspan($colspan)
86
- ->setRenderingArea(is_null($area) ? -1 : $area)
87
- ->toHtml();
88
-
89
- }
90
-
91
- }
92
-
93
- /**
94
- * Render totals html for specific totals area (footer, body)
95
- *
96
- * @param null|string $area
97
- * @param int $colspan
98
- * @return string
99
- */
100
- public function renderTotals($area = null, $colspan = 1)
101
- {
102
- $html = '';
103
- foreach ($this->getTotals() as $total) {
104
- if ($total->getArea() != $area && $area != -1) {
105
- continue;
106
- }
107
- $html .= $this->renderTotal($total, $area, $colspan);
108
- }
109
- return $html;
110
- }
111
-
112
- /**
113
- * Check if we have display grand total in base currency
114
- *
115
- * @return bool
116
- */
117
- public function needDisplayBaseGrandtotal()
118
- {
119
- $quote = $this->getQuote();
120
- if ($quote->getBaseCurrencyCode() != $quote->getQuoteCurrencyCode()) {
121
- return true;
122
- }
123
- return false;
124
- }
125
-
126
- /**
127
- * Get formated in base currency base grand total value
128
- *
129
- * @return string
130
- */
131
- public function displayBaseGrandtotal()
132
- {
133
- $firstTotal = reset($this->_totals);
134
- if ($firstTotal) {
135
- $total = $firstTotal->getAddress()->getBaseGrandTotal();
136
- return Mage::app()->getStore()->getBaseCurrency()->format($total, array(), true);
137
- }
138
- return '-';
139
- }
140
-
141
- /**
142
- * Get active or custom quote
143
- *
144
- * @return Mage_Sales_Model_Quote
145
- */
146
- public function getQuote()
147
- {
148
- if ($this->getCustomQuote()) {
149
- return $this->getCustomQuote();
150
- }
151
-
152
- if (null === $this->_quote) {
153
- $this->_quote = $this->getCheckout()->getQuote();
154
- }
155
- return $this->_quote;
156
- }
157
- }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Checkout
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Checkout
8
+ * @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Checkout_Block_Cart_Totals extends Mage_Checkout_Block_Cart_Abstract
11
+ {
12
+ protected $_totalRenderers;
13
+ protected $_defaultRenderer = 'checkout/total_default';
14
+ protected $_totals = null;
15
+
16
+ public function getTotals()
17
+ {
18
+ if (is_null($this->_totals)) {
19
+ return parent::getTotals();
20
+ }
21
+ return $this->_totals;
22
+ }
23
+
24
+ public function setTotals($value)
25
+ {
26
+ $this->_totals = $value;
27
+ return $this;
28
+ }
29
+
30
+ protected function _getTotalRenderer($code)
31
+ {
32
+ $blockName = $code . '_total_renderer';
33
+ $block = $this->getLayout()->getBlock($blockName);
34
+ if (!$block) {
35
+ $block = $this->_defaultRenderer;
36
+ $config = Mage::getConfig()->getNode("global/sales/quote/totals/{$code}/renderer");
37
+ if ($config) {
38
+ $block = (string)$config;
39
+ }
40
+
41
+ $block = $this->getLayout()->createBlock($block, $blockName);
42
+ }
43
+ /**
44
+ * Transfer totals to renderer
45
+ */
46
+ $block->setTotals($this->getTotals());
47
+ return $block;
48
+ }
49
+
50
+ public function renderTotal($total, $area = null, $colspan = 1)
51
+ {
52
+ $code = $total->getCode();
53
+ /**
54
+ * Integration 3 start, show price shop in cart*
55
+ */
56
+ $allowRunByIntegration3 = true;
57
+ //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
58
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
59
+ if ($typeIntegration == 3) {
60
+ $allowRunByIntegration3 = false;
61
+ }
62
+
63
+ $locationAllow = Mage::getModel('skyboxcheckout/api_checkout')->getLocationAllow();
64
+
65
+ /**
66
+ * Integration 3 end, show price shop in cart*
67
+ */
68
+ if ($allowRunByIntegration3 && $locationAllow) {
69
+ if ($code != "subtotal") {
70
+ if ($total->getAs()) {
71
+ $code = $total->getAs();
72
+ }
73
+ return $this->_getTotalRenderer($code)
74
+ ->setTotal($total)
75
+ ->setColspan($colspan)
76
+ ->setRenderingArea(is_null($area) ? -1 : $area)
77
+ ->toHtml();
78
+ }
79
+ } else {
80
+ if ($total->getAs()) {
81
+ $code = $total->getAs();
82
+ }
83
+ return $this->_getTotalRenderer($code)
84
+ ->setTotal($total)
85
+ ->setColspan($colspan)
86
+ ->setRenderingArea(is_null($area) ? -1 : $area)
87
+ ->toHtml();
88
+
89
+ }
90
+
91
+ }
92
+
93
+ /**
94
+ * Render totals html for specific totals area (footer, body)
95
+ *
96
+ * @param null|string $area
97
+ * @param int $colspan
98
+ * @return string
99
+ */
100
+ public function renderTotals($area = null, $colspan = 1)
101
+ {
102
+ $html = '';
103
+ foreach ($this->getTotals() as $total) {
104
+ if ($total->getArea() != $area && $area != -1) {
105
+ continue;
106
+ }
107
+ $html .= $this->renderTotal($total, $area, $colspan);
108
+ }
109
+ return $html;
110
+ }
111
+
112
+ /**
113
+ * Check if we have display grand total in base currency
114
+ *
115
+ * @return bool
116
+ */
117
+ public function needDisplayBaseGrandtotal()
118
+ {
119
+ $quote = $this->getQuote();
120
+ if ($quote->getBaseCurrencyCode() != $quote->getQuoteCurrencyCode()) {
121
+ return true;
122
+ }
123
+ return false;
124
+ }
125
+
126
+ /**
127
+ * Get formated in base currency base grand total value
128
+ *
129
+ * @return string
130
+ */
131
+ public function displayBaseGrandtotal()
132
+ {
133
+ $firstTotal = reset($this->_totals);
134
+ if ($firstTotal) {
135
+ $total = $firstTotal->getAddress()->getBaseGrandTotal();
136
+ return Mage::app()->getStore()->getBaseCurrency()->format($total, array(), true);
137
+ }
138
+ return '-';
139
+ }
140
+
141
+ /**
142
+ * Get active or custom quote
143
+ *
144
+ * @return Mage_Sales_Model_Quote
145
+ */
146
+ public function getQuote()
147
+ {
148
+ if ($this->getCustomQuote()) {
149
+ return $this->getCustomQuote();
150
+ }
151
+
152
+ if (null === $this->_quote) {
153
+ $this->_quote = $this->getCheckout()->getQuote();
154
+ }
155
+ return $this->_quote;
156
+ }
157
+ }
app/code/community/Skybox/Checkout/Block/Checkout/Cart.php CHANGED
@@ -1,45 +1,45 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category Mage
22
- * @package Mage_Checkout
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
-
27
- /**
28
- * Shopping cart block
29
- *
30
- * @category Mage
31
- * @package Mage_Checkout
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Skybox_Checkout_Block_Checkout_Cart extends Mage_Checkout_Block_Cart
35
- {
36
-
37
- public function getCheckoutUrl()
38
- {
39
- if (!$this->helper('checkout')->isRewriteCheckoutLinksEnabled()){
40
- return parent::getCheckoutUrl();
41
- }
42
- return $this->getUrl('skbcheckout/international', array('_secure'=>true));
43
- }
44
-
45
- }
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Checkout
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Shopping cart block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Checkout
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Skybox_Checkout_Block_Checkout_Cart extends Mage_Checkout_Block_Cart
35
+ {
36
+
37
+ public function getCheckoutUrl()
38
+ {
39
+ if (!$this->helper('checkout')->isRewriteCheckoutLinksEnabled()){
40
+ return parent::getCheckoutUrl();
41
+ }
42
+ return $this->getUrl('skbcheckout/international', array('_secure'=>true));
43
+ }
44
+
45
+ }
app/code/community/Skybox/Checkout/Block/Checkout/Cart/Sidebar.php CHANGED
@@ -1,16 +1,30 @@
1
- <?php
2
- class Skybox_Checkout_Block_Checkout_Cart_Sidebar extends Mage_Checkout_Block_Cart_Sidebar
3
- {
4
- /**
5
- * Get one page checkout page url
6
- *
7
- * @return bool
8
- */
9
- public function getCheckoutUrl()
10
- {
11
- if (!$this->helper('checkout')->isRewriteCheckoutLinksEnabled()){
12
- return parent::getCheckoutUrl();
13
- }
14
- return $this->getUrl('skbcheckout/international', array('_secure'=>true));
15
- }
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Skybox_Checkout_Block_Checkout_Cart_Sidebar extends Mage_Checkout_Block_Cart_Sidebar
3
+ {
4
+ /**
5
+ * Get one page checkout page url
6
+ *
7
+ * @return bool
8
+ */
9
+ public function getCheckoutUrl()
10
+ {
11
+ if (!$this->helper('checkout')->isRewriteCheckoutLinksEnabled()){
12
+ return parent::getCheckoutUrl();
13
+ }
14
+ return $this->getUrl('skbcheckout/international', array('_secure'=>true));
15
+ }
16
+
17
+ public function getSubtotal()
18
+ {
19
+ /** @var Skybox_Core_Helper_Allow $allowHelper */
20
+ $allowHelper = Mage::helper('skyboxcore/allow');
21
+ if ($allowHelper->isPriceEnabled()) {
22
+ $quote = $this->getQuote();
23
+ /** @var Mage_Sales_Model_Quote_Address $address */
24
+ $address = $quote->getShippingAddress();
25
+ $subtotal = $address->getSubtotal();
26
+ return $subtotal;
27
+ }
28
+ return parent::getSubtotal();
29
+ }
30
+ }
app/code/community/Skybox/Checkout/Block/Checkout/Links.php CHANGED
@@ -1,26 +1,26 @@
1
- <?php
2
- class Skybox_Checkout_Block_Checkout_Links extends Mage_Checkout_Block_Links
3
- {
4
- /**
5
- * Add link on checkout page to parent block
6
- *
7
- * @return Mage_Checkout_Block_Links
8
- */
9
- public function addCheckoutLink()
10
- {
11
- //Mage::log('get addCheckoutLink skybox', null, 'tracer.log', true);
12
-
13
- if (!$this->helper('checkout')->isRewriteCheckoutLinksEnabled()){
14
- return parent::addCheckoutLink();
15
- }
16
-
17
- if (!$this->helper('checkout')->canOnepageCheckout()) {
18
- return $this;
19
- }
20
- if ($parentBlock = $this->getParentBlock()) {
21
- $text = $this->__('Checkout');
22
- $parentBlock->addLink($text, 'skbcheckout/international', $text, true, array('_secure'=>true), 60, null, 'class="top-link-skybox"');
23
- }
24
- return $this;
25
- }
26
- }
1
+ <?php
2
+ class Skybox_Checkout_Block_Checkout_Links extends Mage_Checkout_Block_Links
3
+ {
4
+ /**
5
+ * Add link on checkout page to parent block
6
+ *
7
+ * @return Mage_Checkout_Block_Links
8
+ */
9
+ public function addCheckoutLink()
10
+ {
11
+ //Mage::log('get addCheckoutLink skybox', null, 'tracer.log', true);
12
+
13
+ if (!$this->helper('checkout')->isRewriteCheckoutLinksEnabled()){
14
+ return parent::addCheckoutLink();
15
+ }
16
+
17
+ if (!$this->helper('checkout')->canOnepageCheckout()) {
18
+ return $this;
19
+ }
20
+ if ($parentBlock = $this->getParentBlock()) {
21
+ $text = $this->__('Checkout');
22
+ $parentBlock->addLink($text, 'skbcheckout/international', $text, true, array('_secure'=>true), 60, null, 'class="top-link-skybox"');
23
+ }
24
+ return $this;
25
+ }
26
+ }
app/code/community/Skybox/Checkout/Block/Checkout/Onepage/Link.php CHANGED
@@ -1,43 +1,43 @@
1
- <?php
2
- class Skybox_Checkout_Block_Checkout_Onepage_Link extends Mage_Checkout_Block_Onepage_Link
3
- {
4
- public function getCheckoutUrl()
5
- {
6
- // TODO: Refactoring
7
-
8
- // $isEnabled = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
9
- $isEnabled = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
10
-
11
- /**
12
- * Integration 3 start
13
- * Give to button a url by default in case is type 3
14
- */
15
- $api = Mage::getModel('skyboxcatalog/api_product');
16
- //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
17
- $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
18
- if (($api->getLocationAllow()==3) && $typeIntegration==3) {
19
- return parent::getCheckoutUrl();
20
- }
21
- /**
22
- * Integration 3 end
23
- */
24
-
25
- if($isEnabled) {
26
- return $this->getUrl('skbcheckout/international', array('_secure'=>true));
27
- }
28
- /*
29
- if (Mage::helper('onestepcheckout')->isRewriteCheckoutLinksEnabled()){
30
- return $this->getUrl('onestepcheckout', array('_secure'=>true));
31
- }
32
- */
33
- /*
34
- Mage::log('get getCheckoutUrl skybox', null, 'tracer.log', true);
35
- if (!$this->helper('checkout')->isRewriteCheckoutLinksEnabled()){
36
- return parent::getCheckoutUrl();
37
- }
38
- */
39
-
40
- return parent::getCheckoutUrl();
41
-
42
- }
43
- }
1
+ <?php
2
+ class Skybox_Checkout_Block_Checkout_Onepage_Link extends Mage_Checkout_Block_Onepage_Link
3
+ {
4
+ public function getCheckoutUrl()
5
+ {
6
+ // TODO: Refactoring
7
+
8
+ // $isEnabled = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
9
+ $isEnabled = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
10
+
11
+ /**
12
+ * Integration 3 start
13
+ * Give to button a url by default in case is type 3
14
+ */
15
+ $api = Mage::getModel('skyboxcatalog/api_product');
16
+ //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
17
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
18
+ if (($api->getLocationAllow()==3) && $typeIntegration==3) {
19
+ return parent::getCheckoutUrl();
20
+ }
21
+ /**
22
+ * Integration 3 end
23
+ */
24
+
25
+ if($isEnabled) {
26
+ return $this->getUrl('skbcheckout/international', array('_secure'=>true));
27
+ }
28
+ /*
29
+ if (Mage::helper('onestepcheckout')->isRewriteCheckoutLinksEnabled()){
30
+ return $this->getUrl('onestepcheckout', array('_secure'=>true));
31
+ }
32
+ */
33
+ /*
34
+ Mage::log('get getCheckoutUrl skybox', null, 'tracer.log', true);
35
+ if (!$this->helper('checkout')->isRewriteCheckoutLinksEnabled()){
36
+ return parent::getCheckoutUrl();
37
+ }
38
+ */
39
+
40
+ return parent::getCheckoutUrl();
41
+
42
+ }
43
+ }
app/code/community/Skybox/Checkout/Block/Sales/Order/Total.php CHANGED
@@ -1,71 +1,92 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Checkout
5
- *
6
- * @category Skybox
7
- * @package Skybox_Checkout
8
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Checkout_Block_Sales_Order_Total extends Mage_Sales_Block_Order_Totals
11
- {
12
- public function initTotals()
13
- {
14
- parent::_initTotals();
15
-
16
- if ($this->isEnable()) {
17
- return $this;
18
- }
19
-
20
- $order = $this->getOrder();
21
-
22
- //Mage::log('$order', null, 'tracer.log', true);
23
- //Mage::log(print_r($order->debug(), true), null, 'tracer.log', true);
24
-
25
- $ConceptsSkyboxjson = json_decode($order->getConceptsSkybox());
26
-
27
- //Mage::log('$ConceptsSkyboxjson', null, 'tracer.log', true);
28
- // Mage::log(print_r($ConceptsSkyboxjson, true), null, 'tracer.log', true);
29
- if (count($ConceptsSkyboxjson) > 0) {
30
- $i = 0;
31
- foreach ($ConceptsSkyboxjson as $item) {
32
- if ($item->Visible != 0) {
33
- $i += 1;
34
- $this->getParentBlock()->addTotal(new Varien_Object(array(
35
- 'code' => 'checkout_total' . $i,
36
- 'value' => $item->ValueUSD,//$item->Value
37
- 'base_value' => $item->ValueUSD,//$item->Value
38
- 'label' => $item->Concept,
39
- )), 'subtotal', 'tax');
40
- }
41
- }
42
- if ($order->getShippingAmount() == 0) {
43
- $this->getParentBlock()->removeTotal('shipping');
44
- }
45
- }
46
-
47
- return $this;
48
- }
49
-
50
- private function isEnable()
51
- {
52
- /** @var Skybox_Core_Model_Api_Restful $api_restful */
53
- $api_restful = Mage::getModel('skyboxcore/api_restful');
54
- $activation = $api_restful->isModuleEnable();
55
-
56
- if (!$activation) {
57
- return false;
58
- }
59
-
60
- /** @var Skybox_Core_Helper_Allow $allowHelper */
61
- $allowHelper = Mage::helper('skyboxcore/allow');
62
-
63
- $locationAllow = $allowHelper->getLocationAllow();
64
-
65
- if (!$locationAllow) {
66
- return false;
67
- }
68
-
69
- return true;
70
- }
71
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Checkout
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Checkout
8
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Checkout_Block_Sales_Order_Total extends Mage_Sales_Block_Order_Totals
11
+ {
12
+ public function initTotals()
13
+ {
14
+ parent::_initTotals();
15
+
16
+ if ($this->isEnable()) {
17
+ return $this;
18
+ }
19
+
20
+ $order = $this->getOrder();
21
+
22
+ // Mage::log('$order', null, 'tracer.log', true);
23
+ // Mage::log(print_r($order->debug(), true), null, 'tracer.log', true);
24
+
25
+ $objData = json_decode($order->getConceptsSkybox());
26
+
27
+ // Mage::log('$ConceptsSkyboxjson', null, 'tracer.log', true);
28
+ // Mage::log(print_r($ConceptsSkyboxjson, true), null, 'tracer.log', true);
29
+
30
+ if (count($objData) > 0) {
31
+
32
+ if (isset($objData->TotalFeeUSD)) {
33
+ $this->getParentBlock()->addTotal(new Varien_Object(array(
34
+ 'code' => 'checkout_total_skybox_fee',
35
+ 'value' => $objData->TotalFeeUSD,
36
+ 'base_value' => $objData->TotalFeeUSD,
37
+ 'label' => 'SkyBoxCheckout',
38
+ )), 'subtotal', 'tax');
39
+
40
+ if ($order->getShippingAmount() == 0) {
41
+ $this->getParentBlock()->removeTotal('shipping');
42
+ }
43
+
44
+ } else {
45
+
46
+ // @note: Only for compatibility, should be removed.
47
+ $i = 0;
48
+
49
+ $ConceptsSkyboxjson = json_decode($order->getConceptsSkybox());
50
+
51
+ foreach ($ConceptsSkyboxjson as $item) {
52
+ if ($item->Visible != 0) {
53
+ $i += 1;
54
+ $this->getParentBlock()->addTotal(new Varien_Object(array(
55
+ 'code' => 'checkout_total' . $i,
56
+ 'value' => $item->ValueUSD,//$item->Value
57
+ 'base_value' => $item->ValueUSD,//$item->Value
58
+ 'label' => $item->Concept,
59
+ )), 'subtotal', 'tax');
60
+ }
61
+ }
62
+ if ($order->getShippingAmount() == 0) {
63
+ $this->getParentBlock()->removeTotal('shipping');
64
+ }
65
+ }
66
+ }
67
+
68
+ return $this;
69
+ }
70
+
71
+ private function isEnable()
72
+ {
73
+ /** @var Skybox_Core_Model_Api_Restful $api_restful */
74
+ $api_restful = Mage::getModel('skyboxcore/api_restful');
75
+ $activation = $api_restful->isModuleEnable();
76
+
77
+ if ( ! $activation) {
78
+ return false;
79
+ }
80
+
81
+ /** @var Skybox_Core_Helper_Allow $allowHelper */
82
+ $allowHelper = Mage::helper('skyboxcore/allow');
83
+
84
+ $locationAllow = $allowHelper->getLocationAllow();
85
+
86
+ if ( ! $locationAllow) {
87
+ return false;
88
+ }
89
+
90
+ return true;
91
+ }
92
+ }
app/code/community/Skybox/Checkout/Helper/Data.php CHANGED
@@ -1,156 +1,156 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Checkout
5
- *
6
- * @category Skybox
7
- * @package Skybox_Checkout
8
- * @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Checkout_Helper_Data extends Mage_Checkout_Helper_Data
11
- {
12
- protected $_api = null;
13
-
14
- /**
15
- * Returns the helper for Location Allow
16
- *
17
- * @return Skybox_Core_Helper_Allow
18
- */
19
- protected function _getAllowHelper()
20
- {
21
- return Mage::helper('skyboxcore/allow');
22
- }
23
-
24
- protected function _getApi()
25
- {
26
- if (null === $this->_api) {
27
- $this->_api = Mage::getModel('skyboxcatalog/api_product');
28
- }
29
- return $this->_api;
30
- }
31
-
32
- public function formatPrice($price)
33
- {
34
-
35
- if (!$this->isRewriteCheckoutLinksEnabled()) {
36
- return parent::formatPrice($price);
37
- }
38
-
39
- if (!$this->_getAllowHelper()->isPriceEnabled()) {
40
- return parent::formatPrice($price);
41
- }
42
-
43
- /* @var $config Skybox_Core_Model_Config */
44
- /*$config = Mage::getModel("skyboxcore/config");
45
- $skybox_user = $config->getSession()->getSkyboxUser();
46
- $currency = $skybox_user->CartCurrencySymbol;
47
- //return '<span class="price">' . $currency . ' ' . number_format($price, 2) . '</span>';
48
- return '<span class="price">' . $currency . ' ' . $price . '</span>';*/
49
- /* @var $config Skybox_Core_Model_Config */
50
-
51
- $config = Mage::getModel("skyboxcore/config");
52
- $skybox_user = $config->getSession()->getSkyboxUser();
53
-
54
- if ($this->_getApi()->getLocationAllow()) {
55
- $currency = $skybox_user->CartCurrencySymbol;
56
- } else {
57
- $currency = Mage::app()->getLocale()->currency($currency_code)->getSymbol();
58
- }
59
-
60
- /**
61
- * Integration 3 Allow and not Allow start currency kind on cart
62
- *
63
- $request = Mage::app()->getRequest();
64
- $module = $request->getModuleName();
65
- $controller = $request->getControllerName();
66
- $action = $request->getActionName();
67
- //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
68
- $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
69
-
70
- if ($module == 'checkout' && $controller == 'cart' && $action == 'index') {
71
- if ($typeIntegration == 3) {
72
- $currency = Mage::app()->getLocale()->currency($currency_code)->getSymbol();
73
- }
74
- }
75
- */
76
-
77
- /**
78
- * Integration 3 Allow and not Allow end currency kind on cart
79
- */
80
-
81
- //Mage::log("currency".$currency, null, 'cartlabels.log', true);
82
- $price = str_replace(',', '', $price);
83
- //Mage::log("precio".$price, null, 'cartlabels.log', true);
84
- $price = Mage::getModel('directory/currency')->setData("currency_code",
85
- Mage::app()->getStore(null)->getCurrentCurrency()->getCode())->format(
86
- $price, array('display' => Zend_Currency::NO_SYMBOL), false);
87
-
88
- if ($price < 0) {
89
- return '<span class="price">(' . $currency . " " . $price . ')</span>';
90
- }
91
- return '<span class="price">' . $currency . " " . $price . '</span>';
92
-
93
- }
94
-
95
- /**
96
- * @deprecated
97
- */
98
- public function getLayoutCheckoutSkybox()
99
- {
100
- $page_layout = Mage::getStoreConfig('customize_your_own');
101
-
102
- if ($this->_getApi()->getLocationAllow()) {
103
- $page_layout = 'skybox/checkout/onepage.phtml';
104
- } else {
105
- $page_layout = 'checkout/onepage.phtml';
106
- }
107
-
108
- /**
109
- * Integration 3 start
110
- *
111
- */
112
- //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
113
- $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
114
- if ($typeIntegration == 3 && $this->_getApi()->getLocationAllow() == 3) {
115
- $page_layout = 'checkout/onepage.phtml';
116
- }
117
- /**
118
- * Integration 3 end
119
- */
120
-
121
- return $page_layout;
122
- }
123
-
124
- public function isRewriteCheckoutLinksEnabled()
125
- {
126
- // return (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
127
- return Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
128
- }
129
-
130
- public function concatNameDetailProduct($product, $sku = null)
131
- {
132
- Mage::log('concatNameDetailProduct', null, 'tracer.log');
133
- $attributesConcat = '';
134
- if ($product->getData('type_id') == 'configurable') {
135
- $options = $this->getAllAttributesVariantConfigurableProducts($product);
136
- $attributesData = $options[$product->getId()][$sku];
137
- $attributesConcat = implode(', ', $attributesData);
138
- }
139
- return $attributesConcat;
140
- }
141
-
142
- public function getAllAttributesVariantConfigurableProducts($configurableProduct)
143
- {
144
- $attributes = array();
145
- $productAttributesOptions = $configurableProduct->getTypeInstance(true)->getConfigurableOptions($configurableProduct);
146
- foreach ($productAttributesOptions as $productAttributeOption) {
147
- $attributes[$configurableProduct->getId()] = array();
148
- foreach ($productAttributeOption as $optionValues) {
149
- $val = ($optionValues['option_title']);
150
- $attributes[$configurableProduct->getId()][$optionValues['sku']][] = $optionValues['attribute_code'] . '-' . $val;
151
- }
152
- }
153
- Mage::log(print_r($attributes, true), null, 'tracer.log');
154
- return $attributes;
155
- }
156
- }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Checkout
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Checkout
8
+ * @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Checkout_Helper_Data extends Mage_Checkout_Helper_Data
11
+ {
12
+ protected $_api = null;
13
+
14
+ /**
15
+ * Returns the helper for Location Allow
16
+ *
17
+ * @return Skybox_Core_Helper_Allow
18
+ */
19
+ protected function _getAllowHelper()
20
+ {
21
+ return Mage::helper('skyboxcore/allow');
22
+ }
23
+
24
+ protected function _getApi()
25
+ {
26
+ if (null === $this->_api) {
27
+ $this->_api = Mage::getModel('skyboxcatalog/api_product');
28
+ }
29
+ return $this->_api;
30
+ }
31
+
32
+ public function formatPrice($price)
33
+ {
34
+
35
+ if (!$this->isRewriteCheckoutLinksEnabled()) {
36
+ return parent::formatPrice($price);
37
+ }
38
+
39
+ if (!$this->_getAllowHelper()->isPriceEnabled()) {
40
+ return parent::formatPrice($price);
41
+ }
42
+
43
+ /* @var $config Skybox_Core_Model_Config */
44
+ /*$config = Mage::getModel("skyboxcore/config");
45
+ $skybox_user = $config->getSession()->getSkyboxUser();
46
+ $currency = $skybox_user->CartCurrencySymbol;
47
+ //return '<span class="price">' . $currency . ' ' . number_format($price, 2) . '</span>';
48
+ return '<span class="price">' . $currency . ' ' . $price . '</span>';*/
49
+ /* @var $config Skybox_Core_Model_Config */
50
+
51
+ $config = Mage::getModel("skyboxcore/config");
52
+ $skybox_user = $config->getSession()->getSkyboxUser();
53
+
54
+ if ($this->_getApi()->getLocationAllow()) {
55
+ $currency = $skybox_user->CartCurrencySymbol;
56
+ } else {
57
+ $currency = Mage::app()->getLocale()->currency($currency_code)->getSymbol();
58
+ }
59
+
60
+ /**
61
+ * Integration 3 Allow and not Allow start currency kind on cart
62
+ *
63
+ $request = Mage::app()->getRequest();
64
+ $module = $request->getModuleName();
65
+ $controller = $request->getControllerName();
66
+ $action = $request->getActionName();
67
+ //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
68
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
69
+
70
+ if ($module == 'checkout' && $controller == 'cart' && $action == 'index') {
71
+ if ($typeIntegration == 3) {
72
+ $currency = Mage::app()->getLocale()->currency($currency_code)->getSymbol();
73
+ }
74
+ }
75
+ */
76
+
77
+ /**
78
+ * Integration 3 Allow and not Allow end currency kind on cart
79
+ */
80
+
81
+ //Mage::log("currency".$currency, null, 'cartlabels.log', true);
82
+ $price = str_replace(',', '', $price);
83
+ //Mage::log("precio".$price, null, 'cartlabels.log', true);
84
+ $price = Mage::getModel('directory/currency')->setData("currency_code",
85
+ Mage::app()->getStore(null)->getCurrentCurrency()->getCode())->format(
86
+ $price, array('display' => Zend_Currency::NO_SYMBOL), false);
87
+
88
+ if ($price < 0) {
89
+ return '<span class="price">(' . $currency . " " . $price . ')</span>';
90
+ }
91
+ return '<span class="price">' . $currency . " " . $price . '</span>';
92
+
93
+ }
94
+
95
+ /**
96
+ * @deprecated
97
+ */
98
+ public function getLayoutCheckoutSkybox()
99
+ {
100
+ $page_layout = Mage::getStoreConfig('customize_your_own');
101
+
102
+ if ($this->_getApi()->getLocationAllow()) {
103
+ $page_layout = 'skybox/checkout/onepage.phtml';
104
+ } else {
105
+ $page_layout = 'checkout/onepage.phtml';
106
+ }
107
+
108
+ /**
109
+ * Integration 3 start
110
+ *
111
+ */
112
+ //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
113
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
114
+ if ($typeIntegration == 3 && $this->_getApi()->getLocationAllow() == 3) {
115
+ $page_layout = 'checkout/onepage.phtml';
116
+ }
117
+ /**
118
+ * Integration 3 end
119
+ */
120
+
121
+ return $page_layout;
122
+ }
123
+
124
+ public function isRewriteCheckoutLinksEnabled()
125
+ {
126
+ // return (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
127
+ return Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
128
+ }
129
+
130
+ public function concatNameDetailProduct($product, $sku = null)
131
+ {
132
+ Mage::log('concatNameDetailProduct', null, 'tracer.log');
133
+ $attributesConcat = '';
134
+ if ($product->getData('type_id') == 'configurable') {
135
+ $options = $this->getAllAttributesVariantConfigurableProducts($product);
136
+ $attributesData = $options[$product->getId()][$sku];
137
+ $attributesConcat = implode(', ', $attributesData);
138
+ }
139
+ return $attributesConcat;
140
+ }
141
+
142
+ public function getAllAttributesVariantConfigurableProducts($configurableProduct)
143
+ {
144
+ $attributes = array();
145
+ $productAttributesOptions = $configurableProduct->getTypeInstance(true)->getConfigurableOptions($configurableProduct);
146
+ foreach ($productAttributesOptions as $productAttributeOption) {
147
+ $attributes[$configurableProduct->getId()] = array();
148
+ foreach ($productAttributeOption as $optionValues) {
149
+ $val = ($optionValues['option_title']);
150
+ $attributes[$configurableProduct->getId()][$optionValues['sku']][] = $optionValues['attribute_code'] . '-' . $val;
151
+ }
152
+ }
153
+ Mage::log(print_r($attributes, true), null, 'tracer.log');
154
+ return $attributes;
155
+ }
156
+ }
app/code/community/Skybox/Checkout/Helper/Url.php CHANGED
@@ -1,59 +1,59 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category Mage
22
- * @package Mage_Checkout
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
-
27
- /**
28
- * Checkout url helper
29
- *
30
- * @author Magento Core Team <core@magentocommerce.com>
31
- */
32
- class Skybox_Checkout_Helper_Url extends Mage_Checkout_Helper_Url
33
- {
34
- /**
35
- * Retrieve checkout url
36
- *
37
- * @return string
38
- */
39
- public function getCheckoutUrl()
40
- {
41
-
42
- // $isEnabled = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
43
- $isEnabled = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
44
-
45
- if ($isEnabled) {
46
- return $this->_getUrl('skbcheckout/international', array('_secure'=>true));
47
- }
48
-
49
- /*if (Mage::helper('onestepcheckout')->isRewriteCheckoutLinksEnabled()){
50
- return $this->_getUrl('onestepcheckout', array('_secure'=>true));
51
- }*/
52
-
53
- if (!Mage::helper('checkout')->isRewriteCheckoutLinksEnabled()){
54
- return parent::getCheckoutUrl();
55
- }
56
-
57
- return parent::getCheckoutUrl();
58
- }
59
  }
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Checkout
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Checkout url helper
29
+ *
30
+ * @author Magento Core Team <core@magentocommerce.com>
31
+ */
32
+ class Skybox_Checkout_Helper_Url extends Mage_Checkout_Helper_Url
33
+ {
34
+ /**
35
+ * Retrieve checkout url
36
+ *
37
+ * @return string
38
+ */
39
+ public function getCheckoutUrl()
40
+ {
41
+
42
+ // $isEnabled = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
43
+ $isEnabled = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
44
+
45
+ if ($isEnabled) {
46
+ return $this->_getUrl('skbcheckout/international', array('_secure'=>true));
47
+ }
48
+
49
+ /*if (Mage::helper('onestepcheckout')->isRewriteCheckoutLinksEnabled()){
50
+ return $this->_getUrl('onestepcheckout', array('_secure'=>true));
51
+ }*/
52
+
53
+ if (!Mage::helper('checkout')->isRewriteCheckoutLinksEnabled()){
54
+ return parent::getCheckoutUrl();
55
+ }
56
+
57
+ return parent::getCheckoutUrl();
58
+ }
59
  }
app/code/community/Skybox/Checkout/Model/Api/Checkout.php CHANGED
@@ -1,223 +1,223 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Checkout
5
- *
6
- * @category Skybox
7
- * @package Skybox_Checkout
8
- * @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Checkout_Model_Api_Checkout extends Skybox_Core_Model_Standard
11
- {
12
-
13
- /**
14
- * Model instance
15
- * @var Mage_Core_Catalog_Model_Product
16
- */
17
- protected $_product = null;
18
-
19
- protected $_currentProduct = null;
20
-
21
- protected $_typeProduct = "catalog/product";
22
-
23
- public function getProduct()
24
- {
25
- if (null === $this->_product)
26
- $this->_product = Mage::getModel($this->_typeProduct);
27
-
28
- return $this->_product;
29
- }
30
-
31
- public function InitializeBarSkybox()
32
- {
33
- //if(!$this->getErrorAuthenticate())
34
- //{
35
- //$this->_config = Mage::getModel('skyboxcore/config');
36
- Mage::log("InitializeBarSkybox ", null, 'checkout.log', true);
37
-
38
- $params = array(
39
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
40
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
41
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
42
- 'customeriplocal' => $this->_getConfig()->getHost(),
43
- 'customeripremote' => $this->_getConfig()->getRemoteAddr(),
44
- 'customeripproxy' => $this->_getConfig()->getProxy(),
45
- 'customerbrowser' => $this->_getConfig()->getUserAgent(),
46
- 'customerlanguages' => $this->_getConfig()->getLanguage()
47
- );
48
-
49
- //$response = $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_INITIALICE, $params)->getResponse();
50
- /**
51
- * only one time for call to service start
52
- */
53
- $session = Mage::getSingleton("core/session", array("name"=>"frontend"));
54
- $callToSkyBox = $session->getData("callToSkyBox");
55
-
56
- //Mage::log($callToSkyBox, null, 'local.log', true);
57
- $initialize = $this->_getConfig()->getSession()->getCartSkybox();
58
- if (!empty($initialize) && (!$callToSkyBox)) {
59
- $response = $initialize;
60
- } else {
61
- $response = $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_INITIALICE, $params)->getResponse();
62
- $session->setData("callToSkyBox", false);
63
- }
64
- // $response = $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_INITIALICE, $params)->getResponse();
65
- // $session->setData("callToSkyBox", false);
66
- /**
67
- * only one time for call to service end
68
- */
69
- // Set SkyboxUser session
70
- $this->_getConfig()->getSession()->setSkyboxUser($response);
71
-
72
- //if ($this->getLocationAllow()) { // Rogged, la primera vez q usuario ingresa con un pais disabled, lanza error porq no se envia datos a url de popup
73
- $this->_getConfig()->getSession()->setCartSkybox($response);
74
- //}
75
- //}
76
- }
77
-
78
- public function setCurrentProduct($product)
79
- {
80
- $this->_currentProduct = $product;
81
- }
82
- public function getCurrentProduct()
83
- {
84
- return $this->_currentProduct;
85
- }
86
-
87
- public function AddProductOfCart($data, $quantity)
88
- {
89
- $detailProduct = Mage::helper('checkout')->concatNameDetailProduct($this->getCurrentProduct(), $data['sku']);
90
-
91
- //Mage::log("entro AddProductOfCart", null, 'tracer.log', true);
92
- if ($this->getErrorAuthenticate() && !$this->getLocationAllow()) {
93
- return $this;
94
- }
95
-
96
- Mage::log("AddProductOfCart: " . print_r($data, true), null, 'skyboxcheckout.log', true);
97
-
98
- $storeProductName = $data['name'].' '.$detailProduct;
99
-
100
- $params = array(
101
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
102
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
103
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
104
- 'productid' => "0",
105
- 'quantity' => $quantity,
106
- 'storeproductcode' => $data['sku'],
107
- 'storeproductname' => $storeProductName,
108
- 'storeproductcategory' => $data['category_id'],
109
- 'storeproductprice' => $data['final_price'],
110
- 'weight' => ($data['weight'])?($data['weight']):1,
111
- 'weightunit' => $this->getWeightUnit(),
112
- 'storeproductimgurl' => $data['image_url'],
113
- 'VolWeight' => $data['VolWeight'],
114
- 'merchantproductid' => $data['merchantproductid']
115
- );
116
- $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_ADD_PRODUCT_CART, $params);
117
-
118
- return $this;
119
- }
120
-
121
- public function GetTotalShoppingCart()
122
- {
123
- if ($this->getErrorAuthenticate() && !$this->getLocationAllow()) {
124
- return $this;
125
- }
126
-
127
- $params = array(
128
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
129
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
130
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi()
131
- );
132
-
133
- $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_GET_TOTAL_SHOPINGCART, $params);
134
-
135
- return $this;
136
- }
137
-
138
- public function UpdateProductOfCart($productId, $quantity)
139
- {
140
- if (!$this->getErrorAuthenticate() && $this->getLocationAllow()) {
141
- $this->getProduct()->load($productId);
142
- $params = array(
143
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
144
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
145
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
146
- 'productid' => $productId,
147
- 'quantity' => $quantity
148
- );
149
-
150
- $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_UPDATE_PRODUCT_CART, $params);
151
- }
152
-
153
- return $this;
154
- }
155
-
156
- public function DeleteProductOfCart($productId)
157
- {
158
-
159
- #if (!$this->getErrorAuthenticate() && $this->getLocationAllow()) { // Rogged
160
- if (!$this->getErrorAuthenticate()) { // Rogged
161
- $params = array(
162
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
163
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
164
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
165
- 'productid' => $productId
166
- );
167
-
168
- $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_DELETE_PRODUCT_CART, $params);
169
- }
170
-
171
- return $this;
172
- }
173
-
174
- public function getCartSkybox()
175
- {
176
- if (!$this->getErrorAuthenticate() && $this->getLocationAllow()) {
177
- //$this->_config = Mage::getModel('skyboxcore/config');
178
- return $this->_getConfig()->getSession()->getCartSkybox();
179
- }
180
- return "";
181
- }
182
-
183
- /*
184
- * Get Categories
185
- *
186
- * @return $data json
187
- */
188
-
189
- public function GetCategories()
190
- {
191
- $params = array(
192
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
193
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken()
194
- );
195
-
196
- /* var $response Skybox_Core_Model_Standard */
197
- $response = $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_CATEGORIES, $params);
198
- $jsonData = $response->getResponse()->{'Categories'};
199
- return $jsonData;
200
- }
201
-
202
- public function getValueAccessService()
203
- {
204
- $params = array(
205
- "merchantCode" => $this->getMerchant(),
206
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
207
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
208
-
209
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
210
- 'customeriplocal' => $this->_getConfig()->getHost(),
211
- 'customeripremote' => $this->_getConfig()->getRemoteAddr(),
212
- 'customeripproxy' => $this->_getConfig()->getProxy(),
213
- 'customerbrowser' => $this->_getConfig()->getUserAgent(),
214
- 'customerlanguages' => $this->_getConfig()->getLanguage()
215
-
216
-
217
- );
218
-
219
-
220
- return $params;
221
-
222
- }
223
  }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Checkout
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Checkout
8
+ * @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Checkout_Model_Api_Checkout extends Skybox_Core_Model_Standard
11
+ {
12
+
13
+ /**
14
+ * Model instance
15
+ * @var Mage_Core_Catalog_Model_Product
16
+ */
17
+ protected $_product = null;
18
+
19
+ protected $_currentProduct = null;
20
+
21
+ protected $_typeProduct = "catalog/product";
22
+
23
+ public function getProduct()
24
+ {
25
+ if (null === $this->_product)
26
+ $this->_product = Mage::getModel($this->_typeProduct);
27
+
28
+ return $this->_product;
29
+ }
30
+
31
+ public function InitializeBarSkybox()
32
+ {
33
+ //if(!$this->getErrorAuthenticate())
34
+ //{
35
+ //$this->_config = Mage::getModel('skyboxcore/config');
36
+ Mage::log("InitializeBarSkybox ", null, 'checkout.log', true);
37
+
38
+ $params = array(
39
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
40
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
41
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
42
+ 'customeriplocal' => $this->_getConfig()->getHost(),
43
+ 'customeripremote' => $this->_getConfig()->getRemoteAddr(),
44
+ 'customeripproxy' => $this->_getConfig()->getProxy(),
45
+ 'customerbrowser' => $this->_getConfig()->getUserAgent(),
46
+ 'customerlanguages' => $this->_getConfig()->getLanguage()
47
+ );
48
+
49
+ //$response = $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_INITIALICE, $params)->getResponse();
50
+ /**
51
+ * only one time for call to service start
52
+ */
53
+ $session = Mage::getSingleton("core/session", array("name"=>"frontend"));
54
+ $callToSkyBox = $session->getData("callToSkyBox");
55
+
56
+ //Mage::log($callToSkyBox, null, 'local.log', true);
57
+ $initialize = $this->_getConfig()->getSession()->getCartSkybox();
58
+ if (!empty($initialize) && (!$callToSkyBox)) {
59
+ $response = $initialize;
60
+ } else {
61
+ $response = $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_INITIALICE, $params)->getResponse();
62
+ $session->setData("callToSkyBox", false);
63
+ }
64
+ // $response = $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_INITIALICE, $params)->getResponse();
65
+ // $session->setData("callToSkyBox", false);
66
+ /**
67
+ * only one time for call to service end
68
+ */
69
+ // Set SkyboxUser session
70
+ $this->_getConfig()->getSession()->setSkyboxUser($response);
71
+
72
+ //if ($this->getLocationAllow()) { // Rogged, la primera vez q usuario ingresa con un pais disabled, lanza error porq no se envia datos a url de popup
73
+ $this->_getConfig()->getSession()->setCartSkybox($response);
74
+ //}
75
+ //}
76
+ }
77
+
78
+ public function setCurrentProduct($product)
79
+ {
80
+ $this->_currentProduct = $product;
81
+ }
82
+ public function getCurrentProduct()
83
+ {
84
+ return $this->_currentProduct;
85
+ }
86
+
87
+ public function AddProductOfCart($data, $quantity)
88
+ {
89
+ $detailProduct = Mage::helper('checkout')->concatNameDetailProduct($this->getCurrentProduct(), $data['sku']);
90
+
91
+ //Mage::log("entro AddProductOfCart", null, 'tracer.log', true);
92
+ if ($this->getErrorAuthenticate() && !$this->getLocationAllow()) {
93
+ return $this;
94
+ }
95
+
96
+ Mage::log("AddProductOfCart: " . print_r($data, true), null, 'skyboxcheckout.log', true);
97
+
98
+ $storeProductName = $data['name'].' '.$detailProduct;
99
+
100
+ $params = array(
101
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
102
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
103
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
104
+ 'productid' => "0",
105
+ 'quantity' => $quantity,
106
+ 'storeproductcode' => $data['sku'],
107
+ 'storeproductname' => $storeProductName,
108
+ 'storeproductcategory' => $data['category_id'],
109
+ 'storeproductprice' => $data['final_price'],
110
+ 'weight' => ($data['weight'])?($data['weight']):1,
111
+ 'weightunit' => $this->getWeightUnit(),
112
+ 'storeproductimgurl' => $data['image_url'],
113
+ 'VolWeight' => $data['VolWeight'],
114
+ 'merchantproductid' => $data['merchantproductid']
115
+ );
116
+ $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_ADD_PRODUCT_CART, $params);
117
+
118
+ return $this;
119
+ }
120
+
121
+ public function GetTotalShoppingCart()
122
+ {
123
+ if ($this->getErrorAuthenticate() && !$this->getLocationAllow()) {
124
+ return $this;
125
+ }
126
+
127
+ $params = array(
128
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
129
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
130
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi()
131
+ );
132
+
133
+ $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_GET_TOTAL_SHOPINGCART, $params);
134
+
135
+ return $this;
136
+ }
137
+
138
+ public function UpdateProductOfCart($productId, $quantity)
139
+ {
140
+ if (!$this->getErrorAuthenticate() && $this->getLocationAllow()) {
141
+ $this->getProduct()->load($productId);
142
+ $params = array(
143
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
144
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
145
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
146
+ 'productid' => $productId,
147
+ 'quantity' => $quantity
148
+ );
149
+
150
+ $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_UPDATE_PRODUCT_CART, $params);
151
+ }
152
+
153
+ return $this;
154
+ }
155
+
156
+ public function DeleteProductOfCart($productId)
157
+ {
158
+
159
+ #if (!$this->getErrorAuthenticate() && $this->getLocationAllow()) { // Rogged
160
+ if (!$this->getErrorAuthenticate()) { // Rogged
161
+ $params = array(
162
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
163
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
164
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
165
+ 'productid' => $productId
166
+ );
167
+
168
+ $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_DELETE_PRODUCT_CART, $params);
169
+ }
170
+
171
+ return $this;
172
+ }
173
+
174
+ public function getCartSkybox()
175
+ {
176
+ if (!$this->getErrorAuthenticate() && $this->getLocationAllow()) {
177
+ //$this->_config = Mage::getModel('skyboxcore/config');
178
+ return $this->_getConfig()->getSession()->getCartSkybox();
179
+ }
180
+ return "";
181
+ }
182
+
183
+ /*
184
+ * Get Categories
185
+ *
186
+ * @return $data json
187
+ */
188
+
189
+ public function GetCategories()
190
+ {
191
+ $params = array(
192
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
193
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken()
194
+ );
195
+
196
+ /* var $response Skybox_Core_Model_Standard */
197
+ $response = $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_CATEGORIES, $params);
198
+ $jsonData = $response->getResponse()->{'Categories'};
199
+ return $jsonData;
200
+ }
201
+
202
+ public function getValueAccessService()
203
+ {
204
+ $params = array(
205
+ "merchantCode" => $this->getMerchant(),
206
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
207
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
208
+
209
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
210
+ 'customeriplocal' => $this->_getConfig()->getHost(),
211
+ 'customeripremote' => $this->_getConfig()->getRemoteAddr(),
212
+ 'customeripproxy' => $this->_getConfig()->getProxy(),
213
+ 'customerbrowser' => $this->_getConfig()->getUserAgent(),
214
+ 'customerlanguages' => $this->_getConfig()->getLanguage()
215
+
216
+
217
+ );
218
+
219
+
220
+ return $params;
221
+
222
+ }
223
  }
app/code/community/Skybox/Checkout/Model/Carrier.php CHANGED
@@ -1,37 +1,37 @@
1
- <?php
2
- class Skybox_Checkout_Model_Carrier extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface
3
- {
4
- protected $_code = 'skyboxcheckout_shipping';
5
-
6
- public function collectRates(Mage_Shipping_Model_Rate_Request $request)
7
- {
8
- if (!$this->getConfigData('active') /*|| !Mage::helper('skyboxinternational')->getActive()*/) {
9
- return false;
10
- }
11
- $result = Mage::getModel('shipping/rate_result');
12
- $result->append($this->_getDefaultRate());
13
-
14
- return $result;
15
- }
16
-
17
- public function getAllowedMethods()
18
- {
19
- return array(
20
- 'skyboxcheckout' => 'skybox delivery'//$this->getConfigData('name'),
21
- );
22
- }
23
-
24
- protected function _getDefaultRate()
25
- {
26
- $rate = Mage::getModel('shipping/rate_result_method');
27
-
28
- $rate->setCarrier($this->_code);
29
- $rate->setCarrierTitle($this->getConfigData('title'));
30
- $rate->setMethod('skyboxcheckout');//$this->_code
31
- $rate->setMethodTitle($this->getConfigData('title'));
32
- $rate->setPrice($this->getConfigData('price'));
33
- $rate->setCost(0);
34
-
35
- return $rate;
36
- }
37
  }
1
+ <?php
2
+ class Skybox_Checkout_Model_Carrier extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface
3
+ {
4
+ protected $_code = 'skyboxcheckout_shipping';
5
+
6
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
7
+ {
8
+ if (!$this->getConfigData('active') /*|| !Mage::helper('skyboxinternational')->getActive()*/) {
9
+ return false;
10
+ }
11
+ $result = Mage::getModel('shipping/rate_result');
12
+ $result->append($this->_getDefaultRate());
13
+
14
+ return $result;
15
+ }
16
+
17
+ public function getAllowedMethods()
18
+ {
19
+ return array(
20
+ 'skyboxcheckout' => 'skybox delivery'//$this->getConfigData('name'),
21
+ );
22
+ }
23
+
24
+ protected function _getDefaultRate()
25
+ {
26
+ $rate = Mage::getModel('shipping/rate_result_method');
27
+
28
+ $rate->setCarrier($this->_code);
29
+ $rate->setCarrierTitle($this->getConfigData('title'));
30
+ $rate->setMethod('skyboxcheckout');//$this->_code
31
+ $rate->setMethodTitle($this->getConfigData('title'));
32
+ $rate->setPrice($this->getConfigData('price'));
33
+ $rate->setCost(0);
34
+
35
+ return $rate;
36
+ }
37
  }
app/code/community/Skybox/Checkout/Model/Cart.php CHANGED
@@ -1,717 +1,717 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Checkout
5
- *
6
- * @category Skybox
7
- * @package Skybox_Checkout
8
- * @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Checkout_Model_Cart extends Mage_Checkout_Model_Cart
11
- {
12
- const MESSAGE_FAIL_TO_ADD_PRODUCT = '[sales] Failed to add the product to the cart.';
13
-
14
- protected $_api = null;
15
- protected $_product = null;
16
- protected $_enable = null;
17
-
18
- /* @return Skybox_Checkout_Model_Api_Checkout */
19
- protected function _getApi()
20
- {
21
- if (null === $this->_api) {
22
- $this->_api = Mage::getModel('skyboxcheckout/api_checkout');
23
- }
24
- return $this->_api;
25
- }
26
-
27
- protected function _getAllowHelper()
28
- {
29
- return Mage::helper('skyboxcore/allow');
30
- }
31
-
32
- // @todo : Move this logic to a helper
33
- private function isEnable()
34
- {
35
- if ($this->_enable == null) {
36
-
37
- $isActive = boolval(Mage::helper('skyboxinternational/data')->getActive());
38
-
39
- if (!$isActive) {
40
- return false;
41
- }
42
-
43
- $isEnable = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
44
-
45
- if (!$isEnable) {
46
- return false;
47
- }
48
-
49
- $allowHelper = Mage::helper('skyboxcore/allow');
50
-
51
- if (!$allowHelper->isOperationCartEnabled()) {
52
- return false;
53
- }
54
-
55
- $api_mproduct = Mage::getModel('skyboxcatalog/api_product');
56
-
57
- if (!$api_mproduct->getLocationAllow()) {
58
- return false;
59
- }
60
-
61
- $this->_enable = true;
62
- }
63
- return $this->_enable;
64
- }
65
-
66
- /**
67
- * Return Skybox API Product
68
- *
69
- * @return Skybox_Catalog_Model_Api_Product
70
- */
71
- protected function _getProductApi()
72
- {
73
- if (null === $this->_product) {
74
- $this->_product = Mage::getModel('skyboxcatalog/api_product');
75
- }
76
- return $this->_product;
77
- }
78
-
79
- /*
80
- * Grouped Product
81
- */
82
- public function addGroupedProduct($productInfo, $requestInfo = null)
83
- {
84
- //Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter addBundleProduct', null, 'tracer.log', true);
85
- $product = $this->_getProduct($productInfo);
86
- $request = $this->_getProductRequest($requestInfo);
87
-
88
- $quote = parent::addProduct($productInfo, $requestInfo);
89
-
90
- $super_group = $request->getData('super_group');
91
- //Mage::log(print_r($super_group, true), null, 'cart.log', true);
92
-
93
- foreach ($super_group as $item => $qty) {
94
- if ($qty <= 0) {
95
- continue;
96
- }
97
-
98
- //Mage::log("Product: " . $item . " - " . $qty, null, 'cart.log', true);
99
-
100
- $product = Mage::getModel('catalog/product')
101
- ->setStoreId(Mage::app()->getStore()->getId())
102
- ->load($item);
103
-
104
- $productId = $product->getId();
105
-
106
- if ($product->getStockItem()) {
107
- $minimumQty = $product->getStockItem()->getMinSaleQty();
108
- //If product was not found in cart and there is set minimal qty for it
109
- if ($minimumQty && $minimumQty > 0 && $qty < $minimumQty
110
- && !$this->getQuote()->hasProductId($productId)
111
- ) {
112
- $request->setQty($minimumQty);
113
- }
114
- }
115
-
116
- $this->_getProductApi()->CalculatePrice($product, null);
117
-
118
- if ($this->_getProductApi()->HasError()) {
119
-
120
- $message = self::MESSAGE_FAIL_TO_ADD_PRODUCT;
121
-
122
- if ($this->_getProductApi()->_getApi()->ErrorRatesNotFound()) {
123
- $languageId = $this->getLanguageId();
124
- $message = $this->_getProductApi()->_getApi()->getErrorRatesNotFoundMessage($languageId);
125
- }
126
- Mage::throwException(
127
- Mage::helper('sales')->__($message)
128
- );
129
- return $this;
130
- }
131
-
132
- $productId = $this->_getProductApi()->getProductId();
133
-
134
- $_data = $this->_getProductApi()->getProductData();
135
- $this->_getApi()->AddProductOfCart($_data, $qty);
136
-
137
- if ($this->_getApi()->HasError()) {
138
- Mage::throwException(Mage::helper('checkout')->__('[checkout] Failed to add the product to the cart.'));
139
- return $this;
140
- }
141
-
142
- $productIdSkybox = $this->_getApi()->getParameter(
143
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID, "0");
144
-
145
- $this->_updateQuoteItem($productId, $productIdSkybox);
146
- }
147
-
148
- return $quote;
149
- }
150
-
151
- /*
152
- * Bundle Product
153
- */
154
- public function addBundleProduct($productInfo, $requestInfo = null)
155
- {
156
- //Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter addBundleProduct', null, 'tracer.log', true);
157
- $product = $this->_getProduct($productInfo);
158
- $request = $this->_getProductRequest($requestInfo);
159
-
160
- //Mage::log(print_r($request, true), null, 'cart.log', true);
161
-
162
- $quote = parent::addProduct($productInfo, $requestInfo);
163
-
164
- // SkyBox Checkout
165
- $this->_getProductApi()->CalculatePrice($product, $request);
166
-
167
- if ($this->_getProductApi()->HasError()) {
168
-
169
- $message = self::MESSAGE_FAIL_TO_ADD_PRODUCT;
170
-
171
- if ($this->_getProductApi()->_getApi()->ErrorRatesNotFound()) {
172
- $languageId = $this->getLanguageId();
173
- $message = $this->_getProductApi()->_getApi()->getErrorRatesNotFoundMessage($languageId);
174
- }
175
- Mage::throwException(
176
- Mage::helper('sales')->__($message)
177
- );
178
- return $this;
179
- }
180
-
181
- //$productId = $product->getId();
182
- $productId = $this->_getProductApi()->getProductId();
183
-
184
- Mage::dispatchEvent('checkout_cart_product_add_before', array(
185
- 'product' => $product,
186
- 'request' => $request
187
- ));
188
-
189
- $_data = $this->_getProductApi()->getProductData();
190
-
191
- // Mage::log("Bundleproduct=Cart=" . print_r($_data, true), null, 'cart.log', true);
192
-
193
- $this->_getApi()->AddProductOfCart($_data, $request->getQty());
194
-
195
- if ($this->_getApi()->HasError()) {
196
- Mage::throwException(Mage::helper('checkout')->__('[checkout] Failed to add the product to the cart.'));
197
- return $this;
198
- }
199
-
200
- $productIdSkybox = $this->_getApi()->getParameter(
201
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID, "0");
202
-
203
- $this->_updateQuoteItem($productId, $productIdSkybox);
204
- return $quote;
205
- }
206
-
207
- /**
208
- * Add product to shopping cart (quote)
209
- *
210
- * @param int|Mage_Catalog_Model_Product $productInfo
211
- * @param mixed $requestInfo
212
- * @return Mage_Checkout_Model_Cart
213
- */
214
- public function addProduct($productInfo, $requestInfo = null)
215
- {
216
- if (!$this->isEnable()) {
217
- parent::addProduct($productInfo, $requestInfo);
218
- return $this;
219
- }
220
-
221
- $api_mproduct = Mage::getModel('skyboxcatalog/api_product');
222
-
223
- if (!$api_mproduct->getLocationAllow()) {
224
- parent::addProduct($productInfo, $requestInfo);
225
- return $this;
226
- }
227
-
228
- //Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter addProduct', null, 'tracer.log', true);
229
- $product = $this->_getProduct($productInfo);
230
- $request = $this->_getProductRequest($requestInfo);
231
-
232
- if ($product->isGrouped()) {
233
- // Mage::log("Product: " . $product->getName() . " is Grouped", null, 'cart.log', true);
234
- return $this->addGroupedProduct($productInfo, $requestInfo);
235
- }
236
-
237
- if ($product->getTypeId() == 'bundle') {
238
- // Mage::log("Product: " . $product->getName() . " is Bundle", null, 'cart.log', true);
239
- return $this->addBundleProduct($productInfo, $requestInfo);
240
- }
241
-
242
- // SkyBox Checkout
243
- $this->_getProductApi()->CalculatePrice($product, $request);
244
-
245
- if ($this->_getProductApi()->HasError()) {
246
-
247
- $message = self::MESSAGE_FAIL_TO_ADD_PRODUCT;
248
-
249
- if ($this->_getProductApi()->_getApi()->ErrorRatesNotFound()) {
250
- $languageId = $this->getLanguageId();
251
- $message = $this->_getProductApi()->_getApi()->getErrorRatesNotFoundMessage($languageId);
252
- }
253
- Mage::throwException(
254
- Mage::helper('sales')->__($message)
255
- );
256
- return $this;
257
- }
258
-
259
- // $productId = $product->getId();
260
- $productId = $this->_getProductApi()->getProductId();
261
- // Mage::log("AddProduct::: productId ::: ". $productId,null, 'updateCart.log', true);
262
-
263
- if ($product->getStockItem()) {
264
- $minimumQty = $product->getStockItem()->getMinSaleQty();
265
- //If product was not found in cart and there is set minimal qty for it
266
- if ($minimumQty && $minimumQty > 0 && $request->getQty() < $minimumQty
267
- && !$this->getQuote()->hasProductId($productId)
268
- ) {
269
- $request->setQty($minimumQty);
270
- }
271
- }
272
-
273
- /*$product->setTaxPercent(0);
274
- $product->setTaxAmount(0);
275
- $product->setBaseTaxAmount(0);*/
276
-
277
- Mage::dispatchEvent('checkout_cart_product_add_before', array(
278
- 'product' => $product,
279
- 'request' => $request
280
- ));
281
-
282
- $_data = $this->_getProductApi()->getProductData();
283
- // Mage::log("product=Cart=" . print_r($_data, true), null, 'cart.log', true);
284
- $this->_getApi()->setCurrentProduct($product);
285
- $this->_getApi()->AddProductOfCart($_data, $request->getQty());
286
-
287
- if ($this->_getApi()->HasError()) {
288
- Mage::throwException(Mage::helper('checkout')->__('[checkout] Failed to add the product to the cart.'));
289
- return $this;
290
- }
291
-
292
- $productIdSkybox = $this->_getApi()->getParameter(
293
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID, "0");
294
-
295
- try {
296
- $quote = parent::addProduct($productInfo, $requestInfo);
297
- $this->_updateQuoteItem($productId, $productIdSkybox);
298
- } catch (\Exception $e) {
299
- Mage::log($e->getMessage(), null, 'tracer.log', true);
300
- }
301
-
302
- return $quote;
303
- }
304
-
305
- // protected function _getProduct($productInfo){
306
- // Mage::log('Entro skybox _getProduct', null, 'tracer.log', true);
307
- // Mage::log(print_r($productInfo,true), null, 'tracer.log', true);
308
- // $product = parent::_getProduct($productInfo);
309
- // return $product;
310
- // }
311
-
312
- public function addProductsByIds($productIds)
313
- {
314
- if (!$this->isEnable()) {
315
- parent::addProductsByIds($productIds);
316
- return $this;
317
- }
318
-
319
- //Mage::log('Entro skybox addProductsByIds', null, 'tracer.log', true);
320
- //Mage::log(print_r($productIds,true), null, 'tracer.log', true);
321
- if (count($productIds) > 0) {
322
- foreach ($productIds as $idproduct) {
323
- $idproduct = trim($idproduct);
324
- if (empty($idproduct)) {
325
- continue;
326
- }
327
- $this->addProduct($idproduct);
328
- }
329
- }
330
- // $quote = parent::addProductsByIds($productIds);
331
- return $this;
332
- }
333
-
334
- private function _updateQuoteItem($productId, $productIdSkybox)
335
- {
336
- // Mage::log("_updateQuoteItem::: productId ::: ". $productId,null, 'updateCart.log', true);
337
- // Mage::log("_updateQuoteItem::: productIdSkybox ::: ". $productIdSkybox,null, 'updateCart.log', true);
338
- // Mage::log('pas x aqui2', null, 'minicars.log', true);
339
-
340
-
341
- /**
342
- * only one time for call to service start - Active
343
- * when do add to cart
344
- */
345
- $session = Mage::getSingleton("core/session", array("name" => "frontend"));
346
- $session->setData("callToSkyBox", true);
347
- //Mage::log("Call true: add to cart", null, 'local.log', true);
348
- /**
349
- * when do add to cart end - Active
350
- */
351
- foreach ($this->getQuote()->getAllItems() as $item) {
352
-
353
- if ($item->getProductId() == $productId) {
354
-
355
- if ($item instanceof Mage_Sales_Model_Quote_Item) {
356
- $parentItem = $item->getParentItem();
357
- if ($parentItem) {
358
- $item = $parentItem;
359
- }
360
- }
361
- /**
362
- * Integration 3 start, show price shop in cart*
363
- */
364
- $isLocationAllow = false;
365
- //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
366
- $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
367
- if ($typeIntegration == 3) {
368
- $isLocationAllow = true;
369
- }
370
- /**
371
- * Integration 3 end, show price shop in cart*
372
- */
373
- if ($isLocationAllow) {
374
- $productModel = Mage::getModel('catalog/product')->load($productId);
375
- $total = str_replace(",", "", $productModel->getTotalPriceUSD());
376
- $item->setIdProductSkybox($productIdSkybox);
377
-
378
- // Currency amounts in the default currency of that customer
379
- $item->setCustomsSkybox($productModel->getCustoms());
380
- $item->setShippingSkybox($productModel->getShipping());
381
- $item->setInsuranceSkybox($productModel->getInsurance());
382
- $item->setPriceSkybox($productModel->getPrice());
383
- $item->setTotalSkybox($productModel->getTotalPrice());
384
- // $item->setRowTotal($total);
385
-
386
- // Currency amounts in the USD Currency
387
- $item->setCustomsUsdSkybox($productModel->getCustomsUSD());
388
- $item->setShippingUsdSkybox($productModel->getShippingUSD());
389
- $item->setInsuranceUsdSkybox($productModel->getInsuranceUSD());
390
- $item->setPriceUsdSkybox($productModel->getPriceUSD());
391
- $item->setTotalUsdSkybox($productModel->getTotalPriceUSD());
392
-
393
- $item->setGuidSkybox($productModel->getGuidSkybox()); //Set GUID
394
-
395
-
396
- $item->setBasePriceSkybox($productModel->getBasePrice());
397
- $item->setBasePriceUsdSkybox($productModel->getBasePriceUSD());
398
- $item->setAdjustTotalSkybox($productModel->getAdjustPrice());
399
- $item->setAdjustTotalUsdSkybox($productModel->getAdjustPriceUSD());
400
- $item->setAdjustLabelSkybox($productModel->getAdjustLabel());
401
-
402
- //$item->setOriginalCustomPrice($this->_getProductApi()->getTotalPriceUSD());
403
- //$item->setOriginalCustomPrice($total);
404
- // $item->setOriginalCustomPrice($this->_getProductApi()->getPrice());
405
- // $prices = str_replace(',', '', $productModel->getPrice());
406
- // $prices = number_format((float)($prices), 2, ',', '.');
407
- // $item->setOriginalCustomPrice($prices);
408
- //$skybox_total = str_replace(",", "", $this->_getProductApi()->getTotalPrice());
409
- $skybox_total = str_replace(",", "", $productModel->getPrice());
410
- $row_total = floatval($skybox_total) * $item->getQty();
411
- $item->setRowTotalSkybox($row_total);
412
- } else {
413
- $total = str_replace(",", "", $this->_getProductApi()->getTotalPriceUSD());
414
- $item->setIdProductSkybox($productIdSkybox);
415
-
416
- // Currency amounts in the default currency of that customer
417
- $item->setCustomsSkybox($this->_getProductApi()->getCustoms());
418
- $item->setShippingSkybox($this->_getProductApi()->getShipping());
419
- $item->setInsuranceSkybox($this->_getProductApi()->getInsurance());
420
- $item->setPriceSkybox($this->_getProductApi()->getPrice());
421
- $item->setTotalSkybox($this->_getProductApi()->getTotalPrice());
422
- // $item->setRowTotal($total);
423
-
424
- // Currency amounts in the USD Currency
425
- $item->setCustomsUsdSkybox($this->_getProductApi()->getCustomsUSD());
426
- $item->setShippingUsdSkybox($this->_getProductApi()->getShippingUSD());
427
- $item->setInsuranceUsdSkybox($this->_getProductApi()->getInsuranceUSD());
428
- $item->setPriceUsdSkybox($this->_getProductApi()->getPriceUSD());
429
- $item->setTotalUsdSkybox($this->_getProductApi()->getTotalPriceUSD());
430
-
431
- $item->setGuidSkybox($this->_getProductApi()->getGuidSkybox()); //Set GUID
432
-
433
- $item->setBasePriceSkybox($this->_getProductApi()->getBasePrice());
434
- $item->setBasePriceUsdSkybox($this->_getProductApi()->getBasePriceUSD());
435
- $item->setAdjustTotalSkybox($this->_getProductApi()->getAdjustPrice());
436
- $item->setAdjustTotalUsdSkybox($this->_getProductApi()->getAdjustPriceUSD());
437
- $item->setAdjustLabelSkybox($this->_getProductApi()->getAdjustLabel());
438
-
439
- //$item->setOriginalCustomPrice($this->_getProductApi()->getTotalPriceUSD());
440
- //$item->setOriginalCustomPrice($total);
441
- // $item->setOriginalCustomPrice($this->_getProductApi()->getPrice());
442
- // $prices = str_replace(',', '', $this->_getProductApi()->getPrice());
443
- // $prices = number_format((float)($prices), 2, ',', '.');
444
- // $item->setOriginalCustomPrice($prices);
445
- //$skybox_total = str_replace(",", "", $this->_getProductApi()->getTotalPrice());
446
- $skybox_total = str_replace(",", "", $this->_getProductApi()->getPrice());
447
- $row_total = floatval($skybox_total) * $item->getQty();
448
- $item->setRowTotalSkybox($row_total);
449
- }
450
- break;
451
- }
452
- }
453
-
454
- }
455
-
456
- private function _updateQuoteItem_backup($productId, $productIdSkybox)
457
- {
458
- Mage::log('pas x aqui2', null, 'minicars.log', true);
459
-
460
- foreach ($this->getQuote()->getAllItems() as $item) {
461
-
462
- if ($item->getProductId() == $productId) {
463
-
464
- if ($item instanceof Mage_Sales_Model_Quote_Item) {
465
- $parentItem = $item->getParentItem();
466
- if ($parentItem) {
467
- $item = $parentItem;
468
- }
469
- }
470
-
471
- $total = str_replace(",", "", $this->_getProductApi()->getTotalPriceUSD());
472
- $item->setIdProductSkybox($productIdSkybox);
473
-
474
- // Currency amounts in the default currency of that customer
475
- $item->setCustomsSkybox($this->_getProductApi()->getCustoms());
476
- $item->setShippingSkybox($this->_getProductApi()->getShipping());
477
- $item->setInsuranceSkybox($this->_getProductApi()->getInsurance());
478
- $item->setPriceSkybox($this->_getProductApi()->getPrice());
479
- $item->setTotalSkybox($this->_getProductApi()->getTotalPrice());
480
- $item->setRowTotal($total);
481
-
482
- // Currency amounts in the USD Currency
483
- $item->setCustomsUsdSkybox($this->_getProductApi()->getCustomsUSD());
484
- $item->setShippingUsdSkybox($this->_getProductApi()->getShippingUSD());
485
- $item->setInsuranceUsdSkybox($this->_getProductApi()->getInsuranceUSD());
486
- $item->setPriceUsdSkybox($this->_getProductApi()->getPriceUSD());
487
- $item->setTotalUsdSkybox($this->_getProductApi()->getTotalPriceUSD());
488
-
489
- $item->setGuidSkybox($this->_getProductApi()->getGuidSkybox()); //Set GUID
490
-
491
-
492
- $item->setBasePriceSkybox($this->_getProductApi()->getBasePrice());
493
- $item->setBasePriceUsdSkybox($this->_getProductApi()->getBasePriceUSD());
494
- $item->setAdjustTotalSkybox($this->_getProductApi()->getAdjustPrice());
495
- $item->setAdjustTotalUsdSkybox($this->_getProductApi()->getAdjustPriceUSD());
496
- $item->setAdjustLabelSkybox($this->_getProductApi()->getAdjustLabel());
497
-
498
- //$item->setOriginalCustomPrice($this->_getProductApi()->getTotalPriceUSD());
499
- //$item->setOriginalCustomPrice($total);
500
- // $item->setOriginalCustomPrice($this->_getProductApi()->getPrice());
501
- $prices = str_replace(',', '', $this->_getProductApi()->getPrice());
502
- $prices = number_format((float)($prices), 2, ',', '.');
503
- $item->setOriginalCustomPrice($prices);
504
- //$skybox_total = str_replace(",", "", $this->_getProductApi()->getTotalPrice());
505
- $skybox_total = str_replace(",", "", $this->_getProductApi()->getPrice());
506
- $row_total = floatval($skybox_total) * $item->getQty();
507
- $item->setRowTotalSkybox($row_total);
508
-
509
- break;
510
- }
511
- }
512
-
513
- }
514
-
515
- /**
516
- * Remove item from cart
517
- *
518
- * @param int $itemId
519
- * @return Mage_Checkout_Model_Cart
520
- */
521
- public function removeItem($itemId)
522
- {
523
- /**
524
- * only one time for call to service start - Active
525
- * when do remove
526
- */
527
- $session = Mage::getSingleton("core/session", array("name" => "frontend"));
528
- $session->setData("callToSkyBox", true);
529
- //Mage::log("Call true: remove", null, 'local.log', true);
530
- /**
531
- * when do remove
532
- */
533
- if (!$this->isEnable()) {
534
- parent::removeItem($itemId);
535
- return $this;
536
- }
537
-
538
- $quoteItem = $this->getQuote()->getItemById($itemId);
539
-
540
- if (!$quoteItem) {
541
- Mage::throwException(Mage::helper('checkout')->__('ID incorrecto de producto.'));
542
- return $this;
543
- }
544
- Mage::log("|removeItem|" . $quoteItem->getIdProductSkybox());
545
- //Realizar llamada al servicio de agregar producto al carrito.
546
- $idProductSkybox = $quoteItem->getIdProductSkybox();
547
- $this->_getApi()->DeleteProductOfCart($idProductSkybox);
548
-
549
- if ($this->_getApi()->HasError()) {
550
- Mage::throwException(Mage::helper('checkout')->__('Error al eliminar producto al carrito.'));
551
- return $this;
552
- }
553
-
554
- return parent::removeItem($itemId);
555
- }
556
-
557
- /**
558
- * Update cart items information
559
- *
560
- * @param array $data
561
- * @return Mage_Checkout_Model_Cart
562
- */
563
- public function updateItems($data)
564
- {
565
- /**
566
- * only one time for call to service start - Active
567
- * when do remove
568
- */
569
- $session = Mage::getSingleton("core/session", array("name" => "frontend"));
570
- $session->setData("callToSkyBox", true);
571
- //Mage::log("Call true: update cart", null, 'local.log', true);
572
- /**
573
- * when do remove
574
- */
575
- if (!$this->isEnable()) {
576
- parent::updateItems($data);
577
- return $this;
578
- }
579
-
580
- Mage::log('pas x aqui5', null, 'cartdetail.log', true);
581
- //Mage::log(print_r($data, true), null, 'tracer.log', true);
582
- //Mage::log("Skybox_Checkout_Checkout_Model_Cart updateItem");
583
- //return parent::updateItems($data);
584
- // Mage::dispatchEvent('checkout_cart_update_items_before', array('cart'=>$this, 'info'=>$data));
585
-
586
- foreach ($data as $itemId => $itemInfo) {
587
- $item = $this->getQuote()->getItemById($itemId);
588
- //Mage::log('item:', null, 'tracer.log', true);
589
- //Mage::log(print_r($item->debug(), true), null, 'tracer.log', true);
590
- //Mage::log(print_r($itemInfo, true), null, 'tracer.log', true);
591
- //Mage::log('updateItems foreach', null, 'tracer.log', true);
592
- if (!$item) {
593
- //Mage::log('no item', null, 'tracer.log', true);
594
- continue;
595
- }
596
-
597
- // if(isset($itemInfo['price']) && !empty($itemInfo['price'])) {
598
- // //price, base_price, custom_price, row_total, base_row_total, row_total_with_discount, original_custom_price
599
- // $price = (float) $itemInfo['price'];
600
- // $item->setPrice($price);
601
- // $item->setRowTotal($price);
602
- // $item->setBasePrice($price);
603
- // continue;
604
- // }
605
-
606
- if (!empty($itemInfo['remove']) || (isset($itemInfo['qty']) && $itemInfo['qty'] == '0')) {
607
- $this->removeItem($itemId);
608
- continue;
609
- }
610
-
611
- $qty = isset($itemInfo['qty']) ? (float)$itemInfo['qty'] : false;
612
- //Mage::log('cantidad: '.$qty, null, 'tracer.log', true);
613
- if ($qty > 0) {
614
-
615
- $idProductSkybox = $item->getIdProductSkybox();
616
-
617
- // $this->_getApi()->UpdateProductOfCart($idProductSkybox, $qty);
618
-
619
- $item->setQty($qty);
620
-
621
- //$skybox_total = str_replace(",", "", $item->getTotalSkybox());
622
- $skybox_total = str_replace(",", "", $item->getPriceSkybox());
623
-
624
-
625
- $row_total = floatval($skybox_total) * $item->getQty();
626
- $item->setRowTotalSkybox($row_total);
627
-
628
- //Mage::log('fin qty', null, 'tracer.log', true);
629
- }
630
- }
631
-
632
- // Mage::dispatchEvent('checkout_cart_update_items_after', array('cart'=>$this, 'info'=>$data));
633
- $current = parent::updateItems($data);
634
- return $current;
635
- }
636
-
637
- /**
638
- * Mark all quote items as deleted (empty shopping cart)
639
- *
640
- * @return Mage_Checkout_Model_Cart
641
- */
642
- public function truncate()
643
- {
644
- foreach ($this->getQuote()->getAllItems() as $item) {
645
- //Mage::log("truncate() ". $item->getId(), null, 'api.log', true);
646
- $this->removeItem($item->getId());
647
- }
648
-
649
- parent::truncate();
650
- return $this;
651
- }
652
-
653
- /**
654
- * Mark all quote items as deleted (empty shopping cart)
655
- * @return $this
656
- */
657
- public function truncateMgCart()
658
- {
659
- parent::truncate();
660
- return $this;
661
- }
662
-
663
- /**
664
- * Update item in shopping cart (quote)
665
- * $requestInfo - either qty (int) or buyRequest in form of array or Varien_Object
666
- * $updatingParams - information on how to perform update, passed to Quote->updateItem() method
667
- */
668
- public function updateItem($itemId, $requestInfo = null, $updatingParams = null)
669
- {
670
- if (!$this->isEnable()) {
671
- $result = parent::updateItem($itemId, $requestInfo, $updatingParams);
672
- return $result;
673
- }
674
-
675
- $item = $this->getQuote()->getItemById($itemId);
676
- $skyboxProductId = $item->getIdProductSkybox();
677
- $_quoteItemId = $item->getId();
678
- $_qty = $item->getQty();
679
-
680
- /** @var Mage_Sales_Model_Quote_Item $result */
681
- $result = parent::updateItem($itemId, $requestInfo, $updatingParams);
682
- $quoteItemId = $result->getId();
683
- $qty = $result->getQty();
684
-
685
- // Update Product
686
- if ($quoteItemId == $_quoteItemId) {
687
- $this->_getApi()->UpdateProductOfCart($skyboxProductId, $qty);
688
- } else {
689
- // Delete and Add a New Product
690
- $this->_getApi()->DeleteProductOfCart($skyboxProductId);
691
-
692
- $product = $result->getProduct();
693
- $this->_getProductApi()->CalculatePrice($product, $requestInfo);
694
-
695
- $_data = $this->_getProductApi()->getProductData();
696
- $this->_getApi()->setCurrentProduct($product);
697
- $this->_getApi()->AddProductOfCart($_data, $qty);
698
-
699
- $productId = $result->getProduct()->getId();
700
- $skyboxProductId = $this->_getApi()->getParameter(
701
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID, "0");
702
-
703
- $this->_updateQuoteItem($productId, $skyboxProductId);
704
- }
705
-
706
- return $result;
707
- }
708
-
709
- private function getLanguageId()
710
- {
711
- $_config = Mage::getModel('skyboxcore/config');
712
- $cart = $_config->getSession()->getCartSkybox();
713
- $id = $cart->{'LanguageId'};
714
- return intval($id);
715
- }
716
-
717
- }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Checkout
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Checkout
8
+ * @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Checkout_Model_Cart extends Mage_Checkout_Model_Cart
11
+ {
12
+ const MESSAGE_FAIL_TO_ADD_PRODUCT = '[sales] Failed to add the product to the cart.';
13
+
14
+ protected $_api = null;
15
+ protected $_product = null;
16
+ protected $_enable = null;
17
+
18
+ /* @return Skybox_Checkout_Model_Api_Checkout */
19
+ protected function _getApi()
20
+ {
21
+ if (null === $this->_api) {
22
+ $this->_api = Mage::getModel('skyboxcheckout/api_checkout');
23
+ }
24
+ return $this->_api;
25
+ }
26
+
27
+ protected function _getAllowHelper()
28
+ {
29
+ return Mage::helper('skyboxcore/allow');
30
+ }
31
+
32
+ // @todo : Move this logic to a helper
33
+ private function isEnable()
34
+ {
35
+ if ($this->_enable == null) {
36
+
37
+ $isActive = boolval(Mage::helper('skyboxinternational/data')->getActive());
38
+
39
+ if (!$isActive) {
40
+ return false;
41
+ }
42
+
43
+ $isEnable = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
44
+
45
+ if (!$isEnable) {
46
+ return false;
47
+ }
48
+
49
+ $allowHelper = Mage::helper('skyboxcore/allow');
50
+
51
+ if (!$allowHelper->isOperationCartEnabled()) {
52
+ return false;
53
+ }
54
+
55
+ $api_mproduct = Mage::getModel('skyboxcatalog/api_product');
56
+
57
+ if (!$api_mproduct->getLocationAllow()) {
58
+ return false;
59
+ }
60
+
61
+ $this->_enable = true;
62
+ }
63
+ return $this->_enable;
64
+ }
65
+
66
+ /**
67
+ * Return Skybox API Product
68
+ *
69
+ * @return Skybox_Catalog_Model_Api_Product
70
+ */
71
+ protected function _getProductApi()
72
+ {
73
+ if (null === $this->_product) {
74
+ $this->_product = Mage::getModel('skyboxcatalog/api_product');
75
+ }
76
+ return $this->_product;
77
+ }
78
+
79
+ /*
80
+ * Grouped Product
81
+ */
82
+ public function addGroupedProduct($productInfo, $requestInfo = null)
83
+ {
84
+ //Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter addBundleProduct', null, 'tracer.log', true);
85
+ $product = $this->_getProduct($productInfo);
86
+ $request = $this->_getProductRequest($requestInfo);
87
+
88
+ $quote = parent::addProduct($productInfo, $requestInfo);
89
+
90
+ $super_group = $request->getData('super_group');
91
+ //Mage::log(print_r($super_group, true), null, 'cart.log', true);
92
+
93
+ foreach ($super_group as $item => $qty) {
94
+ if ($qty <= 0) {
95
+ continue;
96
+ }
97
+
98
+ //Mage::log("Product: " . $item . " - " . $qty, null, 'cart.log', true);
99
+
100
+ $product = Mage::getModel('catalog/product')
101
+ ->setStoreId(Mage::app()->getStore()->getId())
102
+ ->load($item);
103
+
104
+ $productId = $product->getId();
105
+
106
+ if ($product->getStockItem()) {
107
+ $minimumQty = $product->getStockItem()->getMinSaleQty();
108
+ //If product was not found in cart and there is set minimal qty for it
109
+ if ($minimumQty && $minimumQty > 0 && $qty < $minimumQty
110
+ && !$this->getQuote()->hasProductId($productId)
111
+ ) {
112
+ $request->setQty($minimumQty);
113
+ }
114
+ }
115
+
116
+ $this->_getProductApi()->CalculatePrice($product, null);
117
+
118
+ if ($this->_getProductApi()->HasError()) {
119
+
120
+ $message = self::MESSAGE_FAIL_TO_ADD_PRODUCT;
121
+
122
+ if ($this->_getProductApi()->_getApi()->ErrorRatesNotFound()) {
123
+ $languageId = $this->getLanguageId();
124
+ $message = $this->_getProductApi()->_getApi()->getErrorRatesNotFoundMessage($languageId);
125
+ }
126
+ Mage::throwException(
127
+ Mage::helper('sales')->__($message)
128
+ );
129
+ return $this;
130
+ }
131
+
132
+ $productId = $this->_getProductApi()->getProductId();
133
+
134
+ $_data = $this->_getProductApi()->getProductData();
135
+ $this->_getApi()->AddProductOfCart($_data, $qty);
136
+
137
+ if ($this->_getApi()->HasError()) {
138
+ Mage::throwException(Mage::helper('checkout')->__('[checkout] Failed to add the product to the cart.'));
139
+ return $this;
140
+ }
141
+
142
+ $productIdSkybox = $this->_getApi()->getParameter(
143
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID, "0");
144
+
145
+ $this->_updateQuoteItem($productId, $productIdSkybox);
146
+ }
147
+
148
+ return $quote;
149
+ }
150
+
151
+ /*
152
+ * Bundle Product
153
+ */
154
+ public function addBundleProduct($productInfo, $requestInfo = null)
155
+ {
156
+ //Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter addBundleProduct', null, 'tracer.log', true);
157
+ $product = $this->_getProduct($productInfo);
158
+ $request = $this->_getProductRequest($requestInfo);
159
+
160
+ //Mage::log(print_r($request, true), null, 'cart.log', true);
161
+
162
+ $quote = parent::addProduct($productInfo, $requestInfo);
163
+
164
+ // SkyBox Checkout
165
+ $this->_getProductApi()->CalculatePrice($product, $request);
166
+
167
+ if ($this->_getProductApi()->HasError()) {
168
+
169
+ $message = self::MESSAGE_FAIL_TO_ADD_PRODUCT;
170
+
171
+ if ($this->_getProductApi()->_getApi()->ErrorRatesNotFound()) {
172
+ $languageId = $this->getLanguageId();
173
+ $message = $this->_getProductApi()->_getApi()->getErrorRatesNotFoundMessage($languageId);
174
+ }
175
+ Mage::throwException(
176
+ Mage::helper('sales')->__($message)
177
+ );
178
+ return $this;
179
+ }
180
+
181
+ //$productId = $product->getId();
182
+ $productId = $this->_getProductApi()->getProductId();
183
+
184
+ Mage::dispatchEvent('checkout_cart_product_add_before', array(
185
+ 'product' => $product,
186
+ 'request' => $request
187
+ ));
188
+
189
+ $_data = $this->_getProductApi()->getProductData();
190
+
191
+ // Mage::log("Bundleproduct=Cart=" . print_r($_data, true), null, 'cart.log', true);
192
+
193
+ $this->_getApi()->AddProductOfCart($_data, $request->getQty());
194
+
195
+ if ($this->_getApi()->HasError()) {
196
+ Mage::throwException(Mage::helper('checkout')->__('[checkout] Failed to add the product to the cart.'));
197
+ return $this;
198
+ }
199
+
200
+ $productIdSkybox = $this->_getApi()->getParameter(
201
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID, "0");
202
+
203
+ $this->_updateQuoteItem($productId, $productIdSkybox);
204
+ return $quote;
205
+ }
206
+
207
+ /**
208
+ * Add product to shopping cart (quote)
209
+ *
210
+ * @param int|Mage_Catalog_Model_Product $productInfo
211
+ * @param mixed $requestInfo
212
+ * @return Mage_Checkout_Model_Cart
213
+ */
214
+ public function addProduct($productInfo, $requestInfo = null)
215
+ {
216
+ if (!$this->isEnable()) {
217
+ parent::addProduct($productInfo, $requestInfo);
218
+ return $this;
219
+ }
220
+
221
+ $api_mproduct = Mage::getModel('skyboxcatalog/api_product');
222
+
223
+ if (!$api_mproduct->getLocationAllow()) {
224
+ parent::addProduct($productInfo, $requestInfo);
225
+ return $this;
226
+ }
227
+
228
+ //Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter addProduct', null, 'tracer.log', true);
229
+ $product = $this->_getProduct($productInfo);
230
+ $request = $this->_getProductRequest($requestInfo);
231
+
232
+ if ($product->isGrouped()) {
233
+ // Mage::log("Product: " . $product->getName() . " is Grouped", null, 'cart.log', true);
234
+ return $this->addGroupedProduct($productInfo, $requestInfo);
235
+ }
236
+
237
+ if ($product->getTypeId() == 'bundle') {
238
+ // Mage::log("Product: " . $product->getName() . " is Bundle", null, 'cart.log', true);
239
+ return $this->addBundleProduct($productInfo, $requestInfo);
240
+ }
241
+
242
+ // SkyBox Checkout
243
+ $this->_getProductApi()->CalculatePrice($product, $request);
244
+
245
+ if ($this->_getProductApi()->HasError()) {
246
+
247
+ $message = self::MESSAGE_FAIL_TO_ADD_PRODUCT;
248
+
249
+ if ($this->_getProductApi()->_getApi()->ErrorRatesNotFound()) {
250
+ $languageId = $this->getLanguageId();
251
+ $message = $this->_getProductApi()->_getApi()->getErrorRatesNotFoundMessage($languageId);
252
+ }
253
+ Mage::throwException(
254
+ Mage::helper('sales')->__($message)
255
+ );
256
+ return $this;
257
+ }
258
+
259
+ // $productId = $product->getId();
260
+ $productId = $this->_getProductApi()->getProductId();
261
+ // Mage::log("AddProduct::: productId ::: ". $productId,null, 'updateCart.log', true);
262
+
263
+ if ($product->getStockItem()) {
264
+ $minimumQty = $product->getStockItem()->getMinSaleQty();
265
+ //If product was not found in cart and there is set minimal qty for it
266
+ if ($minimumQty && $minimumQty > 0 && $request->getQty() < $minimumQty
267
+ && !$this->getQuote()->hasProductId($productId)
268
+ ) {
269
+ $request->setQty($minimumQty);
270
+ }
271
+ }
272
+
273
+ /*$product->setTaxPercent(0);
274
+ $product->setTaxAmount(0);
275
+ $product->setBaseTaxAmount(0);*/
276
+
277
+ Mage::dispatchEvent('checkout_cart_product_add_before', array(
278
+ 'product' => $product,
279
+ 'request' => $request
280
+ ));
281
+
282
+ $_data = $this->_getProductApi()->getProductData();
283
+ // Mage::log("product=Cart=" . print_r($_data, true), null, 'cart.log', true);
284
+ $this->_getApi()->setCurrentProduct($product);
285
+ $this->_getApi()->AddProductOfCart($_data, $request->getQty());
286
+
287
+ if ($this->_getApi()->HasError()) {
288
+ Mage::throwException(Mage::helper('checkout')->__('[checkout] Failed to add the product to the cart.'));
289
+ return $this;
290
+ }
291
+
292
+ $productIdSkybox = $this->_getApi()->getParameter(
293
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID, "0");
294
+
295
+ try {
296
+ $quote = parent::addProduct($productInfo, $requestInfo);
297
+ $this->_updateQuoteItem($productId, $productIdSkybox);
298
+ } catch (\Exception $e) {
299
+ Mage::log($e->getMessage(), null, 'tracer.log', true);
300
+ }
301
+
302
+ return $quote;
303
+ }
304
+
305
+ // protected function _getProduct($productInfo){
306
+ // Mage::log('Entro skybox _getProduct', null, 'tracer.log', true);
307
+ // Mage::log(print_r($productInfo,true), null, 'tracer.log', true);
308
+ // $product = parent::_getProduct($productInfo);
309
+ // return $product;
310
+ // }
311
+
312
+ public function addProductsByIds($productIds)
313
+ {
314
+ if (!$this->isEnable()) {
315
+ parent::addProductsByIds($productIds);
316
+ return $this;
317
+ }
318
+
319
+ //Mage::log('Entro skybox addProductsByIds', null, 'tracer.log', true);
320
+ //Mage::log(print_r($productIds,true), null, 'tracer.log', true);
321
+ if (count($productIds) > 0) {
322
+ foreach ($productIds as $idproduct) {
323
+ $idproduct = trim($idproduct);
324
+ if (empty($idproduct)) {
325
+ continue;
326
+ }
327
+ $this->addProduct($idproduct);
328
+ }
329
+ }
330
+ // $quote = parent::addProductsByIds($productIds);
331
+ return $this;
332
+ }
333
+
334
+ private function _updateQuoteItem($productId, $productIdSkybox)
335
+ {
336
+ // Mage::log("_updateQuoteItem::: productId ::: ". $productId,null, 'updateCart.log', true);
337
+ // Mage::log("_updateQuoteItem::: productIdSkybox ::: ". $productIdSkybox,null, 'updateCart.log', true);
338
+ // Mage::log('pas x aqui2', null, 'minicars.log', true);
339
+
340
+
341
+ /**
342
+ * only one time for call to service start - Active
343
+ * when do add to cart
344
+ */
345
+ $session = Mage::getSingleton("core/session", array("name" => "frontend"));
346
+ $session->setData("callToSkyBox", true);
347
+ //Mage::log("Call true: add to cart", null, 'local.log', true);
348
+ /**
349
+ * when do add to cart end - Active
350
+ */
351
+ foreach ($this->getQuote()->getAllItems() as $item) {
352
+
353
+ if ($item->getProductId() == $productId) {
354
+
355
+ if ($item instanceof Mage_Sales_Model_Quote_Item) {
356
+ $parentItem = $item->getParentItem();
357
+ if ($parentItem) {
358
+ $item = $parentItem;
359
+ }
360
+ }
361
+ /**
362
+ * Integration 3 start, show price shop in cart*
363
+ */
364
+ $isLocationAllow = false;
365
+ //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
366
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
367
+ if ($typeIntegration == 3) {
368
+ $isLocationAllow = true;
369
+ }
370
+ /**
371
+ * Integration 3 end, show price shop in cart*
372
+ */
373
+ if ($isLocationAllow) {
374
+ $productModel = Mage::getModel('catalog/product')->load($productId);
375
+ $total = str_replace(",", "", $productModel->getTotalPriceUSD());
376
+ $item->setIdProductSkybox($productIdSkybox);
377
+
378
+ // Currency amounts in the default currency of that customer
379
+ $item->setCustomsSkybox($productModel->getCustoms());
380
+ $item->setShippingSkybox($productModel->getShipping());
381
+ $item->setInsuranceSkybox($productModel->getInsurance());
382
+ $item->setPriceSkybox($productModel->getPrice());
383
+ $item->setTotalSkybox($productModel->getTotalPrice());
384
+ // $item->setRowTotal($total);
385
+
386
+ // Currency amounts in the USD Currency
387
+ $item->setCustomsUsdSkybox($productModel->getCustomsUSD());
388
+ $item->setShippingUsdSkybox($productModel->getShippingUSD());
389
+ $item->setInsuranceUsdSkybox($productModel->getInsuranceUSD());
390
+ $item->setPriceUsdSkybox($productModel->getPriceUSD());
391
+ $item->setTotalUsdSkybox($productModel->getTotalPriceUSD());
392
+
393
+ $item->setGuidSkybox($productModel->getGuidSkybox()); //Set GUID
394
+
395
+
396
+ $item->setBasePriceSkybox($productModel->getBasePrice());
397
+ $item->setBasePriceUsdSkybox($productModel->getBasePriceUSD());
398
+ $item->setAdjustTotalSkybox($productModel->getAdjustPrice());
399
+ $item->setAdjustTotalUsdSkybox($productModel->getAdjustPriceUSD());
400
+ $item->setAdjustLabelSkybox($productModel->getAdjustLabel());
401
+
402
+ //$item->setOriginalCustomPrice($this->_getProductApi()->getTotalPriceUSD());
403
+ //$item->setOriginalCustomPrice($total);
404
+ // $item->setOriginalCustomPrice($this->_getProductApi()->getPrice());
405
+ // $prices = str_replace(',', '', $productModel->getPrice());
406
+ // $prices = number_format((float)($prices), 2, ',', '.');
407
+ // $item->setOriginalCustomPrice($prices);
408
+ //$skybox_total = str_replace(",", "", $this->_getProductApi()->getTotalPrice());
409
+ $skybox_total = str_replace(",", "", $productModel->getPrice());
410
+ $row_total = floatval($skybox_total) * $item->getQty();
411
+ $item->setRowTotalSkybox($row_total);
412
+ } else {
413
+ $total = str_replace(",", "", $this->_getProductApi()->getTotalPriceUSD());
414
+ $item->setIdProductSkybox($productIdSkybox);
415
+
416
+ // Currency amounts in the default currency of that customer
417
+ $item->setCustomsSkybox($this->_getProductApi()->getCustoms());
418
+ $item->setShippingSkybox($this->_getProductApi()->getShipping());
419
+ $item->setInsuranceSkybox($this->_getProductApi()->getInsurance());
420
+ $item->setPriceSkybox($this->_getProductApi()->getPrice());
421
+ $item->setTotalSkybox($this->_getProductApi()->getTotalPrice());
422
+ // $item->setRowTotal($total);
423
+
424
+ // Currency amounts in the USD Currency
425
+ $item->setCustomsUsdSkybox($this->_getProductApi()->getCustomsUSD());
426
+ $item->setShippingUsdSkybox($this->_getProductApi()->getShippingUSD());
427
+ $item->setInsuranceUsdSkybox($this->_getProductApi()->getInsuranceUSD());
428
+ $item->setPriceUsdSkybox($this->_getProductApi()->getPriceUSD());
429
+ $item->setTotalUsdSkybox($this->_getProductApi()->getTotalPriceUSD());
430
+
431
+ $item->setGuidSkybox($this->_getProductApi()->getGuidSkybox()); //Set GUID
432
+
433
+ $item->setBasePriceSkybox($this->_getProductApi()->getBasePrice());
434
+ $item->setBasePriceUsdSkybox($this->_getProductApi()->getBasePriceUSD());
435
+ $item->setAdjustTotalSkybox($this->_getProductApi()->getAdjustPrice());
436
+ $item->setAdjustTotalUsdSkybox($this->_getProductApi()->getAdjustPriceUSD());
437
+ $item->setAdjustLabelSkybox($this->_getProductApi()->getAdjustLabel());
438
+
439
+ //$item->setOriginalCustomPrice($this->_getProductApi()->getTotalPriceUSD());
440
+ //$item->setOriginalCustomPrice($total);
441
+ // $item->setOriginalCustomPrice($this->_getProductApi()->getPrice());
442
+ // $prices = str_replace(',', '', $this->_getProductApi()->getPrice());
443
+ // $prices = number_format((float)($prices), 2, ',', '.');
444
+ // $item->setOriginalCustomPrice($prices);
445
+ //$skybox_total = str_replace(",", "", $this->_getProductApi()->getTotalPrice());
446
+ $skybox_total = str_replace(",", "", $this->_getProductApi()->getPrice());
447
+ $row_total = floatval($skybox_total) * $item->getQty();
448
+ $item->setRowTotalSkybox($row_total);
449
+ }
450
+ break;
451
+ }
452
+ }
453
+
454
+ }
455
+
456
+ private function _updateQuoteItem_backup($productId, $productIdSkybox)
457
+ {
458
+ Mage::log('pas x aqui2', null, 'minicars.log', true);
459
+
460
+ foreach ($this->getQuote()->getAllItems() as $item) {
461
+
462
+ if ($item->getProductId() == $productId) {
463
+
464
+ if ($item instanceof Mage_Sales_Model_Quote_Item) {
465
+ $parentItem = $item->getParentItem();
466
+ if ($parentItem) {
467
+ $item = $parentItem;
468
+ }
469
+ }
470
+
471
+ $total = str_replace(",", "", $this->_getProductApi()->getTotalPriceUSD());
472
+ $item->setIdProductSkybox($productIdSkybox);
473
+
474
+ // Currency amounts in the default currency of that customer
475
+ $item->setCustomsSkybox($this->_getProductApi()->getCustoms());
476
+ $item->setShippingSkybox($this->_getProductApi()->getShipping());
477
+ $item->setInsuranceSkybox($this->_getProductApi()->getInsurance());
478
+ $item->setPriceSkybox($this->_getProductApi()->getPrice());
479
+ $item->setTotalSkybox($this->_getProductApi()->getTotalPrice());
480
+ $item->setRowTotal($total);
481
+
482
+ // Currency amounts in the USD Currency
483
+ $item->setCustomsUsdSkybox($this->_getProductApi()->getCustomsUSD());
484
+ $item->setShippingUsdSkybox($this->_getProductApi()->getShippingUSD());
485
+ $item->setInsuranceUsdSkybox($this->_getProductApi()->getInsuranceUSD());
486
+ $item->setPriceUsdSkybox($this->_getProductApi()->getPriceUSD());
487
+ $item->setTotalUsdSkybox($this->_getProductApi()->getTotalPriceUSD());
488
+
489
+ $item->setGuidSkybox($this->_getProductApi()->getGuidSkybox()); //Set GUID
490
+
491
+
492
+ $item->setBasePriceSkybox($this->_getProductApi()->getBasePrice());
493
+ $item->setBasePriceUsdSkybox($this->_getProductApi()->getBasePriceUSD());
494
+ $item->setAdjustTotalSkybox($this->_getProductApi()->getAdjustPrice());
495
+ $item->setAdjustTotalUsdSkybox($this->_getProductApi()->getAdjustPriceUSD());
496
+ $item->setAdjustLabelSkybox($this->_getProductApi()->getAdjustLabel());
497
+
498
+ //$item->setOriginalCustomPrice($this->_getProductApi()->getTotalPriceUSD());
499
+ //$item->setOriginalCustomPrice($total);
500
+ // $item->setOriginalCustomPrice($this->_getProductApi()->getPrice());
501
+ $prices = str_replace(',', '', $this->_getProductApi()->getPrice());
502
+ $prices = number_format((float)($prices), 2, ',', '.');
503
+ $item->setOriginalCustomPrice($prices);
504
+ //$skybox_total = str_replace(",", "", $this->_getProductApi()->getTotalPrice());
505
+ $skybox_total = str_replace(",", "", $this->_getProductApi()->getPrice());
506
+ $row_total = floatval($skybox_total) * $item->getQty();
507
+ $item->setRowTotalSkybox($row_total);
508
+
509
+ break;
510
+ }
511
+ }
512
+
513
+ }
514
+
515
+ /**
516
+ * Remove item from cart
517
+ *
518
+ * @param int $itemId
519
+ * @return Mage_Checkout_Model_Cart
520
+ */
521
+ public function removeItem($itemId)
522
+ {
523
+ /**
524
+ * only one time for call to service start - Active
525
+ * when do remove
526
+ */
527
+ $session = Mage::getSingleton("core/session", array("name" => "frontend"));
528
+ $session->setData("callToSkyBox", true);
529
+ //Mage::log("Call true: remove", null, 'local.log', true);
530
+ /**
531
+ * when do remove
532
+ */
533
+ if (!$this->isEnable()) {
534
+ parent::removeItem($itemId);
535
+ return $this;
536
+ }
537
+
538
+ $quoteItem = $this->getQuote()->getItemById($itemId);
539
+
540
+ if (!$quoteItem) {
541
+ Mage::throwException(Mage::helper('checkout')->__('ID incorrecto de producto.'));
542
+ return $this;
543
+ }
544
+ Mage::log("|removeItem|" . $quoteItem->getIdProductSkybox());
545
+ //Realizar llamada al servicio de agregar producto al carrito.
546
+ $idProductSkybox = $quoteItem->getIdProductSkybox();
547
+ $this->_getApi()->DeleteProductOfCart($idProductSkybox);
548
+
549
+ if ($this->_getApi()->HasError()) {
550
+ Mage::throwException(Mage::helper('checkout')->__('Error al eliminar producto al carrito.'));
551
+ return $this;
552
+ }
553
+
554
+ return parent::removeItem($itemId);
555
+ }
556
+
557
+ /**
558
+ * Update cart items information
559
+ *
560
+ * @param array $data
561
+ * @return Mage_Checkout_Model_Cart
562
+ */
563
+ public function updateItems($data)
564
+ {
565
+ /**
566
+ * only one time for call to service start - Active
567
+ * when do remove
568
+ */
569
+ $session = Mage::getSingleton("core/session", array("name" => "frontend"));
570
+ $session->setData("callToSkyBox", true);
571
+ //Mage::log("Call true: update cart", null, 'local.log', true);
572
+ /**
573
+ * when do remove
574
+ */
575
+ if (!$this->isEnable()) {
576
+ parent::updateItems($data);
577
+ return $this;
578
+ }
579
+
580
+ Mage::log('pas x aqui5', null, 'cartdetail.log', true);
581
+ //Mage::log(print_r($data, true), null, 'tracer.log', true);
582
+ //Mage::log("Skybox_Checkout_Checkout_Model_Cart updateItem");
583
+ //return parent::updateItems($data);
584
+ // Mage::dispatchEvent('checkout_cart_update_items_before', array('cart'=>$this, 'info'=>$data));
585
+
586
+ foreach ($data as $itemId => $itemInfo) {
587
+ $item = $this->getQuote()->getItemById($itemId);
588
+ //Mage::log('item:', null, 'tracer.log', true);
589
+ //Mage::log(print_r($item->debug(), true), null, 'tracer.log', true);
590
+ //Mage::log(print_r($itemInfo, true), null, 'tracer.log', true);
591
+ //Mage::log('updateItems foreach', null, 'tracer.log', true);
592
+ if (!$item) {
593
+ //Mage::log('no item', null, 'tracer.log', true);
594
+ continue;
595
+ }
596
+
597
+ // if(isset($itemInfo['price']) && !empty($itemInfo['price'])) {
598
+ // //price, base_price, custom_price, row_total, base_row_total, row_total_with_discount, original_custom_price
599
+ // $price = (float) $itemInfo['price'];
600
+ // $item->setPrice($price);
601
+ // $item->setRowTotal($price);
602
+ // $item->setBasePrice($price);
603
+ // continue;
604
+ // }
605
+
606
+ if (!empty($itemInfo['remove']) || (isset($itemInfo['qty']) && $itemInfo['qty'] == '0')) {
607
+ $this->removeItem($itemId);
608
+ continue;
609
+ }
610
+
611
+ $qty = isset($itemInfo['qty']) ? (float)$itemInfo['qty'] : false;
612
+ //Mage::log('cantidad: '.$qty, null, 'tracer.log', true);
613
+ if ($qty > 0) {
614
+
615
+ $idProductSkybox = $item->getIdProductSkybox();
616
+
617
+ // $this->_getApi()->UpdateProductOfCart($idProductSkybox, $qty);
618
+
619
+ $item->setQty($qty);
620
+
621
+ //$skybox_total = str_replace(",", "", $item->getTotalSkybox());
622
+ $skybox_total = str_replace(",", "", $item->getPriceSkybox());
623
+
624
+
625
+ $row_total = floatval($skybox_total) * $item->getQty();
626
+ $item->setRowTotalSkybox($row_total);
627
+
628
+ //Mage::log('fin qty', null, 'tracer.log', true);
629
+ }
630
+ }
631
+
632
+ // Mage::dispatchEvent('checkout_cart_update_items_after', array('cart'=>$this, 'info'=>$data));
633
+ $current = parent::updateItems($data);
634
+ return $current;
635
+ }
636
+
637
+ /**
638
+ * Mark all quote items as deleted (empty shopping cart)
639
+ *
640
+ * @return Mage_Checkout_Model_Cart
641
+ */
642
+ public function truncate()
643
+ {
644
+ foreach ($this->getQuote()->getAllItems() as $item) {
645
+ //Mage::log("truncate() ". $item->getId(), null, 'api.log', true);
646
+ $this->removeItem($item->getId());
647
+ }
648
+
649
+ parent::truncate();
650
+ return $this;
651
+ }
652
+
653
+ /**
654
+ * Mark all quote items as deleted (empty shopping cart)
655
+ * @return $this
656
+ */
657
+ public function truncateMgCart()
658
+ {
659
+ parent::truncate();
660
+ return $this;
661
+ }
662
+
663
+ /**
664
+ * Update item in shopping cart (quote)
665
+ * $requestInfo - either qty (int) or buyRequest in form of array or Varien_Object
666
+ * $updatingParams - information on how to perform update, passed to Quote->updateItem() method
667
+ */
668
+ public function updateItem($itemId, $requestInfo = null, $updatingParams = null)
669
+ {
670
+ if (!$this->isEnable()) {
671
+ $result = parent::updateItem($itemId, $requestInfo, $updatingParams);
672
+ return $result;
673
+ }
674
+
675
+ $item = $this->getQuote()->getItemById($itemId);
676
+ $skyboxProductId = $item->getIdProductSkybox();
677
+ $_quoteItemId = $item->getId();
678
+ $_qty = $item->getQty();
679
+
680
+ /** @var Mage_Sales_Model_Quote_Item $result */
681
+ $result = parent::updateItem($itemId, $requestInfo, $updatingParams);
682
+ $quoteItemId = $result->getId();
683
+ $qty = $result->getQty();
684
+
685
+ // Update Product
686
+ if ($quoteItemId == $_quoteItemId) {
687
+ $this->_getApi()->UpdateProductOfCart($skyboxProductId, $qty);
688
+ } else {
689
+ // Delete and Add a New Product
690
+ $this->_getApi()->DeleteProductOfCart($skyboxProductId);
691
+
692
+ $product = $result->getProduct();
693
+ $this->_getProductApi()->CalculatePrice($product, $requestInfo);
694
+
695
+ $_data = $this->_getProductApi()->getProductData();
696
+ $this->_getApi()->setCurrentProduct($product);
697
+ $this->_getApi()->AddProductOfCart($_data, $qty);
698
+
699
+ $productId = $result->getProduct()->getId();
700
+ $skyboxProductId = $this->_getApi()->getParameter(
701
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID, "0");
702
+
703
+ $this->_updateQuoteItem($productId, $skyboxProductId);
704
+ }
705
+
706
+ return $result;
707
+ }
708
+
709
+ private function getLanguageId()
710
+ {
711
+ $_config = Mage::getModel('skyboxcore/config');
712
+ $cart = $_config->getSession()->getCartSkybox();
713
+ $id = $cart->{'LanguageId'};
714
+ return intval($id);
715
+ }
716
+
717
+ }
app/code/community/Skybox/Checkout/Model/Creditmemo/Total.php CHANGED
@@ -1,18 +1,18 @@
1
- <?php
2
-
3
- class Skybox_Checkout_Model_Creditmemo_Total extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract{
4
-
5
- public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
6
- {
7
-
8
- Mage::log("==============================ini", null, 'invoice.log', true);
9
- $order = $creditmemo->getOrder();
10
- $amount = 20;
11
- if ($amount) {
12
- $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $amount);
13
- $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $amount);
14
- }
15
-
16
- return $this;
17
- }
18
  }
1
+ <?php
2
+
3
+ class Skybox_Checkout_Model_Creditmemo_Total extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract{
4
+
5
+ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
6
+ {
7
+
8
+ Mage::log("==============================ini", null, 'invoice.log', true);
9
+ $order = $creditmemo->getOrder();
10
+ $amount = 20;
11
+ if ($amount) {
12
+ $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $amount);
13
+ $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $amount);
14
+ }
15
+
16
+ return $this;
17
+ }
18
  }
app/code/community/Skybox/Checkout/Model/Invoice/Total.php CHANGED
@@ -1,18 +1,18 @@
1
- <?php
2
-
3
- class Skybox_Checkout_Model_Invoice_Total extends Mage_Sales_Model_Order_Invoice_Total_Abstract
4
- {
5
- public function collect($invoice)
6
- {
7
-
8
- /*Mage::log("==============================ini", null, 'invoice.log', true);
9
- $order = $invoice->getOrder();
10
- $amount = 40;
11
- if ($amount) {
12
- $invoice->setGrandTotal($invoice->getGrandTotal() + $amount);
13
- $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $amount);
14
- }*/
15
-
16
- return $this;
17
- }
18
- }
1
+ <?php
2
+
3
+ class Skybox_Checkout_Model_Invoice_Total extends Mage_Sales_Model_Order_Invoice_Total_Abstract
4
+ {
5
+ public function collect($invoice)
6
+ {
7
+
8
+ /*Mage::log("==============================ini", null, 'invoice.log', true);
9
+ $order = $invoice->getOrder();
10
+ $amount = 40;
11
+ if ($amount) {
12
+ $invoice->setGrandTotal($invoice->getGrandTotal() + $amount);
13
+ $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $amount);
14
+ }*/
15
+
16
+ return $this;
17
+ }
18
+ }
app/code/community/Skybox/Checkout/Model/Observer.php CHANGED
@@ -1,328 +1,328 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Checkout
5
- *
6
- * @category Skybox
7
- * @package Skybox_Checkout
8
- * @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Checkout_Model_Observer
11
- {
12
- protected $_typeApi = 'skyboxcheckout/api_checkout';
13
- /**
14
- * Model instance
15
- *
16
- * @var Skybox_Checkout_Model_Api_Checkout
17
- */
18
- protected $_api = null;
19
-
20
- protected function _getApi()
21
- {
22
- if (null === $this->_api) {
23
- $this->_api = Mage::getModel($this->_typeApi);
24
- }
25
-
26
- return $this->_api;
27
- }
28
-
29
- protected $_typeProduct = 'skyboxcatalog/api_product';
30
- protected $_product = null;
31
- protected $_enable = null;
32
-
33
- protected function _getProduct()
34
- {
35
- if (null === $this->_product) {
36
- $this->_product = Mage::getModel($this->_typeProduct);
37
- }
38
-
39
- return $this->_product;
40
- }
41
-
42
- private function isEnable()
43
- {
44
- if ($this->_enable === null) {
45
- // $value = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
46
- $value = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
47
- $this->_enable = $value;
48
- }
49
- return $this->_enable;
50
- }
51
-
52
- /**
53
- * Metodo inicializador de Skybox Checkout
54
- */
55
- public function InitializeSkybox($observer)
56
- {
57
- $event = $observer->getEvent();
58
- Mage::log($event->getName());
59
- $this->_getApi()->InitializeBarSkybox();
60
- }
61
-
62
- public function RemoveTax(Varien_Event_Observer $observer)
63
- {
64
- if (!$this->isEnable()) {
65
- return;
66
- }
67
-
68
- Mage::log('RemoveTax->ini', null, 'SkyObserver.log', true);
69
- $customer_id = Mage::getSingleton('customer/session')->getId();
70
- $customer = Mage::getModel("customer/customer")->load($customer_id);
71
-
72
- if ($customer->getIsTaxExempt() == 1) {
73
- $items = $observer->getEvent()->getQuote()->getAllVisibleItems();
74
- foreach ($items as $item) {
75
- $item->getProduct()->setTaxClassId(0);
76
- }
77
- Mage::log('RemoveTax->Tax', null, 'SkyObserver.log', true);
78
- }
79
- Mage::log('RemoveTax->fin', null, 'SkyObserver.log', true);
80
- }
81
-
82
- public function CalculatePriceQuoteItem(Varien_Event_Observer $observer)
83
- {
84
- if (!$this->isEnable()) {
85
- return $this;
86
- }
87
- // Mage::log('Observer->CalculatePriceQuoteItem->ini', null, 'cart.log', true);
88
-
89
- $event = $observer->getEvent();
90
- $quote_item = $event->getQuoteItem();
91
-
92
- /*if (count($quote_item)) {
93
- foreach ($quote_item as $item) {
94
-
95
- $item->setTaxPercent(0);
96
- $item->setTaxAmount(0);
97
- $item->setBaseTaxAmount(0);
98
-
99
- $item->setPriceInclTax($item->getPrice());
100
- $item->setBasePriceInclTax($item->getBasePrice());
101
- $item->setBaseRowTotalInclTax($item->setBaseRowTotal());
102
-
103
- }
104
-
105
- //$quote_item->save();
106
- Mage::log('|UpdateParametersQuoteItem|fin', null, 'cart.log', true);
107
- }*/
108
-
109
- return $this;
110
-
111
- //$product = $quote_item->getProduct();
112
-
113
- /*$quote = Mage::getSingleton('checkout/session');
114
- foreach ($quote->getQuote()->getAllItems() as $item) {
115
- if($item->getProductId() == $quote_item->getProductId())
116
- {
117
- Mage::throwException(
118
- Mage::helper('sales')->__('Error al agregar producto al carrito.' . $item->getQty())
119
- );
120
- break;
121
- }
122
- }
123
- Mage::throwException(
124
- Mage::helper('sales')->__('Error al agregar producto al carrito.-')
125
- );*/
126
- /*$this->_getProduct()->CalculatePrice($quote_item->getProductId(), $product->getFInalPrice());
127
-
128
- if($this->_getProduct()->HasError())
129
- {
130
- Mage::throwException(
131
- Mage::helper('sales')->__('Error al agregar producto al carrito.')
132
- );
133
- //return $this;
134
- }
135
-
136
- Mage::log(json_encode($this->_getProduct()->getResponse()));
137
-
138
- $this->_getApi()->AddProductOfCart($quote_item->getProductId(), 1);
139
-
140
-
141
-
142
- if($this->_getApi()->HasError())
143
- {
144
- Mage::throwException(
145
- Mage::helper('sales')->__('Error al agregar producto al carrito')
146
- );
147
- //return $this;
148
- }
149
-
150
- $idProductSkybox = $this->_getApi()->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID, "0");
151
- $customsSkybox = $this->_getProduct()->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_CUSTOMS, "0");
152
- $shippingSkybox = $this->_getProduct()->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_SHIPPING, "0");
153
- $insuranceSkybox = $this->_getProduct()->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_INSURANCE, "0");
154
- $totalPrice = $this->_getProduct()->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_TOTAL, "0");
155
-
156
- $quote_item->setIdProductSkybox($idProductSkybox);
157
- $quote_item->setCustomsSkybox($customsSkybox);
158
- $quote_item->setShippingSkybox($shippingSkybox);
159
- $quote_item->setInsureSkybox($insuranceSkybox);
160
- $quote_item->setOriginalCustomPrice($totalPrice);
161
-
162
- $quote_item->save();
163
- */
164
- //Mage::log('|UpdateParametersQuoteItem| id->' . $quote_item->getId() . " quty->" . $quote_item->getQty(), null, 'cart.log', true);
165
- }
166
-
167
- public function changeQuoteAddressSkybox(Varien_Event_Observer $observer)
168
- {
169
- /**
170
- * only one time for call to service start - Active
171
- * This always run when you do alter to product as change/delete product
172
- */
173
- //$session = Mage::getSingleton("core/session", array("name"=>"frontend"));
174
- //$session->setData("callToSkyBox", true);
175
-
176
- /**
177
- * only one time for call to service end - Active
178
- */
179
-
180
- if (!$this->isEnable()) {
181
- return $this;
182
- }
183
-
184
- /**
185
- * Integration 3 start, show price shop in cart*
186
- */
187
- $allowRunByIntegration3 = true;
188
- //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
189
- $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
190
- if ($typeIntegration == 3) {
191
- $allowRunByIntegration3 = false;
192
- }
193
- //Mage::log("Call true22: changeQuoteAddressSkybox", null, 'local.log', true);
194
- /**
195
- * Integration 3 end, show price shop in cart*
196
- */
197
- if ($allowRunByIntegration3) {
198
- if ($this->_getApi()->getLocationAllow()) {
199
- Mage::log('Observer->changeQuoteAddressSkybox : ini', null, 'TotalSales.log', true);
200
- /* $quote Mage_Sales_Model_Quote */
201
- $quote = $observer->getEvent()->getQuote();
202
-
203
- /* $address Mage_Sales_Model_Quote_Address */
204
- $address = $quote->getShippingAddress();
205
-
206
- $totals = 0;
207
- $baseTotals = 0;
208
- $totalTax = 0;
209
-
210
- foreach ($quote->getAllItems() as $item) {
211
-
212
- //Estas lineas se agregaron para elimnar el Tax del Carrito
213
- /*$item->setTaxPercent(0);
214
- $item->setTaxAmount(0);
215
- $item->setBaseTaxAmount(0);
216
-
217
- $item->setPriceInclTax($item->getPrice());
218
- $item->setBasePriceInclTax($item->getBasePrice());
219
- $item->setBaseRowTotalInclTax($item->setBaseRowTotal());*/
220
- //------------------------------------------------------------>
221
-
222
- Mage::log('Observer->changeQuoteAddressSkybox->Item->getRowTotalSkybox->' . $item->getRowTotalSkybox(),
223
- null, 'TotalSales.log', true);
224
-
225
- $totals += $item->getRowTotalSkybox();
226
- }
227
-
228
- $quote->save();
229
-
230
- $baseTotals = $totals;
231
-
232
- //$totalTax1= $address->getTaxAmount();
233
-
234
- //Estas lineas se agregaron para elimnar el Tax del Carrito
235
- $address->setTaxAmount(0);
236
- $address->setBaseTaxAmount(0);
237
-
238
- $applied_taxes = array();
239
-
240
- $address->setAppliedTaxes($applied_taxes);
241
- //------------------------------------------------------------>
242
-
243
- //$address->save();
244
-
245
- //$totales = $address->getTotalAmount("checkout_total1");
246
-
247
- //$tamanio = count($totales);
248
- //for ($x=0;$x<$tamanio; $x++) Mage::log('Observer->changeQuoteAddressSkybox->total->' . $totales[$x], null, 'TotalSales.log', true);
249
-
250
- //Mage::log('Observer->changeQuoteAddressSkybox->totales->' . var_dump($totales["subtotal"]), null, 'TotalSales.log', true);
251
- //Mage::log('Observer->changeQuoteAddressSkybox->totales->' . $totales, null, 'TotalSales.log', true);
252
-
253
- $totalTax = 0; //$address->getTaxAmount(); //Comentado
254
-
255
- //Recorremos los conceptos agrupados (esto debe modificarse no es lo optimo)
256
- /*$conceptsSkybox = json_decode($address->getConceptsSkybox());
257
- foreach ($conceptsSkybox as $concept) {
258
- $totalTax = $totalTax + $concept->Value;
259
- }*/
260
-
261
- $totalRmt = 0;
262
- //Recorremos los conceptos agrupados (esto debe modificarse no es lo optimo)
263
- /*$rmtSkybox = json_decode($address->getRmtSkybox());
264
- foreach ($rmtSkybox as $rmt) {
265
- $totalRmt = $totalRmt + $rmt->Value;
266
- }*/
267
-
268
- //Mage::log('Observer->changeQuoteAddressSkybox->totalTax1->' . $totalTax1 . ' &totalbase->' . $baseTotals, null, 'TotalSales.log', true);
269
- //Mage::log('Observer->changeQuoteAddressSkybox->totalTax->' . $totalTax . ' &totalbase->' . $baseTotals, null, 'TotalSales.log', true);
270
-
271
- /*$address->setSubtotalSkybox($totals);
272
- $address->setBaseSubtotalSkybox($baseTotals);
273
- $address->setGrandTotalSkybox($totals+$totalTax);
274
- $address->setBaseGrandTotalSkybox($baseTotals+$totalTax);*/
275
-
276
- $baseTotals = $address->getBaseGrandTotalSkybox();
277
- $totals = $address->getGrandTotalSkybox();
278
-
279
- $address->setPriceInclTax($totals);
280
- $address->setBasePriceInclTax($baseTotals);
281
-
282
- $totals = floatval(preg_replace("/[^-0-9\.]/", "", $totals));
283
- //$address->setGrandTotal($totals+$totalTax);
284
- $address->setGrandTotal($totals + $totalTax);
285
- $address->setBaseGrandTotal($baseTotals + $totalTax);
286
-
287
- //$address->save();
288
-
289
- Mage::log('Observer->changeQuoteAddressSkybox : fin', null, 'TotalSales.log', true);
290
-
291
- return $this;
292
- }
293
- return $this;
294
- }
295
-
296
- }
297
-
298
- /**
299
- * Hide Skybox Shipping Method
300
- * @param Varien_Event_Observer $observer
301
- */
302
- public function hideShippingMethod(Varien_Event_Observer $observer)
303
- {
304
- if (Mage::getDesign()->getArea() === Mage_Core_Model_App_Area::AREA_FRONTEND) {
305
- $quote = $observer->getEvent()->getQuote();
306
- $store = Mage::app()->getStore($quote->getStoreId());
307
- $carriers = Mage::getStoreConfig('carriers', $store);
308
-
309
- $hiddenMethodCode = 'skyboxcheckout_shipping';
310
-
311
- foreach ($carriers as $carrierCode => $carrierConfig) {
312
- if ($carrierCode == $hiddenMethodCode) {
313
- $store->setConfig("carriers/{$carrierCode}/active", '0');
314
- }
315
- }
316
- }
317
- }
318
-
319
- public function paymentMethodIsActive(Varien_Event_Observer $observer)
320
- {
321
- $event = $observer->getEvent();
322
- $result = $event->getResult();
323
-
324
- $allowHelper = Mage::helper('skyboxcore/allow');
325
- $result->isAvailable = ($allowHelper->isPriceEnabled()) ? false : true ;
326
-
327
- }
328
- }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Checkout
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Checkout
8
+ * @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Checkout_Model_Observer
11
+ {
12
+ protected $_typeApi = 'skyboxcheckout/api_checkout';
13
+ /**
14
+ * Model instance
15
+ *
16
+ * @var Skybox_Checkout_Model_Api_Checkout
17
+ */
18
+ protected $_api = null;
19
+
20
+ protected function _getApi()
21
+ {
22
+ if (null === $this->_api) {
23
+ $this->_api = Mage::getModel($this->_typeApi);
24
+ }
25
+
26
+ return $this->_api;
27
+ }
28
+
29
+ protected $_typeProduct = 'skyboxcatalog/api_product';
30
+ protected $_product = null;
31
+ protected $_enable = null;
32
+
33
+ protected function _getProduct()
34
+ {
35
+ if (null === $this->_product) {
36
+ $this->_product = Mage::getModel($this->_typeProduct);
37
+ }
38
+
39
+ return $this->_product;
40
+ }
41
+
42
+ private function isEnable()
43
+ {
44
+ if ($this->_enable === null) {
45
+ // $value = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
46
+ $value = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
47
+ $this->_enable = $value;
48
+ }
49
+ return $this->_enable;
50
+ }
51
+
52
+ /**
53
+ * Metodo inicializador de Skybox Checkout
54
+ */
55
+ public function InitializeSkybox($observer)
56
+ {
57
+ $event = $observer->getEvent();
58
+ Mage::log($event->getName());
59
+ $this->_getApi()->InitializeBarSkybox();
60
+ }
61
+
62
+ public function RemoveTax(Varien_Event_Observer $observer)
63
+ {
64
+ if (!$this->isEnable()) {
65
+ return;
66
+ }
67
+
68
+ Mage::log('RemoveTax->ini', null, 'SkyObserver.log', true);
69
+ $customer_id = Mage::getSingleton('customer/session')->getId();
70
+ $customer = Mage::getModel("customer/customer")->load($customer_id);
71
+
72
+ if ($customer->getIsTaxExempt() == 1) {
73
+ $items = $observer->getEvent()->getQuote()->getAllVisibleItems();
74
+ foreach ($items as $item) {
75
+ $item->getProduct()->setTaxClassId(0);
76
+ }
77
+ Mage::log('RemoveTax->Tax', null, 'SkyObserver.log', true);
78
+ }
79
+ Mage::log('RemoveTax->fin', null, 'SkyObserver.log', true);
80
+ }
81
+
82
+ public function CalculatePriceQuoteItem(Varien_Event_Observer $observer)
83
+ {
84
+ if (!$this->isEnable()) {
85
+ return $this;
86
+ }
87
+ // Mage::log('Observer->CalculatePriceQuoteItem->ini', null, 'cart.log', true);
88
+
89
+ $event = $observer->getEvent();
90
+ $quote_item = $event->getQuoteItem();
91
+
92
+ /*if (count($quote_item)) {
93
+ foreach ($quote_item as $item) {
94
+
95
+ $item->setTaxPercent(0);
96
+ $item->setTaxAmount(0);
97
+ $item->setBaseTaxAmount(0);
98
+
99
+ $item->setPriceInclTax($item->getPrice());
100
+ $item->setBasePriceInclTax($item->getBasePrice());
101
+ $item->setBaseRowTotalInclTax($item->setBaseRowTotal());
102
+
103
+ }
104
+
105
+ //$quote_item->save();
106
+ Mage::log('|UpdateParametersQuoteItem|fin', null, 'cart.log', true);
107
+ }*/
108
+
109
+ return $this;
110
+
111
+ //$product = $quote_item->getProduct();
112
+
113
+ /*$quote = Mage::getSingleton('checkout/session');
114
+ foreach ($quote->getQuote()->getAllItems() as $item) {
115
+ if($item->getProductId() == $quote_item->getProductId())
116
+ {
117
+ Mage::throwException(
118
+ Mage::helper('sales')->__('Error al agregar producto al carrito.' . $item->getQty())
119
+ );
120
+ break;
121
+ }
122
+ }
123
+ Mage::throwException(
124
+ Mage::helper('sales')->__('Error al agregar producto al carrito.-')
125
+ );*/
126
+ /*$this->_getProduct()->CalculatePrice($quote_item->getProductId(), $product->getFInalPrice());
127
+
128
+ if($this->_getProduct()->HasError())
129
+ {
130
+ Mage::throwException(
131
+ Mage::helper('sales')->__('Error al agregar producto al carrito.')
132
+ );
133
+ //return $this;
134
+ }
135
+
136
+ Mage::log(json_encode($this->_getProduct()->getResponse()));
137
+
138
+ $this->_getApi()->AddProductOfCart($quote_item->getProductId(), 1);
139
+
140
+
141
+
142
+ if($this->_getApi()->HasError())
143
+ {
144
+ Mage::throwException(
145
+ Mage::helper('sales')->__('Error al agregar producto al carrito')
146
+ );
147
+ //return $this;
148
+ }
149
+
150
+ $idProductSkybox = $this->_getApi()->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID, "0");
151
+ $customsSkybox = $this->_getProduct()->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_CUSTOMS, "0");
152
+ $shippingSkybox = $this->_getProduct()->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_SHIPPING, "0");
153
+ $insuranceSkybox = $this->_getProduct()->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_INSURANCE, "0");
154
+ $totalPrice = $this->_getProduct()->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_TOTAL, "0");
155
+
156
+ $quote_item->setIdProductSkybox($idProductSkybox);
157
+ $quote_item->setCustomsSkybox($customsSkybox);
158
+ $quote_item->setShippingSkybox($shippingSkybox);
159
+ $quote_item->setInsureSkybox($insuranceSkybox);
160
+ $quote_item->setOriginalCustomPrice($totalPrice);
161
+
162
+ $quote_item->save();
163
+ */
164
+ //Mage::log('|UpdateParametersQuoteItem| id->' . $quote_item->getId() . " quty->" . $quote_item->getQty(), null, 'cart.log', true);
165
+ }
166
+
167
+ public function changeQuoteAddressSkybox(Varien_Event_Observer $observer)
168
+ {
169
+ /**
170
+ * only one time for call to service start - Active
171
+ * This always run when you do alter to product as change/delete product
172
+ */
173
+ //$session = Mage::getSingleton("core/session", array("name"=>"frontend"));
174
+ //$session->setData("callToSkyBox", true);
175
+
176
+ /**
177
+ * only one time for call to service end - Active
178
+ */
179
+
180
+ if (!$this->isEnable()) {
181
+ return $this;
182
+ }
183
+
184
+ /**
185
+ * Integration 3 start, show price shop in cart*
186
+ */
187
+ $allowRunByIntegration3 = true;
188
+ //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
189
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
190
+ if ($typeIntegration == 3) {
191
+ $allowRunByIntegration3 = false;
192
+ }
193
+ //Mage::log("Call true22: changeQuoteAddressSkybox", null, 'local.log', true);
194
+ /**
195
+ * Integration 3 end, show price shop in cart*
196
+ */
197
+ if ($allowRunByIntegration3) {
198
+ if ($this->_getApi()->getLocationAllow()) {
199
+ Mage::log('Observer->changeQuoteAddressSkybox : ini', null, 'TotalSales.log', true);
200
+ /* $quote Mage_Sales_Model_Quote */
201
+ $quote = $observer->getEvent()->getQuote();
202
+
203
+ /* $address Mage_Sales_Model_Quote_Address */
204
+ $address = $quote->getShippingAddress();
205
+
206
+ $totals = 0;
207
+ $baseTotals = 0;
208
+ $totalTax = 0;
209
+
210
+ foreach ($quote->getAllItems() as $item) {
211
+
212
+ //Estas lineas se agregaron para elimnar el Tax del Carrito
213
+ /*$item->setTaxPercent(0);
214
+ $item->setTaxAmount(0);
215
+ $item->setBaseTaxAmount(0);
216
+
217
+ $item->setPriceInclTax($item->getPrice());
218
+ $item->setBasePriceInclTax($item->getBasePrice());
219
+ $item->setBaseRowTotalInclTax($item->setBaseRowTotal());*/
220
+ //------------------------------------------------------------>
221
+
222
+ Mage::log('Observer->changeQuoteAddressSkybox->Item->getRowTotalSkybox->' . $item->getRowTotalSkybox(),
223
+ null, 'TotalSales.log', true);
224
+
225
+ $totals += $item->getRowTotalSkybox();
226
+ }
227
+
228
+ $quote->save();
229
+
230
+ $baseTotals = $totals;
231
+
232
+ //$totalTax1= $address->getTaxAmount();
233
+
234
+ //Estas lineas se agregaron para elimnar el Tax del Carrito
235
+ $address->setTaxAmount(0);
236
+ $address->setBaseTaxAmount(0);
237
+
238
+ $applied_taxes = array();
239
+
240
+ $address->setAppliedTaxes($applied_taxes);
241
+ //------------------------------------------------------------>
242
+
243
+ //$address->save();
244
+
245
+ //$totales = $address->getTotalAmount("checkout_total1");
246
+
247
+ //$tamanio = count($totales);
248
+ //for ($x=0;$x<$tamanio; $x++) Mage::log('Observer->changeQuoteAddressSkybox->total->' . $totales[$x], null, 'TotalSales.log', true);
249
+
250
+ //Mage::log('Observer->changeQuoteAddressSkybox->totales->' . var_dump($totales["subtotal"]), null, 'TotalSales.log', true);
251
+ //Mage::log('Observer->changeQuoteAddressSkybox->totales->' . $totales, null, 'TotalSales.log', true);
252
+
253
+ $totalTax = 0; //$address->getTaxAmount(); //Comentado
254
+
255
+ //Recorremos los conceptos agrupados (esto debe modificarse no es lo optimo)
256
+ /*$conceptsSkybox = json_decode($address->getConceptsSkybox());
257
+ foreach ($conceptsSkybox as $concept) {
258
+ $totalTax = $totalTax + $concept->Value;
259
+ }*/
260
+
261
+ $totalRmt = 0;
262
+ //Recorremos los conceptos agrupados (esto debe modificarse no es lo optimo)
263
+ /*$rmtSkybox = json_decode($address->getRmtSkybox());
264
+ foreach ($rmtSkybox as $rmt) {
265
+ $totalRmt = $totalRmt + $rmt->Value;
266
+ }*/
267
+
268
+ //Mage::log('Observer->changeQuoteAddressSkybox->totalTax1->' . $totalTax1 . ' &totalbase->' . $baseTotals, null, 'TotalSales.log', true);
269
+ //Mage::log('Observer->changeQuoteAddressSkybox->totalTax->' . $totalTax . ' &totalbase->' . $baseTotals, null, 'TotalSales.log', true);
270
+
271
+ /*$address->setSubtotalSkybox($totals);
272
+ $address->setBaseSubtotalSkybox($baseTotals);
273
+ $address->setGrandTotalSkybox($totals+$totalTax);
274
+ $address->setBaseGrandTotalSkybox($baseTotals+$totalTax);*/
275
+
276
+ $baseTotals = $address->getBaseGrandTotalSkybox();
277
+ $totals = $address->getGrandTotalSkybox();
278
+
279
+ $address->setPriceInclTax($totals);
280
+ $address->setBasePriceInclTax($baseTotals);
281
+
282
+ $totals = floatval(preg_replace("/[^-0-9\.]/", "", $totals));
283
+ //$address->setGrandTotal($totals+$totalTax);
284
+ $address->setGrandTotal($totals + $totalTax);
285
+ $address->setBaseGrandTotal($baseTotals + $totalTax);
286
+
287
+ //$address->save();
288
+
289
+ Mage::log('Observer->changeQuoteAddressSkybox : fin', null, 'TotalSales.log', true);
290
+
291
+ return $this;
292
+ }
293
+ return $this;
294
+ }
295
+
296
+ }
297
+
298
+ /**
299
+ * Hide Skybox Shipping Method
300
+ * @param Varien_Event_Observer $observer
301
+ */
302
+ public function hideShippingMethod(Varien_Event_Observer $observer)
303
+ {
304
+ if (Mage::getDesign()->getArea() === Mage_Core_Model_App_Area::AREA_FRONTEND) {
305
+ $quote = $observer->getEvent()->getQuote();
306
+ $store = Mage::app()->getStore($quote->getStoreId());
307
+ $carriers = Mage::getStoreConfig('carriers', $store);
308
+
309
+ $hiddenMethodCode = 'skyboxcheckout_shipping';
310
+
311
+ foreach ($carriers as $carrierCode => $carrierConfig) {
312
+ if ($carrierCode == $hiddenMethodCode) {
313
+ $store->setConfig("carriers/{$carrierCode}/active", '0');
314
+ }
315
+ }
316
+ }
317
+ }
318
+
319
+ public function paymentMethodIsActive(Varien_Event_Observer $observer)
320
+ {
321
+ $event = $observer->getEvent();
322
+ $result = $event->getResult();
323
+
324
+ $allowHelper = Mage::helper('skyboxcore/allow');
325
+ $result->isAvailable = ($allowHelper->isPriceEnabled()) ? false : true ;
326
+
327
+ }
328
+ }
app/code/community/Skybox/Checkout/Model/Pay.php CHANGED
@@ -1,12 +1,12 @@
1
- <?php
2
- class Skybox_Checkout_Model_Pay extends Mage_Payment_Model_Method_Abstract
3
- {
4
-
5
- protected $_code = 'skyboxcheckout_pay';
6
-
7
- protected $_isInitializeNeeded = true;
8
- protected $_canUseInternal = true;
9
- protected $_canUseForMultishipping = false;
10
- protected $_canUseCheckout = false;
11
-
12
  }
1
+ <?php
2
+ class Skybox_Checkout_Model_Pay extends Mage_Payment_Model_Method_Abstract
3
+ {
4
+
5
+ protected $_code = 'skyboxcheckout_pay';
6
+
7
+ protected $_isInitializeNeeded = true;
8
+ protected $_canUseInternal = true;
9
+ protected $_canUseForMultishipping = false;
10
+ protected $_canUseCheckout = false;
11
+
12
  }
app/code/community/Skybox/Checkout/Model/Quote/Address/Total/Rmt.php CHANGED
@@ -1,112 +1,112 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Checkout
5
- *
6
- * @category Skybox
7
- * @package Skybox_Checkout
8
- * @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Checkout_Model_Quote_Address_Total_Rmt extends Mage_Sales_Model_Quote_Address_Total_Abstract
11
- {
12
- /**
13
- * Esta función es llamada cada vez que Magento requiere calcular los
14
- * totales por cualquier motivo: carrito actualizado, usuario se logea,
15
- * aplicar un cupón, selección de medios de envío, de pago, etc.
16
- *
17
- * Se trata de calcular lo que queremos añadir de recargo y actualizar
18
- * el total del carrito (Magento itera sobre los totales y cada uno añade
19
- * su parte)
20
- **/
21
- public function collect(Mage_Sales_Model_Quote_Address $address)
22
- {
23
-
24
- parent::collect($address); //Comentado por verificar
25
-
26
- // Si no hay items, no hay nada que hacer
27
- $items = $this->_getAddressItems($address);
28
- if (!count($items)) {
29
- return $this;
30
- }
31
-
32
- $quote = $address->getQuote();
33
- if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
34
- return $this;
35
- }
36
-
37
- //Verificar esta parte porque se podria raelizar desde el Total
38
-
39
-
40
- return $this;
41
- }
42
-
43
- /**
44
- * Esta función es llamada por Magento cuando quiere mostrar los totales en pantalla.
45
- *
46
- * El cálculo ya se habrá hecho y deberíamos guardarlo en algún sitio para aquí,
47
- * simplemente retornar el valor formateado y que Magento lo muestre.
48
- */
49
- public function fetch(Mage_Sales_Model_Quote_Address $address)
50
- {
51
- parent::fetch($address);
52
-
53
- if (!$this->isEnable()) {
54
- return $this;
55
- }
56
-
57
- $quote = $address->getQuote();
58
- if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
59
- return $this;
60
- }
61
-
62
- $skyboxRMT = $address->getRmtSkybox();
63
-
64
- if ($skyboxRMT) {
65
- $RmtSkyboxjson = json_decode($skyboxRMT);
66
-
67
- Mage::log("quote->address->rmt->fetch : ini", null, 'TotalSales.log', true);
68
-
69
- $i = 0;
70
- foreach ($RmtSkyboxjson as $item) {
71
- $i += 1;
72
- $value = $item->Value;
73
- $value = str_replace(',', '', $value);
74
- // $value = abs($value);
75
-
76
- $address->addTotal(array(
77
- 'code' => 'checkout_total_rmt' . $i,
78
- 'title' => $item->Concept,
79
- 'value' => $value
80
- ));
81
- Mage::log("quote->address->rmt->fetch(Concepts)->" . $item->Concept . "=" . $item->Value, null,
82
- 'TotalSales.log', true);
83
- }
84
-
85
- Mage::log("quote->address->rmt->fetch : fini", null, 'TotalSales.log', true);
86
-
87
- }
88
- return $this;
89
- }
90
-
91
- private function isEnable()
92
- {
93
- /** @var Skybox_Core_Model_Api_Restful $api_restful */
94
- $api_restful = Mage::getModel('skyboxcore/api_restful');
95
- $activation = $api_restful->isModuleEnable();
96
-
97
- if (!$activation) {
98
- return false;
99
- }
100
-
101
- /** @var Skybox_Core_Helper_Allow $allowHelper */
102
- $allowHelper = Mage::helper('skyboxcore/allow');
103
-
104
- $locationAllow = $allowHelper->getLocationAllow();
105
-
106
- if (!$locationAllow) {
107
- return false;
108
- }
109
-
110
- return true;
111
- }
112
- }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Checkout
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Checkout
8
+ * @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Checkout_Model_Quote_Address_Total_Rmt extends Mage_Sales_Model_Quote_Address_Total_Abstract
11
+ {
12
+ /**
13
+ * Esta función es llamada cada vez que Magento requiere calcular los
14
+ * totales por cualquier motivo: carrito actualizado, usuario se logea,
15
+ * aplicar un cupón, selección de medios de envío, de pago, etc.
16
+ *
17
+ * Se trata de calcular lo que queremos añadir de recargo y actualizar
18
+ * el total del carrito (Magento itera sobre los totales y cada uno añade
19
+ * su parte)
20
+ **/
21
+ public function collect(Mage_Sales_Model_Quote_Address $address)
22
+ {
23
+
24
+ parent::collect($address); //Comentado por verificar
25
+
26
+ // Si no hay items, no hay nada que hacer
27
+ $items = $this->_getAddressItems($address);
28
+ if (!count($items)) {
29
+ return $this;
30
+ }
31
+
32
+ $quote = $address->getQuote();
33
+ if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
34
+ return $this;
35
+ }
36
+
37
+ //Verificar esta parte porque se podria raelizar desde el Total
38
+
39
+
40
+ return $this;
41
+ }
42
+
43
+ /**
44
+ * Esta función es llamada por Magento cuando quiere mostrar los totales en pantalla.
45
+ *
46
+ * El cálculo ya se habrá hecho y deberíamos guardarlo en algún sitio para aquí,
47
+ * simplemente retornar el valor formateado y que Magento lo muestre.
48
+ */
49
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
50
+ {
51
+ parent::fetch($address);
52
+
53
+ if (!$this->isEnable()) {
54
+ return $this;
55
+ }
56
+
57
+ $quote = $address->getQuote();
58
+ if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
59
+ return $this;
60
+ }
61
+
62
+ $skyboxRMT = $address->getRmtSkybox();
63
+
64
+ if ($skyboxRMT) {
65
+ $RmtSkyboxjson = json_decode($skyboxRMT);
66
+
67
+ Mage::log("quote->address->rmt->fetch : ini", null, 'TotalSales.log', true);
68
+
69
+ $i = 0;
70
+ foreach ($RmtSkyboxjson as $item) {
71
+ $i += 1;
72
+ $value = $item->Value;
73
+ $value = str_replace(',', '', $value);
74
+ // $value = abs($value);
75
+
76
+ $address->addTotal(array(
77
+ 'code' => 'checkout_total_rmt' . $i,
78
+ 'title' => $item->Concept,
79
+ 'value' => $value
80
+ ));
81
+ Mage::log("quote->address->rmt->fetch(Concepts)->" . $item->Concept . "=" . $item->Value, null,
82
+ 'TotalSales.log', true);
83
+ }
84
+
85
+ Mage::log("quote->address->rmt->fetch : fini", null, 'TotalSales.log', true);
86
+
87
+ }
88
+ return $this;
89
+ }
90
+
91
+ private function isEnable()
92
+ {
93
+ /** @var Skybox_Core_Model_Api_Restful $api_restful */
94
+ $api_restful = Mage::getModel('skyboxcore/api_restful');
95
+ $activation = $api_restful->isModuleEnable();
96
+
97
+ if (!$activation) {
98
+ return false;
99
+ }
100
+
101
+ /** @var Skybox_Core_Helper_Allow $allowHelper */
102
+ $allowHelper = Mage::helper('skyboxcore/allow');
103
+
104
+ $locationAllow = $allowHelper->getLocationAllow();
105
+
106
+ if (!$locationAllow) {
107
+ return false;
108
+ }
109
+
110
+ return true;
111
+ }
112
+ }
app/code/community/Skybox/Checkout/Model/Quote/Address/Total/Tax.php CHANGED
@@ -1,6 +1,6 @@
1
- <?php
2
-
3
- class Skybox_Checkout_Model_Quote_Address_Total_Tax extends Mage_Sales_Model_Quote_Address_Total_Abstract
4
- {
5
-
6
  }
1
+ <?php
2
+
3
+ class Skybox_Checkout_Model_Quote_Address_Total_Tax extends Mage_Sales_Model_Quote_Address_Total_Abstract
4
+ {
5
+
6
  }
app/code/community/Skybox/Checkout/Model/Quote/Item.php CHANGED
@@ -1,68 +1,68 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Checkout
5
- *
6
- * @category Skybox
7
- * @package Skybox_Checkout
8
- * @copyright Copyright (c) 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Checkout_Model_Quote_Item extends Mage_Sales_Model_Quote_Item
11
- {
12
- /**
13
- * Declare quote item quantity
14
- *
15
- * @param float $qty
16
- * @return Mage_Sales_Model_Quote_Item
17
- */
18
- public function setQty($qty)
19
- {
20
- $oldQty = $this->_getData('qty');
21
-
22
- parent::setQty($qty);
23
- $qty = $this->getQty();
24
-
25
- if ($oldQty != $qty) {
26
- $skyboxProductId = $this->getIdProductSkybox();
27
-
28
- if ($skyboxProductId) {
29
- $api_checkout = Mage::getModel('skyboxcheckout/api_checkout');
30
- $api_checkout->UpdateProductOfCart($skyboxProductId, $qty);
31
- }
32
- }
33
- return $this;
34
- }
35
-
36
- /**
37
- * Get item price used for quote calculation process.
38
- * This method get custom price (if it is defined) or original product final price
39
- *
40
- * @return float
41
- */
42
- public function getCalculationPrice()
43
- {
44
- $price = parent::getCalculationPrice();
45
- $price = $this->callHelper($price, 'price');
46
- return $price;
47
- }
48
-
49
- /*
50
- * * @method float getRowTotal()
51
- */
52
- public function getRowTotal()
53
- {
54
- $price = parent::getRowTotal();
55
- $price = $this->callHelper($price, 'row_total');
56
- return $price;
57
- }
58
-
59
- private function callHelper($price, $type)
60
- {
61
- $allowHelper = Mage::helper('skyboxcore/allow');
62
- if ($allowHelper->isPriceEnabled()) {
63
- $price = $this->_getData($type . '_skybox');
64
- }
65
- return $price;
66
- }
67
-
68
- }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Checkout
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Checkout
8
+ * @copyright Copyright (c) 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Checkout_Model_Quote_Item extends Mage_Sales_Model_Quote_Item
11
+ {
12
+ /**
13
+ * Declare quote item quantity
14
+ *
15
+ * @param float $qty
16
+ * @return Mage_Sales_Model_Quote_Item
17
+ */
18
+ public function setQty($qty)
19
+ {
20
+ $oldQty = $this->_getData('qty');
21
+
22
+ parent::setQty($qty);
23
+ $qty = $this->getQty();
24
+
25
+ if ($oldQty != $qty) {
26
+ $skyboxProductId = $this->getIdProductSkybox();
27
+
28
+ if ($skyboxProductId) {
29
+ $api_checkout = Mage::getModel('skyboxcheckout/api_checkout');
30
+ $api_checkout->UpdateProductOfCart($skyboxProductId, $qty);
31
+ }
32
+ }
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * Get item price used for quote calculation process.
38
+ * This method get custom price (if it is defined) or original product final price
39
+ *
40
+ * @return float
41
+ */
42
+ public function getCalculationPrice()
43
+ {
44
+ $price = parent::getCalculationPrice();
45
+ $price = $this->callHelper($price, 'price');
46
+ return $price;
47
+ }
48
+
49
+ /*
50
+ * * @method float getRowTotal()
51
+ */
52
+ public function getRowTotal()
53
+ {
54
+ $price = parent::getRowTotal();
55
+ $price = $this->callHelper($price, 'row_total');
56
+ return $price;
57
+ }
58
+
59
+ private function callHelper($price, $type)
60
+ {
61
+ $allowHelper = Mage::helper('skyboxcore/allow');
62
+ if ($allowHelper->isPriceEnabled()) {
63
+ $price = $this->_getData($type . '_skybox');
64
+ }
65
+ return $price;
66
+ }
67
+
68
+ }
app/code/community/Skybox/Checkout/Model/Quote/SubTotal.php CHANGED
@@ -1,136 +1,136 @@
1
- <?php
2
-
3
- class Skybox_Checkout_Model_Quote_SubTotal extends Mage_Sales_Model_Quote_Address_Total_Abstract
4
- {
5
-
6
- // Cantidad del recargo sin impuestos
7
- var $_amount;
8
-
9
- protected $_api = null;
10
- protected $_product = null;
11
-
12
- /* @return Skybox_Checkout_Model_Api_Checkout */
13
- protected function _getApi()
14
- {
15
- if (null === $this->_api) {
16
- $this->_api = Mage::getModel('skyboxcheckout/api_checkout');
17
- }
18
- return $this->_api;
19
- }
20
-
21
- /**
22
- * Return Skybox API Product
23
- *
24
- * @return Skybox_Catalogo_Model_Api_Product
25
- */
26
- protected function _getProductApi()
27
- {
28
- if (null === $this->_product) {
29
- $this->_product = Mage::getModel('skyboxcatalog/api_product');
30
- }
31
- return $this->_product;
32
- }
33
-
34
- /**
35
- * Esta función es llamada cada vez que Magento requiere calcular los
36
- * totales por cualquier motivo: carrito actualizado, usuario se logea,
37
- * aplicar un cupón, selección de medios de envío, de pago, etc.
38
- *
39
- * Se trata de calcular lo que queremos añadir de recargo y actualizar
40
- * el total del carrito (Magento itera sobre los totales y cada uno añade
41
- * su parte)
42
- **/
43
- public function collect(Mage_Sales_Model_Quote_Address $address)
44
- {
45
-
46
- parent::collect($address); //Comentado por verificar
47
-
48
- // Si no hay items, no hay nada que hacer
49
- $items = $this->_getAddressItems($address);
50
- if (!count($items)) {
51
- return $this;
52
- }
53
-
54
- $quote = $address->getQuote();
55
- if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
56
- return $this;
57
- }
58
-
59
-
60
- //$address->setSubTotal(100);
61
- //$address->setBaseSubTotal(100);
62
-
63
- $address->setRowtotalResult(100);
64
-
65
- //$address->setTaxAmount(0);
66
-
67
- //$address->save(); //Guardamos los Cambios
68
- Mage::log("quote->address->collect->getSubTotal->" . $address->getSubTotal(), null, 'SubTotalSales.log', true);
69
- Mage::log("quote->address->collect->getGrandTotal->" . $address->getGrandTotal(), null, 'SubTotalSales.log',
70
- true);
71
-
72
- Mage::log("quote->address->collect->Total->" . $totalskybox, null, 'SubTotalSales.log', true);
73
- Mage::log("quote->address->collect : fin", null, 'SubTotalSales.log', true);
74
-
75
- return $this;
76
- }
77
-
78
- /**
79
- * Esta función es llamada por Magento cuando quiere mostrar los totales en pantalla.
80
- *
81
- * El cálculo ya se habrá hecho y deberíamos guardarlo en algún sitio para aquí,
82
- * simplemente retornar el valor formateado y que Magento lo muestre.
83
- */
84
- public function fetch(Mage_Sales_Model_Quote_Address $address)
85
- {
86
- parent::fetch($address); //Comentado por verificar
87
-
88
- if (!$this->isEnable()) {
89
- return $this;
90
- }
91
-
92
- $quote = $address->getQuote();
93
- if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
94
- return $this;
95
- }
96
-
97
- $_conceptsSkybox = $address->getConceptsSkybox();
98
-
99
- if ($_conceptsSkybox) {
100
-
101
- $ConceptsSkyboxjson = json_decode($address->getConceptsSkybox());
102
-
103
- $address->addTotal(array(
104
- 'code' => 'subtotal',
105
- 'title' => 'Sub Total',
106
- 'value' => 150
107
- ));
108
- Mage::log("quote->address->fetch : fin", null, 'SubTotalSales.log', true);
109
- }
110
-
111
- return $this;
112
- }
113
-
114
- private function isEnable()
115
- {
116
- /** @var Skybox_Core_Model_Api_Restful $api_restful */
117
- $api_restful = Mage::getModel('skyboxcore/api_restful');
118
- $activation = $api_restful->isModuleEnable();
119
-
120
- if (!$activation) {
121
- return false;
122
- }
123
-
124
- /** @var Skybox_Core_Helper_Allow $allowHelper */
125
- $allowHelper = Mage::helper('skyboxcore/allow');
126
-
127
- $locationAllow = $allowHelper->getLocationAllow();
128
-
129
- if (!$locationAllow) {
130
- return false;
131
- }
132
-
133
- return true;
134
- }
135
- }
136
-
1
+ <?php
2
+
3
+ class Skybox_Checkout_Model_Quote_SubTotal extends Mage_Sales_Model_Quote_Address_Total_Abstract
4
+ {
5
+
6
+ // Cantidad del recargo sin impuestos
7
+ var $_amount;
8
+
9
+ protected $_api = null;
10
+ protected $_product = null;
11
+
12
+ /* @return Skybox_Checkout_Model_Api_Checkout */
13
+ protected function _getApi()
14
+ {
15
+ if (null === $this->_api) {
16
+ $this->_api = Mage::getModel('skyboxcheckout/api_checkout');
17
+ }
18
+ return $this->_api;
19
+ }
20
+
21
+ /**
22
+ * Return Skybox API Product
23
+ *
24
+ * @return Skybox_Catalogo_Model_Api_Product
25
+ */
26
+ protected function _getProductApi()
27
+ {
28
+ if (null === $this->_product) {
29
+ $this->_product = Mage::getModel('skyboxcatalog/api_product');
30
+ }
31
+ return $this->_product;
32
+ }
33
+
34
+ /**
35
+ * Esta función es llamada cada vez que Magento requiere calcular los
36
+ * totales por cualquier motivo: carrito actualizado, usuario se logea,
37
+ * aplicar un cupón, selección de medios de envío, de pago, etc.
38
+ *
39
+ * Se trata de calcular lo que queremos añadir de recargo y actualizar
40
+ * el total del carrito (Magento itera sobre los totales y cada uno añade
41
+ * su parte)
42
+ **/
43
+ public function collect(Mage_Sales_Model_Quote_Address $address)
44
+ {
45
+
46
+ parent::collect($address); //Comentado por verificar
47
+
48
+ // Si no hay items, no hay nada que hacer
49
+ $items = $this->_getAddressItems($address);
50
+ if (!count($items)) {
51
+ return $this;
52
+ }
53
+
54
+ $quote = $address->getQuote();
55
+ if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
56
+ return $this;
57
+ }
58
+
59
+
60
+ //$address->setSubTotal(100);
61
+ //$address->setBaseSubTotal(100);
62
+
63
+ $address->setRowtotalResult(100);
64
+
65
+ //$address->setTaxAmount(0);
66
+
67
+ //$address->save(); //Guardamos los Cambios
68
+ Mage::log("quote->address->collect->getSubTotal->" . $address->getSubTotal(), null, 'SubTotalSales.log', true);
69
+ Mage::log("quote->address->collect->getGrandTotal->" . $address->getGrandTotal(), null, 'SubTotalSales.log',
70
+ true);
71
+
72
+ Mage::log("quote->address->collect->Total->" . $totalskybox, null, 'SubTotalSales.log', true);
73
+ Mage::log("quote->address->collect : fin", null, 'SubTotalSales.log', true);
74
+
75
+ return $this;
76
+ }
77
+
78
+ /**
79
+ * Esta función es llamada por Magento cuando quiere mostrar los totales en pantalla.
80
+ *
81
+ * El cálculo ya se habrá hecho y deberíamos guardarlo en algún sitio para aquí,
82
+ * simplemente retornar el valor formateado y que Magento lo muestre.
83
+ */
84
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
85
+ {
86
+ parent::fetch($address); //Comentado por verificar
87
+
88
+ if (!$this->isEnable()) {
89
+ return $this;
90
+ }
91
+
92
+ $quote = $address->getQuote();
93
+ if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
94
+ return $this;
95
+ }
96
+
97
+ $_conceptsSkybox = $address->getConceptsSkybox();
98
+
99
+ if ($_conceptsSkybox) {
100
+
101
+ $ConceptsSkyboxjson = json_decode($address->getConceptsSkybox());
102
+
103
+ $address->addTotal(array(
104
+ 'code' => 'subtotal',
105
+ 'title' => 'Sub Total',
106
+ 'value' => 150
107
+ ));
108
+ Mage::log("quote->address->fetch : fin", null, 'SubTotalSales.log', true);
109
+ }
110
+
111
+ return $this;
112
+ }
113
+
114
+ private function isEnable()
115
+ {
116
+ /** @var Skybox_Core_Model_Api_Restful $api_restful */
117
+ $api_restful = Mage::getModel('skyboxcore/api_restful');
118
+ $activation = $api_restful->isModuleEnable();
119
+
120
+ if (!$activation) {
121
+ return false;
122
+ }
123
+
124
+ /** @var Skybox_Core_Helper_Allow $allowHelper */
125
+ $allowHelper = Mage::helper('skyboxcore/allow');
126
+
127
+ $locationAllow = $allowHelper->getLocationAllow();
128
+
129
+ if (!$locationAllow) {
130
+ return false;
131
+ }
132
+
133
+ return true;
134
+ }
135
+ }
136
+
app/code/community/Skybox/Checkout/Model/Quote/Total.php CHANGED
@@ -1,304 +1,304 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Checkout
5
- *
6
- * @category Skybox
7
- * @package Skybox_Checkout
8
- * @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Checkout_Model_Quote_Total extends Mage_Sales_Model_Quote_Address_Total_Abstract
11
- {
12
-
13
- // Cantidad del recargo sin impuestos
14
- // var $_amount;
15
-
16
- protected $_api = null;
17
- protected $_product = null;
18
-
19
- /* @return Skybox_Checkout_Model_Api_Checkout */
20
- protected function _getApi()
21
- {
22
- if (null === $this->_api) {
23
- $this->_api = Mage::getModel('skyboxcheckout/api_checkout');
24
- }
25
- return $this->_api;
26
- }
27
-
28
- /**
29
- * Return Skybox API Product
30
- *
31
- * @return Skybox_Catalogo_Model_Api_Product
32
- */
33
- protected function _getProductApi()
34
- {
35
- if (null === $this->_product) {
36
- $this->_product = Mage::getModel('skyboxcatalog/api_product');
37
- }
38
- return $this->_product;
39
- }
40
-
41
- /**
42
- * Esta función es llamada cada vez que Magento requiere calcular los
43
- * totales por cualquier motivo: carrito actualizado, usuario se logea,
44
- * aplicar un cupón, selección de medios de envío, de pago, etc.
45
- *
46
- * Se trata de calcular lo que queremos añadir de recargo y actualizar
47
- * el total del carrito (Magento itera sobre los totales y cada uno añade
48
- * su parte)
49
- **/
50
- public function collect(Mage_Sales_Model_Quote_Address $address)
51
- {
52
- $activation = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
53
- if (!$activation) {
54
- return $this;
55
- }
56
- $isIntegration3 = false;
57
- $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
58
- if ($typeIntegration == 3) {
59
- $isIntegration3 = true;
60
- }
61
-
62
- $locationAllow = $this->_getApi()->getLocationAllow();
63
-
64
- if (!$isIntegration3 && $locationAllow) {
65
- if ($this->_getApi()->getLocationAllow()) {
66
-
67
-
68
- parent::collect($address); //Comentado por verificar
69
-
70
- // Si no hay items, no hay nada que hacer
71
- $items = $this->_getAddressItems($address);
72
- if (!count($items)) {
73
- return $this;
74
- }
75
-
76
- $quote = $address->getQuote();
77
-
78
- // $quote = Mage::helper('checkout/cart')->getCart()->getQuote();
79
- $shippingMethod = $quote->getShippingAddress()->getShippingMethod();
80
- if ($shippingMethod) {
81
- Mage::log('set shipping method null', null, 'tracer.log', true);
82
- $quote->getShippingAddress()->setShippingMethod(null); //setting method to null
83
- $quote->save();
84
- }
85
-
86
- if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
87
- return $this;
88
- }
89
-
90
- //$quote->setCustomerTaxClassId(0);
91
-
92
- //Limpiamos los Valores de Impuestos
93
- /*$rates = array();
94
- $address->setAppliedTaxes($rates);*/
95
-
96
- /*--------Nuevos conceptos---------*/
97
- $totals = $this->_getApi()->GetTotalShoppingCart();
98
-
99
- if ($this->_getApi()->HasError()) {
100
- Mage::log("StatusCode: Error", null, 'TotalSales.log', true);
101
- return $this;
102
- }
103
-
104
- Mage::log("quote->address->collect : ini", null, 'TotalSales.log', true);
105
-
106
- //$StatusCode = $totals->getParameter('StatusCode');
107
- //$StatusCode = $totals->getParameter('StatusCode');//Comentado por estar repetido
108
-
109
- $Customs = $totals->getParameter('Customs');
110
- $CustomsUSD = $totals->getParameter('CustomsUSD');
111
-
112
- $Shipping = $totals->getParameter('Shipping');
113
- $ShippingUSD = $totals->getParameter('ShippingUSD');
114
-
115
- $Insurance = $totals->getParameter('Insurance');
116
- $InsuranceUSD = $totals->getParameter('InsuranceUSD');
117
-
118
- $Taxes = $totals->getParameter('Taxes');
119
- $TaxesUSD = $totals->getParameter('TaxesUSD');
120
-
121
- $Duties = $totals->getParameter('Duties');
122
- $DutiesUSD = $totals->getParameter('DutiesUSD');
123
-
124
- $Handling = $totals->getParameter('Handling');
125
- $HandlingUSD = $totals->getParameter('HandlingUSD');
126
-
127
- $Clearence = $totals->getParameter('Clearence');
128
- $ClearenceUSD = $totals->getParameter('ClearenceUSD');
129
-
130
- $Others = $totals->getParameter('Others');
131
- $OthersUSD = $totals->getParameter('OthersUSD');
132
-
133
- $Adjustment = $totals->getParameter('Adjustment');
134
- $AdjustmentUSD = $totals->getParameter('AdjustmentUSD');
135
-
136
- $listAdjustjson = $totals->getResponse()->{'ListDetailConcepts'};
137
-
138
- $listRmtjson = $totals->getResponse()->{'ListDetailAdjusts'};
139
-
140
- /*--------------------------------*/
141
- // Apuntamos lo que hemos calculado para usarlo luego
142
- // Idealmente esto debería ir a parar a la base de datos a un campo
143
- // creado a los efectos
144
- $address->setCustomsTotalSkybox($Customs);
145
- $address->setCustomsTotalUsdSkybox($CustomsUSD);
146
-
147
- $address->setShippingTotalSkybox($Shipping);
148
- $address->setShippingTotalUsdSkybox($ShippingUSD);
149
-
150
- $address->setInsuranceTotalSkybox($Insurance);
151
- $address->setInsuranceTotalUsdSkybox($InsuranceUSD);
152
-
153
- $address->setTaxesTotalSkybox($Taxes);
154
- $address->setTaxesTotalUsdSkybox($TaxesUSD);
155
-
156
- $address->setDutiesTotalSkybox($Duties);
157
- $address->setDutiesTotalUsdSkybox($DutiesUSD);
158
-
159
- $address->setHandlingTotalSkybox($Handling);
160
- $address->setHandlingTotalUsdSkybox($HandlingUSD);
161
-
162
- $address->setClearenceTotalSkybox($Clearence);
163
- $address->setClearenceTotalUsdSkybox($ClearenceUSD);
164
-
165
- $address->setOthersTotalSkybox($Others);
166
- $address->setOthersTotalUsdSkybox($OthersUSD);
167
-
168
- $address->setAdjustTotalSkybox($Adjustment);
169
- $address->setAdjustTotalUsdSkybox($AdjustmentUSD);
170
-
171
- $address->setConceptsSkybox(json_encode($listAdjustjson));
172
-
173
- $address->setRmtSkybox(json_encode($listRmtjson));
174
-
175
- $totalskybox = 0;
176
- //$totalskybox=$Taxes+$Handling+$Shipping+$Insurance+$Clearence+$Duties+$Others-$Adjustment;
177
- $subtotalskybox = $totals->getResponse()->{'StoreProductPrice'};
178
- $totalskybox = $totals->getResponse()->{'TotalProduct'};
179
- //$totalskyboxbase=$TaxesUSD+$HandlingUSD+$ShippingUSD+$InsuranceUSD+$ClearenceUSD+$DutiesUSD+$OthersUSD-$AdjustmentUSD;
180
- $subtotalskyboxbase = $totals->getResponse()->{'StoreProductPriceUSD'};
181
- $totalskyboxbase = $totals->getResponse()->{'TotalProductUSD'};
182
- /*$address->setBasePaypalfeeAmount($this->_amount);*/
183
-
184
- // Actualizamos el total de la quote
185
- //$address->setGrandTotal($address->getGrandTotal() +$totalskybox);
186
- //$address->setBaseGrandTotal($address->getBaseGrandTotal() + $totalskyboxbase);
187
-
188
- $address->setSubTotal(100);
189
- $address->setBaseSubTotal(100);
190
- $address->setGrandTotal($totalskybox);/*this is total variable on cart checkout*/
191
- $address->setBaseGrandTotal($totalskyboxbase);
192
-
193
- //$address->setGrandTotalSkybox($address->getGrandTotal() + $totalskybox);
194
- //$address->setBaseGrandTotalSkybox($address->getBaseGrandTotal() + $totalskyboxbase);
195
-
196
- $address->setSubtotalSkybox($subtotalskybox);
197
- $address->setBaseSubtotalSkybox($totalskyboxbase);
198
- $address->setGrandTotalSkybox($totalskybox);
199
- $address->setBaseGrandTotalSkybox($totalskyboxbase);
200
-
201
- //$address->setTaxAmount(0);
202
-
203
- //$address->save(); //Guardamos los Cambios
204
- Mage::log("quote->address->collect->getSubTotal->" . $address->getSubTotal(), null, 'TotalSales.log',
205
- true);
206
- Mage::log("quote->address->collect->getGrandTotal->" . $address->getGrandTotal(), null,
207
- 'TotalSales.log', true);
208
-
209
- Mage::log("quote->address->collect->Total->" . $totalskybox, null, 'TotalSales.log', true);
210
- Mage::log("quote->address->collect : fin", null, 'TotalSales.log', true);
211
-
212
- return $this;
213
- } else {
214
- parent::collect($address);
215
- }
216
- }
217
- return $this;
218
-
219
- }
220
-
221
- /**
222
- * Esta función es llamada por Magento cuando quiere mostrar los totales en pantalla.
223
- *
224
- * El cálculo ya se habrá hecho y deberíamos guardarlo en algún sitio para aquí,
225
- * simplemente retornar el valor formateado y que Magento lo muestre.
226
- */
227
- public function fetch(Mage_Sales_Model_Quote_Address $address)
228
- {
229
- $activation = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
230
- if (!$activation) {
231
- return $this;
232
- }
233
- /**
234
- * Integration 3 start, show price shop in cart*
235
- */
236
- $allowRunByIntegration3 = true;
237
- //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
238
- $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
239
- if ($typeIntegration == 3) {
240
- $allowRunByIntegration3 = false;
241
- }
242
- /**
243
- * Integration 3 end, show price shop in cart*
244
- */
245
- if ($allowRunByIntegration3) {
246
-
247
- if ($this->_getApi()->getLocationAllow()) {
248
- parent::fetch($address); // check
249
-
250
- $quote = $address->getQuote();
251
- if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
252
- return $this;
253
- }
254
-
255
- $ConceptsSkyboxjson = json_decode($address->getConceptsSkybox());
256
-
257
- Mage::log("quote->address->fetch : ini", null, 'TotalSales.log', true);
258
- Mage::log("quote->address->fetch->getSubTotal->" . $address->getSubTotal(), null, 'TotalSales.log',
259
- true);
260
- Mage::log("quote->address->fetch->getGrandTotal->" . $address->getGrandTotal(), null, 'TotalSales.log',
261
- true);
262
-
263
- /*
264
- * Reescribimos el monto del SubTotal a Mostrar
265
- */
266
-
267
- // @todo: Make this code better!
268
- $skyboxSubtotal = $address->getSubtotalSkybox();
269
- $skyboxSubtotal = str_replace(',', '', $skyboxSubtotal);
270
-
271
- $address->addTotal(array(
272
- 'code' => 'subtotal',
273
- 'title' => Mage::helper('sales')->__('Subtotal'),
274
- 'value' => $skyboxSubtotal
275
- ));
276
-
277
- /*
278
- * Reescribimos el monto de los conceptos a Mostrar
279
- */
280
- $i = 0;
281
- foreach ($ConceptsSkyboxjson as $item) {
282
- if ($item->Visible != 0) {
283
- $i += 1;
284
- $address->addTotal(array(
285
- 'code' => 'checkout_total' . $i,
286
- 'title' => $item->Concept,
287
- 'value' => $item->Value
288
- ));
289
- Mage::log("quote->address->fetch(Concepts)->" . $item->Concept . "=" . $item->Value, null,
290
- 'TotalSales.log', true);
291
- }
292
- }
293
- Mage::log("quote->address->fetch : fin", null, 'TotalSales.log', true);
294
- // Retornamos el total con su título
295
- return $this;
296
- } else {
297
- parent::fetch($address);
298
- return $this;
299
- }
300
- }
301
-
302
- }
303
- }
304
-
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Checkout
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Checkout
8
+ * @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Checkout_Model_Quote_Total extends Mage_Sales_Model_Quote_Address_Total_Abstract
11
+ {
12
+
13
+ // Cantidad del recargo sin impuestos
14
+ // var $_amount;
15
+
16
+ protected $_api = null;
17
+ protected $_product = null;
18
+
19
+ /* @return Skybox_Checkout_Model_Api_Checkout */
20
+ protected function _getApi()
21
+ {
22
+ if (null === $this->_api) {
23
+ $this->_api = Mage::getModel('skyboxcheckout/api_checkout');
24
+ }
25
+ return $this->_api;
26
+ }
27
+
28
+ /**
29
+ * Return Skybox API Product
30
+ *
31
+ * @return Skybox_Catalogo_Model_Api_Product
32
+ */
33
+ protected function _getProductApi()
34
+ {
35
+ if (null === $this->_product) {
36
+ $this->_product = Mage::getModel('skyboxcatalog/api_product');
37
+ }
38
+ return $this->_product;
39
+ }
40
+
41
+ /**
42
+ * Esta función es llamada cada vez que Magento requiere calcular los
43
+ * totales por cualquier motivo: carrito actualizado, usuario se logea,
44
+ * aplicar un cupón, selección de medios de envío, de pago, etc.
45
+ *
46
+ * Se trata de calcular lo que queremos añadir de recargo y actualizar
47
+ * el total del carrito (Magento itera sobre los totales y cada uno añade
48
+ * su parte)
49
+ **/
50
+ public function collect(Mage_Sales_Model_Quote_Address $address)
51
+ {
52
+ $activation = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
53
+ if (!$activation) {
54
+ return $this;
55
+ }
56
+ $isIntegration3 = false;
57
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
58
+ if ($typeIntegration == 3) {
59
+ $isIntegration3 = true;
60
+ }
61
+
62
+ $locationAllow = $this->_getApi()->getLocationAllow();
63
+
64
+ if (!$isIntegration3 && $locationAllow) {
65
+ if ($this->_getApi()->getLocationAllow()) {
66
+
67
+
68
+ parent::collect($address); //Comentado por verificar
69
+
70
+ // Si no hay items, no hay nada que hacer
71
+ $items = $this->_getAddressItems($address);
72
+ if (!count($items)) {
73
+ return $this;
74
+ }
75
+
76
+ $quote = $address->getQuote();
77
+
78
+ // $quote = Mage::helper('checkout/cart')->getCart()->getQuote();
79
+ $shippingMethod = $quote->getShippingAddress()->getShippingMethod();
80
+ if ($shippingMethod) {
81
+ Mage::log('set shipping method null', null, 'tracer.log', true);
82
+ $quote->getShippingAddress()->setShippingMethod(null); //setting method to null
83
+ $quote->save();
84
+ }
85
+
86
+ if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
87
+ return $this;
88
+ }
89
+
90
+ //$quote->setCustomerTaxClassId(0);
91
+
92
+ //Limpiamos los Valores de Impuestos
93
+ /*$rates = array();
94
+ $address->setAppliedTaxes($rates);*/
95
+
96
+ /*--------Nuevos conceptos---------*/
97
+ $totals = $this->_getApi()->GetTotalShoppingCart();
98
+
99
+ if ($this->_getApi()->HasError()) {
100
+ Mage::log("StatusCode: Error", null, 'TotalSales.log', true);
101
+ return $this;
102
+ }
103
+
104
+ Mage::log("quote->address->collect : ini", null, 'TotalSales.log', true);
105
+
106
+ //$StatusCode = $totals->getParameter('StatusCode');
107
+ //$StatusCode = $totals->getParameter('StatusCode');//Comentado por estar repetido
108
+
109
+ $Customs = $totals->getParameter('Customs');
110
+ $CustomsUSD = $totals->getParameter('CustomsUSD');
111
+
112
+ $Shipping = $totals->getParameter('Shipping');
113
+ $ShippingUSD = $totals->getParameter('ShippingUSD');
114
+
115
+ $Insurance = $totals->getParameter('Insurance');
116
+ $InsuranceUSD = $totals->getParameter('InsuranceUSD');
117
+
118
+ $Taxes = $totals->getParameter('Taxes');
119
+ $TaxesUSD = $totals->getParameter('TaxesUSD');
120
+
121
+ $Duties = $totals->getParameter('Duties');
122
+ $DutiesUSD = $totals->getParameter('DutiesUSD');
123
+
124
+ $Handling = $totals->getParameter('Handling');
125
+ $HandlingUSD = $totals->getParameter('HandlingUSD');
126
+
127
+ $Clearence = $totals->getParameter('Clearence');
128
+ $ClearenceUSD = $totals->getParameter('ClearenceUSD');
129
+
130
+ $Others = $totals->getParameter('Others');
131
+ $OthersUSD = $totals->getParameter('OthersUSD');
132
+
133
+ $Adjustment = $totals->getParameter('Adjustment');
134
+ $AdjustmentUSD = $totals->getParameter('AdjustmentUSD');
135
+
136
+ $listAdjustjson = $totals->getResponse()->{'ListDetailConcepts'};
137
+
138
+ $listRmtjson = $totals->getResponse()->{'ListDetailAdjusts'};
139
+
140
+ /*--------------------------------*/
141
+ // Apuntamos lo que hemos calculado para usarlo luego
142
+ // Idealmente esto debería ir a parar a la base de datos a un campo
143
+ // creado a los efectos
144
+ $address->setCustomsTotalSkybox($Customs);
145
+ $address->setCustomsTotalUsdSkybox($CustomsUSD);
146
+
147
+ $address->setShippingTotalSkybox($Shipping);
148
+ $address->setShippingTotalUsdSkybox($ShippingUSD);
149
+
150
+ $address->setInsuranceTotalSkybox($Insurance);
151
+ $address->setInsuranceTotalUsdSkybox($InsuranceUSD);
152
+
153
+ $address->setTaxesTotalSkybox($Taxes);
154
+ $address->setTaxesTotalUsdSkybox($TaxesUSD);
155
+
156
+ $address->setDutiesTotalSkybox($Duties);
157
+ $address->setDutiesTotalUsdSkybox($DutiesUSD);
158
+
159
+ $address->setHandlingTotalSkybox($Handling);
160
+ $address->setHandlingTotalUsdSkybox($HandlingUSD);
161
+
162
+ $address->setClearenceTotalSkybox($Clearence);
163
+ $address->setClearenceTotalUsdSkybox($ClearenceUSD);
164
+
165
+ $address->setOthersTotalSkybox($Others);
166
+ $address->setOthersTotalUsdSkybox($OthersUSD);
167
+
168
+ $address->setAdjustTotalSkybox($Adjustment);
169
+ $address->setAdjustTotalUsdSkybox($AdjustmentUSD);
170
+
171
+ $address->setConceptsSkybox(json_encode($listAdjustjson));
172
+
173
+ $address->setRmtSkybox(json_encode($listRmtjson));
174
+
175
+ $totalskybox = 0;
176
+ //$totalskybox=$Taxes+$Handling+$Shipping+$Insurance+$Clearence+$Duties+$Others-$Adjustment;
177
+ $subtotalskybox = $totals->getResponse()->{'StoreProductPrice'};
178
+ $totalskybox = $totals->getResponse()->{'TotalProduct'};
179
+ //$totalskyboxbase=$TaxesUSD+$HandlingUSD+$ShippingUSD+$InsuranceUSD+$ClearenceUSD+$DutiesUSD+$OthersUSD-$AdjustmentUSD;
180
+ $subtotalskyboxbase = $totals->getResponse()->{'StoreProductPriceUSD'};
181
+ $totalskyboxbase = $totals->getResponse()->{'TotalProductUSD'};
182
+ /*$address->setBasePaypalfeeAmount($this->_amount);*/
183
+
184
+ // Actualizamos el total de la quote
185
+ //$address->setGrandTotal($address->getGrandTotal() +$totalskybox);
186
+ //$address->setBaseGrandTotal($address->getBaseGrandTotal() + $totalskyboxbase);
187
+
188
+ $address->setSubTotal(100);
189
+ $address->setBaseSubTotal(100);
190
+ $address->setGrandTotal($totalskybox);/*this is total variable on cart checkout*/
191
+ $address->setBaseGrandTotal($totalskyboxbase);
192
+
193
+ //$address->setGrandTotalSkybox($address->getGrandTotal() + $totalskybox);
194
+ //$address->setBaseGrandTotalSkybox($address->getBaseGrandTotal() + $totalskyboxbase);
195
+
196
+ $address->setSubtotalSkybox($subtotalskybox);
197
+ $address->setBaseSubtotalSkybox($totalskyboxbase);
198
+ $address->setGrandTotalSkybox($totalskybox);
199
+ $address->setBaseGrandTotalSkybox($totalskyboxbase);
200
+
201
+ //$address->setTaxAmount(0);
202
+
203
+ //$address->save(); //Guardamos los Cambios
204
+ Mage::log("quote->address->collect->getSubTotal->" . $address->getSubTotal(), null, 'TotalSales.log',
205
+ true);
206
+ Mage::log("quote->address->collect->getGrandTotal->" . $address->getGrandTotal(), null,
207
+ 'TotalSales.log', true);
208
+
209
+ Mage::log("quote->address->collect->Total->" . $totalskybox, null, 'TotalSales.log', true);
210
+ Mage::log("quote->address->collect : fin", null, 'TotalSales.log', true);
211
+
212
+ return $this;
213
+ } else {
214
+ parent::collect($address);
215
+ }
216
+ }
217
+ return $this;
218
+
219
+ }
220
+
221
+ /**
222
+ * Esta función es llamada por Magento cuando quiere mostrar los totales en pantalla.
223
+ *
224
+ * El cálculo ya se habrá hecho y deberíamos guardarlo en algún sitio para aquí,
225
+ * simplemente retornar el valor formateado y que Magento lo muestre.
226
+ */
227
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
228
+ {
229
+ $activation = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
230
+ if (!$activation) {
231
+ return $this;
232
+ }
233
+ /**
234
+ * Integration 3 start, show price shop in cart*
235
+ */
236
+ $allowRunByIntegration3 = true;
237
+ //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
238
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
239
+ if ($typeIntegration == 3) {
240
+ $allowRunByIntegration3 = false;
241
+ }
242
+ /**
243
+ * Integration 3 end, show price shop in cart*
244
+ */
245
+ if ($allowRunByIntegration3) {
246
+
247
+ if ($this->_getApi()->getLocationAllow()) {
248
+ parent::fetch($address); // check
249
+
250
+ $quote = $address->getQuote();
251
+ if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
252
+ return $this;
253
+ }
254
+
255
+ $ConceptsSkyboxjson = json_decode($address->getConceptsSkybox());
256
+
257
+ Mage::log("quote->address->fetch : ini", null, 'TotalSales.log', true);
258
+ Mage::log("quote->address->fetch->getSubTotal->" . $address->getSubTotal(), null, 'TotalSales.log',
259
+ true);
260
+ Mage::log("quote->address->fetch->getGrandTotal->" . $address->getGrandTotal(), null, 'TotalSales.log',
261
+ true);
262
+
263
+ /*
264
+ * Reescribimos el monto del SubTotal a Mostrar
265
+ */
266
+
267
+ // @todo: Make this code better!
268
+ $skyboxSubtotal = $address->getSubtotalSkybox();
269
+ $skyboxSubtotal = str_replace(',', '', $skyboxSubtotal);
270
+
271
+ $address->addTotal(array(
272
+ 'code' => 'subtotal',
273
+ 'title' => Mage::helper('sales')->__('Subtotal'),
274
+ 'value' => $skyboxSubtotal
275
+ ));
276
+
277
+ /*
278
+ * Reescribimos el monto de los conceptos a Mostrar
279
+ */
280
+ $i = 0;
281
+ foreach ($ConceptsSkyboxjson as $item) {
282
+ if ($item->Visible != 0) {
283
+ $i += 1;
284
+ $address->addTotal(array(
285
+ 'code' => 'checkout_total' . $i,
286
+ 'title' => $item->Concept,
287
+ 'value' => $item->Value
288
+ ));
289
+ Mage::log("quote->address->fetch(Concepts)->" . $item->Concept . "=" . $item->Value, null,
290
+ 'TotalSales.log', true);
291
+ }
292
+ }
293
+ Mage::log("quote->address->fetch : fin", null, 'TotalSales.log', true);
294
+ // Retornamos el total con su título
295
+ return $this;
296
+ } else {
297
+ parent::fetch($address);
298
+ return $this;
299
+ }
300
+ }
301
+
302
+ }
303
+ }
304
+
app/code/community/Skybox/Checkout/Model/Quote/Total10.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Skybox_Checkout_Model_Quote_Total10 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
+
5
+
6
+ }
7
+
app/code/community/Skybox/Checkout/Model/Quote/Total11.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Skybox_Checkout_Model_Quote_Total11 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
+
5
+
6
+ }
7
+
app/code/community/Skybox/Checkout/Model/Quote/Total12.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Skybox_Checkout_Model_Quote_Total12 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
+
5
+
6
+ }
7
+
app/code/community/Skybox/Checkout/Model/Quote/Total13.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Skybox_Checkout_Model_Quote_Total13 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
+
5
+
6
+ }
7
+
app/code/community/Skybox/Checkout/Model/Quote/Total14.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Skybox_Checkout_Model_Quote_Total14 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
+
5
+
6
+ }
7
+
app/code/community/Skybox/Checkout/Model/Quote/Total15.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Skybox_Checkout_Model_Quote_Total15 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
+
5
+
6
+ }
7
+
app/code/community/Skybox/Checkout/Model/Quote/Total2.php CHANGED
@@ -1,7 +1,7 @@
1
- <?php
2
-
3
- class Skybox_Checkout_Model_Quote_Total2 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
-
5
-
6
- }
7
-
1
+ <?php
2
+
3
+ class Skybox_Checkout_Model_Quote_Total2 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
+
5
+
6
+ }
7
+
app/code/community/Skybox/Checkout/Model/Quote/Total3.php CHANGED
@@ -1,6 +1,6 @@
1
- <?php
2
-
3
- class Skybox_Checkout_Model_Quote_Total3 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
-
5
- }
6
-
1
+ <?php
2
+
3
+ class Skybox_Checkout_Model_Quote_Total3 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
+
5
+ }
6
+
app/code/community/Skybox/Checkout/Model/Quote/Total4.php CHANGED
@@ -1,6 +1,6 @@
1
- <?php
2
-
3
- class Skybox_Checkout_Model_Quote_Total4 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
-
5
- }
6
-
1
+ <?php
2
+
3
+ class Skybox_Checkout_Model_Quote_Total4 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
+
5
+ }
6
+
app/code/community/Skybox/Checkout/Model/Quote/Total5.php CHANGED
@@ -1,6 +1,6 @@
1
- <?php
2
-
3
- class Skybox_Checkout_Model_Quote_Total5 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
-
5
- }
6
-
1
+ <?php
2
+
3
+ class Skybox_Checkout_Model_Quote_Total5 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
+
5
+ }
6
+
app/code/community/Skybox/Checkout/Model/Quote/Total6.php CHANGED
@@ -1,6 +1,6 @@
1
- <?php
2
-
3
- class Skybox_Checkout_Model_Quote_Total6 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
-
5
- }
6
-
1
+ <?php
2
+
3
+ class Skybox_Checkout_Model_Quote_Total6 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
+
5
+ }
6
+
app/code/community/Skybox/Checkout/Model/Quote/Total7.php CHANGED
@@ -1,6 +1,6 @@
1
- <?php
2
-
3
- class Skybox_Checkout_Model_Quote_Total7 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
-
5
- }
6
-
1
+ <?php
2
+
3
+ class Skybox_Checkout_Model_Quote_Total7 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
+
5
+ }
6
+
app/code/community/Skybox/Checkout/Model/Quote/Total8.php CHANGED
@@ -1,7 +1,7 @@
1
- <?php
2
-
3
- class Skybox_Checkout_Model_Quote_Total8 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
-
5
-
6
- }
7
-
1
+ <?php
2
+
3
+ class Skybox_Checkout_Model_Quote_Total8 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
+
5
+
6
+ }
7
+
app/code/community/Skybox/Checkout/Model/Quote/Total9.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Skybox_Checkout_Model_Quote_Total9 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
4
+
5
+
6
+ }
7
+
app/code/community/Skybox/Checkout/controllers/CalculateController.php CHANGED
@@ -1,138 +1,138 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Checkout
5
- *
6
- * @category Skybox
7
- * @package Skybox_Checkout
8
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Checkout_CalculateController extends Mage_Core_Controller_Front_Action
11
- {
12
- public function indexAction()
13
- {
14
- $isAjax = Mage::app()->getRequest()->isAjax();
15
-
16
- if ($isAjax) {
17
-
18
- $productId = ($this->getRequest()->getParam('product_id')) ?
19
- $this->getRequest()->getParam('product_id') : null;
20
-
21
- $price = ($this->getRequest()->getParam('price')) ?
22
- $this->getRequest()->getParam('price') : null;
23
-
24
- $_request = ($this->getRequest()->getParam('request')) ?
25
- $this->getRequest()->getParam('request') : null;
26
-
27
- if (!isset($productId) || !isset($price)) {
28
- //trigger_error('Invalid Product or Price.');
29
- $this->_error('Invalid Product or Price.');
30
- }
31
-
32
- if ($_request) {
33
- parse_str($_request, $request);
34
- $request = $this->_array_filter_recursive($request);
35
- $request = $this->_getProductRequest($request);
36
- //Mage::log(print_r($request, true), null, 'cart.log', true);
37
- }
38
-
39
- /** @var Skybox_Catalog_Model_Api_Product $productAPI */
40
- $productAPI = Mage::getModel('skyboxcatalog/api_product');
41
- $locationAllow = $productAPI->getLocationAllow();
42
-
43
- if($locationAllow != "1"){
44
- // Mage::log("getLocationAllow:::::[0]". $locationAllow, null, 'data.log', true);
45
- }else {
46
- // Mage::log("getLocationAllow:::::[1]". $locationAllow, null, 'data.log', true);
47
- /* $product Mage_Catalog_Model_Product */
48
- $product = Mage::getModel('catalog/product')->load($productId);
49
- $type = $product->getTypeId();
50
- $template = null;
51
- //Mage::log(print_r('calculateController: '.$type, true), null, 'tracer.log', true);
52
- switch ($type) {
53
- case 'simple':
54
- Mage::log("catch_exception_pendejerete_simple", null, 'tracerlog.log', true);
55
- $template = $productAPI->CalculatePrice($product->getId(), null, $product->getFinalPrice(),
56
- 'simple')
57
- ->GetTemplateProduct();
58
- break;
59
- case 'configurable':
60
- Mage::log("catch_exception_pendejerete_configurable", null, 'tracerlog.log', true);
61
- $template = $productAPI->CalculatePrice($product->getId(), null, $price, $product->getTypeId())
62
- ->GetTemplateProduct();
63
- break;
64
- case 'bundle':
65
- try {
66
- Mage::log("catch_exception_pendejerete_bundle", null, 'tracerlog.log', true);
67
- $template = $productAPI->CalculatePrice($product->getId(), $request, $price, 'bundle')
68
- ->GetTemplateProduct();
69
- } catch (Exception $e) {
70
- Mage::log("catch_exception_pendejerete", null, 'tracerlog.log', true);
71
- Mage::logException($e);
72
- $template = '';
73
- }
74
- break;
75
- default;
76
- $this->_error('Invalid or not supported Product Type.');
77
- break;
78
- }
79
-
80
- $extraHtml = '<div id="skybox-configurable-price-from-'
81
- . $product->getId()
82
- //. $this->getIdSuffix()
83
- . ''
84
- . '">'
85
- . $template
86
- . '</div>'
87
- . '<div style="clear:both"></div>';
88
-
89
- $this->getResponse()->setBody($extraHtml);
90
- }
91
- }
92
- }
93
-
94
- private function _error($message = null)
95
- {
96
- if ($message == null) {
97
- $message = "Unexpected error";
98
- }
99
- return $this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array('error' => $message)));
100
- }
101
-
102
- /**
103
- * Get request for product
104
- *
105
- * @param mixed $requestInfo
106
- * @return Varien_Object
107
- */
108
- private function _getProductRequest($requestInfo)
109
- {
110
- if ($requestInfo instanceof Varien_Object) {
111
- $request = $requestInfo;
112
- } elseif (is_numeric($requestInfo)) {
113
- $request = new Varien_Object(array('qty' => $requestInfo));
114
- } else {
115
- $request = new Varien_Object($requestInfo);
116
- }
117
-
118
- if (!$request->hasQty()) {
119
- $request->setQty(1);
120
- }
121
-
122
- return $request;
123
- }
124
-
125
- /*
126
- * Array Filter Recursive (utils)
127
- */
128
- private function _array_filter_recursive($input)
129
- {
130
- foreach ($input as &$value) {
131
- if (is_array($value)) {
132
- $value = $this->_array_filter_recursive($value);
133
- }
134
- }
135
-
136
- return array_filter($input);
137
- }
138
- }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Checkout
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Checkout
8
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Checkout_CalculateController extends Mage_Core_Controller_Front_Action
11
+ {
12
+ public function indexAction()
13
+ {
14
+ $isAjax = Mage::app()->getRequest()->isAjax();
15
+
16
+ if ($isAjax) {
17
+
18
+ $productId = ($this->getRequest()->getParam('product_id')) ?
19
+ $this->getRequest()->getParam('product_id') : null;
20
+
21
+ $price = ($this->getRequest()->getParam('price')) ?
22
+ $this->getRequest()->getParam('price') : null;
23
+
24
+ $_request = ($this->getRequest()->getParam('request')) ?
25
+ $this->getRequest()->getParam('request') : null;
26
+
27
+ if (!isset($productId) || !isset($price)) {
28
+ //trigger_error('Invalid Product or Price.');
29
+ $this->_error('Invalid Product or Price.');
30
+ }
31
+
32
+ if ($_request) {
33
+ parse_str($_request, $request);
34
+ $request = $this->_array_filter_recursive($request);
35
+ $request = $this->_getProductRequest($request);
36
+ //Mage::log(print_r($request, true), null, 'cart.log', true);
37
+ }
38
+
39
+ /** @var Skybox_Catalog_Model_Api_Product $productAPI */
40
+ $productAPI = Mage::getModel('skyboxcatalog/api_product');
41
+ $locationAllow = $productAPI->getLocationAllow();
42
+
43
+ if($locationAllow != "1"){
44
+ // Mage::log("getLocationAllow:::::[0]". $locationAllow, null, 'data.log', true);
45
+ }else {
46
+ // Mage::log("getLocationAllow:::::[1]". $locationAllow, null, 'data.log', true);
47
+ /* $product Mage_Catalog_Model_Product */
48
+ $product = Mage::getModel('catalog/product')->load($productId);
49
+ $type = $product->getTypeId();
50
+ $template = null;
51
+ //Mage::log(print_r('calculateController: '.$type, true), null, 'tracer.log', true);
52
+ switch ($type) {
53
+ case 'simple':
54
+ Mage::log("catch_exception_pendejerete_simple", null, 'tracerlog.log', true);
55
+ $template = $productAPI->CalculatePrice($product->getId(), null, $product->getFinalPrice(),
56
+ 'simple')
57
+ ->GetTemplateProduct();
58
+ break;
59
+ case 'configurable':
60
+ Mage::log("catch_exception_pendejerete_configurable", null, 'tracerlog.log', true);
61
+ $template = $productAPI->CalculatePrice($product->getId(), null, $price, $product->getTypeId())
62
+ ->GetTemplateProduct();
63
+ break;
64
+ case 'bundle':
65
+ try {
66
+ Mage::log("catch_exception_pendejerete_bundle", null, 'tracerlog.log', true);
67
+ $template = $productAPI->CalculatePrice($product->getId(), $request, $price, 'bundle')
68
+ ->GetTemplateProduct();
69
+ } catch (Exception $e) {
70
+ Mage::log("catch_exception_pendejerete", null, 'tracerlog.log', true);
71
+ Mage::logException($e);
72
+ $template = '';
73
+ }
74
+ break;
75
+ default;
76
+ $this->_error('Invalid or not supported Product Type.');
77
+ break;
78
+ }
79
+
80
+ $extraHtml = '<div id="skybox-configurable-price-from-'
81
+ . $product->getId()
82
+ //. $this->getIdSuffix()
83
+ . ''
84
+ . '">'
85
+ . $template
86
+ . '</div>'
87
+ . '<div style="clear:both"></div>';
88
+
89
+ $this->getResponse()->setBody($extraHtml);
90
+ }
91
+ }
92
+ }
93
+
94
+ private function _error($message = null)
95
+ {
96
+ if ($message == null) {
97
+ $message = "Unexpected error";
98
+ }
99
+ return $this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array('error' => $message)));
100
+ }
101
+
102
+ /**
103
+ * Get request for product
104
+ *
105
+ * @param mixed $requestInfo
106
+ * @return Varien_Object
107
+ */
108
+ private function _getProductRequest($requestInfo)
109
+ {
110
+ if ($requestInfo instanceof Varien_Object) {
111
+ $request = $requestInfo;
112
+ } elseif (is_numeric($requestInfo)) {
113
+ $request = new Varien_Object(array('qty' => $requestInfo));
114
+ } else {
115
+ $request = new Varien_Object($requestInfo);
116
+ }
117
+
118
+ if (!$request->hasQty()) {
119
+ $request->setQty(1);
120
+ }
121
+
122
+ return $request;
123
+ }
124
+
125
+ /*
126
+ * Array Filter Recursive (utils)
127
+ */
128
+ private function _array_filter_recursive($input)
129
+ {
130
+ foreach ($input as &$value) {
131
+ if (is_array($value)) {
132
+ $value = $this->_array_filter_recursive($value);
133
+ }
134
+ }
135
+
136
+ return array_filter($input);
137
+ }
138
+ }
app/code/community/Skybox/Checkout/controllers/InternationalController.php CHANGED
@@ -1,89 +1,89 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Checkout
5
- *
6
- * @category Skybox
7
- * @package Skybox_Checkout
8
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Checkout_InternationalController extends Mage_Core_Controller_Front_Action
11
- {
12
- public function indexAction()
13
- {
14
- /** @var $checkout_cart Mage_Checkout_Model_Session */
15
- $checkout_cart = Mage::getSingleton('checkout/cart');
16
- $items = $checkout_cart->getItems();
17
-
18
- if (!$items) {
19
- $this->getResponse()->setRedirect(
20
- Mage::getUrl('checkout/cart')
21
- );
22
- }
23
-
24
- $cart_count = Mage::helper('checkout/cart')->getSummaryCount();
25
-
26
- /** @var $config Skybox_Checkout_Model_Config */
27
- $config = Mage::getModel('skyboxcore/config');
28
- $cart = $config->getSession()->getCartSkybox();
29
-
30
- $cartItemCount = 0;
31
- if (!empty($cart)) {
32
- $cartItemCount = intval($cart->{'CartItemCount'});
33
- }
34
-
35
- /** @var $api_mproduct Skybox_Catalog_Model_Api_Product */
36
- $api_mproduct = Mage::getModel('skyboxcatalog/api_product');
37
-
38
- if ($cart_count != $cartItemCount && $api_mproduct->getLocationAllow()) {
39
-
40
- $processUrl = Mage::getUrl() . 'skbcheckout/process';
41
- $returnUrl = Mage::getUrl() . 'skbcheckout/international';
42
-
43
- $url = $processUrl . '?return_url=' . $returnUrl;
44
- $this->getResponse()->setRedirect($url);
45
- }
46
-
47
- $this->loadLayout();
48
- $this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
49
- //$this->getLayout()->getBlock('root')->setTemplate('skybox/checkout/pagecheckout.phtml');
50
- $this->renderLayout();
51
- }
52
-
53
- public function successAction()
54
- {
55
- // Mage::log("Call true: successAction limpiar carro", null, 'local.log', true);
56
- // Mage::getSingleton('checkout/cart')->truncate()->save();
57
- Mage::getSingleton('checkout/cart')->truncateMgCart()->save();
58
-
59
- $_config = Mage::getModel('skyboxcore/config');
60
- $cart = $_config->getSession()->getCartSkybox();
61
- $id = $cart->{'LanguageId'};
62
-
63
- $message_success = $this->languages($id);
64
-
65
- Mage::getSingleton('core/session')->setSkyboxSuccessMsg($message_success);
66
-
67
- $this->loadLayout();
68
- $this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
69
- $this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
70
- $this->renderLayout();
71
- }
72
-
73
- private function languages($id)
74
- {
75
- $languages = array(
76
- 0 => "Thanks for your purchase, We have received your order and we will contact you. We will send you a confirmation email.",
77
- 1 => "Thanks for your purchase, We have received your order and we will contact you. We will send you a confirmation email.",
78
- // 2 => "&#33;Gracias por su compra! Hemos recibido su orden y nos pondremos en contacto contigo. Le enviaremos un correo electrónico de confirmaci&oacute;n",
79
- 2 => "Gracias por su compra! Le enviaremos un correo electrónico de confirmaci&oacute;n.",
80
- 3 => "'Obrigado por sua compra, Recebemos seu pedido e entraremos em contato com você. Nós lhe enviaremos um e-mail de confirma&ccedil;&atilde;o.",
81
- );
82
- if (isset($languages[$id])) {
83
- return $languages[$id];
84
- } else {
85
- return $languages[0];
86
- }
87
- }
88
-
89
- }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Checkout
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Checkout
8
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Checkout_InternationalController extends Mage_Core_Controller_Front_Action
11
+ {
12
+ public function indexAction()
13
+ {
14
+ /** @var $checkout_cart Mage_Checkout_Model_Session */
15
+ $checkout_cart = Mage::getSingleton('checkout/cart');
16
+ $items = $checkout_cart->getItems();
17
+
18
+ if (!$items) {
19
+ $this->getResponse()->setRedirect(
20
+ Mage::getUrl('checkout/cart')
21
+ );
22
+ }
23
+
24
+ $cart_count = Mage::helper('checkout/cart')->getSummaryCount();
25
+
26
+ /** @var $config Skybox_Checkout_Model_Config */
27
+ $config = Mage::getModel('skyboxcore/config');
28
+ $cart = $config->getSession()->getCartSkybox();
29
+
30
+ $cartItemCount = 0;
31
+ if (!empty($cart)) {
32
+ $cartItemCount = intval($cart->{'CartItemCount'});
33
+ }
34
+
35
+ /** @var $api_mproduct Skybox_Catalog_Model_Api_Product */
36
+ $api_mproduct = Mage::getModel('skyboxcatalog/api_product');
37
+
38
+ if ($cart_count != $cartItemCount && $api_mproduct->getLocationAllow()) {
39
+
40
+ $processUrl = Mage::getUrl() . 'skbcheckout/process';
41
+ $returnUrl = Mage::getUrl() . 'skbcheckout/international';
42
+
43
+ $url = $processUrl . '?return_url=' . $returnUrl;
44
+ $this->getResponse()->setRedirect($url);
45
+ }
46
+
47
+ $this->loadLayout();
48
+ $this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
49
+ //$this->getLayout()->getBlock('root')->setTemplate('skybox/checkout/pagecheckout.phtml');
50
+ $this->renderLayout();
51
+ }
52
+
53
+ public function successAction()
54
+ {
55
+ // Mage::log("Call true: successAction limpiar carro", null, 'local.log', true);
56
+ // Mage::getSingleton('checkout/cart')->truncate()->save();
57
+ Mage::getSingleton('checkout/cart')->truncateMgCart()->save();
58
+
59
+ $_config = Mage::getModel('skyboxcore/config');
60
+ $cart = $_config->getSession()->getCartSkybox();
61
+ $id = $cart->{'LanguageId'};
62
+
63
+ $message_success = $this->languages($id);
64
+
65
+ Mage::getSingleton('core/session')->setSkyboxSuccessMsg($message_success);
66
+
67
+ $this->loadLayout();
68
+ $this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
69
+ $this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
70
+ $this->renderLayout();
71
+ }
72
+
73
+ private function languages($id)
74
+ {
75
+ $languages = array(
76
+ 0 => "Thanks for your purchase, We have received your order and we will contact you. We will send you a confirmation email.",
77
+ 1 => "Thanks for your purchase, We have received your order and we will contact you. We will send you a confirmation email.",
78
+ // 2 => "&#33;Gracias por su compra! Hemos recibido su orden y nos pondremos en contacto contigo. Le enviaremos un correo electrónico de confirmaci&oacute;n",
79
+ 2 => "Gracias por su compra! Le enviaremos un correo electrónico de confirmaci&oacute;n.",
80
+ 3 => "'Obrigado por sua compra, Recebemos seu pedido e entraremos em contato com você. Nós lhe enviaremos um e-mail de confirma&ccedil;&atilde;o.",
81
+ );
82
+ if (isset($languages[$id])) {
83
+ return $languages[$id];
84
+ } else {
85
+ return $languages[0];
86
+ }
87
+ }
88
+
89
+ }
app/code/community/Skybox/Checkout/controllers/ProcessController.php CHANGED
@@ -1,364 +1,354 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Checkout
5
- *
6
- * @category Skybox
7
- * @package Skybox_Checkout
8
- * @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Checkout_ProcessController extends Mage_Core_Controller_Front_Action
11
- {
12
- public function indexAction()
13
- {
14
- // Mage::log(":::-----------------------------------:::", null, 'pendejerete.log', true);
15
- /**
16
- * only one time for call to service start - Active
17
- * This always run when you do change country
18
- */
19
- $session = Mage::getSingleton("core/session", array("name" => "frontend"));
20
- $session->setData("callToSkyBox", true);
21
- //Mage::log("Call true: Skybox_Checkout_ProcessController", null, 'local.log', true);
22
- /**
23
- * only one time for call to service end - Active
24
- */
25
- /**
26
- * Integration 3 start, show price shop in cart*
27
- */
28
- $isLocationAllow = false;
29
- //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
30
- $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
31
- if ($typeIntegration == 3) {
32
- $isLocationAllow = true;
33
- }
34
- /**
35
- * Integration 3 end, show price shop in cart*
36
- */
37
- //Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter index', null, 'tracer.log', true);
38
- $_checkout = Mage::getModel('skyboxcheckout/api_checkout');
39
- $_checkout->InitializeBarSkybox();
40
-
41
- $return_url = ($this->getRequest()->getParam('return_url')) ?
42
- $this->getRequest()->getParam('return_url') :
43
- Mage::helper('core/url')->getHomeUrl();
44
-
45
- // Mage::log("returnUrl:::". $return_url, null, 'pendejerete.log', true);
46
-
47
- $quote = Mage::getSingleton('checkout/session')->getQuote();
48
- $product_api = Mage::getSingleton('skyboxcatalog/api_product');
49
-
50
- // Mage::log("product_api:::".print_r($product_api,1), null, 'pendejerete.log', true);
51
- // Mage::log("product_api-GetLocationAllow:::".$product_api->getLocationAllow(), null, 'pendejerete.log', true);
52
-
53
- /*---------------- Rogged ------------------*/
54
- $_config = Mage::getModel('skyboxcore/config');
55
- $cart = $_config->getSession()->getCartSkybox();
56
- $CartItemCount = 0;
57
- if (!empty($cart)) {
58
- $CartItemCount = intval($cart->{'CartItemCount'});
59
- }
60
- # check if local skybox shopping cart and skybox-checkout match
61
- $differentqty = 0;
62
- // $api_mproduct = Mage::getModel('skyboxcatalog/api_product');
63
-
64
- // Mage::log('entro getAllItems $CartItemCount',null,'tracer.log',true);
65
- // Mage::log((int)$quote->getItemsQty() .'-'.$CartItemCount,null,'tracer.log',true);
66
- if (!$isLocationAllow) {
67
- // Mage::log('entro !$isLocationAllow::: ',null,'tracer.log',true);
68
- if ((int)$quote->getItemsQty() != $CartItemCount && $product_api->getLocationAllow()) {
69
- $differentqty = 1;
70
- }
71
- }
72
-
73
- // Mage::log("product_api-QuoteAllItems:::".print_r($quote->getAllItems(),1), null, 'pendejerete.log', true);
74
-
75
- /*-----------------------------------------*/
76
- foreach ($quote->getAllItems() as $key => $item) {
77
- $parentItem = $item->getParentItem();
78
- // Mage::log("parentItem:::", null, 'verify.log', true);
79
- $parentItemId = $item->getParentItemId();
80
- /*---------------- Rogged ------------------*/
81
- if ($differentqty == 1) {
82
- // Mage::log("differentqty::: 1 ", null, 'verify.log', true);
83
- $cart = Mage::getModel('skyboxcheckout/cart');
84
-
85
- if ($item->getProductType() === 'simple' && !$parentItem) {
86
- // Mage::log("getProductType ::: simple ::: !parentItem", null, 'verify.log', true);
87
- $productModel = Mage::getModel('catalog/product')->load($item->getProductId());
88
- $paramsRequest = array();
89
- $paramsRequest['product'] = $item->getProductId();
90
- $paramsRequest['qty'] = $item->getQty();
91
- // Mage::log("removeItem::: ", null, 'verify.log', true);
92
- $cart->removeItem($item->getItemId());
93
- // Mage::log("removeItem::: finish ", null, 'verify.log', true);
94
- // Mage::log("addProduct::: ", null, 'verify.log', true);
95
- $cart->addProduct($productModel, $paramsRequest);
96
- // Mage::log("addProduct::: finish ", null, 'verify.log', true);
97
- }
98
- /* end */
99
-
100
- if ($item->getProductType() === 'simple' && $parentItem) {
101
- // Mage::log("getProductType ::: simple ::: parentItem", null, 'verify.log', true);
102
- $paramsRequest = array();
103
- $productParentId = Mage::getModel('catalog/product_type_configurable')
104
- ->getParentIdsByChild($item->getProductId());
105
- $productParentId = $productParentId[0];
106
-
107
- // Mage::log("productParentId:::". print_r($productParentId), null, 'pendejerete.log', true);
108
- // Mage::log("productParentId[0]:::". $productParentId, null, 'pendejerete.log', true);
109
-
110
- $productModel = Mage::getModel('catalog/product')->load($productParentId);
111
- $_typeInstance = $productModel->getTypeInstance(true);
112
- $_children = $_typeInstance->getUsedProducts(null, $productModel);
113
- $_attributes = $_typeInstance->getUsedProductAttributes($productModel);
114
-
115
- foreach ($_children as $_child) {
116
- if ($_child->entity_id == $item->getProductId()) {
117
- $_superAttributes = array();
118
- foreach ($_attributes as $_attribute) {
119
- $_superAttributes[$_attribute->getAttributeId()] = $_child->getData($_attribute->getAttributeCode());
120
- }
121
- }
122
- }
123
-
124
- $paramsRequest['product'] = $item->getProductId();
125
- $paramsRequest['qty'] = $item->getQty();
126
- $paramsRequest['super_attribute'] = $_superAttributes;
127
- $cart->removeItem($parentItemId);
128
- $cart->addProduct($productModel, $paramsRequest);
129
- }
130
- // if ($item->getProductType() === 'simple' && !$parentItem && $item->getPriceSkybox()) {
131
- // $productModel = Mage::getModel('catalog/product')->load($item->getProductId());
132
- // $paramsRequest=array();
133
- // $paramsRequest['product']=$item->getProductId();
134
- // $paramsRequest['qty']=$item->getQty();
135
- // $cart->removeItem($item->getItemId());
136
- // $cart->addProduct($productModel,$paramsRequest);
137
- // }
138
- }
139
- /*----------------------------------------*/
140
-
141
-
142
- // Mage::log("process", null, 'process.log', true);
143
- //Mage::log("ITEM Class: " . get_class($item), null, 'cart.log', true);
144
- //Mage::log("ITEM Id: " . $item->getProductId(), null, 'cart.log', true);
145
-
146
-
147
- /*if ($item->getProductType() === 'configurable') continue;
148
- if ($item->getProductType() === 'simple' && $parentItem && !$item->getPriceSkybox()) continue;
149
-
150
- // Simple Product
151
- if ($item->getProductType() === 'simple' && !$parentItem && $item->getPriceSkybox()) {
152
- $product_api->CalculatePrice($item->getProductId(), null, null);
153
- }
154
-
155
- // Configurable Product
156
- if ($item->getProductType() === 'simple' && $parentItem) {
157
- $item = $parentItem;
158
- $product_api->CalculatePrice($item->getProductId(), null, $item->getPriceUsdSkybox());
159
- }
160
-
161
- // Bundle Product
162
- if ($item->getProductType() === 'bundle') {
163
- $product_api->CalculatePrice($item->getProductId(), null, $item->getPriceUsdSkybox());
164
- };
165
-
166
- $total = str_replace(",", "", $product_api->getTotalPriceUSD());*/
167
-
168
- /* -- Rogged --*/
169
- /* Cuando se cambia de country no allow a otro country allow, no hay precio en skybox registrado, por eso tomamos el precio de tienda */
170
- /** @var Mage_Catalog_Model_Resource_Product $productModel */
171
- // $productModel = Mage::getModel('catalog/product')->load($item->getProductId());
172
-
173
- /** @var Mage_Catalog_Model_Product $productModel */
174
- $productModel = Mage::getModel('catalog/product')->load($item->getProductId());
175
-
176
- if (!$isLocationAllow) {
177
- if ($product_api->getLocationAllow() && !$item->getPriceSkybox()) {
178
- $item->setPriceSkybox($productModel->getPrice());
179
- }
180
- }
181
-
182
- /* -- ----- --*/
183
-
184
- #echo $item->getPrice()." - ".$item->getPriceSkybox()."<br>";
185
-
186
-
187
- // Mage::log(print_r($productModel->getFinalPrice(), true), null, 'processcontroller.log', true);
188
-
189
- if ($item->getProductType() === 'configurable') {
190
- // Mage::log("getProductType == configurable", null, 'verify.log', true);
191
- // $product_api->CalculatePrice($item->getProductId(), null, $productModel->getPriceUsdSkybox(),
192
- // $item->getProductType(), null);
193
- // Mage::log("configurable", null, 'processcontroller.log', true);
194
- }
195
- if ($item->getProductType() === 'simple' && $parentItem && !$item->getPriceSkybox()) {
196
- // Mage::log("getProductType == simple ::: parentItem ::: !getPriceSkybox", null, 'verify.log', true);
197
- $product_api->CalculatePrice($item->getProductId(), null, $productModel->getPriceUsdSkybox(),
198
- $item->getProductType(), null);
199
- // Mage::log("simple1", null, 'processcontroller.log', true);
200
- }
201
-
202
- // Simple Product
203
- if ($item->getProductType() === 'simple' && !$parentItem && $item->getPriceSkybox()) {
204
- // Mage::log("getProductType == simple ::: !parentItem ::: getPriceSkybox", null, 'verify.log', true);
205
- $product_api->CalculatePrice($item->getProductId(), null, null);
206
- // Mage::log("simple2", null, 'processcontroller.log', true);
207
- }
208
-
209
- // Configurable Product
210
- if ($item->getProductType() === 'simple' && $parentItem) {
211
- // Mage::log("getProductType == simple ::: parentItem", null, 'verify.log', true);
212
- $item = $parentItem;
213
- // $product_api->CalculatePrice($item->getProductId(), null, $productModel->getFinalPrice());
214
-
215
- $_price = $productModel->getFinalPrice();
216
- $_price = isset($_price) ? $productModel->getFinalPrice() : $productModel->getPrice();
217
- $product_api->CalculatePrice($item->getProductId(), null, $_price);
218
- // Mage::log("simple3", null, 'processcontroller.log', true);
219
- }
220
-
221
- // Bundle Product
222
- if ($item->getProductType() === 'bundle') {
223
-
224
- $product_api->CalculatePrice($item->getProductId(), null, $productModel->getPriceUsdSkybox());
225
- // Mage::log("bundle", null, 'processcontroller.log', true);
226
- };
227
-
228
- if ($isLocationAllow) {
229
- //$total = str_replace(",", "", $product_api->getPriceUSD());
230
- $total = str_replace(",", "", $productModel->getTotalPriceUSD());
231
-
232
- /**
233
- * Currency amounts in the default currency of that customer
234
- */
235
- $item->setCustomsSkybox($productModel->getCustoms());
236
- $item->setShippingSkybox($productModel->getShipping());
237
- $item->setInsuranceSkybox($productModel->getInsurance());
238
- $item->setPriceSkybox($productModel->getPrice());
239
- $item->setTotalSkybox($productModel->getTotalPrice());
240
- $item->setRowTotal($total);
241
-
242
- /*
243
- * Currency amounts in the USD Currency
244
- */
245
- $item->setCustomsUsdSkybox($productModel->getCustomsUSD());
246
- $item->setShippingUsdSkybox($productModel->getShippingUSD());
247
- $item->setInsuranceUsdSkybox($productModel->getInsuranceUSD());
248
- $item->setPriceUsdSkybox($productModel->getPriceUSD());
249
- $item->setTotalUsdSkybox($productModel->getTotalPriceUSD());
250
-
251
- // Set GUID
252
- $item->setGuidSkybox($productModel->getGuidSkybox());
253
-
254
- $item->setBasePriceSkybox($productModel->getBasePrice());
255
- $item->setBasePriceUsdSkybox($productModel->getBasePriceUSD());
256
- $item->setAdjustTotalSkybox($productModel->getAdjustPrice());
257
- $item->setAdjustTotalUsdSkybox($productModel->getAdjustPriceUSD());
258
- $item->setAdjustLabelSkybox($productModel->getAdjustLabel());
259
-
260
- /**
261
- * Registramos el monto total en USD
262
- */
263
- //$item->setOriginalCustomPrice($product_api->getTotalPriceUSD());
264
- //$item->setOriginalCustomPrice($total);
265
- $prices = str_replace(',', '', $productModel->getPrice());
266
- $prices = number_format((float)($prices), 2, ',', '.');
267
- $item->setOriginalCustomPrice($prices);
268
- //$item->setOriginalCustomPrice($product_api->getPrice());
269
- //$skybox_total = str_replace(",", "", $product_api->getTotalPrice());
270
- $skybox_total = str_replace(",", "", $productModel->getPrice());
271
- $row_total = floatval($skybox_total) * $item->getQty();
272
- $item->setRowTotalSkybox($row_total);
273
- } else {
274
- //$total = str_replace(",", "", $product_api->getPriceUSD());
275
- $total = str_replace(",", "", $product_api->getTotalPriceUSD());
276
-
277
- /**
278
- * Currency amounts in the default currency of that customer
279
- */
280
- $item->setCustomsSkybox($product_api->getCustoms());
281
- $item->setShippingSkybox($product_api->getShipping());
282
- $item->setInsuranceSkybox($product_api->getInsurance());
283
- $item->setPriceSkybox($product_api->getPrice());
284
- $item->setTotalSkybox($product_api->getTotalPrice());
285
- //$item->setRowTotal($total);
286
-
287
- /*
288
- * Currency amounts in the USD Currency
289
- */
290
- $item->setCustomsUsdSkybox($product_api->getCustomsUSD());
291
- $item->setShippingUsdSkybox($product_api->getShippingUSD());
292
- $item->setInsuranceUsdSkybox($product_api->getInsuranceUSD());
293
- $item->setPriceUsdSkybox($product_api->getPriceUSD());
294
- $item->setTotalUsdSkybox($product_api->getTotalPriceUSD());
295
-
296
- // Set GUID
297
- $item->setGuidSkybox($product_api->getGuidSkybox());
298
-
299
- $item->setBasePriceSkybox($product_api->getBasePrice());
300
- $item->setBasePriceUsdSkybox($product_api->getBasePriceUSD());
301
- $item->setAdjustTotalSkybox($product_api->getAdjustPrice());
302
- $item->setAdjustTotalUsdSkybox($product_api->getAdjustPriceUSD());
303
- $item->setAdjustLabelSkybox($product_api->getAdjustLabel());
304
-
305
- /**
306
- * Registramos el monto total en USD
307
- */
308
- //$item->setOriginalCustomPrice($product_api->getTotalPriceUSD());
309
- //$item->setOriginalCustomPrice($total);
310
-
311
-
312
- //bueyada
313
- // $prices = str_replace(',', '', $product_api->getPrice());
314
- // $prices = number_format((float)($prices), 2, ',', '.');
315
-
316
- // $prices = $this->getFormatPrice($product_api->getPrice());
317
- //
318
- // $item->setOriginalCustomPrice($prices);
319
- //
320
- // // @todo: Rewrite custom Quote and LocationAllow logic.
321
- // if ($product_api->getLocationAllow() == 0) {
322
- // // Mage::log("The country is not allow", null, 'bueyada.log', true);
323
- // $item->setOriginalCustomPrice($productModel->getPrice());
324
- // }
325
- //$item->setOriginalCustomPrice($product_api->getPrice());
326
- //$skybox_total = str_replace(",", "", $product_api->getTotalPrice());
327
- $skybox_total = str_replace(",", "", $product_api->getPrice());
328
- $row_total = floatval($skybox_total) * $item->getQty();
329
- $item->setRowTotalSkybox($row_total);
330
- }
331
-
332
- }
333
-
334
- $quote->save();
335
-
336
- $_getSession = Mage::getSingleton('checkout/session');
337
- $_getSession->setCartWasUpdated(true);
338
-
339
- // @note: Force to load Home Page due cache issue. (minicart)
340
- if (strpos($return_url, 'force_reload')) {
341
- $return_url = str_replace('force_reload', '', $return_url);
342
-
343
- /** @var Skybox_Core_Model_Config $config */
344
- $config = Mage::getModel("skyboxcore/config");
345
- $forceReload = 1;
346
- $config->getSession()->setChangeCountryHomePage($forceReload);
347
- }
348
-
349
- //$this->getResponse()->setRedirect($return_url);
350
- Mage::app()->getResponse()->setRedirect($return_url);
351
- }
352
-
353
- /**
354
- * Skybox Format Price
355
- * @param $price
356
- * @return mixed|string
357
- */
358
- function getFormatPrice($price)
359
- {
360
- $value = str_replace(',', '', $price);
361
- $value = number_format((float)($value), 2, ',', '.');
362
- return $value;
363
- }
364
- }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Checkout
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Checkout
8
+ * @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Checkout_ProcessController extends Mage_Core_Controller_Front_Action
11
+ {
12
+ public function indexAction()
13
+ {
14
+ // Mage::log(":::-----------------------------------:::", null, 'pendejerete.log', true);
15
+ /**
16
+ * only one time for call to service start - Active
17
+ * This always run when you do change country
18
+ */
19
+ $session = Mage::getSingleton("core/session", array("name" => "frontend"));
20
+ $session->setData("callToSkyBox", true);
21
+ //Mage::log("Call true: Skybox_Checkout_ProcessController", null, 'local.log', true);
22
+ /**
23
+ * only one time for call to service end - Active
24
+ */
25
+ /**
26
+ * Integration 3 start, show price shop in cart*
27
+ */
28
+ $isLocationAllow = false;
29
+ //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
30
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
31
+ if ($typeIntegration == 3) {
32
+ $isLocationAllow = true;
33
+ }
34
+ /**
35
+ * Integration 3 end, show price shop in cart*
36
+ */
37
+ //Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter index', null, 'tracer.log', true);
38
+ $_checkout = Mage::getModel('skyboxcheckout/api_checkout');
39
+ $_checkout->InitializeBarSkybox();
40
+
41
+ $return_url = ($this->getRequest()->getParam('return_url')) ?
42
+ $this->getRequest()->getParam('return_url') :
43
+ Mage::helper('core/url')->getHomeUrl();
44
+
45
+ // Mage::log("returnUrl:::". $return_url, null, 'pendejerete.log', true);
46
+
47
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
48
+ $product_api = Mage::getSingleton('skyboxcatalog/api_product');
49
+
50
+ // Mage::log("product_api:::".print_r($product_api,1), null, 'pendejerete.log', true);
51
+ // Mage::log("product_api-GetLocationAllow:::".$product_api->getLocationAllow(), null, 'pendejerete.log', true);
52
+
53
+ /*---------------- Rogged ------------------*/
54
+ $_config = Mage::getModel('skyboxcore/config');
55
+ $cart = $_config->getSession()->getCartSkybox();
56
+ $CartItemCount = 0;
57
+ if (!empty($cart)) {
58
+ $CartItemCount = intval($cart->{'CartItemCount'});
59
+ }
60
+ # check if local skybox shopping cart and skybox-checkout match
61
+ $differentqty = 0;
62
+ // $api_mproduct = Mage::getModel('skyboxcatalog/api_product');
63
+
64
+ // Mage::log('entro getAllItems $CartItemCount',null,'tracer.log',true);
65
+ // Mage::log((int)$quote->getItemsQty() .'-'.$CartItemCount,null,'tracer.log',true);
66
+ if (!$isLocationAllow) {
67
+ // Mage::log('entro !$isLocationAllow::: ',null,'tracer.log',true);
68
+ if ((int)$quote->getItemsQty() != $CartItemCount && $product_api->getLocationAllow()) {
69
+ $differentqty = 1;
70
+ }
71
+ }
72
+
73
+ // Mage::log("product_api-QuoteAllItems:::".print_r($quote->getAllItems(),1), null, 'pendejerete.log', true);
74
+
75
+ /*-----------------------------------------*/
76
+ foreach ($quote->getAllItems() as $key => $item) {
77
+ $parentItem = $item->getParentItem();
78
+ // Mage::log("parentItem:::", null, 'verify.log', true);
79
+ $parentItemId = $item->getParentItemId();
80
+ /*---------------- Rogged ------------------*/
81
+ if ($differentqty == 1) {
82
+ // Mage::log("differentqty::: 1 ", null, 'verify.log', true);
83
+ $cart = Mage::getModel('skyboxcheckout/cart');
84
+
85
+ if ($item->getProductType() === 'simple' && !$parentItem) {
86
+ // Mage::log("getProductType ::: simple ::: !parentItem", null, 'verify.log', true);
87
+ $productModel = Mage::getModel('catalog/product')->load($item->getProductId());
88
+ $paramsRequest = array();
89
+ $paramsRequest['product'] = $item->getProductId();
90
+ $paramsRequest['qty'] = $item->getQty();
91
+ // Mage::log("removeItem::: ", null, 'verify.log', true);
92
+ $cart->removeItem($item->getItemId());
93
+ // Mage::log("removeItem::: finish ", null, 'verify.log', true);
94
+ // Mage::log("addProduct::: ", null, 'verify.log', true);
95
+ $cart->addProduct($productModel, $paramsRequest);
96
+ // Mage::log("addProduct::: finish ", null, 'verify.log', true);
97
+ }
98
+ /* end */
99
+
100
+ if ($item->getProductType() === 'simple' && $parentItem) {
101
+ // Mage::log("getProductType ::: simple ::: parentItem", null, 'verify.log', true);
102
+ $paramsRequest = array();
103
+ $productParentId = Mage::getModel('catalog/product_type_configurable')
104
+ ->getParentIdsByChild($item->getProductId());
105
+ $productParentId = $productParentId[0];
106
+
107
+ // Mage::log("productParentId:::". print_r($productParentId), null, 'pendejerete.log', true);
108
+ // Mage::log("productParentId[0]:::". $productParentId, null, 'pendejerete.log', true);
109
+
110
+ $productModel = Mage::getModel('catalog/product')->load($productParentId);
111
+ $_typeInstance = $productModel->getTypeInstance(true);
112
+ $_children = $_typeInstance->getUsedProducts(null, $productModel);
113
+ $_attributes = $_typeInstance->getUsedProductAttributes($productModel);
114
+
115
+ foreach ($_children as $_child) {
116
+ if ($_child->entity_id == $item->getProductId()) {
117
+ $_superAttributes = array();
118
+ foreach ($_attributes as $_attribute) {
119
+ $_superAttributes[$_attribute->getAttributeId()] = $_child->getData($_attribute->getAttributeCode());
120
+ }
121
+ }
122
+ }
123
+
124
+ $paramsRequest['product'] = $item->getProductId();
125
+ $paramsRequest['qty'] = $item->getQty();
126
+ $paramsRequest['super_attribute'] = $_superAttributes;
127
+ $cart->removeItem($parentItemId);
128
+ $cart->addProduct($productModel, $paramsRequest);
129
+ }
130
+ // if ($item->getProductType() === 'simple' && !$parentItem && $item->getPriceSkybox()) {
131
+ // $productModel = Mage::getModel('catalog/product')->load($item->getProductId());
132
+ // $paramsRequest=array();
133
+ // $paramsRequest['product']=$item->getProductId();
134
+ // $paramsRequest['qty']=$item->getQty();
135
+ // $cart->removeItem($item->getItemId());
136
+ // $cart->addProduct($productModel,$paramsRequest);
137
+ // }
138
+ }
139
+ /*----------------------------------------*/
140
+
141
+
142
+ // Mage::log("process", null, 'process.log', true);
143
+ //Mage::log("ITEM Class: " . get_class($item), null, 'cart.log', true);
144
+ //Mage::log("ITEM Id: " . $item->getProductId(), null, 'cart.log', true);
145
+
146
+
147
+ /*if ($item->getProductType() === 'configurable') continue;
148
+ if ($item->getProductType() === 'simple' && $parentItem && !$item->getPriceSkybox()) continue;
149
+
150
+ // Simple Product
151
+ if ($item->getProductType() === 'simple' && !$parentItem && $item->getPriceSkybox()) {
152
+ $product_api->CalculatePrice($item->getProductId(), null, null);
153
+ }
154
+
155
+ // Configurable Product
156
+ if ($item->getProductType() === 'simple' && $parentItem) {
157
+ $item = $parentItem;
158
+ $product_api->CalculatePrice($item->getProductId(), null, $item->getPriceUsdSkybox());
159
+ }
160
+
161
+ // Bundle Product
162
+ if ($item->getProductType() === 'bundle') {
163
+ $product_api->CalculatePrice($item->getProductId(), null, $item->getPriceUsdSkybox());
164
+ };
165
+
166
+ $total = str_replace(",", "", $product_api->getTotalPriceUSD());*/
167
+
168
+ /* -- Rogged --*/
169
+ /* Cuando se cambia de country no allow a otro country allow, no hay precio en skybox registrado, por eso tomamos el precio de tienda */
170
+ /** @var Mage_Catalog_Model_Resource_Product $productModel */
171
+ // $productModel = Mage::getModel('catalog/product')->load($item->getProductId());
172
+
173
+ /** @var Mage_Catalog_Model_Product $productModel */
174
+ $productModel = Mage::getModel('catalog/product')->load($item->getProductId());
175
+
176
+ if (!$isLocationAllow) {
177
+ if ($product_api->getLocationAllow() && !$item->getPriceSkybox()) {
178
+ $item->setPriceSkybox($productModel->getPrice());
179
+ }
180
+ }
181
+
182
+ /* -- ----- --*/
183
+
184
+ #echo $item->getPrice()." - ".$item->getPriceSkybox()."<br>";
185
+
186
+
187
+ // Mage::log(print_r($productModel->getFinalPrice(), true), null, 'processcontroller.log', true);
188
+
189
+ if ($item->getProductType() === 'configurable') {
190
+ // Mage::log("getProductType == configurable", null, 'verify.log', true);
191
+ // $product_api->CalculatePrice($item->getProductId(), null, $productModel->getPriceUsdSkybox(),
192
+ // $item->getProductType(), null);
193
+ // Mage::log("configurable", null, 'processcontroller.log', true);
194
+ }
195
+ if ($item->getProductType() === 'simple' && $parentItem && !$item->getPriceSkybox()) {
196
+ // Mage::log("getProductType == simple ::: parentItem ::: !getPriceSkybox", null, 'verify.log', true);
197
+ $product_api->CalculatePrice($item->getProductId(), null, $productModel->getPriceUsdSkybox(),
198
+ $item->getProductType(), null);
199
+ // Mage::log("simple1", null, 'processcontroller.log', true);
200
+ }
201
+
202
+ // Simple Product
203
+ if ($item->getProductType() === 'simple' && !$parentItem && $item->getPriceSkybox()) {
204
+ // Mage::log("getProductType == simple ::: !parentItem ::: getPriceSkybox", null, 'verify.log', true);
205
+ $product_api->CalculatePrice($item->getProductId(), null, null);
206
+ // Mage::log("simple2", null, 'processcontroller.log', true);
207
+ }
208
+
209
+ // Configurable Product
210
+ if ($item->getProductType() === 'simple' && $parentItem) {
211
+ // Mage::log("getProductType == simple ::: parentItem", null, 'verify.log', true);
212
+ $item = $parentItem;
213
+ // $product_api->CalculatePrice($item->getProductId(), null, $productModel->getFinalPrice());
214
+
215
+ $_price = $productModel->getFinalPrice();
216
+ $_price = isset($_price) ? $productModel->getFinalPrice() : $productModel->getPrice();
217
+ $product_api->CalculatePrice($item->getProductId(), null, $_price);
218
+ // Mage::log("simple3", null, 'processcontroller.log', true);
219
+ }
220
+
221
+ // Bundle Product
222
+ if ($item->getProductType() === 'bundle') {
223
+
224
+ $product_api->CalculatePrice($item->getProductId(), null, $productModel->getPriceUsdSkybox());
225
+ // Mage::log("bundle", null, 'processcontroller.log', true);
226
+ };
227
+
228
+ if ($isLocationAllow) {
229
+ //$total = str_replace(",", "", $product_api->getPriceUSD());
230
+ $total = str_replace(",", "", $productModel->getTotalPriceUSD());
231
+
232
+ /**
233
+ * Currency amounts in the default currency of that customer
234
+ */
235
+ $item->setCustomsSkybox($productModel->getCustoms());
236
+ $item->setShippingSkybox($productModel->getShipping());
237
+ $item->setInsuranceSkybox($productModel->getInsurance());
238
+ $item->setPriceSkybox($productModel->getPrice());
239
+ $item->setTotalSkybox($productModel->getTotalPrice());
240
+ $item->setRowTotal($total);
241
+
242
+ /*
243
+ * Currency amounts in the USD Currency
244
+ */
245
+ $item->setCustomsUsdSkybox($productModel->getCustomsUSD());
246
+ $item->setShippingUsdSkybox($productModel->getShippingUSD());
247
+ $item->setInsuranceUsdSkybox($productModel->getInsuranceUSD());
248
+ $item->setPriceUsdSkybox($productModel->getPriceUSD());
249
+ $item->setTotalUsdSkybox($productModel->getTotalPriceUSD());
250
+
251
+ // Set GUID
252
+ $item->setGuidSkybox($productModel->getGuidSkybox());
253
+
254
+ $item->setBasePriceSkybox($productModel->getBasePrice());
255
+ $item->setBasePriceUsdSkybox($productModel->getBasePriceUSD());
256
+ $item->setAdjustTotalSkybox($productModel->getAdjustPrice());
257
+ $item->setAdjustTotalUsdSkybox($productModel->getAdjustPriceUSD());
258
+ $item->setAdjustLabelSkybox($productModel->getAdjustLabel());
259
+
260
+ /**
261
+ * Registramos el monto total en USD
262
+ */
263
+ //$item->setOriginalCustomPrice($product_api->getTotalPriceUSD());
264
+ //$item->setOriginalCustomPrice($total);
265
+ $prices = str_replace(',', '', $productModel->getPrice());
266
+ $prices = number_format((float)($prices), 2, ',', '.');
267
+ $item->setOriginalCustomPrice($prices);
268
+ //$item->setOriginalCustomPrice($product_api->getPrice());
269
+ //$skybox_total = str_replace(",", "", $product_api->getTotalPrice());
270
+ $skybox_total = str_replace(",", "", $productModel->getPrice());
271
+ $row_total = floatval($skybox_total) * $item->getQty();
272
+ $item->setRowTotalSkybox($row_total);
273
+ } else {
274
+ //$total = str_replace(",", "", $product_api->getPriceUSD());
275
+ $total = str_replace(",", "", $product_api->getTotalPriceUSD());
276
+
277
+ /**
278
+ * Currency amounts in the default currency of that customer
279
+ */
280
+ $item->setCustomsSkybox($product_api->getCustoms());
281
+ $item->setShippingSkybox($product_api->getShipping());
282
+ $item->setInsuranceSkybox($product_api->getInsurance());
283
+ $item->setPriceSkybox($product_api->getPrice());
284
+ $item->setTotalSkybox($product_api->getTotalPrice());
285
+ //$item->setRowTotal($total);
286
+
287
+ /*
288
+ * Currency amounts in the USD Currency
289
+ */
290
+ $item->setCustomsUsdSkybox($product_api->getCustomsUSD());
291
+ $item->setShippingUsdSkybox($product_api->getShippingUSD());
292
+ $item->setInsuranceUsdSkybox($product_api->getInsuranceUSD());
293
+ $item->setPriceUsdSkybox($product_api->getPriceUSD());
294
+ $item->setTotalUsdSkybox($product_api->getTotalPriceUSD());
295
+
296
+ // Set GUID
297
+ $item->setGuidSkybox($product_api->getGuidSkybox());
298
+
299
+ $item->setBasePriceSkybox($product_api->getBasePrice());
300
+ $item->setBasePriceUsdSkybox($product_api->getBasePriceUSD());
301
+ $item->setAdjustTotalSkybox($product_api->getAdjustPrice());
302
+ $item->setAdjustTotalUsdSkybox($product_api->getAdjustPriceUSD());
303
+ $item->setAdjustLabelSkybox($product_api->getAdjustLabel());
304
+
305
+ /**
306
+ * Registramos el monto total en USD
307
+ */
308
+ //$item->setOriginalCustomPrice($product_api->getTotalPriceUSD());
309
+ //$item->setOriginalCustomPrice($total);
310
+
311
+
312
+ //bueyada
313
+ // $prices = str_replace(',', '', $product_api->getPrice());
314
+ // $prices = number_format((float)($prices), 2, ',', '.');
315
+
316
+ // $prices = $this->getFormatPrice($product_api->getPrice());
317
+ //
318
+ // $item->setOriginalCustomPrice($prices);
319
+ //
320
+ // // @todo: Rewrite custom Quote and LocationAllow logic.
321
+ // if ($product_api->getLocationAllow() == 0) {
322
+ // // Mage::log("The country is not allow", null, 'bueyada.log', true);
323
+ // $item->setOriginalCustomPrice($productModel->getPrice());
324
+ // }
325
+ //$item->setOriginalCustomPrice($product_api->getPrice());
326
+ //$skybox_total = str_replace(",", "", $product_api->getTotalPrice());
327
+ $skybox_total = str_replace(",", "", $product_api->getPrice());
328
+ $row_total = floatval($skybox_total) * $item->getQty();
329
+ $item->setRowTotalSkybox($row_total);
330
+ }
331
+
332
+ }
333
+
334
+ $quote->save();
335
+
336
+ $_getSession = Mage::getSingleton('checkout/session');
337
+ $_getSession->setCartWasUpdated(true);
338
+
339
+ //$this->getResponse()->setRedirect($return_url);
340
+ Mage::app()->getResponse()->setRedirect($return_url);
341
+ }
342
+
343
+ /**
344
+ * Skybox Format Price
345
+ * @param $price
346
+ * @return mixed|string
347
+ */
348
+ function getFormatPrice($price)
349
+ {
350
+ $value = str_replace(',', '', $price);
351
+ $value = number_format((float)($value), 2, ',', '.');
352
+ return $value;
353
+ }
354
+ }
 
 
 
 
 
 
 
 
 
 
app/code/community/Skybox/Checkout/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Skybox_Checkout>
5
- <version>1.2.10</version>
6
  <codePool>community</codePool>
7
  </Skybox_Checkout>
8
  </modules>
@@ -258,12 +258,12 @@
258
  </observers>
259
  </sales_quote_collect_totals_before-->
260
  <sales_quote_collect_totals_before>
261
- <observers>
262
- <frontend_shipping_rates_sales_quote_collect_totals_before>
263
- <class>Skybox_Checkout_Model_Observer</class>
264
- <method>hideShippingMethod</method>
265
- </frontend_shipping_rates_sales_quote_collect_totals_before>
266
- </observers>
267
  </sales_quote_collect_totals_before>
268
  </events>
269
  <!--rewrite>
@@ -326,13 +326,48 @@
326
  <after>subtotal,discount,shipping</after>
327
  <before>tax,grand_total</before>
328
  </checkout_total8>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
329
  <!--Eliminar-->
330
  <!--<skybox_insurance>
331
  <class>skyboxcheckout/total_screen_quote</class>
332
  <after>subtotal</after>
333
  <before>tax</before>
334
  </skybox_insurance>-->
335
- <checkout_total_rmt1>
336
  <class>skyboxcheckout/quote_address_total_rmt</class>
337
  <after>subtotal,discount,shipping</after>
338
  <before>tax,grand_total</before>
@@ -340,34 +375,34 @@
340
  </totals>
341
  </quote>
342
  <!--<order_invoice>-->
343
- <!--<totals>-->
344
- <!--<checkout_total1>-->
345
- <!--<class>skyboxcheckout/invoice_total</class>-->
346
- <!--<after>subtotal,discount,shipping</after>-->
347
- <!--<before>tax,grand_total</before>-->
348
- <!--</checkout_total1>-->
349
- <!--&lt;!&ndash;Eliminar&ndash;&gt;-->
350
- <!--&lt;!&ndash;<skybox_insurance>-->
351
- <!--<class>skyboxcheckout/total_screen_invoice</class>-->
352
- <!--<after>subtotal</after>-->
353
- <!--<before>tax</before>-->
354
- <!--</skybox_insurance>&ndash;&gt;-->
355
- <!--</totals>-->
356
  <!--</order_invoice> -->
357
  <!--<order_creditmemo>-->
358
- <!--<totals>-->
359
- <!--<checkout_total1>-->
360
- <!--<class>skyboxcheckout/creditmemo_total</class>-->
361
- <!--<after>subtotal,discount,shipping</after>-->
362
- <!--<before>tax,grand_total</before>-->
363
- <!--</checkout_total1>-->
364
- <!--&lt;!&ndash;Eliminar&ndash;&gt;-->
365
- <!--&lt;!&ndash;<skybox_insurance>-->
366
- <!--<class>skyboxcheckout/total_screen_creditmemo</class>-->
367
- <!--<after>subtotal</after>-->
368
- <!--<before>tax</before>-->
369
- <!--</skybox_insurance>&ndash;&gt;-->
370
- <!--</totals>-->
371
  <!--</order_creditmemo>-->
372
  </sales>
373
  <!--routers>
@@ -397,7 +432,7 @@
397
  </rewrite>
398
  </checkout>
399
  <!--<skyboxcheckout_pay>-->
400
- <!--<class>Skybox_Checkout_Helper</class>-->
401
  <!--</skyboxcheckout_pay>-->
402
  </helpers>
403
 
@@ -475,11 +510,11 @@
475
  </payment>
476
  <config_vars/>
477
  <!--Eliminar-->
478
- <!--<sales>
479
- <totals_sort>
480
- <skybox_insurance>0</skybox_insurance>
481
- </totals_sort>
482
- </sales>-->
483
  <!--<sales>
484
  <totals_sort>
485
  <checkout_insurance>15</checkout_insurance>
2
  <config>
3
  <modules>
4
  <Skybox_Checkout>
5
+ <version>1.2.11</version>
6
  <codePool>community</codePool>
7
  </Skybox_Checkout>
8
  </modules>
258
  </observers>
259
  </sales_quote_collect_totals_before-->
260
  <sales_quote_collect_totals_before>
261
+ <observers>
262
+ <frontend_shipping_rates_sales_quote_collect_totals_before>
263
+ <class>Skybox_Checkout_Model_Observer</class>
264
+ <method>hideShippingMethod</method>
265
+ </frontend_shipping_rates_sales_quote_collect_totals_before>
266
+ </observers>
267
  </sales_quote_collect_totals_before>
268
  </events>
269
  <!--rewrite>
326
  <after>subtotal,discount,shipping</after>
327
  <before>tax,grand_total</before>
328
  </checkout_total8>
329
+ <checkout_total9>
330
+ <class>skyboxcheckout/quote_total9</class>
331
+ <after>subtotal,discount,shipping</after>
332
+ <before>tax,grand_total</before>
333
+ </checkout_total9>
334
+ <checkout_total10>
335
+ <class>skyboxcheckout/quote_total10</class>
336
+ <after>subtotal,discount,shipping</after>
337
+ <before>tax,grand_total</before>
338
+ </checkout_total10>
339
+ <checkout_total11>
340
+ <class>skyboxcheckout/quote_total11</class>
341
+ <after>subtotal,discount,shipping</after>
342
+ <before>tax,grand_total</before>
343
+ </checkout_total11>
344
+ <checkout_total12>
345
+ <class>skyboxcheckout/quote_total12</class>
346
+ <after>subtotal,discount,shipping</after>
347
+ <before>tax,grand_total</before>
348
+ </checkout_total12>
349
+ <checkout_total13>
350
+ <class>skyboxcheckout/quote_total13</class>
351
+ <after>subtotal,discount,shipping</after>
352
+ <before>tax,grand_total</before>
353
+ </checkout_total13>
354
+ <checkout_total14>
355
+ <class>skyboxcheckout/quote_total14</class>
356
+ <after>subtotal,discount,shipping</after>
357
+ <before>tax,grand_total</before>
358
+ </checkout_total14>
359
+ <checkout_total15>
360
+ <class>skyboxcheckout/quote_total15</class>
361
+ <after>subtotal,discount,shipping</after>
362
+ <before>tax,grand_total</before>
363
+ </checkout_total15>
364
  <!--Eliminar-->
365
  <!--<skybox_insurance>
366
  <class>skyboxcheckout/total_screen_quote</class>
367
  <after>subtotal</after>
368
  <before>tax</before>
369
  </skybox_insurance>-->
370
+ <checkout_total_rmt1>
371
  <class>skyboxcheckout/quote_address_total_rmt</class>
372
  <after>subtotal,discount,shipping</after>
373
  <before>tax,grand_total</before>
375
  </totals>
376
  </quote>
377
  <!--<order_invoice>-->
378
+ <!--<totals>-->
379
+ <!--<checkout_total1>-->
380
+ <!--<class>skyboxcheckout/invoice_total</class>-->
381
+ <!--<after>subtotal,discount,shipping</after>-->
382
+ <!--<before>tax,grand_total</before>-->
383
+ <!--</checkout_total1>-->
384
+ <!--&lt;!&ndash;Eliminar&ndash;&gt;-->
385
+ <!--&lt;!&ndash;<skybox_insurance>-->
386
+ <!--<class>skyboxcheckout/total_screen_invoice</class>-->
387
+ <!--<after>subtotal</after>-->
388
+ <!--<before>tax</before>-->
389
+ <!--</skybox_insurance>&ndash;&gt;-->
390
+ <!--</totals>-->
391
  <!--</order_invoice> -->
392
  <!--<order_creditmemo>-->
393
+ <!--<totals>-->
394
+ <!--<checkout_total1>-->
395
+ <!--<class>skyboxcheckout/creditmemo_total</class>-->
396
+ <!--<after>subtotal,discount,shipping</after>-->
397
+ <!--<before>tax,grand_total</before>-->
398
+ <!--</checkout_total1>-->
399
+ <!--&lt;!&ndash;Eliminar&ndash;&gt;-->
400
+ <!--&lt;!&ndash;<skybox_insurance>-->
401
+ <!--<class>skyboxcheckout/total_screen_creditmemo</class>-->
402
+ <!--<after>subtotal</after>-->
403
+ <!--<before>tax</before>-->
404
+ <!--</skybox_insurance>&ndash;&gt;-->
405
+ <!--</totals>-->
406
  <!--</order_creditmemo>-->
407
  </sales>
408
  <!--routers>
432
  </rewrite>
433
  </checkout>
434
  <!--<skyboxcheckout_pay>-->
435
+ <!--<class>Skybox_Checkout_Helper</class>-->
436
  <!--</skyboxcheckout_pay>-->
437
  </helpers>
438
 
510
  </payment>
511
  <config_vars/>
512
  <!--Eliminar-->
513
+ <!--<sales>
514
+ <totals_sort>
515
+ <skybox_insurance>0</skybox_insurance>
516
+ </totals_sort>
517
+ </sales>-->
518
  <!--<sales>
519
  <totals_sort>
520
  <checkout_insurance>15</checkout_insurance>
app/code/community/Skybox/Checkout/etc/system.xml CHANGED
@@ -1,127 +1,127 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <config>
3
- <sections>
4
- <carriers translate="label" module="shipping">
5
- <groups>
6
- <skyboxcheckout_shipping translate="label">
7
- <label>Shipping SkyboxCheckout</label>
8
- <frontend_type>text</frontend_type>
9
- <sort_order>0</sort_order>
10
- <show_in_default>1</show_in_default>
11
- <show_in_website>1</show_in_website>
12
- <show_in_store>1</show_in_store>
13
- <fields>
14
- <active translate="label">
15
- <label>Enabled</label>
16
- <frontend_type>select</frontend_type>
17
- <source_model>adminhtml/system_config_source_yesno</source_model>
18
- <sort_order>1</sort_order>
19
- <show_in_default>1</show_in_default>
20
- <show_in_website>1</show_in_website>
21
- <show_in_store>1</show_in_store>
22
- </active>
23
- <title translate="label">
24
- <label>Title</label>
25
- <frontend_type>text</frontend_type>
26
- <sort_order>2</sort_order>
27
- <show_in_default>1</show_in_default>
28
- <show_in_website>1</show_in_website>
29
- <show_in_store>1</show_in_store>
30
- </title>
31
- <sort_order translate="label">
32
- <label>Sort Order</label>
33
- <frontend_type>text</frontend_type>
34
- <sort_order>100</sort_order>
35
- <show_in_default>1</show_in_default>
36
- <show_in_website>1</show_in_website>
37
- <show_in_store>0</show_in_store>
38
- </sort_order>
39
- <price translate="label">
40
- <label>Price</label>
41
- <frontend_type>text</frontend_type>
42
- <sort_order>3</sort_order>
43
- <show_in_default>1</show_in_default>
44
- <show_in_website>1</show_in_website>
45
- <show_in_store>1</show_in_store>
46
- </price>
47
- <!--
48
- This value is used to specify whether
49
- the carrier is available only for
50
- specific countries or all countries
51
- available in the current Magento
52
- installation.
53
- -->
54
- <!--<sallowspecific translate="label">-->
55
- <!--<label>Ship to Applicable Countries</label>-->
56
- <!--<frontend_type>select</frontend_type>-->
57
- <!--<sort_order>90</sort_order>-->
58
- <!--<frontend_class>shipping-applicable-country</frontend_class>-->
59
- <!--<source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>-->
60
- <!--<show_in_default>1</show_in_default>-->
61
- <!--<show_in_website>1</show_in_website>-->
62
- <!--<show_in_store>0</show_in_store>-->
63
- <!--</sallowspecific>-->
64
- <!--
65
- If 'specific countries' is chosen
66
- in the previous option, then this field
67
- allows the administrator to specify
68
- which specific countries this carrier
69
- should be available for.
70
- -->
71
- <!--<specificcountry translate="label">-->
72
- <!--<label>Ship to Specific Countries</label>-->
73
- <!--<frontend_type>multiselect</frontend_type>-->
74
- <!--<sort_order>91</sort_order>-->
75
- <!--<source_model>adminhtml/system_config_source_country</source_model>-->
76
- <!--<show_in_default>1</show_in_default>-->
77
- <!--<show_in_website>1</show_in_website>-->
78
- <!--<show_in_store>0</show_in_store>-->
79
- <!--<can_be_empty>1</can_be_empty>-->
80
- <!--</specificcountry>-->
81
- </fields>
82
- </skyboxcheckout_shipping>
83
- </groups>
84
- </carriers>
85
- <payment>
86
- <groups>
87
- <skyboxcheckout_pay translate="label">
88
- <label>Skybox Payment Module</label>
89
- <sort_order>0</sort_order>
90
- <show_in_default>1</show_in_default>
91
- <show_in_website>1</show_in_website>
92
- <show_in_store>0</show_in_store>
93
- <fields>
94
- <active translate="label">
95
- <label>Enabled</label>
96
- <frontend_type>select</frontend_type>
97
- <source_model>adminhtml/system_config_source_yesno</source_model>
98
- <sort_order>1</sort_order>
99
- <show_in_default>1</show_in_default>
100
- <show_in_website>1</show_in_website>
101
- <show_in_store>0</show_in_store>
102
- </active>
103
- <order_status translate="label">
104
- <label>New order status</label>
105
- <frontend_type>select</frontend_type>
106
- <source_model>adminhtml/system_config_source_order_status</source_model>
107
- <!--<source_model>adminhtml/system_config_source_order_status_new</source_model>-->
108
- <!--<source_model>adminhtml/system_config_source_order_status_processing</source_model>-->
109
- <sort_order>2</sort_order>
110
- <show_in_default>1</show_in_default>
111
- <show_in_website>1</show_in_website>
112
- <show_in_store>0</show_in_store>
113
- </order_status>
114
- <title translate="label">
115
- <label>Title</label>
116
- <frontend_type>text</frontend_type>
117
- <sort_order>3</sort_order>
118
- <show_in_default>1</show_in_default>
119
- <show_in_website>1</show_in_website>
120
- <show_in_store>0</show_in_store>
121
- </title>
122
- </fields>
123
- </skyboxcheckout_pay>
124
- </groups>
125
- </payment>
126
- </sections>
127
- </config>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <sections>
4
+ <carriers translate="label" module="shipping">
5
+ <groups>
6
+ <skyboxcheckout_shipping translate="label">
7
+ <label>Shipping SkyboxCheckout</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>0</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>1</show_in_store>
13
+ <fields>
14
+ <active translate="label">
15
+ <label>Enabled</label>
16
+ <frontend_type>select</frontend_type>
17
+ <source_model>adminhtml/system_config_source_yesno</source_model>
18
+ <sort_order>1</sort_order>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>1</show_in_store>
22
+ </active>
23
+ <title translate="label">
24
+ <label>Title</label>
25
+ <frontend_type>text</frontend_type>
26
+ <sort_order>2</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ </title>
31
+ <sort_order translate="label">
32
+ <label>Sort Order</label>
33
+ <frontend_type>text</frontend_type>
34
+ <sort_order>100</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>0</show_in_store>
38
+ </sort_order>
39
+ <price translate="label">
40
+ <label>Price</label>
41
+ <frontend_type>text</frontend_type>
42
+ <sort_order>3</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>1</show_in_store>
46
+ </price>
47
+ <!--
48
+ This value is used to specify whether
49
+ the carrier is available only for
50
+ specific countries or all countries
51
+ available in the current Magento
52
+ installation.
53
+ -->
54
+ <!--<sallowspecific translate="label">-->
55
+ <!--<label>Ship to Applicable Countries</label>-->
56
+ <!--<frontend_type>select</frontend_type>-->
57
+ <!--<sort_order>90</sort_order>-->
58
+ <!--<frontend_class>shipping-applicable-country</frontend_class>-->
59
+ <!--<source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>-->
60
+ <!--<show_in_default>1</show_in_default>-->
61
+ <!--<show_in_website>1</show_in_website>-->
62
+ <!--<show_in_store>0</show_in_store>-->
63
+ <!--</sallowspecific>-->
64
+ <!--
65
+ If 'specific countries' is chosen
66
+ in the previous option, then this field
67
+ allows the administrator to specify
68
+ which specific countries this carrier
69
+ should be available for.
70
+ -->
71
+ <!--<specificcountry translate="label">-->
72
+ <!--<label>Ship to Specific Countries</label>-->
73
+ <!--<frontend_type>multiselect</frontend_type>-->
74
+ <!--<sort_order>91</sort_order>-->
75
+ <!--<source_model>adminhtml/system_config_source_country</source_model>-->
76
+ <!--<show_in_default>1</show_in_default>-->
77
+ <!--<show_in_website>1</show_in_website>-->
78
+ <!--<show_in_store>0</show_in_store>-->
79
+ <!--<can_be_empty>1</can_be_empty>-->
80
+ <!--</specificcountry>-->
81
+ </fields>
82
+ </skyboxcheckout_shipping>
83
+ </groups>
84
+ </carriers>
85
+ <payment>
86
+ <groups>
87
+ <skyboxcheckout_pay translate="label">
88
+ <label>Skybox Payment Module</label>
89
+ <sort_order>0</sort_order>
90
+ <show_in_default>1</show_in_default>
91
+ <show_in_website>1</show_in_website>
92
+ <show_in_store>0</show_in_store>
93
+ <fields>
94
+ <active translate="label">
95
+ <label>Enabled</label>
96
+ <frontend_type>select</frontend_type>
97
+ <source_model>adminhtml/system_config_source_yesno</source_model>
98
+ <sort_order>1</sort_order>
99
+ <show_in_default>1</show_in_default>
100
+ <show_in_website>1</show_in_website>
101
+ <show_in_store>0</show_in_store>
102
+ </active>
103
+ <order_status translate="label">
104
+ <label>New order status</label>
105
+ <frontend_type>select</frontend_type>
106
+ <source_model>adminhtml/system_config_source_order_status</source_model>
107
+ <!--<source_model>adminhtml/system_config_source_order_status_new</source_model>-->
108
+ <!--<source_model>adminhtml/system_config_source_order_status_processing</source_model>-->
109
+ <sort_order>2</sort_order>
110
+ <show_in_default>1</show_in_default>
111
+ <show_in_website>1</show_in_website>
112
+ <show_in_store>0</show_in_store>
113
+ </order_status>
114
+ <title translate="label">
115
+ <label>Title</label>
116
+ <frontend_type>text</frontend_type>
117
+ <sort_order>3</sort_order>
118
+ <show_in_default>1</show_in_default>
119
+ <show_in_website>1</show_in_website>
120
+ <show_in_store>0</show_in_store>
121
+ </title>
122
+ </fields>
123
+ </skyboxcheckout_pay>
124
+ </groups>
125
+ </payment>
126
+ </sections>
127
+ </config>
app/code/community/Skybox/Checkout/sql/skyboxcheckout_setup/mysql4-install-0.1.0.php CHANGED
@@ -1,133 +1,133 @@
1
- <?php
2
-
3
- $installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
4
- $installer->startSetup();
5
-
6
- // Table: sales_flat_quote_address
7
-
8
- $installer->addAttribute('quote_address', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
9
- $installer->addAttribute('quote_address', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
10
- $installer->addAttribute('quote_address', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
11
- $installer->addAttribute('quote_address', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
12
-
13
- $installer->addAttribute('quote_address', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
14
- $installer->addAttribute('quote_address', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
15
-
16
- $installer->addAttribute('quote_address', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
17
- $installer->addAttribute('quote_address', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
18
-
19
- $installer->addAttribute('quote_address', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
20
- $installer->addAttribute('quote_address', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
21
-
22
- $installer->addAttribute('quote_address', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
23
- $installer->addAttribute('quote_address', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
24
-
25
- $installer->addAttribute('quote_address', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
26
- $installer->addAttribute('quote_address', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
27
-
28
- $installer->addAttribute('quote_address', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
29
- $installer->addAttribute('quote_address', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
30
-
31
- $installer->addAttribute('quote_address', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
32
- $installer->addAttribute('quote_address', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
33
-
34
- $installer->addAttribute('quote_address', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
35
- $installer->addAttribute('quote_address', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
36
-
37
- $installer->addAttribute('quote_address', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
38
- $installer->addAttribute('quote_address', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
39
-
40
- $installer->addAttribute('quote_address', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
41
- $installer->addAttribute('quote_address', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
42
-
43
- // Table: sales_flat_quote_item
44
-
45
- $installer->addAttribute('quote_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
46
- $installer->addAttribute('quote_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
47
- $installer->addAttribute('quote_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
48
- $installer->addAttribute('quote_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
49
- $installer->addAttribute('quote_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
50
- $installer->addAttribute('quote_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
51
-
52
- $installer->addAttribute('quote_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
53
- $installer->addAttribute('quote_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
54
- $installer->addAttribute('quote_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
55
- $installer->addAttribute('quote_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
56
- $installer->addAttribute('quote_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
57
- $installer->addAttribute('quote_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
58
- $installer->addAttribute('quote_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
59
-
60
- $installer->addAttribute('quote_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
61
- $installer->addAttribute('quote_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
62
- $installer->addAttribute('quote_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
63
- $installer->addAttribute('quote_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
64
- $installer->addAttribute('quote_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
65
- $installer->addAttribute('quote_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
66
- $installer->addAttribute('quote_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
67
-
68
-
69
- // Table: sales_flat_order_item
70
-
71
- $installer->addAttribute('order_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
72
- $installer->addAttribute('order_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
73
- $installer->addAttribute('order_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
74
- $installer->addAttribute('order_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
75
- $installer->addAttribute('order_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
76
- $installer->addAttribute('order_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
77
-
78
- $installer->addAttribute('order_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
79
- $installer->addAttribute('order_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
80
- $installer->addAttribute('order_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
81
- $installer->addAttribute('order_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
82
- $installer->addAttribute('order_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
83
- $installer->addAttribute('order_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
84
- $installer->addAttribute('order_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
85
-
86
- $installer->addAttribute('order_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
87
- $installer->addAttribute('order_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
88
- $installer->addAttribute('order_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
89
- $installer->addAttribute('order_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
90
- $installer->addAttribute('order_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
91
- $installer->addAttribute('order_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
92
- $installer->addAttribute('order_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
93
-
94
-
95
- // Table: sales_flat_order
96
-
97
- $installer->addAttribute('order', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
98
- $installer->addAttribute('order', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
99
- $installer->addAttribute('order', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
100
- $installer->addAttribute('order', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
101
-
102
- $installer->addAttribute('order', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
103
- $installer->addAttribute('order', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
104
-
105
- $installer->addAttribute('order', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
106
- $installer->addAttribute('order', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
107
-
108
- $installer->addAttribute('order', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
109
- $installer->addAttribute('order', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
110
-
111
- $installer->addAttribute('order', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
112
- $installer->addAttribute('order', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
113
-
114
- $installer->addAttribute('order', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
115
- $installer->addAttribute('order', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
116
-
117
- $installer->addAttribute('order', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
118
- $installer->addAttribute('order', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
119
-
120
- $installer->addAttribute('order', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
121
- $installer->addAttribute('order', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
122
-
123
- $installer->addAttribute('order', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
124
- $installer->addAttribute('order', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
125
-
126
- $installer->addAttribute('order', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
127
- $installer->addAttribute('order', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
128
-
129
- $installer->addAttribute('order', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
130
- $installer->addAttribute('order', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
131
-
132
-
133
  $installer->endSetup();
1
+ <?php
2
+
3
+ $installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
4
+ $installer->startSetup();
5
+
6
+ // Table: sales_flat_quote_address
7
+
8
+ $installer->addAttribute('quote_address', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
9
+ $installer->addAttribute('quote_address', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
10
+ $installer->addAttribute('quote_address', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
11
+ $installer->addAttribute('quote_address', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
12
+
13
+ $installer->addAttribute('quote_address', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
14
+ $installer->addAttribute('quote_address', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
15
+
16
+ $installer->addAttribute('quote_address', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
17
+ $installer->addAttribute('quote_address', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
18
+
19
+ $installer->addAttribute('quote_address', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
20
+ $installer->addAttribute('quote_address', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
21
+
22
+ $installer->addAttribute('quote_address', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
23
+ $installer->addAttribute('quote_address', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
24
+
25
+ $installer->addAttribute('quote_address', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
26
+ $installer->addAttribute('quote_address', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
27
+
28
+ $installer->addAttribute('quote_address', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
29
+ $installer->addAttribute('quote_address', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
30
+
31
+ $installer->addAttribute('quote_address', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
32
+ $installer->addAttribute('quote_address', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
33
+
34
+ $installer->addAttribute('quote_address', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
35
+ $installer->addAttribute('quote_address', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
36
+
37
+ $installer->addAttribute('quote_address', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
38
+ $installer->addAttribute('quote_address', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
39
+
40
+ $installer->addAttribute('quote_address', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
41
+ $installer->addAttribute('quote_address', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
42
+
43
+ // Table: sales_flat_quote_item
44
+
45
+ $installer->addAttribute('quote_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
46
+ $installer->addAttribute('quote_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
47
+ $installer->addAttribute('quote_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
48
+ $installer->addAttribute('quote_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
49
+ $installer->addAttribute('quote_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
50
+ $installer->addAttribute('quote_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
51
+
52
+ $installer->addAttribute('quote_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
53
+ $installer->addAttribute('quote_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
54
+ $installer->addAttribute('quote_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
55
+ $installer->addAttribute('quote_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
56
+ $installer->addAttribute('quote_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
57
+ $installer->addAttribute('quote_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
58
+ $installer->addAttribute('quote_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
59
+
60
+ $installer->addAttribute('quote_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
61
+ $installer->addAttribute('quote_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
62
+ $installer->addAttribute('quote_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
63
+ $installer->addAttribute('quote_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
64
+ $installer->addAttribute('quote_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
65
+ $installer->addAttribute('quote_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
66
+ $installer->addAttribute('quote_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
67
+
68
+
69
+ // Table: sales_flat_order_item
70
+
71
+ $installer->addAttribute('order_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
72
+ $installer->addAttribute('order_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
73
+ $installer->addAttribute('order_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
74
+ $installer->addAttribute('order_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
75
+ $installer->addAttribute('order_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
76
+ $installer->addAttribute('order_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
77
+
78
+ $installer->addAttribute('order_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
79
+ $installer->addAttribute('order_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
80
+ $installer->addAttribute('order_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
81
+ $installer->addAttribute('order_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
82
+ $installer->addAttribute('order_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
83
+ $installer->addAttribute('order_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
84
+ $installer->addAttribute('order_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
85
+
86
+ $installer->addAttribute('order_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
87
+ $installer->addAttribute('order_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
88
+ $installer->addAttribute('order_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
89
+ $installer->addAttribute('order_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
90
+ $installer->addAttribute('order_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
91
+ $installer->addAttribute('order_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
92
+ $installer->addAttribute('order_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
93
+
94
+
95
+ // Table: sales_flat_order
96
+
97
+ $installer->addAttribute('order', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
98
+ $installer->addAttribute('order', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
99
+ $installer->addAttribute('order', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
100
+ $installer->addAttribute('order', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
101
+
102
+ $installer->addAttribute('order', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
103
+ $installer->addAttribute('order', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
104
+
105
+ $installer->addAttribute('order', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
106
+ $installer->addAttribute('order', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
107
+
108
+ $installer->addAttribute('order', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
109
+ $installer->addAttribute('order', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
110
+
111
+ $installer->addAttribute('order', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
112
+ $installer->addAttribute('order', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
113
+
114
+ $installer->addAttribute('order', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
115
+ $installer->addAttribute('order', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
116
+
117
+ $installer->addAttribute('order', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
118
+ $installer->addAttribute('order', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
119
+
120
+ $installer->addAttribute('order', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
121
+ $installer->addAttribute('order', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
122
+
123
+ $installer->addAttribute('order', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
124
+ $installer->addAttribute('order', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
125
+
126
+ $installer->addAttribute('order', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
127
+ $installer->addAttribute('order', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
128
+
129
+ $installer->addAttribute('order', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
130
+ $installer->addAttribute('order', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
131
+
132
+
133
  $installer->endSetup();
app/code/community/Skybox/Checkout/sql/skyboxcheckout_setup/mysql4-upgrade-0.1.0-0.1.1.php CHANGED
@@ -1,68 +1,68 @@
1
- <?php
2
-
3
- echo 'Running This Upgrade: ' . get_class($this) . "\n <br /> \n";
4
-
5
-
6
- $installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
7
- $installer->startSetup();
8
- /*
9
- $installer->addAttribute('quote_address', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
10
- $installer->addAttribute('quote_address', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
11
-
12
- $installer->addAttribute('quote_address', 'Taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
13
- $installer->addAttribute('quote_address', 'Taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
14
-
15
- $installer->addAttribute('quote_address', 'Handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
16
- $installer->addAttribute('quote_address', 'Handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
17
-
18
- $installer->addAttribute('quote_address', 'Shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
19
- $installer->addAttribute('quote_address', 'Shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
20
-
21
- $installer->addAttribute('quote_address', 'Insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
22
- $installer->addAttribute('quote_address', 'Insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
23
-
24
- $installer->addAttribute('quote_address', 'Clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
25
- $installer->addAttribute('quote_address', 'Clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
26
-
27
- $installer->addAttribute('quote_address', 'Duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
28
- $installer->addAttribute('quote_address', 'Duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
29
-
30
- $installer->addAttribute('quote_address', 'Adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
31
- $installer->addAttribute('quote_address', 'Adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));*/
32
-
33
- /*$installer->addAttribute('quote_address', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));*/
34
-
35
-
36
- /*$installer->addAttribute('order', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
37
- $installer->addAttribute('order', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
38
- $installer->addAttribute('order', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
39
- $installer->addAttribute('order', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
40
-
41
- $installer->addAttribute('order', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
42
- $installer->addAttribute('order', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
43
-
44
- $installer->addAttribute('order', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
45
- $installer->addAttribute('order', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
46
-
47
- $installer->addAttribute('order', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
48
- $installer->addAttribute('order', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
49
-
50
- $installer->addAttribute('order', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
51
- $installer->addAttribute('order', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
52
-
53
- $installer->addAttribute('order', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
54
- $installer->addAttribute('order', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
55
-
56
- $installer->addAttribute('order', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
57
- $installer->addAttribute('order', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
58
-
59
- $installer->addAttribute('order', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
60
- $installer->addAttribute('order', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
61
-
62
- $installer->addAttribute('order', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
63
- $installer->addAttribute('order', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
64
-
65
- $installer->addAttribute('order', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
66
- */
67
-
68
- $installer->endSetup();
1
+ <?php
2
+
3
+ echo 'Running This Upgrade: ' . get_class($this) . "\n <br /> \n";
4
+
5
+
6
+ $installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
7
+ $installer->startSetup();
8
+ /*
9
+ $installer->addAttribute('quote_address', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
10
+ $installer->addAttribute('quote_address', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
11
+
12
+ $installer->addAttribute('quote_address', 'Taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
13
+ $installer->addAttribute('quote_address', 'Taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
14
+
15
+ $installer->addAttribute('quote_address', 'Handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
16
+ $installer->addAttribute('quote_address', 'Handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
17
+
18
+ $installer->addAttribute('quote_address', 'Shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
19
+ $installer->addAttribute('quote_address', 'Shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
20
+
21
+ $installer->addAttribute('quote_address', 'Insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
22
+ $installer->addAttribute('quote_address', 'Insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
23
+
24
+ $installer->addAttribute('quote_address', 'Clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
25
+ $installer->addAttribute('quote_address', 'Clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
26
+
27
+ $installer->addAttribute('quote_address', 'Duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
28
+ $installer->addAttribute('quote_address', 'Duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
29
+
30
+ $installer->addAttribute('quote_address', 'Adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
31
+ $installer->addAttribute('quote_address', 'Adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));*/
32
+
33
+ /*$installer->addAttribute('quote_address', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));*/
34
+
35
+
36
+ /*$installer->addAttribute('order', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
37
+ $installer->addAttribute('order', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
38
+ $installer->addAttribute('order', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
39
+ $installer->addAttribute('order', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
40
+
41
+ $installer->addAttribute('order', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
42
+ $installer->addAttribute('order', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
43
+
44
+ $installer->addAttribute('order', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
45
+ $installer->addAttribute('order', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
46
+
47
+ $installer->addAttribute('order', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
48
+ $installer->addAttribute('order', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
49
+
50
+ $installer->addAttribute('order', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
51
+ $installer->addAttribute('order', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
52
+
53
+ $installer->addAttribute('order', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
54
+ $installer->addAttribute('order', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
55
+
56
+ $installer->addAttribute('order', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
57
+ $installer->addAttribute('order', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
58
+
59
+ $installer->addAttribute('order', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
60
+ $installer->addAttribute('order', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
61
+
62
+ $installer->addAttribute('order', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
63
+ $installer->addAttribute('order', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
64
+
65
+ $installer->addAttribute('order', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
66
+ */
67
+
68
+ $installer->endSetup();
app/code/community/Skybox/Checkout/sql/skyboxcheckout_setup/mysql4-upgrade-0.1.0-0.1.2.php CHANGED
@@ -1,16 +1,16 @@
1
- <?php
2
-
3
- echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";
4
-
5
-
6
- $installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
7
- $installer->startSetup();
8
- /*
9
- $installer->addAttribute('quote_address', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
10
- $installer->addAttribute('quote_address', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
11
-
12
- $installer->addAttribute('order', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
13
- $installer->addAttribute('order', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
14
- */
15
- $installer->endSetup();
16
-
1
+ <?php
2
+
3
+ echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";
4
+
5
+
6
+ $installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
7
+ $installer->startSetup();
8
+ /*
9
+ $installer->addAttribute('quote_address', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
10
+ $installer->addAttribute('quote_address', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
11
+
12
+ $installer->addAttribute('order', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
13
+ $installer->addAttribute('order', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
14
+ */
15
+ $installer->endSetup();
16
+
app/code/community/Skybox/Checkout/sql/skyboxcheckout_setup/mysql4-upgrade-1.2.5-1.2.5.2.php CHANGED
@@ -1,138 +1,138 @@
1
- <?php
2
-
3
- echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";
4
-
5
-
6
- // @note: Force Table entities created!
7
-
8
- $installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
9
- $installer->startSetup();
10
-
11
- // Table: sales_flat_quote_address
12
-
13
- $installer->addAttribute('quote_address', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
14
- $installer->addAttribute('quote_address', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
15
- $installer->addAttribute('quote_address', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
16
- $installer->addAttribute('quote_address', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
17
-
18
- $installer->addAttribute('quote_address', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
19
- $installer->addAttribute('quote_address', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
20
-
21
- $installer->addAttribute('quote_address', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
22
- $installer->addAttribute('quote_address', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
23
-
24
- $installer->addAttribute('quote_address', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
25
- $installer->addAttribute('quote_address', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
26
-
27
- $installer->addAttribute('quote_address', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
28
- $installer->addAttribute('quote_address', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
29
-
30
- $installer->addAttribute('quote_address', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
31
- $installer->addAttribute('quote_address', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
32
-
33
- $installer->addAttribute('quote_address', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
34
- $installer->addAttribute('quote_address', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
35
-
36
- $installer->addAttribute('quote_address', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
37
- $installer->addAttribute('quote_address', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
38
-
39
- $installer->addAttribute('quote_address', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
40
- $installer->addAttribute('quote_address', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
41
-
42
- $installer->addAttribute('quote_address', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
43
- $installer->addAttribute('quote_address', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
44
-
45
- $installer->addAttribute('quote_address', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
46
- $installer->addAttribute('quote_address', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
47
-
48
- // Table: sales_flat_quote_item
49
-
50
- $installer->addAttribute('quote_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
51
- $installer->addAttribute('quote_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
52
- $installer->addAttribute('quote_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
53
- $installer->addAttribute('quote_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
54
- $installer->addAttribute('quote_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
55
- $installer->addAttribute('quote_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
56
-
57
- $installer->addAttribute('quote_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
58
- $installer->addAttribute('quote_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
59
- $installer->addAttribute('quote_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
60
- $installer->addAttribute('quote_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
61
- $installer->addAttribute('quote_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
62
- $installer->addAttribute('quote_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
63
- $installer->addAttribute('quote_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
64
-
65
- $installer->addAttribute('quote_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
66
- $installer->addAttribute('quote_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
67
- $installer->addAttribute('quote_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
68
- $installer->addAttribute('quote_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
69
- $installer->addAttribute('quote_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
70
- $installer->addAttribute('quote_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
71
- $installer->addAttribute('quote_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
72
-
73
-
74
- // Table: sales_flat_order_item
75
-
76
- $installer->addAttribute('order_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
77
- $installer->addAttribute('order_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
78
- $installer->addAttribute('order_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
79
- $installer->addAttribute('order_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
80
- $installer->addAttribute('order_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
81
- $installer->addAttribute('order_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
82
-
83
- $installer->addAttribute('order_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
84
- $installer->addAttribute('order_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
85
- $installer->addAttribute('order_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
86
- $installer->addAttribute('order_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
87
- $installer->addAttribute('order_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
88
- $installer->addAttribute('order_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
89
- $installer->addAttribute('order_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
90
-
91
- $installer->addAttribute('order_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
92
- $installer->addAttribute('order_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
93
- $installer->addAttribute('order_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
94
- $installer->addAttribute('order_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
95
- $installer->addAttribute('order_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
96
- $installer->addAttribute('order_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
97
- $installer->addAttribute('order_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
98
-
99
-
100
- // Table: sales_flat_order
101
-
102
- $installer->addAttribute('order', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
103
- $installer->addAttribute('order', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
104
- $installer->addAttribute('order', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
105
- $installer->addAttribute('order', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
106
-
107
- $installer->addAttribute('order', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
108
- $installer->addAttribute('order', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
109
-
110
- $installer->addAttribute('order', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
111
- $installer->addAttribute('order', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
112
-
113
- $installer->addAttribute('order', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
114
- $installer->addAttribute('order', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
115
-
116
- $installer->addAttribute('order', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
117
- $installer->addAttribute('order', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
118
-
119
- $installer->addAttribute('order', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
120
- $installer->addAttribute('order', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
121
-
122
- $installer->addAttribute('order', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
123
- $installer->addAttribute('order', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
124
-
125
- $installer->addAttribute('order', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
126
- $installer->addAttribute('order', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
127
-
128
- $installer->addAttribute('order', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
129
- $installer->addAttribute('order', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
130
-
131
- $installer->addAttribute('order', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
132
- $installer->addAttribute('order', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
133
-
134
- $installer->addAttribute('order', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
135
- $installer->addAttribute('order', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
136
-
137
-
138
- $installer->endSetup();
1
+ <?php
2
+
3
+ echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";
4
+
5
+
6
+ // @note: Force Table entities created!
7
+
8
+ $installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
9
+ $installer->startSetup();
10
+
11
+ // Table: sales_flat_quote_address
12
+
13
+ $installer->addAttribute('quote_address', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
14
+ $installer->addAttribute('quote_address', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
15
+ $installer->addAttribute('quote_address', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
16
+ $installer->addAttribute('quote_address', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
17
+
18
+ $installer->addAttribute('quote_address', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
19
+ $installer->addAttribute('quote_address', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
20
+
21
+ $installer->addAttribute('quote_address', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
22
+ $installer->addAttribute('quote_address', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
23
+
24
+ $installer->addAttribute('quote_address', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
25
+ $installer->addAttribute('quote_address', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
26
+
27
+ $installer->addAttribute('quote_address', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
28
+ $installer->addAttribute('quote_address', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
29
+
30
+ $installer->addAttribute('quote_address', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
31
+ $installer->addAttribute('quote_address', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
32
+
33
+ $installer->addAttribute('quote_address', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
34
+ $installer->addAttribute('quote_address', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
35
+
36
+ $installer->addAttribute('quote_address', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
37
+ $installer->addAttribute('quote_address', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
38
+
39
+ $installer->addAttribute('quote_address', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
40
+ $installer->addAttribute('quote_address', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
41
+
42
+ $installer->addAttribute('quote_address', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
43
+ $installer->addAttribute('quote_address', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
44
+
45
+ $installer->addAttribute('quote_address', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
46
+ $installer->addAttribute('quote_address', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
47
+
48
+ // Table: sales_flat_quote_item
49
+
50
+ $installer->addAttribute('quote_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
51
+ $installer->addAttribute('quote_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
52
+ $installer->addAttribute('quote_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
53
+ $installer->addAttribute('quote_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
54
+ $installer->addAttribute('quote_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
55
+ $installer->addAttribute('quote_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
56
+
57
+ $installer->addAttribute('quote_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
58
+ $installer->addAttribute('quote_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
59
+ $installer->addAttribute('quote_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
60
+ $installer->addAttribute('quote_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
61
+ $installer->addAttribute('quote_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
62
+ $installer->addAttribute('quote_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
63
+ $installer->addAttribute('quote_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
64
+
65
+ $installer->addAttribute('quote_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
66
+ $installer->addAttribute('quote_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
67
+ $installer->addAttribute('quote_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
68
+ $installer->addAttribute('quote_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
69
+ $installer->addAttribute('quote_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
70
+ $installer->addAttribute('quote_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
71
+ $installer->addAttribute('quote_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
72
+
73
+
74
+ // Table: sales_flat_order_item
75
+
76
+ $installer->addAttribute('order_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
77
+ $installer->addAttribute('order_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
78
+ $installer->addAttribute('order_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
79
+ $installer->addAttribute('order_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
80
+ $installer->addAttribute('order_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
81
+ $installer->addAttribute('order_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
82
+
83
+ $installer->addAttribute('order_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
84
+ $installer->addAttribute('order_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
85
+ $installer->addAttribute('order_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
86
+ $installer->addAttribute('order_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
87
+ $installer->addAttribute('order_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
88
+ $installer->addAttribute('order_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
89
+ $installer->addAttribute('order_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
90
+
91
+ $installer->addAttribute('order_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
92
+ $installer->addAttribute('order_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
93
+ $installer->addAttribute('order_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
94
+ $installer->addAttribute('order_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
95
+ $installer->addAttribute('order_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
96
+ $installer->addAttribute('order_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
97
+ $installer->addAttribute('order_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
98
+
99
+
100
+ // Table: sales_flat_order
101
+
102
+ $installer->addAttribute('order', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
103
+ $installer->addAttribute('order', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
104
+ $installer->addAttribute('order', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
105
+ $installer->addAttribute('order', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
106
+
107
+ $installer->addAttribute('order', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
108
+ $installer->addAttribute('order', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
109
+
110
+ $installer->addAttribute('order', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
111
+ $installer->addAttribute('order', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
112
+
113
+ $installer->addAttribute('order', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
114
+ $installer->addAttribute('order', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
115
+
116
+ $installer->addAttribute('order', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
117
+ $installer->addAttribute('order', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
118
+
119
+ $installer->addAttribute('order', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
120
+ $installer->addAttribute('order', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
121
+
122
+ $installer->addAttribute('order', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
123
+ $installer->addAttribute('order', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
124
+
125
+ $installer->addAttribute('order', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
126
+ $installer->addAttribute('order', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
127
+
128
+ $installer->addAttribute('order', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
129
+ $installer->addAttribute('order', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
130
+
131
+ $installer->addAttribute('order', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
132
+ $installer->addAttribute('order', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
133
+
134
+ $installer->addAttribute('order', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
135
+ $installer->addAttribute('order', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
136
+
137
+
138
+ $installer->endSetup();
app/code/community/Skybox/Checkout/sql/skyboxcheckout_setup/mysql4-upgrade-1.2.5.2-1.2.6.php CHANGED
@@ -1,138 +1,138 @@
1
- <?php
2
-
3
- echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";
4
-
5
-
6
- // @note: Force Table entities created!
7
-
8
- $installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
9
- $installer->startSetup();
10
-
11
- // Table: sales_flat_quote_address
12
-
13
- $installer->addAttribute('quote_address', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
14
- $installer->addAttribute('quote_address', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
15
- $installer->addAttribute('quote_address', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
16
- $installer->addAttribute('quote_address', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
17
-
18
- $installer->addAttribute('quote_address', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
19
- $installer->addAttribute('quote_address', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
20
-
21
- $installer->addAttribute('quote_address', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
22
- $installer->addAttribute('quote_address', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
23
-
24
- $installer->addAttribute('quote_address', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
25
- $installer->addAttribute('quote_address', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
26
-
27
- $installer->addAttribute('quote_address', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
28
- $installer->addAttribute('quote_address', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
29
-
30
- $installer->addAttribute('quote_address', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
31
- $installer->addAttribute('quote_address', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
32
-
33
- $installer->addAttribute('quote_address', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
34
- $installer->addAttribute('quote_address', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
35
-
36
- $installer->addAttribute('quote_address', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
37
- $installer->addAttribute('quote_address', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
38
-
39
- $installer->addAttribute('quote_address', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
40
- $installer->addAttribute('quote_address', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
41
-
42
- $installer->addAttribute('quote_address', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
43
- $installer->addAttribute('quote_address', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
44
-
45
- $installer->addAttribute('quote_address', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
46
- $installer->addAttribute('quote_address', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
47
-
48
- // Table: sales_flat_quote_item
49
-
50
- $installer->addAttribute('quote_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
51
- $installer->addAttribute('quote_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
52
- $installer->addAttribute('quote_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
53
- $installer->addAttribute('quote_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
54
- $installer->addAttribute('quote_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
55
- $installer->addAttribute('quote_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
56
-
57
- $installer->addAttribute('quote_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
58
- $installer->addAttribute('quote_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
59
- $installer->addAttribute('quote_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
60
- $installer->addAttribute('quote_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
61
- $installer->addAttribute('quote_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
62
- $installer->addAttribute('quote_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
63
- $installer->addAttribute('quote_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
64
-
65
- $installer->addAttribute('quote_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
66
- $installer->addAttribute('quote_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
67
- $installer->addAttribute('quote_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
68
- $installer->addAttribute('quote_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
69
- $installer->addAttribute('quote_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
70
- $installer->addAttribute('quote_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
71
- $installer->addAttribute('quote_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
72
-
73
-
74
- // Table: sales_flat_order_item
75
-
76
- $installer->addAttribute('order_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
77
- $installer->addAttribute('order_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
78
- $installer->addAttribute('order_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
79
- $installer->addAttribute('order_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
80
- $installer->addAttribute('order_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
81
- $installer->addAttribute('order_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
82
-
83
- $installer->addAttribute('order_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
84
- $installer->addAttribute('order_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
85
- $installer->addAttribute('order_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
86
- $installer->addAttribute('order_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
87
- $installer->addAttribute('order_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
88
- $installer->addAttribute('order_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
89
- $installer->addAttribute('order_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
90
-
91
- $installer->addAttribute('order_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
92
- $installer->addAttribute('order_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
93
- $installer->addAttribute('order_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
94
- $installer->addAttribute('order_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
95
- $installer->addAttribute('order_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
96
- $installer->addAttribute('order_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
97
- $installer->addAttribute('order_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
98
-
99
-
100
- // Table: sales_flat_order
101
-
102
- $installer->addAttribute('order', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
103
- $installer->addAttribute('order', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
104
- $installer->addAttribute('order', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
105
- $installer->addAttribute('order', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
106
-
107
- $installer->addAttribute('order', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
108
- $installer->addAttribute('order', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
109
-
110
- $installer->addAttribute('order', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
111
- $installer->addAttribute('order', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
112
-
113
- $installer->addAttribute('order', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
114
- $installer->addAttribute('order', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
115
-
116
- $installer->addAttribute('order', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
117
- $installer->addAttribute('order', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
118
-
119
- $installer->addAttribute('order', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
120
- $installer->addAttribute('order', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
121
-
122
- $installer->addAttribute('order', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
123
- $installer->addAttribute('order', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
124
-
125
- $installer->addAttribute('order', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
126
- $installer->addAttribute('order', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
127
-
128
- $installer->addAttribute('order', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
129
- $installer->addAttribute('order', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
130
-
131
- $installer->addAttribute('order', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
132
- $installer->addAttribute('order', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
133
-
134
- $installer->addAttribute('order', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
135
- $installer->addAttribute('order', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
136
-
137
-
138
- $installer->endSetup();
1
+ <?php
2
+
3
+ echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";
4
+
5
+
6
+ // @note: Force Table entities created!
7
+
8
+ $installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
9
+ $installer->startSetup();
10
+
11
+ // Table: sales_flat_quote_address
12
+
13
+ $installer->addAttribute('quote_address', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
14
+ $installer->addAttribute('quote_address', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
15
+ $installer->addAttribute('quote_address', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
16
+ $installer->addAttribute('quote_address', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
17
+
18
+ $installer->addAttribute('quote_address', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
19
+ $installer->addAttribute('quote_address', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
20
+
21
+ $installer->addAttribute('quote_address', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
22
+ $installer->addAttribute('quote_address', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
23
+
24
+ $installer->addAttribute('quote_address', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
25
+ $installer->addAttribute('quote_address', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
26
+
27
+ $installer->addAttribute('quote_address', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
28
+ $installer->addAttribute('quote_address', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
29
+
30
+ $installer->addAttribute('quote_address', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
31
+ $installer->addAttribute('quote_address', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
32
+
33
+ $installer->addAttribute('quote_address', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
34
+ $installer->addAttribute('quote_address', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
35
+
36
+ $installer->addAttribute('quote_address', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
37
+ $installer->addAttribute('quote_address', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
38
+
39
+ $installer->addAttribute('quote_address', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
40
+ $installer->addAttribute('quote_address', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
41
+
42
+ $installer->addAttribute('quote_address', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
43
+ $installer->addAttribute('quote_address', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
44
+
45
+ $installer->addAttribute('quote_address', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
46
+ $installer->addAttribute('quote_address', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
47
+
48
+ // Table: sales_flat_quote_item
49
+
50
+ $installer->addAttribute('quote_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
51
+ $installer->addAttribute('quote_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
52
+ $installer->addAttribute('quote_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
53
+ $installer->addAttribute('quote_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
54
+ $installer->addAttribute('quote_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
55
+ $installer->addAttribute('quote_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
56
+
57
+ $installer->addAttribute('quote_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
58
+ $installer->addAttribute('quote_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
59
+ $installer->addAttribute('quote_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
60
+ $installer->addAttribute('quote_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
61
+ $installer->addAttribute('quote_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
62
+ $installer->addAttribute('quote_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
63
+ $installer->addAttribute('quote_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
64
+
65
+ $installer->addAttribute('quote_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
66
+ $installer->addAttribute('quote_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
67
+ $installer->addAttribute('quote_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
68
+ $installer->addAttribute('quote_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
69
+ $installer->addAttribute('quote_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
70
+ $installer->addAttribute('quote_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
71
+ $installer->addAttribute('quote_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
72
+
73
+
74
+ // Table: sales_flat_order_item
75
+
76
+ $installer->addAttribute('order_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
77
+ $installer->addAttribute('order_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
78
+ $installer->addAttribute('order_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
79
+ $installer->addAttribute('order_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
80
+ $installer->addAttribute('order_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
81
+ $installer->addAttribute('order_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
82
+
83
+ $installer->addAttribute('order_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
84
+ $installer->addAttribute('order_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
85
+ $installer->addAttribute('order_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
86
+ $installer->addAttribute('order_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
87
+ $installer->addAttribute('order_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
88
+ $installer->addAttribute('order_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
89
+ $installer->addAttribute('order_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
90
+
91
+ $installer->addAttribute('order_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
92
+ $installer->addAttribute('order_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
93
+ $installer->addAttribute('order_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
94
+ $installer->addAttribute('order_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
95
+ $installer->addAttribute('order_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
96
+ $installer->addAttribute('order_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
97
+ $installer->addAttribute('order_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
98
+
99
+
100
+ // Table: sales_flat_order
101
+
102
+ $installer->addAttribute('order', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
103
+ $installer->addAttribute('order', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
104
+ $installer->addAttribute('order', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
105
+ $installer->addAttribute('order', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
106
+
107
+ $installer->addAttribute('order', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
108
+ $installer->addAttribute('order', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
109
+
110
+ $installer->addAttribute('order', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
111
+ $installer->addAttribute('order', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
112
+
113
+ $installer->addAttribute('order', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
114
+ $installer->addAttribute('order', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
115
+
116
+ $installer->addAttribute('order', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
117
+ $installer->addAttribute('order', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
118
+
119
+ $installer->addAttribute('order', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
120
+ $installer->addAttribute('order', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
121
+
122
+ $installer->addAttribute('order', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
123
+ $installer->addAttribute('order', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
124
+
125
+ $installer->addAttribute('order', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
126
+ $installer->addAttribute('order', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
127
+
128
+ $installer->addAttribute('order', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
129
+ $installer->addAttribute('order', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
130
+
131
+ $installer->addAttribute('order', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
132
+ $installer->addAttribute('order', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
133
+
134
+ $installer->addAttribute('order', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
135
+ $installer->addAttribute('order', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
136
+
137
+
138
+ $installer->endSetup();
app/code/community/Skybox/Core/Exception.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Core
5
- *
6
- * @category Skybox
7
- * @package Skybox_Core
8
- * @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
9
- */
10
-
11
- /**
12
- *
13
- * Exception
14
- *
15
- * @author César Tapia M. <ctapia@skyworldint.com>
16
- */
17
- class Skybox_Core_Exception extends Mage_Core_Exception{
18
-
19
- }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Core
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Core
8
+ * @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
9
+ */
10
+
11
+ /**
12
+ *
13
+ * Exception
14
+ *
15
+ * @author César Tapia M. <ctapia@skyworldint.com>
16
+ */
17
+ class Skybox_Core_Exception extends Mage_Core_Exception{
18
+
19
+ }
app/code/community/Skybox/Core/Helper/Allow.php CHANGED
@@ -1,236 +1,236 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Core
5
- *
6
- * @category Skybox
7
- * @package Skybox_Core
8
- * @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Core_Helper_Allow extends Mage_Core_Helper_Abstract
11
- {
12
- const TYPE_LOCATION_ALLOW_STORE = 1;
13
- const TYPE_LOCATION_ALLOW_CART_DISABLE = 0;
14
- const TYPE_LOCATION_ALLOW_CART_SHOW = 1;
15
- const TYPE_LOCATION_ALLOW_CART_HIDE = 3;
16
- const FULL_ACTION_NAME_IFRAME = 'skbcheckout_international_index';
17
-
18
- protected $_integrationType;
19
- protected $_locationAllow;
20
- protected $_actionName;
21
-
22
- public function isPriceEnabled()
23
- {
24
- if ($this->getTypeLocationAllow()
25
- == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
26
- ) {
27
- return true;
28
- } elseif ($this->getTypeLocationAllow()
29
- == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
30
- ) {
31
- return false;
32
- } elseif ($this->getTypeLocationAllow()
33
- == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
34
- ) {
35
- return false;
36
- } elseif ($this->getTypeLocationAllow()
37
- == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
38
- ) {
39
- return false;
40
- }
41
-
42
- return false;
43
- }
44
-
45
- public function isCartBarEnabled()
46
- {
47
- $fullActionName = $this->getFullActionName();
48
-
49
- if ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_SHOW
50
- && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE && $fullActionName != self::FULL_ACTION_NAME_IFRAME
51
- ) {
52
- return true;
53
- } elseif ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_SHOW
54
- && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE && $fullActionName == self::FULL_ACTION_NAME_IFRAME
55
- ) {
56
- return false;
57
- } elseif ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_SHOW
58
- && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
59
- ) {
60
- return false;
61
- } elseif ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_HIDE
62
- && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE && $fullActionName != self::FULL_ACTION_NAME_IFRAME
63
- ) {
64
- return false;
65
- } elseif ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_HIDE
66
- && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE && $fullActionName == self::FULL_ACTION_NAME_IFRAME
67
- ) {
68
- return true;
69
- } elseif ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_HIDE
70
- && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
71
- ) {
72
- return false;
73
- }
74
-
75
- return false;
76
- }
77
-
78
- public function isCartButtonEnabled()
79
- {
80
- if ($this->getTypeLocationAllow()
81
- == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
82
- ) {
83
- return true;
84
- } elseif ($this->getTypeLocationAllow()
85
- == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
86
- ) {
87
- return false;
88
- } elseif ($this->getTypeLocationAllow()
89
- == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
90
- ) {
91
- return false;
92
- } elseif ($this->getTypeLocationAllow()
93
- == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
94
- ) {
95
- return false;
96
- }
97
-
98
- return false;
99
- }
100
-
101
- public function isCartButtonSkyboxEnabled()
102
- {
103
- if ($this->getTypeLocationAllow()
104
- == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
105
- ) {
106
- return false;
107
- } elseif ($this->getTypeLocationAllow()
108
- == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
109
- ) {
110
- return false;
111
- } elseif ($this->getTypeLocationAllow()
112
- == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
113
- ) {
114
- return true;
115
- } elseif ($this->getTypeLocationAllow()
116
- == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
117
- ) {
118
- return false;
119
- }
120
-
121
- return false;
122
- }
123
-
124
- public function isChangeCountryEnabled()
125
- {
126
- if ($this->getTypeLocationAllow()
127
- == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
128
- ) {
129
- return true;
130
- } elseif ($this->getTypeLocationAllow()
131
- == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
132
- ) {
133
- return false;
134
- } elseif ($this->getTypeLocationAllow()
135
- == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
136
- ) {
137
- return false;
138
- } elseif ($this->getTypeLocationAllow()
139
- == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
140
- ) {
141
- return false;
142
- }
143
-
144
- return false;
145
- }
146
-
147
- public function isVisible()
148
- {
149
- return $this->getLocationAllow() != 0 ? true : false;
150
- }
151
-
152
- public function isOperationCartEnabled()
153
- {
154
- if ($this->getTypeLocationAllow()
155
- == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
156
- ) {
157
- return false;
158
- } elseif ($this->getTypeLocationAllow()
159
- == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
160
- ) {
161
- return true;
162
- } elseif ($this->getTypeLocationAllow()
163
- == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
164
- ) {
165
- return false;
166
- } elseif ($this->getTypeLocationAllow()
167
- == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
168
- ) {
169
- return false;
170
- }
171
-
172
- return false;
173
- }
174
-
175
- public function showSubtotal()
176
- {
177
- if ($this->getTypeLocationAllow()
178
- == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
179
- ) {
180
- return false;
181
- } elseif ($this->getTypeLocationAllow()
182
- == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
183
- ) {
184
- return true;
185
- } elseif ($this->getTypeLocationAllow()
186
- == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
187
- ) {
188
- return true;
189
- } elseif ($this->getTypeLocationAllow()
190
- == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
191
- ) {
192
- return true;
193
- }
194
-
195
- return true;
196
- }
197
-
198
- /*
199
- * Get Store Type Location
200
- */
201
- private function getTypeLocationAllow()
202
- {
203
- if ($this->_integrationType == null) {
204
- $integrationType = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
205
- $this->_integrationType = $integrationType;
206
- }
207
- return $this->_integrationType;
208
- }
209
-
210
- /*
211
- * Get LocationAllow
212
- */
213
- public function getLocationAllow()
214
- {
215
- if ($this->_locationAllow == null) {
216
- $_checkout = Mage::getModel('skyboxcheckout/api_checkout');
217
- $value = $_checkout->getLocationAllow();
218
- $value = isset($value) ? $value : 0;
219
- $this->_locationAllow = $value;
220
- }
221
- return $this->_locationAllow;
222
- }
223
-
224
- /*
225
- * Get FullActionName router name
226
- */
227
- private function getFullActionName()
228
- {
229
- $moduleName = Mage::app()->getRequest()->getModuleName();
230
- $controllerName = Mage::app()->getRequest()->getControllerName();
231
- $actionName = Mage::app()->getRequest()->getActionName();
232
-
233
- $result = $moduleName . "_" . $controllerName . "_" . $actionName;
234
- return $result;
235
- }
236
- }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Core
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Core
8
+ * @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Core_Helper_Allow extends Mage_Core_Helper_Abstract
11
+ {
12
+ const TYPE_LOCATION_ALLOW_STORE = 1;
13
+ const TYPE_LOCATION_ALLOW_CART_DISABLE = 0;
14
+ const TYPE_LOCATION_ALLOW_CART_SHOW = 1;
15
+ const TYPE_LOCATION_ALLOW_CART_HIDE = 3;
16
+ const FULL_ACTION_NAME_IFRAME = 'skbcheckout_international_index';
17
+
18
+ protected $_integrationType;
19
+ protected $_locationAllow;
20
+ protected $_actionName;
21
+
22
+ public function isPriceEnabled()
23
+ {
24
+ if ($this->getTypeLocationAllow()
25
+ == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
26
+ ) {
27
+ return true;
28
+ } elseif ($this->getTypeLocationAllow()
29
+ == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
30
+ ) {
31
+ return false;
32
+ } elseif ($this->getTypeLocationAllow()
33
+ == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
34
+ ) {
35
+ return false;
36
+ } elseif ($this->getTypeLocationAllow()
37
+ == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
38
+ ) {
39
+ return false;
40
+ }
41
+
42
+ return false;
43
+ }
44
+
45
+ public function isCartBarEnabled()
46
+ {
47
+ $fullActionName = $this->getFullActionName();
48
+
49
+ if ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_SHOW
50
+ && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE && $fullActionName != self::FULL_ACTION_NAME_IFRAME
51
+ ) {
52
+ return true;
53
+ } elseif ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_SHOW
54
+ && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE && $fullActionName == self::FULL_ACTION_NAME_IFRAME
55
+ ) {
56
+ return false;
57
+ } elseif ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_SHOW
58
+ && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
59
+ ) {
60
+ return false;
61
+ } elseif ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_HIDE
62
+ && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE && $fullActionName != self::FULL_ACTION_NAME_IFRAME
63
+ ) {
64
+ return false;
65
+ } elseif ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_HIDE
66
+ && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE && $fullActionName == self::FULL_ACTION_NAME_IFRAME
67
+ ) {
68
+ return true;
69
+ } elseif ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_HIDE
70
+ && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
71
+ ) {
72
+ return false;
73
+ }
74
+
75
+ return false;
76
+ }
77
+
78
+ public function isCartButtonEnabled()
79
+ {
80
+ if ($this->getTypeLocationAllow()
81
+ == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
82
+ ) {
83
+ return true;
84
+ } elseif ($this->getTypeLocationAllow()
85
+ == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
86
+ ) {
87
+ return false;
88
+ } elseif ($this->getTypeLocationAllow()
89
+ == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
90
+ ) {
91
+ return false;
92
+ } elseif ($this->getTypeLocationAllow()
93
+ == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
94
+ ) {
95
+ return false;
96
+ }
97
+
98
+ return false;
99
+ }
100
+
101
+ public function isCartButtonSkyboxEnabled()
102
+ {
103
+ if ($this->getTypeLocationAllow()
104
+ == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
105
+ ) {
106
+ return false;
107
+ } elseif ($this->getTypeLocationAllow()
108
+ == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
109
+ ) {
110
+ return false;
111
+ } elseif ($this->getTypeLocationAllow()
112
+ == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
113
+ ) {
114
+ return true;
115
+ } elseif ($this->getTypeLocationAllow()
116
+ == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
117
+ ) {
118
+ return false;
119
+ }
120
+
121
+ return false;
122
+ }
123
+
124
+ public function isChangeCountryEnabled()
125
+ {
126
+ if ($this->getTypeLocationAllow()
127
+ == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
128
+ ) {
129
+ return true;
130
+ } elseif ($this->getTypeLocationAllow()
131
+ == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
132
+ ) {
133
+ return false;
134
+ } elseif ($this->getTypeLocationAllow()
135
+ == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
136
+ ) {
137
+ return false;
138
+ } elseif ($this->getTypeLocationAllow()
139
+ == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
140
+ ) {
141
+ return false;
142
+ }
143
+
144
+ return false;
145
+ }
146
+
147
+ public function isVisible()
148
+ {
149
+ return $this->getLocationAllow() != 0 ? true : false;
150
+ }
151
+
152
+ public function isOperationCartEnabled()
153
+ {
154
+ if ($this->getTypeLocationAllow()
155
+ == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
156
+ ) {
157
+ return false;
158
+ } elseif ($this->getTypeLocationAllow()
159
+ == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
160
+ ) {
161
+ return true;
162
+ } elseif ($this->getTypeLocationAllow()
163
+ == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
164
+ ) {
165
+ return false;
166
+ } elseif ($this->getTypeLocationAllow()
167
+ == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
168
+ ) {
169
+ return false;
170
+ }
171
+
172
+ return false;
173
+ }
174
+
175
+ public function showSubtotal()
176
+ {
177
+ if ($this->getTypeLocationAllow()
178
+ == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
179
+ ) {
180
+ return false;
181
+ } elseif ($this->getTypeLocationAllow()
182
+ == self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
183
+ ) {
184
+ return true;
185
+ } elseif ($this->getTypeLocationAllow()
186
+ == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
187
+ ) {
188
+ return true;
189
+ } elseif ($this->getTypeLocationAllow()
190
+ == self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
191
+ ) {
192
+ return true;
193
+ }
194
+
195
+ return true;
196
+ }
197
+
198
+ /*
199
+ * Get Store Type Location
200
+ */
201
+ private function getTypeLocationAllow()
202
+ {
203
+ if ($this->_integrationType == null) {
204
+ $integrationType = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
205
+ $this->_integrationType = $integrationType;
206
+ }
207
+ return $this->_integrationType;
208
+ }
209
+
210
+ /*
211
+ * Get LocationAllow
212
+ */
213
+ public function getLocationAllow()
214
+ {
215
+ if ($this->_locationAllow == null) {
216
+ $_checkout = Mage::getModel('skyboxcheckout/api_checkout');
217
+ $value = $_checkout->getLocationAllow();
218
+ $value = isset($value) ? $value : 0;
219
+ $this->_locationAllow = $value;
220
+ }
221
+ return $this->_locationAllow;
222
+ }
223
+
224
+ /*
225
+ * Get FullActionName router name
226
+ */
227
+ private function getFullActionName()
228
+ {
229
+ $moduleName = Mage::app()->getRequest()->getModuleName();
230
+ $controllerName = Mage::app()->getRequest()->getControllerName();
231
+ $actionName = Mage::app()->getRequest()->getActionName();
232
+
233
+ $result = $moduleName . "_" . $controllerName . "_" . $actionName;
234
+ return $result;
235
+ }
236
+ }
app/code/community/Skybox/Core/Helper/Data.php CHANGED
@@ -1,12 +1,12 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Core
5
- *
6
- * @category Skybox
7
- * @package Skybox_Core
8
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Core_Helper_Data extends Mage_Core_Helper_Abstract
11
- {
12
  }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Core
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Core
8
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Core_Helper_Data extends Mage_Core_Helper_Abstract
11
+ {
12
  }
app/code/community/Skybox/Core/Helper/Email.php CHANGED
@@ -1,53 +1,53 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Core
5
- *
6
- * @category Skybox
7
- * @package Skybox_Core
8
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
-
11
- class Skybox_Core_Helper_Email extends Mage_Core_Helper_Abstract
12
- {
13
- public function sendException($message)
14
- {
15
- $storeName = "[" . Mage::app()->getStore()->getName() . "]";
16
- $subject = $storeName . " - Exception generated at " . strftime("%H:%M:%S", time());
17
- return $this->email($subject, $message);
18
- }
19
-
20
- public function sendAPIError($message)
21
- {
22
- $storeName = "[" . Mage::app()->getStore()->getName() . "]";
23
- $subject = $storeName . " - Error trying to connect to API at " . strftime("%H:%M:%S", time());
24
- return $this->email($subject, $message);
25
- }
26
-
27
- public function email($subject, $body)
28
- {
29
- $skybox_email = Mage::helper('skyboxinternational/data')->getSkyboxEmail();
30
-
31
- if (!$skybox_email) {
32
- return false;
33
- }
34
-
35
- /* @var $mail Mage_Core_Model_Email */
36
- $mail = Mage::getModel('core/email');
37
- $mail->setToName('Magento Store');
38
- $mail->setToEmail($skybox_email);
39
- $mail->setBody($body);
40
- $mail->setSubject($subject);
41
- $mail->setFromEmail($skybox_email);
42
- $mail->setFromName('Magento Store');
43
- $mail->setType('text');
44
-
45
- try {
46
- $myEmail = $mail->send();
47
- Mage::log($myEmail);
48
- Mage::log('SkyboxCheckout: Your request email has been sent');
49
- } catch (Exception $e) {
50
- Mage::log('SkyboxCheckout: Unable to send');
51
- }
52
- }
53
  }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Core
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Core
8
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+
11
+ class Skybox_Core_Helper_Email extends Mage_Core_Helper_Abstract
12
+ {
13
+ public function sendException($message)
14
+ {
15
+ $storeName = "[" . Mage::app()->getStore()->getName() . "]";
16
+ $subject = $storeName . " - Exception generated at " . strftime("%H:%M:%S", time());
17
+ return $this->email($subject, $message);
18
+ }
19
+
20
+ public function sendAPIError($message)
21
+ {
22
+ $storeName = "[" . Mage::app()->getStore()->getName() . "]";
23
+ $subject = $storeName . " - Error trying to connect to API at " . strftime("%H:%M:%S", time());
24
+ return $this->email($subject, $message);
25
+ }
26
+
27
+ public function email($subject, $body)
28
+ {
29
+ $skybox_email = Mage::helper('skyboxinternational/data')->getSkyboxEmail();
30
+
31
+ if (!$skybox_email) {
32
+ return false;
33
+ }
34
+
35
+ /* @var $mail Mage_Core_Model_Email */
36
+ $mail = Mage::getModel('core/email');
37
+ $mail->setToName('Magento Store');
38
+ $mail->setToEmail($skybox_email);
39
+ $mail->setBody($body);
40
+ $mail->setSubject($subject);
41
+ $mail->setFromEmail($skybox_email);
42
+ $mail->setFromName('Magento Store');
43
+ $mail->setType('text');
44
+
45
+ try {
46
+ $myEmail = $mail->send();
47
+ Mage::log($myEmail);
48
+ Mage::log('SkyboxCheckout: Your request email has been sent');
49
+ } catch (Exception $e) {
50
+ Mage::log('SkyboxCheckout: Unable to send');
51
+ }
52
+ }
53
  }
app/code/community/Skybox/Core/Model/Api/Abstract.php CHANGED
@@ -1,440 +1,440 @@
1
- <?php
2
- /**
3
- * Skybox Checkout
4
- *
5
- * @category Mage
6
- * @package Skybox_Core
7
- * @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
8
- */
9
-
10
- /**
11
- * SkyBox API - Abstract Class
12
- */
13
- class Skybox_Core_Model_Api_Abstract extends Varien_Object
14
- {
15
- /**
16
- * Config instance
17
- * @var Skybox_Core_Model_Config
18
- */
19
- protected $_config = null;
20
-
21
- /**
22
- * Respuesta de api
23
- * @var string
24
- */
25
- protected $_response = null;
26
-
27
- /**
28
- * Solicitud de api
29
- * @var string
30
- */
31
- protected $_request = null;
32
-
33
- /**
34
- * Código de metodo actual
35
- * @var string
36
- */
37
- protected $_methodCode = null;
38
-
39
- /**
40
- * Código de metodo actual
41
- * @var array()
42
- */
43
- protected $_params = null;
44
-
45
- /*
46
- * @var string
47
- */
48
- protected $_status_code = null;
49
-
50
- /**
51
- * Seteamos la instancia Config
52
- * @param Skybox_Core_Model_Config $config
53
- * @return Skybox_Core_Model_Api_Abstract
54
- */
55
- public function setConfigObject(Skybox_Core_Model_Config $config)
56
- {
57
- $this->_config = $config;
58
- return $this;
59
- }
60
-
61
- public function setStatusCode($value)
62
- {
63
- $this->_status_code = $value;
64
- }
65
-
66
- public function getStatusCode()
67
- {
68
- //Mage::log("Error:" . $this->gerResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_STATUS});
69
- //return $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_STATUS};
70
- return $this->_status_code;
71
- }
72
-
73
- public function getStatusMessage()
74
- {
75
- return $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_MESSAGE};
76
- }
77
-
78
- /**
79
- * Seteamos la respuesta del api
80
- * @param string $response
81
- * @return Skybox_Core_Model_Api_Abstract
82
- */
83
- public function setResponse($response)
84
- {
85
- //Mage::log('setResponse->' . $response);
86
- if (!empty($response)) {
87
- $this->_response = $response;
88
- }
89
- return $this;
90
- }
91
-
92
- public function getResponse()
93
- {
94
- return $this->_response;
95
- }
96
-
97
- public function getResponseJson()
98
- {
99
- //Mage::log('gerResponseJson->' . $this->_response);
100
- return json_decode($this->_response);
101
- }
102
-
103
- /**
104
- * Setea url de llamda al ApiRest con sus parametros
105
- * @param String $action
106
- * @param Array $params
107
- * @return Skybox_Core_Model_Api_Abstract
108
- */
109
- protected function setUrlService($method, $params)
110
- {
111
- $this->_methodCode = $method;
112
- $paramsRequest = '';
113
- if (!empty($params)) {
114
- $paramsRequest = '?' . http_build_query($params);
115
- }
116
- //$this->_request = $this->_config->skyboxDefaultApiUrl . $method . $paramsRequest;
117
- $this->_request = $this->_config->getSkyBoxUrlAPI() . $method . $paramsRequest;
118
- return $this;
119
- }
120
-
121
- /**
122
- * Retorna la url de llamada al servicio
123
- * @return String
124
- */
125
- public function getUrlService()
126
- {
127
- Mage::log(" | getUrlService | " . $this->_request);
128
- return $this->_request;
129
- }
130
-
131
- /**
132
- * Obtenemos el objeto Session
133
- * @return Skybox_Core_Model_Session
134
- */
135
- public function getSession()
136
- {
137
- return Mage::getSingleton('skybox/session');
138
- }
139
-
140
- /**
141
- * Obtenemos el objeto Cookie
142
- * @return Mage_Core_Model_Cookie
143
- */
144
- public function getCookie()
145
- {
146
- return Mage::getModel('core/cookie');
147
- }
148
-
149
- /**
150
- * Obtenemos el objeto Http
151
- * @return Mage_Core_Helper_Http
152
- */
153
- public function getHttp()
154
- {
155
- return Mage::helper('core/http');
156
- }
157
-
158
- /**
159
- * Current locale code getter
160
- *
161
- * @return string
162
- */
163
- public function getLocaleCode()
164
- {
165
- return Mage::app()->getLocale()->getLocaleCode();
166
- }
167
-
168
- /**
169
- * Obtenemos inforamción del navegador del cliente
170
- * @return HTTP_USER_AGENT
171
- */
172
- public function getUserAgent()
173
- {
174
- return $this->getHttp()->getHttpUserAgent();
175
- }
176
-
177
- /**
178
- * Obtenemos la Ip Local Remota del Cliente
179
- * @return REMOTE_ADDR
180
- */
181
- public function getRemoteAddr()
182
- {
183
- return $_SERVER['REMOTE_ADDR'];
184
- //return $this->getHttp()->getRemoteAddr();
185
- }
186
-
187
- /**
188
- * Obtenemos la Ip Proxy del Client
189
- * @return HTTP_VIA or HTTP_X_FORWARDED_FOR
190
- */
191
- public function getProxy()
192
- {
193
- return $_SERVER['HTTP_X_FORWARDED_FOR'];
194
- }
195
-
196
- /**
197
- * Obtenemos la Ip Local del Cliente
198
- * @return String
199
- */
200
- public function getHost()
201
- {
202
- return $this->getHttp()->getHttpHost();
203
- }
204
-
205
- /**
206
- * Obtenemos el lenguaje del Navegador del Cliente
207
- */
208
- public function getLanguage()
209
- {
210
- return $this->getHttp()->getHttpAcceptLanguage();
211
- }
212
-
213
- /**
214
- * Sección de Validaciones
215
- */
216
-
217
- /**
218
- * Valida que no exista ningun error
219
- * @return bool
220
- */
221
- public function HasError()
222
- {
223
- /*if($this->ErrorService()) return true;
224
- if($this->ErrorKeyInvalid()) return true;
225
- if($this->ErrorIpNoAllow()) return true;
226
- if($this->ErrorMerchantInvalid()) return true;
227
- if($this->ErrorGuidInvalid()) return true;
228
- if($this->ErrorTokenInvalid()) return true;
229
- if($this->ErrorToAddProductToCart()) return true;*/
230
-
231
- if ($this->ErrorRatesNotFound()) {
232
- return true;
233
- }
234
-
235
- if ($this->ErrorServiceNotController()) {
236
- return true;
237
- }
238
-
239
- if ($this->ErrorIpNoAllow()) {
240
- return true;
241
- }
242
- if ($this->ErrorIdMerchantInvalid()) {
243
- return true;
244
- }
245
- if ($this->ErrorGuidInvalid()) {
246
- return true;
247
- }
248
- if ($this->ErrorTokenExpired()) {
249
- return true;
250
- }
251
- if ($this->ErrorToAddProductToCart()) {
252
- return true;
253
- }
254
- if ($this->ErrorMerchantNotConfigured()) {
255
- return true;
256
- }
257
- if ($this->ErrorProductCategoryRequired()) {
258
- return true;
259
- }
260
- if ($this->ErrorProductUnitWeigthRequired()) {
261
- return true;
262
- }
263
- if ($this->ErrorProductWeigthInvalid()) {
264
- return true;
265
- }
266
- if ($this->ErrorProductWeigthIsnull()) {
267
- return true;
268
- }
269
- if ($this->ErrorProductUnitWeightInvalid()) {
270
- return true;
271
- }
272
- if ($this->ErrorStoreCityNotConfigured()) {
273
- return true;
274
- }
275
-
276
- if ($this->ErrorTokenIsnull()) {
277
- return true;
278
- }
279
- if ($this->ErrorGuidIsnull()) {
280
- return true;
281
- }
282
- if ($this->ErrorRegionNotConfigured()) {
283
- return true;
284
- }
285
- if ($this->ErrorProductNameRequiered()) {
286
- return true;
287
- }
288
- if ($this->ErrorProductCodeRequiered()) {
289
- return true;
290
- }
291
-
292
- if ($this->ErrorMerchantKeyIsnull()) {
293
- return true;
294
- }
295
- if ($this->ErrorMerchantKeyInvalid()) {
296
- return true;
297
- }
298
-
299
- return false;
300
-
301
- }
302
-
303
- /**
304
- * Valida si se devolvio un error por Merchant invalido
305
- * @return bool
306
- */
307
- public function ErrorIdMerchantInvalid()
308
- {
309
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_IDMERCHANT_INVALID;
310
- }
311
-
312
- public function ErrorMerchantNotConfigured()
313
- {
314
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_COUNTRY_NOT_CONFIGURED_TO_STORE;
315
- }
316
-
317
- /**
318
- * Valida si se devolvio un error por Guid invalido
319
- * @return bool
320
- */
321
- public function ErrorGuidInvalid()
322
- {
323
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_DEVICE_GUID_INVALID;
324
- }
325
-
326
- /**
327
- * Valida si se devolvio un error por Token invalido
328
- * @return bool
329
- */
330
- public function ErrorTokenExpired()
331
- {
332
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_TOKEN_EXPIRED;
333
- }
334
-
335
- /**
336
- * Valida si se devolvio un error de agregación de producto al carrito de compras
337
- * @return bool
338
- */
339
- public function ErrorToAddProductToCart()
340
- {
341
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_NOT_IN_SHOPPING_CART;
342
- }
343
-
344
- /**
345
- * Valida si se devolvio un error no controlado la respuesta del servicio
346
- * @return bool
347
- */
348
- public function ErrorServiceNotController()
349
- {
350
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_SERVICE_NOT_CONTROLLER;
351
- }
352
-
353
-
354
- public function ErrorIpNoAllow()
355
- {
356
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_IP_NOT_ALLOWED;
357
- }
358
-
359
- public function ErrorProductCategoryRequired()
360
- {
361
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_CATEGORY_INVALID;
362
- }
363
-
364
- public function ErrorProductUnitWeigthRequired()
365
- {
366
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_UNITWEIGHT_IS_NULL;
367
- }
368
-
369
- public function ErrorProductWeigthInvalid()
370
- {
371
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_WEIGHT_INVALID;
372
- }
373
-
374
- public function ErrorProductWeigthIsnull()
375
- {
376
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_WEIGHT_IS_NULL;
377
- }
378
-
379
- public function ErrorProductUnitWeightInvalid()
380
- {
381
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_UNITWEIGHT_INVALID;
382
- }
383
-
384
- public function ErrorStoreCityNotConfigured()
385
- {
386
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_STORE_CITY_NOT_CONFIGURED;
387
- }
388
-
389
- public function ErrorTokenIsnull()
390
- {
391
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_TOKEN_IS_NULL;
392
- }
393
-
394
- public function ErrorGuidIsnull()
395
- {
396
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_GUID_IS_NULL;
397
- }
398
-
399
- public function ErrorRegionNotConfigured()
400
- {
401
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_REGION_NOT_CONFIGURED_TO_STORE;
402
- }
403
-
404
- public function ErrorProductNameRequiered()
405
- {
406
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_NAME_IS_NULL;
407
- }
408
-
409
- public function ErrorProductCodeRequiered()
410
- {
411
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_CODE_IS_NULL;
412
- }
413
-
414
- public function ErrorMerchantKeyInvalid()
415
- {
416
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_MERCHANT_KEY_INVALID;
417
- }
418
-
419
- public function ErrorMerchantKeyIsnull()
420
- {
421
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_MERCHANT_KEY_IS_NULL;
422
- }
423
-
424
- public function ErrorRatesNotFound()
425
- {
426
- return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_RATES_NOT_FOUND;
427
- }
428
-
429
- // @todo: Improved message exceptions
430
- public function getErrorRatesNotFoundMessage($id = 0)
431
- {
432
- $languages = array(
433
- 0 => "U.S. Orders Only",
434
- 1 => "U.S. Orders Only",
435
- 2 => "Restringido fuera de USA",
436
- 3 => "Restringido fuera de USA",
437
- );
438
- return $languages[$id];
439
- }
440
- }
1
+ <?php
2
+ /**
3
+ * Skybox Checkout
4
+ *
5
+ * @category Mage
6
+ * @package Skybox_Core
7
+ * @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
8
+ */
9
+
10
+ /**
11
+ * SkyBox API - Abstract Class
12
+ */
13
+ class Skybox_Core_Model_Api_Abstract extends Varien_Object
14
+ {
15
+ /**
16
+ * Config instance
17
+ * @var Skybox_Core_Model_Config
18
+ */
19
+ protected $_config = null;
20
+
21
+ /**
22
+ * Respuesta de api
23
+ * @var string
24
+ */
25
+ protected $_response = null;
26
+
27
+ /**
28
+ * Solicitud de api
29
+ * @var string
30
+ */
31
+ protected $_request = null;
32
+
33
+ /**
34
+ * Código de metodo actual
35
+ * @var string
36
+ */
37
+ protected $_methodCode = null;
38
+
39
+ /**
40
+ * Código de metodo actual
41
+ * @var array()
42
+ */
43
+ protected $_params = null;
44
+
45
+ /*
46
+ * @var string
47
+ */
48
+ protected $_status_code = null;
49
+
50
+ /**
51
+ * Seteamos la instancia Config
52
+ * @param Skybox_Core_Model_Config $config
53
+ * @return Skybox_Core_Model_Api_Abstract
54
+ */
55
+ public function setConfigObject(Skybox_Core_Model_Config $config)
56
+ {
57
+ $this->_config = $config;
58
+ return $this;
59
+ }
60
+
61
+ public function setStatusCode($value)
62
+ {
63
+ $this->_status_code = $value;
64
+ }
65
+
66
+ public function getStatusCode()
67
+ {
68
+ //Mage::log("Error:" . $this->gerResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_STATUS});
69
+ //return $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_STATUS};
70
+ return $this->_status_code;
71
+ }
72
+
73
+ public function getStatusMessage()
74
+ {
75
+ return $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_MESSAGE};
76
+ }
77
+
78
+ /**
79
+ * Seteamos la respuesta del api
80
+ * @param string $response
81
+ * @return Skybox_Core_Model_Api_Abstract
82
+ */
83
+ public function setResponse($response)
84
+ {
85
+ //Mage::log('setResponse->' . $response);
86
+ if (!empty($response)) {
87
+ $this->_response = $response;
88
+ }
89
+ return $this;
90
+ }
91
+
92
+ public function getResponse()
93
+ {
94
+ return $this->_response;
95
+ }
96
+
97
+ public function getResponseJson()
98
+ {
99
+ //Mage::log('gerResponseJson->' . $this->_response);
100
+ return json_decode($this->_response);
101
+ }
102
+
103
+ /**
104
+ * Setea url de llamda al ApiRest con sus parametros
105
+ * @param String $action
106
+ * @param Array $params
107
+ * @return Skybox_Core_Model_Api_Abstract
108
+ */
109
+ protected function setUrlService($method, $params)
110
+ {
111
+ $this->_methodCode = $method;
112
+ $paramsRequest = '';
113
+ if (!empty($params)) {
114
+ $paramsRequest = '?' . http_build_query($params);
115
+ }
116
+ //$this->_request = $this->_config->skyboxDefaultApiUrl . $method . $paramsRequest;
117
+ $this->_request = $this->_config->getSkyBoxUrlAPI() . $method . $paramsRequest;
118
+ return $this;
119
+ }
120
+
121
+ /**
122
+ * Retorna la url de llamada al servicio
123
+ * @return String
124
+ */
125
+ public function getUrlService()
126
+ {
127
+ Mage::log(" | getUrlService | " . $this->_request);
128
+ return $this->_request;
129
+ }
130
+
131
+ /**
132
+ * Obtenemos el objeto Session
133
+ * @return Skybox_Core_Model_Session
134
+ */
135
+ public function getSession()
136
+ {
137
+ return Mage::getSingleton('skybox/session');
138
+ }
139
+
140
+ /**
141
+ * Obtenemos el objeto Cookie
142
+ * @return Mage_Core_Model_Cookie
143
+ */
144
+ public function getCookie()
145
+ {
146
+ return Mage::getModel('core/cookie');
147
+ }
148
+
149
+ /**
150
+ * Obtenemos el objeto Http
151
+ * @return Mage_Core_Helper_Http
152
+ */
153
+ public function getHttp()
154
+ {
155
+ return Mage::helper('core/http');
156
+ }
157
+
158
+ /**
159
+ * Current locale code getter
160
+ *
161
+ * @return string
162
+ */
163
+ public function getLocaleCode()
164
+ {
165
+ return Mage::app()->getLocale()->getLocaleCode();
166
+ }
167
+
168
+ /**
169
+ * Obtenemos inforamción del navegador del cliente
170
+ * @return HTTP_USER_AGENT
171
+ */
172
+ public function getUserAgent()
173
+ {
174
+ return $this->getHttp()->getHttpUserAgent();
175
+ }
176
+
177
+ /**
178
+ * Obtenemos la Ip Local Remota del Cliente
179
+ * @return REMOTE_ADDR
180
+ */
181
+ public function getRemoteAddr()
182
+ {
183
+ return $_SERVER['REMOTE_ADDR'];
184
+ //return $this->getHttp()->getRemoteAddr();
185
+ }
186
+
187
+ /**
188
+ * Obtenemos la Ip Proxy del Client
189
+ * @return HTTP_VIA or HTTP_X_FORWARDED_FOR
190
+ */
191
+ public function getProxy()
192
+ {
193
+ return $_SERVER['HTTP_X_FORWARDED_FOR'];
194
+ }
195
+
196
+ /**
197
+ * Obtenemos la Ip Local del Cliente
198
+ * @return String
199
+ */
200
+ public function getHost()
201
+ {
202
+ return $this->getHttp()->getHttpHost();
203
+ }
204
+
205
+ /**
206
+ * Obtenemos el lenguaje del Navegador del Cliente
207
+ */
208
+ public function getLanguage()
209
+ {
210
+ return $this->getHttp()->getHttpAcceptLanguage();
211
+ }
212
+
213
+ /**
214
+ * Sección de Validaciones
215
+ */
216
+
217
+ /**
218
+ * Valida que no exista ningun error
219
+ * @return bool
220
+ */
221
+ public function HasError()
222
+ {
223
+ /*if($this->ErrorService()) return true;
224
+ if($this->ErrorKeyInvalid()) return true;
225
+ if($this->ErrorIpNoAllow()) return true;
226
+ if($this->ErrorMerchantInvalid()) return true;
227
+ if($this->ErrorGuidInvalid()) return true;
228
+ if($this->ErrorTokenInvalid()) return true;
229
+ if($this->ErrorToAddProductToCart()) return true;*/
230
+
231
+ if ($this->ErrorRatesNotFound()) {
232
+ return true;
233
+ }
234
+
235
+ if ($this->ErrorServiceNotController()) {
236
+ return true;
237
+ }
238
+
239
+ if ($this->ErrorIpNoAllow()) {
240
+ return true;
241
+ }
242
+ if ($this->ErrorIdMerchantInvalid()) {
243
+ return true;
244
+ }
245
+ if ($this->ErrorGuidInvalid()) {
246
+ return true;
247
+ }
248
+ if ($this->ErrorTokenExpired()) {
249
+ return true;
250
+ }
251
+ if ($this->ErrorToAddProductToCart()) {
252
+ return true;
253
+ }
254
+ if ($this->ErrorMerchantNotConfigured()) {
255
+ return true;
256
+ }
257
+ if ($this->ErrorProductCategoryRequired()) {
258
+ return true;
259
+ }
260
+ if ($this->ErrorProductUnitWeigthRequired()) {
261
+ return true;
262
+ }
263
+ if ($this->ErrorProductWeigthInvalid()) {
264
+ return true;
265
+ }
266
+ if ($this->ErrorProductWeigthIsnull()) {
267
+ return true;
268
+ }
269
+ if ($this->ErrorProductUnitWeightInvalid()) {
270
+ return true;
271
+ }
272
+ if ($this->ErrorStoreCityNotConfigured()) {
273
+ return true;
274
+ }
275
+
276
+ if ($this->ErrorTokenIsnull()) {
277
+ return true;
278
+ }
279
+ if ($this->ErrorGuidIsnull()) {
280
+ return true;
281
+ }
282
+ if ($this->ErrorRegionNotConfigured()) {
283
+ return true;
284
+ }
285
+ if ($this->ErrorProductNameRequiered()) {
286
+ return true;
287
+ }
288
+ if ($this->ErrorProductCodeRequiered()) {
289
+ return true;
290
+ }
291
+
292
+ if ($this->ErrorMerchantKeyIsnull()) {
293
+ return true;
294
+ }
295
+ if ($this->ErrorMerchantKeyInvalid()) {
296
+ return true;
297
+ }
298
+
299
+ return false;
300
+
301
+ }
302
+
303
+ /**
304
+ * Valida si se devolvio un error por Merchant invalido
305
+ * @return bool
306
+ */
307
+ public function ErrorIdMerchantInvalid()
308
+ {
309
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_IDMERCHANT_INVALID;
310
+ }
311
+
312
+ public function ErrorMerchantNotConfigured()
313
+ {
314
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_COUNTRY_NOT_CONFIGURED_TO_STORE;
315
+ }
316
+
317
+ /**
318
+ * Valida si se devolvio un error por Guid invalido
319
+ * @return bool
320
+ */
321
+ public function ErrorGuidInvalid()
322
+ {
323
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_DEVICE_GUID_INVALID;
324
+ }
325
+
326
+ /**
327
+ * Valida si se devolvio un error por Token invalido
328
+ * @return bool
329
+ */
330
+ public function ErrorTokenExpired()
331
+ {
332
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_TOKEN_EXPIRED;
333
+ }
334
+
335
+ /**
336
+ * Valida si se devolvio un error de agregación de producto al carrito de compras
337
+ * @return bool
338
+ */
339
+ public function ErrorToAddProductToCart()
340
+ {
341
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_NOT_IN_SHOPPING_CART;
342
+ }
343
+
344
+ /**
345
+ * Valida si se devolvio un error no controlado la respuesta del servicio
346
+ * @return bool
347
+ */
348
+ public function ErrorServiceNotController()
349
+ {
350
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_SERVICE_NOT_CONTROLLER;
351
+ }
352
+
353
+
354
+ public function ErrorIpNoAllow()
355
+ {
356
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_IP_NOT_ALLOWED;
357
+ }
358
+
359
+ public function ErrorProductCategoryRequired()
360
+ {
361
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_CATEGORY_INVALID;
362
+ }
363
+
364
+ public function ErrorProductUnitWeigthRequired()
365
+ {
366
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_UNITWEIGHT_IS_NULL;
367
+ }
368
+
369
+ public function ErrorProductWeigthInvalid()
370
+ {
371
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_WEIGHT_INVALID;
372
+ }
373
+
374
+ public function ErrorProductWeigthIsnull()
375
+ {
376
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_WEIGHT_IS_NULL;
377
+ }
378
+
379
+ public function ErrorProductUnitWeightInvalid()
380
+ {
381
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_UNITWEIGHT_INVALID;
382
+ }
383
+
384
+ public function ErrorStoreCityNotConfigured()
385
+ {
386
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_STORE_CITY_NOT_CONFIGURED;
387
+ }
388
+
389
+ public function ErrorTokenIsnull()
390
+ {
391
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_TOKEN_IS_NULL;
392
+ }
393
+
394
+ public function ErrorGuidIsnull()
395
+ {
396
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_GUID_IS_NULL;
397
+ }
398
+
399
+ public function ErrorRegionNotConfigured()
400
+ {
401
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_REGION_NOT_CONFIGURED_TO_STORE;
402
+ }
403
+
404
+ public function ErrorProductNameRequiered()
405
+ {
406
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_NAME_IS_NULL;
407
+ }
408
+
409
+ public function ErrorProductCodeRequiered()
410
+ {
411
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_CODE_IS_NULL;
412
+ }
413
+
414
+ public function ErrorMerchantKeyInvalid()
415
+ {
416
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_MERCHANT_KEY_INVALID;
417
+ }
418
+
419
+ public function ErrorMerchantKeyIsnull()
420
+ {
421
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_MERCHANT_KEY_IS_NULL;
422
+ }
423
+
424
+ public function ErrorRatesNotFound()
425
+ {
426
+ return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_RATES_NOT_FOUND;
427
+ }
428
+
429
+ // @todo: Improved message exceptions
430
+ public function getErrorRatesNotFoundMessage($id = 0)
431
+ {
432
+ $languages = array(
433
+ 0 => "U.S. Orders Only",
434
+ 1 => "U.S. Orders Only",
435
+ 2 => "Restringido fuera de USA",
436
+ 3 => "Restringido fuera de USA",
437
+ );
438
+ return $languages[$id];
439
+ }
440
+ }
app/code/community/Skybox/Core/Model/Api/Restful.php CHANGED
@@ -1,365 +1,365 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Core
5
- *
6
- * @category Skybox
7
- * @package Skybox_Core
8
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Core_Model_Api_Restful extends Skybox_Core_Model_Api_Abstract
11
- {
12
- public $_skybox_guid = "";
13
-
14
- /**
15
- * Guardamos en sesión el Html Template del Botón
16
- * @param string $value
17
- * @return Skybox_Core_Model_Api_Restful
18
- */
19
- public function setHtmlTemplateButton($value = null)
20
- {
21
- $html = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_BUTTONHTML};
22
- $htmlError = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_BUTTONERRORHTML};
23
- $this->_config->getSession()->setHtmlTemplateButton($html);
24
- $this->_config->getSession()->setHtmlTemplateButtonError($htmlError);
25
- return $this;
26
- }
27
-
28
- /**
29
- * Se recupera el Html Template del Botón almacenado en la sesión
30
- * @return String
31
- */
32
- public function getHtmlTemplateButton()
33
- {
34
- return $this->_config->getSession()->getHtmlTemplateButton();
35
- }
36
-
37
- /**
38
- * Guardamos en sesión el Html Template de la barra
39
- * @param string $value
40
- * @return Skybox_Core_Model_Api_Restful
41
- */
42
- public function setHtmlTemplateBar($value = null)
43
- {
44
- $html = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_BARHTML};
45
- $this->_config->getSession()->setHtmlTemplateBar($html);
46
- return $this;
47
- }
48
-
49
- /**
50
- * Se recupera el Html Template del Botón almacenado en la sesión
51
- * @return String
52
- */
53
- public function getHtmlTemplateBar()
54
- {
55
- return $this->_config->getSession()->getHtmlTemplateBar();
56
- }
57
-
58
- public function setGuidApi($value = null)
59
- {
60
- $guidId = null;
61
-
62
- if (!$guidId) {
63
- $guidId = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_GUID};
64
- Mage::log("GuidID Not cart: " . $guidId);
65
- }
66
-
67
- $this->_config->getSession()->setCookieGuid($guidId);
68
- $this->_skybox_guid = $guidId;
69
- Mage::log("GuidID found: " . $guidId);
70
- return $this;
71
- }
72
-
73
- // @todo Rewrite the way to get GUID
74
- public function getGuidApi()
75
- {
76
- $guidId = null;
77
-
78
- $quote = Mage::getSingleton('checkout/session')->getQuote();
79
- foreach ($quote->getAllItems() as $item) {
80
- $guidId = $item->getGuidSkybox();
81
- Mage::log(' | CallApiRest->Error1 | ', null, 'guid.log', true);
82
- Mage::log("getGuidApi(): GuidID found (quote): " . $guidId, null, 'guid.log', true);
83
- break;
84
- }
85
-
86
- if (!$guidId) {
87
- $skyboxSession = $this->_config->getSession()->getCookieGuid();
88
- if ($skyboxSession) {
89
- // Mage::log(' | CallApiRest->Error2 | ', null, 'guid.log', true);
90
- Mage::log("Call getGuidApi() from getSession(): " . $this->_config->getSession()->getCookieGuid(), null,
91
- 'guid.log', true);
92
- $guidId = $this->_config->getSession()->getCookieGuid();
93
- }
94
- }
95
- return $guidId;
96
- }
97
-
98
- public function compareGuid()
99
- {
100
- $already_guid = $this->getGuidApi();
101
- $called_guid = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_GUID};
102
-
103
- if ($already_guid == $called_guid) {
104
- return true;
105
- }
106
- return false;
107
- }
108
-
109
- /**
110
- * Seteamos si la localización del usuario esta permitida
111
- * @param string $value
112
- * @return Skybox_Core_Model_Api_Restful
113
- */
114
- public function setLocationAllow($value = null)
115
- {
116
- $allow = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_LOCATION_ALLOW};
117
- //$allow = 0; // Rogged
118
- $this->_config->getSession()->setLocationAllow($allow);
119
- return $this;
120
- }
121
-
122
-
123
- public function getLocationAllow()
124
- {
125
- return $this->_config->getSession()->getLocationAllow();
126
- }
127
-
128
- public function setStoreCode($value = null)
129
- {
130
- $storeCode = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_STORE_CODE};
131
- $storeCode = trim($storeCode);
132
- $this->_config->getSession()->setStoreCode($storeCode);
133
- return $storeCode;
134
- }
135
-
136
- public function getStoreCode()
137
- {
138
- return $this->_config->getSession()->getStoreCode();
139
- }
140
-
141
- public function setCssVersion($value = null)
142
- {
143
- $cssVersion = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_CSS_VERSION};
144
- $cssVersion = (isset($cssVersion)) ? trim($cssVersion) : 1;
145
- $this->_config->getSession()->setCssVersion($cssVersion);
146
- return $cssVersion;
147
- }
148
-
149
- public function getCssVersion()
150
- {
151
- return $this->_config->getSession()->getCssVersion();
152
- }
153
-
154
- /**
155
- * Seteamos error del servicio
156
- * @param string $value
157
- * @return Skybox_Core_Model_Api_Restful
158
- */
159
- public function setErrorAuthenticate()
160
- {
161
- $this->_config->getSession()->setErrorAuthenticate($this->HasError());
162
- return $this;
163
- }
164
-
165
- public function getErrorAuthenticate()
166
- {
167
- return $this->_config->getSession()->getErrorAuthenticate();
168
- }
169
-
170
- /**
171
- * Guardamos en sesión el token de autorización
172
- * @param string $value
173
- * @return Skybox_Core_Model_Api_Restful
174
- */
175
- public function setAuthorizedToken($value = null)
176
- {
177
- $token = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_TOKEN};
178
- Mage::log('setAuthorizedToken token skybox: ' . $token);
179
- // $token = urlencode($token);
180
- $this->_config->getSession()->setTokenApiRest($token);
181
- return $this;
182
- }
183
-
184
- /**
185
- * Obtenemos el token de autorización almacenado en sesión
186
- * @return string
187
- */
188
- public function getAuthorizedToken()
189
- {
190
- //return $this->_config->getSession()->getTokenApiRest() ?: "";
191
- $algo = $this->_config->getSession()->getTokenApiRest();
192
- if (!empty($algo)) {
193
- return $this->_config->getSession()->getTokenApiRest();
194
- }
195
- return "";
196
- }
197
-
198
- /**
199
- * Sección de llamadas a los metodos del ApiRest
200
- */
201
-
202
- /**
203
- * Se realiza llamado al metodo del Servicio y se guarda resultado
204
- * @return Skybox_Core_Model_Api_Restful
205
- */
206
- protected function SetResponseService()
207
- {
208
- //$this->_response = file_get_contents($this->getUrlService());
209
- $this->_response = $this->file_get_contents_curl($this->getUrlService());
210
- return $this;
211
- }
212
-
213
- /**
214
- * Invocamos al servicio
215
- * @return Skybox_Core_Model_Api_Standard
216
- */
217
- public function CallService($method, $params)
218
- {
219
- $params['platform'] = "magento-".Mage::getVersion();
220
- $params['version'] = "v.".Skybox_Core_Model_Config::SKYBOX_VERSION;
221
- $start_time = time();
222
- try {
223
- /**
224
- * Pasos
225
- * 1: Generamos la Url del Servicio
226
- * 2: Guardamos la solicitud que se realiza al servicio
227
- * 3: Invocamos al response del Servicio
228
- * 4: Asignamos valores a los parametros
229
- * 5: Guardamos la respuesta del servicio
230
- */
231
- $this->setUrlService($method, $params)
232
- ->SaveRequestService()
233
- ->SetResponseService()
234
- ->SetValuesResponse()
235
- ->SaveResponseService($method, $start_time);
236
- } catch (Exception $e) {
237
- //throw new Exception($e->getMessage(), 1);
238
- Mage::log($e->getMessage());
239
- Mage::helper('skyboxcore/email')->sendException($e->getMessage());
240
- return $this;
241
- }
242
-
243
- return $this;
244
- }
245
-
246
- /**
247
- * Seteamos valores a los parametros correspondientes a partir del methodo invocado
248
- * @return Skybox_Core_Model_Api_Restful
249
- */
250
- protected function SetValuesResponse()
251
- {
252
- $status = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_STATUS};
253
- $this->setStatusCode($status);
254
-
255
- switch ($this->_methodCode) {
256
- case Skybox_Core_Model_Config::SKYBOX_ACTION_AUTHENTICATE:
257
- $this->setAuthorizedToken();
258
- $this->setErrorAuthenticate();
259
- break;
260
-
261
- case Skybox_Core_Model_Config::SKYBOX_ACTION_INITIALICE:
262
- //$this->setGuidApi();
263
-
264
- if ($this->compareGuid() && $this->getGuidApi()) {
265
- $this->getGuidApi();
266
- } else {
267
- $this->setGuidApi();
268
- }
269
- $this->setLocationAllow();
270
- $this->setStoreCode();
271
- $this->setCssVersion();
272
- $this->setHtmlTemplateBar();
273
- break;
274
- case Skybox_Core_Model_Config::SKYBOX_ACTION_GET_TEMPLATE_BUTTON:
275
- $this->setHtmlTemplateButton();
276
- break;
277
- }
278
-
279
- return $this;
280
- }
281
-
282
-
283
-
284
- /**
285
- * Sesión de registro de log
286
- */
287
-
288
- /**
289
- * Se registra la llamada al servicio
290
- */
291
- public function SaveRequestService()
292
- {
293
- //Acciones
294
- return $this;
295
- }
296
-
297
- /**
298
- * SaveResponseService
299
- * Save Service Response
300
- *
301
- * @param string $action
302
- * @param string $start_time
303
- * @return Skybox_Core_Model_Api_Restful
304
- */
305
- public function SaveResponseService($action, $start_time)
306
- {
307
- $skybox_log = Mage::helper('skyboxinternational/data')->getSkyboxLog();
308
-
309
- if ($skybox_log) {
310
- $data = array(
311
- 'action' => $action,
312
- 'request' => $this->getUrlService(),
313
- 'response' => $this->getResponse(),
314
- 'timestamp_request' => $start_time,
315
- 'timestamp_response' => time(),
316
- );
317
-
318
- try {
319
- /* @var $log_service Skybox_Core_Model_Logservice */
320
- $log_service = Mage::getModel('skyboxcore/logservice');
321
- $log_service->setData($data);
322
- $log_service->save();
323
-
324
- } catch (Exception $e) {
325
- Mage::log($e->getMessage());
326
- }
327
- }
328
- return $this;
329
- }
330
-
331
- /*
332
- * file_get_contents_curl
333
- */
334
-
335
- function file_get_contents_curl($url)
336
- {
337
- if (!function_exists("curl_init")) {
338
- die("cURL extension is not installed");
339
- }
340
- $ch = curl_init();
341
- // Disable SSL verification
342
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
343
- // Will return the response, if false it print the response
344
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
345
- // To force the use of a new connection instead of a cached one
346
- //curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
347
- // Set the url
348
- curl_setopt($ch, CURLOPT_URL, $url);
349
- // Execute
350
- $result = curl_exec($ch);
351
-
352
- // Will dump a beauty json :3
353
- //var_dump(json_decode($result, true));
354
- return $result;
355
- }
356
-
357
- /**
358
- * Validad que el módulo de skybox este habilitado para la tienda
359
- * @return bool
360
- */
361
- public function isModuleEnable()
362
- {
363
- return (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
364
- }
365
- }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Core
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Core
8
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Core_Model_Api_Restful extends Skybox_Core_Model_Api_Abstract
11
+ {
12
+ public $_skybox_guid = "";
13
+
14
+ /**
15
+ * Guardamos en sesión el Html Template del Botón
16
+ * @param string $value
17
+ * @return Skybox_Core_Model_Api_Restful
18
+ */
19
+ public function setHtmlTemplateButton($value = null)
20
+ {
21
+ $html = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_BUTTONHTML};
22
+ $htmlError = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_BUTTONERRORHTML};
23
+ $this->_config->getSession()->setHtmlTemplateButton($html);
24
+ $this->_config->getSession()->setHtmlTemplateButtonError($htmlError);
25
+ return $this;
26
+ }
27
+
28
+ /**
29
+ * Se recupera el Html Template del Botón almacenado en la sesión
30
+ * @return String
31
+ */
32
+ public function getHtmlTemplateButton()
33
+ {
34
+ return $this->_config->getSession()->getHtmlTemplateButton();
35
+ }
36
+
37
+ /**
38
+ * Guardamos en sesión el Html Template de la barra
39
+ * @param string $value
40
+ * @return Skybox_Core_Model_Api_Restful
41
+ */
42
+ public function setHtmlTemplateBar($value = null)
43
+ {
44
+ $html = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_BARHTML};
45
+ $this->_config->getSession()->setHtmlTemplateBar($html);
46
+ return $this;
47
+ }
48
+
49
+ /**
50
+ * Se recupera el Html Template del Botón almacenado en la sesión
51
+ * @return String
52
+ */
53
+ public function getHtmlTemplateBar()
54
+ {
55
+ return $this->_config->getSession()->getHtmlTemplateBar();
56
+ }
57
+
58
+ public function setGuidApi($value = null)
59
+ {
60
+ $guidId = null;
61
+
62
+ if (!$guidId) {
63
+ $guidId = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_GUID};
64
+ Mage::log("GuidID Not cart: " . $guidId);
65
+ }
66
+
67
+ $this->_config->getSession()->setCookieGuid($guidId);
68
+ $this->_skybox_guid = $guidId;
69
+ Mage::log("GuidID found: " . $guidId);
70
+ return $this;
71
+ }
72
+
73
+ // @todo Rewrite the way to get GUID
74
+ public function getGuidApi()
75
+ {
76
+ $guidId = null;
77
+
78
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
79
+ foreach ($quote->getAllItems() as $item) {
80
+ $guidId = $item->getGuidSkybox();
81
+ Mage::log(' | CallApiRest->Error1 | ', null, 'guid.log', true);
82
+ Mage::log("getGuidApi(): GuidID found (quote): " . $guidId, null, 'guid.log', true);
83
+ break;
84
+ }
85
+
86
+ if (!$guidId) {
87
+ $skyboxSession = $this->_config->getSession()->getCookieGuid();
88
+ if ($skyboxSession) {
89
+ // Mage::log(' | CallApiRest->Error2 | ', null, 'guid.log', true);
90
+ Mage::log("Call getGuidApi() from getSession(): " . $this->_config->getSession()->getCookieGuid(), null,
91
+ 'guid.log', true);
92
+ $guidId = $this->_config->getSession()->getCookieGuid();
93
+ }
94
+ }
95
+ return $guidId;
96
+ }
97
+
98
+ public function compareGuid()
99
+ {
100
+ $already_guid = $this->getGuidApi();
101
+ $called_guid = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_GUID};
102
+
103
+ if ($already_guid == $called_guid) {
104
+ return true;
105
+ }
106
+ return false;
107
+ }
108
+
109
+ /**
110
+ * Seteamos si la localización del usuario esta permitida
111
+ * @param string $value
112
+ * @return Skybox_Core_Model_Api_Restful
113
+ */
114
+ public function setLocationAllow($value = null)
115
+ {
116
+ $allow = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_LOCATION_ALLOW};
117
+ //$allow = 0; // Rogged
118
+ $this->_config->getSession()->setLocationAllow($allow);
119
+ return $this;
120
+ }
121
+
122
+
123
+ public function getLocationAllow()
124
+ {
125
+ return $this->_config->getSession()->getLocationAllow();
126
+ }
127
+
128
+ public function setStoreCode($value = null)
129
+ {
130
+ $storeCode = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_STORE_CODE};
131
+ $storeCode = trim($storeCode);
132
+ $this->_config->getSession()->setStoreCode($storeCode);
133
+ return $storeCode;
134
+ }
135
+
136
+ public function getStoreCode()
137
+ {
138
+ return $this->_config->getSession()->getStoreCode();
139
+ }
140
+
141
+ public function setCssVersion($value = null)
142
+ {
143
+ $cssVersion = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_CSS_VERSION};
144
+ $cssVersion = (isset($cssVersion)) ? trim($cssVersion) : 1;
145
+ $this->_config->getSession()->setCssVersion($cssVersion);
146
+ return $cssVersion;
147
+ }
148
+
149
+ public function getCssVersion()
150
+ {
151
+ return $this->_config->getSession()->getCssVersion();
152
+ }
153
+
154
+ /**
155
+ * Seteamos error del servicio
156
+ * @param string $value
157
+ * @return Skybox_Core_Model_Api_Restful
158
+ */
159
+ public function setErrorAuthenticate()
160
+ {
161
+ $this->_config->getSession()->setErrorAuthenticate($this->HasError());
162
+ return $this;
163
+ }
164
+
165
+ public function getErrorAuthenticate()
166
+ {
167
+ return $this->_config->getSession()->getErrorAuthenticate();
168
+ }
169
+
170
+ /**
171
+ * Guardamos en sesión el token de autorización
172
+ * @param string $value
173
+ * @return Skybox_Core_Model_Api_Restful
174
+ */
175
+ public function setAuthorizedToken($value = null)
176
+ {
177
+ $token = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_TOKEN};
178
+ Mage::log('setAuthorizedToken token skybox: ' . $token);
179
+ // $token = urlencode($token);
180
+ $this->_config->getSession()->setTokenApiRest($token);
181
+ return $this;
182
+ }
183
+
184
+ /**
185
+ * Obtenemos el token de autorización almacenado en sesión
186
+ * @return string
187
+ */
188
+ public function getAuthorizedToken()
189
+ {
190
+ //return $this->_config->getSession()->getTokenApiRest() ?: "";
191
+ $algo = $this->_config->getSession()->getTokenApiRest();
192
+ if (!empty($algo)) {
193
+ return $this->_config->getSession()->getTokenApiRest();
194
+ }
195
+ return "";
196
+ }
197
+
198
+ /**
199
+ * Sección de llamadas a los metodos del ApiRest
200
+ */
201
+
202
+ /**
203
+ * Se realiza llamado al metodo del Servicio y se guarda resultado
204
+ * @return Skybox_Core_Model_Api_Restful
205
+ */
206
+ protected function SetResponseService()
207
+ {
208
+ //$this->_response = file_get_contents($this->getUrlService());
209
+ $this->_response = $this->file_get_contents_curl($this->getUrlService());
210
+ return $this;
211
+ }
212
+
213
+ /**
214
+ * Invocamos al servicio
215
+ * @return Skybox_Core_Model_Api_Standard
216
+ */
217
+ public function CallService($method, $params)
218
+ {
219
+ $params['platform'] = "magento-".Mage::getVersion();
220
+ $params['version'] = "v.".Skybox_Core_Model_Config::SKYBOX_VERSION;
221
+ $start_time = time();
222
+ try {
223
+ /**
224
+ * Pasos
225
+ * 1: Generamos la Url del Servicio
226
+ * 2: Guardamos la solicitud que se realiza al servicio
227
+ * 3: Invocamos al response del Servicio
228
+ * 4: Asignamos valores a los parametros
229
+ * 5: Guardamos la respuesta del servicio
230
+ */
231
+ $this->setUrlService($method, $params)
232
+ ->SaveRequestService()
233
+ ->SetResponseService()
234
+ ->SetValuesResponse()
235
+ ->SaveResponseService($method, $start_time);
236
+ } catch (Exception $e) {
237
+ //throw new Exception($e->getMessage(), 1);
238
+ Mage::log($e->getMessage());
239
+ Mage::helper('skyboxcore/email')->sendException($e->getMessage());
240
+ return $this;
241
+ }
242
+
243
+ return $this;
244
+ }
245
+
246
+ /**
247
+ * Seteamos valores a los parametros correspondientes a partir del methodo invocado
248
+ * @return Skybox_Core_Model_Api_Restful
249
+ */
250
+ protected function SetValuesResponse()
251
+ {
252
+ $status = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_STATUS};
253
+ $this->setStatusCode($status);
254
+
255
+ switch ($this->_methodCode) {
256
+ case Skybox_Core_Model_Config::SKYBOX_ACTION_AUTHENTICATE:
257
+ $this->setAuthorizedToken();
258
+ $this->setErrorAuthenticate();
259
+ break;
260
+
261
+ case Skybox_Core_Model_Config::SKYBOX_ACTION_INITIALICE:
262
+ //$this->setGuidApi();
263
+
264
+ if ($this->compareGuid() && $this->getGuidApi()) {
265
+ $this->getGuidApi();
266
+ } else {
267
+ $this->setGuidApi();
268
+ }
269
+ $this->setLocationAllow();
270
+ $this->setStoreCode();
271
+ $this->setCssVersion();
272
+ $this->setHtmlTemplateBar();
273
+ break;
274
+ case Skybox_Core_Model_Config::SKYBOX_ACTION_GET_TEMPLATE_BUTTON:
275
+ $this->setHtmlTemplateButton();
276
+ break;
277
+ }
278
+
279
+ return $this;
280
+ }
281
+
282
+
283
+
284
+ /**
285
+ * Sesión de registro de log
286
+ */
287
+
288
+ /**
289
+ * Se registra la llamada al servicio
290
+ */
291
+ public function SaveRequestService()
292
+ {
293
+ //Acciones
294
+ return $this;
295
+ }
296
+
297
+ /**
298
+ * SaveResponseService
299
+ * Save Service Response
300
+ *
301
+ * @param string $action
302
+ * @param string $start_time
303
+ * @return Skybox_Core_Model_Api_Restful
304
+ */
305
+ public function SaveResponseService($action, $start_time)
306
+ {
307
+ $skybox_log = Mage::helper('skyboxinternational/data')->getSkyboxLog();
308
+
309
+ if ($skybox_log) {
310
+ $data = array(
311
+ 'action' => $action,
312
+ 'request' => $this->getUrlService(),
313
+ 'response' => $this->getResponse(),
314
+ 'timestamp_request' => $start_time,
315
+ 'timestamp_response' => time(),
316
+ );
317
+
318
+ try {
319
+ /* @var $log_service Skybox_Core_Model_Logservice */
320
+ $log_service = Mage::getModel('skyboxcore/logservice');
321
+ $log_service->setData($data);
322
+ $log_service->save();
323
+
324
+ } catch (Exception $e) {
325
+ Mage::log($e->getMessage());
326
+ }
327
+ }
328
+ return $this;
329
+ }
330
+
331
+ /*
332
+ * file_get_contents_curl
333
+ */
334
+
335
+ function file_get_contents_curl($url)
336
+ {
337
+ if (!function_exists("curl_init")) {
338
+ die("cURL extension is not installed");
339
+ }
340
+ $ch = curl_init();
341
+ // Disable SSL verification
342
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
343
+ // Will return the response, if false it print the response
344
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
345
+ // To force the use of a new connection instead of a cached one
346
+ //curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
347
+ // Set the url
348
+ curl_setopt($ch, CURLOPT_URL, $url);
349
+ // Execute
350
+ $result = curl_exec($ch);
351
+
352
+ // Will dump a beauty json :3
353
+ //var_dump(json_decode($result, true));
354
+ return $result;
355
+ }
356
+
357
+ /**
358
+ * Validad que el módulo de skybox este habilitado para la tienda
359
+ * @return bool
360
+ */
361
+ public function isModuleEnable()
362
+ {
363
+ return (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
364
+ }
365
+ }
app/code/community/Skybox/Core/Model/Config.php CHANGED
@@ -1,252 +1,252 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Core
5
- *
6
- * @category Skybox
7
- * @package Skybox_Core
8
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
-
11
- /**
12
- * Configuración del modelo
13
- * @author César Tapia M. <ctapia@skyworldint.com>
14
- */
15
- class Skybox_Core_Model_Config
16
- {
17
-
18
- const SKYBOX_VERSION = "1.2.10";
19
- /**
20
- * Skybox cookie
21
- * @var string
22
- */
23
- const SKYBOX_COOKIE_API_GUID = "int_guid_api";
24
-
25
- /**
26
- * Skybox actions
27
- * @var string
28
- */
29
- const SKYBOX_ACTION_AUTHENTICATE = "AuthenticateService";
30
- const SKYBOX_ACTION_INITIALICE = "InitializeSessionUser";
31
- const SKYBOX_ACTION_CALCULATE = "Calculate";
32
- const SKYBOX_ACTION_CATEGORIES = "Categories";
33
- const SKYBOX_ACTION_ADD_PRODUCT_CART = "AddProductToCart";
34
- const SKYBOX_ACTION_DELETE_PRODUCT_CART = "DelProductOfCart";
35
- const SKYBOX_ACTION_UPDATE_PRODUCT_CART = "UpdateProductOfCart";
36
- const SKYBOX_ACTION_GET_TEMPLATE_BUTTON = "GetButtonTemplate";
37
- const SKYBOX_ACTION_GET_TOTAL_SHOPINGCART = "GetTotalShoppingCart";
38
-
39
- /**
40
- * Skybox errors
41
- * @var string
42
- */
43
- const SKYBOX_ERROR_SERVICE_NOT_CONTROLLER = "50000";
44
- const SKYBOX_ERROR_GCODE_IDMERCHANT_INVALID = "50001";
45
- const SKYBOX_ERROR_GCODE_TOKEN_EXPIRED = "50002";
46
- const SKYBOX_ERROR_GCODE_DEVICE_GUID_INVALID = "50003";
47
- const SKYBOX_ERROR_GCODE_PRODUCT_NOT_IN_SHOPPING_CART = "50004";
48
- const SKYBOX_ERROR_GCODE_COUNTRY_NOT_CONFIGURED_TO_STORE = "50005";
49
- const SKYBOX_ERROR_MERCHANT_KEY_INVALID = "50006";
50
- const SKYBOX_ERROR_GCODE_IP_NOT_ALLOWED = "50007";
51
- const SKYBOX_ERROR_GCODE_PRODUCT_CATEGORY_INVALID = "50008";
52
- const SKYBOX_ERROR_GCODE_PRODUCT_UNITWEIGHT_IS_NULL = "50009";
53
- const SKYBOX_ERROR_GCODE_PRODUCT_WEIGHT_INVALID = "50010";
54
- const SKYBOX_ERROR_GCODE_PRODUCT_WEIGHT_IS_NULL = "50011";
55
- const SKYBOX_ERROR_GCODE_MERCHANT_KEY_IS_NULL = "50013";
56
- const SKYBOX_ERROR_GCODE_PRODUCT_UNITWEIGHT_INVALID = "50014";
57
- const SKYBOX_ERROR_GCODE_STORE_CITY_NOT_CONFIGURED = "50015";
58
- const SKYBOX_ERROR_GCODE_TOKEN_IS_NULL = "50016";
59
- const SKYBOX_ERROR_GCODE_GUID_IS_NULL = "50017";
60
- const SKYBOX_ERROR_GCODE_REGION_NOT_CONFIGURED_TO_STORE = "50018";
61
- const SKYBOX_ERROR_GCODE_PRODUCT_NAME_IS_NULL = "50019";
62
- const SKYBOX_ERROR_GCODE_PRODUCT_CODE_IS_NULL = "50020";
63
- const SKYBOX_ERROR_GCODE_RATES_NOT_FOUND = "50021";
64
-
65
- /**
66
- * Skybox PARAMETERS REQUEST
67
- * @var string
68
- */
69
- const SKYBOX_PARAMETER_MERCHANT = "merchant";
70
- const SKYBOX_PARAMETER_MERCHANTKEY = "merchantKey";
71
- const SKYBOX_PARAMETER_GUID = "guid";
72
- const SKYBOX_PARAMETER_TOKEN = "token";
73
-
74
- /**
75
- * Skybox PARAMETERS RESPONSE
76
- * @var string
77
- */
78
- const SKYBOX_PARAMETER_RESPONSE_TOKEN = "TokenCode";
79
- const SKYBOX_PARAMETER_RESPONSE_GUID = "Guid";
80
- const SKYBOX_PARAMETER_RESPONSE_MESSAGE = "StatusMessage";
81
- const SKYBOX_PARAMETER_RESPONSE_STATUS = "StatusCode";
82
- const SKYBOX_PARAMETER_RESPONSE_BARHTML = "BarHtmlTemplate";
83
- const SKYBOX_PARAMETER_RESPONSE_LOCATION_ALLOW = "LocationAllow";
84
- const SKYBOX_PARAMETER_RESPONSE_STORE_CODE = "StoreCode";
85
- const SKYBOX_PARAMETER_RESPONSE_BUTTONHTML = "HtmlTemplate";
86
- const SKYBOX_PARAMETER_RESPONSE_BUTTONERRORHTML = "HtmlTemplateError";
87
- const SKYBOX_PARAMETER_RESPONSE_BUTTONERROR = "CalcErrorCode";
88
- const SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID = "ProductId";
89
- const SKYBOX_PARAMETER_RESPONSE_PRODUCT_CUSTOMS = "ProductCustoms";
90
- const SKYBOX_PARAMETER_RESPONSE_PRODUCT_SHIPPING = "ProductShipping";
91
- const SKYBOX_PARAMETER_RESPONSE_PRODUCT_INSURANCE = "ProductInsurance";
92
- const SKYBOX_PARAMETER_RESPONSE_PRODUCT_TOTAL = "TotalProduct";
93
- const SKYBOX_PARAMETER_RESPONSE_PRODUCT_PRICE = "StoreProductPrice";
94
- const SKYBOX_PARAMETER_RESPONSE_PRODUCT_CUSTOMS_USD = "ProductCustomsUSD";
95
- const SKYBOX_PARAMETER_RESPONSE_PRODUCT_SHIPPING_USD = "ProductShippingUSD";
96
- const SKYBOX_PARAMETER_RESPONSE_PRODUCT_INSURANCE_USD = "ProductInsuranceUSD";
97
- const SKYBOX_PARAMETER_RESPONSE_PRODUCT_TOTAL_USD = "TotalProductUSD";
98
- const SKYBOX_PARAMETER_RESPONSE_PRODUCT_PRICE_USD = "StoreProductPriceUSD";
99
- const SKYBOX_PARAMETER_RESPONSE_CART_CURRENCY_ISO = "CartCurrencyIso";
100
-
101
- const SKYBOX_PARAMETER_RESPONSE_PRODUCT_BASE_PRICE = "BaseProductPrice";
102
- const SKYBOX_PARAMETER_RESPONSE_PRODUCT_BASE_PRICE_USD = "BaseProductPriceUSD";
103
- const SKYBOX_PARAMETER_RESPONSE_PRODUCT_ADJUST_PRICE = "ProductAdjustment";
104
- const SKYBOX_PARAMETER_RESPONSE_PRODUCT_ADJUST_PRICE_USD = "ProductAdjustmentUSD";
105
- const SKYBOX_PARAMETER_RESPONSE_PRODUCT_LABEL_ADJUST = "WidgetLabelAdjustment";
106
-
107
- const SKYBOX_PARAMETER_RESPONSE_CSS_VERSION = "CssVersion";
108
-
109
- const SKYBOX_CURRENCY_USD = "USD";
110
-
111
- /**
112
- * Default URL para Api Skybox Checkout
113
- *
114
- * @var string
115
- */
116
- //public $skyboxDefaultApiUrl = 'http://www.skyboxcheckout.com/Service/ApiRest/';
117
- //public $skyboxDefaultApiUrl = 'http://localhost:65065/ApiRest/';
118
- public $skyboxDefaultApiUrl = 'http://127.0.0.1:65065/ApiRest/';
119
- //public $skyboxDefaultApiUrl = 'http://checkout.skynet.com/Service/ApiRest/';
120
- //public $skyboxDefaultApiUrl = 'http://beta.skyboxcheckout.com/ServiceTest/ApiRest/';
121
-
122
- /**
123
- * Default URL para Skybox Checkout
124
- *
125
- * @var string
126
- */
127
- //public $skyboxDefaultUrl = 'http://www.skyboxcheckout.com/';
128
- //public $skyboxDefaultUrl = 'http://localhost:6761/';
129
- //public $skyboxDefaultUrl = 'http://127.0.0.1:6761/';
130
- public $skyboxDefaultUrl = 'http://127.0.0.1:6761/';
131
- //public $skyboxDefaultUrl = 'http://checkout.skynet.com/';
132
-
133
- /**
134
- * Código de Tienda
135
- *
136
- * @var string
137
- */
138
- protected $_merchantId = null;
139
-
140
-
141
- /**
142
- * Llave de Tienda
143
- *
144
- * @var string
145
- */
146
- protected $_merchantkey = null;
147
-
148
- /**
149
- * Código de Guid
150
- * @var string
151
- */
152
- protected $_guidapi = null;
153
-
154
- /**
155
- * Obtenemos el objeto Session
156
- * @return Skybox_Core_Model_Session
157
- */
158
- public function getSession()
159
- {
160
- return Mage::getSingleton('skyboxcore/session');
161
- }
162
-
163
- /**
164
- * Obtenemos el objeto Cookie
165
- * @return Mage_Core_Model_Cookie
166
- */
167
- public function getCookie()
168
- {
169
- return Mage::getModel('core/cookie');
170
- }
171
-
172
- /**
173
- * Obtenemos el objeto Http
174
- *
175
- * @return Mage_Core_Helper_Http
176
- */
177
- public function getHttp()
178
- {
179
- return Mage::helper('core/http');
180
- }
181
-
182
- /**
183
- * Current locale code getter
184
- *
185
- * @return string
186
- */
187
- public function getLocaleCode()
188
- {
189
- return Mage::app()->getLocale()->getLocaleCode();
190
- }
191
-
192
- /**
193
- * Obtenemos inforamción del navegador del cliente
194
- *
195
- * @return HTTP_USER_AGENT
196
- */
197
- public function getUserAgent()
198
- {
199
- return $this->getHttp()->getHttpUserAgent();
200
- }
201
-
202
- /**
203
- * Obtenemos la Ip Local Remota del Cliente
204
- *
205
- * @return REMOTE_ADDR
206
- */
207
- public function getRemoteAddr()
208
- {
209
- return $this->getHttp()->getRemoteAddr();
210
- }
211
-
212
- /**
213
- * Obtenemos la Ip Proxy del Client
214
- *
215
- * @return HTTP_VIA or HTTP_X_FORWARDED_FOR
216
- */
217
- public function getProxy()
218
- {
219
- $proxy = getenv('HTTP_X_FORWARDED_FOR');
220
- return isset($proxy) ? $proxy : "";
221
- }
222
-
223
- /**
224
- * Obtenemos la Ip Local del Cliente
225
- *
226
- * @return String
227
- */
228
- public function getHost()
229
- {
230
- return $this->getHttp()->getHttpHost();
231
- }
232
-
233
- /**
234
- * Obtenemos el lenguaje del Navegador del Cliente
235
- *
236
- * @return string
237
- */
238
- public function getLanguage()
239
- {
240
- return $this->getHttp()->getHttpAcceptLanguage();
241
- }
242
-
243
- public function getSkyBoxUrlAPI()
244
- {
245
- return Mage::helper('skyboxinternational/data')->getSkyboxUrlAPI();
246
- }
247
-
248
- public function getSkyBoxUrlMain()
249
- {
250
- return Mage::helper('skyboxinternational/data')->getSkyboxUrlMain();
251
- }
252
  }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Core
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Core
8
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+
11
+ /**
12
+ * Configuración del modelo
13
+ * @author César Tapia M. <ctapia@skyworldint.com>
14
+ */
15
+ class Skybox_Core_Model_Config
16
+ {
17
+
18
+ const SKYBOX_VERSION = "1.2.11";
19
+ /**
20
+ * Skybox cookie
21
+ * @var string
22
+ */
23
+ const SKYBOX_COOKIE_API_GUID = "int_guid_api";
24
+
25
+ /**
26
+ * Skybox actions
27
+ * @var string
28
+ */
29
+ const SKYBOX_ACTION_AUTHENTICATE = "AuthenticateService";
30
+ const SKYBOX_ACTION_INITIALICE = "InitializeSessionUser";
31
+ const SKYBOX_ACTION_CALCULATE = "Calculate";
32
+ const SKYBOX_ACTION_CATEGORIES = "Categories";
33
+ const SKYBOX_ACTION_ADD_PRODUCT_CART = "AddProductToCart";
34
+ const SKYBOX_ACTION_DELETE_PRODUCT_CART = "DelProductOfCart";
35
+ const SKYBOX_ACTION_UPDATE_PRODUCT_CART = "UpdateProductOfCart";
36
+ const SKYBOX_ACTION_GET_TEMPLATE_BUTTON = "GetButtonTemplate";
37
+ const SKYBOX_ACTION_GET_TOTAL_SHOPINGCART = "GetTotalShoppingCart";
38
+
39
+ /**
40
+ * Skybox errors
41
+ * @var string
42
+ */
43
+ const SKYBOX_ERROR_SERVICE_NOT_CONTROLLER = "50000";
44
+ const SKYBOX_ERROR_GCODE_IDMERCHANT_INVALID = "50001";
45
+ const SKYBOX_ERROR_GCODE_TOKEN_EXPIRED = "50002";
46
+ const SKYBOX_ERROR_GCODE_DEVICE_GUID_INVALID = "50003";
47
+ const SKYBOX_ERROR_GCODE_PRODUCT_NOT_IN_SHOPPING_CART = "50004";
48
+ const SKYBOX_ERROR_GCODE_COUNTRY_NOT_CONFIGURED_TO_STORE = "50005";
49
+ const SKYBOX_ERROR_MERCHANT_KEY_INVALID = "50006";
50
+ const SKYBOX_ERROR_GCODE_IP_NOT_ALLOWED = "50007";
51
+ const SKYBOX_ERROR_GCODE_PRODUCT_CATEGORY_INVALID = "50008";
52
+ const SKYBOX_ERROR_GCODE_PRODUCT_UNITWEIGHT_IS_NULL = "50009";
53
+ const SKYBOX_ERROR_GCODE_PRODUCT_WEIGHT_INVALID = "50010";
54
+ const SKYBOX_ERROR_GCODE_PRODUCT_WEIGHT_IS_NULL = "50011";
55
+ const SKYBOX_ERROR_GCODE_MERCHANT_KEY_IS_NULL = "50013";
56
+ const SKYBOX_ERROR_GCODE_PRODUCT_UNITWEIGHT_INVALID = "50014";
57
+ const SKYBOX_ERROR_GCODE_STORE_CITY_NOT_CONFIGURED = "50015";
58
+ const SKYBOX_ERROR_GCODE_TOKEN_IS_NULL = "50016";
59
+ const SKYBOX_ERROR_GCODE_GUID_IS_NULL = "50017";
60
+ const SKYBOX_ERROR_GCODE_REGION_NOT_CONFIGURED_TO_STORE = "50018";
61
+ const SKYBOX_ERROR_GCODE_PRODUCT_NAME_IS_NULL = "50019";
62
+ const SKYBOX_ERROR_GCODE_PRODUCT_CODE_IS_NULL = "50020";
63
+ const SKYBOX_ERROR_GCODE_RATES_NOT_FOUND = "50021";
64
+
65
+ /**
66
+ * Skybox PARAMETERS REQUEST
67
+ * @var string
68
+ */
69
+ const SKYBOX_PARAMETER_MERCHANT = "merchant";
70
+ const SKYBOX_PARAMETER_MERCHANTKEY = "merchantKey";
71
+ const SKYBOX_PARAMETER_GUID = "guid";
72
+ const SKYBOX_PARAMETER_TOKEN = "token";
73
+
74
+ /**
75
+ * Skybox PARAMETERS RESPONSE
76
+ * @var string
77
+ */
78
+ const SKYBOX_PARAMETER_RESPONSE_TOKEN = "TokenCode";
79
+ const SKYBOX_PARAMETER_RESPONSE_GUID = "Guid";
80
+ const SKYBOX_PARAMETER_RESPONSE_MESSAGE = "StatusMessage";
81
+ const SKYBOX_PARAMETER_RESPONSE_STATUS = "StatusCode";
82
+ const SKYBOX_PARAMETER_RESPONSE_BARHTML = "BarHtmlTemplate";
83
+ const SKYBOX_PARAMETER_RESPONSE_LOCATION_ALLOW = "LocationAllow";
84
+ const SKYBOX_PARAMETER_RESPONSE_STORE_CODE = "StoreCode";
85
+ const SKYBOX_PARAMETER_RESPONSE_BUTTONHTML = "HtmlTemplate";
86
+ const SKYBOX_PARAMETER_RESPONSE_BUTTONERRORHTML = "HtmlTemplateError";
87
+ const SKYBOX_PARAMETER_RESPONSE_BUTTONERROR = "CalcErrorCode";
88
+ const SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID = "ProductId";
89
+ const SKYBOX_PARAMETER_RESPONSE_PRODUCT_CUSTOMS = "ProductCustoms";
90
+ const SKYBOX_PARAMETER_RESPONSE_PRODUCT_SHIPPING = "ProductShipping";
91
+ const SKYBOX_PARAMETER_RESPONSE_PRODUCT_INSURANCE = "ProductInsurance";
92
+ const SKYBOX_PARAMETER_RESPONSE_PRODUCT_TOTAL = "TotalProduct";
93
+ const SKYBOX_PARAMETER_RESPONSE_PRODUCT_PRICE = "StoreProductPrice";
94
+ const SKYBOX_PARAMETER_RESPONSE_PRODUCT_CUSTOMS_USD = "ProductCustomsUSD";
95
+ const SKYBOX_PARAMETER_RESPONSE_PRODUCT_SHIPPING_USD = "ProductShippingUSD";
96
+ const SKYBOX_PARAMETER_RESPONSE_PRODUCT_INSURANCE_USD = "ProductInsuranceUSD";
97
+ const SKYBOX_PARAMETER_RESPONSE_PRODUCT_TOTAL_USD = "TotalProductUSD";
98
+ const SKYBOX_PARAMETER_RESPONSE_PRODUCT_PRICE_USD = "StoreProductPriceUSD";
99
+ const SKYBOX_PARAMETER_RESPONSE_CART_CURRENCY_ISO = "CartCurrencyIso";
100
+
101
+ const SKYBOX_PARAMETER_RESPONSE_PRODUCT_BASE_PRICE = "BaseProductPrice";
102
+ const SKYBOX_PARAMETER_RESPONSE_PRODUCT_BASE_PRICE_USD = "BaseProductPriceUSD";
103
+ const SKYBOX_PARAMETER_RESPONSE_PRODUCT_ADJUST_PRICE = "ProductAdjustment";
104
+ const SKYBOX_PARAMETER_RESPONSE_PRODUCT_ADJUST_PRICE_USD = "ProductAdjustmentUSD";
105
+ const SKYBOX_PARAMETER_RESPONSE_PRODUCT_LABEL_ADJUST = "WidgetLabelAdjustment";
106
+
107
+ const SKYBOX_PARAMETER_RESPONSE_CSS_VERSION = "CssVersion";
108
+
109
+ const SKYBOX_CURRENCY_USD = "USD";
110
+
111
+ /**
112
+ * Default URL para Api Skybox Checkout
113
+ *
114
+ * @var string
115
+ */
116
+ //public $skyboxDefaultApiUrl = 'http://www.skyboxcheckout.com/Service/ApiRest/';
117
+ //public $skyboxDefaultApiUrl = 'http://localhost:65065/ApiRest/';
118
+ public $skyboxDefaultApiUrl = 'http://127.0.0.1:65065/ApiRest/';
119
+ //public $skyboxDefaultApiUrl = 'http://checkout.skynet.com/Service/ApiRest/';
120
+ //public $skyboxDefaultApiUrl = 'http://beta.skyboxcheckout.com/ServiceTest/ApiRest/';
121
+
122
+ /**
123
+ * Default URL para Skybox Checkout
124
+ *
125
+ * @var string
126
+ */
127
+ //public $skyboxDefaultUrl = 'http://www.skyboxcheckout.com/';
128
+ //public $skyboxDefaultUrl = 'http://localhost:6761/';
129
+ //public $skyboxDefaultUrl = 'http://127.0.0.1:6761/';
130
+ public $skyboxDefaultUrl = 'http://127.0.0.1:6761/';
131
+ //public $skyboxDefaultUrl = 'http://checkout.skynet.com/';
132
+
133
+ /**
134
+ * Código de Tienda
135
+ *
136
+ * @var string
137
+ */
138
+ protected $_merchantId = null;
139
+
140
+
141
+ /**
142
+ * Llave de Tienda
143
+ *
144
+ * @var string
145
+ */
146
+ protected $_merchantkey = null;
147
+
148
+ /**
149
+ * Código de Guid
150
+ * @var string
151
+ */
152
+ protected $_guidapi = null;
153
+
154
+ /**
155
+ * Obtenemos el objeto Session
156
+ * @return Skybox_Core_Model_Session
157
+ */
158
+ public function getSession()
159
+ {
160
+ return Mage::getSingleton('skyboxcore/session');
161
+ }
162
+
163
+ /**
164
+ * Obtenemos el objeto Cookie
165
+ * @return Mage_Core_Model_Cookie
166
+ */
167
+ public function getCookie()
168
+ {
169
+ return Mage::getModel('core/cookie');
170
+ }
171
+
172
+ /**
173
+ * Obtenemos el objeto Http
174
+ *
175
+ * @return Mage_Core_Helper_Http
176
+ */
177
+ public function getHttp()
178
+ {
179
+ return Mage::helper('core/http');
180
+ }
181
+
182
+ /**
183
+ * Current locale code getter
184
+ *
185
+ * @return string
186
+ */
187
+ public function getLocaleCode()
188
+ {
189
+ return Mage::app()->getLocale()->getLocaleCode();
190
+ }
191
+
192
+ /**
193
+ * Obtenemos inforamción del navegador del cliente
194
+ *
195
+ * @return HTTP_USER_AGENT
196
+ */
197
+ public function getUserAgent()
198
+ {
199
+ return $this->getHttp()->getHttpUserAgent();
200
+ }
201
+
202
+ /**
203
+ * Obtenemos la Ip Local Remota del Cliente
204
+ *
205
+ * @return REMOTE_ADDR
206
+ */
207
+ public function getRemoteAddr()
208
+ {
209
+ return $this->getHttp()->getRemoteAddr();
210
+ }
211
+
212
+ /**
213
+ * Obtenemos la Ip Proxy del Client
214
+ *
215
+ * @return HTTP_VIA or HTTP_X_FORWARDED_FOR
216
+ */
217
+ public function getProxy()
218
+ {
219
+ $proxy = getenv('HTTP_X_FORWARDED_FOR');
220
+ return isset($proxy) ? $proxy : "";
221
+ }
222
+
223
+ /**
224
+ * Obtenemos la Ip Local del Cliente
225
+ *
226
+ * @return String
227
+ */
228
+ public function getHost()
229
+ {
230
+ return $this->getHttp()->getHttpHost();
231
+ }
232
+
233
+ /**
234
+ * Obtenemos el lenguaje del Navegador del Cliente
235
+ *
236
+ * @return string
237
+ */
238
+ public function getLanguage()
239
+ {
240
+ return $this->getHttp()->getHttpAcceptLanguage();
241
+ }
242
+
243
+ public function getSkyBoxUrlAPI()
244
+ {
245
+ return Mage::helper('skyboxinternational/data')->getSkyboxUrlAPI();
246
+ }
247
+
248
+ public function getSkyBoxUrlMain()
249
+ {
250
+ return Mage::helper('skyboxinternational/data')->getSkyboxUrlMain();
251
+ }
252
  }
app/code/community/Skybox/Core/Model/Logservice.php CHANGED
@@ -1,17 +1,17 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Core
5
- *
6
- * @category Skybox
7
- * @package Skybox_Core
8
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Core_Model_Logservice extends Mage_Core_Model_Abstract
11
- {
12
- protected function _construct()
13
- {
14
- parent::_construct();
15
- $this->_init('skyboxcore/logservice', 'service_id');
16
- }
17
  }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Core
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Core
8
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Core_Model_Logservice extends Mage_Core_Model_Abstract
11
+ {
12
+ protected function _construct()
13
+ {
14
+ parent::_construct();
15
+ $this->_init('skyboxcore/logservice', 'service_id');
16
+ }
17
  }
app/code/community/Skybox/Core/Model/Mysql4.php CHANGED
@@ -1,17 +1,17 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Core
5
- *
6
- * @category Skybox
7
- * @package Skybox_Core
8
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Core_Model_Mysql4 extends Mage_Core_Model_Abstract
11
- {
12
- public function _construct()
13
- {
14
- parent::_construct();
15
- $this->_init('skybox/mysql4');
16
- }
17
  }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Core
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Core
8
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Core_Model_Mysql4 extends Mage_Core_Model_Abstract
11
+ {
12
+ public function _construct()
13
+ {
14
+ parent::_construct();
15
+ $this->_init('skybox/mysql4');
16
+ }
17
  }
app/code/community/Skybox/Core/Model/Mysql4/Logservice.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Core
5
- *
6
- * @category Skybox
7
- * @package Skybox_Core
8
- * @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
9
- */
10
-
11
- /**
12
- *
13
- * Skybox Log Service Model
14
- *
15
- */
16
- class Skybox_Core_Model_Mysql4_Logservice extends Mage_Core_Model_Mysql4_Abstract
17
- {
18
- protected function _construct()
19
- {
20
- //parent::_construct();
21
- $this->_init('skyboxcore/logservice', 'service_id');
22
- }
23
  }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Core
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Core
8
+ * @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
9
+ */
10
+
11
+ /**
12
+ *
13
+ * Skybox Log Service Model
14
+ *
15
+ */
16
+ class Skybox_Core_Model_Mysql4_Logservice extends Mage_Core_Model_Mysql4_Abstract
17
+ {
18
+ protected function _construct()
19
+ {
20
+ //parent::_construct();
21
+ $this->_init('skyboxcore/logservice', 'service_id');
22
+ }
23
  }
app/code/community/Skybox/Core/Model/Mysql4/Logservice/Collection.php CHANGED
@@ -1,18 +1,18 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Core
5
- *
6
- * @category Skybox
7
- * @package Skybox_Core
8
- * @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Core_Model_Mysql4_Logservice_Collection
11
- extends Mage_Core_Model_Mysql4_Collection_Abstract
12
- {
13
-
14
- protected function _construct()
15
- {
16
- $this->_init('skyboxcore/logservice', 'service_id');
17
- }
18
  }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Core
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Core
8
+ * @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Core_Model_Mysql4_Logservice_Collection
11
+ extends Mage_Core_Model_Mysql4_Collection_Abstract
12
+ {
13
+
14
+ protected function _construct()
15
+ {
16
+ $this->_init('skyboxcore/logservice', 'service_id');
17
+ }
18
  }
app/code/community/Skybox/Core/Model/Session.php CHANGED
@@ -1,30 +1,30 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Core
5
- *
6
- * @category Skybox
7
- * @package Skybox_Core
8
- * @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
9
- */
10
-
11
- /**
12
- *
13
- * Skybox transaction session namespace
14
- *
15
- * @author César Tapia M. <ctapia@skyworldint.com>
16
- */
17
- class Skybox_Core_Model_Session extends Mage_Core_Model_Session_Abstract
18
- {
19
- public function __construct()
20
- {
21
- //$this->init('skybox');
22
- //Mage::dispatchEvent('myapp_session_init', array('myapp_session' => $this));
23
-
24
- $namespace = 'skyboxcore';
25
- $namespace .= '_' . (Mage::app()->getStore()->getWebsite()->getCode());
26
-
27
- $this->init($namespace);
28
- Mage::dispatchEvent('skyboxcore_session_init', array('skyboxcore_session' => $this));
29
- }
30
  }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Core
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Core
8
+ * @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
9
+ */
10
+
11
+ /**
12
+ *
13
+ * Skybox transaction session namespace
14
+ *
15
+ * @author César Tapia M. <ctapia@skyworldint.com>
16
+ */
17
+ class Skybox_Core_Model_Session extends Mage_Core_Model_Session_Abstract
18
+ {
19
+ public function __construct()
20
+ {
21
+ //$this->init('skybox');
22
+ //Mage::dispatchEvent('myapp_session_init', array('myapp_session' => $this));
23
+
24
+ $namespace = 'skyboxcore';
25
+ $namespace .= '_' . (Mage::app()->getStore()->getWebsite()->getCode());
26
+
27
+ $this->init($namespace);
28
+ Mage::dispatchEvent('skyboxcore_session_init', array('skyboxcore_session' => $this));
29
+ }
30
  }
app/code/community/Skybox/Core/Model/Standard.php CHANGED
@@ -1,292 +1,292 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Core
5
- *
6
- * @category Skybox
7
- * @package Skybox_Core
8
- * @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Core_Model_Standard
11
- {
12
- /**
13
- * Config instance
14
- * @var Skybox_Core_Model_Config
15
- */
16
- protected $_config = null;
17
-
18
- /**
19
- * Config Model Type
20
- *
21
- * @var string
22
- */
23
- protected $_typeConfig = "skyboxcore/config";
24
-
25
- /**
26
- * API instance
27
- * @var Skybox_Core_Model_Api_Restful
28
- */
29
- protected $_api = null;
30
-
31
- /**
32
- * Api Model Type
33
- *
34
- * @var string
35
- */
36
- protected $_apiType = 'skyboxcore/api_restful';
37
-
38
- /**
39
- * Helper instance
40
- * @var Skybox_International_Helper_Data
41
- */
42
- protected $_help = null;
43
-
44
- /**
45
- * Api Model Type
46
- *
47
- * @var string
48
- */
49
- protected $_helpType = 'skyboxinternational/data';
50
-
51
- /* @return Skybox_Core_Model_Config */
52
- protected function _getConfig()
53
- {
54
- if (null === $this->_config)
55
- $this->_config = Mage::getModel($this->_typeConfig);
56
- return $this->_config;
57
- }
58
-
59
- /* @return Skybox_Core_Model_Api_Restful */
60
- public function _getApi()
61
- {
62
- if (null === $this->_api) {
63
- $this->_api = Mage::getModel($this->_apiType)->setConfigObject($this->_config);
64
- }
65
- return $this->_api;
66
- }
67
-
68
- /* @return Skybox_International_Helper_Data */
69
- protected function _getHelper()
70
- {
71
- if (null === $this->_help) {
72
- $this->_help = Mage::helper($this->_helpType);
73
- }
74
- return $this->_help;
75
- }
76
-
77
- public function __construct($params = array())
78
- {
79
- $this->_getConfig();
80
- $this->_getApi();
81
- }
82
-
83
- public function getMerchant()
84
- {
85
- return $this->_getHelper()->getMerchantCode();
86
- }
87
-
88
- public function getMerchantKey()
89
- {
90
- return $this->_getHelper()->getMerchantKey();
91
- }
92
-
93
- public function getEnabledAddSumTaxToPrice()
94
- {
95
- return $this->_getHelper()->getEnabledAddSumTaxToPrice();
96
- }
97
-
98
- public function getWeightUnit()
99
- {
100
- return $this->_getHelper()->getWeightUnit();
101
- }
102
-
103
- public function getAuthorizedToken()
104
- {
105
- return $this->_api->getAuthorizedToken();
106
- }
107
-
108
- public function getGuidApi()
109
- {
110
- return $this->_api->getGuidApi();
111
- }
112
-
113
- public function getResponse()
114
- {
115
- return $this->_api->getResponseJson();
116
- }
117
-
118
- public function getParameter($paramName, $valueDefault = null)
119
- {
120
- try {
121
- return $this->getResponse()->{$paramName};
122
- } catch (Exception $e) {
123
- return $valueDefault;
124
- }
125
- }
126
-
127
- public function getLocationAllow()
128
- {
129
- //return $this->_api->getLocationAllow() == "1";
130
- return $this->_api->getLocationAllow();
131
- }
132
-
133
- public function getStoreCode()
134
- {
135
- return $this->_api->getStoreCode();
136
- }
137
-
138
- public function getErrorAuthenticate()
139
- {
140
- return $this->_api->getErrorAuthenticate();
141
- }
142
-
143
- public function getHtmlTemplateBar()
144
- {
145
- return $this->_api->getHtmlTemplateBar();
146
- }
147
-
148
- public function getHtmlTemplateButton()
149
- {
150
- return $this->_api->getHtmlTemplateButton();
151
- }
152
-
153
- public function getHtmlTemplateButtonError()
154
- {
155
- return $this->_api->getHtmlTemplateButtonError();
156
- }
157
-
158
- public function HasError()
159
- {
160
- return $this->_api->HasError();
161
- }
162
-
163
- public function getStatusCode()
164
- {
165
- return $this->_api->getStatusCode();
166
- }
167
-
168
- public function getStatusMessage()
169
- {
170
- return $this->_api->getStatusMessage();
171
- }
172
-
173
- public function getCssVersion()
174
- {
175
- return$this->_api->getCssVersion();
176
- }
177
-
178
- /**
179
- * Se invoca al servicio para generar Token de Seguridad
180
- * @return Skybox_Core_Model_Standard
181
- */
182
- public function AuthenticateService()
183
- {
184
- //$this->_getApi(); // Why? http://goo.gl/xYs9zM
185
- Mage::log("AuthenticateService ", null, 'autenticate.log', true);
186
-
187
- $successService = false;
188
- $errorService = 1;
189
-
190
- while (!$successService) {
191
- $params = array(
192
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
193
- Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANTKEY => $this->getMerchantKey()
194
- );
195
-
196
- Mage::log('|AuthenticateService|' . json_encode($params));
197
-
198
- $this->_api->CallService(Skybox_Core_Model_Config::SKYBOX_ACTION_AUTHENTICATE, $params);
199
-
200
- //if ($this->_api->ErrorKeyInvalid() || $this->_api->ErrorIpNoAllow()) break;
201
- //if (!($this->_api->ErrorService())) $successService = true;
202
- if ($this->_api->ErrorMerchantKeyInvalid() || $this->_api->ErrorIpNoAllow()) break;
203
- if (!($this->_api->ErrorServiceNotController())) $successService = true;
204
- $errorService++;
205
- if ($errorService > 3) break;
206
- }
207
-
208
- if (!$successService) {
209
- //throw new Exception("Error Processing Request", 1);
210
- //Mage::throwException('Error: al comunicarse con el servidor, si el error persiste comunicarse con su administrador');
211
- }
212
-
213
- return $this;
214
- }
215
-
216
- public function CallApiRest($action, $params)
217
- {
218
-
219
- $start = microtime(true);
220
-
221
- Mage::log("CallApiRest ", null, 'standart.log', true);
222
-
223
- $successService = false;
224
- $errorService = 1;
225
- $successAuthenticate = true;
226
- try {
227
- //$this->_getApi(); // Why? http://goo.gl/xYs9zM
228
- $variable = $this->getAuthorizedToken();
229
- if (empty($variable)) {
230
- Mage::log("empty ", null, 'standart.log', true);
231
-
232
- $this->AuthenticateService();
233
- $params = $this->resetValueDefault($params);
234
- $successAuthenticate = !$this->getErrorAuthenticate();
235
- }
236
-
237
- if ($successAuthenticate) {
238
- Mage::log("successAuthenticate ", null, 'standart.log', true);
239
-
240
- while (!$successService) {
241
- Mage::log(" ---------------------------------------------");
242
- Mage::log(" | Call | " . $action);
243
- $this->_api->CallService($action, $params);
244
-
245
- if ($this->_api->HasError()) {
246
- Mage::log("HasError ", null, 'standart.log', true);
247
- Mage::log(' | CallApiRest->Error | ');
248
- $errorService++;
249
- //if ($this->_api->ErrorTokenInvalid()) $this->AuthenticateService();
250
- if ($this->_api->ErrorTokenExpired()) $this->AuthenticateService();
251
- if ($errorService > 3) break;
252
- $params = $this->resetValueDefault($params);
253
- } else {
254
- Mage::log(' | CallApiRest->Success | ');
255
- $successService = true;
256
- }
257
- }
258
- }
259
- } catch (Exception $e) {
260
- Mage::log(' | CallApiRest->Error | ' . $e->getMessage());
261
- Mage::helper('skyboxcore/email')->sendException($e->getMessage());
262
- $successService = false;
263
- }
264
-
265
- if (!$successService) {
266
- Mage::log(' | Error Processing Request / CallApiRest | ' . $action);
267
- //throw new Exception("Error Processing Request", 1);
268
- //Mage::throwException('Error: al comunicarse con el servidor, si el error persiste comunicarse con su administrador');
269
- //Mage::helper('skyboxcore/email')->sendAPIError($e->getMessage());
270
- }
271
-
272
-
273
- // $total_time = round(microtime(true)-$start, 4);
274
- // Mage::log('Servicio generado ['.$action.']: '.$total_time.' segundos.', null, 'timer.log',true);
275
-
276
- return $this;
277
- }
278
-
279
- /**
280
- * Setea los valores por defecto
281
- * @return array()
282
- */
283
- protected function resetValueDefault($params)
284
- {
285
- foreach ($params as $key => $val) {
286
- if ($key == Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN) $params[$key] = $this->_api->getAuthorizedToken();
287
- if ($key == Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID) $params[$key] = $this->_api->getGuidApi();
288
- }
289
-
290
- return $params;
291
- }
292
- }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Core
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Core
8
+ * @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Core_Model_Standard
11
+ {
12
+ /**
13
+ * Config instance
14
+ * @var Skybox_Core_Model_Config
15
+ */
16
+ protected $_config = null;
17
+
18
+ /**
19
+ * Config Model Type
20
+ *
21
+ * @var string
22
+ */
23
+ protected $_typeConfig = "skyboxcore/config";
24
+
25
+ /**
26
+ * API instance
27
+ * @var Skybox_Core_Model_Api_Restful
28
+ */
29
+ protected $_api = null;
30
+
31
+ /**
32
+ * Api Model Type
33
+ *
34
+ * @var string
35
+ */
36
+ protected $_apiType = 'skyboxcore/api_restful';
37
+
38
+ /**
39
+ * Helper instance
40
+ * @var Skybox_International_Helper_Data
41
+ */
42
+ protected $_help = null;
43
+
44
+ /**
45
+ * Api Model Type
46
+ *
47
+ * @var string
48
+ */
49
+ protected $_helpType = 'skyboxinternational/data';
50
+
51
+ /* @return Skybox_Core_Model_Config */
52
+ protected function _getConfig()
53
+ {
54
+ if (null === $this->_config)
55
+ $this->_config = Mage::getModel($this->_typeConfig);
56
+ return $this->_config;
57
+ }
58
+
59
+ /* @return Skybox_Core_Model_Api_Restful */
60
+ public function _getApi()
61
+ {
62
+ if (null === $this->_api) {
63
+ $this->_api = Mage::getModel($this->_apiType)->setConfigObject($this->_config);
64
+ }
65
+ return $this->_api;
66
+ }
67
+
68
+ /* @return Skybox_International_Helper_Data */
69
+ protected function _getHelper()
70
+ {
71
+ if (null === $this->_help) {
72
+ $this->_help = Mage::helper($this->_helpType);
73
+ }
74
+ return $this->_help;
75
+ }
76
+
77
+ public function __construct($params = array())
78
+ {
79
+ $this->_getConfig();
80
+ $this->_getApi();
81
+ }
82
+
83
+ public function getMerchant()
84
+ {
85
+ return $this->_getHelper()->getMerchantCode();
86
+ }
87
+
88
+ public function getMerchantKey()
89
+ {
90
+ return $this->_getHelper()->getMerchantKey();
91
+ }
92
+
93
+ public function getEnabledAddSumTaxToPrice()
94
+ {
95
+ return $this->_getHelper()->getEnabledAddSumTaxToPrice();
96
+ }
97
+
98
+ public function getWeightUnit()
99
+ {
100
+ return $this->_getHelper()->getWeightUnit();
101
+ }
102
+
103
+ public function getAuthorizedToken()
104
+ {
105
+ return $this->_api->getAuthorizedToken();
106
+ }
107
+
108
+ public function getGuidApi()
109
+ {
110
+ return $this->_api->getGuidApi();
111
+ }
112
+
113
+ public function getResponse()
114
+ {
115
+ return $this->_api->getResponseJson();
116
+ }
117
+
118
+ public function getParameter($paramName, $valueDefault = null)
119
+ {
120
+ try {
121
+ return $this->getResponse()->{$paramName};
122
+ } catch (Exception $e) {
123
+ return $valueDefault;
124
+ }
125
+ }
126
+
127
+ public function getLocationAllow()
128
+ {
129
+ //return $this->_api->getLocationAllow() == "1";
130
+ return $this->_api->getLocationAllow();
131
+ }
132
+
133
+ public function getStoreCode()
134
+ {
135
+ return $this->_api->getStoreCode();
136
+ }
137
+
138
+ public function getErrorAuthenticate()
139
+ {
140
+ return $this->_api->getErrorAuthenticate();
141
+ }
142
+
143
+ public function getHtmlTemplateBar()
144
+ {
145
+ return $this->_api->getHtmlTemplateBar();
146
+ }
147
+
148
+ public function getHtmlTemplateButton()
149
+ {
150
+ return $this->_api->getHtmlTemplateButton();
151
+ }
152
+
153
+ public function getHtmlTemplateButtonError()
154
+ {
155
+ return $this->_api->getHtmlTemplateButtonError();
156
+ }
157
+
158
+ public function HasError()
159
+ {
160
+ return $this->_api->HasError();
161
+ }
162
+
163
+ public function getStatusCode()
164
+ {
165
+ return $this->_api->getStatusCode();
166
+ }
167
+
168
+ public function getStatusMessage()
169
+ {
170
+ return $this->_api->getStatusMessage();
171
+ }
172
+
173
+ public function getCssVersion()
174
+ {
175
+ return$this->_api->getCssVersion();
176
+ }
177
+
178
+ /**
179
+ * Se invoca al servicio para generar Token de Seguridad
180
+ * @return Skybox_Core_Model_Standard
181
+ */
182
+ public function AuthenticateService()
183
+ {
184
+ //$this->_getApi(); // Why? http://goo.gl/xYs9zM
185
+ Mage::log("AuthenticateService ", null, 'autenticate.log', true);
186
+
187
+ $successService = false;
188
+ $errorService = 1;
189
+
190
+ while (!$successService) {
191
+ $params = array(
192
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
193
+ Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANTKEY => $this->getMerchantKey()
194
+ );
195
+
196
+ Mage::log('|AuthenticateService|' . json_encode($params));
197
+
198
+ $this->_api->CallService(Skybox_Core_Model_Config::SKYBOX_ACTION_AUTHENTICATE, $params);
199
+
200
+ //if ($this->_api->ErrorKeyInvalid() || $this->_api->ErrorIpNoAllow()) break;
201
+ //if (!($this->_api->ErrorService())) $successService = true;
202
+ if ($this->_api->ErrorMerchantKeyInvalid() || $this->_api->ErrorIpNoAllow()) break;
203
+ if (!($this->_api->ErrorServiceNotController())) $successService = true;
204
+ $errorService++;
205
+ if ($errorService > 3) break;
206
+ }
207
+
208
+ if (!$successService) {
209
+ //throw new Exception("Error Processing Request", 1);
210
+ //Mage::throwException('Error: al comunicarse con el servidor, si el error persiste comunicarse con su administrador');
211
+ }
212
+
213
+ return $this;
214
+ }
215
+
216
+ public function CallApiRest($action, $params)
217
+ {
218
+
219
+ $start = microtime(true);
220
+
221
+ Mage::log("CallApiRest ", null, 'standart.log', true);
222
+
223
+ $successService = false;
224
+ $errorService = 1;
225
+ $successAuthenticate = true;
226
+ try {
227
+ //$this->_getApi(); // Why? http://goo.gl/xYs9zM
228
+ $variable = $this->getAuthorizedToken();
229
+ if (empty($variable)) {
230
+ Mage::log("empty ", null, 'standart.log', true);
231
+
232
+ $this->AuthenticateService();
233
+ $params = $this->resetValueDefault($params);
234
+ $successAuthenticate = !$this->getErrorAuthenticate();
235
+ }
236
+
237
+ if ($successAuthenticate) {
238
+ Mage::log("successAuthenticate ", null, 'standart.log', true);
239
+
240
+ while (!$successService) {
241
+ Mage::log(" ---------------------------------------------");
242
+ Mage::log(" | Call | " . $action);
243
+ $this->_api->CallService($action, $params);
244
+
245
+ if ($this->_api->HasError()) {
246
+ Mage::log("HasError ", null, 'standart.log', true);
247
+ Mage::log(' | CallApiRest->Error | ');
248
+ $errorService++;
249
+ //if ($this->_api->ErrorTokenInvalid()) $this->AuthenticateService();
250
+ if ($this->_api->ErrorTokenExpired()) $this->AuthenticateService();
251
+ if ($errorService > 3) break;
252
+ $params = $this->resetValueDefault($params);
253
+ } else {
254
+ Mage::log(' | CallApiRest->Success | ');
255
+ $successService = true;
256
+ }
257
+ }
258
+ }
259
+ } catch (Exception $e) {
260
+ Mage::log(' | CallApiRest->Error | ' . $e->getMessage());
261
+ Mage::helper('skyboxcore/email')->sendException($e->getMessage());
262
+ $successService = false;
263
+ }
264
+
265
+ if (!$successService) {
266
+ Mage::log(' | Error Processing Request / CallApiRest | ' . $action);
267
+ //throw new Exception("Error Processing Request", 1);
268
+ //Mage::throwException('Error: al comunicarse con el servidor, si el error persiste comunicarse con su administrador');
269
+ //Mage::helper('skyboxcore/email')->sendAPIError($e->getMessage());
270
+ }
271
+
272
+
273
+ // $total_time = round(microtime(true)-$start, 4);
274
+ // Mage::log('Servicio generado ['.$action.']: '.$total_time.' segundos.', null, 'timer.log',true);
275
+
276
+ return $this;
277
+ }
278
+
279
+ /**
280
+ * Setea los valores por defecto
281
+ * @return array()
282
+ */
283
+ protected function resetValueDefault($params)
284
+ {
285
+ foreach ($params as $key => $val) {
286
+ if ($key == Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN) $params[$key] = $this->_api->getAuthorizedToken();
287
+ if ($key == Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID) $params[$key] = $this->_api->getGuidApi();
288
+ }
289
+
290
+ return $params;
291
+ }
292
+ }
app/code/community/Skybox/Core/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Skybox_Core>
5
- <version>1.2.10</version>
6
  <codePool>community</codePool>
7
  </Skybox_Core>
8
  </modules>
2
  <config>
3
  <modules>
4
  <Skybox_Core>
5
+ <version>1.2.11</version>
6
  <codePool>community</codePool>
7
  </Skybox_Core>
8
  </modules>
app/code/community/Skybox/Core/sql/skyboxcore_setup/mysql4-install-0.1.0.php CHANGED
@@ -1,67 +1,67 @@
1
- <?php
2
- /*
3
- $installer = $this;
4
- $installer->startSetup();
5
-
6
- $installer->run("
7
- --DROP TABLE IF EXISTS {$this->getTable('skybox_log_service')};
8
-
9
- CREATE TABLE {$this->getTable('skybox_log_service')} (
10
- `service_id` int(11) NOT NULL auto_increment,
11
- `action` text NOT NULl,
12
- `request` text NOT NULl,
13
- `response` text NULL,
14
- `timestamp_request` timestamp NOT NULL default CURRENT_TIMESTAMP,
15
- `timestamp_response` timestamp NULL
16
- PRIMARY KEY (`service_id`)
17
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8
18
- ");
19
-
20
- $installer->endSetup();
21
-
22
- echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";
23
- */
24
-
25
- $installer = $this;
26
- $installer->startSetup();
27
-
28
- //$table = $installer->getConnection()
29
- // //->newTable($installer->getTable('skyboxcore/skybox_log_service'))
30
- // ->newTable($installer->getTable('skybox_log_service'))
31
- // ->addColumn('service_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
32
- // 'identity' => true,
33
- // 'unsigned' => true,
34
- // 'nullable' => false,
35
- // 'primary' => true,
36
- // ), 'Service Id')
37
- // ->addColumn('action', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
38
- // 'nullable' => false,
39
- // ), 'Action')
40
- // ->addColumn('request', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
41
- // 'request' => false,
42
- // ), 'Request')
43
- // ->addColumn('response', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
44
- // 'request' => false,
45
- // ), 'Response')
46
- // ->addColumn('timestamp_request', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
47
- // 'request' => false,
48
- // ), 'Timestamp Request')
49
- // ->addColumn('timestamp_response', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
50
- // 'request' => false,
51
- // ), 'Timestamp Response');
52
- //$installer->getConnection()->createTable($table);
53
-
54
- $installer->run("
55
- DROP TABLE IF EXISTS `{$this->getTable('skybox_log_service')}`;
56
- CREATE TABLE `skybox_log_service` (
57
- `service_id` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Service Id' ,
58
- `action` TEXT NOT NULL COMMENT 'Action' ,
59
- `request` TEXT NULL COMMENT 'Request' ,
60
- `response` TEXT NULL COMMENT 'Response' ,
61
- `timestamp_request` TIMESTAMP NULL DEFAULT NULL COMMENT 'Timestamp Request' ,
62
- `timestamp_response` TIMESTAMP NULL DEFAULT NULL COMMENT 'Timestamp Response' ,
63
- PRIMARY KEY (`service_id`)
64
- )
65
- COMMENT='skybox_log_service' ENGINE=INNODB CHARSET=utf8 COLLATE=utf8_general_ci;
66
- ");
67
- $installer->endSetup();
1
+ <?php
2
+ /*
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ $installer->run("
7
+ --DROP TABLE IF EXISTS {$this->getTable('skybox_log_service')};
8
+
9
+ CREATE TABLE {$this->getTable('skybox_log_service')} (
10
+ `service_id` int(11) NOT NULL auto_increment,
11
+ `action` text NOT NULl,
12
+ `request` text NOT NULl,
13
+ `response` text NULL,
14
+ `timestamp_request` timestamp NOT NULL default CURRENT_TIMESTAMP,
15
+ `timestamp_response` timestamp NULL
16
+ PRIMARY KEY (`service_id`)
17
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
18
+ ");
19
+
20
+ $installer->endSetup();
21
+
22
+ echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";
23
+ */
24
+
25
+ $installer = $this;
26
+ $installer->startSetup();
27
+
28
+ //$table = $installer->getConnection()
29
+ // //->newTable($installer->getTable('skyboxcore/skybox_log_service'))
30
+ // ->newTable($installer->getTable('skybox_log_service'))
31
+ // ->addColumn('service_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
32
+ // 'identity' => true,
33
+ // 'unsigned' => true,
34
+ // 'nullable' => false,
35
+ // 'primary' => true,
36
+ // ), 'Service Id')
37
+ // ->addColumn('action', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
38
+ // 'nullable' => false,
39
+ // ), 'Action')
40
+ // ->addColumn('request', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
41
+ // 'request' => false,
42
+ // ), 'Request')
43
+ // ->addColumn('response', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
44
+ // 'request' => false,
45
+ // ), 'Response')
46
+ // ->addColumn('timestamp_request', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
47
+ // 'request' => false,
48
+ // ), 'Timestamp Request')
49
+ // ->addColumn('timestamp_response', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
50
+ // 'request' => false,
51
+ // ), 'Timestamp Response');
52
+ //$installer->getConnection()->createTable($table);
53
+
54
+ $installer->run("
55
+ DROP TABLE IF EXISTS `{$this->getTable('skybox_log_service')}`;
56
+ CREATE TABLE `skybox_log_service` (
57
+ `service_id` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Service Id' ,
58
+ `action` TEXT NOT NULL COMMENT 'Action' ,
59
+ `request` TEXT NULL COMMENT 'Request' ,
60
+ `response` TEXT NULL COMMENT 'Response' ,
61
+ `timestamp_request` TIMESTAMP NULL DEFAULT NULL COMMENT 'Timestamp Request' ,
62
+ `timestamp_response` TIMESTAMP NULL DEFAULT NULL COMMENT 'Timestamp Response' ,
63
+ PRIMARY KEY (`service_id`)
64
+ )
65
+ COMMENT='skybox_log_service' ENGINE=INNODB CHARSET=utf8 COLLATE=utf8_general_ci;
66
+ ");
67
+ $installer->endSetup();
app/code/community/Skybox/International/Helper/Data.php CHANGED
@@ -1,78 +1,78 @@
1
- <?php
2
-
3
- /**
4
- * Skybox International
5
- *
6
- * @category Skybox
7
- * @package Skybox_International
8
- * @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_International_Helper_Data extends Mage_Core_Helper_Abstract
11
- {
12
- public function getMerchantCode()
13
- {
14
- return Mage::getStoreConfig('skyboxinternational/skyboxsettings/merchantcode', Mage::app()->getStore());
15
- }
16
-
17
- public function getMerchantKey()
18
- {
19
- return Mage::getStoreConfig('skyboxinternational/skyboxsettings/merchantkey', Mage::app()->getStore());
20
- }
21
-
22
- public function getWeightUnit()
23
- {
24
- return Mage::getStoreConfig('skyboxinternational/skyboxsettings/weigthunitproduct', Mage::app()->getStore());
25
- }
26
-
27
- public function getActive()
28
- {
29
- // return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
30
- return Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
31
- }
32
-
33
- public function getSkyboxLog()
34
- {
35
- return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxlog', Mage::app()->getStore());
36
- }
37
-
38
- public function getSkyboxEmail()
39
- {
40
- return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxemail', Mage::app()->getStore());
41
- }
42
-
43
- public function getSkyboxIntegration()
44
- {
45
- return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxintegration', Mage::app()->getStore());
46
- }
47
-
48
- public function getSkyboxUrlAPI()
49
- {
50
- return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxurlapi', Mage::app()->getStore());
51
- }
52
-
53
- public function getSkyboxUrlMain()
54
- {
55
- return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxurlmain', Mage::app()->getStore());
56
- }
57
-
58
- public function getEnabledAddSumTaxToPrice()
59
- {
60
- return Mage::getStoreConfig('skyboxinternational/skyboxproduct/skyboxaddtaxtopriceenable', Mage::app()->getStore());
61
- }
62
-
63
- public function getStoreId()
64
- {
65
- //return $this->helper('core')->getStoreId();
66
- return Mage::app()->getStore()->getId();
67
- }
68
-
69
- public function getCartId()
70
- {
71
- return Mage::getSingleton('checkout/session')->getQuoteId();
72
- }
73
-
74
- public function getCssVersion()
75
- {
76
- return Mage::getModel('skyboxcatalog/api_product')->getCssVersion();
77
- }
78
  }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox International
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_International
8
+ * @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_International_Helper_Data extends Mage_Core_Helper_Abstract
11
+ {
12
+ public function getMerchantCode()
13
+ {
14
+ return Mage::getStoreConfig('skyboxinternational/skyboxsettings/merchantcode', Mage::app()->getStore());
15
+ }
16
+
17
+ public function getMerchantKey()
18
+ {
19
+ return Mage::getStoreConfig('skyboxinternational/skyboxsettings/merchantkey', Mage::app()->getStore());
20
+ }
21
+
22
+ public function getWeightUnit()
23
+ {
24
+ return Mage::getStoreConfig('skyboxinternational/skyboxsettings/weigthunitproduct', Mage::app()->getStore());
25
+ }
26
+
27
+ public function getActive()
28
+ {
29
+ // return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
30
+ return Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
31
+ }
32
+
33
+ public function getSkyboxLog()
34
+ {
35
+ return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxlog', Mage::app()->getStore());
36
+ }
37
+
38
+ public function getSkyboxEmail()
39
+ {
40
+ return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxemail', Mage::app()->getStore());
41
+ }
42
+
43
+ public function getSkyboxIntegration()
44
+ {
45
+ return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxintegration', Mage::app()->getStore());
46
+ }
47
+
48
+ public function getSkyboxUrlAPI()
49
+ {
50
+ return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxurlapi', Mage::app()->getStore());
51
+ }
52
+
53
+ public function getSkyboxUrlMain()
54
+ {
55
+ return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxurlmain', Mage::app()->getStore());
56
+ }
57
+
58
+ public function getEnabledAddSumTaxToPrice()
59
+ {
60
+ return Mage::getStoreConfig('skyboxinternational/skyboxproduct/skyboxaddtaxtopriceenable', Mage::app()->getStore());
61
+ }
62
+
63
+ public function getStoreId()
64
+ {
65
+ //return $this->helper('core')->getStoreId();
66
+ return Mage::app()->getStore()->getId();
67
+ }
68
+
69
+ public function getCartId()
70
+ {
71
+ return Mage::getSingleton('checkout/session')->getQuoteId();
72
+ }
73
+
74
+ public function getCssVersion()
75
+ {
76
+ return Mage::getModel('skyboxcatalog/api_product')->getCssVersion();
77
+ }
78
  }
app/code/community/Skybox/International/Model/Config.php CHANGED
@@ -1,16 +1,16 @@
1
- <?php
2
- /**
3
- * Skybox International
4
- *
5
- * @category Skybox
6
- * @package Skybox_International
7
- * @subpackage Skybox_International_Model
8
- * @copyright Copyright (c) 2014 SkyBOX Checkout Inc. (http://www.skyboxcheckout.com)
9
- */
10
-
11
- class Skybox_International_Model_Config extends Mage_Core_Model_Abstract
12
- {
13
- public function __construct($params = array())
14
- {
15
- }
16
  }
1
+ <?php
2
+ /**
3
+ * Skybox International
4
+ *
5
+ * @category Skybox
6
+ * @package Skybox_International
7
+ * @subpackage Skybox_International_Model
8
+ * @copyright Copyright (c) 2014 SkyBOX Checkout Inc. (http://www.skyboxcheckout.com)
9
+ */
10
+
11
+ class Skybox_International_Model_Config extends Mage_Core_Model_Abstract
12
+ {
13
+ public function __construct($params = array())
14
+ {
15
+ }
16
  }
app/code/community/Skybox/International/Model/StoreType.php CHANGED
@@ -1,12 +1,12 @@
1
- <?php
2
-
3
- class Skybox_International_Model_StoreType
4
- {
5
- public function toOptionArray()
6
- {
7
- return array(
8
- array('value' => '1', 'label' => "Store Type 1"),
9
- array('value' => '3', 'label' => "Store Type 3"),
10
- );
11
- }
12
- }
1
+ <?php
2
+
3
+ class Skybox_International_Model_StoreType
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value' => '1', 'label' => "Store Type 1"),
9
+ array('value' => '3', 'label' => "Store Type 3"),
10
+ );
11
+ }
12
+ }
app/code/community/Skybox/International/etc/adminhtml.xml CHANGED
@@ -1,39 +1,39 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <config>
3
- <menu>
4
- <skyboxinternational translate="title" module="skyboxinternational">
5
- <title>Skybox Checkout</title>
6
- <sort_order>300</sort_order>
7
- <children>
8
- <skyboxinternational translate="title" module="skyboxinternational">
9
- <title>Skybox Settings</title>
10
- <sort_order>1</sort_order>
11
- <action>adminhtml/system_config/edit/section/skyboxinternational</action>
12
- </skyboxinternational>
13
- </children>
14
- </skyboxinternational>
15
- </menu>
16
- <acl>
17
- <resources>
18
- <all>
19
- <title>Allow Everything</title>
20
- </all>
21
- <admin>
22
- <children>
23
- <system>
24
- <children>
25
- <config>
26
- <children>
27
- <skyboxinternational translate="title" module="skyboxinternational">
28
- <title>Skybox Checkout</title>
29
- <sort_order>300</sort_order>
30
- </skyboxinternational>
31
- </children>
32
- </config>
33
- </children>
34
- </system>
35
- </children>
36
- </admin>
37
- </resources>
38
- </acl>
39
- </config>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <menu>
4
+ <skyboxinternational translate="title" module="skyboxinternational">
5
+ <title>Skybox Checkout</title>
6
+ <sort_order>300</sort_order>
7
+ <children>
8
+ <skyboxinternational translate="title" module="skyboxinternational">
9
+ <title>Skybox Settings</title>
10
+ <sort_order>1</sort_order>
11
+ <action>adminhtml/system_config/edit/section/skyboxinternational</action>
12
+ </skyboxinternational>
13
+ </children>
14
+ </skyboxinternational>
15
+ </menu>
16
+ <acl>
17
+ <resources>
18
+ <all>
19
+ <title>Allow Everything</title>
20
+ </all>
21
+ <admin>
22
+ <children>
23
+ <system>
24
+ <children>
25
+ <config>
26
+ <children>
27
+ <skyboxinternational translate="title" module="skyboxinternational">
28
+ <title>Skybox Checkout</title>
29
+ <sort_order>300</sort_order>
30
+ </skyboxinternational>
31
+ </children>
32
+ </config>
33
+ </children>
34
+ </system>
35
+ </children>
36
+ </admin>
37
+ </resources>
38
+ </acl>
39
+ </config>
app/code/community/Skybox/International/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Skybox_International>
5
- <version>1.2.10</version>
6
  <codePool>community</codePool>
7
  </Skybox_International>
8
  </modules>
2
  <config>
3
  <modules>
4
  <Skybox_International>
5
+ <version>1.2.11</version>
6
  <codePool>community</codePool>
7
  </Skybox_International>
8
  </modules>
app/code/community/Skybox/International/etc/system.xml CHANGED
@@ -1,136 +1,136 @@
1
- <config>
2
- <tabs>
3
- <skyboxinternational translate="label" module="skyboxinternational">
4
- <label>Skybox Checkout</label>
5
- <sort_order>100</sort_order>
6
- </skyboxinternational>
7
- </tabs>
8
- <sections>
9
- <skyboxinternational translate="label" module="skyboxinternational">
10
- <label>Skybox Checkout Settings</label>
11
- <tab>skyboxinternational</tab>
12
- <sort_order>1000</sort_order>
13
- <show_in_default>1</show_in_default>
14
- <show_in_website>1</show_in_website>
15
- <show_in_store>1</show_in_store>
16
- <groups>
17
- <skyboxsettings translate="label" module="skyboxinternational">
18
- <label>Merchant Settings</label>
19
- <frontend_type>text</frontend_type>
20
- <sort_order>10</sort_order>
21
- <show_in_default>1</show_in_default>
22
- <show_in_website>1</show_in_website>
23
- <show_in_store>1</show_in_store>
24
- <fields>
25
- <skyboxactive translate="label">
26
- <label>Enabled</label>
27
- <frontend_type>select</frontend_type>
28
- <source_model>adminhtml/system_config_source_yesno</source_model>
29
- <sort_order>1</sort_order>
30
- <show_in_default>1</show_in_default>
31
- <show_in_website>1</show_in_website>
32
- <show_in_store>1</show_in_store>
33
- </skyboxactive>
34
- <merchantcode translate="label">
35
- <label>Merchant Id:</label>
36
- <comment>Code Merchant by Skybox Checkout International</comment>
37
- <frontend_type>text</frontend_type>
38
- <sort_order>2</sort_order>
39
- <show_in_default>1</show_in_default>
40
- <show_in_website>1</show_in_website>
41
- <show_in_store>1</show_in_store>
42
- </merchantcode>
43
- <merchantkey translate="label">
44
- <label>Merchant Key:</label>
45
- <comment>Key Merchant by Skybox Checkout International</comment>
46
- <frontend_type>text</frontend_type>
47
- <sort_order>3</sort_order>
48
- <show_in_default>1</show_in_default>
49
- <show_in_website>1</show_in_website>
50
- <show_in_store>1</show_in_store>
51
- </merchantkey>
52
- <weigthunitproduct translate="label">
53
- <label>Weight Unit:</label>
54
- <comment>Source model provider Magento's unit of measure values</comment>
55
- <frontend_type>select</frontend_type>
56
- <sort_order>4</sort_order>
57
- <show_in_default>1</show_in_default>
58
- <show_in_website>1</show_in_website>
59
- <show_in_store>1</show_in_store>
60
- <source_model>usa/shipping_carrier_ups_source_unitofmeasure</source_model>
61
- </weigthunitproduct>
62
- <skyboxlog translate="label">
63
- <label>Save API Responses</label>
64
- <frontend_type>select</frontend_type>
65
- <source_model>adminhtml/system_config_source_yesno</source_model>
66
- <sort_order>5</sort_order>
67
- <show_in_default>1</show_in_default>
68
- <show_in_website>1</show_in_website>
69
- <show_in_store>1</show_in_store>
70
- </skyboxlog>
71
- <skyboxemail translate="label">
72
- <label>SkyBox Email:</label>
73
- <comment>SkyBox Email</comment>
74
- <frontend_type>text</frontend_type>
75
- <validate>validate-email</validate>
76
- <sort_order>6</sort_order>
77
- <show_in_default>1</show_in_default>
78
- <show_in_website>1</show_in_website>
79
- <show_in_store>1</show_in_store>
80
- </skyboxemail>
81
- <skyboxintegration translate="label">
82
- <label>SkyBox Itegration:</label>
83
- <comment>SkyBox Integration</comment>
84
- <frontend_type>select</frontend_type>
85
- <!--<source_model>adminhtml/system_config_source_yesno</source_model>-->
86
- <source_model>Skybox_International_Model_StoreType</source_model>
87
- <!--<frontend_type>text</frontend_type>-->
88
- <sort_order>7</sort_order>
89
- <show_in_default>1</show_in_default>
90
- <show_in_website>1</show_in_website>
91
- <show_in_store>1</show_in_store>
92
- </skyboxintegration>
93
- <skyboxurlapi translate="label">
94
- <label>SkyBox Url API:</label>
95
- <comment>Url API By Skybox Checkout International</comment>
96
- <frontend_type>text</frontend_type>
97
- <sort_order>8</sort_order>
98
- <show_in_default>1</show_in_default>
99
- <show_in_website>1</show_in_website>
100
- <show_in_store>1</show_in_store>
101
- </skyboxurlapi>
102
- <skyboxurlmain translate="label">
103
- <label>SkyBox Url Client:</label>
104
- <comment>Url Client By Skybox Checkout International</comment>
105
- <frontend_type>text</frontend_type>
106
- <sort_order>9</sort_order>
107
- <show_in_default>1</show_in_default>
108
- <show_in_website>1</show_in_website>
109
- <show_in_store>1</show_in_store>
110
- </skyboxurlmain>
111
- </fields>
112
- </skyboxsettings>
113
- <skyboxproduct translate="label" module="skyboxinternational">
114
- <label>Tax Product</label>
115
- <frontend_type>text</frontend_type>
116
- <!--<comment>Tax + Price product</comment>-->
117
- <sort_order>20</sort_order>
118
- <show_in_default>1</show_in_default>
119
- <show_in_website>1</show_in_website>
120
- <show_in_store>1</show_in_store>
121
- <fields>
122
- <skyboxaddtaxtopriceenable translate="label">
123
- <label>Add Tax to Price</label>
124
- <frontend_type>select</frontend_type>
125
- <source_model>adminhtml/system_config_source_yesno</source_model>
126
- <sort_order>1</sort_order>
127
- <show_in_default>1</show_in_default>
128
- <show_in_website>1</show_in_website>
129
- <show_in_store>1</show_in_store>
130
- </skyboxaddtaxtopriceenable>
131
- </fields>
132
- </skyboxproduct>
133
- </groups>
134
- </skyboxinternational>
135
- </sections>
136
  </config>
1
+ <config>
2
+ <tabs>
3
+ <skyboxinternational translate="label" module="skyboxinternational">
4
+ <label>Skybox Checkout</label>
5
+ <sort_order>100</sort_order>
6
+ </skyboxinternational>
7
+ </tabs>
8
+ <sections>
9
+ <skyboxinternational translate="label" module="skyboxinternational">
10
+ <label>Skybox Checkout Settings</label>
11
+ <tab>skyboxinternational</tab>
12
+ <sort_order>1000</sort_order>
13
+ <show_in_default>1</show_in_default>
14
+ <show_in_website>1</show_in_website>
15
+ <show_in_store>1</show_in_store>
16
+ <groups>
17
+ <skyboxsettings translate="label" module="skyboxinternational">
18
+ <label>Merchant Settings</label>
19
+ <frontend_type>text</frontend_type>
20
+ <sort_order>10</sort_order>
21
+ <show_in_default>1</show_in_default>
22
+ <show_in_website>1</show_in_website>
23
+ <show_in_store>1</show_in_store>
24
+ <fields>
25
+ <skyboxactive translate="label">
26
+ <label>Enabled</label>
27
+ <frontend_type>select</frontend_type>
28
+ <source_model>adminhtml/system_config_source_yesno</source_model>
29
+ <sort_order>1</sort_order>
30
+ <show_in_default>1</show_in_default>
31
+ <show_in_website>1</show_in_website>
32
+ <show_in_store>1</show_in_store>
33
+ </skyboxactive>
34
+ <merchantcode translate="label">
35
+ <label>Merchant Id:</label>
36
+ <comment>Code Merchant by Skybox Checkout International</comment>
37
+ <frontend_type>text</frontend_type>
38
+ <sort_order>2</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ </merchantcode>
43
+ <merchantkey translate="label">
44
+ <label>Merchant Key:</label>
45
+ <comment>Key Merchant by Skybox Checkout International</comment>
46
+ <frontend_type>text</frontend_type>
47
+ <sort_order>3</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ </merchantkey>
52
+ <weigthunitproduct translate="label">
53
+ <label>Weight Unit:</label>
54
+ <comment>Source model provider Magento's unit of measure values</comment>
55
+ <frontend_type>select</frontend_type>
56
+ <sort_order>4</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ <source_model>usa/shipping_carrier_ups_source_unitofmeasure</source_model>
61
+ </weigthunitproduct>
62
+ <skyboxlog translate="label">
63
+ <label>Save API Responses</label>
64
+ <frontend_type>select</frontend_type>
65
+ <source_model>adminhtml/system_config_source_yesno</source_model>
66
+ <sort_order>5</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>1</show_in_store>
70
+ </skyboxlog>
71
+ <skyboxemail translate="label">
72
+ <label>SkyBox Email:</label>
73
+ <comment>SkyBox Email</comment>
74
+ <frontend_type>text</frontend_type>
75
+ <validate>validate-email</validate>
76
+ <sort_order>6</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <show_in_store>1</show_in_store>
80
+ </skyboxemail>
81
+ <skyboxintegration translate="label">
82
+ <label>SkyBox Itegration:</label>
83
+ <comment>SkyBox Integration</comment>
84
+ <frontend_type>select</frontend_type>
85
+ <!--<source_model>adminhtml/system_config_source_yesno</source_model>-->
86
+ <source_model>Skybox_International_Model_StoreType</source_model>
87
+ <!--<frontend_type>text</frontend_type>-->
88
+ <sort_order>7</sort_order>
89
+ <show_in_default>1</show_in_default>
90
+ <show_in_website>1</show_in_website>
91
+ <show_in_store>1</show_in_store>
92
+ </skyboxintegration>
93
+ <skyboxurlapi translate="label">
94
+ <label>SkyBox Url API:</label>
95
+ <comment>Url API By Skybox Checkout International</comment>
96
+ <frontend_type>text</frontend_type>
97
+ <sort_order>8</sort_order>
98
+ <show_in_default>1</show_in_default>
99
+ <show_in_website>1</show_in_website>
100
+ <show_in_store>1</show_in_store>
101
+ </skyboxurlapi>
102
+ <skyboxurlmain translate="label">
103
+ <label>SkyBox Url Client:</label>
104
+ <comment>Url Client By Skybox Checkout International</comment>
105
+ <frontend_type>text</frontend_type>
106
+ <sort_order>9</sort_order>
107
+ <show_in_default>1</show_in_default>
108
+ <show_in_website>1</show_in_website>
109
+ <show_in_store>1</show_in_store>
110
+ </skyboxurlmain>
111
+ </fields>
112
+ </skyboxsettings>
113
+ <skyboxproduct translate="label" module="skyboxinternational">
114
+ <label>Tax Product</label>
115
+ <frontend_type>text</frontend_type>
116
+ <!--<comment>Tax + Price product</comment>-->
117
+ <sort_order>20</sort_order>
118
+ <show_in_default>1</show_in_default>
119
+ <show_in_website>1</show_in_website>
120
+ <show_in_store>1</show_in_store>
121
+ <fields>
122
+ <skyboxaddtaxtopriceenable translate="label">
123
+ <label>Add Tax to Price</label>
124
+ <frontend_type>select</frontend_type>
125
+ <source_model>adminhtml/system_config_source_yesno</source_model>
126
+ <sort_order>1</sort_order>
127
+ <show_in_default>1</show_in_default>
128
+ <show_in_website>1</show_in_website>
129
+ <show_in_store>1</show_in_store>
130
+ </skyboxaddtaxtopriceenable>
131
+ </fields>
132
+ </skyboxproduct>
133
+ </groups>
134
+ </skyboxinternational>
135
+ </sections>
136
  </config>
app/code/community/Skybox/Services/Model/Api.php CHANGED
@@ -1,310 +1,354 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Services
5
- *
6
- * @category Skybox
7
- * @package Skybox_Services
8
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
-
11
- /**
12
- *
13
- * Skybox Services API
14
- *
15
- * @author Luis Alex Cordova Leon <lcordova@skyworldint.com>
16
- */
17
-
18
- class Skybox_Services_Model_Api extends Mage_Api_Model_Resource_Abstract
19
- {
20
- const SKYBOX_SHIPPING = 'skyboxcheckout_shipping_skyboxcheckout';
21
- const SKYBOX_PAYMENT = 'skyboxcheckout_pay';
22
-
23
- public function __construct()
24
- {
25
- Mage::log("API Construct started " . date('m/d/Y h:i:s a', time()));
26
- }
27
-
28
-
29
- /**
30
- * Field name in session for saving store id
31
- * @var int $orderIncrementId
32
- * @var string $status
33
- * @return boolean
34
- */
35
- public function setStatusOrder($orderIncrementId, $status)
36
- {
37
- try {
38
- $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
39
- $order->setData('state', $status); //complete
40
- $order->setStatus($status);
41
- if(Mage_Sales_Model_Order::STATE_PROCESSING == $status){
42
- $order->setTotalPaid($order->getGrandTotal());
43
- }elseif(Mage_Sales_Model_Order::STATE_COMPLETE == $status){
44
- $history = $order->addStatusHistoryComment('La orden se estableció como completa', false);
45
- $history->setIsCustomerNotified(false);
46
- }
47
- $order->save();
48
- return true;
49
- } catch (Exception $e) {
50
- return false;
51
- }
52
- }
53
-
54
-
55
- public function setQuoteDesactive($quoteId)
56
- {
57
- try {
58
- Mage::log("API setQuoteDesactive started " . date('m/d/Y h:i:s a', time()));
59
- $quote = Mage::getModel("sales/quote");
60
- $quote->loadByIdWithoutStore($quoteId);
61
- $quote->setIsActive(false);
62
- $quote->save();
63
- Mage::log("API setQuoteDesactive finished " . date('m/d/Y h:i:s a', time()));
64
- return true;
65
- } catch (Exception $e) {
66
- return false;
67
- }
68
- }
69
-
70
- /*
71
- * Return a order generated
72
- *
73
- * @params many
74
- * @return integer Quote ID
75
- */
76
- public function generateOrder($IdCart, $IdStore, $CustomerName, $CustomerLasName, $CustomerEmail, $CustomerAdresss, $CustomerPhone, $CustomerZipCode, $CityName, $CountryId, $RegionId, $regionName = '')
77
- {
78
-
79
- Mage::log("API generateOrder started " . date('m/d/Y h:i:s a', time()));
80
-
81
- $quoteId = $IdCart; // should be!
82
-
83
- /* @var $quote Mage_Sales_Model_Quote */
84
- $quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
85
-
86
- $address = $quote->getShippingAddress();
87
-
88
- foreach ($quote->getAllItems() as $item) {
89
- Mage::log(print_r($item->debug(), true), null, 'tracer.log', true);
90
- $item->setCustomPrice($item->getPriceUsdSkybox());
91
- $item->setOriginalCustomPrice($item->getPriceUsdSkybox());
92
- // getOrderCurrencyCode
93
- // $item->getProduct()->setIsSuperMode(true);
94
- // $item->save();
95
- }
96
-
97
- /*
98
- // Bug: When a customer is already registered as guest,
99
- // it doesn't work with Customer validation
100
-
101
- /* @var $customer Mage_Customer_Model_Customer
102
- $customer = Mage::getModel('customer/customer');
103
- $customer
104
- ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())// or 1
105
- ->loadByEmail($CustomerEmail);
106
-
107
- if ($customer->getId()) {
108
- $quote->assignCustomer($customer); // for customer orders
109
- } else {
110
- // ...
111
- }
112
- */
113
-
114
- // for guest orders only
115
- $quote->setIsMultiShipping(false);
116
- $quote->setCheckoutMethod('guest');
117
- $quote->setCustomerId(null);
118
- $quote->setCustomerEmail($CustomerEmail);
119
- $quote->setCustomerIsGuest(true);
120
- $quote->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
121
-
122
- $grandTotal = $address->getBaseGrandTotalSkybox();
123
- // $quote->setBaseGrandTotal($grandTotal);
124
- // $quote->setGrandTotal($grandTotal);
125
- // setBaseCurrencyCode(string $value)
126
- // setGlobalCurrencyCode(string $value)
127
- // setQuoteCurrencyCode(string $value)
128
- // setStoreCurrencyCode(string $value)
129
-
130
- // Just for Guest User
131
- $CustomerLasName = ($CustomerLasName != null) ? $CustomerLasName : $CustomerName;
132
-
133
- $addressData = array(
134
- 'firstname' => $CustomerName,
135
- 'lastname' => $CustomerLasName,
136
- 'street' => $CustomerAdresss,
137
- 'city' => $CityName,
138
- 'postcode' => $CustomerZipCode,
139
- 'telephone' => $CustomerPhone,
140
- 'country_id' => $CountryId,
141
- 'region_id' => $RegionId,
142
- 'region' => $regionName,
143
- 'is_default_billing' => '1',
144
- );
145
-
146
- $billingAddress = $quote->getBillingAddress()->addData($addressData);
147
- $shippingAddress = $quote->getShippingAddress()->addData($addressData);
148
-
149
- // if(!Mage::getStoreConfig('payment/checkmo/active')){
150
- // Mage::log('Desactivado checkmo', null, 'tracer.log', true);
151
- // Mage::app()->getStore()->setConfig('payment/checkmo/active', true);
152
- // }
153
-
154
- $shippingAddress->setCollectShippingRates(true)
155
- ->collectShippingRates()
156
- ->setShippingMethod(self::SKYBOX_SHIPPING)//flatrate_flatrate
157
- ->setPaymentMethod(self::SKYBOX_PAYMENT);
158
-
159
- $quote->getPayment()->importData(array('method' => self::SKYBOX_PAYMENT));
160
- // $quote->getPayment()->importData(array('method' => 'checkmo'));
161
-
162
- $quote->collectTotals()->save();
163
-
164
- $address->setGrandTotal($grandTotal);
165
- $address->setBaseGrandTotal($grandTotal);
166
-
167
- $service = Mage::getModel('sales/service_quote', $quote);
168
- $service->submitAll();
169
-
170
- try {
171
- $order = $service->getOrder();
172
-
173
- // Comment
174
- $comment = "This order was generated by Skybox Checkout";
175
- $order->addStatusHistoryComment($comment);
176
- $order->save();
177
-
178
- // setQuoteDesactive
179
- $this->setQuoteDesactive($quoteId);
180
- //$quote->setIsActive(false);
181
-
182
- /*Mage::log("Order " . $order->getIncrementId() . " was created");
183
- Mage::log("API generateOrder finished " . date('m/d/Y h:i:s a', time()));
184
- Mage::log("API Construct finished " . date('m/d/Y h:i:s a', time()));
185
- Mage::log("getShippingMethod: " . $order->getShippingMethod());*/
186
- return $order->getIncrementId();
187
- } catch (Exception $e) {
188
- Mage::log("exception", null, 'servicios.log', true);
189
- Mage::log($e->getMessage());
190
- }
191
- }
192
-
193
- public function generateOrderFull($DataProducts, $IdStore, $CustomerName, $CustomerLasName, $CustomerEmail, $CustomerAdresss, $CustomerPhone, $CustomerZipCode, $CityName, $CountryId, $RegionId, $regionName = '')
194
- {
195
- Mage::log("API generateOrderFull started " . date('m/d/Y h:i:s a', time()));
196
-
197
- $IdStore = !empty($IdStore)?$IdStore:Mage::app()->getStore('default')->getId();
198
- $quote = Mage::getModel('sales/quote')->setStoreId($IdStore);
199
- $productList = array();
200
- $objData = json_decode($DataProducts);
201
- Mage::log('########### $objData ###########', null, 'tracer.log', true);
202
- Mage::log(print_r($objData, true), null, 'tracer.log', true);
203
- if(count($objData->Products)>0){
204
- foreach ($objData->Products as $prod){
205
- $product = Mage::getModel('catalog/product')->load($prod->ProductId);
206
- $buyInfo = array(
207
- 'qty' => $prod->Quantity,
208
- // custom option id => value id
209
- // or
210
- // configurable attribute id => value id
211
- );
212
- $productList[$prod->ProductId] = $prod;
213
- $quote->addProduct($product, new Varien_Object($buyInfo));
214
- }
215
- }
216
- Mage::log('########### $productList ###########', null, 'tracer.log', true);
217
- Mage::log(print_r($productList, true), null, 'tracer.log', true);
218
-
219
- $quoteId = $quote->getId();
220
-
221
- $address = $quote->getShippingAddress();
222
-
223
- foreach ($quote->getAllItems() as $item) {
224
- Mage::log('########### $item ###########', null, 'tracer.log', true);
225
- // Mage::log(print_r($item->debug(), true), null, 'tracer.log', true);
226
- Mage::log(print_r($item->getProductId(), true), null, 'tracer.log', true);
227
- $prod = $productList[$item->getProductId()];
228
- Mage::log('########### PROD ###########', null, 'tracer.log', true);
229
- Mage::log(print_r($prod, true), null, 'tracer.log', true);
230
- $item->setCustomPrice($prod->ProductPriceUSD);
231
- $item->setOriginalCustomPrice($prod->ProductPriceUSD);
232
- // getOrderCurrencyCode
233
- // $item->getProduct()->setIsSuperMode(true);
234
- // $item->save();
235
- }
236
-
237
- // for guest orders only
238
- $quote->setIsMultiShipping(false);
239
- $quote->setCheckoutMethod('guest');
240
- $quote->setCustomerId(null);
241
- $quote->setCustomerEmail($CustomerEmail);
242
- $quote->setCustomerIsGuest(true);
243
- $quote->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
244
-
245
- // $grandTotal = $address->getBaseGrandTotalSkybox();
246
- $grandTotal = $objData->TotalShoppingCart->TotalPriceUSD;
247
- Mage::log('########### $grandTotal ###########', null, 'tracer.log', true);
248
- Mage::log(print_r($grandTotal, true), null, 'tracer.log', true);
249
- // $quote->setBaseGrandTotal($grandTotal);
250
- // $quote->setGrandTotal($grandTotal);
251
- // setBaseCurrencyCode(string $value)
252
- // setGlobalCurrencyCode(string $value)
253
- // setQuoteCurrencyCode(string $value)
254
- // setStoreCurrencyCode(string $value)
255
-
256
- // Just for Guest User
257
- $CustomerLasName = ($CustomerLasName != null) ? $CustomerLasName : $CustomerName;
258
-
259
- $addressData = array(
260
- 'firstname' => $CustomerName,
261
- 'lastname' => $CustomerLasName,
262
- 'street' => $CustomerAdresss,
263
- 'city' => $CityName,
264
- 'postcode' => $CustomerZipCode,
265
- 'telephone' => $CustomerPhone,
266
- 'country_id' => $CountryId,
267
- 'region_id' => $RegionId,
268
- 'region' => $regionName,
269
- 'is_default_billing' => '1',
270
- );
271
-
272
- $billingAddress = $quote->getBillingAddress()->addData($addressData);
273
- $shippingAddress = $quote->getShippingAddress()->addData($addressData);
274
-
275
- $shippingAddress->setCollectShippingRates(true)
276
- ->collectShippingRates()
277
- ->setShippingMethod(self::SKYBOX_SHIPPING)//flatrate_flatrate
278
- ->setPaymentMethod(self::SKYBOX_PAYMENT);
279
-
280
- $quote->getPayment()->importData(array('method' => self::SKYBOX_PAYMENT));
281
-
282
- $quote->collectTotals()->save();
283
-
284
- $address->setConceptsSkybox(json_encode($objData->TotalShoppingCart->ListDetailConcepts));
285
- $address->setGrandTotal($grandTotal);
286
- $address->setBaseGrandTotal($grandTotal);
287
-
288
- $service = Mage::getModel('sales/service_quote', $quote);
289
- $service->submitAll();
290
-
291
- try {
292
- $order = $service->getOrder();
293
-
294
- // Comment
295
- $comment = "This order was generated by Skybox Checkout";
296
- $order->addStatusHistoryComment($comment);
297
- $order->setTotalPaid($order->getGrandTotal());
298
- $order->save();
299
-
300
- // setQuoteDesactive
301
- $this->setQuoteDesactive($quoteId);
302
- //$quote->setIsActive(false);
303
-
304
- return $order->getIncrementId();
305
- } catch (Exception $e) {
306
- Mage::log("exception", null, 'servicios.log', true);
307
- Mage::log($e->getMessage());
308
- }
309
- }
310
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Services
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Services
8
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+
11
+ /**
12
+ *
13
+ * Skybox Services API
14
+ *
15
+ * @author Luis Alex Cordova Leon <lcordova@skyworldint.com>
16
+ */
17
+ class Skybox_Services_Model_Api extends Mage_Api_Model_Resource_Abstract
18
+ {
19
+ const SKYBOX_SHIPPING = 'skyboxcheckout_shipping_skyboxcheckout';
20
+ const SKYBOX_PAYMENT = 'skyboxcheckout_pay';
21
+
22
+ public function __construct()
23
+ {
24
+ Mage::log("API Construct started " . date('m/d/Y h:i:s a', time()));
25
+ }
26
+
27
+
28
+ /**
29
+ * Field name in session for saving store id
30
+ * @var int $orderIncrementId
31
+ * @var string $status
32
+ * @return boolean
33
+ */
34
+ public function setStatusOrder($orderIncrementId, $status)
35
+ {
36
+ try {
37
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
38
+ $order->setData('state', $status); //complete
39
+ $order->setStatus($status);
40
+ if (Mage_Sales_Model_Order::STATE_PROCESSING == $status) {
41
+ $order->setTotalPaid($order->getGrandTotal());
42
+ } elseif (Mage_Sales_Model_Order::STATE_COMPLETE == $status) {
43
+ $history = $order->addStatusHistoryComment('La orden se estableció como completa', false);
44
+ $history->setIsCustomerNotified(false);
45
+ }
46
+ $order->save();
47
+
48
+ return true;
49
+ } catch (Exception $e) {
50
+ return false;
51
+ }
52
+ }
53
+
54
+
55
+ public function setQuoteDesactive($quoteId)
56
+ {
57
+ try {
58
+ Mage::log("API setQuoteDesactive started " . date('m/d/Y h:i:s a', time()));
59
+ $quote = Mage::getModel("sales/quote");
60
+ $quote->loadByIdWithoutStore($quoteId);
61
+ $quote->setIsActive(false);
62
+ $quote->save();
63
+ Mage::log("API setQuoteDesactive finished " . date('m/d/Y h:i:s a', time()));
64
+
65
+ return true;
66
+ } catch (Exception $e) {
67
+ return false;
68
+ }
69
+ }
70
+
71
+ /*
72
+ * Return a order generated
73
+ *
74
+ * @params many
75
+ * @return integer Quote ID
76
+ */
77
+ public function generateOrder(
78
+ $IdCart,
79
+ $IdStore,
80
+ $CustomerName,
81
+ $CustomerLasName,
82
+ $CustomerEmail,
83
+ $CustomerAdresss,
84
+ $CustomerPhone,
85
+ $CustomerZipCode,
86
+ $CityName,
87
+ $CountryId,
88
+ $RegionId,
89
+ $regionName = ''
90
+ ) {
91
+
92
+ Mage::log("API generateOrder started " . date('m/d/Y h:i:s a', time()));
93
+
94
+ $quoteId = $IdCart; // should be!
95
+
96
+ /* @var $quote Mage_Sales_Model_Quote */
97
+ $quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
98
+
99
+ $address = $quote->getShippingAddress();
100
+
101
+ foreach ($quote->getAllItems() as $item) {
102
+ Mage::log(print_r($item->debug(), true), null, 'tracer.log', true);
103
+ $item->setCustomPrice($item->getPriceUsdSkybox());
104
+ $item->setOriginalCustomPrice($item->getPriceUsdSkybox());
105
+ // getOrderCurrencyCode
106
+ // $item->getProduct()->setIsSuperMode(true);
107
+ // $item->save();
108
+ }
109
+
110
+ /*
111
+ // Bug: When a customer is already registered as guest,
112
+ // it doesn't work with Customer validation
113
+
114
+ /* @var $customer Mage_Customer_Model_Customer
115
+ $customer = Mage::getModel('customer/customer');
116
+ $customer
117
+ ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())// or 1
118
+ ->loadByEmail($CustomerEmail);
119
+
120
+ if ($customer->getId()) {
121
+ $quote->assignCustomer($customer); // for customer orders
122
+ } else {
123
+ // ...
124
+ }
125
+ */
126
+
127
+ // for guest orders only
128
+ $quote->setIsMultiShipping(false);
129
+ $quote->setCheckoutMethod('guest');
130
+ $quote->setCustomerId(null);
131
+ $quote->setCustomerEmail($CustomerEmail);
132
+ $quote->setCustomerIsGuest(true);
133
+ $quote->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
134
+
135
+ $grandTotal = $address->getBaseGrandTotalSkybox();
136
+ // $quote->setBaseGrandTotal($grandTotal);
137
+ // $quote->setGrandTotal($grandTotal);
138
+ // setBaseCurrencyCode(string $value)
139
+ // setGlobalCurrencyCode(string $value)
140
+ // setQuoteCurrencyCode(string $value)
141
+ // setStoreCurrencyCode(string $value)
142
+
143
+ // Just for Guest User
144
+ $CustomerLasName = ($CustomerLasName != null) ? $CustomerLasName : $CustomerName;
145
+
146
+ $addressData = array(
147
+ 'firstname' => $CustomerName,
148
+ 'lastname' => $CustomerLasName,
149
+ 'street' => $CustomerAdresss,
150
+ 'city' => $CityName,
151
+ 'postcode' => $CustomerZipCode,
152
+ 'telephone' => $CustomerPhone,
153
+ 'country_id' => $CountryId,
154
+ 'region_id' => $RegionId,
155
+ 'region' => $regionName,
156
+ 'is_default_billing' => '1',
157
+ );
158
+
159
+ $billingAddress = $quote->getBillingAddress()->addData($addressData);
160
+ $shippingAddress = $quote->getShippingAddress()->addData($addressData);
161
+
162
+ // if(!Mage::getStoreConfig('payment/checkmo/active')){
163
+ // Mage::log('Desactivado checkmo', null, 'tracer.log', true);
164
+ // Mage::app()->getStore()->setConfig('payment/checkmo/active', true);
165
+ // }
166
+
167
+ $shippingAddress->setCollectShippingRates(true)
168
+ ->collectShippingRates()
169
+ ->setShippingMethod(self::SKYBOX_SHIPPING)//flatrate_flatrate
170
+ ->setPaymentMethod(self::SKYBOX_PAYMENT);
171
+
172
+ $quote->getPayment()->importData(array('method' => self::SKYBOX_PAYMENT));
173
+ // $quote->getPayment()->importData(array('method' => 'checkmo'));
174
+
175
+ $quote->collectTotals()->save();
176
+
177
+ $address->setGrandTotal($grandTotal);
178
+ $address->setBaseGrandTotal($grandTotal);
179
+
180
+ $service = Mage::getModel('sales/service_quote', $quote);
181
+ $service->submitAll();
182
+
183
+ try {
184
+ $order = $service->getOrder();
185
+
186
+ // Comment
187
+ $comment = "This order was generated by Skybox Checkout";
188
+ $order->addStatusHistoryComment($comment);
189
+ $order->save();
190
+
191
+ // setQuoteDesactive
192
+ $this->setQuoteDesactive($quoteId);
193
+ //$quote->setIsActive(false);
194
+
195
+ /*Mage::log("Order " . $order->getIncrementId() . " was created");
196
+ Mage::log("API generateOrder finished " . date('m/d/Y h:i:s a', time()));
197
+ Mage::log("API Construct finished " . date('m/d/Y h:i:s a', time()));
198
+ Mage::log("getShippingMethod: " . $order->getShippingMethod());*/
199
+
200
+ return $order->getIncrementId();
201
+ } catch (Exception $e) {
202
+ Mage::log("exception", null, 'servicios.log', true);
203
+ Mage::log($e->getMessage());
204
+ }
205
+ }
206
+
207
+ public function generateOrderFull(
208
+ $DataProducts,
209
+ $IdStore,
210
+ $CustomerName,
211
+ $CustomerLasName,
212
+ $CustomerEmail,
213
+ $CustomerAdresss,
214
+ $CustomerPhone,
215
+ $CustomerZipCode,
216
+ $CityName,
217
+ $CountryId,
218
+ $RegionId,
219
+ $regionName = ''
220
+ ) {
221
+ Mage::log("API generateOrderFull started " . date('m/d/Y h:i:s a', time()));
222
+
223
+ $IdStore = ! empty($IdStore) ? $IdStore : Mage::app()->getStore('default')->getId();
224
+
225
+ /** @var $quote Mage_Sales_Model_Quote */
226
+ $quote = Mage::getModel('sales/quote')->setStoreId($IdStore);
227
+ $productList = array();
228
+ $objData = json_decode($DataProducts);
229
+ Mage::log('########### $objData ###########', null, 'tracer.log', true);
230
+ Mage::log(print_r($objData, true), null, 'tracer.log', true);
231
+ if (count($objData->Products) > 0) {
232
+ foreach ($objData->Products as $prod) {
233
+ $product = Mage::getModel('catalog/product')->load($prod->ProductId);
234
+ $buyInfo = array(
235
+ 'qty' => $prod->Quantity,
236
+ // custom option id => value id
237
+ // or
238
+ // configurable attribute id => value id
239
+ );
240
+ $productList[$prod->ProductId] = $prod;
241
+ $quote->addProduct($product, new Varien_Object($buyInfo));
242
+ }
243
+ }
244
+ Mage::log('########### $productList ###########', null, 'tracer.log', true);
245
+ Mage::log(print_r($productList, true), null, 'tracer.log', true);
246
+
247
+ $quoteId = $quote->getId();
248
+
249
+ /** @var Mage_Sales_Model_Quote_Address $address */
250
+ $address = $quote->getShippingAddress();
251
+
252
+ foreach ($quote->getAllItems() as $item) {
253
+ /** @var $item Mage_Sales_Model_Quote_Item */
254
+
255
+ Mage::log('########### $item ###########', null, 'tracer.log', true);
256
+ // Mage::log(print_r($item->debug(), true), null, 'tracer.log', true);
257
+ Mage::log(print_r($item->getProductId(), true), null, 'tracer.log', true);
258
+ $prod = $productList[$item->getProductId()];
259
+ Mage::log('########### PROD ###########', null, 'tracer.log', true);
260
+ Mage::log(print_r($prod, true), null, 'tracer.log', true);
261
+ $item->setCustomPrice($prod->ProductPriceUSD);
262
+ $item->setOriginalCustomPrice($prod->ProductPriceUSD);
263
+ $item->setTaxAmount(0);
264
+ $item->setBaseTaxAmount(0);
265
+ $item->setTaxPercent(0);
266
+ $item->setTaxPercent(0);
267
+ $item->setBaseHiddenTaxAmount(0);
268
+
269
+ // getOrderCurrencyCode
270
+ // $item->getProduct()->setIsSuperMode(true);
271
+ // $item->save();
272
+ }
273
+
274
+ // for guest orders only
275
+ $quote->setIsMultiShipping(false);
276
+ $quote->setCheckoutMethod('guest');
277
+ $quote->setCustomerId(null);
278
+ $quote->setCustomerEmail($CustomerEmail);
279
+ $quote->setCustomerIsGuest(true);
280
+ $quote->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
281
+
282
+ $quote->setCustomerTaxClassId(0);
283
+
284
+ // $grandTotal = $address->getBaseGrandTotalSkybox();
285
+ $grandTotal = $objData->TotalShoppingCart->TotalPriceUSD;
286
+ Mage::log('########### $grandTotal ###########', null, 'tracer.log', true);
287
+ Mage::log(print_r($grandTotal, true), null, 'tracer.log', true);
288
+ // $quote->setBaseGrandTotal($grandTotal);
289
+ // $quote->setGrandTotal($grandTotal);
290
+ // setBaseCurrencyCode(string $value)
291
+ // setGlobalCurrencyCode(string $value)
292
+ // setQuoteCurrencyCode(string $value)
293
+ // setStoreCurrencyCode(string $value)
294
+
295
+
296
+ // Just for Guest User
297
+ $CustomerLasName = ($CustomerLasName != null) ? $CustomerLasName : $CustomerName;
298
+
299
+ $addressData = array(
300
+ 'firstname' => $CustomerName,
301
+ 'lastname' => $CustomerLasName,
302
+ 'street' => $CustomerAdresss,
303
+ 'city' => $CityName,
304
+ 'postcode' => $CustomerZipCode,
305
+ 'telephone' => $CustomerPhone,
306
+ 'country_id' => $CountryId,
307
+ 'region_id' => $RegionId,
308
+ 'region' => $regionName,
309
+ 'is_default_billing' => '1',
310
+ );
311
+
312
+ $billingAddress = $quote->getBillingAddress()->addData($addressData);
313
+ $shippingAddress = $quote->getShippingAddress()->addData($addressData);
314
+
315
+ $shippingAddress->setCollectShippingRates(true)
316
+ ->collectShippingRates()
317
+ ->setShippingMethod(self::SKYBOX_SHIPPING)//flatrate_flatrate
318
+ ->setPaymentMethod(self::SKYBOX_PAYMENT);
319
+
320
+ $quote->getPayment()->importData(array('method' => self::SKYBOX_PAYMENT));
321
+
322
+ $quote->collectTotals()->save();
323
+
324
+ $address->setTaxAmount(0);
325
+ $address->setBaseTaxAmount(0);
326
+
327
+ $address->setConceptsSkybox(json_encode($objData->TotalShoppingCart));
328
+ $address->setGrandTotal($grandTotal);
329
+ $address->setBaseGrandTotal($grandTotal);
330
+
331
+ $service = Mage::getModel('sales/service_quote', $quote);
332
+ $service->submitAll();
333
+
334
+ try {
335
+ $order = $service->getOrder();
336
+
337
+ // Comment
338
+ $comment = "This order was generated by Skybox Checkout";
339
+ $order->addStatusHistoryComment($comment);
340
+ $order->setTotalPaid($order->getGrandTotal());
341
+ $order->save();
342
+
343
+ // setQuoteDesactive
344
+ $this->setQuoteDesactive($quoteId);
345
+
346
+ //$quote->setIsActive(false);
347
+
348
+ return $order->getIncrementId();
349
+ } catch (Exception $e) {
350
+ Mage::log("exception", null, 'servicios.log', true);
351
+ Mage::log($e->getMessage());
352
+ }
353
+ }
354
+ }
app/code/community/Skybox/Services/Model/Api/V2.php CHANGED
@@ -1,12 +1,12 @@
1
- <?php
2
-
3
- /**
4
- * Skybox Services
5
- *
6
- * @category Skybox
7
- * @package Skybox_Services
8
- * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
- */
10
- class Skybox_Services_Model_Api_V2 extends Skybox_Services_Model_Api
11
- {
12
  }
1
+ <?php
2
+
3
+ /**
4
+ * Skybox Services
5
+ *
6
+ * @category Skybox
7
+ * @package Skybox_Services
8
+ * @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
9
+ */
10
+ class Skybox_Services_Model_Api_V2 extends Skybox_Services_Model_Api
11
+ {
12
  }
app/code/community/Skybox/Services/etc/api.xml CHANGED
@@ -1,38 +1,38 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <api>
4
- <resources>
5
- <services>
6
- <model>services/api</model>
7
- <title>Skybox Web Services</title>
8
- <methods>
9
- <setStatusOrder translate="title" module="services">
10
- <title>Change status order to complete</title>
11
- <method>setStatusOrder</method>
12
- <acl>services/setStatusOrder</acl>
13
- </setStatusOrder>
14
- <setQuoteDesactive translate="title" module="services">
15
- <title>Change Quote to Desactive</title>
16
- <method>setQuoteDesactive</method>
17
- <acl>services/setQuoteDesactive</acl>
18
- </setQuoteDesactive>
19
- <generateOrder translate="title" module="services">
20
- <title>Generate Order Magento</title>
21
- <method>generateOrder</method>
22
- <acl>services/generateOrder</acl>
23
- </generateOrder>
24
- <generateOrderFull translate="title" module="services">
25
- <title>Generate Order Full Magento</title>
26
- <method>generateOrderFull</method>
27
- <acl>services/generateOrderFull</acl>
28
- </generateOrderFull>
29
- </methods>
30
- </services>
31
- </resources>
32
- <v2>
33
- <resources_function_prefix>
34
- <services>services</services>
35
- </resources_function_prefix>
36
- </v2>
37
- </api>
38
  </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <api>
4
+ <resources>
5
+ <services>
6
+ <model>services/api</model>
7
+ <title>Skybox Web Services</title>
8
+ <methods>
9
+ <setStatusOrder translate="title" module="services">
10
+ <title>Change status order to complete</title>
11
+ <method>setStatusOrder</method>
12
+ <acl>services/setStatusOrder</acl>
13
+ </setStatusOrder>
14
+ <setQuoteDesactive translate="title" module="services">
15
+ <title>Change Quote to Desactive</title>
16
+ <method>setQuoteDesactive</method>
17
+ <acl>services/setQuoteDesactive</acl>
18
+ </setQuoteDesactive>
19
+ <generateOrder translate="title" module="services">
20
+ <title>Generate Order Magento</title>
21
+ <method>generateOrder</method>
22
+ <acl>services/generateOrder</acl>
23
+ </generateOrder>
24
+ <generateOrderFull translate="title" module="services">
25
+ <title>Generate Order Full Magento</title>
26
+ <method>generateOrderFull</method>
27
+ <acl>services/generateOrderFull</acl>
28
+ </generateOrderFull>
29
+ </methods>
30
+ </services>
31
+ </resources>
32
+ <v2>
33
+ <resources_function_prefix>
34
+ <services>services</services>
35
+ </resources_function_prefix>
36
+ </v2>
37
+ </api>
38
  </config>
app/code/community/Skybox/Services/etc/config.xml CHANGED
@@ -3,7 +3,7 @@
3
  <modules>
4
  <Skybox_Services>
5
  <active>true</active>
6
- <version>1.2.10</version>
7
  <codePool>community</codePool>
8
  </Skybox_Services>
9
  </modules>
3
  <modules>
4
  <Skybox_Services>
5
  <active>true</active>
6
+ <version>1.2.11</version>
7
  <codePool>community</codePool>
8
  </Skybox_Services>
9
  </modules>
app/code/community/Skybox/Services/etc/wsdl.xml CHANGED
@@ -1,142 +1,142 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <definitions xmlns:typens="urn:{{var wsdl.name}}" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
3
- xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"
4
- name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}">
5
- <types>
6
- <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
7
- <import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />
8
- </schema>
9
- </types>
10
-
11
- <message name="servicesSetStatusOrderRequest">
12
- <part name="sessionId" type="xsd:string" />
13
- <part name="orderIncrementId" type="xsd:string" />
14
- <part name="status" type="xsd:string" />
15
- </message>
16
- <message name="servicesSetStatusOrderResponse">
17
- <part name="result" type="xsd:boolean" />
18
- </message>
19
-
20
- <message name="servicesSetQuoteDesactiveRequest">
21
- <part name="sessionId" type="xsd:string" />
22
- <part name="quoteId" type="xsd:int" />
23
- </message>
24
- <message name="servicesSetQuoteDesactiveResponse">
25
- <part name="result" type="xsd:boolean" />
26
- </message>
27
-
28
-
29
- <message name="servicesGenerateOrderRequest">
30
- <part name="sessionId" type="xsd:string" />
31
- <part name="IdCart" type="xsd:int" />
32
- <part name="IdStore" type="xsd:string" />
33
- <part name="CustomerName" type="xsd:string" />
34
- <part name="CustomerLasName" type="xsd:string" />
35
- <part name="CustomerEmail" type="xsd:string" />
36
- <part name="CustomerAdresss" type="xsd:string" />
37
- <part name="CustomerPhone" type="xsd:string" />
38
- <part name="CustomerZipCode" type="xsd:string" />
39
- <part name="CityName" type="xsd:string" />
40
- <part name="CountryId" type="xsd:string" />
41
- <part name="RegionId" type="xsd:string" />
42
- <part name="RegionName" type="xsd:string" />
43
- </message>
44
-
45
- <message name="servicesGenerateOrderResponse">
46
- <part name="result" type="xsd:string" />
47
- </message>
48
-
49
- <message name="servicesGenerateOrderFullRequest">
50
- <part name="sessionId" type="xsd:string" />
51
- <part name="DataProducts" type="xsd:string" />
52
- <part name="IdStore" type="xsd:string" />
53
- <part name="CustomerName" type="xsd:string" />
54
- <part name="CustomerLasName" type="xsd:string" />
55
- <part name="CustomerEmail" type="xsd:string" />
56
- <part name="CustomerAdresss" type="xsd:string" />
57
- <part name="CustomerPhone" type="xsd:string" />
58
- <part name="CustomerZipCode" type="xsd:string" />
59
- <part name="CityName" type="xsd:string" />
60
- <part name="CountryId" type="xsd:string" />
61
- <part name="RegionId" type="xsd:string" />
62
- <part name="RegionName" type="xsd:string" />
63
- </message>
64
-
65
- <message name="servicesGenerateOrderFullResponse">
66
- <part name="result" type="xsd:string" />
67
- </message>
68
-
69
-
70
- <portType name="{{var wsdl.handler}}PortType">
71
-
72
- <operation name="servicesSetStatusOrder">
73
- <documentation>Change status order to complete</documentation>
74
- <input message="typens:servicesSetStatusOrderRequest" />
75
- <output message="typens:servicesSetStatusOrderResponse" />
76
- </operation>
77
-
78
- <operation name="servicesSetQuoteDesactive">
79
- <documentation>Change Quote to Desactive</documentation>
80
- <input message="typens:servicesSetQuoteDesactiveRequest" />
81
- <output message="typens:servicesSetQuoteDesactiveResponse" />
82
- </operation>
83
-
84
- <operation name="servicesGenerateOrder">
85
- <documentation>Generate Order Magento</documentation>
86
- <input message="typens:servicesGenerateOrderRequest" />
87
- <output message="typens:servicesGenerateOrderResponse" />
88
- </operation>
89
-
90
- <operation name="servicesGenerateOrderFull">
91
- <documentation>Generate Order Full Magento</documentation>
92
- <input message="typens:servicesGenerateOrderFullRequest" />
93
- <output message="typens:servicesGenerateOrderFullResponse" />
94
- </operation>
95
-
96
-
97
- </portType>
98
- <binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
99
- <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
100
-
101
- <operation name="servicesSetStatusOrder">
102
- <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
103
- <input>
104
- <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
105
- </input>
106
- <output>
107
- <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
108
- </output>
109
- </operation>
110
-
111
- <operation name="servicesSetQuoteDesactive">
112
- <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
113
- <input>
114
- <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
115
- </input>
116
- <output>
117
- <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
118
- </output>
119
- </operation>
120
-
121
- <operation name="servicesGenerateOrder">
122
- <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
123
- <input>
124
- <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
125
- </input>
126
- <output>
127
- <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
128
- </output>
129
- </operation>
130
-
131
- <operation name="servicesGenerateOrderFull">
132
- <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
133
- <input>
134
- <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
135
- </input>
136
- <output>
137
- <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
138
- </output>
139
- </operation>
140
-
141
- </binding>
142
  </definitions>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <definitions xmlns:typens="urn:{{var wsdl.name}}" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
3
+ xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"
4
+ name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}">
5
+ <types>
6
+ <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
7
+ <import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />
8
+ </schema>
9
+ </types>
10
+
11
+ <message name="servicesSetStatusOrderRequest">
12
+ <part name="sessionId" type="xsd:string" />
13
+ <part name="orderIncrementId" type="xsd:string" />
14
+ <part name="status" type="xsd:string" />
15
+ </message>
16
+ <message name="servicesSetStatusOrderResponse">
17
+ <part name="result" type="xsd:boolean" />
18
+ </message>
19
+
20
+ <message name="servicesSetQuoteDesactiveRequest">
21
+ <part name="sessionId" type="xsd:string" />
22
+ <part name="quoteId" type="xsd:int" />
23
+ </message>
24
+ <message name="servicesSetQuoteDesactiveResponse">
25
+ <part name="result" type="xsd:boolean" />
26
+ </message>
27
+
28
+
29
+ <message name="servicesGenerateOrderRequest">
30
+ <part name="sessionId" type="xsd:string" />
31
+ <part name="IdCart" type="xsd:int" />
32
+ <part name="IdStore" type="xsd:string" />
33
+ <part name="CustomerName" type="xsd:string" />
34
+ <part name="CustomerLasName" type="xsd:string" />
35
+ <part name="CustomerEmail" type="xsd:string" />
36
+ <part name="CustomerAdresss" type="xsd:string" />
37
+ <part name="CustomerPhone" type="xsd:string" />
38
+ <part name="CustomerZipCode" type="xsd:string" />
39
+ <part name="CityName" type="xsd:string" />
40
+ <part name="CountryId" type="xsd:string" />
41
+ <part name="RegionId" type="xsd:string" />
42
+ <part name="RegionName" type="xsd:string" />
43
+ </message>
44
+
45
+ <message name="servicesGenerateOrderResponse">
46
+ <part name="result" type="xsd:string" />
47
+ </message>
48
+
49
+ <message name="servicesGenerateOrderFullRequest">
50
+ <part name="sessionId" type="xsd:string" />
51
+ <part name="DataProducts" type="xsd:string" />
52
+ <part name="IdStore" type="xsd:string" />
53
+ <part name="CustomerName" type="xsd:string" />
54
+ <part name="CustomerLasName" type="xsd:string" />
55
+ <part name="CustomerEmail" type="xsd:string" />
56
+ <part name="CustomerAdresss" type="xsd:string" />
57
+ <part name="CustomerPhone" type="xsd:string" />
58
+ <part name="CustomerZipCode" type="xsd:string" />
59
+ <part name="CityName" type="xsd:string" />
60
+ <part name="CountryId" type="xsd:string" />
61
+ <part name="RegionId" type="xsd:string" />
62
+ <part name="RegionName" type="xsd:string" />
63
+ </message>
64
+
65
+ <message name="servicesGenerateOrderFullResponse">
66
+ <part name="result" type="xsd:string" />
67
+ </message>
68
+
69
+
70
+ <portType name="{{var wsdl.handler}}PortType">
71
+
72
+ <operation name="servicesSetStatusOrder">
73
+ <documentation>Change status order to complete</documentation>
74
+ <input message="typens:servicesSetStatusOrderRequest" />
75
+ <output message="typens:servicesSetStatusOrderResponse" />
76
+ </operation>
77
+
78
+ <operation name="servicesSetQuoteDesactive">
79
+ <documentation>Change Quote to Desactive</documentation>
80
+ <input message="typens:servicesSetQuoteDesactiveRequest" />
81
+ <output message="typens:servicesSetQuoteDesactiveResponse" />
82
+ </operation>
83
+
84
+ <operation name="servicesGenerateOrder">
85
+ <documentation>Generate Order Magento</documentation>
86
+ <input message="typens:servicesGenerateOrderRequest" />
87
+ <output message="typens:servicesGenerateOrderResponse" />
88
+ </operation>
89
+
90
+ <operation name="servicesGenerateOrderFull">
91
+ <documentation>Generate Order Full Magento</documentation>
92
+ <input message="typens:servicesGenerateOrderFullRequest" />
93
+ <output message="typens:servicesGenerateOrderFullResponse" />
94
+ </operation>
95
+
96
+
97
+ </portType>
98
+ <binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
99
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
100
+
101
+ <operation name="servicesSetStatusOrder">
102
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
103
+ <input>
104
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
105
+ </input>
106
+ <output>
107
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
108
+ </output>
109
+ </operation>
110
+
111
+ <operation name="servicesSetQuoteDesactive">
112
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
113
+ <input>
114
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
115
+ </input>
116
+ <output>
117
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
118
+ </output>
119
+ </operation>
120
+
121
+ <operation name="servicesGenerateOrder">
122
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
123
+ <input>
124
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
125
+ </input>
126
+ <output>
127
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
128
+ </output>
129
+ </operation>
130
+
131
+ <operation name="servicesGenerateOrderFull">
132
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
133
+ <input>
134
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
135
+ </input>
136
+ <output>
137
+ <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
138
+ </output>
139
+ </operation>
140
+
141
+ </binding>
142
  </definitions>
app/code/community/Skybox/Services/etc/wsi.xml CHANGED
@@ -1,159 +1,159 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <wsdl:definitions xmlns:typens="urn:{{var wsdl.name}}"
3
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
4
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
5
- xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
6
- xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
7
- name="{{var wsdl.name}}"
8
- targetNamespace="urn:{{var wsdl.name}}">
9
- <wsdl:types>
10
- <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:{{var wsdl.name}}">
11
-
12
-
13
- <xsd:element name="servicesSetStatusOrderRequestParam">
14
- <xsd:complexType>
15
- <xsd:sequence>
16
- <xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
17
- <xsd:element minOccurs="1" maxOccurs="1" name="orderIncrementId" type="xsd:string" />
18
- <xsd:element minOccurs="1" maxOccurs="1" name="status" type="xsd:string" />
19
- </xsd:sequence>
20
- </xsd:complexType>
21
- </xsd:element>
22
- <xsd:element name="servicesSetStatusOrderResponseParam">
23
- <xsd:complexType>
24
- <xsd:sequence>
25
- <xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:boolean" />
26
- </xsd:sequence>
27
- </xsd:complexType>
28
- </xsd:element>
29
-
30
-
31
- <xsd:element name="servicesSetQuoteDesactiveRequestParam">
32
- <xsd:complexType>
33
- <xsd:sequence>
34
- <xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
35
- <xsd:element minOccurs="1" maxOccurs="1" name="quoteId" type="xsd:int" />
36
- </xsd:sequence>
37
- </xsd:complexType>
38
- </xsd:element>
39
- <xsd:element name="servicesSetQuoteDesactiveResponseParam">
40
- <xsd:complexType>
41
- <xsd:sequence>
42
- <xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:boolean" />
43
- </xsd:sequence>
44
- </xsd:complexType>
45
- </xsd:element>
46
-
47
-
48
- <xsd:element name="servicesGenerateOrderRequestParam">
49
- <xsd:complexType>
50
- <xsd:sequence>
51
- <xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
52
- <xsd:element minOccurs="1" maxOccurs="1" name="IdCart" type="xsd:int" />
53
- <xsd:element minOccurs="1" maxOccurs="1" name="IdStore" type="xsd:string" />
54
- <xsd:element minOccurs="1" maxOccurs="1" name="CustomerName" type="xsd:string" />
55
- <xsd:element minOccurs="1" maxOccurs="1" name="CustomerLasName" type="xsd:string" />
56
- <xsd:element minOccurs="1" maxOccurs="1" name="CustomerEmail" type="xsd:string" />
57
- <xsd:element minOccurs="1" maxOccurs="1" name="CustomerAdresss" type="xsd:string" />
58
- <xsd:element minOccurs="1" maxOccurs="1" name="CustomerPhone" type="xsd:string" />
59
- <xsd:element minOccurs="1" maxOccurs="1" name="CustomerZipCode" type="xsd:string" />
60
- <xsd:element minOccurs="1" maxOccurs="1" name="CityName" type="xsd:string" />
61
- <xsd:element minOccurs="1" maxOccurs="1" name="CountryId" type="xsd:string" />
62
- <xsd:element minOccurs="1" maxOccurs="1" name="RegionId" type="xsd:string" />
63
- <xsd:element minOccurs="1" maxOccurs="1" name="RegionName" type="xsd:string" />
64
- </xsd:sequence>
65
- </xsd:complexType>
66
- </xsd:element>
67
- <xsd:element name="servicesGenerateOrderResponseParam">
68
- <xsd:complexType>
69
- <xsd:sequence>
70
- <xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:string" />
71
- </xsd:sequence>
72
- </xsd:complexType>
73
- </xsd:element>
74
-
75
-
76
- </xsd:schema>
77
- </wsdl:types>
78
-
79
-
80
- <wsdl:message name="ServicesSetStatusOrderRequest">
81
- <wsdl:part name="parameters" element="typens:servicesSetStatusOrderRequestParam" />
82
- </wsdl:message>
83
- <wsdl:message name="ServicesSetStatusOrderResponse">
84
- <wsdl:part name="parameters" element="typens:servicesSetStatusOrderResponseParam" />
85
- </wsdl:message>
86
-
87
- <wsdl:message name="ServicesSetQuoteDesactiveRequest">
88
- <wsdl:part name="parameters" element="typens:servicesSetQuoteDesactiveRequestParam" />
89
- </wsdl:message>
90
- <wsdl:message name="ServicesSetQuoteDesactiveResponse">
91
- <wsdl:part name="parameters" element="typens:servicesSetQuoteDesactiveResponseParam" />
92
- </wsdl:message>
93
-
94
- <wsdl:message name="ServicesGenerateOrderRequest">
95
- <wsdl:part name="parameters" element="typens:servicesGenerateOrderRequestParam" />
96
- </wsdl:message>
97
- <wsdl:message name="ServicesGenerateOrderResponse">
98
- <wsdl:part name="parameters" element="typens:servicesGenerateOrderResponseParam" />
99
- </wsdl:message>
100
-
101
-
102
- <wsdl:portType name="{{var wsdl.handler}}PortType">
103
-
104
- <wsdl:operation name="ServicesSetStatusOrder">
105
- <wsdl:documentation>Service set status</wsdl:documentation>
106
- <wsdl:input message="typens:ServicesSetStatusOrderRequest" />
107
- <wsdl:output message="typens:ServicesSetStatusOrderResponse" />
108
- </wsdl:operation>
109
-
110
-
111
- <wsdl:operation name="ServicesSetQuoteDesactive">
112
- <wsdl:documentation>Service desactive quote</wsdl:documentation>
113
- <wsdl:input message="typens:ServicesSetQuoteDesactiveRequest" />
114
- <wsdl:output message="typens:ServicesSetQuoteDesactiveResponse" />
115
- </wsdl:operation>
116
-
117
- <wsdl:operation name="ServicesGenerateOrder">
118
- <wsdl:documentation>Generate Order Magento</wsdl:documentation>
119
- <wsdl:input message="typens:ServicesGenerateOrderRequest" />
120
- <wsdl:output message="typens:ServicesGenerateOrderResponse" />
121
- </wsdl:operation>
122
-
123
- </wsdl:portType>
124
-
125
- <wsdl:binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
126
- <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
127
-
128
- <wsdl:operation name="ServicesSetStatusOrder">
129
- <soap:operation soapAction="" />
130
- <wsdl:input>
131
- <soap:body use="literal" />
132
- </wsdl:input>
133
- <wsdl:output>
134
- <soap:body use="literal" />
135
- </wsdl:output>
136
- </wsdl:operation>
137
-
138
- <wsdl:operation name="ServicesSetQuoteDesactive">
139
- <soap:operation soapAction="" />
140
- <wsdl:input>
141
- <soap:body use="literal" />
142
- </wsdl:input>
143
- <wsdl:output>
144
- <soap:body use="literal" />
145
- </wsdl:output>
146
- </wsdl:operation>
147
-
148
- <wsdl:operation name="ServicesGenerateOrder">
149
- <soap:operation soapAction="" />
150
- <wsdl:input>
151
- <soap:body use="literal" />
152
- </wsdl:input>
153
- <wsdl:output>
154
- <soap:body use="literal" />
155
- </wsdl:output>
156
- </wsdl:operation>
157
-
158
- </wsdl:binding>
159
- </wsdl:definitions>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <wsdl:definitions xmlns:typens="urn:{{var wsdl.name}}"
3
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
4
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
5
+ xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
6
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
7
+ name="{{var wsdl.name}}"
8
+ targetNamespace="urn:{{var wsdl.name}}">
9
+ <wsdl:types>
10
+ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:{{var wsdl.name}}">
11
+
12
+
13
+ <xsd:element name="servicesSetStatusOrderRequestParam">
14
+ <xsd:complexType>
15
+ <xsd:sequence>
16
+ <xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
17
+ <xsd:element minOccurs="1" maxOccurs="1" name="orderIncrementId" type="xsd:string" />
18
+ <xsd:element minOccurs="1" maxOccurs="1" name="status" type="xsd:string" />
19
+ </xsd:sequence>
20
+ </xsd:complexType>
21
+ </xsd:element>
22
+ <xsd:element name="servicesSetStatusOrderResponseParam">
23
+ <xsd:complexType>
24
+ <xsd:sequence>
25
+ <xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:boolean" />
26
+ </xsd:sequence>
27
+ </xsd:complexType>
28
+ </xsd:element>
29
+
30
+
31
+ <xsd:element name="servicesSetQuoteDesactiveRequestParam">
32
+ <xsd:complexType>
33
+ <xsd:sequence>
34
+ <xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
35
+ <xsd:element minOccurs="1" maxOccurs="1" name="quoteId" type="xsd:int" />
36
+ </xsd:sequence>
37
+ </xsd:complexType>
38
+ </xsd:element>
39
+ <xsd:element name="servicesSetQuoteDesactiveResponseParam">
40
+ <xsd:complexType>
41
+ <xsd:sequence>
42
+ <xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:boolean" />
43
+ </xsd:sequence>
44
+ </xsd:complexType>
45
+ </xsd:element>
46
+
47
+
48
+ <xsd:element name="servicesGenerateOrderRequestParam">
49
+ <xsd:complexType>
50
+ <xsd:sequence>
51
+ <xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
52
+ <xsd:element minOccurs="1" maxOccurs="1" name="IdCart" type="xsd:int" />
53
+ <xsd:element minOccurs="1" maxOccurs="1" name="IdStore" type="xsd:string" />
54
+ <xsd:element minOccurs="1" maxOccurs="1" name="CustomerName" type="xsd:string" />
55
+ <xsd:element minOccurs="1" maxOccurs="1" name="CustomerLasName" type="xsd:string" />
56
+ <xsd:element minOccurs="1" maxOccurs="1" name="CustomerEmail" type="xsd:string" />
57
+ <xsd:element minOccurs="1" maxOccurs="1" name="CustomerAdresss" type="xsd:string" />
58
+ <xsd:element minOccurs="1" maxOccurs="1" name="CustomerPhone" type="xsd:string" />
59
+ <xsd:element minOccurs="1" maxOccurs="1" name="CustomerZipCode" type="xsd:string" />
60
+ <xsd:element minOccurs="1" maxOccurs="1" name="CityName" type="xsd:string" />
61
+ <xsd:element minOccurs="1" maxOccurs="1" name="CountryId" type="xsd:string" />
62
+ <xsd:element minOccurs="1" maxOccurs="1" name="RegionId" type="xsd:string" />
63
+ <xsd:element minOccurs="1" maxOccurs="1" name="RegionName" type="xsd:string" />
64
+ </xsd:sequence>
65
+ </xsd:complexType>
66
+ </xsd:element>
67
+ <xsd:element name="servicesGenerateOrderResponseParam">
68
+ <xsd:complexType>
69
+ <xsd:sequence>
70
+ <xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:string" />
71
+ </xsd:sequence>
72
+ </xsd:complexType>
73
+ </xsd:element>
74
+
75
+
76
+ </xsd:schema>
77
+ </wsdl:types>
78
+
79
+
80
+ <wsdl:message name="ServicesSetStatusOrderRequest">
81
+ <wsdl:part name="parameters" element="typens:servicesSetStatusOrderRequestParam" />
82
+ </wsdl:message>
83
+ <wsdl:message name="ServicesSetStatusOrderResponse">
84
+ <wsdl:part name="parameters" element="typens:servicesSetStatusOrderResponseParam" />
85
+ </wsdl:message>
86
+
87
+ <wsdl:message name="ServicesSetQuoteDesactiveRequest">
88
+ <wsdl:part name="parameters" element="typens:servicesSetQuoteDesactiveRequestParam" />
89
+ </wsdl:message>
90
+ <wsdl:message name="ServicesSetQuoteDesactiveResponse">
91
+ <wsdl:part name="parameters" element="typens:servicesSetQuoteDesactiveResponseParam" />
92
+ </wsdl:message>
93
+
94
+ <wsdl:message name="ServicesGenerateOrderRequest">
95
+ <wsdl:part name="parameters" element="typens:servicesGenerateOrderRequestParam" />
96
+ </wsdl:message>
97
+ <wsdl:message name="ServicesGenerateOrderResponse">
98
+ <wsdl:part name="parameters" element="typens:servicesGenerateOrderResponseParam" />
99
+ </wsdl:message>
100
+
101
+
102
+ <wsdl:portType name="{{var wsdl.handler}}PortType">
103
+
104
+ <wsdl:operation name="ServicesSetStatusOrder">
105
+ <wsdl:documentation>Service set status</wsdl:documentation>
106
+ <wsdl:input message="typens:ServicesSetStatusOrderRequest" />
107
+ <wsdl:output message="typens:ServicesSetStatusOrderResponse" />
108
+ </wsdl:operation>
109
+
110
+
111
+ <wsdl:operation name="ServicesSetQuoteDesactive">
112
+ <wsdl:documentation>Service desactive quote</wsdl:documentation>
113
+ <wsdl:input message="typens:ServicesSetQuoteDesactiveRequest" />
114
+ <wsdl:output message="typens:ServicesSetQuoteDesactiveResponse" />
115
+ </wsdl:operation>
116
+
117
+ <wsdl:operation name="ServicesGenerateOrder">
118
+ <wsdl:documentation>Generate Order Magento</wsdl:documentation>
119
+ <wsdl:input message="typens:ServicesGenerateOrderRequest" />
120
+ <wsdl:output message="typens:ServicesGenerateOrderResponse" />
121
+ </wsdl:operation>
122
+
123
+ </wsdl:portType>
124
+
125
+ <wsdl:binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
126
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
127
+
128
+ <wsdl:operation name="ServicesSetStatusOrder">
129
+ <soap:operation soapAction="" />
130
+ <wsdl:input>
131
+ <soap:body use="literal" />
132
+ </wsdl:input>
133
+ <wsdl:output>
134
+ <soap:body use="literal" />
135
+ </wsdl:output>
136
+ </wsdl:operation>
137
+
138
+ <wsdl:operation name="ServicesSetQuoteDesactive">
139
+ <soap:operation soapAction="" />
140
+ <wsdl:input>
141
+ <soap:body use="literal" />
142
+ </wsdl:input>
143
+ <wsdl:output>
144
+ <soap:body use="literal" />
145
+ </wsdl:output>
146
+ </wsdl:operation>
147
+
148
+ <wsdl:operation name="ServicesGenerateOrder">
149
+ <soap:operation soapAction="" />
150
+ <wsdl:input>
151
+ <soap:body use="literal" />
152
+ </wsdl:input>
153
+ <wsdl:output>
154
+ <soap:body use="literal" />
155
+ </wsdl:output>
156
+ </wsdl:operation>
157
+
158
+ </wsdl:binding>
159
+ </wsdl:definitions>
app/design/adminhtml/default/default/layout/skyboxcatalog.xml CHANGED
@@ -1,8 +1,8 @@
1
- <?xml version="1.0"?>
2
- <layout version="0.1.0">
3
- <default>
4
- <reference name="head">
5
- <action method="addJs"><script>skybox/adminhtml.category.js</script></action>
6
- </reference>
7
- </default>
8
  </layout>
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addJs"><script>skybox/adminhtml.category.js</script></action>
6
+ </reference>
7
+ </default>
8
  </layout>
app/design/adminhtml/default/default/layout/skyboxinternational.xml CHANGED
@@ -1,15 +1,15 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <layout version="0.1.0">
3
- <skyboxinternational_adminhtml_debug_index>
4
- <reference name="content">
5
- <block type="skyboxinternational/adminhtml_debug" name="skyboxinternational_debug_info" />
6
- </reference>
7
- </skyboxinternational_adminhtml_debug_index>
8
-
9
- <adminhtml_sales_order_view>
10
- <reference name="order_totals">
11
- <block type="skyboxcheckout/sales_order_total" before="tax" />
12
- </reference>
13
- </adminhtml_sales_order_view>
14
-
15
  </layout>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout version="0.1.0">
3
+ <skyboxinternational_adminhtml_debug_index>
4
+ <reference name="content">
5
+ <block type="skyboxinternational/adminhtml_debug" name="skyboxinternational_debug_info" />
6
+ </reference>
7
+ </skyboxinternational_adminhtml_debug_index>
8
+
9
+ <adminhtml_sales_order_view>
10
+ <reference name="order_totals">
11
+ <block type="skyboxcheckout/sales_order_total" before="tax" />
12
+ </reference>
13
+ </adminhtml_sales_order_view>
14
+
15
  </layout>
app/design/frontend/base/default/layout/skyboxcheckout.xml CHANGED
@@ -1,204 +1,204 @@
1
- <?xml version="1.0"?>
2
- <layout version="0.1.0">
3
- <skyboxcheckout_international_index>
4
- <remove name="top.container"/>
5
- <reference name="content">
6
- <block type="core/template" name="skyboxcheckout.international.index"
7
- template="skybox/checkout/skyboxcheckout.phtml"/>
8
- </reference>
9
- </skyboxcheckout_international_index>
10
- <skyboxcheckout_international_success>
11
- <reference name="content">
12
- <block type="core/template" name="skyboxcheckout.international.index"
13
- template="skybox/checkout/skyboxsuccess.phtml"/>
14
- </reference>
15
- </skyboxcheckout_international_success>
16
- <checkout_onepage_index>
17
- <reference name="checkout.onepage">
18
- <!--
19
- <action method="setTemplate"><template>skybox/checkout/onepage.phtml</template></action>
20
- -->
21
- <action method="setTemplate">
22
- <template helper="checkout/data/getLayoutCheckoutSkybox"/>
23
- </action>
24
- <!-- Rogged -->
25
- </reference>
26
- </checkout_onepage_index>
27
- <!--
28
- Shopping cart item renderer
29
- -->
30
- <checkout_cart_index>
31
- <remove name="top.container"/>
32
- <reference name="checkout.cart.methods">
33
- <block type="core/template" before="content" name="skybox.checkout.cart.methods.onepage.bottom"
34
- template="skybox/checkout/onepage/link.phtml"/>
35
- </reference>
36
-
37
- <reference name="checkout.cart.shipping">
38
- <block type="checkout/cart_shipping" name="shippping" as="shippping" template="checkout/cart/shipping.phtml"/>
39
- <action method="setTemplate">
40
- <template>skybox/checkout/cart/shipping.phtml</template>
41
- </action>
42
- </reference>
43
-
44
- <reference name="checkout.cart.methods.multishipping">
45
- <block type="checkout/multishipping_link" name="multishipping2" as="multishipping2" template="checkout/multishipping/link.phtml"/>
46
- <action method="setTemplate">
47
- <template>skybox/checkout/multishipping/link.phtml</template>
48
- </action>
49
- </reference>
50
-
51
- <reference name="checkout.cart.sidebar">
52
- <action method="setTemplate">
53
- <template>skybox/checkout/cart/shipping.phtml</template>
54
- </action>
55
- </reference>
56
- <!--
57
-
58
- <reference name="checkout.cart">
59
-
60
- <action method="setTemplate">
61
- <template>skybox/checkout/cart_list.phtml</template>
62
- </action>
63
-
64
- <action method="setCartTemplate"><value>skybox/checkout/cart_list.phtml</value></action>
65
- <action method="setEmptyTemplate"><value>checkout/cart/noItems.phtml</value></action>
66
- <action method="chooseTemplate"/>
67
-
68
- <action method="addItemRender">
69
- <type>simple</type>
70
- <block>checkout/cart_item_renderer</block>
71
- <template>skybox/checkout/cart/item/default.phtml</template>
72
- </action>
73
-
74
- <action method="addItemRender">
75
- <type>grouped</type>
76
- <block>checkout/cart_item_renderer_grouped</block>
77
- <template>skybox/checkout/cart/item/default.phtml</template>
78
- </action>
79
-
80
- <action method="addItemRender">
81
- <type>configurable</type>
82
- <block>checkout/cart_item_renderer_configurable</block>
83
- <template>skybox/checkout/cart/item/default.phtml</template>
84
- </action>
85
-
86
- <action method="addItemRender">
87
- <type>bundle</type>
88
- <block>bundle/checkout_cart_item_renderer</block>
89
- <template>skybox/checkout/cart/item/default.phtml</template>
90
- </action>
91
-
92
- </reference>
93
-
94
- <reference name="checkout.cart.shipping">
95
- <action method="setTemplate"><template>skybox/checkout/cart/shipping.phtml</template></action>
96
- </reference>
97
-
98
- <reference name="checkout.cart.sidebar">
99
- <action method="setTemplate"><template>skybox/checkout/cart/shipping.phtml</template></action>
100
- </reference>
101
- -->
102
- </checkout_cart_index>
103
- <default>
104
- <reference name="head">
105
- <!--
106
- <block type="directory/currency" name="custom_currency_selector" template="currency/currency.phtml"/>
107
- -->
108
- <action method="addJs" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
109
- <script>prototype/window.js</script>
110
- </action>
111
- <action method="addJs" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
112
- <script>prototype/debug.js</script>
113
- </action>
114
- <action method="addJs" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
115
- <script>prototype/effects.js</script>
116
- </action>
117
- <action method="addItem" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
118
- <type>js_css</type>
119
- <name>prototype/windows/themes/default.css</name>
120
- </action>
121
- <action method="addItem" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
122
- <type>js_css</type>
123
- <name>prototype/windows/themes/alphacube.css</name>
124
- </action>
125
- <action method="addJs" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
126
- <script>skybox/load-jquery.js</script>
127
- </action>
128
- <!-- jQuery ver. 1.7.2 -->
129
- <!--
130
-
131
- <action method="addJs"><script>skybox/jquery.min.js</script></action>
132
- <action method="addJs"><script>skybox/jquery.ba-resize.min.js</script></action>
133
-
134
- <block type="core/text" name="google.cdn.jquery">
135
- <action method="setText">
136
- <text><![CDATA[<script type="text/javascript">jQuery.noConflict();</script>]]></text>
137
- </action>
138
- </block>
139
-
140
- -->
141
- <!--
142
-
143
- <block type="core/text" name="google.cdn.jquery">
144
- <action method="setText">
145
- <text><![CDATA[<script type="text/javascript">
146
- if ( (typeof jQuery === 'undefined') && !window.jQuery ) {
147
- document.write(unescape("%3Cscript type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'%3E%3C/script%3E"));
148
- document.write(unescape("%3Cscript type='text/javascript'%3E%3C/script%3E jQuery.noConflict(); %3Cscript%3E%3C/script%3E"));
149
- }</script>]]></text>
150
- </action>
151
- </block>
152
-
153
- -->
154
- <!--
155
- <action method="addItem" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
156
- -->
157
- <!--
158
- <type>skin_js</type><name>js/skybox/catalog.product.configurable.js</name>
159
- -->
160
- <!-- </action> -->
161
- </reference>
162
- <!--
163
-
164
- <reference name="content">
165
- <block type="core/template" name="skyboxcheckout.top.container.cart" before="-" template="skybox/checkout/cart.phtml"/>
166
- </reference>
167
-
168
- -->
169
- <reference name="top.container">
170
- <!-- <reference name="content"> -->
171
- <block type="core/template" name="skyboxcheckout.top.container.cart">
172
- <action method="setTemplate" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
173
- <template>skybox/checkout/cart.phtml</template>
174
- </action>
175
- <action method="unsetData">
176
- <key>cache_lifetime</key>
177
- </action>
178
- <action method="unsetData">
179
- <key>cache_tags</key>
180
- </action>
181
- </block>
182
- </reference>
183
- <reference name="right">
184
- <remove name="checkout/cart_sidebar"/>
185
- <block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" before="-">
186
- <action method="addItemRender">
187
- <type>simple</type>
188
- <block>checkout/cart_item_renderer</block>
189
- <template>skybox/checkout/cart/sidebar/default.phtml</template>
190
- </action>
191
- <action method="addItemRender">
192
- <type>grouped</type>
193
- <block>checkout/cart_item_renderer_grouped</block>
194
- <template>skybox/checkout/cart/sidebar/default.phtml</template>
195
- </action>
196
- <action method="addItemRender">
197
- <type>configurable</type>
198
- <block>checkout/cart_item_renderer_configurable</block>
199
- <template>skybox/checkout/cart/sidebar/default.phtml</template>
200
- </action>
201
- </block>
202
- </reference>
203
- </default>
204
- </layout>
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <skyboxcheckout_international_index>
4
+ <remove name="top.container"/>
5
+ <reference name="content">
6
+ <block type="core/template" name="skyboxcheckout.international.index"
7
+ template="skybox/checkout/skyboxcheckout.phtml"/>
8
+ </reference>
9
+ </skyboxcheckout_international_index>
10
+ <skyboxcheckout_international_success>
11
+ <reference name="content">
12
+ <block type="core/template" name="skyboxcheckout.international.index"
13
+ template="skybox/checkout/skyboxsuccess.phtml"/>
14
+ </reference>
15
+ </skyboxcheckout_international_success>
16
+ <checkout_onepage_index>
17
+ <reference name="checkout.onepage">
18
+ <!--
19
+ <action method="setTemplate"><template>skybox/checkout/onepage.phtml</template></action>
20
+ -->
21
+ <action method="setTemplate">
22
+ <template helper="checkout/data/getLayoutCheckoutSkybox"/>
23
+ </action>
24
+ <!-- Rogged -->
25
+ </reference>
26
+ </checkout_onepage_index>
27
+ <!--
28
+ Shopping cart item renderer
29
+ -->
30
+ <checkout_cart_index>
31
+ <remove name="top.container"/>
32
+ <reference name="checkout.cart.methods">
33
+ <block type="core/template" before="content" name="skybox.checkout.cart.methods.onepage.bottom"
34
+ template="skybox/checkout/onepage/link.phtml"/>
35
+ </reference>
36
+
37
+ <reference name="checkout.cart.shipping">
38
+ <block type="checkout/cart_shipping" name="shippping" as="shippping" template="checkout/cart/shipping.phtml"/>
39
+ <action method="setTemplate">
40
+ <template>skybox/checkout/cart/shipping.phtml</template>
41
+ </action>
42
+ </reference>
43
+
44
+ <reference name="checkout.cart.methods.multishipping">
45
+ <block type="checkout/multishipping_link" name="multishipping2" as="multishipping2" template="checkout/multishipping/link.phtml"/>
46
+ <action method="setTemplate">
47
+ <template>skybox/checkout/multishipping/link.phtml</template>
48
+ </action>
49
+ </reference>
50
+
51
+ <reference name="checkout.cart.sidebar">
52
+ <action method="setTemplate">
53
+ <template>skybox/checkout/cart/shipping.phtml</template>
54
+ </action>
55
+ </reference>
56
+ <!--
57
+
58
+ <reference name="checkout.cart">
59
+
60
+ <action method="setTemplate">
61
+ <template>skybox/checkout/cart_list.phtml</template>
62
+ </action>
63
+
64
+ <action method="setCartTemplate"><value>skybox/checkout/cart_list.phtml</value></action>
65
+ <action method="setEmptyTemplate"><value>checkout/cart/noItems.phtml</value></action>
66
+ <action method="chooseTemplate"/>
67
+
68
+ <action method="addItemRender">
69
+ <type>simple</type>
70
+ <block>checkout/cart_item_renderer</block>
71
+ <template>skybox/checkout/cart/item/default.phtml</template>
72
+ </action>
73
+
74
+ <action method="addItemRender">
75
+ <type>grouped</type>
76
+ <block>checkout/cart_item_renderer_grouped</block>
77
+ <template>skybox/checkout/cart/item/default.phtml</template>
78
+ </action>
79
+
80
+ <action method="addItemRender">
81
+ <type>configurable</type>
82
+ <block>checkout/cart_item_renderer_configurable</block>
83
+ <template>skybox/checkout/cart/item/default.phtml</template>
84
+ </action>
85
+
86
+ <action method="addItemRender">
87
+ <type>bundle</type>
88
+ <block>bundle/checkout_cart_item_renderer</block>
89
+ <template>skybox/checkout/cart/item/default.phtml</template>
90
+ </action>
91
+
92
+ </reference>
93
+
94
+ <reference name="checkout.cart.shipping">
95
+ <action method="setTemplate"><template>skybox/checkout/cart/shipping.phtml</template></action>
96
+ </reference>
97
+
98
+ <reference name="checkout.cart.sidebar">
99
+ <action method="setTemplate"><template>skybox/checkout/cart/shipping.phtml</template></action>
100
+ </reference>
101
+ -->
102
+ </checkout_cart_index>
103
+ <default>
104
+ <reference name="head">
105
+ <!--
106
+ <block type="directory/currency" name="custom_currency_selector" template="currency/currency.phtml"/>
107
+ -->
108
+ <action method="addJs" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
109
+ <script>prototype/window.js</script>
110
+ </action>
111
+ <action method="addJs" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
112
+ <script>prototype/debug.js</script>
113
+ </action>
114
+ <action method="addJs" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
115
+ <script>prototype/effects.js</script>
116
+ </action>
117
+ <action method="addItem" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
118
+ <type>js_css</type>
119
+ <name>prototype/windows/themes/default.css</name>
120
+ </action>
121
+ <action method="addItem" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
122
+ <type>js_css</type>
123
+ <name>prototype/windows/themes/alphacube.css</name>
124
+ </action>
125
+ <action method="addJs" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
126
+ <script>skybox/load-jquery.js</script>
127
+ </action>
128
+ <!-- jQuery ver. 1.7.2 -->
129
+ <!--
130
+
131
+ <action method="addJs"><script>skybox/jquery.min.js</script></action>
132
+ <action method="addJs"><script>skybox/jquery.ba-resize.min.js</script></action>
133
+
134
+ <block type="core/text" name="google.cdn.jquery">
135
+ <action method="setText">
136
+ <text><![CDATA[<script type="text/javascript">jQuery.noConflict();</script>]]></text>
137
+ </action>
138
+ </block>
139
+
140
+ -->
141
+ <!--
142
+
143
+ <block type="core/text" name="google.cdn.jquery">
144
+ <action method="setText">
145
+ <text><![CDATA[<script type="text/javascript">
146
+ if ( (typeof jQuery === 'undefined') && !window.jQuery ) {
147
+ document.write(unescape("%3Cscript type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'%3E%3C/script%3E"));
148
+ document.write(unescape("%3Cscript type='text/javascript'%3E%3C/script%3E jQuery.noConflict(); %3Cscript%3E%3C/script%3E"));
149
+ }</script>]]></text>
150
+ </action>
151
+ </block>
152
+
153
+ -->
154
+ <!--
155
+ <action method="addItem" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
156
+ -->
157
+ <!--
158
+ <type>skin_js</type><name>js/skybox/catalog.product.configurable.js</name>
159
+ -->
160
+ <!-- </action> -->
161
+ </reference>
162
+ <!--
163
+
164
+ <reference name="content">
165
+ <block type="core/template" name="skyboxcheckout.top.container.cart" before="-" template="skybox/checkout/cart.phtml"/>
166
+ </reference>
167
+
168
+ -->
169
+ <reference name="top.container">
170
+ <!-- <reference name="content"> -->
171
+ <block type="core/template" name="skyboxcheckout.top.container.cart">
172
+ <action method="setTemplate" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
173
+ <template>skybox/checkout/cart.phtml</template>
174
+ </action>
175
+ <action method="unsetData">
176
+ <key>cache_lifetime</key>
177
+ </action>
178
+ <action method="unsetData">
179
+ <key>cache_tags</key>
180
+ </action>
181
+ </block>
182
+ </reference>
183
+ <reference name="right">
184
+ <remove name="checkout/cart_sidebar"/>
185
+ <block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" before="-">
186
+ <action method="addItemRender">
187
+ <type>simple</type>
188
+ <block>checkout/cart_item_renderer</block>
189
+ <template>skybox/checkout/cart/sidebar/default.phtml</template>
190
+ </action>
191
+ <action method="addItemRender">
192
+ <type>grouped</type>
193
+ <block>checkout/cart_item_renderer_grouped</block>
194
+ <template>skybox/checkout/cart/sidebar/default.phtml</template>
195
+ </action>
196
+ <action method="addItemRender">
197
+ <type>configurable</type>
198
+ <block>checkout/cart_item_renderer_configurable</block>
199
+ <template>skybox/checkout/cart/sidebar/default.phtml</template>
200
+ </action>
201
+ </block>
202
+ </reference>
203
+ </default>
204
+ </layout>
app/design/frontend/base/default/template/skybox/checkout/cart.phtml CHANGED
@@ -1,177 +1,157 @@
1
- <?php
2
- /** @var Skybox_International_Helper_Data $_helper */
3
- $_helper = Mage::helper('skyboxinternational/data');
4
-
5
- if ($_helper->getActive()) {
6
-
7
- /** @var Skybox_Core_Model_Config $_config */
8
- $_config = Mage::getModel('skyboxcore/config');
9
-
10
- /** @var Skybox_Checkout_Model_Api_Checkout $_checkout */
11
- $_checkout = Mage::getModel('skyboxcheckout/api_checkout');
12
-
13
- /** @var Skybox_Core_Helper_Allow $allowHelper */
14
- $allowHelper = Mage::helper('skyboxcore/allow');
15
-
16
- $_cartDataURL = "";
17
- $_merchant = $_helper->getMerchantCode();
18
- $template = "";
19
- $cartId = $_helper->getCartId();
20
- $cssVersion= $_helper->getCssVersion();
21
-
22
- $_checkout->InitializeBarSkybox();
23
-
24
- $change_country = false;
25
-
26
- // $request = $this->getRequest();
27
- // $module = $request->getModuleName();
28
- // $controller = $request->getControllerName();
29
- // $action = $request->getActionName();
30
- $getHomeUrl = Mage::helper('core/url')->getHomeUrl();
31
- $urlCheckCart = Mage::getUrl("checkout/cart");
32
-
33
- $cart = $_config->getSession()->getCartSkybox();
34
-
35
- // Load CSS & JS
36
- $skybox_url = $_helper->getSkyboxUrlMain();// $_config->skyboxDefaultUrl;
37
- $api_css_button_international = $skybox_url . 'widgets/api-button/css/api-button-international-css.ashx';
38
- $api_css_button_international .= '?s=' . $_merchant;
39
- $api_css_button_international .= '&CssVersion=' . $cssVersion;
40
- $api_js_button_international = $skybox_url . 'Content/debug/API/js/api-button-tooltip.js';
41
- $countryChange = 0;
42
-
43
- if ($allowHelper->isCartBarEnabled()) :
44
- $countryChange = 1;
45
- $template = '';
46
- // $cart = $_config->getSession()->getCartSkybox();
47
- if (!empty($cart)) :
48
- $template = $cart->BarHtmlTemplate;
49
- foreach ($cart as $key => $value) :
50
- $template = str_replace('{' . $key . '}', $value, $template);
51
- endforeach;
52
- endif;
53
- $_cartDataURL = $cart->CartDataURL;
54
- echo $template;
55
- endif;
56
-
57
- if ($allowHelper->isChangeCountryEnabled()):
58
- // $cart = $_config->getSession()->getCartSkybox();
59
- $template = "<div class='main-container' style='padding: 10px 0 0;text-align: right;'>";
60
- $template .= "<div class='change_country'>";
61
- $template .= "<a class='skx_position_option_country' href='javascript:;'>Change country</a>";
62
- $template .= "</div>";
63
- $template .= "</div>";
64
- $change_country = true;
65
- $countryChange = 0;
66
- $_cartDataURL = $cart->CartDataURL;
67
- echo $template;
68
- endif;
69
-
70
- if ($allowHelper->isPriceEnabled()) {
71
- $productConfigurable = $this->getSkinUrl('js/skybox/catalog.product.configurable.js');
72
- echo '<script type="text/javascript" src="' . $productConfigurable . '"></script>';
73
- }
74
-
75
- $skyBoxUrlClientBase = $_helper->getSkyBoxUrlAPI();
76
- $storeCode = Mage::getModel('skyboxcatalog/api_product')->getStoreCode();
77
- $skyBoxUrlClientGet = str_replace("apirest/", "", $skyBoxUrlClientBase);
78
- $skyBoxUrlClient = $skyBoxUrlClientGet . "multiplecalculate/" . $storeCode . "/calc-";
79
- $skyboxForceReload = intval(Mage::getBlockSingleton('page/html_header')->getIsHomePage());
80
- ?>
81
-
82
- <link rel="stylesheet" type="text/css" href="<?php echo $api_css_button_international; ?>"/>
83
- <link rel="stylesheet" type="text/css"
84
- href="<?php echo $this->getSkinUrl('css/skybox/style.css?v=' . $cssVersion); ?>"/>
85
- <script type="text/javascript">
86
- var URL_CHECK_CART = "<?php echo $urlCheckCart ?>";
87
- var CART_ID = "<?php echo $cartId ?>";
88
- var CART_DATA_URL_SKYBOX = "<?php echo $_cartDataURL ?>";
89
- var MERCHANT_ID_SKYBOX = "<?php echo $_merchant ?>";
90
- var SKYBOX_URL = "<?php echo $skybox_url ?>";
91
- var CHANGE_COUNTRY = "<?php echo $change_country ?>";
92
- var ACTUAL_URI = "<?php echo 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'] ?>";
93
- var GET_HOME_URL = "<?php echo $getHomeUrl ?>";
94
- var COUNTRY_CHANGE = "<?php echo $countryChange?>";
95
- var IS_SKYBOX_VISIBLE = "<?php echo $_checkout->getLocationAllow(); ?>";
96
- var URL_BASE_MAGENTO = "<?php echo Mage::getBaseUrl() ?>";
97
- var IS_REGISTRATION_DISABLED_SKYBOX = 1;
98
- var SKYBOX_FORCE_RELOAD = "<?php echo $skyboxForceReload; ?>";
99
- var LOADING_IMAGE = "<?php echo $this->getSkinUrl('images/skybox/ajax-loading.gif')?>";
100
-
101
- (function ($) {
102
- $(document).ready(function () {
103
- if (typeof $.fancybox !== "function") {
104
- var fileref = document.createElement("link");
105
- fileref.rel = "stylesheet";
106
- fileref.type = "text/css";
107
- fileref.href = "<?php echo $this->getSkinUrl('css/skybox/jquery.fancybox.css');?>";
108
- document.getElementsByTagName("head")[0].appendChild(fileref);
109
- $('head').append($('<script />').attr('src', '<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'js/skybox/jquery.fancybox.js'; ?>'));
110
- }
111
- $(".skybox-price-set").each(function (index) {
112
- var SkyBoxUrlClient = "<?php echo $skyBoxUrlClient;?>";
113
- var dataId = $(this).attr("id");
114
- var id = $(this).attr("product-id");
115
- var url = SkyBoxUrlClient + id + ".html";
116
- var content = $.get(url, function (data) {
117
- $("#" + dataId).html(data);
118
- });
119
- });
120
- });
121
- })(jQuery);
122
- </script>
123
- <script src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'js/skybox/main.js'; ?>"></script>
124
- <script type="text/javascript">
125
- //<![CDATA[
126
- var SKYBOX_OPTIONS_PRICE_URL = '<?php echo Mage::getUrl("skbcheckout/calculate"); ?>';
127
- //]]>
128
- </script>
129
- <script type="text/javascript" src="<?php echo $api_js_button_international; ?>"></script>
130
- <?php
131
- // note: Just to force reload page on Home Page.
132
- $forceReload = $_config->getSession()->getChangeCountryHomePage();
133
- $forceReload = isset($forceReload) ? $forceReload : 0;
134
-
135
- // if (Mage::getBlockSingleton('page/html_header')->getIsHomePage()) :
136
- if ($skyboxForceReload):
137
- if ($forceReload == 1):
138
- $forceReload = 0;
139
- $_config->getSession()->setChangeCountryHomePage($forceReload);
140
- ?>
141
- <script type="text/javascript">
142
- console.log("[Skybox] Reloading page...");
143
- // window.location.reload(true);
144
- </script>
145
- <?php
146
- endif;
147
- endif;
148
- ?>
149
- <script>
150
- setTimeout(function () {
151
- jQuery("a[href='#'].skx-bar-other").attr('href', 'javascript:;');
152
- var country_change = "<?php echo $countryChange?>";
153
- if (parseInt(country_change) === 1) {
154
- var currencyISO_ = document.getElementsByClassName('skx_banner_label_currencyISO');
155
- if (currencyISO_.length > 1) {
156
- var nextSiblingOne = currencyISO_[0].nextElementSibling;
157
- var getAttrNextSiblingOne = nextSiblingOne.getAttribute('class');
158
- var nextSiblingLast = currencyISO_[1].nextElementSibling;
159
- nextSiblingLast.setAttribute('class', getAttrNextSiblingOne);
160
- currencyISO_[1].innerHTML = currencyISO_[0].innerHTML;
161
- }
162
- } else {
163
- var optCountry = document.getElementsByClassName('skx_position_option_country');
164
- if (optCountry.length > 1) {
165
- optCountry[1].innerHTML = optCountry[0].innerText;
166
- try {
167
- document.getElementById('l_checkout_view_account').style.display = 'none';
168
- } catch (e) {
169
-
170
- }
171
- }
172
- }
173
- }, 500);
174
- </script>
175
- <?php
176
- }
177
- ?>
1
+ <?php
2
+ /** @var Skybox_International_Helper_Data $_helper */
3
+ $_helper = Mage::helper('skyboxinternational/data');
4
+
5
+ if ($_helper->getActive()) {
6
+
7
+ /** @var Skybox_Core_Model_Config $_config */
8
+ $_config = Mage::getModel('skyboxcore/config');
9
+
10
+ /** @var Skybox_Checkout_Model_Api_Checkout $_checkout */
11
+ $_checkout = Mage::getModel('skyboxcheckout/api_checkout');
12
+
13
+ /** @var Skybox_Core_Helper_Allow $allowHelper */
14
+ $allowHelper = Mage::helper('skyboxcore/allow');
15
+
16
+ $_cartDataURL = "";
17
+ $_merchant = $_helper->getMerchantCode();
18
+ $template = "";
19
+ $cartId = $_helper->getCartId();
20
+ $cssVersion = $_helper->getCssVersion();
21
+
22
+ $_checkout->InitializeBarSkybox();
23
+
24
+ $change_country = false;
25
+
26
+ // $request = $this->getRequest();
27
+ // $module = $request->getModuleName();
28
+ // $controller = $request->getControllerName();
29
+ // $action = $request->getActionName();
30
+ $getHomeUrl = Mage::helper('core/url')->getHomeUrl();
31
+ $urlCheckCart = Mage::getUrl("checkout/cart");
32
+
33
+ $cart = $_config->getSession()->getCartSkybox();
34
+
35
+ // Load CSS & JS
36
+ $skybox_url = $_helper->getSkyboxUrlMain();// $_config->skyboxDefaultUrl;
37
+ $api_css_button_international = $skybox_url . 'widgets/api-button/css/api-button-international-css.ashx';
38
+ $api_css_button_international .= '?s=' . $_merchant;
39
+ $api_css_button_international .= '&CssVersion=' . $cssVersion;
40
+ $api_js_button_international = $skybox_url . 'Content/debug/API/js/api-button-tooltip.js';
41
+ $countryChange = 0;
42
+
43
+ if ($allowHelper->isCartBarEnabled()) :
44
+ $countryChange = 1;
45
+ $template = '';
46
+ // $cart = $_config->getSession()->getCartSkybox();
47
+ if (!empty($cart)) :
48
+ $template = $cart->BarHtmlTemplate;
49
+ foreach ($cart as $key => $value) :
50
+ $template = str_ireplace('{' . $key . '}', $value, $template);
51
+ endforeach;
52
+ endif;
53
+ $_cartDataURL = $cart->CartDataURL;
54
+ echo $template;
55
+ endif;
56
+
57
+ if ($allowHelper->isChangeCountryEnabled()):
58
+ // $cart = $_config->getSession()->getCartSkybox();
59
+ $template = "<div class='main-container' style='padding: 10px 0 0;text-align: right;'>";
60
+ $template .= "<div class='change_country'>";
61
+ $template .= "<a class='skx_position_option_country' href='javascript:;'>Change country</a>";
62
+ $template .= "</div>";
63
+ $template .= "</div>";
64
+ $change_country = true;
65
+ $countryChange = 0;
66
+ $_cartDataURL = $cart->CartDataURL;
67
+ echo $template;
68
+ endif;
69
+
70
+ if ($allowHelper->isPriceEnabled()) {
71
+ $productConfigurable = $this->getSkinUrl('js/skybox/catalog.product.configurable.js');
72
+ echo '<script type="text/javascript" src="' . $productConfigurable . '"></script>';
73
+ }
74
+
75
+ $skyBoxUrlClientBase = $_helper->getSkyBoxUrlAPI();
76
+ $storeCode = Mage::getModel('skyboxcatalog/api_product')->getStoreCode();
77
+ $skyBoxUrlClientGet = str_ireplace("apirest/", "", $skyBoxUrlClientBase);
78
+ $skyBoxUrlClient = $skyBoxUrlClientGet . "multiplecalculate/" . $storeCode . "/calc-";
79
+ ?>
80
+
81
+ <link rel="stylesheet" type="text/css" href="<?php echo $api_css_button_international; ?>"/>
82
+ <link rel="stylesheet" type="text/css"
83
+ href="<?php echo $this->getSkinUrl('css/skybox/style.css?v=' . $cssVersion); ?>"/>
84
+ <script type="text/javascript">
85
+ var URL_CHECK_CART = "<?php echo $urlCheckCart ?>";
86
+ var CART_ID = "<?php echo $cartId ?>";
87
+ var CART_DATA_URL_SKYBOX = "<?php echo $_cartDataURL ?>";
88
+ var MERCHANT_ID_SKYBOX = "<?php echo $_merchant ?>";
89
+ var SKYBOX_URL = "<?php echo $skybox_url ?>";
90
+ var CHANGE_COUNTRY = "<?php echo $change_country ?>";
91
+ var ACTUAL_URI = "<?php echo 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'] ?>";
92
+ var GET_HOME_URL = "<?php echo $getHomeUrl ?>";
93
+ var COUNTRY_CHANGE = "<?php echo $countryChange?>";
94
+ var IS_SKYBOX_VISIBLE = "<?php echo $_checkout->getLocationAllow(); ?>";
95
+ var URL_BASE_MAGENTO = "<?php echo Mage::getBaseUrl() ?>";
96
+ var IS_REGISTRATION_DISABLED_SKYBOX = 1;
97
+ var LOADING_IMAGE = "<?php echo $this->getSkinUrl('images/skybox/ajax-loading.gif')?>";
98
+
99
+ (function ($) {
100
+ $(document).ready(function () {
101
+ if (typeof $.fancybox !== "function") {
102
+ var fileref = document.createElement("link");
103
+ fileref.rel = "stylesheet";
104
+ fileref.type = "text/css";
105
+ fileref.href = "<?php echo $this->getSkinUrl('css/skybox/jquery.fancybox.css');?>";
106
+ document.getElementsByTagName("head")[0].appendChild(fileref);
107
+ $('head').append($('<script />').attr('src', '<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'js/skybox/jquery.fancybox.js'; ?>'));
108
+ }
109
+ $(".skybox-price-set").each(function (index) {
110
+ var SkyBoxUrlClient = "<?php echo $skyBoxUrlClient;?>";
111
+ var dataId = $(this).attr("id");
112
+ var id = $(this).attr("product-id");
113
+ var url = SkyBoxUrlClient + id + ".html";
114
+ var content = $.get(url, function (data) {
115
+ $("#" + dataId).html(data);
116
+ });
117
+ });
118
+ });
119
+ })(jQuery);
120
+ </script>
121
+ <script src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'js/skybox/main.js'; ?>"></script>
122
+ <script type="text/javascript">
123
+ //<![CDATA[
124
+ var SKYBOX_OPTIONS_PRICE_URL = '<?php echo Mage::getUrl("skbcheckout/calculate"); ?>';
125
+ //]]>
126
+ </script>
127
+ <script type="text/javascript" src="<?php echo $api_js_button_international; ?>"></script>
128
+ <script>
129
+ // @todo Fix more Change countries Block issue
130
+ setTimeout(function () {
131
+ jQuery("a[href='#'].skx-bar-other").attr('href', 'javascript:;');
132
+ var country_change = "<?php echo $countryChange?>";
133
+ if (parseInt(country_change) === 1) {
134
+ var currencyISO_ = document.getElementsByClassName('skx_banner_label_currencyISO');
135
+ if (currencyISO_.length > 1) {
136
+ var nextSiblingOne = currencyISO_[0].nextElementSibling;
137
+ var getAttrNextSiblingOne = nextSiblingOne.getAttribute('class');
138
+ var nextSiblingLast = currencyISO_[1].nextElementSibling;
139
+ nextSiblingLast.setAttribute('class', getAttrNextSiblingOne);
140
+ currencyISO_[1].innerHTML = currencyISO_[0].innerHTML;
141
+ }
142
+ } else {
143
+ var optCountry = document.getElementsByClassName('skx_position_option_country');
144
+ if (optCountry.length > 1) {
145
+ optCountry[1].innerHTML = optCountry[0].innerText;
146
+ try {
147
+ document.getElementById('l_checkout_view_account').style.display = 'none';
148
+ } catch (e) {
149
+
150
+ }
151
+ }
152
+ }
153
+ }, 500);
154
+ </script>
155
+ <?php
156
+ }
157
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/skybox/checkout/cart/item/default.phtml CHANGED
@@ -1,294 +1,294 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- */
26
- ?>
27
- <?php
28
- $_item = $this->getItem();
29
- $isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility();
30
- $canApplyMsrp = Mage::helper('catalog')->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM);
31
- ?>
32
- <tr>
33
- <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>
34
- <td>
35
- <h2 class="product-name">
36
- <?php if ($this->hasProductUrl()):?>
37
- <a href="<?php echo $this->getProductUrl() ?>"><?php echo $this->escapeHtml($this->getProductName()) ?></a>
38
- <?php else: ?>
39
- <?php echo $this->escapeHtml($this->getProductName()) ?>
40
- <?php endif; ?>
41
- </h2>
42
- <?php if ($_options = $this->getOptionList()):?>
43
- <dl class="item-options">
44
- <?php foreach ($_options as $_option) : ?>
45
- <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
46
- <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
47
- <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
48
- <?php if (isset($_formatedOptionValue['full_view'])): ?>
49
- <div class="truncated_full_value">
50
- <dl class="item-options">
51
- <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
52
- <dd><?php echo $_formatedOptionValue['full_view'] ?></dd>
53
- </dl>
54
- </div>
55
- <?php endif; ?>
56
- </dd>
57
- <?php endforeach; ?>
58
- </dl>
59
- <?php endif;?>
60
- <?php if ($messages = $this->getMessages()): ?>
61
- <?php foreach ($messages as $message): ?>
62
- <p class="item-msg <?php echo $message['type'] ?>">* <?php echo $this->escapeHtml($message['text']) ?></p>
63
- <?php endforeach; ?>
64
- <?php endif; ?>
65
- <?php $addInfoBlock = $this->getProductAdditionalInformationBlock(); ?>
66
- <?php if ($addInfoBlock): ?>
67
- <?php echo $addInfoBlock->setItem($_item)->toHtml() ?>
68
- <?php endif;?>
69
- </td>
70
- <td class="a-center">
71
- <?php if ($isVisibleProduct): ?>
72
- <a href="<?php echo $this->getConfigureUrl() ?>" title="<?php echo $this->__('Edit item parameters') ?>"><?php echo $this->__('Edit') ?></a>
73
- <?php endif ?>
74
- </td>
75
- <?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
76
- <td class="a-center">
77
- <?php if ($isVisibleProduct): ?>
78
- <a href="<?php echo $this->helper('wishlist')->getMoveFromCartUrl($_item->getId()); ?>" class="link-wishlist use-ajax"><?php echo $this->__('Move'); ?></a>
79
- <?php endif ?>
80
- </td>
81
- <?php endif ?>
82
-
83
- <?php if ($canApplyMsrp): ?>
84
- <td class="a-right"<?php if ($this->helper('tax')->displayCartBothPrices()): ?> colspan="2"<?php endif; ?>>
85
- <span class="cart-price">
86
- <span class="cart-msrp-unit"><?php echo $this->__('See price before order confirmation.'); ?></span>
87
- <?php $helpLinkId = 'cart-msrp-help-' . $_item->getId(); ?>
88
- <a id="<?php echo $helpLinkId ?>" href="#" class="map-help-link"><?php echo $this->__("What's this?"); ?></a>
89
- <script type="text/javascript">
90
- Catalog.Map.addHelpLink($('<?php echo $helpLinkId ?>'), "<?php echo $this->__("Whats this?") ?>");
91
- </script>
92
- </span>
93
- </td>
94
- <?php else: ?>
95
-
96
- <!-- Skybox Checkout -->
97
- <!--<td class="a-center"><?php echo $this->helper('checkout')->formatPrice($_item->getPriceSkybox()); ?></td>
98
- <td class="a-center"><?php echo $this->helper('checkout')->formatPrice($_item->getCustomsSkybox()); ?></td>
99
- <td class="a-center"><?php echo $this->helper('checkout')->formatPrice($_item->getInsuranceSkybox()); ?></td>
100
- <td class="a-center"><?php echo $this->helper('checkout')->formatPrice($_item->getShippingSkybox()); ?></td>-->
101
- <!-- /Skybox Checkout -->
102
-
103
- <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
104
- <td class="a-right">
105
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
106
- <span class="cart-tax-total" onclick="taxToggle('eunit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
107
- <?php else: ?>
108
- <span class="cart-price" style="white-space: nowrap;">
109
- <?php endif; ?>
110
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
111
- <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
112
- <?php else: ?>
113
- <?php echo $this->helper('checkout')->formatPrice($_item->getPriceSkybox()); ?>
114
-
115
- <!--<?php echo $this->helper('checkout')->formatPrice($_item->getTotalSkybox()); ?>-->
116
- <?php endif; ?>
117
- <?php if ($_item->getBasePriceSkybox() > $_item->getPriceSkybox()):?>
118
- <span class="price price-discount" style="text-decoration: line-through;">
119
- (<?php echo $this->helper('checkout')->formatPrice($_item->getBasePriceSkybox()); ?>)
120
- </span>
121
- <span class="text-discount"><?php echo $_item->getAdjustLabelSkybox(); ?></span>
122
- <?php endif; ?>
123
- </span>
124
-
125
- <?php if (Mage::helper('weee')->getApplied($_item)): ?>
126
-
127
- <div class="cart-tax-info" id="eunit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
128
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
129
- <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
130
- <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
131
- <?php endforeach; ?>
132
- <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
133
- <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
134
- <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
135
- <?php endforeach; ?>
136
- <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
137
- <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
138
- <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
139
- <?php endforeach; ?>
140
- <?php endif; ?>
141
- </div>
142
-
143
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
144
- <div class="cart-tax-total" onclick="taxToggle('eunit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
145
- <span class="weee"><?php echo Mage::helper('weee')->__('Total'); ?>: <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?></span>
146
- </div>
147
- <?php endif; ?>
148
- <?php endif; ?>
149
- </td>
150
- <?php endif; ?><!-- inclusive price starts here -->
151
- <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
152
- <td>
153
- <?php $_incl = $this->helper('checkout')->getPriceInclTax($_item); ?>
154
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
155
- <span class="cart-tax-total" onclick="taxToggle('unit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
156
- <?php else: ?>
157
- <span class="cart-price">
158
- <?php endif; ?>
159
-
160
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
161
- <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?>
162
- <?php else: ?>
163
- <?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?>
164
- <?php endif; ?>
165
-
166
- </span>
167
- <?php if (Mage::helper('weee')->getApplied($_item)): ?>
168
-
169
- <div class="cart-tax-info" id="unit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
170
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
171
- <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
172
- <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
173
- <?php endforeach; ?>
174
- <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
175
- <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
176
- <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
177
- <?php endforeach; ?>
178
- <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
179
- <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
180
- <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
181
- <?php endforeach; ?>
182
- <?php endif; ?>
183
- </div>
184
-
185
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
186
- <div class="cart-tax-total" onclick="taxToggle('unit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
187
- <span class="weee"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>: <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?></span>
188
- </div>
189
- <?php endif; ?>
190
- <?php endif; ?>
191
- </td>
192
- <?php endif; ?>
193
- <?php endif; ?>
194
- <td class="a-center">
195
- <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" />
196
- </td>
197
-
198
- <!--Sub total starts here -->
199
- <?php if (($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) && !$_item->getNoSubtotal()): ?>
200
- <td class="a-right" style="white-space: nowrap;">
201
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
202
- <span class="cart-tax-total" onclick="taxToggle('esubtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
203
- <?php else: ?>
204
- <span class="cart-price">
205
- <?php endif; ?>
206
-
207
- <?php if ($canApplyMsrp): ?>
208
- <span class="cart-msrp-subtotal">--</span>
209
- <?php else: ?>
210
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
211
- <?php echo $this->helper('checkout')->formatPrice($_item->getTotalSkybox()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?>
212
- <?php else: ?>
213
- <?php //echo $this->helper('checkout')->formatPrice($_item->getRowTotalSkybox()) ?>
214
- <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotalSkybox()) ?><!--total-->
215
- <?php endif; ?>
216
- <?php endif; ?>
217
-
218
- </span>
219
- <?php if (Mage::helper('weee')->getApplied($_item)): ?>
220
-
221
- <div class="cart-tax-info" id="esubtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
222
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
223
- <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
224
- <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
225
- <?php endforeach; ?>
226
- <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
227
- <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
228
- <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
229
- <?php endforeach; ?>
230
- <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
231
- <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
232
- <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
233
- <?php endforeach; ?>
234
- <?php endif; ?>
235
- </div>
236
-
237
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
238
- <div class="cart-tax-total" onclick="taxToggle('esubtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
239
- <span class="weee"><?php echo Mage::helper('weee')->__('Total'); ?>: <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span>
240
- </div>
241
- <?php endif; ?>
242
- <?php endif; ?>
243
- </td>
244
- <?php endif; ?>
245
- <?php if (($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) && !$_item->getNoSubtotal()): ?>
246
- <td>
247
- <?php $_incl = $this->helper('checkout')->getSubtotalInclTax($_item); ?>
248
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
249
- <span class="cart-tax-total" onclick="taxToggle('subtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
250
- <?php else: ?>
251
- <span class="cart-price">
252
- <?php endif; ?>
253
-
254
- <?php if ($canApplyMsrp): ?>
255
- <span class="cart-msrp-subtotal">--</span>
256
- <?php else: ?>
257
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
258
- <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getRowWeeeTaxInclTax($_item)); ?>
259
- <?php else: ?>
260
- <?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?>
261
- <?php endif; ?>
262
- <?php endif; ?>
263
-
264
- </span>
265
-
266
-
267
- <?php if (Mage::helper('weee')->getApplied($_item)): ?>
268
-
269
- <div class="cart-tax-info" id="subtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
270
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
271
- <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
272
- <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
273
- <?php endforeach; ?>
274
- <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
275
- <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
276
- <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
277
- <?php endforeach; ?>
278
- <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
279
- <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
280
- <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
281
- <?php endforeach; ?>
282
- <?php endif; ?>
283
- </div>
284
-
285
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
286
- <div class="cart-tax-total" onclick="taxToggle('subtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
287
- <span class="weee"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>: <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getRowWeeeTaxInclTax($_item)); ?></span>
288
- </div>
289
- <?php endif; ?>
290
- <?php endif; ?>
291
- </td>
292
- <?php endif; ?>
293
- <td class="a-center"><a href="<?php echo $this->getDeleteUrl()?>" title="<?php echo $this->__('Remove item')?>" class="btn-remove btn-remove2"><?php echo $this->__('Remove item')?></a></td>
294
- </tr>
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ $_item = $this->getItem();
29
+ $isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility();
30
+ $canApplyMsrp = Mage::helper('catalog')->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM);
31
+ ?>
32
+ <tr>
33
+ <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>
34
+ <td>
35
+ <h2 class="product-name">
36
+ <?php if ($this->hasProductUrl()):?>
37
+ <a href="<?php echo $this->getProductUrl() ?>"><?php echo $this->escapeHtml($this->getProductName()) ?></a>
38
+ <?php else: ?>
39
+ <?php echo $this->escapeHtml($this->getProductName()) ?>
40
+ <?php endif; ?>
41
+ </h2>
42
+ <?php if ($_options = $this->getOptionList()):?>
43
+ <dl class="item-options">
44
+ <?php foreach ($_options as $_option) : ?>
45
+ <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
46
+ <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
47
+ <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
48
+ <?php if (isset($_formatedOptionValue['full_view'])): ?>
49
+ <div class="truncated_full_value">
50
+ <dl class="item-options">
51
+ <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
52
+ <dd><?php echo $_formatedOptionValue['full_view'] ?></dd>
53
+ </dl>
54
+ </div>
55
+ <?php endif; ?>
56
+ </dd>
57
+ <?php endforeach; ?>
58
+ </dl>
59
+ <?php endif;?>
60
+ <?php if ($messages = $this->getMessages()): ?>
61
+ <?php foreach ($messages as $message): ?>
62
+ <p class="item-msg <?php echo $message['type'] ?>">* <?php echo $this->escapeHtml($message['text']) ?></p>
63
+ <?php endforeach; ?>
64
+ <?php endif; ?>
65
+ <?php $addInfoBlock = $this->getProductAdditionalInformationBlock(); ?>
66
+ <?php if ($addInfoBlock): ?>
67
+ <?php echo $addInfoBlock->setItem($_item)->toHtml() ?>
68
+ <?php endif;?>
69
+ </td>
70
+ <td class="a-center">
71
+ <?php if ($isVisibleProduct): ?>
72
+ <a href="<?php echo $this->getConfigureUrl() ?>" title="<?php echo $this->__('Edit item parameters') ?>"><?php echo $this->__('Edit') ?></a>
73
+ <?php endif ?>
74
+ </td>
75
+ <?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
76
+ <td class="a-center">
77
+ <?php if ($isVisibleProduct): ?>
78
+ <a href="<?php echo $this->helper('wishlist')->getMoveFromCartUrl($_item->getId()); ?>" class="link-wishlist use-ajax"><?php echo $this->__('Move'); ?></a>
79
+ <?php endif ?>
80
+ </td>
81
+ <?php endif ?>
82
+
83
+ <?php if ($canApplyMsrp): ?>
84
+ <td class="a-right"<?php if ($this->helper('tax')->displayCartBothPrices()): ?> colspan="2"<?php endif; ?>>
85
+ <span class="cart-price">
86
+ <span class="cart-msrp-unit"><?php echo $this->__('See price before order confirmation.'); ?></span>
87
+ <?php $helpLinkId = 'cart-msrp-help-' . $_item->getId(); ?>
88
+ <a id="<?php echo $helpLinkId ?>" href="#" class="map-help-link"><?php echo $this->__("What's this?"); ?></a>
89
+ <script type="text/javascript">
90
+ Catalog.Map.addHelpLink($('<?php echo $helpLinkId ?>'), "<?php echo $this->__("Whats this?") ?>");
91
+ </script>
92
+ </span>
93
+ </td>
94
+ <?php else: ?>
95
+
96
+ <!-- Skybox Checkout -->
97
+ <!--<td class="a-center"><?php echo $this->helper('checkout')->formatPrice($_item->getPriceSkybox()); ?></td>
98
+ <td class="a-center"><?php echo $this->helper('checkout')->formatPrice($_item->getCustomsSkybox()); ?></td>
99
+ <td class="a-center"><?php echo $this->helper('checkout')->formatPrice($_item->getInsuranceSkybox()); ?></td>
100
+ <td class="a-center"><?php echo $this->helper('checkout')->formatPrice($_item->getShippingSkybox()); ?></td>-->
101
+ <!-- /Skybox Checkout -->
102
+
103
+ <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
104
+ <td class="a-right">
105
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
106
+ <span class="cart-tax-total" onclick="taxToggle('eunit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
107
+ <?php else: ?>
108
+ <span class="cart-price" style="white-space: nowrap;">
109
+ <?php endif; ?>
110
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
111
+ <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
112
+ <?php else: ?>
113
+ <?php echo $this->helper('checkout')->formatPrice($_item->getPriceSkybox()); ?>
114
+
115
+ <!--<?php echo $this->helper('checkout')->formatPrice($_item->getTotalSkybox()); ?>-->
116
+ <?php endif; ?>
117
+ <?php if ($_item->getBasePriceSkybox() > $_item->getPriceSkybox()):?>
118
+ <span class="price price-discount" style="text-decoration: line-through;">
119
+ (<?php echo $this->helper('checkout')->formatPrice($_item->getBasePriceSkybox()); ?>)
120
+ </span>
121
+ <span class="text-discount"><?php echo $_item->getAdjustLabelSkybox(); ?></span>
122
+ <?php endif; ?>
123
+ </span>
124
+
125
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
126
+
127
+ <div class="cart-tax-info" id="eunit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
128
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
129
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
130
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
131
+ <?php endforeach; ?>
132
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
133
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
134
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
135
+ <?php endforeach; ?>
136
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
137
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
138
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
139
+ <?php endforeach; ?>
140
+ <?php endif; ?>
141
+ </div>
142
+
143
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
144
+ <div class="cart-tax-total" onclick="taxToggle('eunit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
145
+ <span class="weee"><?php echo Mage::helper('weee')->__('Total'); ?>: <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?></span>
146
+ </div>
147
+ <?php endif; ?>
148
+ <?php endif; ?>
149
+ </td>
150
+ <?php endif; ?><!-- inclusive price starts here -->
151
+ <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
152
+ <td>
153
+ <?php $_incl = $this->helper('checkout')->getPriceInclTax($_item); ?>
154
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
155
+ <span class="cart-tax-total" onclick="taxToggle('unit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
156
+ <?php else: ?>
157
+ <span class="cart-price">
158
+ <?php endif; ?>
159
+
160
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
161
+ <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?>
162
+ <?php else: ?>
163
+ <?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?>
164
+ <?php endif; ?>
165
+
166
+ </span>
167
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
168
+
169
+ <div class="cart-tax-info" id="unit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
170
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
171
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
172
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
173
+ <?php endforeach; ?>
174
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
175
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
176
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
177
+ <?php endforeach; ?>
178
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
179
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
180
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
181
+ <?php endforeach; ?>
182
+ <?php endif; ?>
183
+ </div>
184
+
185
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
186
+ <div class="cart-tax-total" onclick="taxToggle('unit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
187
+ <span class="weee"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>: <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?></span>
188
+ </div>
189
+ <?php endif; ?>
190
+ <?php endif; ?>
191
+ </td>
192
+ <?php endif; ?>
193
+ <?php endif; ?>
194
+ <td class="a-center">
195
+ <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" />
196
+ </td>
197
+
198
+ <!--Sub total starts here -->
199
+ <?php if (($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) && !$_item->getNoSubtotal()): ?>
200
+ <td class="a-right" style="white-space: nowrap;">
201
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
202
+ <span class="cart-tax-total" onclick="taxToggle('esubtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
203
+ <?php else: ?>
204
+ <span class="cart-price">
205
+ <?php endif; ?>
206
+
207
+ <?php if ($canApplyMsrp): ?>
208
+ <span class="cart-msrp-subtotal">--</span>
209
+ <?php else: ?>
210
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
211
+ <?php echo $this->helper('checkout')->formatPrice($_item->getTotalSkybox()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?>
212
+ <?php else: ?>
213
+ <?php //echo $this->helper('checkout')->formatPrice($_item->getRowTotalSkybox()) ?>
214
+ <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotalSkybox()) ?><!--total-->
215
+ <?php endif; ?>
216
+ <?php endif; ?>
217
+
218
+ </span>
219
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
220
+
221
+ <div class="cart-tax-info" id="esubtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
222
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
223
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
224
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
225
+ <?php endforeach; ?>
226
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
227
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
228
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
229
+ <?php endforeach; ?>
230
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
231
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
232
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
233
+ <?php endforeach; ?>
234
+ <?php endif; ?>
235
+ </div>
236
+
237
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
238
+ <div class="cart-tax-total" onclick="taxToggle('esubtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
239
+ <span class="weee"><?php echo Mage::helper('weee')->__('Total'); ?>: <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span>
240
+ </div>
241
+ <?php endif; ?>
242
+ <?php endif; ?>
243
+ </td>
244
+ <?php endif; ?>
245
+ <?php if (($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) && !$_item->getNoSubtotal()): ?>
246
+ <td>
247
+ <?php $_incl = $this->helper('checkout')->getSubtotalInclTax($_item); ?>
248
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
249
+ <span class="cart-tax-total" onclick="taxToggle('subtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
250
+ <?php else: ?>
251
+ <span class="cart-price">
252
+ <?php endif; ?>
253
+
254
+ <?php if ($canApplyMsrp): ?>
255
+ <span class="cart-msrp-subtotal">--</span>
256
+ <?php else: ?>
257
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
258
+ <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getRowWeeeTaxInclTax($_item)); ?>
259
+ <?php else: ?>
260
+ <?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?>
261
+ <?php endif; ?>
262
+ <?php endif; ?>
263
+
264
+ </span>
265
+
266
+
267
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
268
+
269
+ <div class="cart-tax-info" id="subtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
270
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
271
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
272
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
273
+ <?php endforeach; ?>
274
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
275
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
276
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
277
+ <?php endforeach; ?>
278
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
279
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
280
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
281
+ <?php endforeach; ?>
282
+ <?php endif; ?>
283
+ </div>
284
+
285
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
286
+ <div class="cart-tax-total" onclick="taxToggle('subtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
287
+ <span class="weee"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>: <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getRowWeeeTaxInclTax($_item)); ?></span>
288
+ </div>
289
+ <?php endif; ?>
290
+ <?php endif; ?>
291
+ </td>
292
+ <?php endif; ?>
293
+ <td class="a-center"><a href="<?php echo $this->getDeleteUrl()?>" title="<?php echo $this->__('Remove item')?>" class="btn-remove btn-remove2"><?php echo $this->__('Remove item')?></a></td>
294
+ </tr>
app/design/frontend/base/default/template/skybox/checkout/cart/shipping.phtml CHANGED
@@ -1,12 +1,12 @@
1
- <?php
2
- /**
3
- * @see Mage_Checkout_Block_Cart_Shipping
4
- */
5
- $allowHelper = Mage::helper('skyboxcore/allow');
6
- if (!$allowHelper->isPriceEnabled()) :
7
- echo $this->getChildHtml('shippping');
8
- else:
9
- $cssStyleSkyBox = $this->getSkinUrl('css/skybox/style.css');
10
- echo '<link rel="stylesheet" type="text/css" href="'.$cssStyleSkyBox.'"/>';
11
- endif;
12
  ?>
1
+ <?php
2
+ /**
3
+ * @see Mage_Checkout_Block_Cart_Shipping
4
+ */
5
+ $allowHelper = Mage::helper('skyboxcore/allow');
6
+ if (!$allowHelper->isPriceEnabled()) :
7
+ echo $this->getChildHtml('shippping');
8
+ else:
9
+ $cssStyleSkyBox = $this->getSkinUrl('css/skybox/style.css');
10
+ echo '<link rel="stylesheet" type="text/css" href="'.$cssStyleSkyBox.'"/>';
11
+ endif;
12
  ?>
app/design/frontend/base/default/template/skybox/checkout/cart/sidebar.phtml CHANGED
@@ -1,80 +1,80 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- */
26
-
27
- /**
28
- * Shoping cart sidebar
29
- *
30
- * @see Mage_Checkout_Block_Cart_Sidebar
31
- */
32
-
33
- ?>
34
- <?php if ($this->getIsNeedToDisplaySideBar()):?>
35
- <div class="block block-cart">
36
- <?php $_cartQty = $this->getSummaryCount() ?>
37
- <div class="block-title">
38
- <strong><span><?php echo $this->__('My Cart') ?></span></strong>
39
- </div>
40
- <div class="block-content">
41
- <?php if ($_cartQty>0): ?>
42
- <div class="summary">
43
- <?php if ($_cartQty==1): ?>
44
- <p class="amount"><?php echo $this->__('There is <a href="%s">1 item</a> in your cart.', $this->getUrl('checkout/cart')) ?></p>
45
- <?php else: ?>
46
- <p class="amount"><?php echo $this->__('There are <a href="%s">%s items</a> in your cart.', $this->getUrl('checkout/cart'), $_cartQty) ?></p>
47
- <?php endif ?>
48
- <p class="subtotal">
49
- <?php if ($this->canApplyMsrp()): ?>
50
- <span class="map-cart-sidebar-total"><?php echo $this->__('ORDER TOTAL WILL BE DISPLAYED BEFORE YOU SUBMIT THE ORDER'); ?></span>
51
- <?php else: ?>
52
- <span class="label"><?php echo $this->__('Cart Subtotal:') ?></span> <?php echo Mage::helper('checkout')->formatPrice($this->getSubtotal()) ?>
53
- <?php if ($_subtotalInclTax = $this->getSubtotalInclTax()): ?>
54
- <br />(<?php echo Mage::helper('checkout')->formatPrice($_subtotalInclTax) ?> <?php echo Mage::helper('tax')->getIncExcText(true) ?>)
55
- <?php endif; ?>
56
- <?php endif; ?>
57
- </p>
58
- </div>
59
- <?php endif ?>
60
- <?php if($_cartQty && $this->isPossibleOnepageCheckout()): ?>
61
- <div class="actions">
62
- <?php echo $this->getChildHtml('extra_actions') ?>
63
- <button type="button" title="<?php echo $this->__('Checkout') ?>" class="button" onclick="setLocation('<?php echo $this->getCheckoutUrl() ?>')"><span><span><?php echo $this->__('Checkout') ?></span></span></button>
64
- </div>
65
- <?php endif ?>
66
- <?php $_items = $this->getRecentItems() ?>
67
- <?php if(count($_items)): ?>
68
- <p class="block-subtitle"><?php echo $this->__('Recently added item(s)') ?></p>
69
- <ol id="cart-sidebar" class="mini-products-list">
70
- <?php foreach($_items as $_item): ?>
71
- <?php echo $this->getItemHtml($_item) ?>
72
- <?php endforeach; ?>
73
- </ol>
74
- <script type="text/javascript">decorateList('cart-sidebar', 'none-recursive')</script>
75
- <?php else: ?>
76
- <p class="empty"><?php echo $this->__('You have no items in your shopping cart.') ?></p>
77
- <?php endif ?>
78
- </div>
79
- </div>
80
- <?php endif;?>
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Shoping cart sidebar
29
+ *
30
+ * @see Mage_Checkout_Block_Cart_Sidebar
31
+ */
32
+
33
+ ?>
34
+ <?php if ($this->getIsNeedToDisplaySideBar()):?>
35
+ <div class="block block-cart">
36
+ <?php $_cartQty = $this->getSummaryCount() ?>
37
+ <div class="block-title">
38
+ <strong><span><?php echo $this->__('My Cart') ?></span></strong>
39
+ </div>
40
+ <div class="block-content">
41
+ <?php if ($_cartQty>0): ?>
42
+ <div class="summary">
43
+ <?php if ($_cartQty==1): ?>
44
+ <p class="amount"><?php echo $this->__('There is <a href="%s">1 item</a> in your cart.', $this->getUrl('checkout/cart')) ?></p>
45
+ <?php else: ?>
46
+ <p class="amount"><?php echo $this->__('There are <a href="%s">%s items</a> in your cart.', $this->getUrl('checkout/cart'), $_cartQty) ?></p>
47
+ <?php endif ?>
48
+ <p class="subtotal">
49
+ <?php if ($this->canApplyMsrp()): ?>
50
+ <span class="map-cart-sidebar-total"><?php echo $this->__('ORDER TOTAL WILL BE DISPLAYED BEFORE YOU SUBMIT THE ORDER'); ?></span>
51
+ <?php else: ?>
52
+ <span class="label"><?php echo $this->__('Cart Subtotal:') ?></span> <?php echo Mage::helper('checkout')->formatPrice($this->getSubtotal()) ?>
53
+ <?php if ($_subtotalInclTax = $this->getSubtotalInclTax()): ?>
54
+ <br />(<?php echo Mage::helper('checkout')->formatPrice($_subtotalInclTax) ?> <?php echo Mage::helper('tax')->getIncExcText(true) ?>)
55
+ <?php endif; ?>
56
+ <?php endif; ?>
57
+ </p>
58
+ </div>
59
+ <?php endif ?>
60
+ <?php if($_cartQty && $this->isPossibleOnepageCheckout()): ?>
61
+ <div class="actions">
62
+ <?php echo $this->getChildHtml('extra_actions') ?>
63
+ <button type="button" title="<?php echo $this->__('Checkout') ?>" class="button" onclick="setLocation('<?php echo $this->getCheckoutUrl() ?>')"><span><span><?php echo $this->__('Checkout') ?></span></span></button>
64
+ </div>
65
+ <?php endif ?>
66
+ <?php $_items = $this->getRecentItems() ?>
67
+ <?php if(count($_items)): ?>
68
+ <p class="block-subtitle"><?php echo $this->__('Recently added item(s)') ?></p>
69
+ <ol id="cart-sidebar" class="mini-products-list">
70
+ <?php foreach($_items as $_item): ?>
71
+ <?php echo $this->getItemHtml($_item) ?>
72
+ <?php endforeach; ?>
73
+ </ol>
74
+ <script type="text/javascript">decorateList('cart-sidebar', 'none-recursive')</script>
75
+ <?php else: ?>
76
+ <p class="empty"><?php echo $this->__('You have no items in your shopping cart.') ?></p>
77
+ <?php endif ?>
78
+ </div>
79
+ </div>
80
+ <?php endif;?>
app/design/frontend/base/default/template/skybox/checkout/cart/sidebar/default.phtml CHANGED
@@ -1,146 +1,146 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- */
26
- ?>
27
- <?php
28
- $_item = $this->getItem();
29
- $isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility();
30
- $canApplyMsrp = Mage::helper('catalog')->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM);
31
- ?>
32
- <li class="item">
33
- <?php if ($this->hasProductUrl()): ?>
34
- <a href="<?php echo $this->getProductUrl()?>" title="<?php echo $this->escapeHtml($this->getProductName()) ?>" class="product-image"><img src="<?php echo $this->getProductThumbnail()->resize(50, 50)->setWatermarkSize('30x10'); ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($this->getProductName()) ?>" /></a>
35
- <?php else: ?>
36
- <span class="product-image"><img src="<?php echo $this->getProductThumbnail()->resize(50, 50)->setWatermarkSize('30x10'); ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($this->getProductName()) ?>" /></span>
37
- <?php endif; ?>
38
- <div class="product-details">
39
- <a href="<?php echo $this->getDeleteUrl() ?>" title="<?php echo $this->__('Remove This Item') ?>" onclick="return confirm('<?php echo $this->__('Are you sure you would like to remove this item from the shopping cart?') ?>');" class="btn-remove"><?php echo $this->__('Remove This Item') ?></a>
40
- <?php if ($isVisibleProduct): ?>
41
- <a href="<?php echo $this->getConfigureUrl() ?>" title="<?php echo $this->__('Edit item') ?>" class="btn-edit"><?php echo $this->__('Edit item')?></a>
42
- <?php endif ?>
43
- <p class="product-name"><?php if ($this->hasProductUrl()): ?><a href="<?php echo $this->getProductUrl() ?>"><?php endif; ?><?php echo $this->escapeHtml($this->getProductName()) ?><?php if ($this->hasProductUrl()): ?></a><?php endif; ?></p>
44
- <strong><?php echo $this->getQty() ?></strong> x
45
-
46
- <?php if ($canApplyMsrp): ?>
47
-
48
- <span class="map-cart-sidebar-item"><?php echo $this->__('See price before order confirmation.'); ?></span>
49
-
50
- <?php else: ?>
51
-
52
- <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
53
- <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
54
- <?php echo $this->__('Excl. Tax'); ?>:
55
- <?php endif; ?>
56
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?>
57
- <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
58
- <?php else: ?>
59
- <?php //echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()) ?>
60
- <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotalSkybox()) ?>
61
- <?php endif; ?>
62
- <?php if (Mage::helper('weee')->getApplied($_item)): ?>
63
- <br />
64
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales')): ?>
65
- <small>
66
- <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
67
- <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span><br />
68
- <?php endforeach; ?>
69
- </small>
70
- <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
71
- <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
72
- <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></small></span><br />
73
- <?php endforeach; ?>
74
- <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales')): ?>
75
- <small>
76
- <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
77
- <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span><br />
78
- <?php endforeach; ?>
79
- </small>
80
- <?php endif; ?>
81
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
82
- <span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br /> <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?></span>
83
- <?php endif; ?>
84
- <?php endif; ?>
85
- <?php endif; ?>
86
-
87
-
88
-
89
- <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
90
- <?php $_incl = $this->helper('checkout')->getPriceInclTax($_item); ?>
91
- <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
92
- <br /><?php echo $this->__('Incl. Tax'); ?>:
93
- <?php endif; ?>
94
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?>
95
- <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?>
96
- <?php else: ?>
97
- <?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?>
98
- <?php endif; ?>
99
- <?php if (Mage::helper('weee')->getApplied($_item)): ?>
100
- <br />
101
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales')): ?>
102
- <small>
103
- <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
104
- <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span><br />
105
- <?php endforeach; ?>
106
- </small>
107
- <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
108
- <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
109
- <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></small></span><br />
110
- <?php endforeach; ?>
111
- <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales')): ?>
112
- <small>
113
- <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
114
- <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span><br />
115
- <?php endforeach; ?>
116
- </small>
117
- <?php endif; ?>
118
- <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
119
- <span class="nobr"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>:<br /> <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?></span>
120
- <?php endif; ?>
121
- <?php endif; ?>
122
- <?php endif; ?>
123
-
124
- <?php endif; //Can apply MSRP ?>
125
-
126
- <?php if ($_options = $this->getOptionList()):?>
127
- <div class="truncated">
128
- <div class="truncated_full_value">
129
- <dl class="item-options">
130
- <?php foreach ($_options as $_option) : ?>
131
- <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
132
- <dd>
133
- <?php if (is_array($_option['value'])): ?>
134
- <?php echo nl2br(implode("\n", $_option['value'])) ?>
135
- <?php else: ?>
136
- <?php echo $_option['value'] ?>
137
- <?php endif; ?>
138
- </dd>
139
- <?php endforeach; ?>
140
- </dl>
141
- </div>
142
- <a href="#" onclick="return false;" class="details"><?php echo $this->__('Details') ?></a>
143
- </div>
144
- <?php endif; ?>
145
- </div>
146
- </li>
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ $_item = $this->getItem();
29
+ $isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility();
30
+ $canApplyMsrp = Mage::helper('catalog')->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM);
31
+ ?>
32
+ <li class="item">
33
+ <?php if ($this->hasProductUrl()): ?>
34
+ <a href="<?php echo $this->getProductUrl()?>" title="<?php echo $this->escapeHtml($this->getProductName()) ?>" class="product-image"><img src="<?php echo $this->getProductThumbnail()->resize(50, 50)->setWatermarkSize('30x10'); ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($this->getProductName()) ?>" /></a>
35
+ <?php else: ?>
36
+ <span class="product-image"><img src="<?php echo $this->getProductThumbnail()->resize(50, 50)->setWatermarkSize('30x10'); ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($this->getProductName()) ?>" /></span>
37
+ <?php endif; ?>
38
+ <div class="product-details">
39
+ <a href="<?php echo $this->getDeleteUrl() ?>" title="<?php echo $this->__('Remove This Item') ?>" onclick="return confirm('<?php echo $this->__('Are you sure you would like to remove this item from the shopping cart?') ?>');" class="btn-remove"><?php echo $this->__('Remove This Item') ?></a>
40
+ <?php if ($isVisibleProduct): ?>
41
+ <a href="<?php echo $this->getConfigureUrl() ?>" title="<?php echo $this->__('Edit item') ?>" class="btn-edit"><?php echo $this->__('Edit item')?></a>
42
+ <?php endif ?>
43
+ <p class="product-name"><?php if ($this->hasProductUrl()): ?><a href="<?php echo $this->getProductUrl() ?>"><?php endif; ?><?php echo $this->escapeHtml($this->getProductName()) ?><?php if ($this->hasProductUrl()): ?></a><?php endif; ?></p>
44
+ <strong><?php echo $this->getQty() ?></strong> x
45
+
46
+ <?php if ($canApplyMsrp): ?>
47
+
48
+ <span class="map-cart-sidebar-item"><?php echo $this->__('See price before order confirmation.'); ?></span>
49
+
50
+ <?php else: ?>
51
+
52
+ <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
53
+ <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
54
+ <?php echo $this->__('Excl. Tax'); ?>:
55
+ <?php endif; ?>
56
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?>
57
+ <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
58
+ <?php else: ?>
59
+ <?php //echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()) ?>
60
+ <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotalSkybox()) ?>
61
+ <?php endif; ?>
62
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
63
+ <br />
64
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales')): ?>
65
+ <small>
66
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
67
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span><br />
68
+ <?php endforeach; ?>
69
+ </small>
70
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
71
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
72
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></small></span><br />
73
+ <?php endforeach; ?>
74
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales')): ?>
75
+ <small>
76
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
77
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span><br />
78
+ <?php endforeach; ?>
79
+ </small>
80
+ <?php endif; ?>
81
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
82
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br /> <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?></span>
83
+ <?php endif; ?>
84
+ <?php endif; ?>
85
+ <?php endif; ?>
86
+
87
+
88
+
89
+ <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
90
+ <?php $_incl = $this->helper('checkout')->getPriceInclTax($_item); ?>
91
+ <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
92
+ <br /><?php echo $this->__('Incl. Tax'); ?>:
93
+ <?php endif; ?>
94
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?>
95
+ <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?>
96
+ <?php else: ?>
97
+ <?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?>
98
+ <?php endif; ?>
99
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
100
+ <br />
101
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales')): ?>
102
+ <small>
103
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
104
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span><br />
105
+ <?php endforeach; ?>
106
+ </small>
107
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
108
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
109
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></small></span><br />
110
+ <?php endforeach; ?>
111
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales')): ?>
112
+ <small>
113
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
114
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span><br />
115
+ <?php endforeach; ?>
116
+ </small>
117
+ <?php endif; ?>
118
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
119
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>:<br /> <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?></span>
120
+ <?php endif; ?>
121
+ <?php endif; ?>
122
+ <?php endif; ?>
123
+
124
+ <?php endif; //Can apply MSRP ?>
125
+
126
+ <?php if ($_options = $this->getOptionList()):?>
127
+ <div class="truncated">
128
+ <div class="truncated_full_value">
129
+ <dl class="item-options">
130
+ <?php foreach ($_options as $_option) : ?>
131
+ <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
132
+ <dd>
133
+ <?php if (is_array($_option['value'])): ?>
134
+ <?php echo nl2br(implode("\n", $_option['value'])) ?>
135
+ <?php else: ?>
136
+ <?php echo $_option['value'] ?>
137
+ <?php endif; ?>
138
+ </dd>
139
+ <?php endforeach; ?>
140
+ </dl>
141
+ </div>
142
+ <a href="#" onclick="return false;" class="details"><?php echo $this->__('Details') ?></a>
143
+ </div>
144
+ <?php endif; ?>
145
+ </div>
146
+ </li>
app/design/frontend/base/default/template/skybox/checkout/cart_list.phtml CHANGED
@@ -1,196 +1,196 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- */
26
- ?>
27
- <?php
28
- /**
29
- * Shopping cart template
30
- *
31
- * @see Mage_Checkout_Block_Cart
32
- */
33
- ?>
34
- <div class="cart">
35
- <div class="page-title title-buttons">
36
- <h1><?php echo $this->__('Shopping Cart') ?></h1>
37
- <?php if(!$this->hasError()): ?>
38
- <ul class="checkout-types">
39
- <?php foreach ($this->getMethods('top_methods') as $method): ?>
40
- <?php if ($methodHtml = $this->getMethodHtml($method)): ?>
41
- <li><?php echo $methodHtml; ?></li>
42
- <?php endif; ?>
43
- <?php endforeach; ?>
44
- </ul>
45
- <?php endif; ?>
46
- </div>
47
- <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
48
- <?php echo $this->getChildHtml('form_before') ?>
49
- <div class="skx-cart-list-product">
50
- <form action="<?php echo $this->getUrl('checkout/cart/updatePost') ?>" method="post">
51
- <?php echo $this->getBlockHtml('formkey'); ?>
52
- <table id="shopping-cart-table" class="data-table cart-table">
53
- <col width="1" />
54
- <col />
55
- <col width="1" />
56
- <?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
57
- <col width="1" />
58
- <?php endif ?>
59
- <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
60
- <col width="1" />
61
- <?php endif; ?>
62
- <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
63
- <col width="1" />
64
- <?php endif; ?>
65
- <col width="1" />
66
- <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
67
- <col width="1" />
68
- <?php endif; ?>
69
- <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
70
- <col width="1" />
71
- <?php endif; ?>
72
- <col width="1" />
73
-
74
- <?php $mergedCells = ($this->helper('tax')->displayCartBothPrices() ? 2 : 1); ?>
75
- <thead>
76
- <tr>
77
- <th rowspan="<?php echo $mergedCells; ?>">&nbsp;</th>
78
- <th rowspan="<?php echo $mergedCells; ?>"><span class="nobr"><?php echo $this->__('Product Name') ?></span></th>
79
- <th rowspan="<?php echo $mergedCells; ?>"></th>
80
- <?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
81
- <th rowspan="<?php echo $mergedCells; ?>" class="a-center"><span class="nobr"><?php echo $this->__('Move to Wishlist') ?></span></th>
82
- <?php endif ?>
83
- <th class="a-center" colspan="<?php echo $mergedCells; ?>"><span class="nobr"><?php echo $this->__('Unit Price') ?></span></th>
84
- <!--<th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Customs') ?></th>
85
- <th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Insurance') ?></th>
86
- <th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Shipping') ?></th>
87
- <th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Price') ?></th>-->
88
- <th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Qty') ?></th>
89
- <th class="a-center" colspan="<?php echo $mergedCells; ?>"><?php echo $this->__('Subtotal') ?></th>
90
- <th rowspan="<?php echo $mergedCells; ?>" class="a-center">&nbsp;</th>
91
- </tr>
92
- <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
93
- <tr>
94
- <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
95
- <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
96
- <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
97
- <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
98
- </tr>
99
- <?php endif; ?>
100
- </thead>
101
- <tfoot>
102
- <tr>
103
- <td colspan="50" class="a-right">
104
- <?php if($this->getContinueShoppingUrl()): ?>
105
- <button type="button" title="<?php echo $this->__('Continue Shopping') ?>" class="button btn-continue" onclick="setLocation('<?php echo $this->getContinueShoppingUrl() ?>')"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
106
- <?php endif; ?>
107
- <button type="submit" name="update_cart_action" value="update_qty" title="<?php echo $this->__('Update Shopping Cart'); ?>" class="button btn-update"><span><span><?php echo $this->__('Update Shopping Cart'); ?></span></span></button>
108
- <button type="submit" name="update_cart_action" value="empty_cart" title="<?php echo $this->__('Clear Shopping Cart'); ?>" class="button btn-empty" id="empty_cart_button"><span><span><?php echo $this->__('Clear Shopping Cart'); ?></span></span></button>
109
- <!--[if lt IE 8]>
110
- <input type="hidden" id="update_cart_action_container" />
111
- <script type="text/javascript">
112
- //<![CDATA[
113
- Event.observe(window, 'load', function()
114
- {
115
- // Internet Explorer (lt 8) does not support value attribute in button elements
116
- $emptyCartButton = $('empty_cart_button');
117
- $cartActionContainer = $('update_cart_action_container');
118
- if ($emptyCartButton && $cartActionContainer) {
119
- Event.observe($emptyCartButton, 'click', function()
120
- {
121
- $emptyCartButton.setAttribute('name', 'update_cart_action_temp');
122
- $cartActionContainer.setAttribute('name', 'update_cart_action');
123
- $cartActionContainer.setValue('empty_cart');
124
- });
125
- }
126
-
127
- });
128
- //]]>
129
- </script>
130
- <![endif]-->
131
- </td>
132
- </tr>
133
- </tfoot>
134
- <tbody>
135
- <?php foreach($this->getItems() as $_item): ?>
136
- <?php echo $this->getItemHtml($_item) ?>
137
- <?php endforeach ?>
138
- </tbody>
139
- </table>
140
- <script type="text/javascript">decorateTable('shopping-cart-table')</script>
141
- </form>
142
- </div>
143
- <div class="skx-cart-total-product">
144
- <div class="cart-forms">
145
- <?php echo $this->getChildHtml('crosssell') ?>
146
- <?php echo $this->getChildHtml('checkout.cart.extra') ?>
147
- <?php echo $this->getChildHtml('coupon') ?>
148
- <?php if (!$this->getIsVirtual()): echo $this->getChildHtml('shipping'); endif; ?>
149
- </div>
150
- <div class="cart-totals-wrapper">
151
- <div class="cart-totals">
152
- <?php echo $this->getChildHtml('totals'); ?>
153
- <?php if(!$this->hasError()): ?>
154
- <ul class="checkout-types">
155
- <?php foreach ($this->getMethods('methods') as $method): ?>
156
- <?php if ($methodHtml = $this->getMethodHtml($method)): ?>
157
- <li><?php echo $methodHtml; ?></li>
158
- <?php endif; ?>
159
- <?php endforeach; ?>
160
- </ul>
161
- <?php endif; ?>
162
- </div>
163
- </div>
164
- </div>
165
- </div>
166
- <style type="text/css">
167
- /*@media (min-width:320px) */
168
- .cart .cart-totals table tfoot strong span, .cart .cart-totals table tfoot span.price {
169
- white-space: nowrap;
170
- }
171
- @media screen and (max-width: 320px) , screen and (max-height: 480px) {
172
- .cart-table {
173
- float: none;
174
- width: 100%;
175
- }
176
- .cart-forms, .cart-totals-wrapper, .crosssell {
177
- float: none;
178
- width: 100%;
179
- padding-left: 0;
180
- }
181
-
182
- .cart .button
183
- {
184
- display: block;
185
- width: 100%;
186
- margin: 5px;
187
- float: none !important;
188
- }
189
-
190
- .cart-table tbody td.a-center {
191
- display: block;
192
- text-align: right;
193
- }
194
-
195
- }
196
  </style>
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * Shopping cart template
30
+ *
31
+ * @see Mage_Checkout_Block_Cart
32
+ */
33
+ ?>
34
+ <div class="cart">
35
+ <div class="page-title title-buttons">
36
+ <h1><?php echo $this->__('Shopping Cart') ?></h1>
37
+ <?php if(!$this->hasError()): ?>
38
+ <ul class="checkout-types">
39
+ <?php foreach ($this->getMethods('top_methods') as $method): ?>
40
+ <?php if ($methodHtml = $this->getMethodHtml($method)): ?>
41
+ <li><?php echo $methodHtml; ?></li>
42
+ <?php endif; ?>
43
+ <?php endforeach; ?>
44
+ </ul>
45
+ <?php endif; ?>
46
+ </div>
47
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
48
+ <?php echo $this->getChildHtml('form_before') ?>
49
+ <div class="skx-cart-list-product">
50
+ <form action="<?php echo $this->getUrl('checkout/cart/updatePost') ?>" method="post">
51
+ <?php echo $this->getBlockHtml('formkey'); ?>
52
+ <table id="shopping-cart-table" class="data-table cart-table">
53
+ <col width="1" />
54
+ <col />
55
+ <col width="1" />
56
+ <?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
57
+ <col width="1" />
58
+ <?php endif ?>
59
+ <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
60
+ <col width="1" />
61
+ <?php endif; ?>
62
+ <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
63
+ <col width="1" />
64
+ <?php endif; ?>
65
+ <col width="1" />
66
+ <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
67
+ <col width="1" />
68
+ <?php endif; ?>
69
+ <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
70
+ <col width="1" />
71
+ <?php endif; ?>
72
+ <col width="1" />
73
+
74
+ <?php $mergedCells = ($this->helper('tax')->displayCartBothPrices() ? 2 : 1); ?>
75
+ <thead>
76
+ <tr>
77
+ <th rowspan="<?php echo $mergedCells; ?>">&nbsp;</th>
78
+ <th rowspan="<?php echo $mergedCells; ?>"><span class="nobr"><?php echo $this->__('Product Name') ?></span></th>
79
+ <th rowspan="<?php echo $mergedCells; ?>"></th>
80
+ <?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
81
+ <th rowspan="<?php echo $mergedCells; ?>" class="a-center"><span class="nobr"><?php echo $this->__('Move to Wishlist') ?></span></th>
82
+ <?php endif ?>
83
+ <th class="a-center" colspan="<?php echo $mergedCells; ?>"><span class="nobr"><?php echo $this->__('Unit Price') ?></span></th>
84
+ <!--<th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Customs') ?></th>
85
+ <th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Insurance') ?></th>
86
+ <th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Shipping') ?></th>
87
+ <th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Price') ?></th>-->
88
+ <th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Qty') ?></th>
89
+ <th class="a-center" colspan="<?php echo $mergedCells; ?>"><?php echo $this->__('Subtotal') ?></th>
90
+ <th rowspan="<?php echo $mergedCells; ?>" class="a-center">&nbsp;</th>
91
+ </tr>
92
+ <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
93
+ <tr>
94
+ <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
95
+ <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
96
+ <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
97
+ <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
98
+ </tr>
99
+ <?php endif; ?>
100
+ </thead>
101
+ <tfoot>
102
+ <tr>
103
+ <td colspan="50" class="a-right">
104
+ <?php if($this->getContinueShoppingUrl()): ?>
105
+ <button type="button" title="<?php echo $this->__('Continue Shopping') ?>" class="button btn-continue" onclick="setLocation('<?php echo $this->getContinueShoppingUrl() ?>')"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
106
+ <?php endif; ?>
107
+ <button type="submit" name="update_cart_action" value="update_qty" title="<?php echo $this->__('Update Shopping Cart'); ?>" class="button btn-update"><span><span><?php echo $this->__('Update Shopping Cart'); ?></span></span></button>
108
+ <button type="submit" name="update_cart_action" value="empty_cart" title="<?php echo $this->__('Clear Shopping Cart'); ?>" class="button btn-empty" id="empty_cart_button"><span><span><?php echo $this->__('Clear Shopping Cart'); ?></span></span></button>
109
+ <!--[if lt IE 8]>
110
+ <input type="hidden" id="update_cart_action_container" />
111
+ <script type="text/javascript">
112
+ //<![CDATA[
113
+ Event.observe(window, 'load', function()
114
+ {
115
+ // Internet Explorer (lt 8) does not support value attribute in button elements
116
+ $emptyCartButton = $('empty_cart_button');
117
+ $cartActionContainer = $('update_cart_action_container');
118
+ if ($emptyCartButton && $cartActionContainer) {
119
+ Event.observe($emptyCartButton, 'click', function()
120
+ {
121
+ $emptyCartButton.setAttribute('name', 'update_cart_action_temp');
122
+ $cartActionContainer.setAttribute('name', 'update_cart_action');
123
+ $cartActionContainer.setValue('empty_cart');
124
+ });
125
+ }
126
+
127
+ });
128
+ //]]>
129
+ </script>
130
+ <![endif]-->
131
+ </td>
132
+ </tr>
133
+ </tfoot>
134
+ <tbody>
135
+ <?php foreach($this->getItems() as $_item): ?>
136
+ <?php echo $this->getItemHtml($_item) ?>
137
+ <?php endforeach ?>
138
+ </tbody>
139
+ </table>
140
+ <script type="text/javascript">decorateTable('shopping-cart-table')</script>
141
+ </form>
142
+ </div>
143
+ <div class="skx-cart-total-product">
144
+ <div class="cart-forms">
145
+ <?php echo $this->getChildHtml('crosssell') ?>
146
+ <?php echo $this->getChildHtml('checkout.cart.extra') ?>
147
+ <?php echo $this->getChildHtml('coupon') ?>
148
+ <?php if (!$this->getIsVirtual()): echo $this->getChildHtml('shipping'); endif; ?>
149
+ </div>
150
+ <div class="cart-totals-wrapper">
151
+ <div class="cart-totals">
152
+ <?php echo $this->getChildHtml('totals'); ?>
153
+ <?php if(!$this->hasError()): ?>
154
+ <ul class="checkout-types">
155
+ <?php foreach ($this->getMethods('methods') as $method): ?>
156
+ <?php if ($methodHtml = $this->getMethodHtml($method)): ?>
157
+ <li><?php echo $methodHtml; ?></li>
158
+ <?php endif; ?>
159
+ <?php endforeach; ?>
160
+ </ul>
161
+ <?php endif; ?>
162
+ </div>
163
+ </div>
164
+ </div>
165
+ </div>
166
+ <style type="text/css">
167
+ /*@media (min-width:320px) */
168
+ .cart .cart-totals table tfoot strong span, .cart .cart-totals table tfoot span.price {
169
+ white-space: nowrap;
170
+ }
171
+ @media screen and (max-width: 320px) , screen and (max-height: 480px) {
172
+ .cart-table {
173
+ float: none;
174
+ width: 100%;
175
+ }
176
+ .cart-forms, .cart-totals-wrapper, .crosssell {
177
+ float: none;
178
+ width: 100%;
179
+ padding-left: 0;
180
+ }
181
+
182
+ .cart .button
183
+ {
184
+ display: block;
185
+ width: 100%;
186
+ margin: 5px;
187
+ float: none !important;
188
+ }
189
+
190
+ .cart-table tbody td.a-center {
191
+ display: block;
192
+ text-align: right;
193
+ }
194
+
195
+ }
196
  </style>
app/design/frontend/base/default/template/skybox/checkout/multishipping/link.phtml CHANGED
@@ -1,9 +1,9 @@
1
- <?php
2
- /**
3
- * @see Mage_Checkout_Block_Multishipping_Link
4
- */
5
- $allowHelper = Mage::helper('skyboxcore/allow');
6
- if (!$allowHelper->isPriceEnabled()) :
7
- echo $this->getChildHtml('multishipping2');
8
- endif;
9
  ?>
1
+ <?php
2
+ /**
3
+ * @see Mage_Checkout_Block_Multishipping_Link
4
+ */
5
+ $allowHelper = Mage::helper('skyboxcore/allow');
6
+ if (!$allowHelper->isPriceEnabled()) :
7
+ echo $this->getChildHtml('multishipping2');
8
+ endif;
9
  ?>
app/design/frontend/base/default/template/skybox/checkout/onepage.phtml CHANGED
@@ -1,3 +1,3 @@
1
- <?php
2
-
3
- Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl("skbcheckout/international"));
1
+ <?php
2
+
3
+ Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl("skbcheckout/international"));
app/design/frontend/base/default/template/skybox/checkout/onepage/link.phtml CHANGED
@@ -1,38 +1,38 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magento.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magento.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- */
26
-
27
- $allowHelper = Mage::helper('skyboxcore/allow');
28
- if ($allowHelper->isCartButtonSkyboxEnabled()) :
29
- ?>
30
- <button type="button"
31
- class="button btn-proceed-checkout btn-checkout"
32
- onclick="window.location='<?php echo $this->getUrl('skbcheckout/international',
33
- array('_secure' => true)) ?>';">
34
- <span>
35
- <span><?php echo $this->__('Checkout with SkyBOX Checkout') ?></span>
36
- </span>
37
- </button>
38
  <?php endif; ?>
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+
27
+ $allowHelper = Mage::helper('skyboxcore/allow');
28
+ if ($allowHelper->isCartButtonSkyboxEnabled()) :
29
+ ?>
30
+ <button type="button"
31
+ class="button btn-proceed-checkout btn-checkout"
32
+ onclick="window.location='<?php echo $this->getUrl('skbcheckout/international',
33
+ array('_secure' => true)) ?>';">
34
+ <span>
35
+ <span><?php echo $this->__('Checkout with SkyBOX Checkout') ?></span>
36
+ </span>
37
+ </button>
38
  <?php endif; ?>
app/design/frontend/base/default/template/skybox/checkout/pagecheckout.phtml CHANGED
@@ -1,32 +1,32 @@
1
- <?php
2
- /**
3
- * Template for Mage_Page_Block_Html
4
- */
5
- ?>
6
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
7
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">
8
- <head>
9
- <?php echo $this->getChildHtml('head') ?>
10
- </head>
11
- <body<?php echo $this->getBodyClass()?' class="'.$this->getBodyClass().'"':'' ?>>
12
- <?php echo $this->getChildHtml('after_body_start') ?>
13
- <div class="wrapper">
14
- <?php echo $this->getChildHtml('global_notices') ?>
15
- <div class="page">
16
- <?php echo $this->getChildHtml('headerskybox') ?>
17
- <div class="main-container col1-layout">
18
- <div class="main">
19
- <div class="col-main">
20
- <?php echo $this->getChildHtml('global_messages') ?>
21
- <?php echo $this->getChildHtml('content') ?>
22
- </div>
23
- </div>
24
- </div>
25
- <?php echo $this->getChildHtml('footer') ?>
26
- <?php echo $this->getChildHtml('global_cookie_notice') ?>
27
- <?php echo $this->getChildHtml('before_body_end') ?>
28
- </div>
29
- </div>
30
- <?php echo $this->getAbsoluteFooter() ?>
31
- </body>
32
  </html>
1
+ <?php
2
+ /**
3
+ * Template for Mage_Page_Block_Html
4
+ */
5
+ ?>
6
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
7
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">
8
+ <head>
9
+ <?php echo $this->getChildHtml('head') ?>
10
+ </head>
11
+ <body<?php echo $this->getBodyClass()?' class="'.$this->getBodyClass().'"':'' ?>>
12
+ <?php echo $this->getChildHtml('after_body_start') ?>
13
+ <div class="wrapper">
14
+ <?php echo $this->getChildHtml('global_notices') ?>
15
+ <div class="page">
16
+ <?php echo $this->getChildHtml('headerskybox') ?>
17
+ <div class="main-container col1-layout">
18
+ <div class="main">
19
+ <div class="col-main">
20
+ <?php echo $this->getChildHtml('global_messages') ?>
21
+ <?php echo $this->getChildHtml('content') ?>
22
+ </div>
23
+ </div>
24
+ </div>
25
+ <?php echo $this->getChildHtml('footer') ?>
26
+ <?php echo $this->getChildHtml('global_cookie_notice') ?>
27
+ <?php echo $this->getChildHtml('before_body_end') ?>
28
+ </div>
29
+ </div>
30
+ <?php echo $this->getAbsoluteFooter() ?>
31
+ </body>
32
  </html>
app/design/frontend/base/default/template/skybox/checkout/skyboxcheckout.phtml CHANGED
@@ -1,358 +1,222 @@
1
- <?php
2
- $_helper = Mage::helper('skyboxinternational/data');
3
-
4
- $_model = Mage::getModel('skyboxcore/standard');
5
-
6
- /** @var Skybox_Core_Model_Config $_config */
7
- $_config = Mage::getModel('skyboxcore/config');
8
-
9
- /** @var Skybox_Checkout_Model_Api_Checkout $_checkout */
10
- $_checkout = Mage::getModel('skyboxcheckout/api_checkout');
11
-
12
- /** @var Skybox_Core_Helper_Allow $allowHelper */
13
- $allowHelper = Mage::helper('skyboxcore/allow');
14
-
15
- $isCartEnabled = $allowHelper->isCartBarEnabled();
16
-
17
- $_cartDataURL = "";
18
- $_merchant = $_helper->getMerchantCode();
19
- $template = "";
20
- $cartId = $_helper->getCartId();
21
-
22
- Mage::log("InitializeBarSkybox ", null, 'skyboxcheckout.log', true);
23
- $_checkout->InitializeBarSkybox();
24
-
25
- $change_country = false;
26
- $request = $this->getRequest();
27
- $module = $request->getModuleName();
28
- $controller = $request->getControllerName();
29
- $action = $request->getActionName();
30
- $getHomeUrl = Mage::helper('core/url')->getHomeUrl();
31
- $_url_check_cart = Mage::getUrl("checkout/cart");
32
-
33
- $cart = $_config->getSession()->getCartSkybox();
34
- /**
35
- * Start Aditional we add a line debug with integration information
36
- */
37
- echo '<script>
38
- console.log("LocationAllowService: ' . $_checkout->getLocationAllow() . ' ");
39
- </script>';
40
- /**
41
- * End Aditional we add a line debug with integration information
42
- */
43
- //$template = "<a href='#' id='link_choise_country'>&nbsp;</a>";
44
- // Load CSS & JS
45
- $skybox_url = $_helper->getSkyboxUrlMain();// $_config->skyboxDefaultUrl;
46
- $api_css_button_international = $skybox_url . 'widgets/api-button/css/api-button-international-css.ashx';
47
- $api_css_button_international .= '?s=' . $_helper->getMerchantCode();
48
- $api_css_button_international .= '&CssVersion=' . $_helper->getCssVersion();
49
- $api_js_button_international = $skybox_url . 'Content/debug/API/js/api-button-tooltip.js';
50
-
51
- if ($allowHelper->isCartBarEnabled()) :
52
- $template = '';
53
- $cart = $_config->getSession()->getCartSkybox();
54
- if (!empty($cart)) :
55
- $template = $cart->BarHtmlTemplate;
56
- foreach ($cart as $key => $value) :
57
- $template = str_replace('{' . $key . '}', $value, $template);
58
- endforeach;
59
- endif;
60
- $_cartDataURL = $cart->CartDataURL;
61
- echo $template;
62
- endif;
63
- ?>
64
- <link rel="stylesheet" type="text/css" href="<?php echo $api_css_button_international; ?>"/>
65
- <link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('css/skybox/style.css?v=' . $_helper->getCssVersion()); ?>"/>
66
- <!-- <link rel="stylesheet" type="text/css" href="--><?php #echo $this->getSkinUrl('css/skybox/style.css?v=230120171122');?><!--"/>-->
67
- <script type="text/javascript">
68
- var URL_CHECK_CART = "<?php echo $_url_check_cart ?>";
69
- var CART_ID = "<?php echo $cartId ?>";
70
- var CART_DATA_URL = "<?php echo $_cartDataURL ?>";
71
- var MERCHANT = "<?php echo $_merchant ?>";
72
- var SKYBOX_URL = "<?php echo $skybox_url ?>";
73
- var CHANGE_COUNTRY = "<?php echo $change_country ?>";
74
- var ACTUAL_URI = "<?php echo 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'] ?>";
75
- var GET_HOME_URL = "<?php echo $getHomeUrl ?>";
76
- jQuery(document).ready(function() {
77
- jQuery(".skybox-price-set").each(function( index ) {
78
- <?php
79
- $skyBoxUrlClientBase= $_helper->getSkyBoxUrlAPI();
80
- $codeShop = Mage::getModel('skyboxcatalog/api_product')->getStoreCode();
81
- $skyBoxUrlClientGet = str_replace("apirest/", "", $skyBoxUrlClientBase);
82
- $skyBoxUrlClient = $skyBoxUrlClientGet . "multiplecalculate/" . $codeShop . "/calc-";
83
- ?>
84
- var SkyBoxUrlClient = "<?php echo $skyBoxUrlClient;?>";
85
- var dataId = jQuery(this).attr("id");
86
- var id = jQuery(this).attr("product-id");
87
- var url = SkyBoxUrlClient + id + ".html";
88
- var content = jQuery.get(url, function (data) {
89
- jQuery("#" + dataId).html(data);
90
- });
91
- });
92
- });
93
-
94
- (function ($) {
95
-
96
- var widthPage = 0;
97
- var heightPage = 0;
98
- var popup = {};
99
- var popupWidth = 540;
100
- var popupHeight = 545;
101
- var win = '';
102
-
103
- function showPopup(name, t, url, w, h) {
104
- //winCompare = new Window('popup', {className: 'alphacube', title: t, url: url, width: w, height: h, minimizable: false, maximizable: false, showEffectOptions: {duration: 0.4}, hideEffectOptions: {duration: 0.4} });
105
- winCompare = new Window(name, {
106
- className: 'alphacube',
107
- title: t,
108
- url: url,
109
- width: w,
110
- height: h,
111
- minimizable: false,
112
- maximizable: false,
113
- showEffectOptions: {duration: 0.4},
114
- hideEffectOptions: {duration: 0.4},
115
- destroyOnClose: true,
116
- draggable: false,
117
- resizable: false
118
- });
119
-
120
- winCompare.setDestroyOnClose();
121
- winCompare.setZIndex(9999);
122
- winCompare.showCenter(true);
123
- return winCompare;
124
- }
125
-
126
- function goToCart() {
127
- document.location = URL_CHECK_CART;
128
- }
129
-
130
- function goToInitializeSession() {
131
- var idCart = CART_ID;
132
- var datos = CART_DATA_URL;
133
- var merchant = MERCHANT;
134
- var actualUri = ACTUAL_URI + "?LoadFrame=1";
135
- var url = SKYBOX_URL + "WebForms/PublicSite/Tracking.aspx?" + datos + "&merchant=" + merchant + "&idCart=" + idCart + "&ReLoad=1&uri=" + actualUri;
136
- var name = 'initSession' + Date.now();
137
- callAlphacube();
138
- showPopup(name, '', url, (widthPage - 50 ), ((heightPage < 800) ? heightPage - 50 : 800));
139
- }
140
-
141
- function callAlphacube(){
142
- var alphacube_ = document.querySelectorAll('.alphacube_close');
143
- if(alphacube_.length > 0){
144
- var overlay_ = document.getElementById("overlay_modal");
145
-
146
- if(overlay_ !== null) overlay_.style.display = '';
147
- var id_modal = (alphacube_[1]) ? alphacube_[1].parentNode.getAttribute('id') : '';
148
- try{
149
- document.getElementById(id_modal).remove();
150
- }
151
- catch(e) {
152
-
153
- }
154
- }
155
- }
156
-
157
- function goToLocation() {
158
- win = 'resync';
159
- var datos = CART_DATA_URL;
160
- var process_url = GET_HOME_URL + "skbcheckout/process";
161
- var return_url = getReturnUrl();
162
- // var return_url = document.URL;
163
- var change_country_status = CHANGE_COUNTRY;
164
- var url = SKYBOX_URL + "Webforms/PublicSite/ReSync.aspx?" + datos;
165
- url += "&process_url=" + process_url;
166
- url += "&return_url=" + return_url;
167
- url += "&change_country=" + change_country_status;
168
-
169
- var _size = getSizeForPopup();
170
- var name = 'selectLocation' + Date.now();
171
- callAlphacube();
172
- popup = showPopup(name, '', url, _size.width, _size.height);
173
- }
174
-
175
- function goToTrackingLocation() {
176
- var url = SKYBOX_URL + "Webforms/PublicSite/Tracking.aspx?" + CART_DATA_URL + "&idCart=" + CART_ID;
177
- var name = 'tracking' + Date.now();
178
- showPopup(name, '', url, (widthPage - 50 ), ((heightPage < 800) ? heightPage - 50 : 800));
179
- }
180
-
181
- function loadIframe() {
182
- var actualUri = ACTUAL_URI;
183
- var flgLoadIframe = "<?php echo (isset($_GET['LoadFrame'])) ? $_GET['LoadFrame'] : 0; ?>";
184
- if (flgLoadIframe === "1") {
185
- if (actualUri.indexOf("skbcheckout/international") === -1) goToInitializeSession();
186
- }
187
- }
188
-
189
- function postMessageIframe() {
190
- var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
191
- var eventer = window[eventMethod];
192
- var messageEvent = eventMethod === "attachEvent" ? "onmessage" : "message";
193
- eventer(messageEvent,function(e) {
194
- // if(e.origin == 'https://www.skyboxcheckout.com'){
195
- recalculateHeightIframe(e.data);
196
- // }
197
- },false);
198
- }
199
-
200
- function recalculateHeightIframe(data) {
201
- if (data.win === 'resync') {
202
- popupHeight = data.height;
203
- var _size = getSizeForPopup();
204
- try{
205
- popup.setSize(_size.width, _size.height);
206
- }
207
- catch (e) {
208
- // console.log("not calculate popup:::: ", e);
209
- }
210
- // popup.showCenter(true);
211
- }
212
- }
213
-
214
- function browserResize() {
215
- jQuery(window).resize(function() {
216
- if(!jQuery.isEmptyObject(popup)){
217
- var _size = getSizeForPopup();
218
- popup.setSize(_size.width, _size.height)
219
- }
220
- });
221
- }
222
-
223
- function getSizeForPopup() {
224
- var _width = jQuery(window).width();
225
- var _height = jQuery(window).height();
226
- _width = (_width < popupWidth) ? _width - 30 : popupWidth ;
227
- return {width: _width, height: popupHeight};
228
- }
229
-
230
- $(".skx_position_option_country").unbind().click(function () {
231
- goToLocation();
232
- });
233
-
234
- $(".skx_banner_image_account").unbind().click(function () {
235
- goToInitializeSession();
236
- });
237
-
238
- $(".skx_banner_image_car").unbind().click(function () {
239
- goToCart();
240
- });
241
-
242
- $(".skx_banner_image_tracking").unbind().click(function () {
243
- goToTrackingLocation();
244
- });
245
-
246
- $("#link_choise_country").unbind().click(function () {
247
- goToCart();
248
- });
249
-
250
- $(document).ready(function () {
251
- widthPage = $(window).width();
252
- heightPage = $(window).height();
253
- postMessageIframe();
254
- loadIframe();
255
- browserResize();
256
- });
257
- })(jQuery);
258
- </script>
259
-
260
- <script type="text/javascript">
261
- //<![CDATA[
262
- var SKYBOX_OPTIONS_PRICE_URL = '<?php echo Mage::getUrl(); ?>skbcheckout/calculate';
263
- //]]>
264
- </script>
265
-
266
- <script type="text/javascript" src="<?php echo $api_js_button_international; ?>"></script>
267
-
268
- <?php
269
-
270
- /**
271
- * Integration 3 start, show bar*
272
- */
273
- if (!$_checkout->getErrorAuthenticate() && $_checkout->getLocationAllow()) : // Rogged
274
- // Calculate height
275
- $size = 0;
276
-
277
- $UserTemporal = "1";
278
- $CartItemCount = 0;
279
-
280
- if (!$_checkout->getErrorAuthenticate() && $_checkout->getLocationAllow()) :
281
- $cart = $_config->getSession()->getCartSkybox();
282
- if (!empty($cart)) :
283
- $UserTemporal = $cart->{'UserTemporal'};
284
- $CartItemCount = intval($cart->{'CartItemCount'});
285
- for ($i = 1; $i <= $CartItemCount; $i++) :
286
- $size = $size + 50;
287
- endfor;
288
- endif;
289
- endif;
290
-
291
-
292
- $merchant = $_helper->getMerchantCode();
293
- $storeId = $_helper->getStoreId();
294
- $cartId = $_helper->getCartId();
295
- $guid = $_model->getGuidApi();
296
- $urlSuccess = Mage::getUrl("skbcheckout/international/success");
297
- $urlConfirm = Mage::getUrl("skbcheckout/international");
298
- $token = $_model->AuthenticateService()->getAuthorizedToken();
299
-
300
- $url = $_helper->getSkyboxUrlMain() . "WebForms/Checkout/APICheckout.aspx"; //$_config->skyboxDefaultUrl . "WebForms/Checkout/APICheckout.aspx";
301
- $url .= "?token=" . $token;
302
- $url .= "&GuiId=" . $guid;
303
- $url .= "&merchant=" . $merchant;
304
- $url .= "&idCart=" . $cartId;
305
- $url .= "&idStore=" . $storeId;
306
- $url .= "&UrlC=" . $urlConfirm;// "http://magento.skynet.com/magento192/skbcheckout/international";
307
- $url .= "&paypal=" . $_GET["paypal"];
308
- $url .= '&checkout=' . strip_tags(Mage::app()->getRequest()->getParam('checkout',''));
309
- $url .= "&UrlR=" . $urlSuccess;
310
-
311
- if($size == 0):
312
- $cart = Mage::getSingleton('checkout/session')->getQuote();
313
- foreach ($cart->getAllItems() as $item) :
314
- $size = $size + 50;
315
- endforeach;
316
- endif;
317
-
318
- if($size == 0) $size = 100;
319
-
320
- $height = (($UserTemporal == "1") ? 1400 : 900) + $size;
321
- $height = 2500;
322
- ?>
323
- <div class="div_iframe_skybox_checkout">
324
- <iframe id="iframe_skybox_checkout" src="<?php echo $url; ?>" frameborder="0" scrolling="no"></iframe>
325
- </div>
326
- <script type="text/javascript">
327
- jQuery(document).ready(function() {
328
- var height = <?php echo $height; ?>;
329
- var isMobile = /Mobi/.test(navigator.userAgent);
330
- console.log("isMobile ::: " + isMobile);
331
- if (isMobile) {
332
- height = jQuery(window).height();
333
- height = height * 5;
334
- }
335
- console.log("height ::: " + height);
336
- jQuery('#iframe_skybox_checkout').attr('height', height);
337
- });
338
- </script>
339
- <?php
340
- // ----- Rogged -----
341
- else:
342
- Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl("checkout/onepage"));
343
- endif;
344
- // ----- ----- -----
345
- ?>
346
- <script>
347
- setTimeout(function(){
348
- var location_pathname = window.location.pathname.split('/');
349
- var skx_bar = document.getElementsByClassName('skx-bar-text');
350
- try{
351
- if(location_pathname[2] === "international") skx_bar[0].style.display = "none";
352
- }
353
- catch(e) {
354
-
355
- }
356
- }, 300);
357
-
358
- </script>
1
+ <?php
2
+ /** @var Skybox_International_Helper_Data $_helper */
3
+ $_helper = Mage::helper('skyboxinternational/data');
4
+
5
+ if ($_helper->getActive()) {
6
+
7
+ /** @var Skybox_Core_Model_Config $_config */
8
+ $_config = Mage::getModel('skyboxcore/config');
9
+
10
+ /** @var Skybox_Checkout_Model_Api_Checkout $_checkout */
11
+ $_checkout = Mage::getModel('skyboxcheckout/api_checkout');
12
+
13
+ /** @var Skybox_Core_Helper_Allow $allowHelper */
14
+ $allowHelper = Mage::helper('skyboxcore/allow');
15
+
16
+ $_cartDataURL = "";
17
+ $_merchant = $_helper->getMerchantCode();
18
+ $template = "";
19
+ $cartId = $_helper->getCartId();
20
+ $cssVersion = $_helper->getCssVersion();
21
+
22
+ $_checkout->InitializeBarSkybox();
23
+
24
+ $change_country = false;
25
+
26
+ // $request = $this->getRequest();
27
+ // $module = $request->getModuleName();
28
+ // $controller = $request->getControllerName();
29
+ // $action = $request->getActionName();
30
+ $getHomeUrl = Mage::helper('core/url')->getHomeUrl();
31
+ $urlCheckCart = Mage::getUrl("checkout/cart");
32
+
33
+ $cart = $_config->getSession()->getCartSkybox();
34
+
35
+ // Load CSS & JS
36
+ $skybox_url = $_helper->getSkyboxUrlMain();// $_config->skyboxDefaultUrl;
37
+ $api_css_button_international = $skybox_url . 'widgets/api-button/css/api-button-international-css.ashx';
38
+ $api_css_button_international .= '?s=' . $_merchant;
39
+ $api_css_button_international .= '&CssVersion=' . $cssVersion;
40
+ $api_js_button_international = $skybox_url . 'Content/debug/API/js/api-button-tooltip.js';
41
+ $countryChange = 0;
42
+
43
+ if ($allowHelper->isCartBarEnabled()) :
44
+ $countryChange = 1;
45
+ $template = '';
46
+ // $cart = $_config->getSession()->getCartSkybox();
47
+ if (!empty($cart)) :
48
+ $template = $cart->BarHtmlTemplate;
49
+ foreach ($cart as $key => $value) :
50
+ $template = str_ireplace('{' . $key . '}', $value, $template);
51
+ endforeach;
52
+ endif;
53
+ $_cartDataURL = $cart->CartDataURL;
54
+ echo $template;
55
+ endif;
56
+
57
+ if ($allowHelper->isChangeCountryEnabled()):
58
+ // $cart = $_config->getSession()->getCartSkybox();
59
+ $template = "<div class='main-container' style='padding: 10px 0 0;text-align: right;'>";
60
+ $template .= "<div class='change_country'>";
61
+ $template .= "<a class='skx_position_option_country' href='javascript:;'>Change country</a>";
62
+ $template .= "</div>";
63
+ $template .= "</div>";
64
+ $change_country = true;
65
+ $countryChange = 0;
66
+ $_cartDataURL = $cart->CartDataURL;
67
+ echo $template;
68
+ endif;
69
+
70
+ if ($allowHelper->isPriceEnabled()) {
71
+ $productConfigurable = $this->getSkinUrl('js/skybox/catalog.product.configurable.js');
72
+ echo '<script type="text/javascript" src="' . $productConfigurable . '"></script>';
73
+ }
74
+
75
+ $skyBoxUrlClientBase = $_helper->getSkyBoxUrlAPI();
76
+ $storeCode = Mage::getModel('skyboxcatalog/api_product')->getStoreCode();
77
+ $skyBoxUrlClientGet = str_ireplace("apirest/", "", $skyBoxUrlClientBase);
78
+ $skyBoxUrlClient = $skyBoxUrlClientGet . "multiplecalculate/" . $storeCode . "/calc-";
79
+ ?>
80
+
81
+ <link rel="stylesheet" type="text/css" href="<?php echo $api_css_button_international; ?>"/>
82
+ <link rel="stylesheet" type="text/css"
83
+ href="<?php echo $this->getSkinUrl('css/skybox/style.css?v=' . $cssVersion); ?>"/>
84
+ <script type="text/javascript">
85
+ var URL_CHECK_CART = "<?php echo $urlCheckCart ?>";
86
+ var CART_ID = "<?php echo $cartId ?>";
87
+ var CART_DATA_URL_SKYBOX = "<?php echo $_cartDataURL ?>";
88
+ var MERCHANT_ID_SKYBOX = "<?php echo $_merchant ?>";
89
+ var SKYBOX_URL = "<?php echo $skybox_url ?>";
90
+ var CHANGE_COUNTRY = "<?php echo $change_country ?>";
91
+ var ACTUAL_URI = "<?php echo 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'] ?>";
92
+ var GET_HOME_URL = "<?php echo $getHomeUrl ?>";
93
+ var COUNTRY_CHANGE = "<?php echo $countryChange?>";
94
+ var IS_SKYBOX_VISIBLE = "<?php echo $_checkout->getLocationAllow(); ?>";
95
+ var URL_BASE_MAGENTO = "<?php echo Mage::getBaseUrl() ?>";
96
+ var IS_REGISTRATION_DISABLED_SKYBOX = 1;
97
+ var LOADING_IMAGE = "<?php echo $this->getSkinUrl('images/skybox/ajax-loading.gif')?>";
98
+
99
+ (function ($) {
100
+ $(document).ready(function () {
101
+ if (typeof $.fancybox !== "function") {
102
+ var fileref = document.createElement("link");
103
+ fileref.rel = "stylesheet";
104
+ fileref.type = "text/css";
105
+ fileref.href = "<?php echo $this->getSkinUrl('css/skybox/jquery.fancybox.css');?>";
106
+ document.getElementsByTagName("head")[0].appendChild(fileref);
107
+ $('head').append($('<script />').attr('src', '<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'js/skybox/jquery.fancybox.js'; ?>'));
108
+ }
109
+ $(".skybox-price-set").each(function (index) {
110
+ var SkyBoxUrlClient = "<?php echo $skyBoxUrlClient;?>";
111
+ var dataId = $(this).attr("id");
112
+ var id = $(this).attr("product-id");
113
+ var url = SkyBoxUrlClient + id + ".html";
114
+ var content = $.get(url, function (data) {
115
+ $("#" + dataId).html(data);
116
+ });
117
+ });
118
+ });
119
+ })(jQuery);
120
+ </script>
121
+ <script src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'js/skybox/main.js'; ?>"></script>
122
+ <script type="text/javascript">
123
+ //<![CDATA[
124
+ var SKYBOX_OPTIONS_PRICE_URL = '<?php echo Mage::getUrl("skbcheckout/calculate"); ?>';
125
+ //]]>
126
+ </script>
127
+ <script type="text/javascript" src="<?php echo $api_js_button_international; ?>"></script>
128
+ <script>
129
+ // @todo Fix more Change countries Block issue
130
+ setTimeout(function () {
131
+ jQuery("a[href='#'].skx-bar-other").attr('href', 'javascript:;');
132
+ var country_change = "<?php echo $countryChange?>";
133
+ if (parseInt(country_change) === 1) {
134
+ var currencyISO_ = document.getElementsByClassName('skx_banner_label_currencyISO');
135
+ if (currencyISO_.length > 1) {
136
+ var nextSiblingOne = currencyISO_[0].nextElementSibling;
137
+ var getAttrNextSiblingOne = nextSiblingOne.getAttribute('class');
138
+ var nextSiblingLast = currencyISO_[1].nextElementSibling;
139
+ nextSiblingLast.setAttribute('class', getAttrNextSiblingOne);
140
+ currencyISO_[1].innerHTML = currencyISO_[0].innerHTML;
141
+ }
142
+ } else {
143
+ var optCountry = document.getElementsByClassName('skx_position_option_country');
144
+ if (optCountry.length > 1) {
145
+ optCountry[1].innerHTML = optCountry[0].innerText;
146
+ try {
147
+ document.getElementById('l_checkout_view_account').style.display = 'none';
148
+ } catch (e) {
149
+
150
+ }
151
+ }
152
+ }
153
+ }, 500);
154
+ </script>
155
+ <?php
156
+ // }
157
+ // /? />
158
+
159
+ $size = 0; // Calculate height
160
+
161
+ if ($allowHelper->getLocationAllow()) {
162
+
163
+ $UserTemporal = "1";
164
+ $cartItemCount = 0;
165
+
166
+ $cart = $_config->getSession()->getCartSkybox();
167
+ if (!empty($cart)) :
168
+ $UserTemporal = $cart->{'UserTemporal'};
169
+ $CartItemCount = intval($cart->{'CartItemCount'});
170
+ for ($i = 0; $i <= $CartItemCount; $i++) :
171
+ $size = $size + 60;
172
+ endfor;
173
+ endif;
174
+
175
+ $merchant = $_helper->getMerchantCode();
176
+ $storeId = $_helper->getStoreId();
177
+ $cartId = $_helper->getCartId();
178
+ $guid = $_checkout->getGuidApi();
179
+ $urlSuccess = Mage::getUrl("skbcheckout/international/success");
180
+ $urlConfirm = Mage::getUrl("skbcheckout/international");
181
+ $token = $_checkout->getAuthorizedToken();
182
+
183
+ // Build Iframe
184
+ $url = $_helper->getSkyboxUrlMain() . "WebForms/Checkout/APICheckout.aspx"; //$_config->skyboxDefaultUrl . "WebForms/Checkout/APICheckout.aspx";
185
+ $url .= "?token=" . $token;
186
+ $url .= "&GuiId=" . $guid;
187
+ $url .= "&merchant=" . $merchant;
188
+ $url .= "&idCart=" . $cartId;
189
+ $url .= "&idStore=" . $storeId;
190
+ $url .= "&UrlC=" . $urlConfirm;// "http://magento.skynet.com/magento192/skbcheckout/international";
191
+ $url .= "&paypal=" . $_GET["paypal"];
192
+ $url .= '&checkout=' . strip_tags(Mage::app()->getRequest()->getParam('checkout', ''));
193
+ $url .= "&UrlR=" . $urlSuccess;
194
+
195
+ $height = (($UserTemporal == "1") ? 2000 : 1500) + $size;
196
+ // $height = 2500;
197
+ }
198
+ }
199
+ ?>
200
+
201
+ <div class="div_iframe_skybox_checkout">
202
+ <iframe id="iframe_skybox_checkout" src="<?php echo $url; ?>" frameborder="0" scrolling="no"></iframe>
203
+ </div>
204
+
205
+ <script type="text/javascript">
206
+ jQuery(document).ready(function () {
207
+ var height = <?php echo $height; ?>;
208
+ var size = <?php echo $size; ?>;
209
+ var isMobile = /Mobi/.test(navigator.userAgent);
210
+ console.log("isMobile ::: " + isMobile);
211
+ console.log("size ::: " + size);
212
+ console.log("height ::: " + height);
213
+ if (isMobile) {
214
+ height = jQuery(window).height();
215
+ height = (height * 5) - (size/2);
216
+ }
217
+ var height = height + "px";
218
+ console.log("height (mobile) ::: " + height);
219
+ jQuery('#iframe_skybox_checkout').attr('height', height);
220
+ jQuery('#iframe_skybox_checkout').css('height', height);
221
+ });
222
+ </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/skybox/checkout/skyboxsuccess.phtml CHANGED
@@ -1,29 +1,59 @@
1
- <div>
2
- <?php
3
- $message = Mage::getSingleton('core/session')->getSkyboxSuccessMsg();
4
- if (isset($message)) {
5
- echo $message;
6
- }
7
- echo "<br/><br/>";
8
- /*echo $_POST["STATUS"] . "<br/>";
9
- echo $_POST["STATUS_DESCRIPTION"] . "<br/>";
10
- echo $_POST["ORDER_NUMBER"] . "<br/>";
11
- echo $_POST["CUSTOMER_EMAIL"] . "<br/>";
12
- echo $_POST["CUSTOMER_NAME"] . "<br/>";
13
- echo $_POST["CUSTOMER_ID"] . "<br/>";
14
- echo $_POST["CUSTOMER_ADDRESS"] . "<br/>";
15
- echo $_POST["CUSTOMER_COUNTRY"] . "<br/>";
16
- echo $_POST["CUSTOMER_REGION"] . "<br/>";
17
- echo $_POST["CUSTOMER_CITY"] . "<br/>";
18
- echo $_POST["CUSTOMER_ZIPCODE"] . "<br/>";
19
- echo $_POST["ORDER_CURRENCY"] . "<br/>";
20
- echo $_POST["ORDER_AMOUNT"] . "<br/>";
21
- echo $_POST["ORDER_PAYMENT_METHOD"] . "<br/>";
22
- echo $_POST["ORDER_CONCEPTS"] . "<br/><br/>";*/
23
-
24
- echo $_POST["INVOICE_HTML"] . "<br/>";
25
- /*if (isset($_POST['ORDER_CONCEPTS'])
26
- foreach ($_POST['ORDER_CONCEPTS'] as $value)
27
- echo $value . "<br/>";*/
28
- ?>
29
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @param $string
5
+ *
6
+ * @return bool
7
+ * @see https://stackoverflow.com/a/30231906
8
+ */
9
+ function isValidBase64($string)
10
+ {
11
+ $decoded = base64_decode($string, true);
12
+
13
+ // Check if there is no invalid character in string
14
+ if ( ! preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $string)) {
15
+ return false;
16
+ }
17
+
18
+ // Decode the string in strict mode and send the response
19
+ if ( ! base64_decode($string, true)) {
20
+ return false;
21
+ }
22
+
23
+ // Encode and compare it to original one
24
+ if (base64_encode($decoded) != $string) {
25
+ return false;
26
+ }
27
+
28
+ return true;
29
+ }
30
+
31
+ $message = Mage::getSingleton('core/session')->getSkyboxSuccessMsg();
32
+
33
+ $invoice_html = '';
34
+ if (isset($_POST['INVOICE_HTML'])) {
35
+ $invoice_html = $_POST['INVOICE_HTML'];
36
+ if (isValidBase64($invoice_html)) {
37
+ $invoice_html = base64_decode($invoice_html);
38
+ }
39
+ }
40
+
41
+ $script_cart = '';
42
+ if (isset($_POST['TAG_CART_ORDERED'])) {
43
+ $script_cart = $_POST['TAG_CART_ORDERED'];
44
+ if (isValidBase64($script_cart)) {
45
+ $script_cart = base64_decode($script_cart);
46
+ }
47
+ }
48
+
49
+ ?>
50
+
51
+ <div>
52
+ <?php
53
+ if (isset($message)) {
54
+ echo $message;
55
+ } ?>
56
+ <br/><br/>
57
+ <?php echo $invoice_html; ?>
58
+ <?php echo $script_cart; ?>
59
+ </div>
app/etc/modules/Skybox_All.xml CHANGED
@@ -1,37 +1,37 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Skybox_Core>
5
- <active>true</active>
6
- <codePool>community</codePool>
7
- </Skybox_Core>
8
- <Skybox_International>
9
- <active>true</active>
10
- <codePool>community</codePool>
11
- </Skybox_International>
12
- <Skybox_Services>
13
- <active>true</active>
14
- <codePool>community</codePool>
15
- </Skybox_Services>
16
- <Skybox_Checkout>
17
- <active>true</active>
18
- <codePool>community</codePool>
19
- <depends>
20
- <Mage_Core/>
21
- <Mage_Checkout/>
22
- <Mage_Sales />
23
- <Mage_Shipping />
24
- <!--Skybox_Core /-->
25
- </depends>
26
- </Skybox_Checkout>
27
- <Skybox_Catalog>
28
- <active>true</active>
29
- <codePool>community</codePool>
30
- <depends>
31
- <Mage_Core/>
32
- <Mage_Catalog/>
33
- <!--Skybox_Core /-->
34
- </depends>
35
- </Skybox_Catalog>
36
- </modules>
37
- </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Skybox_Core>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Skybox_Core>
8
+ <Skybox_International>
9
+ <active>true</active>
10
+ <codePool>community</codePool>
11
+ </Skybox_International>
12
+ <Skybox_Services>
13
+ <active>true</active>
14
+ <codePool>community</codePool>
15
+ </Skybox_Services>
16
+ <Skybox_Checkout>
17
+ <active>true</active>
18
+ <codePool>community</codePool>
19
+ <depends>
20
+ <Mage_Core/>
21
+ <Mage_Checkout/>
22
+ <Mage_Sales />
23
+ <Mage_Shipping />
24
+ <!--Skybox_Core /-->
25
+ </depends>
26
+ </Skybox_Checkout>
27
+ <Skybox_Catalog>
28
+ <active>true</active>
29
+ <codePool>community</codePool>
30
+ <depends>
31
+ <Mage_Core/>
32
+ <Mage_Catalog/>
33
+ <!--Skybox_Core /-->
34
+ </depends>
35
+ </Skybox_Catalog>
36
+ </modules>
37
+ </config>
js/skybox/adminhtml.category.js CHANGED
@@ -1,11 +1,11 @@
1
- // Adminhtml Category
2
-
3
- function categorySubmit2(url, useAjax) {
4
- document.getElementById('apply_button').value = 'all_products';
5
- categorySubmit(url, useAjax);
6
- }
7
-
8
- function categorySubmit3(url, useAjax) {
9
- document.getElementById('apply_button').value = 'all_products_without_commoditites';
10
- categorySubmit(url, useAjax);
11
  }
1
+ // Adminhtml Category
2
+
3
+ function categorySubmit2(url, useAjax) {
4
+ document.getElementById('apply_button').value = 'all_products';
5
+ categorySubmit(url, useAjax);
6
+ }
7
+
8
+ function categorySubmit3(url, useAjax) {
9
+ document.getElementById('apply_button').value = 'all_products_without_commoditites';
10
+ categorySubmit(url, useAjax);
11
  }
js/skybox/jquery.ba-resize.min.js CHANGED
@@ -1,9 +1,9 @@
1
- /*
2
- * jQuery resize event - v1.1 - 3/14/2010
3
- * http://benalman.com/projects/jquery-resize-plugin/
4
- *
5
- * Copyright (c) 2010 "Cowboy" Ben Alman
6
- * Dual licensed under the MIT and GPL licenses.
7
- * http://benalman.com/about/license/
8
- */
9
  (function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this);
1
+ /*
2
+ * jQuery resize event - v1.1 - 3/14/2010
3
+ * http://benalman.com/projects/jquery-resize-plugin/
4
+ *
5
+ * Copyright (c) 2010 "Cowboy" Ben Alman
6
+ * Dual licensed under the MIT and GPL licenses.
7
+ * http://benalman.com/about/license/
8
+ */
9
  (function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this);
js/skybox/jquery.fancybox.js CHANGED
@@ -1,2020 +1,2020 @@
1
- /*!
2
- * fancyBox - jQuery Plugin
3
- * version: 2.1.5 (Fri, 14 Jun 2013)
4
- * @requires jQuery v1.6 or later
5
- *
6
- * Examples at http://fancyapps.com/fancybox/
7
- * License: www.fancyapps.com/fancybox/#license
8
- *
9
- * Copyright 2012 Janis Skarnelis - janis@fancyapps.com
10
- *
11
- */
12
-
13
- (function (window, document, $, undefined) {
14
- "use strict";
15
-
16
- var H = $("html"),
17
- W = $(window),
18
- D = $(document),
19
- F = $.fancybox = function () {
20
- F.open.apply( this, arguments );
21
- },
22
- IE = navigator.userAgent.match(/msie/i),
23
- didUpdate = null,
24
- isTouch = document.createTouch !== undefined,
25
-
26
- isQuery = function(obj) {
27
- return obj && obj.hasOwnProperty && obj instanceof $;
28
- },
29
- isString = function(str) {
30
- return str && $.type(str) === "string";
31
- },
32
- isPercentage = function(str) {
33
- return isString(str) && str.indexOf('%') > 0;
34
- },
35
- isScrollable = function(el) {
36
- return (el && !(el.style.overflow && el.style.overflow === 'hidden') && ((el.clientWidth && el.scrollWidth > el.clientWidth) || (el.clientHeight && el.scrollHeight > el.clientHeight)));
37
- },
38
- getScalar = function(orig, dim) {
39
- var value = parseInt(orig, 10) || 0;
40
-
41
- if (dim && isPercentage(orig)) {
42
- value = F.getViewport()[ dim ] / 100 * value;
43
- }
44
-
45
- return Math.ceil(value);
46
- },
47
- getValue = function(value, dim) {
48
- return getScalar(value, dim) + 'px';
49
- };
50
-
51
- $.extend(F, {
52
- // The current version of fancyBox
53
- version: '2.1.5',
54
-
55
- defaults: {
56
- padding : 15,
57
- margin : 20,
58
-
59
- width : 800,
60
- height : 600,
61
- minWidth : 100,
62
- minHeight : 100,
63
- maxWidth : 9999,
64
- maxHeight : 9999,
65
- pixelRatio: 1, // Set to 2 for retina display support
66
-
67
- autoSize : true,
68
- autoHeight : false,
69
- autoWidth : false,
70
-
71
- autoResize : true,
72
- autoCenter : !isTouch,
73
- fitToView : true,
74
- aspectRatio : false,
75
- topRatio : 0.5,
76
- leftRatio : 0.5,
77
-
78
- scrolling : 'auto', // 'auto', 'yes' or 'no'
79
- wrapCSS : '',
80
-
81
- arrows : true,
82
- closeBtn : true,
83
- closeClick : false,
84
- nextClick : false,
85
- mouseWheel : true,
86
- autoPlay : false,
87
- playSpeed : 3000,
88
- preload : 3,
89
- modal : false,
90
- loop : true,
91
-
92
- ajax : {
93
- dataType : 'html',
94
- headers : { 'X-fancyBox': true }
95
- },
96
- iframe : {
97
- scrolling : 'auto',
98
- preload : true
99
- },
100
- swf : {
101
- wmode: 'transparent',
102
- allowfullscreen : 'true',
103
- allowscriptaccess : 'always'
104
- },
105
-
106
- keys : {
107
- next : {
108
- 13 : 'left', // enter
109
- 34 : 'up', // page down
110
- 39 : 'left', // right arrow
111
- 40 : 'up' // down arrow
112
- },
113
- prev : {
114
- 8 : 'right', // backspace
115
- 33 : 'down', // page up
116
- 37 : 'right', // left arrow
117
- 38 : 'down' // up arrow
118
- },
119
- close : [27], // escape key
120
- play : [32], // space - start/stop slideshow
121
- toggle : [70] // letter "f" - toggle fullscreen
122
- },
123
-
124
- direction : {
125
- next : 'left',
126
- prev : 'right'
127
- },
128
-
129
- scrollOutside : true,
130
-
131
- // Override some properties
132
- index : 0,
133
- type : null,
134
- href : null,
135
- content : null,
136
- title : null,
137
-
138
- // HTML templates
139
- tpl: {
140
- wrap : '<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>',
141
- image : '<img class="fancybox-image" src="{href}" alt="" />',
142
- iframe : '<iframe id="fancybox-frame{rnd}" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen' + (IE ? ' allowtransparency="true"' : '') + '></iframe>',
143
- error : '<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',
144
- closeBtn : '<a title="Close" class="fancybox-item fancybox-close" href="javascript:;"></a>',
145
- next : '<a title="Next" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',
146
- prev : '<a title="Previous" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'
147
- },
148
-
149
- // Properties for each animation type
150
- // Opening fancyBox
151
- openEffect : 'fade', // 'elastic', 'fade' or 'none'
152
- openSpeed : 250,
153
- openEasing : 'swing',
154
- openOpacity : true,
155
- openMethod : 'zoomIn',
156
-
157
- // Closing fancyBox
158
- closeEffect : 'fade', // 'elastic', 'fade' or 'none'
159
- closeSpeed : 250,
160
- closeEasing : 'swing',
161
- closeOpacity : true,
162
- closeMethod : 'zoomOut',
163
-
164
- // Changing next gallery item
165
- nextEffect : 'elastic', // 'elastic', 'fade' or 'none'
166
- nextSpeed : 250,
167
- nextEasing : 'swing',
168
- nextMethod : 'changeIn',
169
-
170
- // Changing previous gallery item
171
- prevEffect : 'elastic', // 'elastic', 'fade' or 'none'
172
- prevSpeed : 250,
173
- prevEasing : 'swing',
174
- prevMethod : 'changeOut',
175
-
176
- // Enable default helpers
177
- helpers : {
178
- overlay : true,
179
- title : true
180
- },
181
-
182
- // Callbacks
183
- onCancel : $.noop, // If canceling
184
- beforeLoad : $.noop, // Before loading
185
- afterLoad : $.noop, // After loading
186
- beforeShow : $.noop, // Before changing in current item
187
- afterShow : $.noop, // After opening
188
- beforeChange : $.noop, // Before changing gallery item
189
- beforeClose : $.noop, // Before closing
190
- afterClose : $.noop // After closing
191
- },
192
-
193
- //Current state
194
- group : {}, // Selected group
195
- opts : {}, // Group options
196
- previous : null, // Previous element
197
- coming : null, // Element being loaded
198
- current : null, // Currently loaded element
199
- isActive : false, // Is activated
200
- isOpen : false, // Is currently open
201
- isOpened : false, // Have been fully opened at least once
202
-
203
- wrap : null,
204
- skin : null,
205
- outer : null,
206
- inner : null,
207
-
208
- player : {
209
- timer : null,
210
- isActive : false
211
- },
212
-
213
- // Loaders
214
- ajaxLoad : null,
215
- imgPreload : null,
216
-
217
- // Some collections
218
- transitions : {},
219
- helpers : {},
220
-
221
- /*
222
- * Static methods
223
- */
224
-
225
- open: function (group, opts) {
226
- if (!group) {
227
- return;
228
- }
229
-
230
- if (!$.isPlainObject(opts)) {
231
- opts = {};
232
- }
233
-
234
- // Close if already active
235
- if (false === F.close(true)) {
236
- return;
237
- }
238
-
239
- // Normalize group
240
- if (!$.isArray(group)) {
241
- group = isQuery(group) ? $(group).get() : [group];
242
- }
243
-
244
- // Recheck if the type of each element is `object` and set content type (image, ajax, etc)
245
- $.each(group, function(i, element) {
246
- var obj = {},
247
- href,
248
- title,
249
- content,
250
- type,
251
- rez,
252
- hrefParts,
253
- selector;
254
-
255
- if ($.type(element) === "object") {
256
- // Check if is DOM element
257
- if (element.nodeType) {
258
- element = $(element);
259
- }
260
-
261
- if (isQuery(element)) {
262
- obj = {
263
- href : element.data('fancybox-href') || element.attr('href'),
264
- title : element.data('fancybox-title') || element.attr('title'),
265
- isDom : true,
266
- element : element
267
- };
268
-
269
- if ($.metadata) {
270
- $.extend(true, obj, element.metadata());
271
- }
272
-
273
- } else {
274
- obj = element;
275
- }
276
- }
277
-
278
- href = opts.href || obj.href || (isString(element) ? element : null);
279
- title = opts.title !== undefined ? opts.title : obj.title || '';
280
-
281
- content = opts.content || obj.content;
282
- type = content ? 'html' : (opts.type || obj.type);
283
-
284
- if (!type && obj.isDom) {
285
- type = element.data('fancybox-type');
286
-
287
- if (!type) {
288
- rez = element.prop('class').match(/fancybox\.(\w+)/);
289
- type = rez ? rez[1] : null;
290
- }
291
- }
292
-
293
- if (isString(href)) {
294
- // Try to guess the content type
295
- if (!type) {
296
- if (F.isImage(href)) {
297
- type = 'image';
298
-
299
- } else if (F.isSWF(href)) {
300
- type = 'swf';
301
-
302
- } else if (href.charAt(0) === '#') {
303
- type = 'inline';
304
-
305
- } else if (isString(element)) {
306
- type = 'html';
307
- content = element;
308
- }
309
- }
310
-
311
- // Split url into two pieces with source url and content selector, e.g,
312
- // "/mypage.html #my_id" will load "/mypage.html" and display element having id "my_id"
313
- if (type === 'ajax') {
314
- hrefParts = href.split(/\s+/, 2);
315
- href = hrefParts.shift();
316
- selector = hrefParts.shift();
317
- }
318
- }
319
-
320
- if (!content) {
321
- if (type === 'inline') {
322
- if (href) {
323
- content = $( isString(href) ? href.replace(/.*(?=#[^\s]+$)/, '') : href ); //strip for ie7
324
-
325
- } else if (obj.isDom) {
326
- content = element;
327
- }
328
-
329
- } else if (type === 'html') {
330
- content = href;
331
-
332
- } else if (!type && !href && obj.isDom) {
333
- type = 'inline';
334
- content = element;
335
- }
336
- }
337
-
338
- $.extend(obj, {
339
- href : href,
340
- type : type,
341
- content : content,
342
- title : title,
343
- selector : selector
344
- });
345
-
346
- group[ i ] = obj;
347
- });
348
-
349
- // Extend the defaults
350
- F.opts = $.extend(true, {}, F.defaults, opts);
351
-
352
- // All options are merged recursive except keys
353
- if (opts.keys !== undefined) {
354
- F.opts.keys = opts.keys ? $.extend({}, F.defaults.keys, opts.keys) : false;
355
- }
356
-
357
- F.group = group;
358
-
359
- return F._start(F.opts.index);
360
- },
361
-
362
- // Cancel image loading or abort ajax request
363
- cancel: function () {
364
- var coming = F.coming;
365
-
366
- if (!coming || false === F.trigger('onCancel')) {
367
- return;
368
- }
369
-
370
- F.hideLoading();
371
-
372
- if (F.ajaxLoad) {
373
- F.ajaxLoad.abort();
374
- }
375
-
376
- F.ajaxLoad = null;
377
-
378
- if (F.imgPreload) {
379
- F.imgPreload.onload = F.imgPreload.onerror = null;
380
- }
381
-
382
- if (coming.wrap) {
383
- coming.wrap.stop(true, true).trigger('onReset').remove();
384
- }
385
-
386
- F.coming = null;
387
-
388
- // If the first item has been canceled, then clear everything
389
- if (!F.current) {
390
- F._afterZoomOut( coming );
391
- }
392
- },
393
-
394
- // Start closing animation if is open; remove immediately if opening/closing
395
- close: function (event) {
396
- F.cancel();
397
-
398
- if (false === F.trigger('beforeClose')) {
399
- return;
400
- }
401
-
402
- F.unbindEvents();
403
-
404
- if (!F.isActive) {
405
- return;
406
- }
407
-
408
- if (!F.isOpen || event === true) {
409
- $('.fancybox-wrap').stop(true).trigger('onReset').remove();
410
-
411
- F._afterZoomOut();
412
-
413
- } else {
414
- F.isOpen = F.isOpened = false;
415
- F.isClosing = true;
416
-
417
- $('.fancybox-item, .fancybox-nav').remove();
418
-
419
- F.wrap.stop(true, true).removeClass('fancybox-opened');
420
-
421
- F.transitions[ F.current.closeMethod ]();
422
- }
423
- },
424
-
425
- // Manage slideshow:
426
- // $.fancybox.play(); - toggle slideshow
427
- // $.fancybox.play( true ); - start
428
- // $.fancybox.play( false ); - stop
429
- play: function ( action ) {
430
- var clear = function () {
431
- clearTimeout(F.player.timer);
432
- },
433
- set = function () {
434
- clear();
435
-
436
- if (F.current && F.player.isActive) {
437
- F.player.timer = setTimeout(F.next, F.current.playSpeed);
438
- }
439
- },
440
- stop = function () {
441
- clear();
442
-
443
- D.unbind('.player');
444
-
445
- F.player.isActive = false;
446
-
447
- F.trigger('onPlayEnd');
448
- },
449
- start = function () {
450
- if (F.current && (F.current.loop || F.current.index < F.group.length - 1)) {
451
- F.player.isActive = true;
452
-
453
- D.bind({
454
- 'onCancel.player beforeClose.player' : stop,
455
- 'onUpdate.player' : set,
456
- 'beforeLoad.player' : clear
457
- });
458
-
459
- set();
460
-
461
- F.trigger('onPlayStart');
462
- }
463
- };
464
-
465
- if (action === true || (!F.player.isActive && action !== false)) {
466
- start();
467
- } else {
468
- stop();
469
- }
470
- },
471
-
472
- // Navigate to next gallery item
473
- next: function ( direction ) {
474
- var current = F.current;
475
-
476
- if (current) {
477
- if (!isString(direction)) {
478
- direction = current.direction.next;
479
- }
480
-
481
- F.jumpto(current.index + 1, direction, 'next');
482
- }
483
- },
484
-
485
- // Navigate to previous gallery item
486
- prev: function ( direction ) {
487
- var current = F.current;
488
-
489
- if (current) {
490
- if (!isString(direction)) {
491
- direction = current.direction.prev;
492
- }
493
-
494
- F.jumpto(current.index - 1, direction, 'prev');
495
- }
496
- },
497
-
498
- // Navigate to gallery item by index
499
- jumpto: function ( index, direction, router ) {
500
- var current = F.current;
501
-
502
- if (!current) {
503
- return;
504
- }
505
-
506
- index = getScalar(index);
507
-
508
- F.direction = direction || current.direction[ (index >= current.index ? 'next' : 'prev') ];
509
- F.router = router || 'jumpto';
510
-
511
- if (current.loop) {
512
- if (index < 0) {
513
- index = current.group.length + (index % current.group.length);
514
- }
515
-
516
- index = index % current.group.length;
517
- }
518
-
519
- if (current.group[ index ] !== undefined) {
520
- F.cancel();
521
-
522
- F._start(index);
523
- }
524
- },
525
-
526
- // Center inside viewport and toggle position type to fixed or absolute if needed
527
- reposition: function (e, onlyAbsolute) {
528
- var current = F.current,
529
- wrap = current ? current.wrap : null,
530
- pos;
531
-
532
- if (wrap) {
533
- pos = F._getPosition(onlyAbsolute);
534
-
535
- if (e && e.type === 'scroll') {
536
- delete pos.position;
537
-
538
- wrap.stop(true, true).animate(pos, 200);
539
-
540
- } else {
541
- wrap.css(pos);
542
-
543
- current.pos = $.extend({}, current.dim, pos);
544
- }
545
- }
546
- },
547
-
548
- update: function (e) {
549
- var type = (e && e.type),
550
- anyway = !type || type === 'orientationchange';
551
-
552
- if (anyway) {
553
- clearTimeout(didUpdate);
554
-
555
- didUpdate = null;
556
- }
557
-
558
- if (!F.isOpen || didUpdate) {
559
- return;
560
- }
561
-
562
- didUpdate = setTimeout(function() {
563
- var current = F.current;
564
-
565
- if (!current || F.isClosing) {
566
- return;
567
- }
568
-
569
- F.wrap.removeClass('fancybox-tmp');
570
-
571
- if (anyway || type === 'load' || (type === 'resize' && current.autoResize)) {
572
- F._setDimension();
573
- }
574
-
575
- if (!(type === 'scroll' && current.canShrink)) {
576
- F.reposition(e);
577
- }
578
-
579
- F.trigger('onUpdate');
580
-
581
- didUpdate = null;
582
-
583
- }, (anyway && !isTouch ? 0 : 300));
584
- },
585
-
586
- // Shrink content to fit inside viewport or restore if resized
587
- toggle: function ( action ) {
588
- if (F.isOpen) {
589
- F.current.fitToView = $.type(action) === "boolean" ? action : !F.current.fitToView;
590
-
591
- // Help browser to restore document dimensions
592
- if (isTouch) {
593
- F.wrap.removeAttr('style').addClass('fancybox-tmp');
594
-
595
- F.trigger('onUpdate');
596
- }
597
-
598
- F.update();
599
- }
600
- },
601
-
602
- hideLoading: function () {
603
- D.unbind('.loading');
604
-
605
- $('#fancybox-loading').remove();
606
- },
607
-
608
- showLoading: function () {
609
- var el, viewport;
610
-
611
- F.hideLoading();
612
-
613
- el = $('<div id="fancybox-loading"><div></div></div>').click(F.cancel).appendTo('body');
614
-
615
- // If user will press the escape-button, the request will be canceled
616
- D.bind('keydown.loading', function(e) {
617
- if ((e.which || e.keyCode) === 27) {
618
- e.preventDefault();
619
-
620
- F.cancel();
621
- }
622
- });
623
-
624
- if (!F.defaults.fixed) {
625
- viewport = F.getViewport();
626
-
627
- el.css({
628
- position : 'absolute',
629
- top : (viewport.h * 0.5) + viewport.y,
630
- left : (viewport.w * 0.5) + viewport.x
631
- });
632
- }
633
- },
634
-
635
- getViewport: function () {
636
- var locked = (F.current && F.current.locked) || false,
637
- rez = {
638
- x: W.scrollLeft(),
639
- y: W.scrollTop()
640
- };
641
-
642
- if (locked) {
643
- rez.w = locked[0].clientWidth;
644
- rez.h = locked[0].clientHeight;
645
-
646
- } else {
647
- // See http://bugs.jquery.com/ticket/6724
648
- rez.w = isTouch && window.innerWidth ? window.innerWidth : W.width();
649
- rez.h = isTouch && window.innerHeight ? window.innerHeight : W.height();
650
- }
651
-
652
- return rez;
653
- },
654
-
655
- // Unbind the keyboard / clicking actions
656
- unbindEvents: function () {
657
- if (F.wrap && isQuery(F.wrap)) {
658
- F.wrap.unbind('.fb');
659
- }
660
-
661
- D.unbind('.fb');
662
- W.unbind('.fb');
663
- },
664
-
665
- bindEvents: function () {
666
- var current = F.current,
667
- keys;
668
-
669
- if (!current) {
670
- return;
671
- }
672
-
673
- // Changing document height on iOS devices triggers a 'resize' event,
674
- // that can change document height... repeating infinitely
675
- W.bind('orientationchange.fb' + (isTouch ? '' : ' resize.fb') + (current.autoCenter && !current.locked ? ' scroll.fb' : ''), F.update);
676
-
677
- keys = current.keys;
678
-
679
- if (keys) {
680
- D.bind('keydown.fb', function (e) {
681
- var code = e.which || e.keyCode,
682
- target = e.target || e.srcElement;
683
-
684
- // Skip esc key if loading, because showLoading will cancel preloading
685
- if (code === 27 && F.coming) {
686
- return false;
687
- }
688
-
689
- // Ignore key combinations and key events within form elements
690
- if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey && !(target && (target.type || $(target).is('[contenteditable]')))) {
691
- $.each(keys, function(i, val) {
692
- if (current.group.length > 1 && val[ code ] !== undefined) {
693
- F[ i ]( val[ code ] );
694
-
695
- e.preventDefault();
696
- return false;
697
- }
698
-
699
- if ($.inArray(code, val) > -1) {
700
- F[ i ] ();
701
-
702
- e.preventDefault();
703
- return false;
704
- }
705
- });
706
- }
707
- });
708
- }
709
-
710
- if ($.fn.mousewheel && current.mouseWheel) {
711
- F.wrap.bind('mousewheel.fb', function (e, delta, deltaX, deltaY) {
712
- var target = e.target || null,
713
- parent = $(target),
714
- canScroll = false;
715
-
716
- while (parent.length) {
717
- if (canScroll || parent.is('.fancybox-skin') || parent.is('.fancybox-wrap')) {
718
- break;
719
- }
720
-
721
- canScroll = isScrollable( parent[0] );
722
- parent = $(parent).parent();
723
- }
724
-
725
- if (delta !== 0 && !canScroll) {
726
- if (F.group.length > 1 && !current.canShrink) {
727
- if (deltaY > 0 || deltaX > 0) {
728
- F.prev( deltaY > 0 ? 'down' : 'left' );
729
-
730
- } else if (deltaY < 0 || deltaX < 0) {
731
- F.next( deltaY < 0 ? 'up' : 'right' );
732
- }
733
-
734
- e.preventDefault();
735
- }
736
- }
737
- });
738
- }
739
- },
740
-
741
- trigger: function (event, o) {
742
- var ret, obj = o || F.coming || F.current;
743
-
744
- if (!obj) {
745
- return;
746
- }
747
-
748
- if ($.isFunction( obj[event] )) {
749
- ret = obj[event].apply(obj, Array.prototype.slice.call(arguments, 1));
750
- }
751
-
752
- if (ret === false) {
753
- return false;
754
- }
755
-
756
- if (obj.helpers) {
757
- $.each(obj.helpers, function (helper, opts) {
758
- if (opts && F.helpers[helper] && $.isFunction(F.helpers[helper][event])) {
759
- F.helpers[helper][event]($.extend(true, {}, F.helpers[helper].defaults, opts), obj);
760
- }
761
- });
762
- }
763
-
764
- D.trigger(event);
765
- },
766
-
767
- isImage: function (str) {
768
- return isString(str) && str.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i);
769
- },
770
-
771
- isSWF: function (str) {
772
- return isString(str) && str.match(/\.(swf)((\?|#).*)?$/i);
773
- },
774
-
775
- _start: function (index) {
776
- var coming = {},
777
- obj,
778
- href,
779
- type,
780
- margin,
781
- padding;
782
-
783
- index = getScalar( index );
784
- obj = F.group[ index ] || null;
785
-
786
- if (!obj) {
787
- return false;
788
- }
789
-
790
- coming = $.extend(true, {}, F.opts, obj);
791
-
792
- // Convert margin and padding properties to array - top, right, bottom, left
793
- margin = coming.margin;
794
- padding = coming.padding;
795
-
796
- if ($.type(margin) === 'number') {
797
- coming.margin = [margin, margin, margin, margin];
798
- }
799
-
800
- if ($.type(padding) === 'number') {
801
- coming.padding = [padding, padding, padding, padding];
802
- }
803
-
804
- // 'modal' propery is just a shortcut
805
- if (coming.modal) {
806
- $.extend(true, coming, {
807
- closeBtn : false,
808
- closeClick : false,
809
- nextClick : false,
810
- arrows : false,
811
- mouseWheel : false,
812
- keys : null,
813
- helpers: {
814
- overlay : {
815
- closeClick : false
816
- }
817
- }
818
- });
819
- }
820
-
821
- // 'autoSize' property is a shortcut, too
822
- if (coming.autoSize) {
823
- coming.autoWidth = coming.autoHeight = true;
824
- }
825
-
826
- if (coming.width === 'auto') {
827
- coming.autoWidth = true;
828
- }
829
-
830
- if (coming.height === 'auto') {
831
- coming.autoHeight = true;
832
- }
833
-
834
- /*
835
- * Add reference to the group, so it`s possible to access from callbacks, example:
836
- * afterLoad : function() {
837
- * this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');
838
- * }
839
- */
840
-
841
- coming.group = F.group;
842
- coming.index = index;
843
-
844
- // Give a chance for callback or helpers to update coming item (type, title, etc)
845
- F.coming = coming;
846
-
847
- if (false === F.trigger('beforeLoad')) {
848
- F.coming = null;
849
-
850
- return;
851
- }
852
-
853
- type = coming.type;
854
- href = coming.href;
855
-
856
- if (!type) {
857
- F.coming = null;
858
-
859
- //If we can not determine content type then drop silently or display next/prev item if looping through gallery
860
- if (F.current && F.router && F.router !== 'jumpto') {
861
- F.current.index = index;
862
-
863
- return F[ F.router ]( F.direction );
864
- }
865
-
866
- return false;
867
- }
868
-
869
- F.isActive = true;
870
-
871
- if (type === 'image' || type === 'swf') {
872
- coming.autoHeight = coming.autoWidth = false;
873
- coming.scrolling = 'visible';
874
- }
875
-
876
- if (type === 'image') {
877
- coming.aspectRatio = true;
878
- }
879
-
880
- if (type === 'iframe' && isTouch) {
881
- coming.scrolling = 'scroll';
882
- }
883
-
884
- // Build the neccessary markup
885
- coming.wrap = $(coming.tpl.wrap).addClass('fancybox-' + (isTouch ? 'mobile' : 'desktop') + ' fancybox-type-' + type + ' fancybox-tmp ' + coming.wrapCSS).appendTo( coming.parent || 'body' );
886
-
887
- $.extend(coming, {
888
- skin : $('.fancybox-skin', coming.wrap),
889
- outer : $('.fancybox-outer', coming.wrap),
890
- inner : $('.fancybox-inner', coming.wrap)
891
- });
892
-
893
- $.each(["Top", "Right", "Bottom", "Left"], function(i, v) {
894
- coming.skin.css('padding' + v, getValue(coming.padding[ i ]));
895
- });
896
-
897
- F.trigger('onReady');
898
-
899
- // Check before try to load; 'inline' and 'html' types need content, others - href
900
- if (type === 'inline' || type === 'html') {
901
- if (!coming.content || !coming.content.length) {
902
- return F._error( 'content' );
903
- }
904
-
905
- } else if (!href) {
906
- return F._error( 'href' );
907
- }
908
-
909
- if (type === 'image') {
910
- F._loadImage();
911
-
912
- } else if (type === 'ajax') {
913
- F._loadAjax();
914
-
915
- } else if (type === 'iframe') {
916
- F._loadIframe();
917
-
918
- } else {
919
- F._afterLoad();
920
- }
921
- },
922
-
923
- _error: function ( type ) {
924
- $.extend(F.coming, {
925
- type : 'html',
926
- autoWidth : true,
927
- autoHeight : true,
928
- minWidth : 0,
929
- minHeight : 0,
930
- scrolling : 'no',
931
- hasError : type,
932
- content : F.coming.tpl.error
933
- });
934
-
935
- F._afterLoad();
936
- },
937
-
938
- _loadImage: function () {
939
- // Reset preload image so it is later possible to check "complete" property
940
- var img = F.imgPreload = new Image();
941
-
942
- img.onload = function () {
943
- this.onload = this.onerror = null;
944
-
945
- F.coming.width = this.width / F.opts.pixelRatio;
946
- F.coming.height = this.height / F.opts.pixelRatio;
947
-
948
- F._afterLoad();
949
- };
950
-
951
- img.onerror = function () {
952
- this.onload = this.onerror = null;
953
-
954
- F._error( 'image' );
955
- };
956
-
957
- img.src = F.coming.href;
958
-
959
- if (img.complete !== true) {
960
- F.showLoading();
961
- }
962
- },
963
-
964
- _loadAjax: function () {
965
- var coming = F.coming;
966
-
967
- F.showLoading();
968
-
969
- F.ajaxLoad = $.ajax($.extend({}, coming.ajax, {
970
- url: coming.href,
971
- error: function (jqXHR, textStatus) {
972
- if (F.coming && textStatus !== 'abort') {
973
- F._error( 'ajax', jqXHR );
974
-
975
- } else {
976
- F.hideLoading();
977
- }
978
- },
979
- success: function (data, textStatus) {
980
- if (textStatus === 'success') {
981
- coming.content = data;
982
-
983
- F._afterLoad();
984
- }
985
- }
986
- }));
987
- },
988
-
989
- _loadIframe: function() {
990
- var coming = F.coming,
991
- iframe = $(coming.tpl.iframe.replace(/\{rnd\}/g, new Date().getTime()))
992
- .attr('scrolling', isTouch ? 'auto' : coming.iframe.scrolling)
993
- .attr('src', coming.href);
994
-
995
- // This helps IE
996
- $(coming.wrap).bind('onReset', function () {
997
- try {
998
- $(this).find('iframe').hide().attr('src', '//about:blank').end().empty();
999
- } catch (e) {}
1000
- });
1001
-
1002
- if (coming.iframe.preload) {
1003
- F.showLoading();
1004
-
1005
- iframe.one('load', function() {
1006
- $(this).data('ready', 1);
1007
-
1008
- // iOS will lose scrolling if we resize
1009
- if (!isTouch) {
1010
- $(this).bind('load.fb', F.update);
1011
- }
1012
-
1013
- // Without this trick:
1014
- // - iframe won't scroll on iOS devices
1015
- // - IE7 sometimes displays empty iframe
1016
- $(this).parents('.fancybox-wrap').width('100%').removeClass('fancybox-tmp').show();
1017
-
1018
- F._afterLoad();
1019
- });
1020
- }
1021
-
1022
- coming.content = iframe.appendTo( coming.inner );
1023
-
1024
- if (!coming.iframe.preload) {
1025
- F._afterLoad();
1026
- }
1027
- },
1028
-
1029
- _preloadImages: function() {
1030
- var group = F.group,
1031
- current = F.current,
1032
- len = group.length,
1033
- cnt = current.preload ? Math.min(current.preload, len - 1) : 0,
1034
- item,
1035
- i;
1036
-
1037
- for (i = 1; i <= cnt; i += 1) {
1038
- item = group[ (current.index + i ) % len ];
1039
-
1040
- if (item.type === 'image' && item.href) {
1041
- new Image().src = item.href;
1042
- }
1043
- }
1044
- },
1045
-
1046
- _afterLoad: function () {
1047
- var coming = F.coming,
1048
- previous = F.current,
1049
- placeholder = 'fancybox-placeholder',
1050
- current,
1051
- content,
1052
- type,
1053
- scrolling,
1054
- href,
1055
- embed;
1056
-
1057
- F.hideLoading();
1058
-
1059
- if (!coming || F.isActive === false) {
1060
- return;
1061
- }
1062
-
1063
- if (false === F.trigger('afterLoad', coming, previous)) {
1064
- coming.wrap.stop(true).trigger('onReset').remove();
1065
-
1066
- F.coming = null;
1067
-
1068
- return;
1069
- }
1070
-
1071
- if (previous) {
1072
- F.trigger('beforeChange', previous);
1073
-
1074
- previous.wrap.stop(true).removeClass('fancybox-opened')
1075
- .find('.fancybox-item, .fancybox-nav')
1076
- .remove();
1077
- }
1078
-
1079
- F.unbindEvents();
1080
-
1081
- current = coming;
1082
- content = coming.content;
1083
- type = coming.type;
1084
- scrolling = coming.scrolling;
1085
-
1086
- $.extend(F, {
1087
- wrap : current.wrap,
1088
- skin : current.skin,
1089
- outer : current.outer,
1090
- inner : current.inner,
1091
- current : current,
1092
- previous : previous
1093
- });
1094
-
1095
- href = current.href;
1096
-
1097
- switch (type) {
1098
- case 'inline':
1099
- case 'ajax':
1100
- case 'html':
1101
- if (current.selector) {
1102
- content = $('<div>').html(content).find(current.selector);
1103
-
1104
- } else if (isQuery(content)) {
1105
- if (!content.data(placeholder)) {
1106
- content.data(placeholder, $('<div class="' + placeholder + '"></div>').insertAfter( content ).hide() );
1107
- }
1108
-
1109
- content = content.show().detach();
1110
-
1111
- current.wrap.bind('onReset', function () {
1112
- if ($(this).find(content).length) {
1113
- content.hide().replaceAll( content.data(placeholder) ).data(placeholder, false);
1114
- }
1115
- });
1116
- }
1117
- break;
1118
-
1119
- case 'image':
1120
- content = current.tpl.image.replace('{href}', href);
1121
- break;
1122
-
1123
- case 'swf':
1124
- content = '<object id="fancybox-swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="movie" value="' + href + '"></param>';
1125
- embed = '';
1126
-
1127
- $.each(current.swf, function(name, val) {
1128
- content += '<param name="' + name + '" value="' + val + '"></param>';
1129
- embed += ' ' + name + '="' + val + '"';
1130
- });
1131
-
1132
- content += '<embed src="' + href + '" type="application/x-shockwave-flash" width="100%" height="100%"' + embed + '></embed></object>';
1133
- break;
1134
- }
1135
-
1136
- if (!(isQuery(content) && content.parent().is(current.inner))) {
1137
- current.inner.append( content );
1138
- }
1139
-
1140
- // Give a chance for helpers or callbacks to update elements
1141
- F.trigger('beforeShow');
1142
-
1143
- // Set scrolling before calculating dimensions
1144
- current.inner.css('overflow', scrolling === 'yes' ? 'scroll' : (scrolling === 'no' ? 'hidden' : scrolling));
1145
-
1146
- // Set initial dimensions and start position
1147
- F._setDimension();
1148
-
1149
- F.reposition();
1150
-
1151
- F.isOpen = false;
1152
- F.coming = null;
1153
-
1154
- F.bindEvents();
1155
-
1156
- if (!F.isOpened) {
1157
- $('.fancybox-wrap').not( current.wrap ).stop(true).trigger('onReset').remove();
1158
-
1159
- } else if (previous.prevMethod) {
1160
- F.transitions[ previous.prevMethod ]();
1161
- }
1162
-
1163
- F.transitions[ F.isOpened ? current.nextMethod : current.openMethod ]();
1164
-
1165
- F._preloadImages();
1166
- },
1167
-
1168
- _setDimension: function () {
1169
- var viewport = F.getViewport(),
1170
- steps = 0,
1171
- canShrink = false,
1172
- canExpand = false,
1173
- wrap = F.wrap,
1174
- skin = F.skin,
1175
- inner = F.inner,
1176
- current = F.current,
1177
- width = current.width,
1178
- height = current.height,
1179
- minWidth = current.minWidth,
1180
- minHeight = current.minHeight,
1181
- maxWidth = current.maxWidth,
1182
- maxHeight = current.maxHeight,
1183
- scrolling = current.scrolling,
1184
- scrollOut = current.scrollOutside ? current.scrollbarWidth : 0,
1185
- margin = current.margin,
1186
- wMargin = getScalar(margin[1] + margin[3]),
1187
- hMargin = getScalar(margin[0] + margin[2]),
1188
- wPadding,
1189
- hPadding,
1190
- wSpace,
1191
- hSpace,
1192
- origWidth,
1193
- origHeight,
1194
- origMaxWidth,
1195
- origMaxHeight,
1196
- ratio,
1197
- width_,
1198
- height_,
1199
- maxWidth_,
1200
- maxHeight_,
1201
- iframe,
1202
- body;
1203
-
1204
- // Reset dimensions so we could re-check actual size
1205
- wrap.add(skin).add(inner).width('auto').height('auto').removeClass('fancybox-tmp');
1206
-
1207
- wPadding = getScalar(skin.outerWidth(true) - skin.width());
1208
- hPadding = getScalar(skin.outerHeight(true) - skin.height());
1209
-
1210
- // Any space between content and viewport (margin, padding, border, title)
1211
- wSpace = wMargin + wPadding;
1212
- hSpace = hMargin + hPadding;
1213
-
1214
- origWidth = isPercentage(width) ? (viewport.w - wSpace) * getScalar(width) / 100 : width;
1215
- origHeight = isPercentage(height) ? (viewport.h - hSpace) * getScalar(height) / 100 : height;
1216
-
1217
- if (current.type === 'iframe') {
1218
- iframe = current.content;
1219
-
1220
- if (current.autoHeight && iframe.data('ready') === 1) {
1221
- try {
1222
- if (iframe[0].contentWindow.document.location) {
1223
- inner.width( origWidth ).height(9999);
1224
-
1225
- body = iframe.contents().find('body');
1226
-
1227
- if (scrollOut) {
1228
- body.css('overflow-x', 'hidden');
1229
- }
1230
-
1231
- origHeight = body.outerHeight(true);
1232
- }
1233
-
1234
- } catch (e) {}
1235
- }
1236
-
1237
- } else if (current.autoWidth || current.autoHeight) {
1238
- inner.addClass( 'fancybox-tmp' );
1239
-
1240
- // Set width or height in case we need to calculate only one dimension
1241
- if (!current.autoWidth) {
1242
- inner.width( origWidth );
1243
- }
1244
-
1245
- if (!current.autoHeight) {
1246
- inner.height( origHeight );
1247
- }
1248
-
1249
- if (current.autoWidth) {
1250
- origWidth = inner.width();
1251
- }
1252
-
1253
- if (current.autoHeight) {
1254
- origHeight = inner.height();
1255
- }
1256
-
1257
- inner.removeClass( 'fancybox-tmp' );
1258
- }
1259
-
1260
- width = getScalar( origWidth );
1261
- height = getScalar( origHeight );
1262
-
1263
- ratio = origWidth / origHeight;
1264
-
1265
- // Calculations for the content
1266
- minWidth = getScalar(isPercentage(minWidth) ? getScalar(minWidth, 'w') - wSpace : minWidth);
1267
- maxWidth = getScalar(isPercentage(maxWidth) ? getScalar(maxWidth, 'w') - wSpace : maxWidth);
1268
-
1269
- minHeight = getScalar(isPercentage(minHeight) ? getScalar(minHeight, 'h') - hSpace : minHeight);
1270
- maxHeight = getScalar(isPercentage(maxHeight) ? getScalar(maxHeight, 'h') - hSpace : maxHeight);
1271
-
1272
- // These will be used to determine if wrap can fit in the viewport
1273
- origMaxWidth = maxWidth;
1274
- origMaxHeight = maxHeight;
1275
-
1276
- if (current.fitToView) {
1277
- maxWidth = Math.min(viewport.w - wSpace, maxWidth);
1278
- maxHeight = Math.min(viewport.h - hSpace, maxHeight);
1279
- }
1280
-
1281
- maxWidth_ = viewport.w - wMargin;
1282
- maxHeight_ = viewport.h - hMargin;
1283
-
1284
- if (current.aspectRatio) {
1285
- if (width > maxWidth) {
1286
- width = maxWidth;
1287
- height = getScalar(width / ratio);
1288
- }
1289
-
1290
- if (height > maxHeight) {
1291
- height = maxHeight;
1292
- width = getScalar(height * ratio);
1293
- }
1294
-
1295
- if (width < minWidth) {
1296
- width = minWidth;
1297
- height = getScalar(width / ratio);
1298
- }
1299
-
1300
- if (height < minHeight) {
1301
- height = minHeight;
1302
- width = getScalar(height * ratio);
1303
- }
1304
-
1305
- } else {
1306
- width = Math.max(minWidth, Math.min(width, maxWidth));
1307
-
1308
- if (current.autoHeight && current.type !== 'iframe') {
1309
- inner.width( width );
1310
-
1311
- height = inner.height();
1312
- }
1313
-
1314
- height = Math.max(minHeight, Math.min(height, maxHeight));
1315
- }
1316
-
1317
- // Try to fit inside viewport (including the title)
1318
- if (current.fitToView) {
1319
- inner.width( width ).height( height );
1320
-
1321
- wrap.width( width + wPadding );
1322
-
1323
- // Real wrap dimensions
1324
- width_ = wrap.width();
1325
- height_ = wrap.height();
1326
-
1327
- if (current.aspectRatio) {
1328
- while ((width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight) {
1329
- if (steps++ > 19) {
1330
- break;
1331
- }
1332
-
1333
- height = Math.max(minHeight, Math.min(maxHeight, height - 10));
1334
- width = getScalar(height * ratio);
1335
-
1336
- if (width < minWidth) {
1337
- width = minWidth;
1338
- height = getScalar(width / ratio);
1339
- }
1340
-
1341
- if (width > maxWidth) {
1342
- width = maxWidth;
1343
- height = getScalar(width / ratio);
1344
- }
1345
-
1346
- inner.width( width ).height( height );
1347
-
1348
- wrap.width( width + wPadding );
1349
-
1350
- width_ = wrap.width();
1351
- height_ = wrap.height();
1352
- }
1353
-
1354
- } else {
1355
- width = Math.max(minWidth, Math.min(width, width - (width_ - maxWidth_)));
1356
- height = Math.max(minHeight, Math.min(height, height - (height_ - maxHeight_)));
1357
- }
1358
- }
1359
-
1360
- if (scrollOut && scrolling === 'auto' && height < origHeight && (width + wPadding + scrollOut) < maxWidth_) {
1361
- width += scrollOut;
1362
- }
1363
-
1364
- inner.width( width ).height( height );
1365
-
1366
- wrap.width( width + wPadding );
1367
-
1368
- width_ = wrap.width();
1369
- height_ = wrap.height();
1370
-
1371
- canShrink = (width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight;
1372
- canExpand = current.aspectRatio ? (width < origMaxWidth && height < origMaxHeight && width < origWidth && height < origHeight) : ((width < origMaxWidth || height < origMaxHeight) && (width < origWidth || height < origHeight));
1373
-
1374
- $.extend(current, {
1375
- dim : {
1376
- width : getValue( width_ ),
1377
- height : getValue( height_ )
1378
- },
1379
- origWidth : origWidth,
1380
- origHeight : origHeight,
1381
- canShrink : canShrink,
1382
- canExpand : canExpand,
1383
- wPadding : wPadding,
1384
- hPadding : hPadding,
1385
- wrapSpace : height_ - skin.outerHeight(true),
1386
- skinSpace : skin.height() - height
1387
- });
1388
-
1389
- if (!iframe && current.autoHeight && height > minHeight && height < maxHeight && !canExpand) {
1390
- inner.height('auto');
1391
- }
1392
- },
1393
-
1394
- _getPosition: function (onlyAbsolute) {
1395
- var current = F.current,
1396
- viewport = F.getViewport(),
1397
- margin = current.margin,
1398
- width = F.wrap.width() + margin[1] + margin[3],
1399
- height = F.wrap.height() + margin[0] + margin[2],
1400
- rez = {
1401
- position: 'absolute',
1402
- top : margin[0],
1403
- left : margin[3]
1404
- };
1405
-
1406
- if (current.autoCenter && current.fixed && !onlyAbsolute && height <= viewport.h && width <= viewport.w) {
1407
- rez.position = 'fixed';
1408
-
1409
- } else if (!current.locked) {
1410
- rez.top += viewport.y;
1411
- rez.left += viewport.x;
1412
- }
1413
-
1414
- rez.top = getValue(Math.max(rez.top, rez.top + ((viewport.h - height) * current.topRatio)));
1415
- rez.left = getValue(Math.max(rez.left, rez.left + ((viewport.w - width) * current.leftRatio)));
1416
-
1417
- return rez;
1418
- },
1419
-
1420
- _afterZoomIn: function () {
1421
- var current = F.current;
1422
-
1423
- if (!current) {
1424
- return;
1425
- }
1426
-
1427
- F.isOpen = F.isOpened = true;
1428
-
1429
- F.wrap.css('overflow', 'visible').addClass('fancybox-opened');
1430
-
1431
- F.update();
1432
-
1433
- // Assign a click event
1434
- if ( current.closeClick || (current.nextClick && F.group.length > 1) ) {
1435
- F.inner.css('cursor', 'pointer').bind('click.fb', function(e) {
1436
- if (!$(e.target).is('a') && !$(e.target).parent().is('a')) {
1437
- e.preventDefault();
1438
-
1439
- F[ current.closeClick ? 'close' : 'next' ]();
1440
- }
1441
- });
1442
- }
1443
-
1444
- // Create a close button
1445
- if (current.closeBtn) {
1446
- $(current.tpl.closeBtn).appendTo(F.skin).bind('click.fb', function(e) {
1447
- e.preventDefault();
1448
-
1449
- F.close();
1450
- });
1451
- }
1452
-
1453
- // Create navigation arrows
1454
- if (current.arrows && F.group.length > 1) {
1455
- if (current.loop || current.index > 0) {
1456
- $(current.tpl.prev).appendTo(F.outer).bind('click.fb', F.prev);
1457
- }
1458
-
1459
- if (current.loop || current.index < F.group.length - 1) {
1460
- $(current.tpl.next).appendTo(F.outer).bind('click.fb', F.next);
1461
- }
1462
- }
1463
-
1464
- F.trigger('afterShow');
1465
-
1466
- // Stop the slideshow if this is the last item
1467
- if (!current.loop && current.index === current.group.length - 1) {
1468
- F.play( false );
1469
-
1470
- } else if (F.opts.autoPlay && !F.player.isActive) {
1471
- F.opts.autoPlay = false;
1472
-
1473
- F.play();
1474
- }
1475
- },
1476
-
1477
- _afterZoomOut: function ( obj ) {
1478
- obj = obj || F.current;
1479
-
1480
- $('.fancybox-wrap').trigger('onReset').remove();
1481
-
1482
- $.extend(F, {
1483
- group : {},
1484
- opts : {},
1485
- router : false,
1486
- current : null,
1487
- isActive : false,
1488
- isOpened : false,
1489
- isOpen : false,
1490
- isClosing : false,
1491
- wrap : null,
1492
- skin : null,
1493
- outer : null,
1494
- inner : null
1495
- });
1496
-
1497
- F.trigger('afterClose', obj);
1498
- }
1499
- });
1500
-
1501
- /*
1502
- * Default transitions
1503
- */
1504
-
1505
- F.transitions = {
1506
- getOrigPosition: function () {
1507
- var current = F.current,
1508
- element = current.element,
1509
- orig = current.orig,
1510
- pos = {},
1511
- width = 50,
1512
- height = 50,
1513
- hPadding = current.hPadding,
1514
- wPadding = current.wPadding,
1515
- viewport = F.getViewport();
1516
-
1517
- if (!orig && current.isDom && element.is(':visible')) {
1518
- orig = element.find('img:first');
1519
-
1520
- if (!orig.length) {
1521
- orig = element;
1522
- }
1523
- }
1524
-
1525
- if (isQuery(orig)) {
1526
- pos = orig.offset();
1527
-
1528
- if (orig.is('img')) {
1529
- width = orig.outerWidth();
1530
- height = orig.outerHeight();
1531
- }
1532
-
1533
- } else {
1534
- pos.top = viewport.y + (viewport.h - height) * current.topRatio;
1535
- pos.left = viewport.x + (viewport.w - width) * current.leftRatio;
1536
- }
1537
-
1538
- if (F.wrap.css('position') === 'fixed' || current.locked) {
1539
- pos.top -= viewport.y;
1540
- pos.left -= viewport.x;
1541
- }
1542
-
1543
- pos = {
1544
- top : getValue(pos.top - hPadding * current.topRatio),
1545
- left : getValue(pos.left - wPadding * current.leftRatio),
1546
- width : getValue(width + wPadding),
1547
- height : getValue(height + hPadding)
1548
- };
1549
-
1550
- return pos;
1551
- },
1552
-
1553
- step: function (now, fx) {
1554
- var ratio,
1555
- padding,
1556
- value,
1557
- prop = fx.prop,
1558
- current = F.current,
1559
- wrapSpace = current.wrapSpace,
1560
- skinSpace = current.skinSpace;
1561
-
1562
- if (prop === 'width' || prop === 'height') {
1563
- ratio = fx.end === fx.start ? 1 : (now - fx.start) / (fx.end - fx.start);
1564
-
1565
- if (F.isClosing) {
1566
- ratio = 1 - ratio;
1567
- }
1568
-
1569
- padding = prop === 'width' ? current.wPadding : current.hPadding;
1570
- value = now - padding;
1571
-
1572
- F.skin[ prop ]( getScalar( prop === 'width' ? value : value - (wrapSpace * ratio) ) );
1573
- F.inner[ prop ]( getScalar( prop === 'width' ? value : value - (wrapSpace * ratio) - (skinSpace * ratio) ) );
1574
- }
1575
- },
1576
-
1577
- zoomIn: function () {
1578
- var current = F.current,
1579
- startPos = current.pos,
1580
- effect = current.openEffect,
1581
- elastic = effect === 'elastic',
1582
- endPos = $.extend({opacity : 1}, startPos);
1583
-
1584
- // Remove "position" property that breaks older IE
1585
- delete endPos.position;
1586
-
1587
- if (elastic) {
1588
- startPos = this.getOrigPosition();
1589
-
1590
- if (current.openOpacity) {
1591
- startPos.opacity = 0.1;
1592
- }
1593
-
1594
- } else if (effect === 'fade') {
1595
- startPos.opacity = 0.1;
1596
- }
1597
-
1598
- F.wrap.css(startPos).animate(endPos, {
1599
- duration : effect === 'none' ? 0 : current.openSpeed,
1600
- easing : current.openEasing,
1601
- step : elastic ? this.step : null,
1602
- complete : F._afterZoomIn
1603
- });
1604
- },
1605
-
1606
- zoomOut: function () {
1607
- var current = F.current,
1608
- effect = current.closeEffect,
1609
- elastic = effect === 'elastic',
1610
- endPos = {opacity : 0.1};
1611
-
1612
- if (elastic) {
1613
- endPos = this.getOrigPosition();
1614
-
1615
- if (current.closeOpacity) {
1616
- endPos.opacity = 0.1;
1617
- }
1618
- }
1619
-
1620
- F.wrap.animate(endPos, {
1621
- duration : effect === 'none' ? 0 : current.closeSpeed,
1622
- easing : current.closeEasing,
1623
- step : elastic ? this.step : null,
1624
- complete : F._afterZoomOut
1625
- });
1626
- },
1627
-
1628
- changeIn: function () {
1629
- var current = F.current,
1630
- effect = current.nextEffect,
1631
- startPos = current.pos,
1632
- endPos = { opacity : 1 },
1633
- direction = F.direction,
1634
- distance = 200,
1635
- field;
1636
-
1637
- startPos.opacity = 0.1;
1638
-
1639
- if (effect === 'elastic') {
1640
- field = direction === 'down' || direction === 'up' ? 'top' : 'left';
1641
-
1642
- if (direction === 'down' || direction === 'right') {
1643
- startPos[ field ] = getValue(getScalar(startPos[ field ]) - distance);
1644
- endPos[ field ] = '+=' + distance + 'px';
1645
-
1646
- } else {
1647
- startPos[ field ] = getValue(getScalar(startPos[ field ]) + distance);
1648
- endPos[ field ] = '-=' + distance + 'px';
1649
- }
1650
- }
1651
-
1652
- // Workaround for http://bugs.jquery.com/ticket/12273
1653
- if (effect === 'none') {
1654
- F._afterZoomIn();
1655
-
1656
- } else {
1657
- F.wrap.css(startPos).animate(endPos, {
1658
- duration : current.nextSpeed,
1659
- easing : current.nextEasing,
1660
- complete : F._afterZoomIn
1661
- });
1662
- }
1663
- },
1664
-
1665
- changeOut: function () {
1666
- var previous = F.previous,
1667
- effect = previous.prevEffect,
1668
- endPos = { opacity : 0.1 },
1669
- direction = F.direction,
1670
- distance = 200;
1671
-
1672
- if (effect === 'elastic') {
1673
- endPos[ direction === 'down' || direction === 'up' ? 'top' : 'left' ] = ( direction === 'up' || direction === 'left' ? '-' : '+' ) + '=' + distance + 'px';
1674
- }
1675
-
1676
- previous.wrap.animate(endPos, {
1677
- duration : effect === 'none' ? 0 : previous.prevSpeed,
1678
- easing : previous.prevEasing,
1679
- complete : function () {
1680
- $(this).trigger('onReset').remove();
1681
- }
1682
- });
1683
- }
1684
- };
1685
-
1686
- /*
1687
- * Overlay helper
1688
- */
1689
-
1690
- F.helpers.overlay = {
1691
- defaults : {
1692
- closeClick : true, // if true, fancyBox will be closed when user clicks on the overlay
1693
- speedOut : 200, // duration of fadeOut animation
1694
- showEarly : true, // indicates if should be opened immediately or wait until the content is ready
1695
- css : {}, // custom CSS properties
1696
- locked : !isTouch, // if true, the content will be locked into overlay
1697
- fixed : true // if false, the overlay CSS position property will not be set to "fixed"
1698
- },
1699
-
1700
- overlay : null, // current handle
1701
- fixed : false, // indicates if the overlay has position "fixed"
1702
- el : $('html'), // element that contains "the lock"
1703
-
1704
- // Public methods
1705
- create : function(opts) {
1706
- opts = $.extend({}, this.defaults, opts);
1707
-
1708
- if (this.overlay) {
1709
- this.close();
1710
- }
1711
-
1712
- this.overlay = $('<div class="fancybox-overlay"></div>').appendTo( F.coming ? F.coming.parent : opts.parent );
1713
- this.fixed = false;
1714
-
1715
- if (opts.fixed && F.defaults.fixed) {
1716
- this.overlay.addClass('fancybox-overlay-fixed');
1717
-
1718
- this.fixed = true;
1719
- }
1720
- },
1721
-
1722
- open : function(opts) {
1723
- var that = this;
1724
-
1725
- opts = $.extend({}, this.defaults, opts);
1726
-
1727
- if (this.overlay) {
1728
- this.overlay.unbind('.overlay').width('auto').height('auto');
1729
-
1730
- } else {
1731
- this.create(opts);
1732
- }
1733
-
1734
- if (!this.fixed) {
1735
- W.bind('resize.overlay', $.proxy( this.update, this) );
1736
-
1737
- this.update();
1738
- }
1739
-
1740
- if (opts.closeClick) {
1741
- this.overlay.bind('click.overlay', function(e) {
1742
- if ($(e.target).hasClass('fancybox-overlay')) {
1743
- if (F.isActive) {
1744
- F.close();
1745
- } else {
1746
- that.close();
1747
- }
1748
-
1749
- return false;
1750
- }
1751
- });
1752
- }
1753
-
1754
- this.overlay.css( opts.css ).show();
1755
- },
1756
-
1757
- close : function() {
1758
- var scrollV, scrollH;
1759
-
1760
- W.unbind('resize.overlay');
1761
-
1762
- if (this.el.hasClass('fancybox-lock')) {
1763
- $('.fancybox-margin').removeClass('fancybox-margin');
1764
-
1765
- scrollV = W.scrollTop();
1766
- scrollH = W.scrollLeft();
1767
-
1768
- this.el.removeClass('fancybox-lock');
1769
-
1770
- W.scrollTop( scrollV ).scrollLeft( scrollH );
1771
- }
1772
-
1773
- $('.fancybox-overlay').remove().hide();
1774
-
1775
- $.extend(this, {
1776
- overlay : null,
1777
- fixed : false
1778
- });
1779
- },
1780
-
1781
- // Private, callbacks
1782
-
1783
- update : function () {
1784
- var width = '100%', offsetWidth;
1785
-
1786
- // Reset width/height so it will not mess
1787
- this.overlay.width(width).height('100%');
1788
-
1789
- // jQuery does not return reliable result for IE
1790
- if (IE) {
1791
- offsetWidth = Math.max(document.documentElement.offsetWidth, document.body.offsetWidth);
1792
-
1793
- if (D.width() > offsetWidth) {
1794
- width = D.width();
1795
- }
1796
-
1797
- } else if (D.width() > W.width()) {
1798
- width = D.width();
1799
- }
1800
-
1801
- this.overlay.width(width).height(D.height());
1802
- },
1803
-
1804
- // This is where we can manipulate DOM, because later it would cause iframes to reload
1805
- onReady : function (opts, obj) {
1806
- var overlay = this.overlay;
1807
-
1808
- $('.fancybox-overlay').stop(true, true);
1809
-
1810
- if (!overlay) {
1811
- this.create(opts);
1812
- }
1813
-
1814
- if (opts.locked && this.fixed && obj.fixed) {
1815
- if (!overlay) {
1816
- this.margin = D.height() > W.height() ? $('html').css('margin-right').replace("px", "") : false;
1817
- }
1818
-
1819
- obj.locked = this.overlay.append( obj.wrap );
1820
- obj.fixed = false;
1821
- }
1822
-
1823
- if (opts.showEarly === true) {
1824
- this.beforeShow.apply(this, arguments);
1825
- }
1826
- },
1827
-
1828
- beforeShow : function(opts, obj) {
1829
- var scrollV, scrollH;
1830
-
1831
- if (obj.locked) {
1832
- if (this.margin !== false) {
1833
- $('*').filter(function(){
1834
- return ($(this).css('position') === 'fixed' && !$(this).hasClass("fancybox-overlay") && !$(this).hasClass("fancybox-wrap") );
1835
- }).addClass('fancybox-margin');
1836
-
1837
- this.el.addClass('fancybox-margin');
1838
- }
1839
-
1840
- scrollV = W.scrollTop();
1841
- scrollH = W.scrollLeft();
1842
-
1843
- this.el.addClass('fancybox-lock');
1844
-
1845
- W.scrollTop( scrollV ).scrollLeft( scrollH );
1846
- }
1847
-
1848
- this.open(opts);
1849
- },
1850
-
1851
- onUpdate : function() {
1852
- if (!this.fixed) {
1853
- this.update();
1854
- }
1855
- },
1856
-
1857
- afterClose: function (opts) {
1858
- // Remove overlay if exists and fancyBox is not opening
1859
- // (e.g., it is not being open using afterClose callback)
1860
- //if (this.overlay && !F.isActive) {
1861
- if (this.overlay && !F.coming) {
1862
- this.overlay.fadeOut(opts.speedOut, $.proxy( this.close, this ));
1863
- }
1864
- }
1865
- };
1866
-
1867
- /*
1868
- * Title helper
1869
- */
1870
-
1871
- F.helpers.title = {
1872
- defaults : {
1873
- type : 'float', // 'float', 'inside', 'outside' or 'over',
1874
- position : 'bottom' // 'top' or 'bottom'
1875
- },
1876
-
1877
- beforeShow: function (opts) {
1878
- var current = F.current,
1879
- text = current.title,
1880
- type = opts.type,
1881
- title,
1882
- target;
1883
-
1884
- if ($.isFunction(text)) {
1885
- text = text.call(current.element, current);
1886
- }
1887
-
1888
- if (!isString(text) || $.trim(text) === '') {
1889
- return;
1890
- }
1891
-
1892
- title = $('<div class="fancybox-title fancybox-title-' + type + '-wrap">' + text + '</div>');
1893
-
1894
- switch (type) {
1895
- case 'inside':
1896
- target = F.skin;
1897
- break;
1898
-
1899
- case 'outside':
1900
- target = F.wrap;
1901
- break;
1902
-
1903
- case 'over':
1904
- target = F.inner;
1905
- break;
1906
-
1907
- default: // 'float'
1908
- target = F.skin;
1909
-
1910
- title.appendTo('body');
1911
-
1912
- if (IE) {
1913
- title.width( title.width() );
1914
- }
1915
-
1916
- title.wrapInner('<span class="child"></span>');
1917
-
1918
- //Increase bottom margin so this title will also fit into viewport
1919
- F.current.margin[2] += Math.abs( getScalar(title.css('margin-bottom')) );
1920
- break;
1921
- }
1922
-
1923
- title[ (opts.position === 'top' ? 'prependTo' : 'appendTo') ](target);
1924
- }
1925
- };
1926
-
1927
- // jQuery plugin initialization
1928
- $.fn.fancybox = function (options) {
1929
- var index,
1930
- that = $(this),
1931
- selector = this.selector || '',
1932
- run = function(e) {
1933
- var what = $(this).blur(), idx = index, relType, relVal;
1934
-
1935
- if (!(e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) && !what.is('.fancybox-wrap')) {
1936
- relType = options.groupAttr || 'data-fancybox-group';
1937
- relVal = what.attr(relType);
1938
-
1939
- if (!relVal) {
1940
- relType = 'rel';
1941
- relVal = what.get(0)[ relType ];
1942
- }
1943
-
1944
- if (relVal && relVal !== '' && relVal !== 'nofollow') {
1945
- what = selector.length ? $(selector) : that;
1946
- what = what.filter('[' + relType + '="' + relVal + '"]');
1947
- idx = what.index(this);
1948
- }
1949
-
1950
- options.index = idx;
1951
-
1952
- // Stop an event from bubbling if everything is fine
1953
- if (F.open(what, options) !== false) {
1954
- e.preventDefault();
1955
- }
1956
- }
1957
- };
1958
-
1959
- options = options || {};
1960
- index = options.index || 0;
1961
-
1962
- if (!selector || options.live === false) {
1963
- that.unbind('click.fb-start').bind('click.fb-start', run);
1964
-
1965
- } else {
1966
- D.undelegate(selector, 'click.fb-start').delegate(selector + ":not('.fancybox-item, .fancybox-nav')", 'click.fb-start', run);
1967
- }
1968
-
1969
- this.filter('[data-fancybox-start=1]').trigger('click');
1970
-
1971
- return this;
1972
- };
1973
-
1974
- // Tests that need a body at doc ready
1975
- D.ready(function() {
1976
- var w1, w2;
1977
-
1978
- if ( $.scrollbarWidth === undefined ) {
1979
- // http://benalman.com/projects/jquery-misc-plugins/#scrollbarwidth
1980
- $.scrollbarWidth = function() {
1981
- var parent = $('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo('body'),
1982
- child = parent.children(),
1983
- width = child.innerWidth() - child.height( 99 ).innerWidth();
1984
-
1985
- parent.remove();
1986
-
1987
- return width;
1988
- };
1989
- }
1990
-
1991
- if ( $.support.fixedPosition === undefined ) {
1992
- $.support.fixedPosition = (function() {
1993
- var elem = $('<div style="position:fixed;top:20px;"></div>').appendTo('body'),
1994
- fixed = ( elem[0].offsetTop === 20 || elem[0].offsetTop === 15 );
1995
-
1996
- elem.remove();
1997
-
1998
- return fixed;
1999
- }());
2000
- }
2001
-
2002
- $.extend(F.defaults, {
2003
- scrollbarWidth : $.scrollbarWidth(),
2004
- fixed : $.support.fixedPosition,
2005
- parent : $('body')
2006
- });
2007
-
2008
- //Get real width of page scroll-bar
2009
- w1 = $(window).width();
2010
-
2011
- H.addClass('fancybox-lock-test');
2012
-
2013
- w2 = $(window).width();
2014
-
2015
- H.removeClass('fancybox-lock-test');
2016
-
2017
- $("<style type='text/css'>.fancybox-margin{margin-right:" + (w2 - w1) + "px;}</style>").appendTo("head");
2018
- });
2019
-
1
+ /*!
2
+ * fancyBox - jQuery Plugin
3
+ * version: 2.1.5 (Fri, 14 Jun 2013)
4
+ * @requires jQuery v1.6 or later
5
+ *
6
+ * Examples at http://fancyapps.com/fancybox/
7
+ * License: www.fancyapps.com/fancybox/#license
8
+ *
9
+ * Copyright 2012 Janis Skarnelis - janis@fancyapps.com
10
+ *
11
+ */
12
+
13
+ (function (window, document, $, undefined) {
14
+ "use strict";
15
+
16
+ var H = $("html"),
17
+ W = $(window),
18
+ D = $(document),
19
+ F = $.fancybox = function () {
20
+ F.open.apply( this, arguments );
21
+ },
22
+ IE = navigator.userAgent.match(/msie/i),
23
+ didUpdate = null,
24
+ isTouch = document.createTouch !== undefined,
25
+
26
+ isQuery = function(obj) {
27
+ return obj && obj.hasOwnProperty && obj instanceof $;
28
+ },
29
+ isString = function(str) {
30
+ return str && $.type(str) === "string";
31
+ },
32
+ isPercentage = function(str) {
33
+ return isString(str) && str.indexOf('%') > 0;
34
+ },
35
+ isScrollable = function(el) {
36
+ return (el && !(el.style.overflow && el.style.overflow === 'hidden') && ((el.clientWidth && el.scrollWidth > el.clientWidth) || (el.clientHeight && el.scrollHeight > el.clientHeight)));
37
+ },
38
+ getScalar = function(orig, dim) {
39
+ var value = parseInt(orig, 10) || 0;
40
+
41
+ if (dim && isPercentage(orig)) {
42
+ value = F.getViewport()[ dim ] / 100 * value;
43
+ }
44
+
45
+ return Math.ceil(value);
46
+ },
47
+ getValue = function(value, dim) {
48
+ return getScalar(value, dim) + 'px';
49
+ };
50
+
51
+ $.extend(F, {
52
+ // The current version of fancyBox
53
+ version: '2.1.5',
54
+
55
+ defaults: {
56
+ padding : 15,
57
+ margin : 20,
58
+
59
+ width : 800,
60
+ height : 600,
61
+ minWidth : 100,
62
+ minHeight : 100,
63
+ maxWidth : 9999,
64
+ maxHeight : 9999,
65
+ pixelRatio: 1, // Set to 2 for retina display support
66
+
67
+ autoSize : true,
68
+ autoHeight : false,
69
+ autoWidth : false,
70
+
71
+ autoResize : true,
72
+ autoCenter : !isTouch,
73
+ fitToView : true,
74
+ aspectRatio : false,
75
+ topRatio : 0.5,
76
+ leftRatio : 0.5,
77
+
78
+ scrolling : 'auto', // 'auto', 'yes' or 'no'
79
+ wrapCSS : '',
80
+
81
+ arrows : true,
82
+ closeBtn : true,
83
+ closeClick : false,
84
+ nextClick : false,
85
+ mouseWheel : true,
86
+ autoPlay : false,
87
+ playSpeed : 3000,
88
+ preload : 3,
89
+ modal : false,
90
+ loop : true,
91
+
92
+ ajax : {
93
+ dataType : 'html',
94
+ headers : { 'X-fancyBox': true }
95
+ },
96
+ iframe : {
97
+ scrolling : 'auto',
98
+ preload : true
99
+ },
100
+ swf : {
101
+ wmode: 'transparent',
102
+ allowfullscreen : 'true',
103
+ allowscriptaccess : 'always'
104
+ },
105
+
106
+ keys : {
107
+ next : {
108
+ 13 : 'left', // enter
109
+ 34 : 'up', // page down
110
+ 39 : 'left', // right arrow
111
+ 40 : 'up' // down arrow
112
+ },
113
+ prev : {
114
+ 8 : 'right', // backspace
115
+ 33 : 'down', // page up
116
+ 37 : 'right', // left arrow
117
+ 38 : 'down' // up arrow
118
+ },
119
+ close : [27], // escape key
120
+ play : [32], // space - start/stop slideshow
121
+ toggle : [70] // letter "f" - toggle fullscreen
122
+ },
123
+
124
+ direction : {
125
+ next : 'left',
126
+ prev : 'right'
127
+ },
128
+
129
+ scrollOutside : true,
130
+
131
+ // Override some properties
132
+ index : 0,
133
+ type : null,
134
+ href : null,
135
+ content : null,
136
+ title : null,
137
+
138
+ // HTML templates
139
+ tpl: {
140
+ wrap : '<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>',
141
+ image : '<img class="fancybox-image" src="{href}" alt="" />',
142
+ iframe : '<iframe id="fancybox-frame{rnd}" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen' + (IE ? ' allowtransparency="true"' : '') + '></iframe>',
143
+ error : '<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',
144
+ closeBtn : '<a title="Close" class="fancybox-item fancybox-close" href="javascript:;"></a>',
145
+ next : '<a title="Next" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',
146
+ prev : '<a title="Previous" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'
147
+ },
148
+
149
+ // Properties for each animation type
150
+ // Opening fancyBox
151
+ openEffect : 'fade', // 'elastic', 'fade' or 'none'
152
+ openSpeed : 250,
153
+ openEasing : 'swing',
154
+ openOpacity : true,
155
+ openMethod : 'zoomIn',
156
+
157
+ // Closing fancyBox
158
+ closeEffect : 'fade', // 'elastic', 'fade' or 'none'
159
+ closeSpeed : 250,
160
+ closeEasing : 'swing',
161
+ closeOpacity : true,
162
+ closeMethod : 'zoomOut',
163
+
164
+ // Changing next gallery item
165
+ nextEffect : 'elastic', // 'elastic', 'fade' or 'none'
166
+ nextSpeed : 250,
167
+ nextEasing : 'swing',
168
+ nextMethod : 'changeIn',
169
+
170
+ // Changing previous gallery item
171
+ prevEffect : 'elastic', // 'elastic', 'fade' or 'none'
172
+ prevSpeed : 250,
173
+ prevEasing : 'swing',
174
+ prevMethod : 'changeOut',
175
+
176
+ // Enable default helpers
177
+ helpers : {
178
+ overlay : true,
179
+ title : true
180
+ },
181
+
182
+ // Callbacks
183
+ onCancel : $.noop, // If canceling
184
+ beforeLoad : $.noop, // Before loading
185
+ afterLoad : $.noop, // After loading
186
+ beforeShow : $.noop, // Before changing in current item
187
+ afterShow : $.noop, // After opening
188
+ beforeChange : $.noop, // Before changing gallery item
189
+ beforeClose : $.noop, // Before closing
190
+ afterClose : $.noop // After closing
191
+ },
192
+
193
+ //Current state
194
+ group : {}, // Selected group
195
+ opts : {}, // Group options
196
+ previous : null, // Previous element
197
+ coming : null, // Element being loaded
198
+ current : null, // Currently loaded element
199
+ isActive : false, // Is activated
200
+ isOpen : false, // Is currently open
201
+ isOpened : false, // Have been fully opened at least once
202
+
203
+ wrap : null,
204
+ skin : null,
205
+ outer : null,
206
+ inner : null,
207
+
208
+ player : {
209
+ timer : null,
210
+ isActive : false
211
+ },
212
+
213
+ // Loaders
214
+ ajaxLoad : null,
215
+ imgPreload : null,
216
+
217
+ // Some collections
218
+ transitions : {},
219
+ helpers : {},
220
+
221
+ /*
222
+ * Static methods
223
+ */
224
+
225
+ open: function (group, opts) {
226
+ if (!group) {
227
+ return;
228
+ }
229
+
230
+ if (!$.isPlainObject(opts)) {
231
+ opts = {};
232
+ }
233
+
234
+ // Close if already active
235
+ if (false === F.close(true)) {
236
+ return;
237
+ }
238
+
239
+ // Normalize group
240
+ if (!$.isArray(group)) {
241
+ group = isQuery(group) ? $(group).get() : [group];
242
+ }
243
+
244
+ // Recheck if the type of each element is `object` and set content type (image, ajax, etc)
245
+ $.each(group, function(i, element) {
246
+ var obj = {},
247
+ href,
248
+ title,
249
+ content,
250
+ type,
251
+ rez,
252
+ hrefParts,
253
+ selector;
254
+
255
+ if ($.type(element) === "object") {
256
+ // Check if is DOM element
257
+ if (element.nodeType) {
258
+ element = $(element);
259
+ }
260
+
261
+ if (isQuery(element)) {
262
+ obj = {
263
+ href : element.data('fancybox-href') || element.attr('href'),
264
+ title : element.data('fancybox-title') || element.attr('title'),
265
+ isDom : true,
266
+ element : element
267
+ };
268
+
269
+ if ($.metadata) {
270
+ $.extend(true, obj, element.metadata());
271
+ }
272
+
273
+ } else {
274
+ obj = element;
275
+ }
276
+ }
277
+
278
+ href = opts.href || obj.href || (isString(element) ? element : null);
279
+ title = opts.title !== undefined ? opts.title : obj.title || '';
280
+
281
+ content = opts.content || obj.content;
282
+ type = content ? 'html' : (opts.type || obj.type);
283
+
284
+ if (!type && obj.isDom) {
285
+ type = element.data('fancybox-type');
286
+
287
+ if (!type) {
288
+ rez = element.prop('class').match(/fancybox\.(\w+)/);
289
+ type = rez ? rez[1] : null;
290
+ }
291
+ }
292
+
293
+ if (isString(href)) {
294
+ // Try to guess the content type
295
+ if (!type) {
296
+ if (F.isImage(href)) {
297
+ type = 'image';
298
+
299
+ } else if (F.isSWF(href)) {
300
+ type = 'swf';
301
+
302
+ } else if (href.charAt(0) === '#') {
303
+ type = 'inline';
304
+
305
+ } else if (isString(element)) {
306
+ type = 'html';
307
+ content = element;
308
+ }
309
+ }
310
+
311
+ // Split url into two pieces with source url and content selector, e.g,
312
+ // "/mypage.html #my_id" will load "/mypage.html" and display element having id "my_id"
313
+ if (type === 'ajax') {
314
+ hrefParts = href.split(/\s+/, 2);
315
+ href = hrefParts.shift();
316
+ selector = hrefParts.shift();
317
+ }
318
+ }
319
+
320
+ if (!content) {
321
+ if (type === 'inline') {
322
+ if (href) {
323
+ content = $( isString(href) ? href.replace(/.*(?=#[^\s]+$)/, '') : href ); //strip for ie7
324
+
325
+ } else if (obj.isDom) {
326
+ content = element;
327
+ }
328
+
329
+ } else if (type === 'html') {
330
+ content = href;
331
+
332
+ } else if (!type && !href && obj.isDom) {
333
+ type = 'inline';
334
+ content = element;
335
+ }
336
+ }
337
+
338
+ $.extend(obj, {
339
+ href : href,
340
+ type : type,
341
+ content : content,
342
+ title : title,
343
+ selector : selector
344
+ });
345
+
346
+ group[ i ] = obj;
347
+ });
348
+
349
+ // Extend the defaults
350
+ F.opts = $.extend(true, {}, F.defaults, opts);
351
+
352
+ // All options are merged recursive except keys
353
+ if (opts.keys !== undefined) {
354
+ F.opts.keys = opts.keys ? $.extend({}, F.defaults.keys, opts.keys) : false;
355
+ }
356
+
357
+ F.group = group;
358
+
359
+ return F._start(F.opts.index);
360
+ },
361
+
362
+ // Cancel image loading or abort ajax request
363
+ cancel: function () {
364
+ var coming = F.coming;
365
+
366
+ if (!coming || false === F.trigger('onCancel')) {
367
+ return;
368
+ }
369
+
370
+ F.hideLoading();
371
+
372
+ if (F.ajaxLoad) {
373
+ F.ajaxLoad.abort();
374
+ }
375
+
376
+ F.ajaxLoad = null;
377
+
378
+ if (F.imgPreload) {
379
+ F.imgPreload.onload = F.imgPreload.onerror = null;
380
+ }
381
+
382
+ if (coming.wrap) {
383
+ coming.wrap.stop(true, true).trigger('onReset').remove();
384
+ }
385
+
386
+ F.coming = null;
387
+
388
+ // If the first item has been canceled, then clear everything
389
+ if (!F.current) {
390
+ F._afterZoomOut( coming );
391
+ }
392
+ },
393
+
394
+ // Start closing animation if is open; remove immediately if opening/closing
395
+ close: function (event) {
396
+ F.cancel();
397
+
398
+ if (false === F.trigger('beforeClose')) {
399
+ return;
400
+ }
401
+
402
+ F.unbindEvents();
403
+
404
+ if (!F.isActive) {
405
+ return;
406
+ }
407
+
408
+ if (!F.isOpen || event === true) {
409
+ $('.fancybox-wrap').stop(true).trigger('onReset').remove();
410
+
411
+ F._afterZoomOut();
412
+
413
+ } else {
414
+ F.isOpen = F.isOpened = false;
415
+ F.isClosing = true;
416
+
417
+ $('.fancybox-item, .fancybox-nav').remove();
418
+
419
+ F.wrap.stop(true, true).removeClass('fancybox-opened');
420
+
421
+ F.transitions[ F.current.closeMethod ]();
422
+ }
423
+ },
424
+
425
+ // Manage slideshow:
426
+ // $.fancybox.play(); - toggle slideshow
427
+ // $.fancybox.play( true ); - start
428
+ // $.fancybox.play( false ); - stop
429
+ play: function ( action ) {
430
+ var clear = function () {
431
+ clearTimeout(F.player.timer);
432
+ },
433
+ set = function () {
434
+ clear();
435
+
436
+ if (F.current && F.player.isActive) {
437
+ F.player.timer = setTimeout(F.next, F.current.playSpeed);
438
+ }
439
+ },
440
+ stop = function () {
441
+ clear();
442
+
443
+ D.unbind('.player');
444
+
445
+ F.player.isActive = false;
446
+
447
+ F.trigger('onPlayEnd');
448
+ },
449
+ start = function () {
450
+ if (F.current && (F.current.loop || F.current.index < F.group.length - 1)) {
451
+ F.player.isActive = true;
452
+
453
+ D.bind({
454
+ 'onCancel.player beforeClose.player' : stop,
455
+ 'onUpdate.player' : set,
456
+ 'beforeLoad.player' : clear
457
+ });
458
+
459
+ set();
460
+
461
+ F.trigger('onPlayStart');
462
+ }
463
+ };
464
+
465
+ if (action === true || (!F.player.isActive && action !== false)) {
466
+ start();
467
+ } else {
468
+ stop();
469
+ }
470
+ },
471
+
472
+ // Navigate to next gallery item
473
+ next: function ( direction ) {
474
+ var current = F.current;
475
+
476
+ if (current) {
477
+ if (!isString(direction)) {
478
+ direction = current.direction.next;
479
+ }
480
+
481
+ F.jumpto(current.index + 1, direction, 'next');
482
+ }
483
+ },
484
+
485
+ // Navigate to previous gallery item
486
+ prev: function ( direction ) {
487
+ var current = F.current;
488
+
489
+ if (current) {
490
+ if (!isString(direction)) {
491
+ direction = current.direction.prev;
492
+ }
493
+
494
+ F.jumpto(current.index - 1, direction, 'prev');
495
+ }
496
+ },
497
+
498
+ // Navigate to gallery item by index
499
+ jumpto: function ( index, direction, router ) {
500
+ var current = F.current;
501
+
502
+ if (!current) {
503
+ return;
504
+ }
505
+
506
+ index = getScalar(index);
507
+
508
+ F.direction = direction || current.direction[ (index >= current.index ? 'next' : 'prev') ];
509
+ F.router = router || 'jumpto';
510
+
511
+ if (current.loop) {
512
+ if (index < 0) {
513
+ index = current.group.length + (index % current.group.length);
514
+ }
515
+
516
+ index = index % current.group.length;
517
+ }
518
+
519
+ if (current.group[ index ] !== undefined) {
520
+ F.cancel();
521
+
522
+ F._start(index);
523
+ }
524
+ },
525
+
526
+ // Center inside viewport and toggle position type to fixed or absolute if needed
527
+ reposition: function (e, onlyAbsolute) {
528
+ var current = F.current,
529
+ wrap = current ? current.wrap : null,
530
+ pos;
531
+
532
+ if (wrap) {
533
+ pos = F._getPosition(onlyAbsolute);
534
+
535
+ if (e && e.type === 'scroll') {
536
+ delete pos.position;
537
+
538
+ wrap.stop(true, true).animate(pos, 200);
539
+
540
+ } else {
541
+ wrap.css(pos);
542
+
543
+ current.pos = $.extend({}, current.dim, pos);
544
+ }
545
+ }
546
+ },
547
+
548
+ update: function (e) {
549
+ var type = (e && e.type),
550
+ anyway = !type || type === 'orientationchange';
551
+
552
+ if (anyway) {
553
+ clearTimeout(didUpdate);
554
+
555
+ didUpdate = null;
556
+ }
557
+
558
+ if (!F.isOpen || didUpdate) {
559
+ return;
560
+ }
561
+
562
+ didUpdate = setTimeout(function() {
563
+ var current = F.current;
564
+
565
+ if (!current || F.isClosing) {
566
+ return;
567
+ }
568
+
569
+ F.wrap.removeClass('fancybox-tmp');
570
+
571
+ if (anyway || type === 'load' || (type === 'resize' && current.autoResize)) {
572
+ F._setDimension();
573
+ }
574
+
575
+ if (!(type === 'scroll' && current.canShrink)) {
576
+ F.reposition(e);
577
+ }
578
+
579
+ F.trigger('onUpdate');
580
+
581
+ didUpdate = null;
582
+
583
+ }, (anyway && !isTouch ? 0 : 300));
584
+ },
585
+
586
+ // Shrink content to fit inside viewport or restore if resized
587
+ toggle: function ( action ) {
588
+ if (F.isOpen) {
589
+ F.current.fitToView = $.type(action) === "boolean" ? action : !F.current.fitToView;
590
+
591
+ // Help browser to restore document dimensions
592
+ if (isTouch) {
593
+ F.wrap.removeAttr('style').addClass('fancybox-tmp');
594
+
595
+ F.trigger('onUpdate');
596
+ }
597
+
598
+ F.update();
599
+ }
600
+ },
601
+
602
+ hideLoading: function () {
603
+ D.unbind('.loading');
604
+
605
+ $('#fancybox-loading').remove();
606
+ },
607
+
608
+ showLoading: function () {
609
+ var el, viewport;
610
+
611
+ F.hideLoading();
612
+
613
+ el = $('<div id="fancybox-loading"><div></div></div>').click(F.cancel).appendTo('body');
614
+
615
+ // If user will press the escape-button, the request will be canceled
616
+ D.bind('keydown.loading', function(e) {
617
+ if ((e.which || e.keyCode) === 27) {
618
+ e.preventDefault();
619
+
620
+ F.cancel();
621
+ }
622
+ });
623
+
624
+ if (!F.defaults.fixed) {
625
+ viewport = F.getViewport();
626
+
627
+ el.css({
628
+ position : 'absolute',
629
+ top : (viewport.h * 0.5) + viewport.y,
630
+ left : (viewport.w * 0.5) + viewport.x
631
+ });
632
+ }
633
+ },
634
+
635
+ getViewport: function () {
636
+ var locked = (F.current && F.current.locked) || false,
637
+ rez = {
638
+ x: W.scrollLeft(),
639
+ y: W.scrollTop()
640
+ };
641
+
642
+ if (locked) {
643
+ rez.w = locked[0].clientWidth;
644
+ rez.h = locked[0].clientHeight;
645
+
646
+ } else {
647
+ // See http://bugs.jquery.com/ticket/6724
648
+ rez.w = isTouch && window.innerWidth ? window.innerWidth : W.width();
649
+ rez.h = isTouch && window.innerHeight ? window.innerHeight : W.height();
650
+ }
651
+
652
+ return rez;
653
+ },
654
+
655
+ // Unbind the keyboard / clicking actions
656
+ unbindEvents: function () {
657
+ if (F.wrap && isQuery(F.wrap)) {
658
+ F.wrap.unbind('.fb');
659
+ }
660
+
661
+ D.unbind('.fb');
662
+ W.unbind('.fb');
663
+ },
664
+
665
+ bindEvents: function () {
666
+ var current = F.current,
667
+ keys;
668
+
669
+ if (!current) {
670
+ return;
671
+ }
672
+
673
+ // Changing document height on iOS devices triggers a 'resize' event,
674
+ // that can change document height... repeating infinitely
675
+ W.bind('orientationchange.fb' + (isTouch ? '' : ' resize.fb') + (current.autoCenter && !current.locked ? ' scroll.fb' : ''), F.update);
676
+
677
+ keys = current.keys;
678
+
679
+ if (keys) {
680
+ D.bind('keydown.fb', function (e) {
681
+ var code = e.which || e.keyCode,
682
+ target = e.target || e.srcElement;
683
+
684
+ // Skip esc key if loading, because showLoading will cancel preloading
685
+ if (code === 27 && F.coming) {
686
+ return false;
687
+ }
688
+
689
+ // Ignore key combinations and key events within form elements
690
+ if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey && !(target && (target.type || $(target).is('[contenteditable]')))) {
691
+ $.each(keys, function(i, val) {
692
+ if (current.group.length > 1 && val[ code ] !== undefined) {
693
+ F[ i ]( val[ code ] );
694
+
695
+ e.preventDefault();
696
+ return false;
697
+ }
698
+
699
+ if ($.inArray(code, val) > -1) {
700
+ F[ i ] ();
701
+
702
+ e.preventDefault();
703
+ return false;
704
+ }
705
+ });
706
+ }
707
+ });
708
+ }
709
+
710
+ if ($.fn.mousewheel && current.mouseWheel) {
711
+ F.wrap.bind('mousewheel.fb', function (e, delta, deltaX, deltaY) {
712
+ var target = e.target || null,
713
+ parent = $(target),
714
+ canScroll = false;
715
+
716
+ while (parent.length) {
717
+ if (canScroll || parent.is('.fancybox-skin') || parent.is('.fancybox-wrap')) {
718
+ break;
719
+ }
720
+
721
+ canScroll = isScrollable( parent[0] );
722
+ parent = $(parent).parent();
723
+ }
724
+
725
+ if (delta !== 0 && !canScroll) {
726
+ if (F.group.length > 1 && !current.canShrink) {
727
+ if (deltaY > 0 || deltaX > 0) {
728
+ F.prev( deltaY > 0 ? 'down' : 'left' );
729
+
730
+ } else if (deltaY < 0 || deltaX < 0) {
731
+ F.next( deltaY < 0 ? 'up' : 'right' );
732
+ }
733
+
734
+ e.preventDefault();
735
+ }
736
+ }
737
+ });
738
+ }
739
+ },
740
+
741
+ trigger: function (event, o) {
742
+ var ret, obj = o || F.coming || F.current;
743
+
744
+ if (!obj) {
745
+ return;
746
+ }
747
+
748
+ if ($.isFunction( obj[event] )) {
749
+ ret = obj[event].apply(obj, Array.prototype.slice.call(arguments, 1));
750
+ }
751
+
752
+ if (ret === false) {
753
+ return false;
754
+ }
755
+
756
+ if (obj.helpers) {
757
+ $.each(obj.helpers, function (helper, opts) {
758
+ if (opts && F.helpers[helper] && $.isFunction(F.helpers[helper][event])) {
759
+ F.helpers[helper][event]($.extend(true, {}, F.helpers[helper].defaults, opts), obj);
760
+ }
761
+ });
762
+ }
763
+
764
+ D.trigger(event);
765
+ },
766
+
767
+ isImage: function (str) {
768
+ return isString(str) && str.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i);
769
+ },
770
+
771
+ isSWF: function (str) {
772
+ return isString(str) && str.match(/\.(swf)((\?|#).*)?$/i);
773
+ },
774
+
775
+ _start: function (index) {
776
+ var coming = {},
777
+ obj,
778
+ href,
779
+ type,
780
+ margin,
781
+ padding;
782
+
783
+ index = getScalar( index );
784
+ obj = F.group[ index ] || null;
785
+
786
+ if (!obj) {
787
+ return false;
788
+ }
789
+
790
+ coming = $.extend(true, {}, F.opts, obj);
791
+
792
+ // Convert margin and padding properties to array - top, right, bottom, left
793
+ margin = coming.margin;
794
+ padding = coming.padding;
795
+
796
+ if ($.type(margin) === 'number') {
797
+ coming.margin = [margin, margin, margin, margin];
798
+ }
799
+
800
+ if ($.type(padding) === 'number') {
801
+ coming.padding = [padding, padding, padding, padding];
802
+ }
803
+
804
+ // 'modal' propery is just a shortcut
805
+ if (coming.modal) {
806
+ $.extend(true, coming, {
807
+ closeBtn : false,
808
+ closeClick : false,
809
+ nextClick : false,
810
+ arrows : false,
811
+ mouseWheel : false,
812
+ keys : null,
813
+ helpers: {
814
+ overlay : {
815
+ closeClick : false
816
+ }
817
+ }
818
+ });
819
+ }
820
+
821
+ // 'autoSize' property is a shortcut, too
822
+ if (coming.autoSize) {
823
+ coming.autoWidth = coming.autoHeight = true;
824
+ }
825
+
826
+ if (coming.width === 'auto') {
827
+ coming.autoWidth = true;
828
+ }
829
+
830
+ if (coming.height === 'auto') {
831
+ coming.autoHeight = true;
832
+ }
833
+
834
+ /*
835
+ * Add reference to the group, so it`s possible to access from callbacks, example:
836
+ * afterLoad : function() {
837
+ * this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');
838
+ * }
839
+ */
840
+
841
+ coming.group = F.group;
842
+ coming.index = index;
843
+
844
+ // Give a chance for callback or helpers to update coming item (type, title, etc)
845
+ F.coming = coming;
846
+
847
+ if (false === F.trigger('beforeLoad')) {
848
+ F.coming = null;
849
+
850
+ return;
851
+ }
852
+
853
+ type = coming.type;
854
+ href = coming.href;
855
+
856
+ if (!type) {
857
+ F.coming = null;
858
+
859
+ //If we can not determine content type then drop silently or display next/prev item if looping through gallery
860
+ if (F.current && F.router && F.router !== 'jumpto') {
861
+ F.current.index = index;
862
+
863
+ return F[ F.router ]( F.direction );
864
+ }
865
+
866
+ return false;
867
+ }
868
+
869
+ F.isActive = true;
870
+
871
+ if (type === 'image' || type === 'swf') {
872
+ coming.autoHeight = coming.autoWidth = false;
873
+ coming.scrolling = 'visible';
874
+ }
875
+
876
+ if (type === 'image') {
877
+ coming.aspectRatio = true;
878
+ }
879
+
880
+ if (type === 'iframe' && isTouch) {
881
+ coming.scrolling = 'scroll';
882
+ }
883
+
884
+ // Build the neccessary markup
885
+ coming.wrap = $(coming.tpl.wrap).addClass('fancybox-' + (isTouch ? 'mobile' : 'desktop') + ' fancybox-type-' + type + ' fancybox-tmp ' + coming.wrapCSS).appendTo( coming.parent || 'body' );
886
+
887
+ $.extend(coming, {
888
+ skin : $('.fancybox-skin', coming.wrap),
889
+ outer : $('.fancybox-outer', coming.wrap),
890
+ inner : $('.fancybox-inner', coming.wrap)
891
+ });
892
+
893
+ $.each(["Top", "Right", "Bottom", "Left"], function(i, v) {
894
+ coming.skin.css('padding' + v, getValue(coming.padding[ i ]));
895
+ });
896
+
897
+ F.trigger('onReady');
898
+
899
+ // Check before try to load; 'inline' and 'html' types need content, others - href
900
+ if (type === 'inline' || type === 'html') {
901
+ if (!coming.content || !coming.content.length) {
902
+ return F._error( 'content' );
903
+ }
904
+
905
+ } else if (!href) {
906
+ return F._error( 'href' );
907
+ }
908
+
909
+ if (type === 'image') {
910
+ F._loadImage();
911
+
912
+ } else if (type === 'ajax') {
913
+ F._loadAjax();
914
+
915
+ } else if (type === 'iframe') {
916
+ F._loadIframe();
917
+
918
+ } else {
919
+ F._afterLoad();
920
+ }
921
+ },
922
+
923
+ _error: function ( type ) {
924
+ $.extend(F.coming, {
925
+ type : 'html',
926
+ autoWidth : true,
927
+ autoHeight : true,
928
+ minWidth : 0,
929
+ minHeight : 0,
930
+ scrolling : 'no',
931
+ hasError : type,
932
+ content : F.coming.tpl.error
933
+ });
934
+
935
+ F._afterLoad();
936
+ },
937
+
938
+ _loadImage: function () {
939
+ // Reset preload image so it is later possible to check "complete" property
940
+ var img = F.imgPreload = new Image();
941
+
942
+ img.onload = function () {
943
+ this.onload = this.onerror = null;
944
+
945
+ F.coming.width = this.width / F.opts.pixelRatio;
946
+ F.coming.height = this.height / F.opts.pixelRatio;
947
+
948
+ F._afterLoad();
949
+ };
950
+
951
+ img.onerror = function () {
952
+ this.onload = this.onerror = null;
953
+
954
+ F._error( 'image' );
955
+ };
956
+
957
+ img.src = F.coming.href;
958
+
959
+ if (img.complete !== true) {
960
+ F.showLoading();
961
+ }
962
+ },
963
+
964
+ _loadAjax: function () {
965
+ var coming = F.coming;
966
+
967
+ F.showLoading();
968
+
969
+ F.ajaxLoad = $.ajax($.extend({}, coming.ajax, {
970
+ url: coming.href,
971
+ error: function (jqXHR, textStatus) {
972
+ if (F.coming && textStatus !== 'abort') {
973
+ F._error( 'ajax', jqXHR );
974
+
975
+ } else {
976
+ F.hideLoading();
977
+ }
978
+ },
979
+ success: function (data, textStatus) {
980
+ if (textStatus === 'success') {
981
+ coming.content = data;
982
+
983
+ F._afterLoad();
984
+ }
985
+ }
986
+ }));
987
+ },
988
+
989
+ _loadIframe: function() {
990
+ var coming = F.coming,
991
+ iframe = $(coming.tpl.iframe.replace(/\{rnd\}/g, new Date().getTime()))
992
+ .attr('scrolling', isTouch ? 'auto' : coming.iframe.scrolling)
993
+ .attr('src', coming.href);
994
+
995
+ // This helps IE
996
+ $(coming.wrap).bind('onReset', function () {
997
+ try {
998
+ $(this).find('iframe').hide().attr('src', '//about:blank').end().empty();
999
+ } catch (e) {}
1000
+ });
1001
+
1002
+ if (coming.iframe.preload) {
1003
+ F.showLoading();
1004
+
1005
+ iframe.one('load', function() {
1006
+ $(this).data('ready', 1);
1007
+
1008
+ // iOS will lose scrolling if we resize
1009
+ if (!isTouch) {
1010
+ $(this).bind('load.fb', F.update);
1011
+ }
1012
+
1013
+ // Without this trick:
1014
+ // - iframe won't scroll on iOS devices
1015
+ // - IE7 sometimes displays empty iframe
1016
+ $(this).parents('.fancybox-wrap').width('100%').removeClass('fancybox-tmp').show();
1017
+
1018
+ F._afterLoad();
1019
+ });
1020
+ }
1021
+
1022
+ coming.content = iframe.appendTo( coming.inner );
1023
+
1024
+ if (!coming.iframe.preload) {
1025
+ F._afterLoad();
1026
+ }
1027
+ },
1028
+
1029
+ _preloadImages: function() {
1030
+ var group = F.group,
1031
+ current = F.current,
1032
+ len = group.length,
1033
+ cnt = current.preload ? Math.min(current.preload, len - 1) : 0,
1034
+ item,
1035
+ i;
1036
+
1037
+ for (i = 1; i <= cnt; i += 1) {
1038
+ item = group[ (current.index + i ) % len ];
1039
+
1040
+ if (item.type === 'image' && item.href) {
1041
+ new Image().src = item.href;
1042
+ }
1043
+ }
1044
+ },
1045
+
1046
+ _afterLoad: function () {
1047
+ var coming = F.coming,
1048
+ previous = F.current,
1049
+ placeholder = 'fancybox-placeholder',
1050
+ current,
1051
+ content,
1052
+ type,
1053
+ scrolling,
1054
+ href,
1055
+ embed;
1056
+
1057
+ F.hideLoading();
1058
+
1059
+ if (!coming || F.isActive === false) {
1060
+ return;
1061
+ }
1062
+
1063
+ if (false === F.trigger('afterLoad', coming, previous)) {
1064
+ coming.wrap.stop(true).trigger('onReset').remove();
1065
+
1066
+ F.coming = null;
1067
+
1068
+ return;
1069
+ }
1070
+
1071
+ if (previous) {
1072
+ F.trigger('beforeChange', previous);
1073
+
1074
+ previous.wrap.stop(true).removeClass('fancybox-opened')
1075
+ .find('.fancybox-item, .fancybox-nav')
1076
+ .remove();
1077
+ }
1078
+
1079
+ F.unbindEvents();
1080
+
1081
+ current = coming;
1082
+ content = coming.content;
1083
+ type = coming.type;
1084
+ scrolling = coming.scrolling;
1085
+
1086
+ $.extend(F, {
1087
+ wrap : current.wrap,
1088
+ skin : current.skin,
1089
+ outer : current.outer,
1090
+ inner : current.inner,
1091
+ current : current,
1092
+ previous : previous
1093
+ });
1094
+
1095
+ href = current.href;
1096
+
1097
+ switch (type) {
1098
+ case 'inline':
1099
+ case 'ajax':
1100
+ case 'html':
1101
+ if (current.selector) {
1102
+ content = $('<div>').html(content).find(current.selector);
1103
+
1104
+ } else if (isQuery(content)) {
1105
+ if (!content.data(placeholder)) {
1106
+ content.data(placeholder, $('<div class="' + placeholder + '"></div>').insertAfter( content ).hide() );
1107
+ }
1108
+
1109
+ content = content.show().detach();
1110
+
1111
+ current.wrap.bind('onReset', function () {
1112
+ if ($(this).find(content).length) {
1113
+ content.hide().replaceAll( content.data(placeholder) ).data(placeholder, false);
1114
+ }
1115
+ });
1116
+ }
1117
+ break;
1118
+
1119
+ case 'image':
1120
+ content = current.tpl.image.replace('{href}', href);
1121
+ break;
1122
+
1123
+ case 'swf':
1124
+ content = '<object id="fancybox-swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="movie" value="' + href + '"></param>';
1125
+ embed = '';
1126
+
1127
+ $.each(current.swf, function(name, val) {
1128
+ content += '<param name="' + name + '" value="' + val + '"></param>';
1129
+ embed += ' ' + name + '="' + val + '"';
1130
+ });
1131
+
1132
+ content += '<embed src="' + href + '" type="application/x-shockwave-flash" width="100%" height="100%"' + embed + '></embed></object>';
1133
+ break;
1134
+ }
1135
+
1136
+ if (!(isQuery(content) && content.parent().is(current.inner))) {
1137
+ current.inner.append( content );
1138
+ }
1139
+
1140
+ // Give a chance for helpers or callbacks to update elements
1141
+ F.trigger('beforeShow');
1142
+
1143
+ // Set scrolling before calculating dimensions
1144
+ current.inner.css('overflow', scrolling === 'yes' ? 'scroll' : (scrolling === 'no' ? 'hidden' : scrolling));
1145
+
1146
+ // Set initial dimensions and start position
1147
+ F._setDimension();
1148
+
1149
+ F.reposition();
1150
+
1151
+ F.isOpen = false;
1152
+ F.coming = null;
1153
+
1154
+ F.bindEvents();
1155
+
1156
+ if (!F.isOpened) {
1157
+ $('.fancybox-wrap').not( current.wrap ).stop(true).trigger('onReset').remove();
1158
+
1159
+ } else if (previous.prevMethod) {
1160
+ F.transitions[ previous.prevMethod ]();
1161
+ }
1162
+
1163
+ F.transitions[ F.isOpened ? current.nextMethod : current.openMethod ]();
1164
+
1165
+ F._preloadImages();
1166
+ },
1167
+
1168
+ _setDimension: function () {
1169
+ var viewport = F.getViewport(),
1170
+ steps = 0,
1171
+ canShrink = false,
1172
+ canExpand = false,
1173
+ wrap = F.wrap,
1174
+ skin = F.skin,
1175
+ inner = F.inner,
1176
+ current = F.current,
1177
+ width = current.width,
1178
+ height = current.height,
1179
+ minWidth = current.minWidth,
1180
+ minHeight = current.minHeight,
1181
+ maxWidth = current.maxWidth,
1182
+ maxHeight = current.maxHeight,
1183
+ scrolling = current.scrolling,
1184
+ scrollOut = current.scrollOutside ? current.scrollbarWidth : 0,
1185
+ margin = current.margin,
1186
+ wMargin = getScalar(margin[1] + margin[3]),
1187
+ hMargin = getScalar(margin[0] + margin[2]),
1188
+ wPadding,
1189
+ hPadding,
1190
+ wSpace,
1191
+ hSpace,
1192
+ origWidth,
1193
+ origHeight,
1194
+ origMaxWidth,
1195
+ origMaxHeight,
1196
+ ratio,
1197
+ width_,
1198
+ height_,
1199
+ maxWidth_,
1200
+ maxHeight_,
1201
+ iframe,
1202
+ body;
1203
+
1204
+ // Reset dimensions so we could re-check actual size
1205
+ wrap.add(skin).add(inner).width('auto').height('auto').removeClass('fancybox-tmp');
1206
+
1207
+ wPadding = getScalar(skin.outerWidth(true) - skin.width());
1208
+ hPadding = getScalar(skin.outerHeight(true) - skin.height());
1209
+
1210
+ // Any space between content and viewport (margin, padding, border, title)
1211
+ wSpace = wMargin + wPadding;
1212
+ hSpace = hMargin + hPadding;
1213
+
1214
+ origWidth = isPercentage(width) ? (viewport.w - wSpace) * getScalar(width) / 100 : width;
1215
+ origHeight = isPercentage(height) ? (viewport.h - hSpace) * getScalar(height) / 100 : height;
1216
+
1217
+ if (current.type === 'iframe') {
1218
+ iframe = current.content;
1219
+
1220
+ if (current.autoHeight && iframe.data('ready') === 1) {
1221
+ try {
1222
+ if (iframe[0].contentWindow.document.location) {
1223
+ inner.width( origWidth ).height(9999);
1224
+
1225
+ body = iframe.contents().find('body');
1226
+
1227
+ if (scrollOut) {
1228
+ body.css('overflow-x', 'hidden');
1229
+ }
1230
+
1231
+ origHeight = body.outerHeight(true);
1232
+ }
1233
+
1234
+ } catch (e) {}
1235
+ }
1236
+
1237
+ } else if (current.autoWidth || current.autoHeight) {
1238
+ inner.addClass( 'fancybox-tmp' );
1239
+
1240
+ // Set width or height in case we need to calculate only one dimension
1241
+ if (!current.autoWidth) {
1242
+ inner.width( origWidth );
1243
+ }
1244
+
1245
+ if (!current.autoHeight) {
1246
+ inner.height( origHeight );
1247
+ }
1248
+
1249
+ if (current.autoWidth) {
1250
+ origWidth = inner.width();
1251
+ }
1252
+
1253
+ if (current.autoHeight) {
1254
+ origHeight = inner.height();
1255
+ }
1256
+
1257
+ inner.removeClass( 'fancybox-tmp' );
1258
+ }
1259
+
1260
+ width = getScalar( origWidth );
1261
+ height = getScalar( origHeight );
1262
+
1263
+ ratio = origWidth / origHeight;
1264
+
1265
+ // Calculations for the content
1266
+ minWidth = getScalar(isPercentage(minWidth) ? getScalar(minWidth, 'w') - wSpace : minWidth);
1267
+ maxWidth = getScalar(isPercentage(maxWidth) ? getScalar(maxWidth, 'w') - wSpace : maxWidth);
1268
+
1269
+ minHeight = getScalar(isPercentage(minHeight) ? getScalar(minHeight, 'h') - hSpace : minHeight);
1270
+ maxHeight = getScalar(isPercentage(maxHeight) ? getScalar(maxHeight, 'h') - hSpace : maxHeight);
1271
+
1272
+ // These will be used to determine if wrap can fit in the viewport
1273
+ origMaxWidth = maxWidth;
1274
+ origMaxHeight = maxHeight;
1275
+
1276
+ if (current.fitToView) {
1277
+ maxWidth = Math.min(viewport.w - wSpace, maxWidth);
1278
+ maxHeight = Math.min(viewport.h - hSpace, maxHeight);
1279
+ }
1280
+
1281
+ maxWidth_ = viewport.w - wMargin;
1282
+ maxHeight_ = viewport.h - hMargin;
1283
+
1284
+ if (current.aspectRatio) {
1285
+ if (width > maxWidth) {
1286
+ width = maxWidth;
1287
+ height = getScalar(width / ratio);
1288
+ }
1289
+
1290
+ if (height > maxHeight) {
1291
+ height = maxHeight;
1292
+ width = getScalar(height * ratio);
1293
+ }
1294
+
1295
+ if (width < minWidth) {
1296
+ width = minWidth;
1297
+ height = getScalar(width / ratio);
1298
+ }
1299
+
1300
+ if (height < minHeight) {
1301
+ height = minHeight;
1302
+ width = getScalar(height * ratio);
1303
+ }
1304
+
1305
+ } else {
1306
+ width = Math.max(minWidth, Math.min(width, maxWidth));
1307
+
1308
+ if (current.autoHeight && current.type !== 'iframe') {
1309
+ inner.width( width );
1310
+
1311
+ height = inner.height();
1312
+ }
1313
+
1314
+ height = Math.max(minHeight, Math.min(height, maxHeight));
1315
+ }
1316
+
1317
+ // Try to fit inside viewport (including the title)
1318
+ if (current.fitToView) {
1319
+ inner.width( width ).height( height );
1320
+
1321
+ wrap.width( width + wPadding );
1322
+
1323
+ // Real wrap dimensions
1324
+ width_ = wrap.width();
1325
+ height_ = wrap.height();
1326
+
1327
+ if (current.aspectRatio) {
1328
+ while ((width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight) {
1329
+ if (steps++ > 19) {
1330
+ break;
1331
+ }
1332
+
1333
+ height = Math.max(minHeight, Math.min(maxHeight, height - 10));
1334
+ width = getScalar(height * ratio);
1335
+
1336
+ if (width < minWidth) {
1337
+ width = minWidth;
1338
+ height = getScalar(width / ratio);
1339
+ }
1340
+
1341
+ if (width > maxWidth) {
1342
+ width = maxWidth;
1343
+ height = getScalar(width / ratio);
1344
+ }
1345
+
1346
+ inner.width( width ).height( height );
1347
+
1348
+ wrap.width( width + wPadding );
1349
+
1350
+ width_ = wrap.width();
1351
+ height_ = wrap.height();
1352
+ }
1353
+
1354
+ } else {
1355
+ width = Math.max(minWidth, Math.min(width, width - (width_ - maxWidth_)));
1356
+ height = Math.max(minHeight, Math.min(height, height - (height_ - maxHeight_)));
1357
+ }
1358
+ }
1359
+
1360
+ if (scrollOut && scrolling === 'auto' && height < origHeight && (width + wPadding + scrollOut) < maxWidth_) {
1361
+ width += scrollOut;
1362
+ }
1363
+
1364
+ inner.width( width ).height( height );
1365
+
1366
+ wrap.width( width + wPadding );
1367
+
1368
+ width_ = wrap.width();
1369
+ height_ = wrap.height();
1370
+
1371
+ canShrink = (width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight;
1372
+ canExpand = current.aspectRatio ? (width < origMaxWidth && height < origMaxHeight && width < origWidth && height < origHeight) : ((width < origMaxWidth || height < origMaxHeight) && (width < origWidth || height < origHeight));
1373
+
1374
+ $.extend(current, {
1375
+ dim : {
1376
+ width : getValue( width_ ),
1377
+ height : getValue( height_ )
1378
+ },
1379
+ origWidth : origWidth,
1380
+ origHeight : origHeight,
1381
+ canShrink : canShrink,
1382
+ canExpand : canExpand,
1383
+ wPadding : wPadding,
1384
+ hPadding : hPadding,
1385
+ wrapSpace : height_ - skin.outerHeight(true),
1386
+ skinSpace : skin.height() - height
1387
+ });
1388
+
1389
+ if (!iframe && current.autoHeight && height > minHeight && height < maxHeight && !canExpand) {
1390
+ inner.height('auto');
1391
+ }
1392
+ },
1393
+
1394
+ _getPosition: function (onlyAbsolute) {
1395
+ var current = F.current,
1396
+ viewport = F.getViewport(),
1397
+ margin = current.margin,
1398
+ width = F.wrap.width() + margin[1] + margin[3],
1399
+ height = F.wrap.height() + margin[0] + margin[2],
1400
+ rez = {
1401
+ position: 'absolute',
1402
+ top : margin[0],
1403
+ left : margin[3]
1404
+ };
1405
+
1406
+ if (current.autoCenter && current.fixed && !onlyAbsolute && height <= viewport.h && width <= viewport.w) {
1407
+ rez.position = 'fixed';
1408
+
1409
+ } else if (!current.locked) {
1410
+ rez.top += viewport.y;
1411
+ rez.left += viewport.x;
1412
+ }
1413
+
1414
+ rez.top = getValue(Math.max(rez.top, rez.top + ((viewport.h - height) * current.topRatio)));
1415
+ rez.left = getValue(Math.max(rez.left, rez.left + ((viewport.w - width) * current.leftRatio)));
1416
+
1417
+ return rez;
1418
+ },
1419
+
1420
+ _afterZoomIn: function () {
1421
+ var current = F.current;
1422
+
1423
+ if (!current) {
1424
+ return;
1425
+ }
1426
+
1427
+ F.isOpen = F.isOpened = true;
1428
+
1429
+ F.wrap.css('overflow', 'visible').addClass('fancybox-opened');
1430
+
1431
+ F.update();
1432
+
1433
+ // Assign a click event
1434
+ if ( current.closeClick || (current.nextClick && F.group.length > 1) ) {
1435
+ F.inner.css('cursor', 'pointer').bind('click.fb', function(e) {
1436
+ if (!$(e.target).is('a') && !$(e.target).parent().is('a')) {
1437
+ e.preventDefault();
1438
+
1439
+ F[ current.closeClick ? 'close' : 'next' ]();
1440
+ }
1441
+ });
1442
+ }
1443
+
1444
+ // Create a close button
1445
+ if (current.closeBtn) {
1446
+ $(current.tpl.closeBtn).appendTo(F.skin).bind('click.fb', function(e) {
1447
+ e.preventDefault();
1448
+
1449
+ F.close();
1450
+ });
1451
+ }
1452
+
1453
+ // Create navigation arrows
1454
+ if (current.arrows && F.group.length > 1) {
1455
+ if (current.loop || current.index > 0) {
1456
+ $(current.tpl.prev).appendTo(F.outer).bind('click.fb', F.prev);
1457
+ }
1458
+
1459
+ if (current.loop || current.index < F.group.length - 1) {
1460
+ $(current.tpl.next).appendTo(F.outer).bind('click.fb', F.next);
1461
+ }
1462
+ }
1463
+
1464
+ F.trigger('afterShow');
1465
+
1466
+ // Stop the slideshow if this is the last item
1467
+ if (!current.loop && current.index === current.group.length - 1) {
1468
+ F.play( false );
1469
+
1470
+ } else if (F.opts.autoPlay && !F.player.isActive) {
1471
+ F.opts.autoPlay = false;
1472
+
1473
+ F.play();
1474
+ }
1475
+ },
1476
+
1477
+ _afterZoomOut: function ( obj ) {
1478
+ obj = obj || F.current;
1479
+
1480
+ $('.fancybox-wrap').trigger('onReset').remove();
1481
+
1482
+ $.extend(F, {
1483
+ group : {},
1484
+ opts : {},
1485
+ router : false,
1486
+ current : null,
1487
+ isActive : false,
1488
+ isOpened : false,
1489
+ isOpen : false,
1490
+ isClosing : false,
1491
+ wrap : null,
1492
+ skin : null,
1493
+ outer : null,
1494
+ inner : null
1495
+ });
1496
+
1497
+ F.trigger('afterClose', obj);
1498
+ }
1499
+ });
1500
+
1501
+ /*
1502
+ * Default transitions
1503
+ */
1504
+
1505
+ F.transitions = {
1506
+ getOrigPosition: function () {
1507
+ var current = F.current,
1508
+ element = current.element,
1509
+ orig = current.orig,
1510
+ pos = {},
1511
+ width = 50,
1512
+ height = 50,
1513
+ hPadding = current.hPadding,
1514
+ wPadding = current.wPadding,
1515
+ viewport = F.getViewport();
1516
+
1517
+ if (!orig && current.isDom && element.is(':visible')) {
1518
+ orig = element.find('img:first');
1519
+
1520
+ if (!orig.length) {
1521
+ orig = element;
1522
+ }
1523
+ }
1524
+
1525
+ if (isQuery(orig)) {
1526
+ pos = orig.offset();
1527
+
1528
+ if (orig.is('img')) {
1529
+ width = orig.outerWidth();
1530
+ height = orig.outerHeight();
1531
+ }
1532
+
1533
+ } else {
1534
+ pos.top = viewport.y + (viewport.h - height) * current.topRatio;
1535
+ pos.left = viewport.x + (viewport.w - width) * current.leftRatio;
1536
+ }
1537
+
1538
+ if (F.wrap.css('position') === 'fixed' || current.locked) {
1539
+ pos.top -= viewport.y;
1540
+ pos.left -= viewport.x;
1541
+ }
1542
+
1543
+ pos = {
1544
+ top : getValue(pos.top - hPadding * current.topRatio),
1545
+ left : getValue(pos.left - wPadding * current.leftRatio),
1546
+ width : getValue(width + wPadding),
1547
+ height : getValue(height + hPadding)
1548
+ };
1549
+
1550
+ return pos;
1551
+ },
1552
+
1553
+ step: function (now, fx) {
1554
+ var ratio,
1555
+ padding,
1556
+ value,
1557
+ prop = fx.prop,
1558
+ current = F.current,
1559
+ wrapSpace = current.wrapSpace,
1560
+ skinSpace = current.skinSpace;
1561
+
1562
+ if (prop === 'width' || prop === 'height') {
1563
+ ratio = fx.end === fx.start ? 1 : (now - fx.start) / (fx.end - fx.start);
1564
+
1565
+ if (F.isClosing) {
1566
+ ratio = 1 - ratio;
1567
+ }
1568
+
1569
+ padding = prop === 'width' ? current.wPadding : current.hPadding;
1570
+ value = now - padding;
1571
+
1572
+ F.skin[ prop ]( getScalar( prop === 'width' ? value : value - (wrapSpace * ratio) ) );
1573
+ F.inner[ prop ]( getScalar( prop === 'width' ? value : value - (wrapSpace * ratio) - (skinSpace * ratio) ) );
1574
+ }
1575
+ },
1576
+
1577
+ zoomIn: function () {
1578
+ var current = F.current,
1579
+ startPos = current.pos,
1580
+ effect = current.openEffect,
1581
+ elastic = effect === 'elastic',
1582
+ endPos = $.extend({opacity : 1}, startPos);
1583
+
1584
+ // Remove "position" property that breaks older IE
1585
+ delete endPos.position;
1586
+
1587
+ if (elastic) {
1588
+ startPos = this.getOrigPosition();
1589
+
1590
+ if (current.openOpacity) {
1591
+ startPos.opacity = 0.1;
1592
+ }
1593
+
1594
+ } else if (effect === 'fade') {
1595
+ startPos.opacity = 0.1;
1596
+ }
1597
+
1598
+ F.wrap.css(startPos).animate(endPos, {
1599
+ duration : effect === 'none' ? 0 : current.openSpeed,
1600
+ easing : current.openEasing,
1601
+ step : elastic ? this.s