SKYBOZ456 - Version 1.2.2

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.2
Comparing to
See all releases


Code changes from version 1.2.1 to 1.2.2

app/code/community/Skybox/Catalog/Block/Product/List.php CHANGED
@@ -195,12 +195,19 @@ class Skybox_Catalog_Block_Product_List extends Mage_Catalog_Block_Product_List
195
196
$start = microtime(true);
197
$resultObjectMultiCurl = $this->file_multi_get_contents_curl($skyBoxUrlClient, $dataJson);
198
//var_export($resultObjectMultiCurl);
199
$time_elapsed_secs = microtime(true) - $start;
200
- /*echo "<div style='position: absolute;
201
background: lightgreen;
202
font-weight: bolder;
203
- z-index: 1111;'>Tiempo de respuesta (Multiple): {$time_elapsed_secs}</div>"."<br/>";*/
204
205
$dataMultiCurl = array();
206
$resultObjectMultiCurl = json_decode($resultObjectMultiCurl);
@@ -210,13 +217,18 @@ z-index: 1111;'>Tiempo de respuesta (Multiple): {$time_elapsed_secs}</div>"."<br
210
$dataMultiCurl[$value["HtmlObjectId"]] = $this->getTemplateServicio($value, $template);
211
}
212
213
- /*$dataMultiCurlVal = array();
214
$cont = 0;
215
foreach($products as $key => $prod) {
216
$dataMultiCurlVal[$prod->getId()] = $dataMultiCurl[$cont];
217
$cont++;
218
- }*/
219
$session->setData("skyBox", $dataMultiCurl);
220
/*end Load all product of catalog*/
221
222
195
196
$start = microtime(true);
197
$resultObjectMultiCurl = $this->file_multi_get_contents_curl($skyBoxUrlClient, $dataJson);
198
+
199
//var_export($resultObjectMultiCurl);
200
+
201
+ /**
202
+ * Only works to async version start
203
+ */
204
+ /*
205
$time_elapsed_secs = microtime(true) - $start;
206
+ echo "<div style='position: absolute;
207
background: lightgreen;
208
font-weight: bolder;
209
+ z-index: 1111;'>Tiempo de respuesta (Multiple): {$time_elapsed_secs}</div>"."<br/>";
210
+
211
212
$dataMultiCurl = array();
213
$resultObjectMultiCurl = json_decode($resultObjectMultiCurl);
217
$dataMultiCurl[$value["HtmlObjectId"]] = $this->getTemplateServicio($value, $template);
218
}
219
220
+ $dataMultiCurlVal = array();
221
$cont = 0;
222
foreach($products as $key => $prod) {
223
$dataMultiCurlVal[$prod->getId()] = $dataMultiCurl[$cont];
224
$cont++;
225
+ }
226
$session->setData("skyBox", $dataMultiCurl);
227
+ */
228
+ /**
229
+ * Only works to async version end
230
+ */
231
+
232
/*end Load all product of catalog*/
233
234
app/code/community/Skybox/Catalog/Block/Product/Price.php CHANGED
@@ -76,15 +76,16 @@ class Skybox_Catalog_Block_Product_Price extends Mage_Catalog_Block_Product_Pric
76
*/
77
public function _toHtml()
78
{
79
// $activation = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
80
$activation = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
81
82
if (!$activation) {
83
return '';
84
}
85
- $typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
86
//Mage::log(print_r('product\Price::_toHtml', true), null, 'tracer.log', true);
87
- if($this->_getApi()->getLocationAllow() && ($typeIntegration!=3)){ // Rogged
88
if ($this->_getApi()->getErrorAuthenticate() && !$this->_getApi()->getLocationAllow() && $this->_getApi()->HasError()) {
89
return '';
90
} elseif ($this->_getApi()->HasError()) {
76
*/
77
public function _toHtml()
78
{
79
+ //echo "locationAllow: ".$this->_getApi()->getLocationAllow();
80
// $activation = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
81
$activation = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
82
83
if (!$activation) {
84
return '';
85
}
86
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
87
//Mage::log(print_r('product\Price::_toHtml', true), null, 'tracer.log', true);
88
+ if($this->_getApi()->getLocationAllow() && ($typeIntegration!=3)) { // Rogged
89
if ($this->_getApi()->getErrorAuthenticate() && !$this->_getApi()->getLocationAllow() && $this->_getApi()->HasError()) {
90
return '';
91
} elseif ($this->_getApi()->HasError()) {
app/code/community/Skybox/Catalog/Model/Api/Product.php CHANGED
@@ -93,7 +93,7 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
93
$finalPrice = isset($finalPrice) ? $finalPrice : $product->getFinalPrice();
94
$category_id = $product->getSkyboxCategoryId();
95
$category_id = isset($category_id) ? $product->getSkyboxCategoryId() : 0;
96
- $volWeight = !empty(trim($product->getDimensionalWeight()))?$product->getDimensionalWeight():0;
97
98
$_data = array(
99
'object_id' => 1,
@@ -101,7 +101,7 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
101
'sku' => $product->getSku(),
102
'category_id' => $category_id,
103
'final_price' => $finalPrice,
104
- 'weight' => ($product->getWeight())?$product->getWeight():1,
105
'image_url' => $product->getImageUrl(),
106
'typeProduct' => $type,
107
'VolWeight' => $volWeight,
@@ -179,7 +179,7 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
179
*/
180
/* Weight end*/
181
182
- $volWeight = !empty(trim($product->getDimensionalWeight()))?$product->getDimensionalWeight():0;
183
$_data = array(
184
'object_id' => 1,
185
'name' => $product->getName(),
@@ -187,7 +187,7 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
187
'sku' => $sku,
188
'category_id' => $product->getSkyboxCategoryId(),
189
'final_price' => $finalPrice,
190
- 'weight' => $weight?$weight:1,
191
'image_url' => $product->getImageUrl(),
192
'typeProduct' => $type,
193
'VolWeight' => $volWeight,
@@ -242,14 +242,17 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
242
//Mage::log("weight: " . $weight, null, 'cart.log', true);
243
//Mage::log("sku: " . $sku, null, 'cart.log', true);
244
245
- $volWeight = !empty(trim($product->getDimensionalWeight()))?$product->getDimensionalWeight():0;
246
$_data = array(
247
'object_id' => 1,
248
'name' => $product->getName(),
249
'sku' => $sku,
250
- 'category_id' => $product->getSkyboxCategoryId(),
251
'final_price' => $finalPrice,
252
- 'weight' => ($weight)?$weight:1,
253
'image_url' => $product->getImageUrl(),
254
'typeProduct' => $type,
255
'VolWeight' => $volWeight,
@@ -302,14 +305,14 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
302
Mage::log("weight: " . $weight, null, 'cart.log', true);
303
Mage::log("sku: " . $sku, null, 'cart.log', true);*/
304
305
- $volWeight = !empty(trim($product->getDimensionalWeight()))?$product->getDimensionalWeight():0;
306
$_data = array(
307
'object_id' => 1,
308
'name' => $product->getName(),
309
'sku' => $sku,
310
'category_id' => $skyboxCategoryId,
311
'final_price' => $finalPrice,
312
- 'weight' => ($weight)?$weight:1,
313
'image_url' => $product->getImageUrl(),
314
'typeProduct' => $type,
315
'VolWeight' => $volWeight,
@@ -326,10 +329,10 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
326
break;
327
}
328
329
- if(!$defaultSwitch){
330
//Mage::log(print_r('EnableTax: ', true), null, 'tracer.log', true);
331
//Mage::log(print_r($this->getEnabledAddSumTaxToPrice(), true), null, 'tracer.log', true);
332
- if($this->getEnabledAddSumTaxToPrice()) {
333
$store = Mage::app()->getStore('default');
334
$taxCalculation = Mage::getModel('tax/calculation');
335
$request = $taxCalculation->getRateRequest(null, null, null, $store);
@@ -393,7 +396,7 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
393
'storeproductcategory' => $data['category_id'],
394
'storeproductprice' => $data['final_price'],
395
//'storeproductprice' => $product->getFinalPrice(),
396
- 'weight' => ($data['weight'])?$data['weight']:1,
397
'weightunit' => $this->getWeightUnit(),
398
'storeproductimgurl' => $data['image_url'],
399
'merchantproductid' => $data['merchantproductid']
@@ -420,7 +423,7 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
420
{
421
Mage::log("ApiProduct ", null, 'orden.log', true);
422
if (!$this->getErrorAuthenticate() && $this->_getApi()->getLocationAllow() && !$this->_getApi()->ErrorServiceNotController()) {
423
- //if (!$this->getErrorAuthenticate() && $this->_getApi()->getLocationAllow() && !$this->_getApi()->ErrorService()) {
424
$_productResult = $this->getResponse();
425
$template = $_productResult->TooltipButtonTemplate;
426
return $template;
@@ -577,8 +580,8 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
577
case 'simple':
578
$finalPrice = isset($finalPrice) ? $finalPrice : $product->getFinalPrice();
579
$category_id = $product->getSkyboxCategoryId();
580
- $category_id = isset($category_id) ? $product->getSkyboxCategoryId() : 0;
581
- $volWeight = !empty(trim($product->getDimensionalWeight()))?$product->getDimensionalWeight():0;
582
583
$_data = array(
584
'object_id' => $product->getId(),
@@ -586,7 +589,7 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
586
'sku' => $product->getSku(),
587
'category_id' => $category_id,
588
'final_price' => $finalPrice,
589
- 'weight' => ($product->getWeight())?$product->getWeight():1,
590
'image_url' => $product->getImageUrl(),
591
'typeProduct' => $type,
592
'VolWeight' => $volWeight,
@@ -638,15 +641,19 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
638
Mage::log("CalculatePrice candidate FIN", null, 'skyboxcheckout.log', false);
639
}
640
641
- $volWeight = !empty(trim($product->getDimensionalWeight()))?$product->getDimensionalWeight():0;
642
$_data = array(
643
'object_id' => $product->getId(),
644
'name' => $product->getName(),
645
//'sku' => $product->getSku(),
646
'sku' => $sku,
647
- 'category_id' => $product->getSkyboxCategoryId(),
648
'final_price' => $finalPrice,
649
- 'weight' => $weight?$weight:1,
650
'image_url' => $product->getImageUrl(),
651
'typeProduct' => $type,
652
'VolWeight' => $volWeight,
@@ -701,14 +708,14 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
701
//Mage::log("weight: " . $weight, null, 'cart.log', true);
702
//Mage::log("sku: " . $sku, null, 'cart.log', true);
703
704
- $volWeight = !empty(trim($product->getDimensionalWeight()))?$product->getDimensionalWeight():0;
705
$_data = array(
706
'object_id' => $product->getId(),
707
'name' => $product->getName(),
708
'sku' => $sku,
709
'category_id' => $product->getSkyboxCategoryId(),
710
'final_price' => $finalPrice,
711
- 'weight' => ($weight)?$weight:1,
712
'image_url' => $product->getImageUrl(),
713
'typeProduct' => $type,
714
'VolWeight' => $volWeight,
@@ -761,14 +768,14 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
761
Mage::log("weight: " . $weight, null, 'cart.log', true);
762
Mage::log("sku: " . $sku, null, 'cart.log', true);*/
763
764
- $volWeight = !empty(trim($product->getDimensionalWeight()))?$product->getDimensionalWeight():0;
765
$_data = array(
766
'object_id' => $product->getId(),
767
'name' => $product->getName(),
768
'sku' => $sku,
769
'category_id' => $skyboxCategoryId,
770
'final_price' => $finalPrice,
771
- 'weight' => ($weight)?$weight:1,
772
'image_url' => $product->getImageUrl(),
773
'typeProduct' => $type,
774
'VolWeight' => $volWeight,
@@ -785,10 +792,10 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
785
break;
786
}
787
788
- if(!$defaultSwitch){
789
//Mage::log(print_r('EnableTax: ', true), null, 'tracer.log', true);
790
//Mage::log(print_r($this->getEnabledAddSumTaxToPrice(), true), null, 'tracer.log', true);
791
- if($this->getEnabledAddSumTaxToPrice()) {
792
$store = Mage::app()->getStore('default');
793
$taxCalculation = Mage::getModel('tax/calculation');
794
$request = $taxCalculation->getRateRequest(null, null, null, $store);
@@ -830,6 +837,25 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
830
return $data;
831
}
832
833
private function _callServiceSky($data)
834
{
835
$msg = sprintf("CalculatePrice: [%s] - [%s] - [%s] - [Category_id: %s] - [Price: %s] - [weight: %s] - [typeProduct: %s]",
@@ -849,7 +875,7 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
849
'category' => $data['category_id'],
850
'price' => $data['final_price'],
851
//'storeproductprice' => $product->getFinalPrice(),
852
- 'weight' => ($data['weight'])?$data['weight']:1,
853
'weightunit' => $this->getWeightUnit(),
854
'imgurl' => $data['image_url'],
855
/*'volweight' => $data['VolWeight'],
93
$finalPrice = isset($finalPrice) ? $finalPrice : $product->getFinalPrice();
94
$category_id = $product->getSkyboxCategoryId();
95
$category_id = isset($category_id) ? $product->getSkyboxCategoryId() : 0;
96
+ $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
97
98
$_data = array(
99
'object_id' => 1,
101
'sku' => $product->getSku(),
102
'category_id' => $category_id,
103
'final_price' => $finalPrice,
104
+ 'weight' => ($product->getWeight()) ? $product->getWeight() : 1,
105
'image_url' => $product->getImageUrl(),
106
'typeProduct' => $type,
107
'VolWeight' => $volWeight,
179
*/
180
/* Weight end*/
181
182
+ $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
183
$_data = array(
184
'object_id' => 1,
185
'name' => $product->getName(),
187
'sku' => $sku,
188
'category_id' => $product->getSkyboxCategoryId(),
189
'final_price' => $finalPrice,
190
+ 'weight' => $weight ? $weight : 1,
191
'image_url' => $product->getImageUrl(),
192
'typeProduct' => $type,
193
'VolWeight' => $volWeight,
242
//Mage::log("weight: " . $weight, null, 'cart.log', true);
243
//Mage::log("sku: " . $sku, null, 'cart.log', true);
244
245
+ $category_id = $product->getSkyboxCategoryId();
246
+ $category_id = isset($category_id) ? $product->getSkyboxCategoryId() : $this->getCommodityFromCategory();
247
+
248
+ $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
249
$_data = array(
250
'object_id' => 1,
251
'name' => $product->getName(),
252
'sku' => $sku,
253
+ 'category_id' => $category_id,
254
'final_price' => $finalPrice,
255
+ 'weight' => ($weight) ? $weight : 1,
256
'image_url' => $product->getImageUrl(),
257
'typeProduct' => $type,
258
'VolWeight' => $volWeight,
305
Mage::log("weight: " . $weight, null, 'cart.log', true);
306
Mage::log("sku: " . $sku, null, 'cart.log', true);*/
307
308
+ $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
309
$_data = array(
310
'object_id' => 1,
311
'name' => $product->getName(),
312
'sku' => $sku,
313
'category_id' => $skyboxCategoryId,
314
'final_price' => $finalPrice,
315
+ 'weight' => ($weight) ? $weight : 1,
316
'image_url' => $product->getImageUrl(),
317
'typeProduct' => $type,
318
'VolWeight' => $volWeight,
329
break;
330
}
331
332
+ if (!$defaultSwitch) {
333
//Mage::log(print_r('EnableTax: ', true), null, 'tracer.log', true);
334
//Mage::log(print_r($this->getEnabledAddSumTaxToPrice(), true), null, 'tracer.log', true);
335
+ if ($this->getEnabledAddSumTaxToPrice()) {
336
$store = Mage::app()->getStore('default');
337
$taxCalculation = Mage::getModel('tax/calculation');
338
$request = $taxCalculation->getRateRequest(null, null, null, $store);
396
'storeproductcategory' => $data['category_id'],
397
'storeproductprice' => $data['final_price'],
398
//'storeproductprice' => $product->getFinalPrice(),
399
+ 'weight' => ($data['weight']) ? $data['weight'] : 1,
400
'weightunit' => $this->getWeightUnit(),
401
'storeproductimgurl' => $data['image_url'],
402
'merchantproductid' => $data['merchantproductid']
423
{
424
Mage::log("ApiProduct ", null, 'orden.log', true);
425
if (!$this->getErrorAuthenticate() && $this->_getApi()->getLocationAllow() && !$this->_getApi()->ErrorServiceNotController()) {
426
+ //if (!$this->getErrorAuthenticate() && $this->_getApi()->getLocationAllow() && !$this->_getApi()->ErrorService()) {
427
$_productResult = $this->getResponse();
428
$template = $_productResult->TooltipButtonTemplate;
429
return $template;
580
case 'simple':
581
$finalPrice = isset($finalPrice) ? $finalPrice : $product->getFinalPrice();
582
$category_id = $product->getSkyboxCategoryId();
583
+ $category_id = isset($category_id) ? $product->getSkyboxCategoryId() : $this->getCommodityFromCategory();
584
+ $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
585
586
$_data = array(
587
'object_id' => $product->getId(),
589
'sku' => $product->getSku(),
590
'category_id' => $category_id,
591
'final_price' => $finalPrice,
592
+ 'weight' => ($product->getWeight()) ? $product->getWeight() : 1,
593
'image_url' => $product->getImageUrl(),
594
'typeProduct' => $type,
595
'VolWeight' => $volWeight,
641
Mage::log("CalculatePrice candidate FIN", null, 'skyboxcheckout.log', false);
642
}
643
644
+ $category_id = $product->getSkyboxCategoryId();
645
+ $category_id = isset($category_id) ? $product->getSkyboxCategoryId() : $this->getCommodityFromCategory();
646
+
647
+ $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
648
+
649
$_data = array(
650
'object_id' => $product->getId(),
651
'name' => $product->getName(),
652
//'sku' => $product->getSku(),
653
'sku' => $sku,
654
+ 'category_id' => $category_id,
655
'final_price' => $finalPrice,
656
+ 'weight' => $weight ? $weight : 1,
657
'image_url' => $product->getImageUrl(),
658
'typeProduct' => $type,
659
'VolWeight' => $volWeight,
708
//Mage::log("weight: " . $weight, null, 'cart.log', true);
709
//Mage::log("sku: " . $sku, null, 'cart.log', true);
710
711
+ $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
712
$_data = array(
713
'object_id' => $product->getId(),
714
'name' => $product->getName(),
715
'sku' => $sku,
716
'category_id' => $product->getSkyboxCategoryId(),
717
'final_price' => $finalPrice,
718
+ 'weight' => ($weight) ? $weight : 1,
719
'image_url' => $product->getImageUrl(),
720
'typeProduct' => $type,
721
'VolWeight' => $volWeight,
768
Mage::log("weight: " . $weight, null, 'cart.log', true);
769
Mage::log("sku: " . $sku, null, 'cart.log', true);*/
770
771
+ $volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
772
$_data = array(
773
'object_id' => $product->getId(),
774
'name' => $product->getName(),
775
'sku' => $sku,
776
'category_id' => $skyboxCategoryId,
777
'final_price' => $finalPrice,
778
+ 'weight' => ($weight) ? $weight : 1,
779
'image_url' => $product->getImageUrl(),
780
'typeProduct' => $type,
781
'VolWeight' => $volWeight,
792
break;
793
}
794
795
+ if (!$defaultSwitch) {
796
//Mage::log(print_r('EnableTax: ', true), null, 'tracer.log', true);
797
//Mage::log(print_r($this->getEnabledAddSumTaxToPrice(), true), null, 'tracer.log', true);
798
+ if ($this->getEnabledAddSumTaxToPrice()) {
799
$store = Mage::app()->getStore('default');
800
$taxCalculation = Mage::getModel('tax/calculation');
801
$request = $taxCalculation->getRateRequest(null, null, null, $store);
837
return $data;
838
}
839
840
+ // @todo: need to be rewrite!!
841
+ /**
842
+ * @param $product
843
+ * @return $category_id
844
+ */
845
+ public function getCommodityFromCategory($product)
846
+ {
847
+ $categoryIds = $product->getCategoryIds();
848
+ if (count($categoryIds)) {
849
+ $firstCategoryId = $categoryIds[0];
850
+ $_category = Mage::getModel('catalog/category')->load($firstCategoryId);
851
+ $category_id = $_category->getSkyboxCategoryIdSelect();
852
+ }
853
+
854
+ $category_id = isset($category_id) ? $product->getSkyboxCategoryId() : 0;
855
+
856
+ return $category_id;
857
+ }
858
+
859
private function _callServiceSky($data)
860
{
861
$msg = sprintf("CalculatePrice: [%s] - [%s] - [%s] - [Category_id: %s] - [Price: %s] - [weight: %s] - [typeProduct: %s]",
875
'category' => $data['category_id'],
876
'price' => $data['final_price'],
877
//'storeproductprice' => $product->getFinalPrice(),
878
+ 'weight' => ($data['weight']) ? $data['weight'] : 1,
879
'weightunit' => $this->getWeightUnit(),
880
'imgurl' => $data['image_url'],
881
/*'volweight' => $data['VolWeight'],
app/code/community/Skybox/Checkout/Block/Cart/Totals.php CHANGED
@@ -67,8 +67,30 @@ class Skybox_Checkout_Block_Cart_Totals extends Mage_Checkout_Block_Cart_Abstrac
67
public function renderTotal($total, $area = null, $colspan = 1)
68
{
69
$code = $total->getCode();
70
- if($code!="subtotal") {
71
-
72
if ($total->getAs()) {
73
$code = $total->getAs();
74
}
@@ -77,7 +99,9 @@ class Skybox_Checkout_Block_Cart_Totals extends Mage_Checkout_Block_Cart_Abstrac
77
->setColspan($colspan)
78
->setRenderingArea(is_null($area) ? -1 : $area)
79
->toHtml();
80
}
81
}
82
83
/**
67
public function renderTotal($total, $area = null, $colspan = 1)
68
{
69
$code = $total->getCode();
70
+ /**
71
+ * Integration 3 start, show price shop in cart*
72
+ */
73
+ $allowRunByIntegration3 = true;
74
+ //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
75
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
76
+ if ($typeIntegration==3) {
77
+ $allowRunByIntegration3 = false;
78
+ }
79
+ /**
80
+ * Integration 3 end, show price shop in cart*
81
+ */
82
+ if($allowRunByIntegration3) {
83
+ if($code!="subtotal") {
84
+ if ($total->getAs()) {
85
+ $code = $total->getAs();
86
+ }
87
+ return $this->_getTotalRenderer($code)
88
+ ->setTotal($total)
89
+ ->setColspan($colspan)
90
+ ->setRenderingArea(is_null($area) ? -1 : $area)
91
+ ->toHtml();
92
+ }
93
+ } else {
94
if ($total->getAs()) {
95
$code = $total->getAs();
96
}
99
->setColspan($colspan)
100
->setRenderingArea(is_null($area) ? -1 : $area)
101
->toHtml();
102
+
103
}
104
+
105
}
106
107
/**
app/code/community/Skybox/Checkout/Block/Checkout/Onepage/Link.php CHANGED
@@ -8,6 +8,20 @@ class Skybox_Checkout_Block_Checkout_Onepage_Link extends Mage_Checkout_Block_On
8
// $isEnabled = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
9
$isEnabled = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
10
11
if($isEnabled) {
12
return $this->getUrl('skbcheckout/international', array('_secure'=>true));
13
}
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
}
app/code/community/Skybox/Checkout/Helper/Data.php CHANGED
@@ -33,14 +33,31 @@ class Skybox_Checkout_Helper_Data extends Mage_Checkout_Helper_Data
33
34
$config = Mage::getModel("skyboxcore/config");
35
$skybox_user = $config->getSession()->getSkyboxUser();
36
- /*LocationAllow3*/
37
- $typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
38
- if($this->_getApi()->getLocationAllow() && ($typeIntegration!=3)){ // Rogged
39
$currency = $skybox_user->CartCurrencySymbol; // Rogged
40
}else{ // Rogged
41
$currency = Mage::app()->getLocale()->currency( $currency_code )->getSymbol(); // Rogged
42
} // Rogged
43
44
//Mage::log("currency".$currency, null, 'cartlabels.log', true);
45
$price=str_replace(',', '', $price);
46
//Mage::log("precio".$price, null, 'cartlabels.log', true);
@@ -59,19 +76,25 @@ class Skybox_Checkout_Helper_Data extends Mage_Checkout_Helper_Data
59
public function getLayoutCheckoutSkybox(){ // Rogged
60
$page_layout = Mage::getStoreConfig('customize_your_own');
61
62
- /*LocationAllow3*/
63
- $active = 0;
64
- if(isset($_GET['v'])) {
65
- $active = 1;
66
- }
67
if($this->_getApi()->getLocationAllow()){
68
$page_layout = 'skybox/checkout/onepage.phtml';
69
}else{
70
$page_layout = 'checkout/onepage.phtml';
71
}
72
- if($active) {
73
$page_layout = 'checkout/onepage.phtml';
74
}
75
return $page_layout;
76
}
77
33
34
$config = Mage::getModel("skyboxcore/config");
35
$skybox_user = $config->getSession()->getSkyboxUser();
36
+ if($this->_getApi()->getLocationAllow()){ // Rogged
37
$currency = $skybox_user->CartCurrencySymbol; // Rogged
38
}else{ // Rogged
39
$currency = Mage::app()->getLocale()->currency( $currency_code )->getSymbol(); // Rogged
40
} // Rogged
41
42
+ /**
43
+ * Integration 3 Allow and not Allow start currency kind on cart
44
+ */
45
+ $request = Mage::app()->getRequest();
46
+ $module = $request->getModuleName();
47
+ $controller = $request->getControllerName();
48
+ $action = $request->getActionName();
49
+ //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
50
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
51
+
52
+ if($module == 'checkout' && $controller == 'cart' && $action == 'index') {
53
+ if ($typeIntegration==3) {
54
+ $currency = Mage::app()->getLocale()->currency( $currency_code )->getSymbol();
55
+ }
56
+ }
57
+ /**
58
+ * Integration 3 Allow and not Allow end currency kind on cart
59
+ */
60
+
61
//Mage::log("currency".$currency, null, 'cartlabels.log', true);
62
$price=str_replace(',', '', $price);
63
//Mage::log("precio".$price, null, 'cartlabels.log', true);
76
public function getLayoutCheckoutSkybox(){ // Rogged
77
$page_layout = Mage::getStoreConfig('customize_your_own');
78
79
if($this->_getApi()->getLocationAllow()){
80
$page_layout = 'skybox/checkout/onepage.phtml';
81
}else{
82
$page_layout = 'checkout/onepage.phtml';
83
}
84
+
85
+ /**
86
+ * Integration 3 start
87
+ *
88
+ */
89
+ //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
90
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
91
+ if($typeIntegration ==3 && $this->_getApi()->getLocationAllow() ==3) {
92
$page_layout = 'checkout/onepage.phtml';
93
}
94
+ /**
95
+ * Integration 3 end
96
+ */
97
+
98
return $page_layout;
99
}
100
app/code/community/Skybox/Checkout/Model/Api/Checkout.php CHANGED
@@ -46,8 +46,24 @@ class Skybox_Checkout_Model_Api_Checkout extends Skybox_Core_Model_Standard
46
'customerlanguages' => $this->_getConfig()->getLanguage()
47
);
48
49
- $response = $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_INITIALICE, $params)->getResponse();
50
-
51
// Set SkyboxUser session
52
$this->_getConfig()->getSession()->setSkyboxUser($response);
53
@@ -162,10 +178,6 @@ class Skybox_Checkout_Model_Api_Checkout extends Skybox_Core_Model_Standard
162
return "";
163
}
164
165
- public function getStoreCode() {
166
- return 77;
167
- }
168
-
169
/*
170
* Get Categories
171
*
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, 'gary.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
+ /**
65
+ * only one time for call to service end
66
+ */
67
// Set SkyboxUser session
68
$this->_getConfig()->getSession()->setSkyboxUser($response);
69
178
return "";
179
}
180
181
/*
182
* Get Categories
183
*
app/code/community/Skybox/Checkout/Model/Cart.php CHANGED
@@ -267,6 +267,129 @@ class Skybox_Checkout_Model_Cart extends Mage_Checkout_Model_Cart
267
{
268
Mage::log('pas x aqui2', null, 'minicars.log', true);
269
270
foreach ($this->getQuote()->getAllItems() as $item) {
271
272
if ($item->getProductId() == $productId) {
@@ -330,6 +453,16 @@ class Skybox_Checkout_Model_Cart extends Mage_Checkout_Model_Cart
330
*/
331
public function removeItem($itemId)
332
{
333
if (!$this->isEnable()) {
334
parent::removeItem($itemId);
335
return $this;
@@ -362,6 +495,16 @@ class Skybox_Checkout_Model_Cart extends Mage_Checkout_Model_Cart
362
*/
363
public function updateItems($data)
364
{
365
if (!$this->isEnable()) {
366
parent::updateItems($data);
367
return $this;
267
{
268
Mage::log('pas x aqui2', null, 'minicars.log', true);
269
270
+
271
+ /**
272
+ * only one time for call to service start - Active
273
+ * when do add to cart
274
+ */
275
+ $session = Mage::getSingleton("core/session", array("name"=>"frontend"));
276
+ $session->setData("callToSkyBox", true);
277
+ Mage::log("Call true: add to cart", null, 'gary.log', true);
278
+ /**
279
+ * when do add to cart end - Active
280
+ */
281
+ foreach ($this->getQuote()->getAllItems() as $item) {
282
+
283
+ if ($item->getProductId() == $productId) {
284
+
285
+ if ($item instanceof Mage_Sales_Model_Quote_Item) {
286
+ $parentItem = $item->getParentItem();
287
+ if ($parentItem) {
288
+ $item = $parentItem;
289
+ }
290
+ }
291
+ /**
292
+ * Integration 3 start, show price shop in cart*
293
+ */
294
+ $isLocationAllow = false;
295
+ //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
296
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
297
+ if ($typeIntegration==3) {
298
+ $isLocationAllow = true;
299
+ }
300
+ /**
301
+ * Integration 3 end, show price shop in cart*
302
+ */
303
+ if($isLocationAllow) {
304
+ $productModel = Mage::getModel('catalog/product')->load($productId);
305
+ $total = str_replace(",", "", $productModel->getTotalPriceUSD());
306
+ $item->setIdProductSkybox($productIdSkybox);
307
+
308
+ // Currency amounts in the default currency of that customer
309
+ $item->setCustomsSkybox($productModel->getCustoms());
310
+ $item->setShippingSkybox($productModel->getShipping());
311
+ $item->setInsuranceSkybox($productModel->getInsurance());
312
+ $item->setPriceSkybox($productModel->getPrice());
313
+ $item->setTotalSkybox($productModel->getTotalPrice());
314
+ $item->setRowTotal($total);
315
+
316
+ // Currency amounts in the USD Currency
317
+ $item->setCustomsUsdSkybox($productModel->getCustomsUSD());
318
+ $item->setShippingUsdSkybox($productModel->getShippingUSD());
319
+ $item->setInsuranceUsdSkybox($productModel->getInsuranceUSD());
320
+ $item->setPriceUsdSkybox($productModel->getPriceUSD());
321
+ $item->setTotalUsdSkybox($productModel->getTotalPriceUSD());
322
+
323
+ $item->setGuidSkybox($productModel->getGuidSkybox()); //Set GUID
324
+
325
+
326
+ $item->setBasePriceSkybox($productModel->getBasePrice());
327
+ $item->setBasePriceUsdSkybox($productModel->getBasePriceUSD());
328
+ $item->setAdjustTotalSkybox($productModel->getAdjustPrice());
329
+ $item->setAdjustTotalUsdSkybox($productModel->getAdjustPriceUSD());
330
+ $item->setAdjustLabelSkybox($productModel->getAdjustLabel());
331
+
332
+ //$item->setOriginalCustomPrice($this->_getProductApi()->getTotalPriceUSD());
333
+ //$item->setOriginalCustomPrice($total);
334
+ // $item->setOriginalCustomPrice($this->_getProductApi()->getPrice());
335
+ $prices = str_replace(',','',$productModel->getPrice());
336
+ $prices = number_format((float)($prices),2, ',', '.');
337
+ $item->setOriginalCustomPrice($prices);
338
+ //$skybox_total = str_replace(",", "", $this->_getProductApi()->getTotalPrice());
339
+ $skybox_total = str_replace(",", "", $productModel->getPrice());
340
+ $row_total = floatval($skybox_total) * $item->getQty();
341
+ $item->setRowTotalSkybox($row_total);
342
+ } else {
343
+ $total = str_replace(",", "", $this->_getProductApi()->getTotalPriceUSD());
344
+ $item->setIdProductSkybox($productIdSkybox);
345
+
346
+ // Currency amounts in the default currency of that customer
347
+ $item->setCustomsSkybox($this->_getProductApi()->getCustoms());
348
+ $item->setShippingSkybox($this->_getProductApi()->getShipping());
349
+ $item->setInsuranceSkybox($this->_getProductApi()->getInsurance());
350
+ $item->setPriceSkybox($this->_getProductApi()->getPrice());
351
+ $item->setTotalSkybox($this->_getProductApi()->getTotalPrice());
352
+ $item->setRowTotal($total);
353
+
354
+ // Currency amounts in the USD Currency
355
+ $item->setCustomsUsdSkybox($this->_getProductApi()->getCustomsUSD());
356
+ $item->setShippingUsdSkybox($this->_getProductApi()->getShippingUSD());
357
+ $item->setInsuranceUsdSkybox($this->_getProductApi()->getInsuranceUSD());
358
+ $item->setPriceUsdSkybox($this->_getProductApi()->getPriceUSD());
359
+ $item->setTotalUsdSkybox($this->_getProductApi()->getTotalPriceUSD());
360
+
361
+ $item->setGuidSkybox($this->_getProductApi()->getGuidSkybox()); //Set GUID
362
+
363
+
364
+ $item->setBasePriceSkybox($this->_getProductApi()->getBasePrice());
365
+ $item->setBasePriceUsdSkybox($this->_getProductApi()->getBasePriceUSD());
366
+ $item->setAdjustTotalSkybox($this->_getProductApi()->getAdjustPrice());
367
+ $item->setAdjustTotalUsdSkybox($this->_getProductApi()->getAdjustPriceUSD());
368
+ $item->setAdjustLabelSkybox($this->_getProductApi()->getAdjustLabel());
369
+
370
+ //$item->setOriginalCustomPrice($this->_getProductApi()->getTotalPriceUSD());
371
+ //$item->setOriginalCustomPrice($total);
372
+ // $item->setOriginalCustomPrice($this->_getProductApi()->getPrice());
373
+ $prices = str_replace(',','',$this->_getProductApi()->getPrice());
374
+ $prices = number_format((float)($prices),2, ',', '.');
375
+ $item->setOriginalCustomPrice($prices);
376
+ //$skybox_total = str_replace(",", "", $this->_getProductApi()->getTotalPrice());
377
+ $skybox_total = str_replace(",", "", $this->_getProductApi()->getPrice());
378
+ $row_total = floatval($skybox_total) * $item->getQty();
379
+ $item->setRowTotalSkybox($row_total);
380
+ }
381
+
382
+
383
+ break;
384
+ }
385
+ }
386
+
387
+ }
388
+
389
+ private function _updateQuoteItem_backup($productId, $productIdSkybox)
390
+ {
391
+ Mage::log('pas x aqui2', null, 'minicars.log', true);
392
+
393
foreach ($this->getQuote()->getAllItems() as $item) {
394
395
if ($item->getProductId() == $productId) {
453
*/
454
public function removeItem($itemId)
455
{
456
+ /**
457
+ * only one time for call to service start - Active
458
+ * when do remove
459
+ */
460
+ $session = Mage::getSingleton("core/session", array("name"=>"frontend"));
461
+ $session->setData("callToSkyBox", true);
462
+ Mage::log("Call true: remove", null, 'gary.log', true);
463
+ /**
464
+ * when do remove
465
+ */
466
if (!$this->isEnable()) {
467
parent::removeItem($itemId);
468
return $this;
495
*/
496
public function updateItems($data)
497
{
498
+ /**
499
+ * only one time for call to service start - Active
500
+ * when do remove
501
+ */
502
+ $session = Mage::getSingleton("core/session", array("name"=>"frontend"));
503
+ $session->setData("callToSkyBox", true);
504
+ Mage::log("Call true: update cart", null, 'gary.log', true);
505
+ /**
506
+ * when do remove
507
+ */
508
if (!$this->isEnable()) {
509
parent::updateItems($data);
510
return $this;
app/code/community/Skybox/Checkout/Model/Observer.php CHANGED
@@ -163,102 +163,131 @@ class Skybox_Checkout_Model_Observer
163
164
public function changeQuoteAddressSkybox(Varien_Event_Observer $observer)
165
{
166
if(!$this->isEnable()) {
167
return $this;
168
}
169
- if($this->_getApi()->getLocationAllow()){
170
- Mage::log('Observer->changeQuoteAddressSkybox : ini', null, 'TotalSales.log', true);
171
- /* $quote Mage_Sales_Model_Quote */
172
- $quote = $observer->getEvent()->getQuote();
173
174
- /* $address Mage_Sales_Model_Quote_Address */
175
- $address = $quote->getShippingAddress();
176
177
- $totals = 0;
178
- $baseTotals = 0;
179
- $totalTax=0;
180
181
- foreach ($quote->getAllItems() as $item) {
182
183
- //Estas lineas se agregaron para elimnar el Tax del Carrito
184
- /*$item->setTaxPercent(0);
185
- $item->setTaxAmount(0);
186
- $item->setBaseTaxAmount(0);
187
188
- $item->setPriceInclTax($item->getPrice());
189
- $item->setBasePriceInclTax($item->getBasePrice());
190
- $item->setBaseRowTotalInclTax($item->setBaseRowTotal());*/
191
- //------------------------------------------------------------>
192
193
- Mage::log('Observer->changeQuoteAddressSkybox->Item->getRowTotalSkybox->' . $item->getRowTotalSkybox(), null, 'TotalSales.log', true);
194
195
- $totals += $item->getRowTotalSkybox();
196
- }
197
198
- $quote->save();
199
200
- $baseTotals = $totals;
201
202
- //$totalTax1= $address->getTaxAmount();
203
204
- //Estas lineas se agregaron para elimnar el Tax del Carrito
205
- $address->setTaxAmount(0);
206
- $address->setBaseTaxAmount(0);
207
208
- $applied_taxes = array();
209
210
- $address->setAppliedTaxes($applied_taxes);
211
- //------------------------------------------------------------>
212
213
- //$address->save();
214
215
- //$totales = $address->getTotalAmount("checkout_total1");
216
217
- //$tamanio = count($totales);
218
- //for ($x=0;$x<$tamanio; $x++) Mage::log('Observer->changeQuoteAddressSkybox->total->' . $totales[$x], null, 'TotalSales.log', true);
219
220
- //Mage::log('Observer->changeQuoteAddressSkybox->totales->' . var_dump($totales["subtotal"]), null, 'TotalSales.log', true);
221
- //Mage::log('Observer->changeQuoteAddressSkybox->totales->' . $totales, null, 'TotalSales.log', true);
222
223
- $totalTax = 0; //$address->getTaxAmount(); //Comentado
224
225
- //Recorremos los conceptos agrupados (esto debe modificarse no es lo optimo)
226
- /*$conceptsSkybox = json_decode($address->getConceptsSkybox());
227
- foreach ($conceptsSkybox as $concept) {
228
- $totalTax = $totalTax + $concept->Value;
229
- }*/
230
231
- $totalRmt = 0;
232
- //Recorremos los conceptos agrupados (esto debe modificarse no es lo optimo)
233
- /*$rmtSkybox = json_decode($address->getRmtSkybox());
234
- foreach ($rmtSkybox as $rmt) {
235
- $totalRmt = $totalRmt + $rmt->Value;
236
- }*/
237
238
- //Mage::log('Observer->changeQuoteAddressSkybox->totalTax1->' . $totalTax1 . ' &totalbase->' . $baseTotals, null, 'TotalSales.log', true);
239
- //Mage::log('Observer->changeQuoteAddressSkybox->totalTax->' . $totalTax . ' &totalbase->' . $baseTotals, null, 'TotalSales.log', true);
240
241
- /*$address->setSubtotalSkybox($totals);
242
- $address->setBaseSubtotalSkybox($baseTotals);
243
- $address->setGrandTotalSkybox($totals+$totalTax);
244
- $address->setBaseGrandTotalSkybox($baseTotals+$totalTax);*/
245
246
- $baseTotals = $address->getBaseGrandTotalSkybox();
247
- $totals = $address->getGrandTotalSkybox();
248
249
- $address->setPriceInclTax($totals);
250
- $address->setBasePriceInclTax($baseTotals);
251
252
- $totals = floatval(preg_replace("/[^-0-9\.]/","",$totals));
253
- //$address->setGrandTotal($totals+$totalTax);
254
- $address->setGrandTotal($totals+$totalTax);
255
- $address->setBaseGrandTotal($baseTotals+$totalTax);
256
257
- //$address->save();
258
259
- Mage::log('Observer->changeQuoteAddressSkybox : fin', null, 'TotalSales.log', true);
260
261
return $this;
262
}
263
}
264
}
163
164
public function changeQuoteAddressSkybox(Varien_Event_Observer $observer)
165
{
166
+ /**
167
+ * only one time for call to service start - Active
168
+ * This always run when you do alter to product as change/delete product
169
+ */
170
+ //$session = Mage::getSingleton("core/session", array("name"=>"frontend"));
171
+ //$session->setData("callToSkyBox", true);
172
+
173
+ /**
174
+ * only one time for call to service end - Active
175
+ */
176
+
177
if(!$this->isEnable()) {
178
return $this;
179
}
180
181
+ /**
182
+ * Integration 3 start, show price shop in cart*
183
+ */
184
+ $allowRunByIntegration3 = true;
185
+ //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
186
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
187
+ if ($typeIntegration==3) {
188
+ $allowRunByIntegration3 = false;
189
+ }
190
+ //Mage::log("Call true22: changeQuoteAddressSkybox", null, 'gary.log', true);
191
+ /**
192
+ * Integration 3 end, show price shop in cart*
193
+ */
194
+ if($allowRunByIntegration3) {
195
+ if($this->_getApi()->getLocationAllow()){
196
+ Mage::log('Observer->changeQuoteAddressSkybox : ini', null, 'TotalSales.log', true);
197
+ /* $quote Mage_Sales_Model_Quote */
198
+ $quote = $observer->getEvent()->getQuote();
199
200
+ /* $address Mage_Sales_Model_Quote_Address */
201
+ $address = $quote->getShippingAddress();
202
203
+ $totals = 0;
204
+ $baseTotals = 0;
205
+ $totalTax=0;
206
207
+ foreach ($quote->getAllItems() as $item) {
208
209
+ //Estas lineas se agregaron para elimnar el Tax del Carrito
210
+ /*$item->setTaxPercent(0);
211
+ $item->setTaxAmount(0);
212
+ $item->setBaseTaxAmount(0);
213
214
+ $item->setPriceInclTax($item->getPrice());
215
+ $item->setBasePriceInclTax($item->getBasePrice());
216
+ $item->setBaseRowTotalInclTax($item->setBaseRowTotal());*/
217
+ //------------------------------------------------------------>
218
219
+ Mage::log('Observer->changeQuoteAddressSkybox->Item->getRowTotalSkybox->' . $item->getRowTotalSkybox(), null, 'TotalSales.log', true);
220
221
+ $totals += $item->getRowTotalSkybox();
222
+ }
223
224
+ $quote->save();
225
226
+ $baseTotals = $totals;
227
228
+ //$totalTax1= $address->getTaxAmount();
229
230
+ //Estas lineas se agregaron para elimnar el Tax del Carrito
231
+ $address->setTaxAmount(0);
232
+ $address->setBaseTaxAmount(0);
233
234
+ $applied_taxes = array();
235
236
+ $address->setAppliedTaxes($applied_taxes);
237
+ //------------------------------------------------------------>
238
239
+ //$address->save();
240
241
+ //$totales = $address->getTotalAmount("checkout_total1");
242
243
+ //$tamanio = count($totales);
244
+ //for ($x=0;$x<$tamanio; $x++) Mage::log('Observer->changeQuoteAddressSkybox->total->' . $totales[$x], null, 'TotalSales.log', true);
245
246
+ //Mage::log('Observer->changeQuoteAddressSkybox->totales->' . var_dump($totales["subtotal"]), null, 'TotalSales.log', true);
247
+ //Mage::log('Observer->changeQuoteAddressSkybox->totales->' . $totales, null, 'TotalSales.log', true);
248
249
+ $totalTax = 0; //$address->getTaxAmount(); //Comentado
250
251
+ //Recorremos los conceptos agrupados (esto debe modificarse no es lo optimo)
252
+ /*$conceptsSkybox = json_decode($address->getConceptsSkybox());
253
+ foreach ($conceptsSkybox as $concept) {
254
+ $totalTax = $totalTax + $concept->Value;
255
+ }*/
256
257
+ $totalRmt = 0;
258
+ //Recorremos los conceptos agrupados (esto debe modificarse no es lo optimo)
259
+ /*$rmtSkybox = json_decode($address->getRmtSkybox());
260
+ foreach ($rmtSkybox as $rmt) {
261
+ $totalRmt = $totalRmt + $rmt->Value;
262
+ }*/
263
264
+ //Mage::log('Observer->changeQuoteAddressSkybox->totalTax1->' . $totalTax1 . ' &totalbase->' . $baseTotals, null, 'TotalSales.log', true);
265
+ //Mage::log('Observer->changeQuoteAddressSkybox->totalTax->' . $totalTax . ' &totalbase->' . $baseTotals, null, 'TotalSales.log', true);
266
267
+ /*$address->setSubtotalSkybox($totals);
268
+ $address->setBaseSubtotalSkybox($baseTotals);
269
+ $address->setGrandTotalSkybox($totals+$totalTax);
270
+ $address->setBaseGrandTotalSkybox($baseTotals+$totalTax);*/
271
272
+ $baseTotals = $address->getBaseGrandTotalSkybox();
273
+ $totals = $address->getGrandTotalSkybox();
274
275
+ $address->setPriceInclTax($totals);
276
+ $address->setBasePriceInclTax($baseTotals);
277
278
+ $totals = floatval(preg_replace("/[^-0-9\.]/","",$totals));
279
+ //$address->setGrandTotal($totals+$totalTax);
280
+ $address->setGrandTotal($totals+$totalTax);
281
+ $address->setBaseGrandTotal($baseTotals+$totalTax);
282
283
+ //$address->save();
284
285
+ Mage::log('Observer->changeQuoteAddressSkybox : fin', null, 'TotalSales.log', true);
286
+
287
+ return $this;
288
+ }
289
return $this;
290
}
291
+
292
}
293
}
app/code/community/Skybox/Checkout/Model/Quote/Total.php CHANGED
@@ -44,153 +44,162 @@ class Skybox_Checkout_Model_Quote_Total extends Mage_Sales_Model_Quote_Address_T
44
if(!$activation) {
45
return $this;
46
}
47
- if($this->_getApi()->getLocationAllow()){ // Rogged
48
-
49
-
50
- parent::collect($address); //Comentado por verificar
51
-
52
- // Si no hay items, no hay nada que hacer
53
- $items = $this->_getAddressItems($address);
54
- if (!count($items)) {
55
- return $this;
56
- }
57
58
- $quote= $address->getQuote();
59
60
// $quote = Mage::helper('checkout/cart')->getCart()->getQuote();
61
- $shippingMethod = $quote->getShippingAddress()->getShippingMethod();
62
- if($shippingMethod){
63
- Mage::log('set shipping method null',null,'tracer.log',true);
64
- $quote->getShippingAddress()->setShippingMethod(null); //setting method to null
65
- $quote->save();
66
- }
67
68
- if(!$quote->isVirtual() && $address->getAddressType() == 'billing'){
69
- return $this;
70
- }
71
72
- //$quote->setCustomerTaxClassId(0);
73
74
- //Limpiamos los Valores de Impuestos
75
- /*$rates = array();
76
- $address->setAppliedTaxes($rates);*/
77
78
- /*--------Nuevos conceptos---------*/
79
- $totals=$this->_getApi()->GetTotalShoppingCart();
80
81
- if ($this->_getApi()->HasError()) {
82
- Mage::log("StatusCode: Error", null, 'TotalSales.log', true);
83
- return $this;
84
- }
85
86
- Mage::log("quote->address->collect : ini", null, 'TotalSales.log', true);
87
88
- //$StatusCode = $totals->getParameter('StatusCode');
89
- //$StatusCode = $totals->getParameter('StatusCode');//Comentado por estar repetido
90
91
- $Customs = $totals->getParameter('Customs');
92
- $CustomsUSD = $totals->getParameter('CustomsUSD');
93
94
- $Shipping = $totals->getParameter('Shipping');
95
- $ShippingUSD = $totals->getParameter('ShippingUSD');
96
97
- $Insurance = $totals->getParameter('Insurance');
98
- $InsuranceUSD = $totals->getParameter('InsuranceUSD');
99
100
- $Taxes = $totals->getParameter('Taxes');
101
- $TaxesUSD = $totals->getParameter('TaxesUSD');
102
103
- $Duties = $totals->getParameter('Duties');
104
- $DutiesUSD = $totals->getParameter('DutiesUSD');
105
106
- $Handling = $totals->getParameter('Handling');
107
- $HandlingUSD = $totals->getParameter('HandlingUSD');
108
109
- $Clearence = $totals->getParameter('Clearence');
110
- $ClearenceUSD = $totals->getParameter('ClearenceUSD');
111
112
- $Others = $totals->getParameter('Others');
113
- $OthersUSD = $totals->getParameter('OthersUSD');
114
115
- $Adjustment = $totals->getParameter('Adjustment');
116
- $AdjustmentUSD = $totals->getParameter('AdjustmentUSD');
117
118
- $listAdjustjson = $totals->getResponse()->{'ListDetailConcepts'};
119
120
- $listRmtjson = $totals->getResponse()->{'ListDetailAdjusts'};
121
122
- /*--------------------------------*/
123
- // Apuntamos lo que hemos calculado para usarlo luego
124
- // Idealmente esto debería ir a parar a la base de datos a un campo
125
- // creado a los efectos
126
- $address->setCustomsTotalSkybox($Customs);
127
- $address->setCustomsTotalUsdSkybox($CustomsUSD);
128
129
- $address->setShippingTotalSkybox($Shipping);
130
- $address->setShippingTotalUsdSkybox($ShippingUSD);
131
132
- $address->setInsuranceTotalSkybox($Insurance);
133
- $address->setInsuranceTotalUsdSkybox($InsuranceUSD);
134
135
- $address->setTaxesTotalSkybox($Taxes);
136
- $address->setTaxesTotalUsdSkybox($TaxesUSD);
137
138
- $address->setDutiesTotalSkybox($Duties);
139
- $address->setDutiesTotalUsdSkybox($DutiesUSD);
140
141
- $address->setHandlingTotalSkybox($Handling);
142
- $address->setHandlingTotalUsdSkybox($HandlingUSD);
143
-
144
- $address->setClearenceTotalSkybox($Clearence);
145
- $address->setClearenceTotalUsdSkybox($ClearenceUSD);
146
147
- $address->setOthersTotalSkybox($Others);
148
- $address->setOthersTotalUsdSkybox($OthersUSD);
149
150
- $address->setAdjustTotalSkybox($Adjustment);
151
- $address->setAdjustTotalUsdSkybox($AdjustmentUSD);
152
153
- $address->setConceptsSkybox(json_encode($listAdjustjson));
154
155
- $address->setRmtSkybox(json_encode($listRmtjson));
156
157
- $totalskybox=0;
158
- //$totalskybox=$Taxes+$Handling+$Shipping+$Insurance+$Clearence+$Duties+$Others-$Adjustment;
159
- $subtotalskybox=$totals->getResponse()->{'StoreProductPrice'};
160
- $totalskybox=$totals->getResponse()->{'TotalProduct'};
161
- //$totalskyboxbase=$TaxesUSD+$HandlingUSD+$ShippingUSD+$InsuranceUSD+$ClearenceUSD+$DutiesUSD+$OthersUSD-$AdjustmentUSD;
162
- $subtotalskyboxbase=$totals->getResponse()->{'StoreProductPriceUSD'};
163
- $totalskyboxbase=$totals->getResponse()->{'TotalProductUSD'};
164
- /*$address->setBasePaypalfeeAmount($this->_amount);*/
165
166
- // Actualizamos el total de la quote
167
- //$address->setGrandTotal($address->getGrandTotal() +$totalskybox);
168
- //$address->setBaseGrandTotal($address->getBaseGrandTotal() + $totalskyboxbase);
169
170
- $address->setSubTotal(100);
171
- $address->setBaseSubTotal(100);
172
- $address->setGrandTotal($totalskybox);
173
- $address->setBaseGrandTotal($totalskyboxbase);
174
175
- //$address->setGrandTotalSkybox($address->getGrandTotal() + $totalskybox);
176
- //$address->setBaseGrandTotalSkybox($address->getBaseGrandTotal() + $totalskyboxbase);
177
178
- $address->setSubtotalSkybox($subtotalskybox);
179
- $address->setBaseSubtotalSkybox($totalskyboxbase);
180
- $address->setGrandTotalSkybox($totalskybox);
181
- $address->setBaseGrandTotalSkybox($totalskyboxbase);
182
183
- //$address->setTaxAmount(0);
184
185
- //$address->save(); //Guardamos los Cambios
186
- Mage::log("quote->address->collect->getSubTotal->" . $address->getSubTotal(), null, 'TotalSales.log', true);
187
- Mage::log("quote->address->collect->getGrandTotal->" . $address->getGrandTotal(), null, 'TotalSales.log', true);
188
189
- Mage::log("quote->address->collect->Total->" . $totalskybox, null, 'TotalSales.log', true);
190
- Mage::log("quote->address->collect : fin", null, 'TotalSales.log', true);
191
192
- return $this;
193
}
194
}
195
196
/**
@@ -204,49 +213,64 @@ class Skybox_Checkout_Model_Quote_Total extends Mage_Sales_Model_Quote_Address_T
204
if(!$activation) {
205
return $this;
206
}
207
- if($this->_getApi()->getLocationAllow()){ // Rogged
208
- parent::fetch($address); //Comentado por verificar
209
210
- $quote= $address->getQuote();
211
- if(!$quote->isVirtual() && $address->getAddressType() == 'billing'){
212
- return $this;
213
- }
214
-
215
- $ConceptsSkyboxjson = json_decode($address->getConceptsSkybox());
216
-
217
- Mage::log("quote->address->fetch : ini", null, 'TotalSales.log', true);
218
- Mage::log("quote->address->fetch->getSubTotal->" . $address->getSubTotal(), null, 'TotalSales.log', true);
219
- Mage::log("quote->address->fetch->getGrandTotal->" . $address->getGrandTotal(), null, 'TotalSales.log', true);
220
-
221
- /*
222
- * Reescribimos el monto del SubTotal a Mostrar
223
- */
224
- $address->addTotal(array(
225
- 'code'=> 'subtotal',
226
- 'title'=>Mage::helper('sales')->__('Subtotal'),
227
- 'value'=> $address->getSubtotalSkybox()
228
- ));
229
-
230
- /*
231
- * Reescribimos el monto de los conceptos a Mostrar
232
- */
233
- $i=0;
234
- foreach ($ConceptsSkyboxjson as $item) {
235
- if($item->Visible != 0)
236
- {
237
- $i+=1;
238
- $address->addTotal(array(
239
'code' => 'checkout_total'.$i,
240
'title' => $item->Concept,
241
'value' => $item->Value
242
));
243
- Mage::log("quote->address->fetch(Concepts)->" . $item->Concept . "=" . $item->Value, null, 'TotalSales.log', true);
244
}
245
}
246
- Mage::log("quote->address->fetch : fin", null, 'TotalSales.log', true);
247
- // Retornamos el total con su título
248
- return $this;
249
}
250
}
251
}
252
44
if(!$activation) {
45
return $this;
46
}
47
+ $isIntegration3 = false;
48
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
49
+ if ($typeIntegration==3) {
50
+ $isIntegration3 = true;
51
+ }
52
+ if(!$isIntegration3) {
53
+ if($this->_getApi()->getLocationAllow()){ // Rogged
54
+
55
+
56
+ parent::collect($address); //Comentado por verificar
57
+
58
+ // Si no hay items, no hay nada que hacer
59
+ $items = $this->_getAddressItems($address);
60
+ if (!count($items)) {
61
+ return $this;
62
+ }
63
64
+ $quote= $address->getQuote();
65
66
// $quote = Mage::helper('checkout/cart')->getCart()->getQuote();
67
+ $shippingMethod = $quote->getShippingAddress()->getShippingMethod();
68
+ if($shippingMethod){
69
+ Mage::log('set shipping method null',null,'tracer.log',true);
70
+ $quote->getShippingAddress()->setShippingMethod(null); //setting method to null
71
+ $quote->save();
72
+ }
73
74
+ if(!$quote->isVirtual() && $address->getAddressType() == 'billing'){
75
+ return $this;
76
+ }
77
78
+ //$quote->setCustomerTaxClassId(0);
79
80
+ //Limpiamos los Valores de Impuestos
81
+ /*$rates = array();
82
+ $address->setAppliedTaxes($rates);*/
83
84
+ /*--------Nuevos conceptos---------*/
85
+ $totals=$this->_getApi()->GetTotalShoppingCart();
86
87
+ if ($this->_getApi()->HasError()) {
88
+ Mage::log("StatusCode: Error", null, 'TotalSales.log', true);
89
+ return $this;
90
+ }
91
92
+ Mage::log("quote->address->collect : ini", null, 'TotalSales.log', true);
93
94
+ //$StatusCode = $totals->getParameter('StatusCode');
95
+ //$StatusCode = $totals->getParameter('StatusCode');//Comentado por estar repetido
96
97
+ $Customs = $totals->getParameter('Customs');
98
+ $CustomsUSD = $totals->getParameter('CustomsUSD');
99
100
+ $Shipping = $totals->getParameter('Shipping');
101
+ $ShippingUSD = $totals->getParameter('ShippingUSD');
102
103
+ $Insurance = $totals->getParameter('Insurance');
104
+ $InsuranceUSD = $totals->getParameter('InsuranceUSD');
105
106
+ $Taxes = $totals->getParameter('Taxes');
107
+ $TaxesUSD = $totals->getParameter('TaxesUSD');
108
109
+ $Duties = $totals->getParameter('Duties');
110
+ $DutiesUSD = $totals->getParameter('DutiesUSD');
111
112
+ $Handling = $totals->getParameter('Handling');
113
+ $HandlingUSD = $totals->getParameter('HandlingUSD');
114
115
+ $Clearence = $totals->getParameter('Clearence');
116
+ $ClearenceUSD = $totals->getParameter('ClearenceUSD');
117
118
+ $Others = $totals->getParameter('Others');
119
+ $OthersUSD = $totals->getParameter('OthersUSD');
120
121
+ $Adjustment = $totals->getParameter('Adjustment');
122
+ $AdjustmentUSD = $totals->getParameter('AdjustmentUSD');
123
124
+ $listAdjustjson = $totals->getResponse()->{'ListDetailConcepts'};
125
126
+ $listRmtjson = $totals->getResponse()->{'ListDetailAdjusts'};
127
128
+ /*--------------------------------*/
129
+ // Apuntamos lo que hemos calculado para usarlo luego
130
+ // Idealmente esto debería ir a parar a la base de datos a un campo
131
+ // creado a los efectos
132
+ $address->setCustomsTotalSkybox($Customs);
133
+ $address->setCustomsTotalUsdSkybox($CustomsUSD);
134
135
+ $address->setShippingTotalSkybox($Shipping);
136
+ $address->setShippingTotalUsdSkybox($ShippingUSD);
137
138
+ $address->setInsuranceTotalSkybox($Insurance);
139
+ $address->setInsuranceTotalUsdSkybox($InsuranceUSD);
140
141
+ $address->setTaxesTotalSkybox($Taxes);
142
+ $address->setTaxesTotalUsdSkybox($TaxesUSD);
143
144
+ $address->setDutiesTotalSkybox($Duties);
145
+ $address->setDutiesTotalUsdSkybox($DutiesUSD);
146
147
+ $address->setHandlingTotalSkybox($Handling);
148
+ $address->setHandlingTotalUsdSkybox($HandlingUSD);
149
150
+ $address->setClearenceTotalSkybox($Clearence);
151
+ $address->setClearenceTotalUsdSkybox($ClearenceUSD);
152
153
+ $address->setOthersTotalSkybox($Others);
154
+ $address->setOthersTotalUsdSkybox($OthersUSD);
155
156
+ $address->setAdjustTotalSkybox($Adjustment);
157
+ $address->setAdjustTotalUsdSkybox($AdjustmentUSD);
158
159
+ $address->setConceptsSkybox(json_encode($listAdjustjson));
160
161
+ $address->setRmtSkybox(json_encode($listRmtjson));
162
163
+ $totalskybox=0;
164
+ //$totalskybox=$Taxes+$Handling+$Shipping+$Insurance+$Clearence+$Duties+$Others-$Adjustment;
165
+ $subtotalskybox=$totals->getResponse()->{'StoreProductPrice'};
166
+ $totalskybox=$totals->getResponse()->{'TotalProduct'};
167
+ //$totalskyboxbase=$TaxesUSD+$HandlingUSD+$ShippingUSD+$InsuranceUSD+$ClearenceUSD+$DutiesUSD+$OthersUSD-$AdjustmentUSD;
168
+ $subtotalskyboxbase=$totals->getResponse()->{'StoreProductPriceUSD'};
169
+ $totalskyboxbase=$totals->getResponse()->{'TotalProductUSD'};
170
+ /*$address->setBasePaypalfeeAmount($this->_amount);*/
171
172
+ // Actualizamos el total de la quote
173
+ //$address->setGrandTotal($address->getGrandTotal() +$totalskybox);
174
+ //$address->setBaseGrandTotal($address->getBaseGrandTotal() + $totalskyboxbase);
175
176
+ $address->setSubTotal(100);
177
+ $address->setBaseSubTotal(100);
178
+ $address->setGrandTotal($totalskybox);/*this is total variable on cart checkout*/
179
+ $address->setBaseGrandTotal($totalskyboxbase);
180
181
+ //$address->setGrandTotalSkybox($address->getGrandTotal() + $totalskybox);
182
+ //$address->setBaseGrandTotalSkybox($address->getBaseGrandTotal() + $totalskyboxbase);
183
184
+ $address->setSubtotalSkybox($subtotalskybox);
185
+ $address->setBaseSubtotalSkybox($totalskyboxbase);
186
+ $address->setGrandTotalSkybox($totalskybox);
187
+ $address->setBaseGrandTotalSkybox($totalskyboxbase);
188
189
+ //$address->setTaxAmount(0);
190
191
+ //$address->save(); //Guardamos los Cambios
192
+ Mage::log("quote->address->collect->getSubTotal->" . $address->getSubTotal(), null, 'TotalSales.log', true);
193
+ Mage::log("quote->address->collect->getGrandTotal->" . $address->getGrandTotal(), null, 'TotalSales.log', true);
194
195
+ Mage::log("quote->address->collect->Total->" . $totalskybox, null, 'TotalSales.log', true);
196
+ Mage::log("quote->address->collect : fin", null, 'TotalSales.log', true);
197
+
198
+ return $this;
199
+ }
200
}
201
+ return $this;
202
+
203
}
204
205
/**
213
if(!$activation) {
214
return $this;
215
}
216
+ /**
217
+ * Integration 3 start, show price shop in cart*
218
+ */
219
+ $allowRunByIntegration3 = true;
220
+ //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
221
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
222
+ if ($typeIntegration==3) {
223
+ $allowRunByIntegration3 = false;
224
+ }
225
+ /**
226
+ * Integration 3 end, show price shop in cart*
227
+ */
228
+ if($allowRunByIntegration3) {
229
+ if($this->_getApi()->getLocationAllow()){ // Rogged
230
+ parent::fetch($address); //Comentado por verificar
231
+
232
+ $quote= $address->getQuote();
233
+ if(!$quote->isVirtual() && $address->getAddressType() == 'billing'){
234
+ return $this;
235
+ }
236
237
+ $ConceptsSkyboxjson = json_decode($address->getConceptsSkybox());
238
+
239
+ Mage::log("quote->address->fetch : ini", null, 'TotalSales.log', true);
240
+ Mage::log("quote->address->fetch->getSubTotal->" . $address->getSubTotal(), null, 'TotalSales.log', true);
241
+ Mage::log("quote->address->fetch->getGrandTotal->" . $address->getGrandTotal(), null, 'TotalSales.log', true);
242
+
243
+ /*
244
+ * Reescribimos el monto del SubTotal a Mostrar
245
+ */
246
+ $address->addTotal(array(
247
+ 'code'=> 'subtotal',
248
+ 'title'=>Mage::helper('sales')->__('Subtotal'),
249
+ 'value'=> $address->getSubtotalSkybox()
250
+ ));
251
+
252
+ /*
253
+ * Reescribimos el monto de los conceptos a Mostrar
254
+ */
255
+ $i=0;
256
+ foreach ($ConceptsSkyboxjson as $item) {
257
+ if($item->Visible != 0)
258
+ {
259
+ $i+=1;
260
+ $address->addTotal(array(
261
'code' => 'checkout_total'.$i,
262
'title' => $item->Concept,
263
'value' => $item->Value
264
));
265
+ Mage::log("quote->address->fetch(Concepts)->" . $item->Concept . "=" . $item->Value, null, 'TotalSales.log', true);
266
+ }
267
}
268
+ Mage::log("quote->address->fetch : fin", null, 'TotalSales.log', true);
269
+ // Retornamos el total con su título
270
+ return $this;
271
}
272
}
273
+
274
}
275
}
276
app/code/community/Skybox/Checkout/controllers/InternationalController.php CHANGED
@@ -29,6 +29,7 @@ class Skybox_Checkout_InternationalController extends Mage_Core_Controller_Front
29
30
public function successAction()
31
{
32
Mage::getSingleton('checkout/cart')->truncate()->save();
33
34
$_config = Mage::getModel('skyboxcore/config');
29
30
public function successAction()
31
{
32
+ Mage::log("Call true: successAction limpiar carro", null, 'gary.log', true);
33
Mage::getSingleton('checkout/cart')->truncate()->save();
34
35
$_config = Mage::getModel('skyboxcore/config');
app/code/community/Skybox/Checkout/controllers/ProcessController.php CHANGED
@@ -11,6 +11,30 @@ class Skybox_Checkout_ProcessController extends Mage_Core_Controller_Front_Actio
11
{
12
public function indexAction()
13
{
14
//Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter index', null, 'tracer.log', true);
15
$_checkout = Mage::getModel('skyboxcheckout/api_checkout');
16
$_checkout->InitializeBarSkybox();
@@ -34,9 +58,12 @@ class Skybox_Checkout_ProcessController extends Mage_Core_Controller_Front_Actio
34
$api_mproduct=Mage::getModel('skyboxcatalog/api_product');
35
// Mage::log('entro getAllItems $CartItemCount',null,'tracer.log',true);
36
// Mage::log((int)$quote->getItemsQty() .'-'.$CartItemCount,null,'tracer.log',true);
37
- if((int)$quote->getItemsQty() != $CartItemCount && $api_mproduct->getLocationAllow()){
38
- $differentqty=1;
39
}
40
/*-----------------------------------------*/
41
foreach ($quote->getAllItems() as $item) {
42
$parentItem = $item->getParentItem();
@@ -121,25 +148,29 @@ class Skybox_Checkout_ProcessController extends Mage_Core_Controller_Front_Actio
121
122
/* -- Rogged --*/
123
/* Cuando se cambia de country no allow a otro country allow, no hay precio en skybox registrado, por eso tomamos el precio de tienda */
124
125
- if($api_mproduct->getLocationAllow() && !$item->getPriceSkybox()){
126
- $item->setPriceSkybox($item->getPrice());
127
}
128
/* -- ----- --*/
129
130
#echo $item->getPrice()." - ".$item->getPriceSkybox()."<br>";
131
132
- $productModel = Mage::getModel('catalog/product')->load($item->getProductId());
133
// Mage::log(print_r($productModel->getFinalPrice(), true), null, 'processcontroller.log', true);
134
135
if ($item->getProductType() === 'configurable'){
136
137
- $product_api->CalculatePrice($item->getProductId(),NULL,$item->getPriceUsdSkybox(),$item->getProductType(),NULL);
138
Mage::log("configurable", null, 'processcontroller.log', true);
139
}
140
if ($item->getProductType() === 'simple' && $parentItem && !$item->getPriceSkybox()) {
141
142
- $product_api->CalculatePrice($item->getProductId(),NULL,$item->getPriceUsdSkybox(),$item->getProductType(),NULL);
143
Mage::log("simple1", null, 'processcontroller.log', true);
144
}
145
@@ -161,54 +192,102 @@ class Skybox_Checkout_ProcessController extends Mage_Core_Controller_Front_Actio
161
// Bundle Product
162
if ($item->getProductType() === 'bundle') {
163
164
- $product_api->CalculatePrice($item->getProductId(), null, $item->getPriceUsdSkybox());
165
Mage::log("bundle", null, 'processcontroller.log', true);
166
};
167
168
- //$total = str_replace(",", "", $product_api->getPriceUSD());
169
- $total = str_replace(",", "", $product_api->getTotalPriceUSD());
170
-
171
- /**
172
- * Currency amounts in the default currency of that customer
173
- */
174
- $item->setCustomsSkybox($product_api->getCustoms());
175
- $item->setShippingSkybox($product_api->getShipping());
176
- $item->setInsuranceSkybox($product_api->getInsurance());
177
- $item->setPriceSkybox($product_api->getPrice());
178
- $item->setTotalSkybox($product_api->getTotalPrice());
179
- $item->setRowTotal($total);
180
-
181
- /*
182
- * Currency amounts in the USD Currency
183
- */
184
- $item->setCustomsUsdSkybox($product_api->getCustomsUSD());
185
- $item->setShippingUsdSkybox($product_api->getShippingUSD());
186
- $item->setInsuranceUsdSkybox($product_api->getInsuranceUSD());
187
- $item->setPriceUsdSkybox($product_api->getPriceUSD());
188
- $item->setTotalUsdSkybox($product_api->getTotalPriceUSD());
189
-
190
- // Set GUID
191
- $item->setGuidSkybox($product_api->getGuidSkybox());
192
-
193
- $item->setBasePriceSkybox($product_api->getBasePrice());
194
- $item->setBasePriceUsdSkybox($product_api->getBasePriceUSD());
195
- $item->setAdjustTotalSkybox($product_api->getAdjustPrice());
196
- $item->setAdjustTotalUsdSkybox($product_api->getAdjustPriceUSD());
197
- $item->setAdjustLabelSkybox($product_api->getAdjustLabel());
198
-
199
- /**
200
- * Registramos el monto total en USD
201
- */
202
- //$item->setOriginalCustomPrice($product_api->getTotalPriceUSD());
203
- //$item->setOriginalCustomPrice($total);
204
- $prices = str_replace(',','',$product_api->getPrice());
205
- $prices = number_format((float)($prices),2, ',', '.');
206
- $item->setOriginalCustomPrice($prices);
207
- //$item->setOriginalCustomPrice($product_api->getPrice());
208
- //$skybox_total = str_replace(",", "", $product_api->getTotalPrice());
209
- $skybox_total = str_replace(",", "", $product_api->getPrice());
210
- $row_total = floatval($skybox_total) * $item->getQty();
211
- $item->setRowTotalSkybox($row_total);
212
213
}
214
11
{
12
public function indexAction()
13
{
14
+ /**
15
+ * only one time for call to service start - Active
16
+ * This always run when you do change country
17
+ */
18
+ $session = Mage::getSingleton("core/session", array("name"=>"frontend"));
19
+ $session->setData("callToSkyBox", true);
20
+ Mage::log("Call true: Skybox_Checkout_ProcessController", null, 'gary.log', true);
21
+ /**
22
+ * only one time for call to service end - Active
23
+ */
24
+
25
+
26
+ /**
27
+ * Integration 3 start, show price shop in cart*
28
+ */
29
+ $isLocationAllow = false;
30
+ //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
31
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
32
+ if ($typeIntegration==3) {
33
+ $isLocationAllow = true;
34
+ }
35
+ /**
36
+ * Integration 3 end, show price shop in cart*
37
+ */
38
//Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter index', null, 'tracer.log', true);
39
$_checkout = Mage::getModel('skyboxcheckout/api_checkout');
40
$_checkout->InitializeBarSkybox();
58
$api_mproduct=Mage::getModel('skyboxcatalog/api_product');
59
// Mage::log('entro getAllItems $CartItemCount',null,'tracer.log',true);
60
// Mage::log((int)$quote->getItemsQty() .'-'.$CartItemCount,null,'tracer.log',true);
61
+ if(!$isLocationAllow) {
62
+ if((int)$quote->getItemsQty() != $CartItemCount && $api_mproduct->getLocationAllow()) {
63
+ $differentqty=1;
64
+ }
65
}
66
+
67
/*-----------------------------------------*/
68
foreach ($quote->getAllItems() as $item) {
69
$parentItem = $item->getParentItem();
148
149
/* -- Rogged --*/
150
/* Cuando se cambia de country no allow a otro country allow, no hay precio en skybox registrado, por eso tomamos el precio de tienda */
151
+ $productModel = Mage::getModel('catalog/product')->load($item->getProductId());
152
153
+ if(!$isLocationAllow) {
154
+ if($api_mproduct->getLocationAllow() && !$item->getPriceSkybox()){
155
+ $item->setPriceSkybox($productModel->getPrice());
156
+ }
157
}
158
+
159
/* -- ----- --*/
160
161
#echo $item->getPrice()." - ".$item->getPriceSkybox()."<br>";
162
163
+
164
// Mage::log(print_r($productModel->getFinalPrice(), true), null, 'processcontroller.log', true);
165
166
if ($item->getProductType() === 'configurable'){
167
168
+ $product_api->CalculatePrice($item->getProductId(),NULL,$productModel->getPriceUsdSkybox(),$item->getProductType(),NULL);
169
Mage::log("configurable", null, 'processcontroller.log', true);
170
}
171
if ($item->getProductType() === 'simple' && $parentItem && !$item->getPriceSkybox()) {
172
173
+ $product_api->CalculatePrice($item->getProductId(),NULL,$productModel->getPriceUsdSkybox(),$item->getProductType(),NULL);
174
Mage::log("simple1", null, 'processcontroller.log', true);
175
}
176
192
// Bundle Product
193
if ($item->getProductType() === 'bundle') {
194
195
+ $product_api->CalculatePrice($item->getProductId(), null, $productModel->getPriceUsdSkybox());
196
Mage::log("bundle", null, 'processcontroller.log', true);
197
};
198
199
+ if($isLocationAllow) {
200
+ //$total = str_replace(",", "", $product_api->getPriceUSD());
201
+ $total = str_replace(",", "", $productModel->getTotalPriceUSD());
202
+
203
+ /**
204
+ * Currency amounts in the default currency of that customer
205
+ */
206
+ $item->setCustomsSkybox($productModel->getCustoms());
207
+ $item->setShippingSkybox($productModel->getShipping());
208
+ $item->setInsuranceSkybox($productModel->getInsurance());
209
+ $item->setPriceSkybox($productModel->getPrice());
210
+ $item->setTotalSkybox($productModel->getTotalPrice());
211
+ $item->setRowTotal($total);
212
+
213
+ /*
214
+ * Currency amounts in the USD Currency
215
+ */
216
+ $item->setCustomsUsdSkybox($productModel->getCustomsUSD());
217
+ $item->setShippingUsdSkybox($productModel->getShippingUSD());
218
+ $item->setInsuranceUsdSkybox($productModel->getInsuranceUSD());
219
+ $item->setPriceUsdSkybox($productModel->getPriceUSD());
220
+ $item->setTotalUsdSkybox($productModel->getTotalPriceUSD());
221
+
222
+ // Set GUID
223
+ $item->setGuidSkybox($productModel->getGuidSkybox());
224
+
225
+ $item->setBasePriceSkybox($productModel->getBasePrice());
226
+ $item->setBasePriceUsdSkybox($productModel->getBasePriceUSD());
227
+ $item->setAdjustTotalSkybox($productModel->getAdjustPrice());
228
+ $item->setAdjustTotalUsdSkybox($productModel->getAdjustPriceUSD());
229
+ $item->setAdjustLabelSkybox($productModel->getAdjustLabel());
230
+
231
+ /**
232
+ * Registramos el monto total en USD
233
+ */
234
+ //$item->setOriginalCustomPrice($product_api->getTotalPriceUSD());
235
+ //$item->setOriginalCustomPrice($total);
236
+ $prices = str_replace(',','',$productModel->getPrice());
237
+ $prices = number_format((float)($prices),2, ',', '.');
238
+ $item->setOriginalCustomPrice($prices);
239
+ //$item->setOriginalCustomPrice($product_api->getPrice());
240
+ //$skybox_total = str_replace(",", "", $product_api->getTotalPrice());
241
+ $skybox_total = str_replace(",", "", $productModel->getPrice());
242
+ $row_total = floatval($skybox_total) * $item->getQty();
243
+ $item->setRowTotalSkybox($row_total);
244
+ } else {
245
+ //$total = str_replace(",", "", $product_api->getPriceUSD());
246
+ $total = str_replace(",", "", $product_api->getTotalPriceUSD());
247
+
248
+ /**
249
+ * Currency amounts in the default currency of that customer
250
+ */
251
+ $item->setCustomsSkybox($product_api->getCustoms());
252
+ $item->setShippingSkybox($product_api->getShipping());
253
+ $item->setInsuranceSkybox($product_api->getInsurance());
254
+ $item->setPriceSkybox($product_api->getPrice());
255
+ $item->setTotalSkybox($product_api->getTotalPrice());
256
+ $item->setRowTotal($total);
257
+
258
+ /*
259
+ * Currency amounts in the USD Currency
260
+ */
261
+ $item->setCustomsUsdSkybox($product_api->getCustomsUSD());
262
+ $item->setShippingUsdSkybox($product_api->getShippingUSD());
263
+ $item->setInsuranceUsdSkybox($product_api->getInsuranceUSD());
264
+ $item->setPriceUsdSkybox($product_api->getPriceUSD());
265
+ $item->setTotalUsdSkybox($product_api->getTotalPriceUSD());
266
+
267
+ // Set GUID
268
+ $item->setGuidSkybox($product_api->getGuidSkybox());
269
+
270
+ $item->setBasePriceSkybox($product_api->getBasePrice());
271
+ $item->setBasePriceUsdSkybox($product_api->getBasePriceUSD());
272
+ $item->setAdjustTotalSkybox($product_api->getAdjustPrice());
273
+ $item->setAdjustTotalUsdSkybox($product_api->getAdjustPriceUSD());
274
+ $item->setAdjustLabelSkybox($product_api->getAdjustLabel());
275
+
276
+ /**
277
+ * Registramos el monto total en USD
278
+ */
279
+ //$item->setOriginalCustomPrice($product_api->getTotalPriceUSD());
280
+ //$item->setOriginalCustomPrice($total);
281
+ $prices = str_replace(',','',$product_api->getPrice());
282
+ $prices = number_format((float)($prices),2, ',', '.');
283
+ $item->setOriginalCustomPrice($prices);
284
+ //$item->setOriginalCustomPrice($product_api->getPrice());
285
+ //$skybox_total = str_replace(",", "", $product_api->getTotalPrice());
286
+ $skybox_total = str_replace(",", "", $product_api->getPrice());
287
+ $row_total = floatval($skybox_total) * $item->getQty();
288
+ $item->setRowTotalSkybox($row_total);
289
+ }
290
+
291
292
}
293
app/code/community/Skybox/International/Helper/Data.php CHANGED
@@ -40,6 +40,11 @@ class Skybox_International_Helper_Data extends Mage_Core_Helper_Abstract
40
return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxemail', Mage::app()->getStore());
41
}
42
43
public function getSkyboxUrlAPI()
44
{
45
return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxurlapi', Mage::app()->getStore());
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());
app/code/community/Skybox/International/etc/system.xml CHANGED
@@ -78,11 +78,21 @@
78
<show_in_website>1</show_in_website>
79
<show_in_store>1</show_in_store>
80
</skyboxemail>
81
<skyboxurlapi translate="label">
82
<label>SkyBox Url API:</label>
83
<comment>Url API By Skybox Checkout International</comment>
84
<frontend_type>text</frontend_type>
85
- <sort_order>7</sort_order>
86
<show_in_default>1</show_in_default>
87
<show_in_website>1</show_in_website>
88
<show_in_store>1</show_in_store>
@@ -91,7 +101,7 @@
91
<label>SkyBox Url Client:</label>
92
<comment>Url Client By Skybox Checkout International</comment>
93
<frontend_type>text</frontend_type>
94
- <sort_order>8</sort_order>
95
<show_in_default>1</show_in_default>
96
<show_in_website>1</show_in_website>
97
<show_in_store>1</show_in_store>
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>text</frontend_type>
85
+ <!-- validate>validate-email</validate -->
86
+ <sort_order>7</sort_order>
87
+ <show_in_default>1</show_in_default>
88
+ <show_in_website>1</show_in_website>
89
+ <show_in_store>1</show_in_store>
90
+ </skyboxintegration>
91
<skyboxurlapi translate="label">
92
<label>SkyBox Url API:</label>
93
<comment>Url API By Skybox Checkout International</comment>
94
<frontend_type>text</frontend_type>
95
+ <sort_order>8</sort_order>
96
<show_in_default>1</show_in_default>
97
<show_in_website>1</show_in_website>
98
<show_in_store>1</show_in_store>
101
<label>SkyBox Url Client:</label>
102
<comment>Url Client By Skybox Checkout International</comment>
103
<frontend_type>text</frontend_type>
104
+ <sort_order>9</sort_order>
105
<show_in_default>1</show_in_default>
106
<show_in_website>1</show_in_website>
107
<show_in_store>1</show_in_store>
app/design/frontend/base/default/layout/skyboxcheckout.xml CHANGED
@@ -27,7 +27,7 @@
27
<!-- Rogged he quitado la invocación de cart -->
28
29
<reference name="checkout.cart.methods">
30
- <block type="core/template" name="skybox.checkout.cart.methods.onepage.bottom" template="skybox/checkout/onepage/link.phtml"/>
31
</reference>
32
33
<reference name="checkout.cart.shipping">
27
<!-- Rogged he quitado la invocación de cart -->
28
29
<reference name="checkout.cart.methods">
30
+ <block type="core/template" before="content" name="skybox.checkout.cart.methods.onepage.bottom" template="skybox/checkout/onepage/link.phtml"/>
31
</reference>
32
33
<reference name="checkout.cart.shipping">
app/design/frontend/base/default/template/skybox/checkout/cart.phtml CHANGED
@@ -12,33 +12,28 @@ Mage::log("InitializeBarSkybox ", null, 'cartphtml.log', true);
12
$_checkout->InitializeBarSkybox();
13
14
$change_country = false;
15
- /*LocationAllow3 start*/
16
- /*Dectect checkout start*/
17
- $checkoutCurrent = true;
18
- /*enciendo si esta en 3*/
19
- $locationAllow3 = false;
20
- $allowBar = true;
21
-
22
-
23
$request = $this->getRequest();
24
$module = $request->getModuleName();
25
$controller = $request->getControllerName();
26
$action = $request->getActionName();
27
- $typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
28
- if($typeIntegration == 3) {
29
- if($module != 'checkout' && $controller != 'cart' && $action != 'index') {
30
- $allowBar = false;
31
- }
32
- if(!$_checkout->getLocationAllow()) {
33
- $allowBar = false;
34
- }
35
- }
36
-
37
- /*LocationAllow3 end*/
38
- if (!$_checkout->getErrorAuthenticate()) { // Si es correcta la authenticación en api
39
-
40
- if($allowBar) {
41
- if($_checkout->getLocationAllow()){ // Si country esta disponible
42
$cart = $_config->getSession()->getCartSkybox();
43
if (!empty($cart)) {
44
$template = $cart->BarHtmlTemplate;
@@ -47,17 +42,61 @@ if (!$_checkout->getErrorAuthenticate()) { // Si es correcta la authenticación
47
}
48
}
49
$_cartDataURL = $cart->CartDataURL;
50
- }else{ // Si country no está disponible
51
$cart = $_config->getSession()->getCartSkybox(); // Rogged
52
$_cartDataURL = $cart->CartDataURL; // Rogged
53
- //$template = "<a href='#' id='link_choise_country'>&nbsp;</a>";
54
$template = "<a href='#' class='skx_position_option_country'>Change country</a>"; // Rogged
55
$change_country = true;
56
}
57
- }
58
59
}
60
- //echo '<script>console.log("'.$_cartDataURL.'")</script>';
61
//$template = "<a href='#' id='link_choise_country'>&nbsp;</a>";
62
63
$_url_check_cart = Mage::getUrl("checkout/cart");
@@ -105,7 +144,7 @@ echo $template; // Skybox Bar
105
var dataId = jQuery(this).attr("id");
106
var id = jQuery(this).attr("product-id");
107
var url = "<?php echo $skyBoxUrlClient;?>" + id + ".html";
108
- console.log("URL refresh: " +url);
109
//console.log(url);
110
var content = jQuery.get(url, function( data ) {
111
jQuery("#" + dataId).html(data);
@@ -229,10 +268,10 @@ echo $template; // Skybox Bar
229
}
230
function recalculateHeightIframe(data)
231
{
232
- console.log('recalculateHeightIframe',data);
233
if(data.win == 'resync'){
234
popupHeight = data.height;
235
- console.log('popupHeight',popupHeight);
236
var _size = getSizeForPopup();
237
popup.setSize(_size.width, _size.height);
238
// popup.showCenter(true);
@@ -243,7 +282,7 @@ echo $template; // Skybox Bar
243
if(!jQuery.isEmptyObject(popup) && win == 'resync'){
244
var iFrameDOM = $("iframe#selectLocation_content").contents();
245
popupHeight = iFrameDOM.find("body").height()+30;
246
- console.log(popupHeight);
247
var _size = getSizeForPopup();
248
popup.setSize(_size.width, _size.height)
249
// popup.updateHeight()s
@@ -314,4 +353,4 @@ echo $template; // Skybox Bar
314
//]]>
315
</script>
316
317
- <script type="text/javascript" src="<?php echo $api_js_button_international; ?>"></script>
12
$_checkout->InitializeBarSkybox();
13
14
$change_country = false;
15
$request = $this->getRequest();
16
$module = $request->getModuleName();
17
$controller = $request->getControllerName();
18
$action = $request->getActionName();
19
+ //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
20
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
21
+
22
+ $cart = $_config->getSession()->getCartSkybox();
23
+ $cart = $_config->getSession()->getCartSkybox();
24
+
25
+ if (!$_checkout->getErrorAuthenticate()) {
26
+ /**
27
+ * Is correct the api authentication
28
+ */
29
+ if( (($_checkout->getLocationAllow()==1) or (!$_checkout->getLocationAllow())) && $typeIntegration==1) {
30
+ /**
31
+ * Integration 1 start bar*
32
+ */
33
+ if($_checkout->getLocationAllow()) {
34
+ /**
35
+ * Allow
36
+ */
37
$cart = $_config->getSession()->getCartSkybox();
38
if (!empty($cart)) {
39
$template = $cart->BarHtmlTemplate;
42
}
43
}
44
$_cartDataURL = $cart->CartDataURL;
45
+ } else {
46
+ /**
47
+ * Not Allow
48
+ */
49
$cart = $_config->getSession()->getCartSkybox(); // Rogged
50
$_cartDataURL = $cart->CartDataURL; // Rogged
51
$template = "<a href='#' class='skx_position_option_country'>Change country</a>"; // Rogged
52
$change_country = true;
53
}
54
+ /**
55
+ * Integration 1 end bar*
56
+ */
57
+ } elseif ($_checkout->getLocationAllow()==3 && $typeIntegration==3) {
58
+ /**
59
+ * Integration 3 start bar*
60
+ */
61
+ if($_checkout->getLocationAllow() == 3) {
62
+ /**
63
+ * Allow
64
+ */
65
+ /*
66
+ if($module == 'checkout' && $controller == 'cart' && $action == 'index') {
67
+
68
+ $cart = $_config->getSession()->getCartSkybox();
69
+ if (!empty($cart)) {
70
+ $template = $cart->BarHtmlTemplate;
71
+ foreach ($cart as $key => $value) {
72
+ $template = str_replace('{' . $key . '}', $value, $template);
73
+ }
74
+ }
75
+ $_cartDataURL = $cart->CartDataURL;
76
+ }
77
78
+ */
79
+ }elseif(!$_checkout->getLocationAllow()) {
80
+ /**
81
+ * Not Allow
82
+ */
83
+ }
84
+ /**
85
+ * For the integration 1 doesn't exist bar
86
+ * Integration 3 end bar*
87
+ */
88
+ }
89
+ //echo $module.'==='.$controller.'---'.$action;
90
}
91
+ /**
92
+ * Start Aditional we add a line debug with integration information
93
+ */
94
+ /*echo '<script>
95
+ console.log("LocationAllowService: '.$_checkout->getLocationAllow().' LocationAllowLocal: '. $typeIntegration.' ")
96
+ </script>';*/
97
+ /**
98
+ * End Aditional we add a line debug with integration information
99
+ */
100
//$template = "<a href='#' id='link_choise_country'>&nbsp;</a>";
101
102
$_url_check_cart = Mage::getUrl("checkout/cart");
144
var dataId = jQuery(this).attr("id");
145
var id = jQuery(this).attr("product-id");
146
var url = "<?php echo $skyBoxUrlClient;?>" + id + ".html";
147
+ /*console.log("URL refresh: " +url);*/
148
//console.log(url);
149
var content = jQuery.get(url, function( data ) {
150
jQuery("#" + dataId).html(data);
268
}
269
function recalculateHeightIframe(data)
270
{
271
+ //console.log('recalculateHeightIframe',data);
272
if(data.win == 'resync'){
273
popupHeight = data.height;
274
+ //console.log('popupHeight',popupHeight);
275
var _size = getSizeForPopup();
276
popup.setSize(_size.width, _size.height);
277
// popup.showCenter(true);
282
if(!jQuery.isEmptyObject(popup) && win == 'resync'){
283
var iFrameDOM = $("iframe#selectLocation_content").contents();
284
popupHeight = iFrameDOM.find("body").height()+30;
285
+ //console.log(popupHeight);
286
var _size = getSizeForPopup();
287
popup.setSize(_size.width, _size.height)
288
// popup.updateHeight()s
353
//]]>
354
</script>
355
356
+ <script type="text/javascript" src="<?php echo $api_js_button_international; ?>"></script>
app/design/frontend/base/default/template/skybox/checkout/onepage/link.phtml CHANGED
@@ -26,16 +26,17 @@
26
?>
27
<?php
28
$api = Mage::getModel('skyboxcatalog/api_product');
29
- $typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
30
31
- if ($api->getLocationAllow() && $typeIntegration==3):
32
?>
33
<button type="button"
34
35
class="button btn-proceed-checkout btn-checkout"
36
- onclick="window.location='<?php echo Mage::getBaseUrl()."/checkout/onepage?v=1" ?>';">
37
<span>
38
- <span><?php echo $this->__('Proceed') ?></span>
39
</span>
40
</button>
41
<?php endif;?>
26
?>
27
<?php
28
$api = Mage::getModel('skyboxcatalog/api_product');
29
+ //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
30
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
31
32
+ if (($api->getLocationAllow()==3) && $typeIntegration==3):
33
?>
34
<button type="button"
35
36
class="button btn-proceed-checkout btn-checkout"
37
+ onclick="window.location='<?php echo $this->getUrl('skbcheckout/international', array('_secure'=>true)) ?>';">
38
<span>
39
+ <span><?php echo $this->__('Checkout with SkyBOX Checkout') ?></span>
40
</span>
41
</button>
42
<?php endif;?>
app/design/frontend/base/default/template/skybox/checkout/skyboxcheckout.phtml CHANGED
@@ -5,6 +5,365 @@ $_model = Mage::getModel('skyboxcore/standard');
5
$_config = Mage::getModel('skyboxcore/config');
6
$_checkout = Mage::getModel('skyboxcheckout/api_checkout');
7
8
if (!$_checkout->getErrorAuthenticate() && $_checkout->getLocationAllow()) { // Rogged
9
// Calculate height
10
$size = 0;
5
$_config = Mage::getModel('skyboxcore/config');
6
$_checkout = Mage::getModel('skyboxcheckout/api_checkout');
7
8
+ /**
9
+ * Integration 3 start, show bar*
10
+ */
11
+ $_cartDataURL = "";
12
+ $_merchant = $_helper->getMerchantCode();
13
+ $template = "";
14
+ $cartId = $_helper->getCartId();
15
+
16
+ Mage::log("InitializeBarSkybox ", null, 'cartphtml.log', true);
17
+
18
+ $_checkout->InitializeBarSkybox();
19
+
20
+ $change_country = false;
21
+ $request = $this->getRequest();
22
+ $module = $request->getModuleName();
23
+ $controller = $request->getControllerName();
24
+ $action = $request->getActionName();
25
+ //$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
26
+ $typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
27
+
28
+
29
+ $cart = $_config->getSession()->getCartSkybox();
30
+ if (!$_checkout->getErrorAuthenticate()) {
31
+ /**
32
+ * Is correct the api authentication
33
+ */
34
+ if( (($_checkout->getLocationAllow()==1) or (!$_checkout->getLocationAllow())) && $typeIntegration==1) {
35
+ /**
36
+ * Integration 1 start bar*
37
+ */
38
+ if($_checkout->getLocationAllow()) {
39
+ /**
40
+ * Allow
41
+ */
42
+ if($module == 'skbcheckout' && $controller == 'international' && $action == 'index') {
43
+
44
+ } else {
45
+ $cart = $_config->getSession()->getCartSkybox();
46
+ if (!empty($cart)) {
47
+ $template = $cart->BarHtmlTemplate;
48
+ foreach ($cart as $key => $value) {
49
+ $template = str_replace('{' . $key . '}', $value, $template);
50
+ }
51
+ }
52
+ $_cartDataURL = $cart->CartDataURL;
53
+ }
54
+
55
+ } else {
56
+ /**
57
+ * Not Allow
58
+ */
59
+ $cart = $_config->getSession()->getCartSkybox(); // Rogged
60
+ $_cartDataURL = $cart->CartDataURL; // Rogged
61
+ $template = "<a href='#' class='skx_position_option_country'>Change country</a>"; // Rogged
62
+ $change_country = true;
63
+ }
64
+ /**
65
+ * Integration 1 end bar*
66
+ */
67
+ } elseif ($_checkout->getLocationAllow()==3 && $typeIntegration==3) {
68
+ /**
69
+ * Integration 3 start bar*
70
+ */
71
+ if($_checkout->getLocationAllow() == 3) {
72
+ /**
73
+ * Allow
74
+ */
75
+ if($module == 'skbcheckout' && $controller == 'international' && $action == 'index') {
76
+ /**
77
+ * Only to show in checkout cart
78
+ * */
79
+ $cart = $_config->getSession()->getCartSkybox();
80
+ if (!empty($cart)) {
81
+ $template = $cart->BarHtmlTemplate;
82
+ foreach ($cart as $key => $value) {
83
+ $template = str_replace('{' . $key . '}', $value, $template);
84
+ }
85
+ }
86
+ $_cartDataURL = $cart->CartDataURL;
87
+ }
88
+
89
+ }elseif(!$_checkout->getLocationAllow()) {
90
+ /**
91
+ * Not Allow
92
+ */
93
+ }
94
+ /**
95
+ * For the integration 1 doesn't exist bar
96
+ * Integration 3 end bar*
97
+ */
98
+ }
99
+ //echo $module.'==='.$controller.'---'.$action;
100
+ }
101
+ /**
102
+ * Start Aditional we add a line debug with integration information
103
+ */
104
+ echo '<script>
105
+ console.log("LocationAllowService: '.$_checkout->getLocationAllow().' LocationAllowLocal: '. $typeIntegration.' ")
106
+ </script>';
107
+ /**
108
+ * End Aditional we add a line debug with integration information
109
+ */
110
+ //$template = "<a href='#' id='link_choise_country'>&nbsp;</a>";
111
+
112
+ $_url_check_cart = Mage::getUrl("checkout/cart");
113
+
114
+ // Load CSS & JS
115
+ $skybox_url = $_helper->getSkyboxUrlMain();// $_config->skyboxDefaultUrl;
116
+ $api_css_button_international = $skybox_url . 'widgets/api-button/css/api-button-international-css.ashx';
117
+ $api_css_button_international .= '?s=' . $_helper->getMerchantCode();
118
+ $api_js_button_international = $skybox_url . 'Content/debug/API/js/api-button-tooltip.js';
119
+ ?>
120
+ <link rel="stylesheet" type="text/css" href="<?php echo $api_css_button_international; ?>"/>
121
+ <?php
122
+ echo $template; // Skybox Bar
123
+ ?>
124
+
125
+ <style type="text/css">
126
+ #selectLocation iframe {
127
+ width: 1px;
128
+ min-width: 100%;
129
+ *width: 100%;
130
+ }
131
+ #selectLocation.dialog, #initSession.dialog {
132
+ background: transparent !important;
133
+ -webkit-box-shadow: none;
134
+ -moz-box-shadow: none;
135
+ box-shadow: none;
136
+ }
137
+ </style>
138
+ <link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('css/skybox/style.css?v=230120171122');?>"/>
139
+ <script type="text/javascript">
140
+
141
+ jQuery(document).ready(function() {
142
+ jQuery(".skybox-price-set").each(function( index ) {
143
+ <?php
144
+ $skyBoxUrlClientBase = Mage::helper('skyboxinternational/data')->getSkyBoxUrlAPI();
145
+ //$codeShop = Mage::getStoreConfig('settings/codeShop');
146
+ //$codeShop = $_config->getSession()->getStoreCode();
147
+ $codeShop = Mage::getModel('skyboxcatalog/api_product')->getStoreCode();
148
+ $skyBoxUrlClientGet = str_replace("apirest/", "", $skyBoxUrlClientBase);
149
+ $skyBoxUrlClient = $skyBoxUrlClientGet . ("multiplecalculate/") . $codeShop ."/calc-";
150
+
151
+ //http://beta.skyboxcheckout.com/testapi/multiplecalculate/" + merchantId + "/calc-
152
+ ?>
153
+
154
+ var dataId = jQuery(this).attr("id");
155
+ var id = jQuery(this).attr("product-id");
156
+ var url = "<?php echo $skyBoxUrlClient;?>" + id + ".html";
157
+ console.log("URL refresh: " +url);
158
+ //console.log(url);
159
+ var content = jQuery.get(url, function( data ) {
160
+ jQuery("#" + dataId).html(data);
161
+ /*return data;*/
162
+ });
163
+
164
+ /*console.log(content);*/
165
+ });
166
+
167
+ });
168
+
169
+
170
+
171
+ (function ($) {
172
+
173
+ var widthPage = 0;
174
+ var heightPage = 0;
175
+ var popup = {};
176
+ var popupWidth = 540;
177
+ var popupHeight = 545;
178
+ var win = '';
179
+
180
+ function showPopup(name, t, url, w, h) {
181
+ //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} });
182
+ winCompare = new Window(name, {className: 'alphacube', title: t, url: url, width: w, height: h, minimizable: false, maximizable: false, showEffectOptions: {duration: 0.4}, hideEffectOptions: {duration: 0.4}, destroyOnClose: true, draggable: false, resizable: false });
183
+ winCompare.setDestroyOnClose();
184
+ winCompare.setZIndex(9999);
185
+ winCompare.showCenter(true);
186
+ return winCompare;
187
+ }
188
+
189
+ function goToCart() {
190
+ document.location = "<?php echo $_url_check_cart?>";
191
+ }
192
+
193
+ function goToInitializeSession() {
194
+ var idCart = "<?php echo $cartId ?>";
195
+ var datos = "<?php echo $_cartDataURL ?>";
196
+ var merchant = "<?php echo $_merchant ?>";
197
+ var actualUri = "<?php echo 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI'] ?>"
198
+ actualUri = actualUri + "?LoadFrame=1";
199
+ //console.log(actualUri);
200
+ // var url = "<?php echo $skybox_url ?>" + "APILoginCustomer.aspx?" + datos + "&merchant=" + merchant + "&idCart=" + idCart + "&ReLoad=1&uri=" + actualUri;
201
+
202
+ var url = "<?php echo $skybox_url ?>" + "WebForms/PublicSite/Tracking.aspx?" + datos + "&merchant=" + merchant + "&idCart=" + idCart + "&ReLoad=1&uri=" + actualUri;
203
+ showPopup('initSession', '', url, (widthPage - 50 ), ((heightPage < 800) ? heightPage - 50 : 800));
204
+ }
205
+
206
+ function goToLocation() {
207
+ win = 'resync';
208
+ var datos = "<?php echo $_cartDataURL ?>";
209
+ var process_url = "<?php echo Mage::helper('core/url')->getHomeUrl(); ?>" + "skbcheckout/process";
210
+ var return_url = document.URL;
211
+ var url = "<?php echo $skybox_url ?>" + "Webforms/PublicSite/ReSync.aspx?" + datos;
212
+ var change_country_status = "<?php echo $change_country ?>";
213
+ url += "&process_url=" + process_url;
214
+ url += "&return_url=" + return_url;
215
+ url += "&change_country=" + change_country_status;
216
+
217
+ var _size = getSizeForPopup();
218
+ popup = showPopup('selectLocation', '', url, _size.width, _size.height);
219
+ }
220
+
221
+ function goToTrackingLocation() {
222
+ var idCart = "<?php echo $cartId ?>";
223
+ var datos = "<?php echo $_cartDataURL ?>";
224
+ //var url = "http://www.skyboxcheckout.com/Tracking.aspx?" + datos;
225
+ var url = "<?php echo $skybox_url ?>" + "Webforms/PublicSite/Tracking.aspx?" + datos + "&idCart=" + idCart;
226
+ //console.log(url);
227
+ showPopup('tracking', '', url, (widthPage - 50 ), ((heightPage < 800) ? heightPage - 50 : 800));
228
+ }
229
+
230
+ function loadIframe() {
231
+ var actualUri = "<?php echo 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI'] ?>";
232
+ <?php $value = isset($_GET['LoadFrame']) ? $_GET['LoadFrame'] : 0; ?>
233
+ var flgLoadIframe = "<?php echo $value; ?>";
234
+ if (flgLoadIframe == "1") {
235
+ if (actualUri.indexOf("skbcheckout/international") == -1) {
236
+ goToInitializeSession();
237
+ }
238
+ }
239
+ }
240
+
241
+ var createCookie = function(name, value, days) {
242
+ var expires;
243
+ if (days) {
244
+ var date = new Date();
245
+ date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
246
+ expires = "; expires=" + date.toGMTString();
247
+ } else {
248
+ expires = "";
249
+ }
250
+ document.cookie = name + "=" + value + expires + "; path=/";
251
+ }
252
+
253
+ function getCookie(c_name) {
254
+ if (document.cookie.length > 0) {
255
+ c_start = document.cookie.indexOf(c_name + "=");
256
+ if (c_start != -1) {
257
+ c_start = c_start + c_name.length + 1;
258
+ c_end = document.cookie.indexOf(";", c_start);
259
+ if (c_end == -1) {
260
+ c_end = document.cookie.length;
261
+ }
262
+ return unescape(document.cookie.substring(c_start, c_end));
263
+ }
264
+ }
265
+ return "";
266
+ }
267
+
268
+ function postMessageIframe()
269
+ {
270
+ var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
271
+ var eventer = window[eventMethod];
272
+ var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";
273
+ eventer(messageEvent,function(e) {
274
+ // if(e.origin == 'https://www.skyboxcheckout.com'){
275
+ recalculateHeightIframe(e.data);
276
+ // }
277
+ },false);
278
+ }
279
+ function recalculateHeightIframe(data)
280
+ {
281
+ console.log('recalculateHeightIframe',data);
282
+ if(data.win == 'resync'){
283