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.9 |
Comparing to | |
See all releases |
Code changes from version 1.2.8 to 1.2.9
- app/code/community/Skybox/Catalog/Block/Bundle/Price.php +149 -149
- app/code/community/Skybox/Catalog/Block/Catalog/Category/Tab/Skyboxcheckout.php +125 -125
- app/code/community/Skybox/Catalog/Block/Product/List.php +182 -182
- app/code/community/Skybox/Catalog/Block/Product/Price.php +256 -255
- app/code/community/Skybox/Catalog/Block/Product/Widget/New.php +203 -48
- app/code/community/Skybox/Catalog/Model/Api/Product.php +937 -937
- app/code/community/Skybox/Catalog/Model/Observer.php +270 -270
- app/code/community/Skybox/Catalog/Model/Product/Attribute/Source/Categories.php +38 -38
- app/code/community/Skybox/Catalog/Model/Product/Type/Price.php +64 -64
- app/code/community/Skybox/Catalog/Model/Resource/Setup.php +11 -11
- app/code/community/Skybox/Catalog/etc/config.xml +1 -1
- app/code/community/Skybox/Catalog/sql/skyboxcatalog_setup/mysql4-install-0.1.0.php +70 -70
- app/code/community/Skybox/Checkout/Block/Cart/Item/Renderer.php +11 -11
- app/code/community/Skybox/Checkout/Block/Cart/Sidebar.php +32 -32
- app/code/community/Skybox/Checkout/Block/Cart/Totals.php +157 -157
- app/code/community/Skybox/Checkout/Block/Checkout/Cart.php +45 -45
- app/code/community/Skybox/Checkout/Block/Checkout/Cart/Sidebar.php +16 -16
- app/code/community/Skybox/Checkout/Block/Checkout/Links.php +26 -26
- app/code/community/Skybox/Checkout/Block/Checkout/Onepage/Link.php +43 -43
- app/code/community/Skybox/Checkout/Block/Sales/Order/Total.php +71 -71
- app/code/community/Skybox/Checkout/Helper/Data.php +156 -156
- app/code/community/Skybox/Checkout/Helper/Url.php +58 -58
- app/code/community/Skybox/Checkout/Model/Api/Checkout.php +222 -222
- app/code/community/Skybox/Checkout/Model/Carrier.php +36 -36
- app/code/community/Skybox/Checkout/Model/Cart.php +717 -717
- app/code/community/Skybox/Checkout/Model/Creditmemo/Total.php +17 -17
- app/code/community/Skybox/Checkout/Model/Invoice/Total.php +18 -18
- app/code/community/Skybox/Checkout/Model/Observer.php +328 -328
- app/code/community/Skybox/Checkout/Model/Pay.php +11 -11
- app/code/community/Skybox/Checkout/Model/Quote/Address/Total/Rmt.php +112 -112
- app/code/community/Skybox/Checkout/Model/Quote/Address/Total/Tax.php +5 -5
- app/code/community/Skybox/Checkout/Model/Quote/Item.php +36 -36
- app/code/community/Skybox/Checkout/Model/Quote/SubTotal.php +136 -136
- app/code/community/Skybox/Checkout/Model/Quote/Total.php +304 -304
- app/code/community/Skybox/Checkout/Model/Quote/Total2.php +7 -7
- app/code/community/Skybox/Checkout/Model/Quote/Total3.php +6 -6
- app/code/community/Skybox/Checkout/Model/Quote/Total4.php +6 -6
- app/code/community/Skybox/Checkout/Model/Quote/Total5.php +6 -6
- app/code/community/Skybox/Checkout/Model/Quote/Total6.php +6 -6
- app/code/community/Skybox/Checkout/Model/Quote/Total7.php +6 -6
- app/code/community/Skybox/Checkout/Model/Quote/Total8.php +7 -7
- app/code/community/Skybox/Checkout/controllers/CalculateController.php +138 -138
- app/code/community/Skybox/Checkout/controllers/InternationalController.php +89 -89
- app/code/community/Skybox/Checkout/controllers/ProcessController.php +352 -352
- app/code/community/Skybox/Checkout/etc/config.xml +1 -1
- app/code/community/Skybox/Checkout/etc/system.xml +127 -127
- app/code/community/Skybox/Checkout/sql/skyboxcheckout_setup/mysql4-install-0.1.0.php +132 -132
- app/code/community/Skybox/Checkout/sql/skyboxcheckout_setup/mysql4-upgrade-0.1.0-0.1.1.php +68 -68
- app/code/community/Skybox/Checkout/sql/skyboxcheckout_setup/mysql4-upgrade-0.1.0-0.1.2.php +16 -16
- app/code/community/Skybox/Checkout/sql/skyboxcheckout_setup/mysql4-upgrade-1.2.5-1.2.5.2.php +138 -138
- app/code/community/Skybox/Checkout/sql/skyboxcheckout_setup/mysql4-upgrade-1.2.5.2-1.2.6.php +138 -138
- app/code/community/Skybox/Core/Exception.php +19 -19
- app/code/community/Skybox/Core/Helper/Allow.php +236 -236
- app/code/community/Skybox/Core/Helper/Data.php +11 -11
- app/code/community/Skybox/Core/Helper/Email.php +52 -52
- app/code/community/Skybox/Core/Model/Api/Abstract.php +440 -440
- app/code/community/Skybox/Core/Model/Api/Restful.php +365 -365
- app/code/community/Skybox/Core/Model/Config.php +251 -251
- app/code/community/Skybox/Core/Model/Logservice.php +16 -16
- app/code/community/Skybox/Core/Model/Mysql4.php +16 -16
- app/code/community/Skybox/Core/Model/Mysql4/Logservice.php +22 -22
- app/code/community/Skybox/Core/Model/Mysql4/Logservice/Collection.php +17 -17
- app/code/community/Skybox/Core/Model/Session.php +29 -29
- app/code/community/Skybox/Core/Model/Standard.php +292 -292
- app/code/community/Skybox/Core/etc/config.xml +1 -1
- app/code/community/Skybox/Core/sql/skyboxcore_setup/mysql4-install-0.1.0.php +67 -67
- app/code/community/Skybox/International/Helper/Data.php +77 -77
- app/code/community/Skybox/International/Model/Config.php +15 -15
- app/code/community/Skybox/International/Model/StoreType.php +12 -12
- app/code/community/Skybox/International/etc/adminhtml.xml +39 -39
- app/code/community/Skybox/International/etc/config.xml +1 -1
- app/code/community/Skybox/International/etc/system.xml +135 -135
- app/code/community/Skybox/Services/Model/Api.php +309 -309
- app/code/community/Skybox/Services/Model/Api/V2.php +11 -11
- app/code/community/Skybox/Services/etc/api.xml +37 -37
- app/code/community/Skybox/Services/etc/config.xml +1 -1
- app/code/community/Skybox/Services/etc/wsdl.xml +141 -141
- app/code/community/Skybox/Services/etc/wsi.xml +159 -159
- app/design/adminhtml/default/default/layout/skyboxcatalog.xml +7 -7
- app/design/adminhtml/default/default/layout/skyboxinternational.xml +14 -14
- app/design/frontend/base/default/layout/skyboxcheckout.xml +204 -204
- app/design/frontend/base/default/template/skybox/checkout/cart.phtml +177 -177
- app/design/frontend/base/default/template/skybox/checkout/cart/item/default.phtml +294 -294
- app/design/frontend/base/default/template/skybox/checkout/cart/shipping.phtml +10 -10
- app/design/frontend/base/default/template/skybox/checkout/cart/sidebar.phtml +80 -80
- app/design/frontend/base/default/template/skybox/checkout/cart/sidebar/default.phtml +146 -146
- app/design/frontend/base/default/template/skybox/checkout/cart_list.phtml +195 -195
- app/design/frontend/base/default/template/skybox/checkout/multishipping/link.phtml +10 -10
- app/design/frontend/base/default/template/skybox/checkout/onepage.phtml +3 -3
- app/design/frontend/base/default/template/skybox/checkout/onepage/link.phtml +37 -37
- app/design/frontend/base/default/template/skybox/checkout/pagecheckout.phtml +31 -31
- app/design/frontend/base/default/template/skybox/checkout/skyboxcheckout.phtml +357 -357
- app/design/frontend/base/default/template/skybox/checkout/skyboxsuccess.phtml +28 -28
- app/etc/modules/Skybox_All.xml +37 -37
- js/skybox/adminhtml.category.js +10 -10
- js/skybox/jquery.ba-resize.min.js +8 -8
- js/skybox/jquery.fancybox.js +2019 -2019
- js/skybox/jquery.min.js +0 -3
app/code/community/Skybox/Catalog/Block/Bundle/Price.php
CHANGED
@@ -1,150 +1,150 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Skybox Checkout
|
4 |
-
*
|
5 |
-
* @category Mage
|
6 |
-
* @package Skybox_Catalog
|
7 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Bundle product price block
|
12 |
-
*
|
13 |
-
* @category Skybox
|
14 |
-
* @package Skybox_Catalog
|
15 |
-
*/
|
16 |
-
class Skybox_Catalog_Block_Bundle_Price extends Mage_Bundle_Block_Catalog_Product_Price
|
17 |
-
{
|
18 |
-
/*
|
19 |
-
* @var string $_cache_code
|
20 |
-
*/
|
21 |
-
public $_cache_code = null;
|
22 |
-
|
23 |
-
public function getCacheCode()
|
24 |
-
{
|
25 |
-
if ($this->_cache_code == null) {
|
26 |
-
/* @var $config Skybox_Core_Model_Config */
|
27 |
-
$config = Mage::getModel("skyboxcore/config");
|
28 |
-
$skyboxUser = $config->getSession()->getSkyboxUser();
|
29 |
-
$cache_code = $skyboxUser->CartCountryISOCode . $skyboxUser->CartCityId . $skyboxUser->CartCurrencyISOCode;
|
30 |
-
$this->_cache_code = $cache_code;
|
31 |
-
}
|
32 |
-
Mage::log("[bundle/price] Cache Code: " . $cache_code, null, 'cache.log', true);
|
33 |
-
return $this->_cache_code;
|
34 |
-
}
|
35 |
-
|
36 |
-
/*
|
37 |
-
protected function _construct()
|
38 |
-
{
|
39 |
-
//parent::__construct();
|
40 |
-
$this->addData(array(
|
41 |
-
'cache_lifetime' => 120 //seconds
|
42 |
-
));
|
43 |
-
}
|
44 |
-
*/
|
45 |
-
|
46 |
-
public function getCacheKey()
|
47 |
-
{
|
48 |
-
$cache_key = "B_PRODUCT_" . $this->getProduct()->getId() . "_" . $this->getCacheCode();
|
49 |
-
return $cache_key;
|
50 |
-
}
|
51 |
-
|
52 |
-
public function getCacheTags()
|
53 |
-
{
|
54 |
-
$cache_tag = $this->getProduct()->getId() . "_B_" . $this->getCacheCode();
|
55 |
-
return array(Mage_Catalog_Model_Product::CACHE_TAG . $cache_tag);
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Retrieve API Product
|
60 |
-
*
|
61 |
-
* @return Skybox_Catalog_Model_Api_Product
|
62 |
-
*/
|
63 |
-
protected function _getApi()
|
64 |
-
{
|
65 |
-
if (null === $this->_api) {
|
66 |
-
$this->_api = Mage::getModel('skyboxcatalog/api_product');
|
67 |
-
}
|
68 |
-
return $this->_api;
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Convert block to html string
|
73 |
-
*
|
74 |
-
* @return string
|
75 |
-
*/
|
76 |
-
public function _toHtml()
|
77 |
-
{
|
78 |
-
//return parent::_toHtml();
|
79 |
-
Mage::log("CatalogBlockPrice__toHtmlbundle ", null, 'orden.log', true);
|
80 |
-
if ($this->_getApi()->getErrorAuthenticate() && !$this->_getApi()->getLocationAllow() && $this->_getApi()->HasError()) {
|
81 |
-
return '';
|
82 |
-
} elseif ($this->_getApi()->HasError()) {
|
83 |
-
//$error_code = $this->_getApi()->getStatusCode();
|
84 |
-
$message = $this->_getApi()->getStatusMessage();
|
85 |
-
//return '<div style="color:#FF0000;">' . $message . '</div>';
|
86 |
-
Mage::log("[bundle/price] Some parameter doesn't given to Calculate Price: " . $this->_getApi()->getStatusMessage(), null, 'skyboxcheckout.log', true);
|
87 |
-
}
|
88 |
-
|
89 |
-
/* @var $product Mage_Catalog_Model_Product */
|
90 |
-
$product = $this->getProduct();
|
91 |
-
$type = $product->getTypeId();
|
92 |
-
$route_name = Mage::app()->getRequest()->getRouteName();
|
93 |
-
//Mage::log("ROUTER; ". $route_name, null, 'cart.log', true);
|
94 |
-
|
95 |
-
if ($type == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE && $this->getTemplate() == 'bundle/catalog/product/price.phtml') {
|
96 |
-
if ($route_name == 'catalog') {
|
97 |
-
return $this->calculatePrice($product);
|
98 |
-
}
|
99 |
-
|
100 |
-
// Note: we can't get the "Final Price".
|
101 |
-
// Moreover, we show "From XXX to XXX" price Block.
|
102 |
-
//return parent::_toHtml();
|
103 |
-
|
104 |
-
// Note: We make a product type: 'bundle_fixed' to calculate Price and Weight dynamically
|
105 |
-
return $this->calculatePrice($product, 'bundle_fixed');
|
106 |
-
}
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Calculate Price HTML output
|
111 |
-
*
|
112 |
-
* @param Mage_Catalog_Model_Product $product
|
113 |
-
* @return string
|
114 |
-
*/
|
115 |
-
protected function calculatePrice($product, $bundleType = 'bundle')
|
116 |
-
{
|
117 |
-
//Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter calculatePrice', null, 'tracer.log', true);
|
118 |
-
$stockItem = $product->getStockItem();
|
119 |
-
if (!$stockItem->getIsInStock()) {
|
120 |
-
return ''; // Out of Stock
|
121 |
-
}
|
122 |
-
|
123 |
-
$finalPrice = $product->getFinalPrice();
|
124 |
-
$finalPrice = ($finalPrice > 0) ? $finalPrice : null;
|
125 |
-
|
126 |
-
/*
|
127 |
-
//$weight = $product->getWeight();
|
128 |
-
$weight = $product->getTypeInstance(true)->getWeight($product);
|
129 |
-
Mage::log("[Bundle] " . $product->getName() . " : " . $finalPrice . " - [weight] " . $weight, null, 'cart.log', true);
|
130 |
-
*/
|
131 |
-
|
132 |
-
//$template = $this->_getApi()->CalculatePrice($product, null, null, 'bundle')
|
133 |
-
//$template = $this->_getApi()->CalculatePrice($product, null, $finalPrice, 'bundle')
|
134 |
-
$template = $this->_getApi()->CalculatePrice($product, null, $finalPrice, $bundleType)
|
135 |
-
->GetTemplateProduct();
|
136 |
-
|
137 |
-
$extraHtml = '<p class="label" id="skybox-configurable-price-from-'
|
138 |
-
. $product->getId()
|
139 |
-
. $this->getIdSuffix()
|
140 |
-
. '">'
|
141 |
-
. $template
|
142 |
-
. '</p>'
|
143 |
-
. '<div style="clear:both"></div>';
|
144 |
-
//$priceHtml = parent::_toHtml();
|
145 |
-
#manually insert extra html needed by the extension into the normal price html
|
146 |
-
|
147 |
-
//substr_replace($priceHtml, $extraHtml, strpos($priceHtml, $htmlToInsertAfter)+strlen($htmlToInsertAfter),0);
|
148 |
-
return $extraHtml;
|
149 |
-
}
|
150 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Skybox Checkout
|
4 |
+
*
|
5 |
+
* @category Mage
|
6 |
+
* @package Skybox_Catalog
|
7 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Bundle product price block
|
12 |
+
*
|
13 |
+
* @category Skybox
|
14 |
+
* @package Skybox_Catalog
|
15 |
+
*/
|
16 |
+
class Skybox_Catalog_Block_Bundle_Price extends Mage_Bundle_Block_Catalog_Product_Price
|
17 |
+
{
|
18 |
+
/*
|
19 |
+
* @var string $_cache_code
|
20 |
+
*/
|
21 |
+
public $_cache_code = null;
|
22 |
+
|
23 |
+
public function getCacheCode()
|
24 |
+
{
|
25 |
+
if ($this->_cache_code == null) {
|
26 |
+
/* @var $config Skybox_Core_Model_Config */
|
27 |
+
$config = Mage::getModel("skyboxcore/config");
|
28 |
+
$skyboxUser = $config->getSession()->getSkyboxUser();
|
29 |
+
$cache_code = $skyboxUser->CartCountryISOCode . $skyboxUser->CartCityId . $skyboxUser->CartCurrencyISOCode;
|
30 |
+
$this->_cache_code = $cache_code;
|
31 |
+
}
|
32 |
+
Mage::log("[bundle/price] Cache Code: " . $cache_code, null, 'cache.log', true);
|
33 |
+
return $this->_cache_code;
|
34 |
+
}
|
35 |
+
|
36 |
+
/*
|
37 |
+
protected function _construct()
|
38 |
+
{
|
39 |
+
//parent::__construct();
|
40 |
+
$this->addData(array(
|
41 |
+
'cache_lifetime' => 120 //seconds
|
42 |
+
));
|
43 |
+
}
|
44 |
+
*/
|
45 |
+
|
46 |
+
public function getCacheKey()
|
47 |
+
{
|
48 |
+
$cache_key = "B_PRODUCT_" . $this->getProduct()->getId() . "_" . $this->getCacheCode();
|
49 |
+
return $cache_key;
|
50 |
+
}
|
51 |
+
|
52 |
+
public function getCacheTags()
|
53 |
+
{
|
54 |
+
$cache_tag = $this->getProduct()->getId() . "_B_" . $this->getCacheCode();
|
55 |
+
return array(Mage_Catalog_Model_Product::CACHE_TAG . $cache_tag);
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Retrieve API Product
|
60 |
+
*
|
61 |
+
* @return Skybox_Catalog_Model_Api_Product
|
62 |
+
*/
|
63 |
+
protected function _getApi()
|
64 |
+
{
|
65 |
+
if (null === $this->_api) {
|
66 |
+
$this->_api = Mage::getModel('skyboxcatalog/api_product');
|
67 |
+
}
|
68 |
+
return $this->_api;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Convert block to html string
|
73 |
+
*
|
74 |
+
* @return string
|
75 |
+
*/
|
76 |
+
public function _toHtml()
|
77 |
+
{
|
78 |
+
//return parent::_toHtml();
|
79 |
+
Mage::log("CatalogBlockPrice__toHtmlbundle ", null, 'orden.log', true);
|
80 |
+
if ($this->_getApi()->getErrorAuthenticate() && !$this->_getApi()->getLocationAllow() && $this->_getApi()->HasError()) {
|
81 |
+
return '';
|
82 |
+
} elseif ($this->_getApi()->HasError()) {
|
83 |
+
//$error_code = $this->_getApi()->getStatusCode();
|
84 |
+
$message = $this->_getApi()->getStatusMessage();
|
85 |
+
//return '<div style="color:#FF0000;">' . $message . '</div>';
|
86 |
+
Mage::log("[bundle/price] Some parameter doesn't given to Calculate Price: " . $this->_getApi()->getStatusMessage(), null, 'skyboxcheckout.log', true);
|
87 |
+
}
|
88 |
+
|
89 |
+
/* @var $product Mage_Catalog_Model_Product */
|
90 |
+
$product = $this->getProduct();
|
91 |
+
$type = $product->getTypeId();
|
92 |
+
$route_name = Mage::app()->getRequest()->getRouteName();
|
93 |
+
//Mage::log("ROUTER; ". $route_name, null, 'cart.log', true);
|
94 |
+
|
95 |
+
if ($type == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE && $this->getTemplate() == 'bundle/catalog/product/price.phtml') {
|
96 |
+
if ($route_name == 'catalog') {
|
97 |
+
return $this->calculatePrice($product);
|
98 |
+
}
|
99 |
+
|
100 |
+
// Note: we can't get the "Final Price".
|
101 |
+
// Moreover, we show "From XXX to XXX" price Block.
|
102 |
+
//return parent::_toHtml();
|
103 |
+
|
104 |
+
// Note: We make a product type: 'bundle_fixed' to calculate Price and Weight dynamically
|
105 |
+
return $this->calculatePrice($product, 'bundle_fixed');
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Calculate Price HTML output
|
111 |
+
*
|
112 |
+
* @param Mage_Catalog_Model_Product $product
|
113 |
+
* @return string
|
114 |
+
*/
|
115 |
+
protected function calculatePrice($product, $bundleType = 'bundle')
|
116 |
+
{
|
117 |
+
//Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter calculatePrice', null, 'tracer.log', true);
|
118 |
+
$stockItem = $product->getStockItem();
|
119 |
+
if (!$stockItem->getIsInStock()) {
|
120 |
+
return ''; // Out of Stock
|
121 |
+
}
|
122 |
+
|
123 |
+
$finalPrice = $product->getFinalPrice();
|
124 |
+
$finalPrice = ($finalPrice > 0) ? $finalPrice : null;
|
125 |
+
|
126 |
+
/*
|
127 |
+
//$weight = $product->getWeight();
|
128 |
+
$weight = $product->getTypeInstance(true)->getWeight($product);
|
129 |
+
Mage::log("[Bundle] " . $product->getName() . " : " . $finalPrice . " - [weight] " . $weight, null, 'cart.log', true);
|
130 |
+
*/
|
131 |
+
|
132 |
+
//$template = $this->_getApi()->CalculatePrice($product, null, null, 'bundle')
|
133 |
+
//$template = $this->_getApi()->CalculatePrice($product, null, $finalPrice, 'bundle')
|
134 |
+
$template = $this->_getApi()->CalculatePrice($product, null, $finalPrice, $bundleType)
|
135 |
+
->GetTemplateProduct();
|
136 |
+
|
137 |
+
$extraHtml = '<p class="label" id="skybox-configurable-price-from-'
|
138 |
+
. $product->getId()
|
139 |
+
. $this->getIdSuffix()
|
140 |
+
. '">'
|
141 |
+
. $template
|
142 |
+
. '</p>'
|
143 |
+
. '<div style="clear:both"></div>';
|
144 |
+
//$priceHtml = parent::_toHtml();
|
145 |
+
#manually insert extra html needed by the extension into the normal price html
|
146 |
+
|
147 |
+
//substr_replace($priceHtml, $extraHtml, strpos($priceHtml, $htmlToInsertAfter)+strlen($htmlToInsertAfter),0);
|
148 |
+
return $extraHtml;
|
149 |
+
}
|
150 |
}
|
app/code/community/Skybox/Catalog/Block/Catalog/Category/Tab/Skyboxcheckout.php
CHANGED
@@ -1,126 +1,126 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Skybox Catalog
|
4 |
-
*
|
5 |
-
* @category Skybox
|
6 |
-
* @package Skybox_Catalog
|
7 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Admin form widget
|
12 |
-
*
|
13 |
-
* @category Skybox
|
14 |
-
* @package Skybox_Catalog
|
15 |
-
*/
|
16 |
-
class Skybox_Catalog_Block_Catalog_Category_Tab_Skyboxcheckout extends Mage_Adminhtml_Block_Widget_Form
|
17 |
-
{
|
18 |
-
public $_commodities = null;
|
19 |
-
|
20 |
-
private function _getCommoditiesData()
|
21 |
-
{
|
22 |
-
if ($this->_commodities == null) {
|
23 |
-
|
24 |
-
/* var @api_checkout Skybox_Checkout_Model_Api_Checkout*/
|
25 |
-
$api_checkout = Mage::getModel('skyboxcheckout/api_checkout');
|
26 |
-
$categories = $api_checkout->GetCategories();
|
27 |
-
|
28 |
-
$options = array('' => '');
|
29 |
-
|
30 |
-
foreach ($categories as $obj) {
|
31 |
-
$item = array(
|
32 |
-
$obj->IdCommoditie => $obj->Description,
|
33 |
-
);
|
34 |
-
//$options = array_merge($options, $item);
|
35 |
-
$options = array_replace($options, $item);
|
36 |
-
}
|
37 |
-
$this->_commodities = $options;
|
38 |
-
}
|
39 |
-
return $this->_commodities;
|
40 |
-
}
|
41 |
-
|
42 |
-
protected function _prepareForm()
|
43 |
-
{
|
44 |
-
$model = Mage::registry('category');
|
45 |
-
|
46 |
-
$form = new Varien_Data_Form(array(
|
47 |
-
'id' => 'edit_form',
|
48 |
-
'action' => $this->getData('action'),
|
49 |
-
'method' => 'post',
|
50 |
-
'enctype' => 'multipart/form-data'
|
51 |
-
));
|
52 |
-
|
53 |
-
// Form 1
|
54 |
-
// -----------------------------------------------------------------
|
55 |
-
|
56 |
-
$fieldset = $form->addFieldset('form1_fieldset',
|
57 |
-
array('legend' => Mage::helper('catalog')->__('For New Products'))
|
58 |
-
);
|
59 |
-
|
60 |
-
if ($model->getId()) {
|
61 |
-
$fieldset->addField('attribute_id', 'hidden', array(
|
62 |
-
'name' => 'attribute_id',
|
63 |
-
));
|
64 |
-
}
|
65 |
-
|
66 |
-
$options = $this->_getCommoditiesData();
|
67 |
-
|
68 |
-
$fieldset->addField('skybox_category_id', 'select', array(
|
69 |
-
'name' => 'skybox_category_id',
|
70 |
-
'label' => Mage::helper('catalog')->__('Default commodity'),
|
71 |
-
'title' => Mage::helper('catalog')->__('Default commodity'),
|
72 |
-
//'note' => Mage::helper('catalog')->__('Custom Attribute note'),
|
73 |
-
'values' => $options
|
74 |
-
));
|
75 |
-
|
76 |
-
// Form 2
|
77 |
-
// -----------------------------------------------------------------
|
78 |
-
|
79 |
-
$fieldset = $form->addFieldset('form2_fieldset',
|
80 |
-
array('legend' => Mage::helper('catalog')->__('For Existing Products in Category')));
|
81 |
-
|
82 |
-
// Buttons
|
83 |
-
$buttons = ' <br/>';
|
84 |
-
$buttons .= '<br/><button type="button" onclick = "categorySubmit2(\'' . $this->getSaveUrl() . '\', true)" > Apply All Products </button>';
|
85 |
-
$buttons .= '<br/><br/><button type="button" onclick = "categorySubmit3(\'' . $this->getSaveUrl() . '\', true)" > Apply All Products without Commodities </button>';
|
86 |
-
|
87 |
-
$fieldset->addField('skybox_category_id_select', 'select', array(
|
88 |
-
'name' => 'skybox_category_id_select',
|
89 |
-
'label' => Mage::helper('catalog')->__('Select commodity'),
|
90 |
-
'title' => Mage::helper('catalog')->__('Select commodity'),
|
91 |
-
'values' => $options,
|
92 |
-
'after_element_html' => $buttons
|
93 |
-
));
|
94 |
-
|
95 |
-
$fieldset->addField('apply_button', 'hidden', array(
|
96 |
-
'name' => 'apply_button',
|
97 |
-
));
|
98 |
-
|
99 |
-
//Mage::log("category->getData()", null, 'skyboxcheckout.log', false);
|
100 |
-
//Mage::log(print_r($model->getData(), true), null, 'skyboxcheckout.log', false);
|
101 |
-
|
102 |
-
// Set Values
|
103 |
-
$values = Mage::registry('category')->getData();
|
104 |
-
$values['apply_button'] = 'nothing';
|
105 |
-
|
106 |
-
$form->setValues($values);
|
107 |
-
$this->setForm($form);
|
108 |
-
return parent::_prepareForm();
|
109 |
-
}
|
110 |
-
|
111 |
-
protected function _getAdditionalElementTypes()
|
112 |
-
{
|
113 |
-
return array(
|
114 |
-
'apply' => Mage::getConfig()->getBlockClassName('adminhtml / catalog_product_helper_form_apply')
|
115 |
-
);
|
116 |
-
}
|
117 |
-
|
118 |
-
public function getSaveUrl(array $args = array())
|
119 |
-
{
|
120 |
-
//$params = array('_current' => true);
|
121 |
-
//$params = array_merge($params, $args);
|
122 |
-
$params = array();
|
123 |
-
return $this->getUrl('*/*/save', $params);
|
124 |
-
}
|
125 |
-
|
126 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Skybox Catalog
|
4 |
+
*
|
5 |
+
* @category Skybox
|
6 |
+
* @package Skybox_Catalog
|
7 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Admin form widget
|
12 |
+
*
|
13 |
+
* @category Skybox
|
14 |
+
* @package Skybox_Catalog
|
15 |
+
*/
|
16 |
+
class Skybox_Catalog_Block_Catalog_Category_Tab_Skyboxcheckout extends Mage_Adminhtml_Block_Widget_Form
|
17 |
+
{
|
18 |
+
public $_commodities = null;
|
19 |
+
|
20 |
+
private function _getCommoditiesData()
|
21 |
+
{
|
22 |
+
if ($this->_commodities == null) {
|
23 |
+
|
24 |
+
/* var @api_checkout Skybox_Checkout_Model_Api_Checkout*/
|
25 |
+
$api_checkout = Mage::getModel('skyboxcheckout/api_checkout');
|
26 |
+
$categories = $api_checkout->GetCategories();
|
27 |
+
|
28 |
+
$options = array('' => '');
|
29 |
+
|
30 |
+
foreach ($categories as $obj) {
|
31 |
+
$item = array(
|
32 |
+
$obj->IdCommoditie => $obj->Description,
|
33 |
+
);
|
34 |
+
//$options = array_merge($options, $item);
|
35 |
+
$options = array_replace($options, $item);
|
36 |
+
}
|
37 |
+
$this->_commodities = $options;
|
38 |
+
}
|
39 |
+
return $this->_commodities;
|
40 |
+
}
|
41 |
+
|
42 |
+
protected function _prepareForm()
|
43 |
+
{
|
44 |
+
$model = Mage::registry('category');
|
45 |
+
|
46 |
+
$form = new Varien_Data_Form(array(
|
47 |
+
'id' => 'edit_form',
|
48 |
+
'action' => $this->getData('action'),
|
49 |
+
'method' => 'post',
|
50 |
+
'enctype' => 'multipart/form-data'
|
51 |
+
));
|
52 |
+
|
53 |
+
// Form 1
|
54 |
+
// -----------------------------------------------------------------
|
55 |
+
|
56 |
+
$fieldset = $form->addFieldset('form1_fieldset',
|
57 |
+
array('legend' => Mage::helper('catalog')->__('For New Products'))
|
58 |
+
);
|
59 |
+
|
60 |
+
if ($model->getId()) {
|
61 |
+
$fieldset->addField('attribute_id', 'hidden', array(
|
62 |
+
'name' => 'attribute_id',
|
63 |
+
));
|
64 |
+
}
|
65 |
+
|
66 |
+
$options = $this->_getCommoditiesData();
|
67 |
+
|
68 |
+
$fieldset->addField('skybox_category_id', 'select', array(
|
69 |
+
'name' => 'skybox_category_id',
|
70 |
+
'label' => Mage::helper('catalog')->__('Default commodity'),
|
71 |
+
'title' => Mage::helper('catalog')->__('Default commodity'),
|
72 |
+
//'note' => Mage::helper('catalog')->__('Custom Attribute note'),
|
73 |
+
'values' => $options
|
74 |
+
));
|
75 |
+
|
76 |
+
// Form 2
|
77 |
+
// -----------------------------------------------------------------
|
78 |
+
|
79 |
+
$fieldset = $form->addFieldset('form2_fieldset',
|
80 |
+
array('legend' => Mage::helper('catalog')->__('For Existing Products in Category')));
|
81 |
+
|
82 |
+
// Buttons
|
83 |
+
$buttons = ' <br/>';
|
84 |
+
$buttons .= '<br/><button type="button" onclick = "categorySubmit2(\'' . $this->getSaveUrl() . '\', true)" > Apply All Products </button>';
|
85 |
+
$buttons .= '<br/><br/><button type="button" onclick = "categorySubmit3(\'' . $this->getSaveUrl() . '\', true)" > Apply All Products without Commodities </button>';
|
86 |
+
|
87 |
+
$fieldset->addField('skybox_category_id_select', 'select', array(
|
88 |
+
'name' => 'skybox_category_id_select',
|
89 |
+
'label' => Mage::helper('catalog')->__('Select commodity'),
|
90 |
+
'title' => Mage::helper('catalog')->__('Select commodity'),
|
91 |
+
'values' => $options,
|
92 |
+
'after_element_html' => $buttons
|
93 |
+
));
|
94 |
+
|
95 |
+
$fieldset->addField('apply_button', 'hidden', array(
|
96 |
+
'name' => 'apply_button',
|
97 |
+
));
|
98 |
+
|
99 |
+
//Mage::log("category->getData()", null, 'skyboxcheckout.log', false);
|
100 |
+
//Mage::log(print_r($model->getData(), true), null, 'skyboxcheckout.log', false);
|
101 |
+
|
102 |
+
// Set Values
|
103 |
+
$values = Mage::registry('category')->getData();
|
104 |
+
$values['apply_button'] = 'nothing';
|
105 |
+
|
106 |
+
$form->setValues($values);
|
107 |
+
$this->setForm($form);
|
108 |
+
return parent::_prepareForm();
|
109 |
+
}
|
110 |
+
|
111 |
+
protected function _getAdditionalElementTypes()
|
112 |
+
{
|
113 |
+
return array(
|
114 |
+
'apply' => Mage::getConfig()->getBlockClassName('adminhtml / catalog_product_helper_form_apply')
|
115 |
+
);
|
116 |
+
}
|
117 |
+
|
118 |
+
public function getSaveUrl(array $args = array())
|
119 |
+
{
|
120 |
+
//$params = array('_current' => true);
|
121 |
+
//$params = array_merge($params, $args);
|
122 |
+
$params = array();
|
123 |
+
return $this->getUrl('*/*/save', $params);
|
124 |
+
}
|
125 |
+
|
126 |
}
|
app/code/community/Skybox/Catalog/Block/Product/List.php
CHANGED
@@ -1,182 +1,182 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Skybox Checkout
|
4 |
-
*
|
5 |
-
* @category Skybox
|
6 |
-
* @package Skybox_Catalog
|
7 |
-
* @copyright Copyright (c) 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Product list
|
12 |
-
*/
|
13 |
-
class Skybox_Catalog_Block_Product_List extends Mage_Catalog_Block_Product_List
|
14 |
-
{
|
15 |
-
public $_sky_cache_code = null;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Retrieve API Product
|
19 |
-
*
|
20 |
-
* @return Skybox_Catalog_Model_Api_Product
|
21 |
-
*/
|
22 |
-
protected function _getApi()
|
23 |
-
{
|
24 |
-
if (null === $this->_api) {
|
25 |
-
$this->_api = Mage::getModel('skyboxcatalog/api_product');
|
26 |
-
}
|
27 |
-
return $this->_api;
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Need use as _prepareLayout - but problem in declaring collection from
|
32 |
-
* another block (was problem with search result)
|
33 |
-
*/
|
34 |
-
protected function _beforeToHtml()
|
35 |
-
{
|
36 |
-
$result = parent::_beforeToHtml();
|
37 |
-
|
38 |
-
if (!$this->isEnable()) {
|
39 |
-
return $result;
|
40 |
-
}
|
41 |
-
|
42 |
-
$api_checkout = Mage::getModel('skyboxcheckout/api_checkout');
|
43 |
-
$api_checkout->InitializeBarSkybox();
|
44 |
-
|
45 |
-
// $session = Mage::getSingleton("core/session", array("name" => "frontend"));
|
46 |
-
// $sky = $session->getData("skyBox");
|
47 |
-
|
48 |
-
$data = $api_checkout->getValueAccessService();
|
49 |
-
|
50 |
-
$skyBoxUrlClient = Mage::helper('skyboxinternational/data')->getSkyBoxUrlAPI();
|
51 |
-
$skyBoxUrlClient = $skyBoxUrlClient . ("multiplecalculate");
|
52 |
-
|
53 |
-
$dataJson = null;
|
54 |
-
$multiCalculate = 1;
|
55 |
-
|
56 |
-
try {
|
57 |
-
// $products = $this->_getProductCollection();
|
58 |
-
$products = $this->getToolbarBlock()->getCollection();
|
59 |
-
|
60 |
-
foreach ($products as $prod) {
|
61 |
-
$product = Mage::getModel('catalog/product')->load($prod->getId());
|
62 |
-
$data['listproducts'][] = $this->getUrlService($product);
|
63 |
-
$dataJson = json_encode($data);
|
64 |
-
}
|
65 |
-
|
66 |
-
$response = $this->multiCalculatePrice($skyBoxUrlClient, $dataJson);
|
67 |
-
// Mage::log(print_r($response, true), null, 'multicalculate.log', true);
|
68 |
-
// Mage::log(print_r($dataJson, true), null, 'multicalculate.log', true);
|
69 |
-
|
70 |
-
} catch (\Exception $e) {
|
71 |
-
$multiCalculate = 0;
|
72 |
-
// Mage::log(print_r($dataJson, true), null, 'multicalculate.log', true);
|
73 |
-
// Mage::log("[multicalculate] " . $e->getMessage(), null, 'multicalculate.log', true);
|
74 |
-
}
|
75 |
-
|
76 |
-
Mage::unregister('skybox_multicalculate');
|
77 |
-
Mage::register('skybox_multicalculate', $multiCalculate);
|
78 |
-
// Mage::registry('skybox_multicalculate');
|
79 |
-
|
80 |
-
return $result;
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* Return the Skybox Cache code
|
85 |
-
*
|
86 |
-
* @param $productId
|
87 |
-
* @return mixed
|
88 |
-
*/
|
89 |
-
public function getSkyboxCacheCode($productId)
|
90 |
-
{
|
91 |
-
if ($this->_sky_cache_code == null) {
|
92 |
-
/* @var $config Skybox_Core_Model_Config */
|
93 |
-
$config = Mage::getModel("skyboxcore/config");
|
94 |
-
$skyboxUser = $config->getSession()->getSkyboxUser();
|
95 |
-
$country_iso_code = strtoupper($skyboxUser->CartCountryISOCode);
|
96 |
-
$cache_code = $country_iso_code . "[REPLACE]" . $skyboxUser->CartCurrencyISOCode;
|
97 |
-
$this->_sky_cache_code = $cache_code;
|
98 |
-
}
|
99 |
-
|
100 |
-
$result = str_replace('[REPLACE]', $productId, $this->_sky_cache_code);
|
101 |
-
return $result;
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* @param $product
|
106 |
-
* @return array|string
|
107 |
-
*/
|
108 |
-
public function getUrlService($product)
|
109 |
-
{
|
110 |
-
$type = $product->getTypeId();
|
111 |
-
$template = '';
|
112 |
-
|
113 |
-
switch ($type) {
|
114 |
-
case 'simple':
|
115 |
-
$template = $this->_getApi()->getUrl($product->getId(), null, $product->getFinalPrice(),
|
116 |
-
$product->getTypeId());
|
117 |
-
break;
|
118 |
-
case 'configurable':
|
119 |
-
$template = $this->_getApi()->getUrl($product->getId(), null, $product->getFinalPrice(),
|
120 |
-
$product->getTypeId());
|
121 |
-
break;
|
122 |
-
case 'bundle':
|
123 |
-
$template = $this->_getApi()->getUrl($product, null, $product->getFinalPrice(), 'simple');
|
124 |
-
break;
|
125 |
-
}
|
126 |
-
|
127 |
-
if (is_array($template)) {
|
128 |
-
$productId = $template['htmlobjectid'];
|
129 |
-
$cache_code = $this->getSkyboxCacheCode($productId);
|
130 |
-
$template['htmlobjectid'] = $cache_code;
|
131 |
-
}
|
132 |
-
return $template;
|
133 |
-
}
|
134 |
-
|
135 |
-
/**
|
136 |
-
* Return Multi CalculatePrice
|
137 |
-
*
|
138 |
-
* @param $url
|
139 |
-
* @param $data
|
140 |
-
* @return mixed
|
141 |
-
* @throws Exception
|
142 |
-
*/
|
143 |
-
function multiCalculatePrice($url, $data)
|
144 |
-
{
|
145 |
-
$ch = curl_init();
|
146 |
-
curl_setopt($ch, CURLOPT_URL, $url);
|
147 |
-
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
148 |
-
curl_setopt($ch, CURLOPT_POST, 1);
|
149 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
150 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
151 |
-
$response = curl_exec($ch);
|
152 |
-
|
153 |
-
$response = json_decode($response, true);
|
154 |
-
|
155 |
-
if ($response['StatusCode'] != 'Success') {
|
156 |
-
throw new \Exception('Missing or invalid data send to MultiCalculate');
|
157 |
-
}
|
158 |
-
return $response;
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* is Enable?
|
163 |
-
*
|
164 |
-
* @return bool
|
165 |
-
*/
|
166 |
-
private function isEnable()
|
167 |
-
{
|
168 |
-
$isModuleEnable = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
169 |
-
if (!$isModuleEnable) {
|
170 |
-
return false;
|
171 |
-
}
|
172 |
-
|
173 |
-
/** @var Skybox_Core_Helper_Allow $allowHelper */
|
174 |
-
$allowHelper = Mage::helper('skyboxcore/allow');
|
175 |
-
|
176 |
-
if (!$allowHelper->isPriceEnabled()) {
|
177 |
-
return false;
|
178 |
-
}
|
179 |
-
|
180 |
-
return true;
|
181 |
-
}
|
182 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Skybox Checkout
|
4 |
+
*
|
5 |
+
* @category Skybox
|
6 |
+
* @package Skybox_Catalog
|
7 |
+
* @copyright Copyright (c) 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Product list
|
12 |
+
*/
|
13 |
+
class Skybox_Catalog_Block_Product_List extends Mage_Catalog_Block_Product_List
|
14 |
+
{
|
15 |
+
public $_sky_cache_code = null;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Retrieve API Product
|
19 |
+
*
|
20 |
+
* @return Skybox_Catalog_Model_Api_Product
|
21 |
+
*/
|
22 |
+
protected function _getApi()
|
23 |
+
{
|
24 |
+
if (null === $this->_api) {
|
25 |
+
$this->_api = Mage::getModel('skyboxcatalog/api_product');
|
26 |
+
}
|
27 |
+
return $this->_api;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Need use as _prepareLayout - but problem in declaring collection from
|
32 |
+
* another block (was problem with search result)
|
33 |
+
*/
|
34 |
+
protected function _beforeToHtml()
|
35 |
+
{
|
36 |
+
$result = parent::_beforeToHtml();
|
37 |
+
|
38 |
+
if (!$this->isEnable()) {
|
39 |
+
return $result;
|
40 |
+
}
|
41 |
+
|
42 |
+
$api_checkout = Mage::getModel('skyboxcheckout/api_checkout');
|
43 |
+
$api_checkout->InitializeBarSkybox();
|
44 |
+
|
45 |
+
// $session = Mage::getSingleton("core/session", array("name" => "frontend"));
|
46 |
+
// $sky = $session->getData("skyBox");
|
47 |
+
|
48 |
+
$data = $api_checkout->getValueAccessService();
|
49 |
+
|
50 |
+
$skyBoxUrlClient = Mage::helper('skyboxinternational/data')->getSkyBoxUrlAPI();
|
51 |
+
$skyBoxUrlClient = $skyBoxUrlClient . ("multiplecalculate");
|
52 |
+
|
53 |
+
$dataJson = null;
|
54 |
+
$multiCalculate = 1;
|
55 |
+
|
56 |
+
try {
|
57 |
+
// $products = $this->_getProductCollection();
|
58 |
+
$products = $this->getToolbarBlock()->getCollection();
|
59 |
+
|
60 |
+
foreach ($products as $prod) {
|
61 |
+
$product = Mage::getModel('catalog/product')->load($prod->getId());
|
62 |
+
$data['listproducts'][] = $this->getUrlService($product);
|
63 |
+
$dataJson = json_encode($data);
|
64 |
+
}
|
65 |
+
|
66 |
+
$response = $this->multiCalculatePrice($skyBoxUrlClient, $dataJson);
|
67 |
+
// Mage::log(print_r($response, true), null, 'multicalculate.log', true);
|
68 |
+
// Mage::log(print_r($dataJson, true), null, 'multicalculate.log', true);
|
69 |
+
|
70 |
+
} catch (\Exception $e) {
|
71 |
+
$multiCalculate = 0;
|
72 |
+
// Mage::log(print_r($dataJson, true), null, 'multicalculate.log', true);
|
73 |
+
// Mage::log("[multicalculate] " . $e->getMessage(), null, 'multicalculate.log', true);
|
74 |
+
}
|
75 |
+
|
76 |
+
Mage::unregister('skybox_multicalculate');
|
77 |
+
Mage::register('skybox_multicalculate', $multiCalculate);
|
78 |
+
// Mage::registry('skybox_multicalculate');
|
79 |
+
|
80 |
+
return $result;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Return the Skybox Cache code
|
85 |
+
*
|
86 |
+
* @param $productId
|
87 |
+
* @return mixed
|
88 |
+
*/
|
89 |
+
public function getSkyboxCacheCode($productId)
|
90 |
+
{
|
91 |
+
if ($this->_sky_cache_code == null) {
|
92 |
+
/* @var $config Skybox_Core_Model_Config */
|
93 |
+
$config = Mage::getModel("skyboxcore/config");
|
94 |
+
$skyboxUser = $config->getSession()->getSkyboxUser();
|
95 |
+
$country_iso_code = strtoupper($skyboxUser->CartCountryISOCode);
|
96 |
+
$cache_code = $country_iso_code . "[REPLACE]" . $skyboxUser->CartCurrencyISOCode;
|
97 |
+
$this->_sky_cache_code = $cache_code;
|
98 |
+
}
|
99 |
+
|
100 |
+
$result = str_replace('[REPLACE]', $productId, $this->_sky_cache_code);
|
101 |
+
return $result;
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* @param $product
|
106 |
+
* @return array|string
|
107 |
+
*/
|
108 |
+
public function getUrlService($product)
|
109 |
+
{
|
110 |
+
$type = $product->getTypeId();
|
111 |
+
$template = '';
|
112 |
+
|
113 |
+
switch ($type) {
|
114 |
+
case 'simple':
|
115 |
+
$template = $this->_getApi()->getUrl($product->getId(), null, $product->getFinalPrice(),
|
116 |
+
$product->getTypeId());
|
117 |
+
break;
|
118 |
+
case 'configurable':
|
119 |
+
$template = $this->_getApi()->getUrl($product->getId(), null, $product->getFinalPrice(),
|
120 |
+
$product->getTypeId());
|
121 |
+
break;
|
122 |
+
case 'bundle':
|
123 |
+
$template = $this->_getApi()->getUrl($product, null, $product->getFinalPrice(), 'simple');
|
124 |
+
break;
|
125 |
+
}
|
126 |
+
|
127 |
+
if (is_array($template)) {
|
128 |
+
$productId = $template['htmlobjectid'];
|
129 |
+
$cache_code = $this->getSkyboxCacheCode($productId);
|
130 |
+
$template['htmlobjectid'] = $cache_code;
|
131 |
+
}
|
132 |
+
return $template;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Return Multi CalculatePrice
|
137 |
+
*
|
138 |
+
* @param $url
|
139 |
+
* @param $data
|
140 |
+
* @return mixed
|
141 |
+
* @throws Exception
|
142 |
+
*/
|
143 |
+
function multiCalculatePrice($url, $data)
|
144 |
+
{
|
145 |
+
$ch = curl_init();
|
146 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
147 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
148 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
149 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
150 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
151 |
+
$response = curl_exec($ch);
|
152 |
+
|
153 |
+
$response = json_decode($response, true);
|
154 |
+
|
155 |
+
if ($response['StatusCode'] != 'Success') {
|
156 |
+
throw new \Exception('Missing or invalid data send to MultiCalculate');
|
157 |
+
}
|
158 |
+
return $response;
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* is Enable?
|
163 |
+
*
|
164 |
+
* @return bool
|
165 |
+
*/
|
166 |
+
private function isEnable()
|
167 |
+
{
|
168 |
+
$isModuleEnable = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
169 |
+
if (!$isModuleEnable) {
|
170 |
+
return false;
|
171 |
+
}
|
172 |
+
|
173 |
+
/** @var Skybox_Core_Helper_Allow $allowHelper */
|
174 |
+
$allowHelper = Mage::helper('skyboxcore/allow');
|
175 |
+
|
176 |
+
if (!$allowHelper->isPriceEnabled()) {
|
177 |
+
return false;
|
178 |
+
}
|
179 |
+
|
180 |
+
return true;
|
181 |
+
}
|
182 |
+
}
|
app/code/community/Skybox/Catalog/Block/Product/Price.php
CHANGED
@@ -1,255 +1,256 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Skybox Checkout
|
4 |
-
*
|
5 |
-
* @category Mage
|
6 |
-
* @package Skybox_Catalog
|
7 |
-
* @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
*
|
12 |
-
* Product Price Block
|
13 |
-
*/
|
14 |
-
class Skybox_Catalog_Block_Product_Price extends Mage_Catalog_Block_Product_Price
|
15 |
-
{
|
16 |
-
public $_cache_code = null;
|
17 |
-
public $_sky_cache_code = null;
|
18 |
-
|
19 |
-
public function getCacheCode()
|
20 |
-
{
|
21 |
-
Mage::log("cache ", null, 'orden.log', true);
|
22 |
-
if ($this->_cache_code == null) {
|
23 |
-
/* @var $config Skybox_Core_Model_Config */
|
24 |
-
$config = Mage::getModel("skyboxcore/config");
|
25 |
-
$skyboxUser = $config->getSession()->getSkyboxUser();
|
26 |
-
$cache_code = $skyboxUser->CartCountryISOCode . $skyboxUser->CartCityId . $skyboxUser->CartCurrencyISOCode;
|
27 |
-
$this->_cache_code = $cache_code;
|
28 |
-
}
|
29 |
-
Mage::log("[product/price] Cache Code: " . $cache_code, null, 'cache.log', true);
|
30 |
-
return $this->_cache_code;
|
31 |
-
}
|
32 |
-
|
33 |
-
/*
|
34 |
-
protected function _construct()
|
35 |
-
{
|
36 |
-
//parent::__construct();
|
37 |
-
$this->addData(array(
|
38 |
-
'cache_lifetime' => 120 //seconds
|
39 |
-
));
|
40 |
-
}
|
41 |
-
*/
|
42 |
-
|
43 |
-
public function getCacheKey()
|
44 |
-
{
|
45 |
-
$cache_key = "PRODUCT_" . $this->getProduct()->getId() . "_" . $this->getCacheCode();
|
46 |
-
return $cache_key;
|
47 |
-
}
|
48 |
-
|
49 |
-
public function getCacheTags()
|
50 |
-
{
|
51 |
-
$cache_tag = $this->getProduct()->getId() . "_" . $this->getCacheCode();
|
52 |
-
return array(Mage_Catalog_Model_Product::CACHE_TAG . $cache_tag);
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Retrieve API Product
|
57 |
-
*
|
58 |
-
* @return Skybox_Catalog_Model_Api_Product
|
59 |
-
*/
|
60 |
-
protected function _getApi()
|
61 |
-
{
|
62 |
-
if (null === $this->_api) {
|
63 |
-
$this->_api = Mage::getModel('skyboxcatalog/api_product');
|
64 |
-
}
|
65 |
-
return $this->_api;
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Render block HTML
|
70 |
-
*
|
71 |
-
* @return string
|
72 |
-
*/
|
73 |
-
public function _toHtml()
|
74 |
-
{
|
75 |
-
$isModuleEnable = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
76 |
-
|
77 |
-
if (!$isModuleEnable) {
|
78 |
-
return parent::_toHtml();
|
79 |
-
}
|
80 |
-
|
81 |
-
/** @var Skybox_Core_Helper_Allow $allowHelper */
|
82 |
-
$allowHelper = Mage::helper('skyboxcore/allow');
|
83 |
-
|
84 |
-
if ($allowHelper->isPriceEnabled()) {
|
85 |
-
|
86 |
-
if ($this->_getApi()->getErrorAuthenticate() && !$this->_getApi()->getLocationAllow() && $this->_getApi()->HasError()) {
|
87 |
-
return '';
|
88 |
-
} elseif ($this->_getApi()->HasError()) {
|
89 |
-
//$error_code = $this->_getApi()->getStatusCode();
|
90 |
-
$message = $this->_getApi()->getStatusMessage();
|
91 |
-
|
92 |
-
if ($this->_getApi()->_getApi()->ErrorRatesNotFound()) {
|
93 |
-
$message = $this->_getApi()->_getApi()->getErrorRatesNotFoundMessage($this->getLanguageId());
|
94 |
-
return '<div style="color:#FF0000;">' . $message . '</div>';
|
95 |
-
}
|
96 |
-
|
97 |
-
// return '<div style="color:#FF0000;">' . $message . '</div>';
|
98 |
-
return '';
|
99 |
-
}
|
100 |
-
|
101 |
-
/* @var Mage_Catalog_Model_Product $product */
|
102 |
-
$product = $this->getProduct();
|
103 |
-
$type = $product->getTypeId();
|
104 |
-
$route_name = Mage::app()->getRequest()->getRouteName();
|
105 |
-
|
106 |
-
// Simple Product
|
107 |
-
if ($type == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE && $this->getTemplate() == 'catalog/product/price.phtml') {
|
108 |
-
return $this->calculatePrice($product);
|
109 |
-
}
|
110 |
-
|
111 |
-
if ($type == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE && $this->getTemplate() == 'catalog/product/view/price_clone.phtml') {
|
112 |
-
return '';
|
113 |
-
}
|
114 |
-
|
115 |
-
// Configurable Product
|
116 |
-
if ($type == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE && $this->getTemplate() == 'catalog/product/price.phtml') {
|
117 |
-
|
118 |
-
if (Mage::registry('current_product')) {
|
119 |
-
return "";
|
120 |
-
}
|
121 |
-
|
122 |
-
return $this->calculatePrice($product);
|
123 |
-
}
|
124 |
-
|
125 |
-
if ($type == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE && $this->getTemplate() == 'catalog/product/view/tierprices.phtml') {
|
126 |
-
if ($route_name == 'catalog') {
|
127 |
-
return $this->calculatePrice($product);
|
128 |
-
}
|
129 |
-
return '';
|
130 |
-
}
|
131 |
-
|
132 |
-
}
|
133 |
-
|
134 |
-
return parent::_toHtml();
|
135 |
-
}
|
136 |
-
|
137 |
-
/**
|
138 |
-
* Calculate Price HTML output
|
139 |
-
*
|
140 |
-
* @param Mage_Catalog_Model_Product $product
|
141 |
-
* @return string
|
142 |
-
*/
|
143 |
-
protected function calculatePrice($product)
|
144 |
-
{
|
145 |
-
//Mage::log('Entro calcular producto', null, 'tracer.log', true);
|
146 |
-
$stockItem = $product->getStockItem();
|
147 |
-
// if (!$stockItem->getIsInStock()) {
|
148 |
-
// Mage::log('sin stock', null, 'tracer.log', true);
|
149 |
-
// return ''; // Out of Stock
|
150 |
-
// }
|
151 |
-
|
152 |
-
$type = $product->getTypeId();
|
153 |
-
//Mage::log(print_r('product\Price: '.$type, true), null, 'tracer.log', true);
|
154 |
-
|
155 |
-
$multiCalculate = Mage::registry('skybox_multicalculate');
|
156 |
-
|
157 |
-
// if ($multiCalculate and Mage::registry('current_category') and (!(Mage::registry('current_product')))) {
|
158 |
-
|
159 |
-
if ($multiCalculate && Mage::registry('current_category')) {
|
160 |
-
|
161 |
-
|
162 |
-
*
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
$
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
->
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
->
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
// Mage::log(print_r(
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
. '<
|
197 |
-
.
|
198 |
-
. $
|
199 |
-
.
|
200 |
-
.
|
201 |
-
.
|
202 |
-
. '</
|
203 |
-
. '
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
. '<
|
209 |
-
.
|
210 |
-
. $
|
211 |
-
.
|
212 |
-
.
|
213 |
-
.
|
214 |
-
. '</
|
215 |
-
. '
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
*
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
$
|
231 |
-
$
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
*
|
238 |
-
*
|
239 |
-
* @
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
$config
|
246 |
-
$
|
247 |
-
$
|
248 |
-
$
|
249 |
-
$
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
}
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Skybox Checkout
|
4 |
+
*
|
5 |
+
* @category Mage
|
6 |
+
* @package Skybox_Catalog
|
7 |
+
* @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
*
|
12 |
+
* Product Price Block
|
13 |
+
*/
|
14 |
+
class Skybox_Catalog_Block_Product_Price extends Mage_Catalog_Block_Product_Price
|
15 |
+
{
|
16 |
+
public $_cache_code = null;
|
17 |
+
public $_sky_cache_code = null;
|
18 |
+
|
19 |
+
public function getCacheCode()
|
20 |
+
{
|
21 |
+
Mage::log("cache ", null, 'orden.log', true);
|
22 |
+
if ($this->_cache_code == null) {
|
23 |
+
/* @var $config Skybox_Core_Model_Config */
|
24 |
+
$config = Mage::getModel("skyboxcore/config");
|
25 |
+
$skyboxUser = $config->getSession()->getSkyboxUser();
|
26 |
+
$cache_code = $skyboxUser->CartCountryISOCode . $skyboxUser->CartCityId . $skyboxUser->CartCurrencyISOCode;
|
27 |
+
$this->_cache_code = $cache_code;
|
28 |
+
}
|
29 |
+
Mage::log("[product/price] Cache Code: " . $cache_code, null, 'cache.log', true);
|
30 |
+
return $this->_cache_code;
|
31 |
+
}
|
32 |
+
|
33 |
+
/*
|
34 |
+
protected function _construct()
|
35 |
+
{
|
36 |
+
//parent::__construct();
|
37 |
+
$this->addData(array(
|
38 |
+
'cache_lifetime' => 120 //seconds
|
39 |
+
));
|
40 |
+
}
|
41 |
+
*/
|
42 |
+
|
43 |
+
public function getCacheKey()
|
44 |
+
{
|
45 |
+
$cache_key = "PRODUCT_" . $this->getProduct()->getId() . "_" . $this->getCacheCode();
|
46 |
+
return $cache_key;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function getCacheTags()
|
50 |
+
{
|
51 |
+
$cache_tag = $this->getProduct()->getId() . "_" . $this->getCacheCode();
|
52 |
+
return array(Mage_Catalog_Model_Product::CACHE_TAG . $cache_tag);
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Retrieve API Product
|
57 |
+
*
|
58 |
+
* @return Skybox_Catalog_Model_Api_Product
|
59 |
+
*/
|
60 |
+
protected function _getApi()
|
61 |
+
{
|
62 |
+
if (null === $this->_api) {
|
63 |
+
$this->_api = Mage::getModel('skyboxcatalog/api_product');
|
64 |
+
}
|
65 |
+
return $this->_api;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Render block HTML
|
70 |
+
*
|
71 |
+
* @return string
|
72 |
+
*/
|
73 |
+
public function _toHtml()
|
74 |
+
{
|
75 |
+
$isModuleEnable = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
76 |
+
|
77 |
+
if (!$isModuleEnable) {
|
78 |
+
return parent::_toHtml();
|
79 |
+
}
|
80 |
+
|
81 |
+
/** @var Skybox_Core_Helper_Allow $allowHelper */
|
82 |
+
$allowHelper = Mage::helper('skyboxcore/allow');
|
83 |
+
|
84 |
+
if ($allowHelper->isPriceEnabled()) {
|
85 |
+
|
86 |
+
if ($this->_getApi()->getErrorAuthenticate() && !$this->_getApi()->getLocationAllow() && $this->_getApi()->HasError()) {
|
87 |
+
return '';
|
88 |
+
} elseif ($this->_getApi()->HasError()) {
|
89 |
+
//$error_code = $this->_getApi()->getStatusCode();
|
90 |
+
$message = $this->_getApi()->getStatusMessage();
|
91 |
+
|
92 |
+
if ($this->_getApi()->_getApi()->ErrorRatesNotFound()) {
|
93 |
+
$message = $this->_getApi()->_getApi()->getErrorRatesNotFoundMessage($this->getLanguageId());
|
94 |
+
return '<div style="color:#FF0000;">' . $message . '</div>';
|
95 |
+
}
|
96 |
+
|
97 |
+
// return '<div style="color:#FF0000;">' . $message . '</div>';
|
98 |
+
return '';
|
99 |
+
}
|
100 |
+
|
101 |
+
/* @var Mage_Catalog_Model_Product $product */
|
102 |
+
$product = $this->getProduct();
|
103 |
+
$type = $product->getTypeId();
|
104 |
+
$route_name = Mage::app()->getRequest()->getRouteName();
|
105 |
+
|
106 |
+
// Simple Product
|
107 |
+
if ($type == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE && $this->getTemplate() == 'catalog/product/price.phtml') {
|
108 |
+
return $this->calculatePrice($product);
|
109 |
+
}
|
110 |
+
|
111 |
+
if ($type == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE && $this->getTemplate() == 'catalog/product/view/price_clone.phtml') {
|
112 |
+
return '';
|
113 |
+
}
|
114 |
+
|
115 |
+
// Configurable Product
|
116 |
+
if ($type == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE && $this->getTemplate() == 'catalog/product/price.phtml') {
|
117 |
+
|
118 |
+
if (Mage::registry('current_product')) {
|
119 |
+
return "";
|
120 |
+
}
|
121 |
+
|
122 |
+
return $this->calculatePrice($product);
|
123 |
+
}
|
124 |
+
|
125 |
+
if ($type == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE && $this->getTemplate() == 'catalog/product/view/tierprices.phtml') {
|
126 |
+
if ($route_name == 'catalog') {
|
127 |
+
return $this->calculatePrice($product);
|
128 |
+
}
|
129 |
+
return '';
|
130 |
+
}
|
131 |
+
|
132 |
+
}
|
133 |
+
|
134 |
+
return parent::_toHtml();
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Calculate Price HTML output
|
139 |
+
*
|
140 |
+
* @param Mage_Catalog_Model_Product $product
|
141 |
+
* @return string
|
142 |
+
*/
|
143 |
+
protected function calculatePrice($product)
|
144 |
+
{
|
145 |
+
//Mage::log('Entro calcular producto', null, 'tracer.log', true);
|
146 |
+
$stockItem = $product->getStockItem();
|
147 |
+
// if (!$stockItem->getIsInStock()) {
|
148 |
+
// Mage::log('sin stock', null, 'tracer.log', true);
|
149 |
+
// return ''; // Out of Stock
|
150 |
+
// }
|
151 |
+
|
152 |
+
$type = $product->getTypeId();
|
153 |
+
//Mage::log(print_r('product\Price: '.$type, true), null, 'tracer.log', true);
|
154 |
+
|
155 |
+
$multiCalculate = Mage::registry('skybox_multicalculate');
|
156 |
+
|
157 |
+
// if ($multiCalculate and Mage::registry('current_category') and (!(Mage::registry('current_product')))) {
|
158 |
+
|
159 |
+
// if ($multiCalculate && Mage::registry('current_category')) {
|
160 |
+
if ($multiCalculate) {
|
161 |
+
/**
|
162 |
+
* Apply multiple calculate start
|
163 |
+
* When: is different to product detail and you are on catalog category
|
164 |
+
*/
|
165 |
+
// $template = '<div class="skybox-price-set" product-id="' . $product->getId() . '" id="product-' . $product->getId() . '"></div>';
|
166 |
+
|
167 |
+
$cache_code = $this->getSkyboxCacheCode($product->getId());
|
168 |
+
$template = '<div class="skybox-price-set" product-id="' . $cache_code . '" id="product-' . $product->getId() . '"></div>';
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Apply multiple calculate end
|
172 |
+
*/
|
173 |
+
} else {
|
174 |
+
switch ($type) {
|
175 |
+
case 'simple':
|
176 |
+
$template = $this->_getApi()->CalculatePrice($product->getId(), null, $product->getFinalPrice(),
|
177 |
+
$product->getTypeId())
|
178 |
+
->GetTemplateProduct();
|
179 |
+
break;
|
180 |
+
case 'configurable':
|
181 |
+
$template = $this->_getApi()->CalculatePrice($product->getId(), null, $product->getFinalPrice(),
|
182 |
+
$product->getTypeId())
|
183 |
+
->GetTemplateProduct();
|
184 |
+
break;
|
185 |
+
case 'bundle':
|
186 |
+
$template = $this->_getApi()->CalculatePrice($product, null, $product->getFinalPrice(), 'simple')
|
187 |
+
->GetTemplateProduct();
|
188 |
+
break;
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
// Mage::log(print_r('##Product template##', true), null, 'tracer.log', true);
|
193 |
+
// Mage::log(print_r($template, true), null, 'tracer.log', true);
|
194 |
+
/*
|
195 |
+
$extraHtml = ''
|
196 |
+
. '<div class="price-box">'
|
197 |
+
. '<p class="label" id="skybox-configurable-price-from-'
|
198 |
+
. $product->getId()
|
199 |
+
. $this->getIdSuffix()
|
200 |
+
. '">'
|
201 |
+
. $template
|
202 |
+
. '</p>'
|
203 |
+
. '</div>'
|
204 |
+
. '<div style="clear:both"></div>';
|
205 |
+
|
206 |
+
*/
|
207 |
+
$extraHtml = ''
|
208 |
+
. '<div class="price-box">'
|
209 |
+
. '<p class="label" id="skybox-configurable-price-from-'
|
210 |
+
. $product->getId()
|
211 |
+
. $this->getIdSuffix()
|
212 |
+
. '">'
|
213 |
+
. $template
|
214 |
+
. '</p>'
|
215 |
+
. '</div>'
|
216 |
+
. '<div style="clear:both"></div>';
|
217 |
+
//$priceHtml = parent::_toHtml();
|
218 |
+
#manually insert extra html needed by the extension into the normal price html
|
219 |
+
|
220 |
+
//substr_replace($priceHtml, $extraHtml, strpos($priceHtml, $htmlToInsertAfter)+strlen($htmlToInsertAfter),0);
|
221 |
+
return $extraHtml;
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Return the Language Id
|
226 |
+
* @return int
|
227 |
+
*/
|
228 |
+
private function getLanguageId()
|
229 |
+
{
|
230 |
+
$_config = Mage::getModel('skyboxcore/config');
|
231 |
+
$cart = $_config->getSession()->getCartSkybox();
|
232 |
+
$id = $cart->{'LanguageId'};
|
233 |
+
return intval($id);
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* Return the Skybox Cache code
|
238 |
+
*
|
239 |
+
* @param $productId
|
240 |
+
* @return mixed
|
241 |
+
*/
|
242 |
+
public function getSkyboxCacheCode($productId)
|
243 |
+
{
|
244 |
+
if ($this->_sky_cache_code == null) {
|
245 |
+
/* @var $config Skybox_Core_Model_Config */
|
246 |
+
$config = Mage::getModel("skyboxcore/config");
|
247 |
+
$skyboxUser = $config->getSession()->getSkyboxUser();
|
248 |
+
$country_iso_code = strtoupper($skyboxUser->CartCountryISOCode);
|
249 |
+
$cache_code = $country_iso_code . "[REPLACE]" . $skyboxUser->CartCurrencyISOCode;
|
250 |
+
$this->_sky_cache_code = $cache_code;
|
251 |
+
}
|
252 |
+
|
253 |
+
$result = str_replace('[REPLACE]', $productId, $this->_sky_cache_code);
|
254 |
+
return $result;
|
255 |
+
}
|
256 |
+
}
|
app/code/community/Skybox/Catalog/Block/Product/Widget/New.php
CHANGED
@@ -1,49 +1,204 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Skybox Checkout
|
4 |
-
*
|
5 |
-
* @category Skybox
|
6 |
-
* @package Skybox_Catalog
|
7 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* New products widget
|
12 |
-
*
|
13 |
-
* @category Skybox
|
14 |
-
* @package Skybox_Catalog
|
15 |
-
*/
|
16 |
-
class Skybox_Catalog_Block_Product_Widget_New extends Mage_Catalog_Block_Product_Widget_New
|
17 |
-
{
|
18 |
-
|
19 |
-
/*
|
20 |
-
* @var string $_cache_code
|
21 |
-
*/
|
22 |
-
public $_cache_code = null;
|
23 |
-
|
24 |
-
public
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Skybox Checkout
|
4 |
+
*
|
5 |
+
* @category Skybox
|
6 |
+
* @package Skybox_Catalog
|
7 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* New products widget
|
12 |
+
*
|
13 |
+
* @category Skybox
|
14 |
+
* @package Skybox_Catalog
|
15 |
+
*/
|
16 |
+
class Skybox_Catalog_Block_Product_Widget_New extends Mage_Catalog_Block_Product_Widget_New
|
17 |
+
{
|
18 |
+
|
19 |
+
/*
|
20 |
+
* @var string $_cache_code
|
21 |
+
*/
|
22 |
+
public $_cache_code = null;
|
23 |
+
|
24 |
+
public $_sky_cache_code = null;
|
25 |
+
// protected $_api;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Retrieve API Product
|
29 |
+
*
|
30 |
+
* @return Skybox_Catalog_Model_Api_Product
|
31 |
+
*/
|
32 |
+
protected function _getApi()
|
33 |
+
{
|
34 |
+
if (null === $this->_api) {
|
35 |
+
$this->_api = Mage::getModel('skyboxcatalog/api_product');
|
36 |
+
}
|
37 |
+
return $this->_api;
|
38 |
+
}
|
39 |
+
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Initialize block's cache and template settings
|
43 |
+
*/
|
44 |
+
protected function _construct()
|
45 |
+
{
|
46 |
+
parent::_construct();
|
47 |
+
$cache_key = Mage_Catalog_Model_Product::CACHE_TAG . "_" . $this->getCacheCode();
|
48 |
+
$this->setAttribute("cache_key", $cache_key);
|
49 |
+
if (Mage::getVersion() == '1.9.1') {
|
50 |
+
$this->addData(array('cache_lifetime' => null)); // Skip cache generation
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
public function getCacheCode()
|
55 |
+
{
|
56 |
+
if ($this->_cache_code == null) {
|
57 |
+
/* @var $config Skybox_Core_Model_Config */
|
58 |
+
$config = Mage::getModel("skyboxcore/config");
|
59 |
+
$skyboxUser = $config->getSession()->getSkyboxUser();
|
60 |
+
$cache_code = $skyboxUser->CartCountryISOCode . $skyboxUser->CartCityId . $skyboxUser->CartCurrencyISOCode;
|
61 |
+
$this->_cache_code = $cache_code;
|
62 |
+
}
|
63 |
+
Mage::log("Cache Code::: ", null, 'test2.log', true);
|
64 |
+
Mage::log("[widget/new] Cache Code: " . $cache_code, null, 'cache.log', true);
|
65 |
+
return $this->_cache_code;
|
66 |
+
}
|
67 |
+
|
68 |
+
protected function _getProductCollection()
|
69 |
+
{
|
70 |
+
|
71 |
+
return parent::_getProductCollection();
|
72 |
+
}
|
73 |
+
|
74 |
+
protected function _beforeToHtml()
|
75 |
+
{
|
76 |
+
$result = parent::_beforeToHtml();
|
77 |
+
if (!$this->isEnable()) {
|
78 |
+
return $result;
|
79 |
+
}
|
80 |
+
$api_checkout = Mage::getModel('skyboxcheckout/api_checkout');
|
81 |
+
$api_checkout->InitializeBarSkybox();
|
82 |
+
|
83 |
+
$data = $api_checkout->getValueAccessService();
|
84 |
+
|
85 |
+
$skyBoxUrlClient = Mage::helper('skyboxinternational/data')->getSkyBoxUrlAPI();
|
86 |
+
$skyBoxUrlClient = $skyBoxUrlClient . "multiplecalculate";
|
87 |
+
|
88 |
+
$dataJson = null;
|
89 |
+
$multiCalculate = 1;
|
90 |
+
|
91 |
+
try {
|
92 |
+
$products = $this->_getProductCollection();
|
93 |
+
foreach ($products as $prod) {
|
94 |
+
$product = Mage::getModel('catalog/product')->load($prod->getId());
|
95 |
+
$data['listproducts'][] = $this->getUrlService($product);
|
96 |
+
$dataJson = json_encode($data);
|
97 |
+
}
|
98 |
+
$response = $this->multiCalculatePrice($skyBoxUrlClient, $dataJson);
|
99 |
+
} catch (\Exception $e) {
|
100 |
+
$multiCalculate = 0;
|
101 |
+
}
|
102 |
+
|
103 |
+
Mage::unregister('skybox_multicalculate');
|
104 |
+
Mage::register('skybox_multicalculate', $multiCalculate);
|
105 |
+
return $result;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* @param $product
|
110 |
+
* @return array|string
|
111 |
+
*/
|
112 |
+
public function getUrlService($product)
|
113 |
+
{
|
114 |
+
$type = $product->getTypeId();
|
115 |
+
$template = '';
|
116 |
+
|
117 |
+
switch ($type) {
|
118 |
+
case 'simple':
|
119 |
+
$template = $this->_getApi()->getUrl($product->getId(), null, $product->getFinalPrice(),
|
120 |
+
$product->getTypeId());
|
121 |
+
break;
|
122 |
+
case 'configurable':
|
123 |
+
$template = $this->_getApi()->getUrl($product->getId(), null, $product->getFinalPrice(),
|
124 |
+
$product->getTypeId());
|
125 |
+
break;
|
126 |
+
case 'bundle':
|
127 |
+
$template = $this->_getApi()->getUrl($product, null, $product->getFinalPrice(), 'simple');
|
128 |
+
break;
|
129 |
+
}
|
130 |
+
|
131 |
+
if (is_array($template)) {
|
132 |
+
$productId = $template['htmlobjectid'];
|
133 |
+
$cache_code = $this->getSkyboxCacheCode($productId);
|
134 |
+
$template['htmlobjectid'] = $cache_code;
|
135 |
+
}
|
136 |
+
return $template;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Return the Skybox Cache code
|
141 |
+
*
|
142 |
+
* @param $productId
|
143 |
+
* @return mixed
|
144 |
+
*/
|
145 |
+
public function getSkyboxCacheCode($productId)
|
146 |
+
{
|
147 |
+
if ($this->_sky_cache_code == null) {
|
148 |
+
/* @var $config Skybox_Core_Model_Config */
|
149 |
+
$config = Mage::getModel("skyboxcore/config");
|
150 |
+
$skyboxUser = $config->getSession()->getSkyboxUser();
|
151 |
+
$country_iso_code = strtoupper($skyboxUser->CartCountryISOCode);
|
152 |
+
$cache_code = $country_iso_code . "[REPLACE]" . $skyboxUser->CartCurrencyISOCode;
|
153 |
+
$this->_sky_cache_code = $cache_code;
|
154 |
+
}
|
155 |
+
|
156 |
+
$result = str_replace('[REPLACE]', $productId, $this->_sky_cache_code);
|
157 |
+
return $result;
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Return Multi CalculatePrice
|
162 |
+
*
|
163 |
+
* @param $url
|
164 |
+
* @param $data
|
165 |
+
* @return mixed
|
166 |
+
* @throws Exception
|
167 |
+
*/
|
168 |
+
function multiCalculatePrice($url, $data)
|
169 |
+
{
|
170 |
+
$ch = curl_init();
|
171 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
172 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
173 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
174 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
175 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
176 |
+
$response = curl_exec($ch);
|
177 |
+
|
178 |
+
$response = json_decode($response, true);
|
179 |
+
|
180 |
+
if ($response['StatusCode'] != 'Success') {
|
181 |
+
throw new \Exception('Missing or invalid data send to MultiCalculate');
|
182 |
+
}
|
183 |
+
return $response;
|
184 |
+
}
|
185 |
+
|
186 |
+
private function isEnable()
|
187 |
+
{
|
188 |
+
$isModuleEnable = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
189 |
+
if (!$isModuleEnable) {
|
190 |
+
return false;
|
191 |
+
}
|
192 |
+
|
193 |
+
/** @var Skybox_Core_Helper_Allow $allowHelper */
|
194 |
+
$allowHelper = Mage::helper('skyboxcore/allow');
|
195 |
+
|
196 |
+
if (!$allowHelper->isPriceEnabled()) {
|
197 |
+
return false;
|
198 |
+
}
|
199 |
+
|
200 |
+
return true;
|
201 |
+
}
|
202 |
+
|
203 |
+
|
204 |
}
|
app/code/community/Skybox/Catalog/Model/Api/Product.php
CHANGED
@@ -1,937 +1,937 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Catalog
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Catalog
|
8 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
|
11 |
-
{
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Model instance
|
15 |
-
* @var Skybox_Core_Model_Config
|
16 |
-
*/
|
17 |
-
/*protected $_config = null;
|
18 |
-
|
19 |
-
protected $_typeConfig = "skyboxcore/config";
|
20 |
-
|
21 |
-
protected function getConfig()
|
22 |
-
{
|
23 |
-
if(null === $this->_config)
|
24 |
-
$this->_config = Mage::getModel($this->_typeConfig);
|
25 |
-
}*/
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Model instance
|
29 |
-
* @var Mage_Core_Catalog_Model_Product
|
30 |
-
*/
|
31 |
-
protected $_product = null;
|
32 |
-
|
33 |
-
protected $_productResult = null;
|
34 |
-
|
35 |
-
protected $_typeProduct = "catalog/product";
|
36 |
-
|
37 |
-
protected $_product_id = null;
|
38 |
-
protected $_product_data = null;
|
39 |
-
|
40 |
-
public function getProductId()
|
41 |
-
{
|
42 |
-
if ($this->_product_id != null) {
|
43 |
-
return $this->_product_id;
|
44 |
-
}
|
45 |
-
return null;
|
46 |
-
}
|
47 |
-
|
48 |
-
public function getProductData()
|
49 |
-
{
|
50 |
-
if ($this->_product_data != null) {
|
51 |
-
return $this->_product_data;
|
52 |
-
}
|
53 |
-
return null;
|
54 |
-
}
|
55 |
-
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Calculate Price
|
59 |
-
*
|
60 |
-
* @param int|Mage_Catalog_Model_Product $product
|
61 |
-
* @param Varien_Object $request
|
62 |
-
* @param float $finalPrice
|
63 |
-
* @param string $type
|
64 |
-
* @param int $objectId
|
65 |
-
* @return Mage_Checkout_Model_Cart
|
66 |
-
*/
|
67 |
-
public function CalculatePrice($product, $request, $finalPrice = null, $type = null, $objectId = 1)
|
68 |
-
{
|
69 |
-
Mage::log("ApiProductCatalog ", null, 'orden.log', true);
|
70 |
-
|
71 |
-
//Mage::log(print_r('Product', true), null, 'tracer.log', true);
|
72 |
-
|
73 |
-
//if ($this->getErrorAuthenticate() && !$this->getLocationAllow()) {
|
74 |
-
if (!$this->getLocationAllow()) {
|
75 |
-
return $this;
|
76 |
-
}
|
77 |
-
|
78 |
-
if (!is_object($product)) {
|
79 |
-
$storeId = Mage::app()->getStore()->getStoreId();
|
80 |
-
$product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($product);
|
81 |
-
}
|
82 |
-
|
83 |
-
$productId = $product->getId();
|
84 |
-
$_data = null;
|
85 |
-
|
86 |
-
if ($type == null) {
|
87 |
-
$type = $product->getTypeId();
|
88 |
-
}
|
89 |
-
|
90 |
-
$defaultSwitch = false;
|
91 |
-
switch ($type) {
|
92 |
-
case 'simple':
|
93 |
-
$finalPrice = isset($finalPrice) ? $finalPrice : $product->getFinalPrice();
|
94 |
-
$category_id = $product->getSkyboxCategoryId();
|
95 |
-
$category_id = isset($category_id) ? $category_id : $this->getCommodityFromCategory($product);
|
96 |
-
$volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
|
97 |
-
|
98 |
-
$_data = array(
|
99 |
-
'object_id' => 1,
|
100 |
-
'name' => $product->getName(),
|
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,
|
108 |
-
'merchantproductid' => $productId
|
109 |
-
);
|
110 |
-
// $this->_calculatePrice($_data);
|
111 |
-
break;
|
112 |
-
|
113 |
-
case 'configurable':
|
114 |
-
|
115 |
-
$finalPrice = isset($finalPrice) ? $finalPrice : null;
|
116 |
-
$weight = $product->getTypeInstance(true)->getWeight($product);
|
117 |
-
$sku = $product->getSku();
|
118 |
-
|
119 |
-
Mage::log("CalculatePrice configurable : " . $finalPrice, null, 'skyboxcheckout.log', false);
|
120 |
-
|
121 |
-
if ($request) {
|
122 |
-
$childProduct = Mage::getModel('catalog/product_type_configurable')
|
123 |
-
->getProductByAttributes($request->getData('super_attribute'), $product);
|
124 |
-
|
125 |
-
$productId = $childProduct->getId();
|
126 |
-
$sku = $childProduct->getSku();
|
127 |
-
|
128 |
-
}
|
129 |
-
|
130 |
-
$parentItem = null;
|
131 |
-
|
132 |
-
if (isset($request) && !$finalPrice) {
|
133 |
-
Mage::log("CalculatePrice candidate INI", null, 'skyboxcheckout.log', false);
|
134 |
-
$_finalPrice = 0;
|
135 |
-
|
136 |
-
$cartCandidates = $product->getTypeInstance(true)
|
137 |
-
->prepareForCartAdvanced($request, $product, 'full');
|
138 |
-
|
139 |
-
foreach ($cartCandidates as $candidate) {
|
140 |
-
// Child items can be sticked together only within their parent
|
141 |
-
$stickWithinParent = $candidate->getParentProductId() ? $parentItem : null;
|
142 |
-
$candidate->setStickWithinParent($stickWithinParent);
|
143 |
-
|
144 |
-
$candidate_getFinalPrice = $candidate->getPriceModel()->getFinalPrice($request->getQty(),
|
145 |
-
$product);
|
146 |
-
Mage::log("CalculatePrice candidate getFinalPrice: " . $candidate_getFinalPrice, null,
|
147 |
-
'skyboxcheckout.log', false);
|
148 |
-
|
149 |
-
$_finalPrice = $_finalPrice + $candidate_getFinalPrice;
|
150 |
-
if ($_finalPrice) {
|
151 |
-
break;
|
152 |
-
}
|
153 |
-
}
|
154 |
-
$finalPrice = $_finalPrice;
|
155 |
-
Mage::log("CalculatePrice candidate FIN", null, 'skyboxcheckout.log', false);
|
156 |
-
}
|
157 |
-
|
158 |
-
/* Weight start*/
|
159 |
-
/*
|
160 |
-
$options = array();
|
161 |
-
// Get any super_attribute settings we need
|
162 |
-
$productAttributesOptions = $product->getTypeInstance(true)->getConfigurableOptions($product);
|
163 |
-
foreach ($productAttributesOptions as $productAttributeOption) {
|
164 |
-
$options[$product->getId()] = array();
|
165 |
-
foreach ($productAttributeOption as $optionValues) {
|
166 |
-
$val = ($optionValues['option_title']);
|
167 |
-
$options[$product->getId()][] = array (
|
168 |
-
$optionValues['sku'] => $optionValues['attribute_code']."=".$val
|
169 |
-
|
170 |
-
) ;
|
171 |
-
}
|
172 |
-
|
173 |
-
}
|
174 |
-
$prod_weight = 1;
|
175 |
-
if(!empty($optionValues)) {
|
176 |
-
$a = Mage::getModel('catalog/product')->loadByAttribute('sku',$optionValues['sku']);
|
177 |
-
//$product->load($product->getIdBySku($optionValues['sku']));
|
178 |
-
$prod_weight = $a->getWeight();
|
179 |
-
echo ":::".$prod_weight."::";
|
180 |
-
}
|
181 |
-
*/
|
182 |
-
/* Weight end*/
|
183 |
-
|
184 |
-
$category_id = $product->getSkyboxCategoryId();
|
185 |
-
$category_id = isset($category_id) ? $category_id : $this->getCommodityFromCategory($product);
|
186 |
-
|
187 |
-
$volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
|
188 |
-
$_data = array(
|
189 |
-
'object_id' => 1,
|
190 |
-
'name' => $product->getName(),
|
191 |
-
//'sku' => $product->getSku(),
|
192 |
-
'sku' => $sku,
|
193 |
-
'category_id' => $category_id,
|
194 |
-
'final_price' => $finalPrice,
|
195 |
-
'weight' => $weight ? $weight : 1,
|
196 |
-
'image_url' => $product->getImageUrl(),
|
197 |
-
'typeProduct' => $type,
|
198 |
-
'VolWeight' => $volWeight,
|
199 |
-
'merchantproductid' => $productId
|
200 |
-
);
|
201 |
-
|
202 |
-
// $this->_calculatePrice($_data);
|
203 |
-
break;
|
204 |
-
|
205 |
-
case 'bundle':
|
206 |
-
//$_finalPrice = $product->getTotalBundleItemsPrice($product, $request->getQty());
|
207 |
-
//$finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
|
208 |
-
|
209 |
-
//Mage::log(print_r($product, true), null, 'cart.log', true);
|
210 |
-
//Mage::log("Product: [" . $product->getId() . "] - Class: " . get_class($product), null, 'skyboxcheckout.log', false);
|
211 |
-
|
212 |
-
//Mage::log(print_r($request, true), null, 'cart.log', true);
|
213 |
-
|
214 |
-
$finalPrice = isset($finalPrice) ? $finalPrice : null;
|
215 |
-
$weight = $product->getTypeInstance(true)->getWeight($product);
|
216 |
-
$sku = $product->getSku();
|
217 |
-
|
218 |
-
//if (isset($request) && !$finalPrice) {
|
219 |
-
if (isset($request)) {
|
220 |
-
|
221 |
-
$parentItem = null;
|
222 |
-
$_finalPrice = null;
|
223 |
-
$_weight = 0;
|
224 |
-
|
225 |
-
$cartCandidates = $product->getTypeInstance(true)
|
226 |
-
->prepareForCartAdvanced($request, $product, 'full');
|
227 |
-
|
228 |
-
foreach ($cartCandidates as $candidate) {
|
229 |
-
// Child items can be sticked together only within their parent
|
230 |
-
$stickWithinParent = $candidate->getParentProductId() ? $parentItem : null;
|
231 |
-
$candidate->setStickWithinParent($stickWithinParent);
|
232 |
-
|
233 |
-
if (!$_finalPrice) {
|
234 |
-
$_finalPrice = $candidate->getPriceModel()->getFinalPrice($request->getQty(), $product);
|
235 |
-
//break;
|
236 |
-
}
|
237 |
-
//$_weight = $_weight + $candidate->getPriceModel()->getWeight();
|
238 |
-
$_weight = $_weight + $candidate->getWeight();
|
239 |
-
}
|
240 |
-
|
241 |
-
$finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
|
242 |
-
if ($_weight > 0) {
|
243 |
-
$weight = $_weight;
|
244 |
-
}
|
245 |
-
}
|
246 |
-
|
247 |
-
//Mage::log("weight: " . $weight, null, 'cart.log', true);
|
248 |
-
//Mage::log("sku: " . $sku, null, 'cart.log', true);
|
249 |
-
|
250 |
-
$category_id = $product->getSkyboxCategoryId();
|
251 |
-
$category_id = isset($category_id) ? $category_id : $this->getCommodityFromCategory($product);
|
252 |
-
|
253 |
-
$volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
|
254 |
-
$_data = array(
|
255 |
-
'object_id' => 1,
|
256 |
-
'name' => $product->getName(),
|
257 |
-
'sku' => $sku,
|
258 |
-
'category_id' => $category_id,
|
259 |
-
'final_price' => $finalPrice,
|
260 |
-
'weight' => ($weight) ? $weight : 1,
|
261 |
-
'image_url' => $product->getImageUrl(),
|
262 |
-
'typeProduct' => $type,
|
263 |
-
'VolWeight' => $volWeight,
|
264 |
-
'merchantproductid' => $productId
|
265 |
-
);
|
266 |
-
// $this->_calculatePrice($_data);
|
267 |
-
break;
|
268 |
-
|
269 |
-
case 'bundle_fixed':
|
270 |
-
|
271 |
-
// @Note: It should be rewrite!!
|
272 |
-
$finalPrice = isset($finalPrice) ? $finalPrice : null;
|
273 |
-
$skyboxCategoryId = $product->getSkyboxCategoryId();
|
274 |
-
$weight = $product->getTypeInstance(true)->getWeight($product);
|
275 |
-
$sku = $product->getSku();
|
276 |
-
|
277 |
-
$selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection(
|
278 |
-
$product->getTypeInstance(true)->getOptionsIds($product), $product
|
279 |
-
);
|
280 |
-
|
281 |
-
$_finalPrice = null;
|
282 |
-
$_weight = 0;
|
283 |
-
$_skyboxCategoryId = null;
|
284 |
-
|
285 |
-
foreach ($selectionCollection as $option) {
|
286 |
-
//if ($option->getData('is_default') == 0) continue;
|
287 |
-
|
288 |
-
$product_simple = Mage::getModel('catalog/product')
|
289 |
-
->load($option->getId());
|
290 |
-
|
291 |
-
$_finalPrice = $_finalPrice + $product_simple->getFinalPrice();
|
292 |
-
$_weight = $_weight + $product_simple->getWeight();
|
293 |
-
|
294 |
-
if (!$_skyboxCategoryId) { // Set SkyboxCategory from the first Simple Product
|
295 |
-
// $_skyboxCategoryId = $product_simple->getSkyboxCategoryId();
|
296 |
-
$_skyboxCategoryId = $product->getSkyboxCategoryId();
|
297 |
-
$_skyboxCategoryId = isset($_skyboxCategoryId) ? $_skyboxCategoryId : $this->getCommodityFromCategory($product);
|
298 |
-
}
|
299 |
-
}
|
300 |
-
|
301 |
-
$finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
|
302 |
-
|
303 |
-
if (!$weight) {
|
304 |
-
$weight = $_weight;
|
305 |
-
}
|
306 |
-
|
307 |
-
if (!$skyboxCategoryId) {
|
308 |
-
$skyboxCategoryId = $_skyboxCategoryId;
|
309 |
-
}
|
310 |
-
|
311 |
-
/*Mage::log("-------------------------", null, 'cart.log', true);
|
312 |
-
Mage::log("Product: " . $product->getName(), null, 'cart.log', true);
|
313 |
-
Mage::log("Price: " . $finalPrice, null, 'cart.log', true);
|
314 |
-
Mage::log("weight: " . $weight, null, 'cart.log', true);
|
315 |
-
Mage::log("sku: " . $sku, null, 'cart.log', true);*/
|
316 |
-
|
317 |
-
|
318 |
-
$volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
|
319 |
-
$_data = array(
|
320 |
-
'object_id' => 1,
|
321 |
-
'name' => $product->getName(),
|
322 |
-
'sku' => $sku,
|
323 |
-
'category_id' => $skyboxCategoryId,
|
324 |
-
'final_price' => $finalPrice,
|
325 |
-
'weight' => ($weight) ? $weight : 1,
|
326 |
-
'image_url' => $product->getImageUrl(),
|
327 |
-
'typeProduct' => $type,
|
328 |
-
'VolWeight' => $volWeight,
|
329 |
-
'merchantproductid' => $productId
|
330 |
-
);
|
331 |
-
|
332 |
-
// $this->_calculatePrice($_data);
|
333 |
-
break;
|
334 |
-
|
335 |
-
default:
|
336 |
-
Mage::log("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice",
|
337 |
-
null, 'skyboxcheckout.log', false);
|
338 |
-
trigger_error("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice");
|
339 |
-
$defaultSwitch = true;
|
340 |
-
break;
|
341 |
-
}
|
342 |
-
|
343 |
-
if (!$defaultSwitch) {
|
344 |
-
//Mage::log(print_r('EnableTax: ', true), null, 'tracer.log', true);
|
345 |
-
//Mage::log(print_r($this->getEnabledAddSumTaxToPrice(), true), null, 'tracer.log', true);
|
346 |
-
if ($this->getEnabledAddSumTaxToPrice()) {
|
347 |
-
$store = Mage::app()->getStore('default');
|
348 |
-
$taxCalculation = Mage::getModel('tax/calculation');
|
349 |
-
$request = $taxCalculation->getRateRequest(null, null, null, $store);
|
350 |
-
// $product = Mage::registry('current_product');
|
351 |
-
$taxClassId = $product->getTaxClassId();
|
352 |
-
$percentTax = $taxCalculation->getRate($request->setProductClassId($taxClassId));
|
353 |
-
|
354 |
-
$taxPrice = $_data['final_price'] * ($percentTax / 100);
|
355 |
-
|
356 |
-
//Mage::log(print_r('Id product: ' . $product->getId(), true), null, 'tracer.log', true);
|
357 |
-
//Mage::log(print_r('$taxPrice: ' . $taxPrice, true), null, 'tracer.log', true);
|
358 |
-
//Mage::log(print_r('price: ' . $_data['final_price'], true), null, 'tracer.log', true);
|
359 |
-
//Mage::log(print_r('$taxPrice+price: ' . ($taxPrice + $_data['final_price']), true), null, 'tracer.log', true);
|
360 |
-
$comissionSkybox = $_data['final_price'] * (10 / 100);
|
361 |
-
//Mage::log(print_r('comision skybox: ' . ($comissionSkybox), true), null, 'tracer.log', true);
|
362 |
-
//Mage::log(print_r('price+comision skybox: ' . ($_data['final_price'] + $comissionSkybox), true), null, 'tracer.log', true);
|
363 |
-
//Mage::log(print_r('$taxPrice+price+comision: ' . ($taxPrice + $_data['final_price'] + $comissionSkybox), true), null, 'tracer.log', true);
|
364 |
-
//Mage::log(print_r('comision true: ' . (($taxPrice + $_data['final_price']) * (10 / 100)), true), null, 'tracer.log', true);
|
365 |
-
$priceReally = ($taxPrice + $_data['final_price']) + ($taxPrice + $_data['final_price']) * (10 / 100);
|
366 |
-
//Mage::log(print_r('$taxPrice+price+comision true: ' . ($priceReally), true), null, 'tracer.log', true);
|
367 |
-
|
368 |
-
|
369 |
-
$_data['final_price'] = $_data['final_price'] + $taxPrice;
|
370 |
-
}
|
371 |
-
|
372 |
-
//Mage::log(print_r('####################### Data produc params #######################', true), null, 'tracer.log', true);
|
373 |
-
//Mage::log(print_r($_data, true), null, 'tracer.log', true);
|
374 |
-
// $this->_calculatePrice($_data);
|
375 |
-
try {
|
376 |
-
$this->_calculatePrice($_data);
|
377 |
-
} catch (\Exception $e) {
|
378 |
-
Mage::log($e->getMessage(), null, 'skyboxcheckout.log', false);
|
379 |
-
}
|
380 |
-
}
|
381 |
-
|
382 |
-
Mage::log("Product Class: " . get_class($product), null, 'skyboxcheckout.log', false);
|
383 |
-
Mage::log("Product Type: " . $type, null, 'skyboxcheckout.log', false);
|
384 |
-
Mage::log(print_r($_data, true), null, 'skyboxcheckout.log', false);
|
385 |
-
|
386 |
-
$this->_product_data = $_data;
|
387 |
-
$this->_product_id = $productId;
|
388 |
-
return $this;
|
389 |
-
}
|
390 |
-
|
391 |
-
private function _calculatePrice($data)
|
392 |
-
{
|
393 |
-
$msg = sprintf("CalculatePrice: [%s] - [%s] - [%s] - [Category_id: %s] - [Price: %s] - [weight: %s] - [typeProduct: %s]",
|
394 |
-
$data['object_id'],
|
395 |
-
$data['sku'],
|
396 |
-
$data['name'],
|
397 |
-
$data['category_id'],
|
398 |
-
$data['final_price'],
|
399 |
-
$data['weight'],
|
400 |
-
$data['typeProduct']
|
401 |
-
);
|
402 |
-
|
403 |
-
Mage::log($msg, null, 'skyboxcheckout.log', false);
|
404 |
-
|
405 |
-
$params = array(
|
406 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
407 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
|
408 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
|
409 |
-
'htmlobjectid' => $data['object_id'],
|
410 |
-
'storeproductcode' => $data['sku'],
|
411 |
-
'storeproductname' => $data['name'],
|
412 |
-
'storeproductcategory' => $data['category_id'],
|
413 |
-
'storeproductprice' => $data['final_price'],
|
414 |
-
//'storeproductprice' => $product->getFinalPrice(),
|
415 |
-
'weight' => ($data['weight']) ? $data['weight'] : 1,
|
416 |
-
'weightunit' => $this->getWeightUnit(),
|
417 |
-
'storeproductimgurl' => $data['image_url'],
|
418 |
-
'merchantproductid' => $data['merchantproductid']
|
419 |
-
);
|
420 |
-
$this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_CALCULATE, $params);
|
421 |
-
}
|
422 |
-
|
423 |
-
public function HtmlTemplateButton()
|
424 |
-
{
|
425 |
-
if (!$this->getErrorAuthenticate() && $this->_getApi()->getLocationAllow()) {
|
426 |
-
$params = array(
|
427 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
428 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
|
429 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi()
|
430 |
-
);
|
431 |
-
|
432 |
-
$this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_GET_TEMPLATE_BUTTON, $params);
|
433 |
-
}
|
434 |
-
|
435 |
-
return $this;
|
436 |
-
}
|
437 |
-
|
438 |
-
public function GetTemplateProduct()
|
439 |
-
{
|
440 |
-
Mage::log("ApiProduct ", null, 'orden.log', true);
|
441 |
-
if (!$this->getErrorAuthenticate() && $this->_getApi()->getLocationAllow() && !$this->_getApi()->ErrorServiceNotController()) {
|
442 |
-
//if (!$this->getErrorAuthenticate() && $this->_getApi()->getLocationAllow() && !$this->_getApi()->ErrorService()) {
|
443 |
-
$_productResult = $this->getResponse();
|
444 |
-
$template = $_productResult->TooltipButtonTemplate;
|
445 |
-
return $template;
|
446 |
-
// $templateButton = $this->getHtmlTemplateButton();
|
447 |
-
// if (empty($templateButton))
|
448 |
-
// $this->HtmlTemplateButton();
|
449 |
-
//
|
450 |
-
// /*if($_productResult->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_BUTTONERROR})
|
451 |
-
// {*/
|
452 |
-
// //Mage::log("_productResult--->" . json_decode($_productResult));
|
453 |
-
// $templateButton = $this->getHtmlTemplateButton();
|
454 |
-
// if (!empty($templateButton)) {
|
455 |
-
// $template = $this->getHtmlTemplateButton();
|
456 |
-
//// Mage::log(print_r('response template buttom', true), null, 'tracer.log', true);
|
457 |
-
//// Mage::log(print_r($_productResult, true), null, 'tracer.log', true);
|
458 |
-
// foreach ($_productResult as $key => $value) {
|
459 |
-
// $template = str_replace('{' . $key . '}', $value, $template);
|
460 |
-
// }
|
461 |
-
//
|
462 |
-
// // Just for {Block} crap
|
463 |
-
// $template = str_replace('{Block}', '', $template);
|
464 |
-
//
|
465 |
-
// return $template;
|
466 |
-
// }
|
467 |
-
//
|
468 |
-
// $displayUSD = "''"; //CartCountryIso
|
469 |
-
// /*}else{
|
470 |
-
// return "Plantilla de error";
|
471 |
-
// }*/
|
472 |
-
// //Mage::log(get_class($this) . " GetTemplateProduct() ", null, 'cart.log', true);
|
473 |
-
} else {
|
474 |
-
$template = '<div class="skx_content_button"></div>';
|
475 |
-
return $template;
|
476 |
-
}
|
477 |
-
return "";
|
478 |
-
}
|
479 |
-
|
480 |
-
protected $_isUSD = null;
|
481 |
-
|
482 |
-
public function IsUSD()
|
483 |
-
{
|
484 |
-
if (null == $this->_isUSD) {
|
485 |
-
$this->_isUSD = ($this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_CART_CURRENCY_ISO,
|
486 |
-
"") == Skybox_Core_Model_Config::SKYBOX_CURRENCY_USD);
|
487 |
-
}
|
488 |
-
return $this->_isUSD;
|
489 |
-
}
|
490 |
-
|
491 |
-
public function getCustoms()
|
492 |
-
{
|
493 |
-
return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_CUSTOMS, "0");
|
494 |
-
}
|
495 |
-
|
496 |
-
public function getShipping()
|
497 |
-
{
|
498 |
-
return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_SHIPPING, "0");
|
499 |
-
}
|
500 |
-
|
501 |
-
public function getInsurance()
|
502 |
-
{
|
503 |
-
return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_INSURANCE, "0");
|
504 |
-
}
|
505 |
-
|
506 |
-
public function getPrice()
|
507 |
-
{
|
508 |
-
return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_PRICE, "0");
|
509 |
-
}
|
510 |
-
|
511 |
-
public function getTotalPrice()
|
512 |
-
{
|
513 |
-
return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_TOTAL, "0");
|
514 |
-
}
|
515 |
-
|
516 |
-
public function getCustomsUSD()
|
517 |
-
{
|
518 |
-
return $this->IsUSD() ? $this->getCustoms() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_CUSTOMS_USD,
|
519 |
-
"0");
|
520 |
-
}
|
521 |
-
|
522 |
-
public function getShippingUSD()
|
523 |
-
{
|
524 |
-
return $this->IsUSD() ? $this->getShipping() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_SHIPPING_USD,
|
525 |
-
"0");
|
526 |
-
}
|
527 |
-
|
528 |
-
public function getInsuranceUSD()
|
529 |
-
{
|
530 |
-
return $this->IsUSD() ? $this->getInsurance() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_INSURANCE_USD,
|
531 |
-
"0");
|
532 |
-
}
|
533 |
-
|
534 |
-
public function getPriceUSD()
|
535 |
-
{
|
536 |
-
return $this->IsUSD() ? $this->getPrice() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_PRICE_USD,
|
537 |
-
"0");
|
538 |
-
}
|
539 |
-
|
540 |
-
public function getTotalPriceUSD()
|
541 |
-
{
|
542 |
-
return $this->IsUSD() ? $this->getTotalPrice() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_TOTAL_USD,
|
543 |
-
"0");
|
544 |
-
}
|
545 |
-
|
546 |
-
public function getGuidSkybox()
|
547 |
-
{
|
548 |
-
return $this->_getApi()->getGuidApi();
|
549 |
-
}
|
550 |
-
|
551 |
-
public function getBasePrice()
|
552 |
-
{
|
553 |
-
return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_BASE_PRICE, "0");
|
554 |
-
}
|
555 |
-
|
556 |
-
public function getBasePriceUSD()
|
557 |
-
{
|
558 |
-
return $this->IsUSD() ? $this->getBasePrice() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_BASE_PRICE_USD,
|
559 |
-
"0");
|
560 |
-
}
|
561 |
-
|
562 |
-
public function getAdjustPrice()
|
563 |
-
{
|
564 |
-
return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ADJUST_PRICE, "0");
|
565 |
-
}
|
566 |
-
|
567 |
-
public function getAdjustPriceUSD()
|
568 |
-
{
|
569 |
-
return $this->IsUSD() ? $this->getAdjustPrice() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ADJUST_PRICE_USD,
|
570 |
-
"0");
|
571 |
-
}
|
572 |
-
|
573 |
-
public function getAdjustLabel()
|
574 |
-
{
|
575 |
-
return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_LABEL_ADJUST, "");
|
576 |
-
}
|
577 |
-
|
578 |
-
/*Async Ini*/
|
579 |
-
|
580 |
-
public function getUrl($product, $request, $finalPrice = null, $type = null, $objectId = 1)
|
581 |
-
{
|
582 |
-
Mage::log("ApiProductCatalog ", null, 'orden.log', true);
|
583 |
-
|
584 |
-
//Mage::log(print_r('Product', true), null, 'tracer.log', true);
|
585 |
-
|
586 |
-
//if ($this->getErrorAuthenticate() && !$this->getLocationAllow()) {
|
587 |
-
if (!$this->getLocationAllow()) {
|
588 |
-
return $this;
|
589 |
-
}
|
590 |
-
|
591 |
-
if (!is_object($product)) {
|
592 |
-
$storeId = Mage::app()->getStore()->getStoreId();
|
593 |
-
$product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($product);
|
594 |
-
}
|
595 |
-
|
596 |
-
$productId = $product->getId();
|
597 |
-
$_data = null;
|
598 |
-
|
599 |
-
if ($type == null) {
|
600 |
-
$type = $product->getTypeId();
|
601 |
-
}
|
602 |
-
|
603 |
-
$defaultSwitch = true;
|
604 |
-
switch ($type) {
|
605 |
-
case 'simple':
|
606 |
-
$finalPrice = isset($finalPrice) ? $finalPrice : $product->getFinalPrice();
|
607 |
-
$category_id = $product->getSkyboxCategoryId();
|
608 |
-
$category_id = isset($category_id) ? $category_id : $this->getCommodityFromCategory($product);
|
609 |
-
$volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
|
610 |
-
|
611 |
-
$_data = array(
|
612 |
-
'object_id' => $product->getId(),
|
613 |
-
'name' => $product->getName(),
|
614 |
-
'sku' => $product->getSku(),
|
615 |
-
'category_id' => $category_id,
|
616 |
-
'final_price' => $finalPrice,
|
617 |
-
'weight' => ($product->getWeight()) ? $product->getWeight() : 1,
|
618 |
-
'image_url' => $product->getImageUrl(),
|
619 |
-
'typeProduct' => $type,
|
620 |
-
'VolWeight' => $volWeight,
|
621 |
-
'merchantproductid' => $productId
|
622 |
-
);
|
623 |
-
// $this->_calculatePrice($_data);
|
624 |
-
break;
|
625 |
-
|
626 |
-
case 'configurable':
|
627 |
-
|
628 |
-
$finalPrice = isset($finalPrice) ? $finalPrice : null;
|
629 |
-
$weight = $product->getTypeInstance(true)->getWeight($product);
|
630 |
-
$sku = $product->getSku();
|
631 |
-
|
632 |
-
Mage::log("CalculatePrice configurable : " . $finalPrice, null, 'skyboxcheckout.log', false);
|
633 |
-
|
634 |
-
if ($request) {
|
635 |
-
$childProduct = Mage::getModel('catalog/product_type_configurable')
|
636 |
-
->getProductByAttributes($request->getData('super_attribute'), $product);
|
637 |
-
|
638 |
-
$productId = $childProduct->getId();
|
639 |
-
$sku = $childProduct->getSku();
|
640 |
-
|
641 |
-
}
|
642 |
-
|
643 |
-
$parentItem = null;
|
644 |
-
|
645 |
-
if (isset($request) && !$finalPrice) {
|
646 |
-
Mage::log("CalculatePrice candidate INI", null, 'skyboxcheckout.log', false);
|
647 |
-
$_finalPrice = 0;
|
648 |
-
|
649 |
-
$cartCandidates = $product->getTypeInstance(true)
|
650 |
-
->prepareForCartAdvanced($request, $product, 'full');
|
651 |
-
|
652 |
-
foreach ($cartCandidates as $candidate) {
|
653 |
-
// Child items can be sticked together only within their parent
|
654 |
-
$stickWithinParent = $candidate->getParentProductId() ? $parentItem : null;
|
655 |
-
$candidate->setStickWithinParent($stickWithinParent);
|
656 |
-
|
657 |
-
$candidate_getFinalPrice = $candidate->getPriceModel()->getFinalPrice($request->getQty(),
|
658 |
-
$product);
|
659 |
-
Mage::log("CalculatePrice candidate getFinalPrice: " . $candidate_getFinalPrice, null,
|
660 |
-
'skyboxcheckout.log', false);
|
661 |
-
|
662 |
-
$_finalPrice = $_finalPrice + $candidate_getFinalPrice;
|
663 |
-
if ($_finalPrice) {
|
664 |
-
break;
|
665 |
-
}
|
666 |
-
}
|
667 |
-
$finalPrice = $_finalPrice;
|
668 |
-
Mage::log("CalculatePrice candidate FIN", null, 'skyboxcheckout.log', false);
|
669 |
-
}
|
670 |
-
|
671 |
-
$category_id = $product->getSkyboxCategoryId();
|
672 |
-
$category_id = isset($category_id) ? $category_id : $this->getCommodityFromCategory($product);
|
673 |
-
|
674 |
-
$volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
|
675 |
-
|
676 |
-
$_data = array(
|
677 |
-
'object_id' => $product->getId(),
|
678 |
-
'name' => $product->getName(),
|
679 |
-
//'sku' => $product->getSku(),
|
680 |
-
'sku' => $sku,
|
681 |
-
'category_id' => $category_id,
|
682 |
-
'final_price' => $finalPrice,
|
683 |
-
'weight' => $weight ? $weight : 1,
|
684 |
-
'image_url' => $product->getImageUrl(),
|
685 |
-
'typeProduct' => $type,
|
686 |
-
'VolWeight' => $volWeight,
|
687 |
-
'merchantproductid' => $productId
|
688 |
-
);
|
689 |
-
|
690 |
-
// $this->_calculatePrice($_data);
|
691 |
-
break;
|
692 |
-
|
693 |
-
case 'bundle':
|
694 |
-
//$_finalPrice = $product->getTotalBundleItemsPrice($product, $request->getQty());
|
695 |
-
//$finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
|
696 |
-
|
697 |
-
//Mage::log(print_r($product, true), null, 'cart.log', true);
|
698 |
-
//Mage::log("Product: [" . $product->getId() . "] - Class: " . get_class($product), null, 'skyboxcheckout.log', false);
|
699 |
-
|
700 |
-
//Mage::log(print_r($request, true), null, 'cart.log', true);
|
701 |
-
|
702 |
-
$finalPrice = isset($finalPrice) ? $finalPrice : null;
|
703 |
-
$weight = $product->getTypeInstance(true)->getWeight($product);
|
704 |
-
$sku = $product->getSku();
|
705 |
-
|
706 |
-
//if (isset($request) && !$finalPrice) {
|
707 |
-
if (isset($request)) {
|
708 |
-
|
709 |
-
$parentItem = null;
|
710 |
-
$_finalPrice = null;
|
711 |
-
$_weight = 0;
|
712 |
-
|
713 |
-
$cartCandidates = $product->getTypeInstance(true)
|
714 |
-
->prepareForCartAdvanced($request, $product, 'full');
|
715 |
-
|
716 |
-
foreach ($cartCandidates as $candidate) {
|
717 |
-
// Child items can be sticked together only within their parent
|
718 |
-
$stickWithinParent = $candidate->getParentProductId() ? $parentItem : null;
|
719 |
-
$candidate->setStickWithinParent($stickWithinParent);
|
720 |
-
|
721 |
-
if (!$_finalPrice) {
|
722 |
-
$_finalPrice = $candidate->getPriceModel()->getFinalPrice($request->getQty(), $product);
|
723 |
-
//break;
|
724 |
-
}
|
725 |
-
//$_weight = $_weight + $candidate->getPriceModel()->getWeight();
|
726 |
-
$_weight = $_weight + $candidate->getWeight();
|
727 |
-
}
|
728 |
-
|
729 |
-
$finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
|
730 |
-
if ($_weight > 0) {
|
731 |
-
$weight = $_weight;
|
732 |
-
}
|
733 |
-
}
|
734 |
-
|
735 |
-
//Mage::log("weight: " . $weight, null, 'cart.log', true);
|
736 |
-
//Mage::log("sku: " . $sku, null, 'cart.log', true);
|
737 |
-
|
738 |
-
$volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
|
739 |
-
$_data = array(
|
740 |
-
'object_id' => $product->getId(),
|
741 |
-
'name' => $product->getName(),
|
742 |
-
'sku' => $sku,
|
743 |
-
'category_id' => $product->getSkyboxCategoryId(),
|
744 |
-
'final_price' => $finalPrice,
|
745 |
-
'weight' => ($weight) ? $weight : 1,
|
746 |
-
'image_url' => $product->getImageUrl(),
|
747 |
-
'typeProduct' => $type,
|
748 |
-
'VolWeight' => $volWeight,
|
749 |
-
'merchantproductid' => $productId
|
750 |
-
);
|
751 |
-
// $this->_calculatePrice($_data);
|
752 |
-
break;
|
753 |
-
|
754 |
-
case 'bundle_fixed':
|
755 |
-
$finalPrice = isset($finalPrice) ? $finalPrice : null;
|
756 |
-
$skyboxCategoryId = $product->getSkyboxCategoryId();
|
757 |
-
$weight = $product->getTypeInstance(true)->getWeight($product);
|
758 |
-
$sku = $product->getSku();
|
759 |
-
|
760 |
-
$selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection(
|
761 |
-
$product->getTypeInstance(true)->getOptionsIds($product), $product
|
762 |
-
);
|
763 |
-
|
764 |
-
$_finalPrice = null;
|
765 |
-
$_weight = 0;
|
766 |
-
$_skyboxCategoryId = null;
|
767 |
-
|
768 |
-
foreach ($selectionCollection as $option) {
|
769 |
-
//if ($option->getData('is_default') == 0) continue;
|
770 |
-
|
771 |
-
$product_simple = Mage::getModel('catalog/product')
|
772 |
-
->load($option->getId());
|
773 |
-
|
774 |
-
$_finalPrice = $_finalPrice + $product_simple->getFinalPrice();
|
775 |
-
$_weight = $_weight + $product_simple->getWeight();
|
776 |
-
|
777 |
-
if (!$_skyboxCategoryId) { // Set SkyboxCategory from the first Simple Product
|
778 |
-
$_skyboxCategoryId = $product_simple->getSkyboxCategoryId();
|
779 |
-
}
|
780 |
-
}
|
781 |
-
|
782 |
-
$finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
|
783 |
-
|
784 |
-
if (!$weight) {
|
785 |
-
$weight = $_weight;
|
786 |
-
}
|
787 |
-
|
788 |
-
if (!$skyboxCategoryId) {
|
789 |
-
$skyboxCategoryId = $_skyboxCategoryId;
|
790 |
-
}
|
791 |
-
|
792 |
-
/*Mage::log("-------------------------", null, 'cart.log', true);
|
793 |
-
Mage::log("Product: " . $product->getName(), null, 'cart.log', true);
|
794 |
-
Mage::log("Price: " . $finalPrice, null, 'cart.log', true);
|
795 |
-
Mage::log("weight: " . $weight, null, 'cart.log', true);
|
796 |
-
Mage::log("sku: " . $sku, null, 'cart.log', true);*/
|
797 |
-
|
798 |
-
$volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
|
799 |
-
$_data = array(
|
800 |
-
'object_id' => $product->getId(),
|
801 |
-
'name' => $product->getName(),
|
802 |
-
'sku' => $sku,
|
803 |
-
'category_id' => $skyboxCategoryId,
|
804 |
-
'final_price' => $finalPrice,
|
805 |
-
'weight' => ($weight) ? $weight : 1,
|
806 |
-
'image_url' => $product->getImageUrl(),
|
807 |
-
'typeProduct' => $type,
|
808 |
-
'VolWeight' => $volWeight,
|
809 |
-
'merchantproductid' => $productId
|
810 |
-
);
|
811 |
-
|
812 |
-
// $this->_calculatePrice($_data);
|
813 |
-
break;
|
814 |
-
|
815 |
-
default:
|
816 |
-
Mage::log("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice",
|
817 |
-
null, 'skyboxcheckout.log', false);
|
818 |
-
trigger_error("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice");
|
819 |
-
$defaultSwitch = true;
|
820 |
-
break;
|
821 |
-
}
|
822 |
-
|
823 |
-
if (!$defaultSwitch) {
|
824 |
-
//Mage::log(print_r('EnableTax: ', true), null, 'tracer.log', true);
|
825 |
-
//Mage::log(print_r($this->getEnabledAddSumTaxToPrice(), true), null, 'tracer.log', true);
|
826 |
-
if ($this->getEnabledAddSumTaxToPrice()) {
|
827 |
-
$store = Mage::app()->getStore('default');
|
828 |
-
$taxCalculation = Mage::getModel('tax/calculation');
|
829 |
-
$request = $taxCalculation->getRateRequest(null, null, null, $store);
|
830 |
-
// $product = Mage::registry('current_product');
|
831 |
-
$taxClassId = $product->getTaxClassId();
|
832 |
-
$percentTax = $taxCalculation->getRate($request->setProductClassId($taxClassId));
|
833 |
-
|
834 |
-
$taxPrice = $_data['final_price'] * ($percentTax / 100);
|
835 |
-
|
836 |
-
//Mage::log(print_r('Id product: ' . $product->getId(), true), null, 'tracer.log', true);
|
837 |
-
//Mage::log(print_r('$taxPrice: ' . $taxPrice, true), null, 'tracer.log', true);
|
838 |
-
//Mage::log(print_r('price: ' . $_data['final_price'], true), null, 'tracer.log', true);
|
839 |
-
//Mage::log(print_r('$taxPrice+price: ' . ($taxPrice + $_data['final_price']), true), null, 'tracer.log', true);
|
840 |
-
$comissionSkybox = $_data['final_price'] * (10 / 100);
|
841 |
-
//Mage::log(print_r('comision skybox: ' . ($comissionSkybox), true), null, 'tracer.log', true);
|
842 |
-
//Mage::log(print_r('price+comision skybox: ' . ($_data['final_price'] + $comissionSkybox), true), null, 'tracer.log', true);
|
843 |
-
//Mage::log(print_r('$taxPrice+price+comision: ' . ($taxPrice + $_data['final_price'] + $comissionSkybox), true), null, 'tracer.log', true);
|
844 |
-
//Mage::log(print_r('comision true: ' . (($taxPrice + $_data['final_price']) * (10 / 100)), true), null, 'tracer.log', true);
|
845 |
-
$priceReally = ($taxPrice + $_data['final_price']) + ($taxPrice + $_data['final_price']) * (10 / 100);
|
846 |
-
//Mage::log(print_r('$taxPrice+price+comision true: ' . ($priceReally), true), null, 'tracer.log', true);
|
847 |
-
$_data['final_price'] = $_data['final_price'] + $taxPrice;
|
848 |
-
}
|
849 |
-
|
850 |
-
//Mage::log(print_r('####################### Data produc params #######################', true), null, 'tracer.log', true);
|
851 |
-
//Mage::log(print_r($_data, true), null, 'tracer.log', true);
|
852 |
-
try {
|
853 |
-
$this->_calculatePrice($_data);
|
854 |
-
} catch (\Exception $e) {
|
855 |
-
Mage::log($e->getMessage(), null, 'skyboxcheckout.log', false);
|
856 |
-
}
|
857 |
-
|
858 |
-
}
|
859 |
-
|
860 |
-
Mage::log("Product Class: " . get_class($product), null, 'skyboxcheckout.log', false);
|
861 |
-
Mage::log("Product Type: " . $type, null, 'skyboxcheckout.log', false);
|
862 |
-
Mage::log(print_r($_data, true), null, 'skyboxcheckout.log', false);
|
863 |
-
|
864 |
-
$data = $this->_callServiceSky($_data);
|
865 |
-
/*var_dump($this); exit;
|
866 |
-
$this->_product_data = $_data;
|
867 |
-
$this->_product_id = $productId;
|
868 |
-
$apiData = $this->_api;
|
869 |
-
var_dump($apiData); exit;*/
|
870 |
-
return $data;
|
871 |
-
}
|
872 |
-
|
873 |
-
/**
|
874 |
-
* Return the Commodity from Category or Root
|
875 |
-
*
|
876 |
-
* @param $product
|
877 |
-
* @return int
|
878 |
-
*/
|
879 |
-
public function getCommodityFromCategory($product)
|
880 |
-
{
|
881 |
-
$result = 0;
|
882 |
-
|
883 |
-
try {
|
884 |
-
$categoryIds = $product->getCategoryIds();
|
885 |
-
|
886 |
-
if (count($categoryIds)) {
|
887 |
-
$categoryId = $categoryIds[0];
|
888 |
-
$category = Mage::getModel('catalog/category')->load($categoryId);
|
889 |
-
$result = $category->getSkyboxCategoryIdSelect();
|
890 |
-
}
|
891 |
-
|
892 |
-
if (empty($result)) {
|
893 |
-
$categoryId = Mage::app()->getStore()->getRootCategoryId();
|
894 |
-
$category = Mage::getModel('catalog/category')->load($categoryId);
|
895 |
-
$result = $category->getSkyboxCategoryIdSelect();
|
896 |
-
}
|
897 |
-
|
898 |
-
$result = isset($result) ? $result : 0;
|
899 |
-
|
900 |
-
} catch (\Exception $e) {
|
901 |
-
\error_log("catch exception product_: " . $product . PHP_EOL, 3, BP . '/var/log/magento19.trace.log');
|
902 |
-
}
|
903 |
-
|
904 |
-
return $result;
|
905 |
-
}
|
906 |
-
|
907 |
-
private function _callServiceSky($data)
|
908 |
-
{
|
909 |
-
$msg = sprintf("CalculatePrice: [%s] - [%s] - [%s] - [Category_id: %s] - [Price: %s] - [weight: %s] - [typeProduct: %s]",
|
910 |
-
$data['object_id'],
|
911 |
-
$data['sku'],
|
912 |
-
$data['name'],
|
913 |
-
$data['category_id'],
|
914 |
-
$data['final_price'],
|
915 |
-
$data['weight'],
|
916 |
-
$data['typeProduct']
|
917 |
-
);
|
918 |
-
|
919 |
-
$params = array(
|
920 |
-
'htmlobjectid' => $data['object_id'],
|
921 |
-
'code' => $data['sku'],
|
922 |
-
'name' => $data['name'],
|
923 |
-
'category' => $data['category_id'],
|
924 |
-
'price' => $data['final_price'],
|
925 |
-
//'storeproductprice' => $product->getFinalPrice(),
|
926 |
-
'weight' => ($data['weight']) ? $data['weight'] : 1,
|
927 |
-
'weightunit' => $this->getWeightUnit(),
|
928 |
-
'imgurl' => $data['image_url'],
|
929 |
-
/*'volweight' => $data['VolWeight'],
|
930 |
-
'merchantproductid' => $data['merchantproductid']*/
|
931 |
-
);
|
932 |
-
//var_dump($params); exit;
|
933 |
-
return $params;
|
934 |
-
}
|
935 |
-
|
936 |
-
/*Async End*/
|
937 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Catalog
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Catalog
|
8 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Model instance
|
15 |
+
* @var Skybox_Core_Model_Config
|
16 |
+
*/
|
17 |
+
/*protected $_config = null;
|
18 |
+
|
19 |
+
protected $_typeConfig = "skyboxcore/config";
|
20 |
+
|
21 |
+
protected function getConfig()
|
22 |
+
{
|
23 |
+
if(null === $this->_config)
|
24 |
+
$this->_config = Mage::getModel($this->_typeConfig);
|
25 |
+
}*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Model instance
|
29 |
+
* @var Mage_Core_Catalog_Model_Product
|
30 |
+
*/
|
31 |
+
protected $_product = null;
|
32 |
+
|
33 |
+
protected $_productResult = null;
|
34 |
+
|
35 |
+
protected $_typeProduct = "catalog/product";
|
36 |
+
|
37 |
+
protected $_product_id = null;
|
38 |
+
protected $_product_data = null;
|
39 |
+
|
40 |
+
public function getProductId()
|
41 |
+
{
|
42 |
+
if ($this->_product_id != null) {
|
43 |
+
return $this->_product_id;
|
44 |
+
}
|
45 |
+
return null;
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getProductData()
|
49 |
+
{
|
50 |
+
if ($this->_product_data != null) {
|
51 |
+
return $this->_product_data;
|
52 |
+
}
|
53 |
+
return null;
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Calculate Price
|
59 |
+
*
|
60 |
+
* @param int|Mage_Catalog_Model_Product $product
|
61 |
+
* @param Varien_Object $request
|
62 |
+
* @param float $finalPrice
|
63 |
+
* @param string $type
|
64 |
+
* @param int $objectId
|
65 |
+
* @return Mage_Checkout_Model_Cart
|
66 |
+
*/
|
67 |
+
public function CalculatePrice($product, $request, $finalPrice = null, $type = null, $objectId = 1)
|
68 |
+
{
|
69 |
+
Mage::log("ApiProductCatalog ", null, 'orden.log', true);
|
70 |
+
|
71 |
+
//Mage::log(print_r('Product', true), null, 'tracer.log', true);
|
72 |
+
|
73 |
+
//if ($this->getErrorAuthenticate() && !$this->getLocationAllow()) {
|
74 |
+
if (!$this->getLocationAllow()) {
|
75 |
+
return $this;
|
76 |
+
}
|
77 |
+
|
78 |
+
if (!is_object($product)) {
|
79 |
+
$storeId = Mage::app()->getStore()->getStoreId();
|
80 |
+
$product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($product);
|
81 |
+
}
|
82 |
+
|
83 |
+
$productId = $product->getId();
|
84 |
+
$_data = null;
|
85 |
+
|
86 |
+
if ($type == null) {
|
87 |
+
$type = $product->getTypeId();
|
88 |
+
}
|
89 |
+
|
90 |
+
$defaultSwitch = false;
|
91 |
+
switch ($type) {
|
92 |
+
case 'simple':
|
93 |
+
$finalPrice = isset($finalPrice) ? $finalPrice : $product->getFinalPrice();
|
94 |
+
$category_id = $product->getSkyboxCategoryId();
|
95 |
+
$category_id = isset($category_id) ? $category_id : $this->getCommodityFromCategory($product);
|
96 |
+
$volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
|
97 |
+
|
98 |
+
$_data = array(
|
99 |
+
'object_id' => 1,
|
100 |
+
'name' => $product->getName(),
|
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,
|
108 |
+
'merchantproductid' => $productId
|
109 |
+
);
|
110 |
+
// $this->_calculatePrice($_data);
|
111 |
+
break;
|
112 |
+
|
113 |
+
case 'configurable':
|
114 |
+
|
115 |
+
$finalPrice = isset($finalPrice) ? $finalPrice : null;
|
116 |
+
$weight = $product->getTypeInstance(true)->getWeight($product);
|
117 |
+
$sku = $product->getSku();
|
118 |
+
|
119 |
+
Mage::log("CalculatePrice configurable : " . $finalPrice, null, 'skyboxcheckout.log', false);
|
120 |
+
|
121 |
+
if ($request) {
|
122 |
+
$childProduct = Mage::getModel('catalog/product_type_configurable')
|
123 |
+
->getProductByAttributes($request->getData('super_attribute'), $product);
|
124 |
+
|
125 |
+
$productId = $childProduct->getId();
|
126 |
+
$sku = $childProduct->getSku();
|
127 |
+
|
128 |
+
}
|
129 |
+
|
130 |
+
$parentItem = null;
|
131 |
+
|
132 |
+
if (isset($request) && !$finalPrice) {
|
133 |
+
Mage::log("CalculatePrice candidate INI", null, 'skyboxcheckout.log', false);
|
134 |
+
$_finalPrice = 0;
|
135 |
+
|
136 |
+
$cartCandidates = $product->getTypeInstance(true)
|
137 |
+
->prepareForCartAdvanced($request, $product, 'full');
|
138 |
+
|
139 |
+
foreach ($cartCandidates as $candidate) {
|
140 |
+
// Child items can be sticked together only within their parent
|
141 |
+
$stickWithinParent = $candidate->getParentProductId() ? $parentItem : null;
|
142 |
+
$candidate->setStickWithinParent($stickWithinParent);
|
143 |
+
|
144 |
+
$candidate_getFinalPrice = $candidate->getPriceModel()->getFinalPrice($request->getQty(),
|
145 |
+
$product);
|
146 |
+
Mage::log("CalculatePrice candidate getFinalPrice: " . $candidate_getFinalPrice, null,
|
147 |
+
'skyboxcheckout.log', false);
|
148 |
+
|
149 |
+
$_finalPrice = $_finalPrice + $candidate_getFinalPrice;
|
150 |
+
if ($_finalPrice) {
|
151 |
+
break;
|
152 |
+
}
|
153 |
+
}
|
154 |
+
$finalPrice = $_finalPrice;
|
155 |
+
Mage::log("CalculatePrice candidate FIN", null, 'skyboxcheckout.log', false);
|
156 |
+
}
|
157 |
+
|
158 |
+
/* Weight start*/
|
159 |
+
/*
|
160 |
+
$options = array();
|
161 |
+
// Get any super_attribute settings we need
|
162 |
+
$productAttributesOptions = $product->getTypeInstance(true)->getConfigurableOptions($product);
|
163 |
+
foreach ($productAttributesOptions as $productAttributeOption) {
|
164 |
+
$options[$product->getId()] = array();
|
165 |
+
foreach ($productAttributeOption as $optionValues) {
|
166 |
+
$val = ($optionValues['option_title']);
|
167 |
+
$options[$product->getId()][] = array (
|
168 |
+
$optionValues['sku'] => $optionValues['attribute_code']."=".$val
|
169 |
+
|
170 |
+
) ;
|
171 |
+
}
|
172 |
+
|
173 |
+
}
|
174 |
+
$prod_weight = 1;
|
175 |
+
if(!empty($optionValues)) {
|
176 |
+
$a = Mage::getModel('catalog/product')->loadByAttribute('sku',$optionValues['sku']);
|
177 |
+
//$product->load($product->getIdBySku($optionValues['sku']));
|
178 |
+
$prod_weight = $a->getWeight();
|
179 |
+
echo ":::".$prod_weight."::";
|
180 |
+
}
|
181 |
+
*/
|
182 |
+
/* Weight end*/
|
183 |
+
|
184 |
+
$category_id = $product->getSkyboxCategoryId();
|
185 |
+
$category_id = isset($category_id) ? $category_id : $this->getCommodityFromCategory($product);
|
186 |
+
|
187 |
+
$volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
|
188 |
+
$_data = array(
|
189 |
+
'object_id' => 1,
|
190 |
+
'name' => $product->getName(),
|
191 |
+
//'sku' => $product->getSku(),
|
192 |
+
'sku' => $sku,
|
193 |
+
'category_id' => $category_id,
|
194 |
+
'final_price' => $finalPrice,
|
195 |
+
'weight' => $weight ? $weight : 1,
|
196 |
+
'image_url' => $product->getImageUrl(),
|
197 |
+
'typeProduct' => $type,
|
198 |
+
'VolWeight' => $volWeight,
|
199 |
+
'merchantproductid' => $productId
|
200 |
+
);
|
201 |
+
|
202 |
+
// $this->_calculatePrice($_data);
|
203 |
+
break;
|
204 |
+
|
205 |
+
case 'bundle':
|
206 |
+
//$_finalPrice = $product->getTotalBundleItemsPrice($product, $request->getQty());
|
207 |
+
//$finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
|
208 |
+
|
209 |
+
//Mage::log(print_r($product, true), null, 'cart.log', true);
|
210 |
+
//Mage::log("Product: [" . $product->getId() . "] - Class: " . get_class($product), null, 'skyboxcheckout.log', false);
|
211 |
+
|
212 |
+
//Mage::log(print_r($request, true), null, 'cart.log', true);
|
213 |
+
|
214 |
+
$finalPrice = isset($finalPrice) ? $finalPrice : null;
|
215 |
+
$weight = $product->getTypeInstance(true)->getWeight($product);
|
216 |
+
$sku = $product->getSku();
|
217 |
+
|
218 |
+
//if (isset($request) && !$finalPrice) {
|
219 |
+
if (isset($request)) {
|
220 |
+
|
221 |
+
$parentItem = null;
|
222 |
+
$_finalPrice = null;
|
223 |
+
$_weight = 0;
|
224 |
+
|
225 |
+
$cartCandidates = $product->getTypeInstance(true)
|
226 |
+
->prepareForCartAdvanced($request, $product, 'full');
|
227 |
+
|
228 |
+
foreach ($cartCandidates as $candidate) {
|
229 |
+
// Child items can be sticked together only within their parent
|
230 |
+
$stickWithinParent = $candidate->getParentProductId() ? $parentItem : null;
|
231 |
+
$candidate->setStickWithinParent($stickWithinParent);
|
232 |
+
|
233 |
+
if (!$_finalPrice) {
|
234 |
+
$_finalPrice = $candidate->getPriceModel()->getFinalPrice($request->getQty(), $product);
|
235 |
+
//break;
|
236 |
+
}
|
237 |
+
//$_weight = $_weight + $candidate->getPriceModel()->getWeight();
|
238 |
+
$_weight = $_weight + $candidate->getWeight();
|
239 |
+
}
|
240 |
+
|
241 |
+
$finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
|
242 |
+
if ($_weight > 0) {
|
243 |
+
$weight = $_weight;
|
244 |
+
}
|
245 |
+
}
|
246 |
+
|
247 |
+
//Mage::log("weight: " . $weight, null, 'cart.log', true);
|
248 |
+
//Mage::log("sku: " . $sku, null, 'cart.log', true);
|
249 |
+
|
250 |
+
$category_id = $product->getSkyboxCategoryId();
|
251 |
+
$category_id = isset($category_id) ? $category_id : $this->getCommodityFromCategory($product);
|
252 |
+
|
253 |
+
$volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
|
254 |
+
$_data = array(
|
255 |
+
'object_id' => 1,
|
256 |
+
'name' => $product->getName(),
|
257 |
+
'sku' => $sku,
|
258 |
+
'category_id' => $category_id,
|
259 |
+
'final_price' => $finalPrice,
|
260 |
+
'weight' => ($weight) ? $weight : 1,
|
261 |
+
'image_url' => $product->getImageUrl(),
|
262 |
+
'typeProduct' => $type,
|
263 |
+
'VolWeight' => $volWeight,
|
264 |
+
'merchantproductid' => $productId
|
265 |
+
);
|
266 |
+
// $this->_calculatePrice($_data);
|
267 |
+
break;
|
268 |
+
|
269 |
+
case 'bundle_fixed':
|
270 |
+
|
271 |
+
// @Note: It should be rewrite!!
|
272 |
+
$finalPrice = isset($finalPrice) ? $finalPrice : null;
|
273 |
+
$skyboxCategoryId = $product->getSkyboxCategoryId();
|
274 |
+
$weight = $product->getTypeInstance(true)->getWeight($product);
|
275 |
+
$sku = $product->getSku();
|
276 |
+
|
277 |
+
$selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection(
|
278 |
+
$product->getTypeInstance(true)->getOptionsIds($product), $product
|
279 |
+
);
|
280 |
+
|
281 |
+
$_finalPrice = null;
|
282 |
+
$_weight = 0;
|
283 |
+
$_skyboxCategoryId = null;
|
284 |
+
|
285 |
+
foreach ($selectionCollection as $option) {
|
286 |
+
//if ($option->getData('is_default') == 0) continue;
|
287 |
+
|
288 |
+
$product_simple = Mage::getModel('catalog/product')
|
289 |
+
->load($option->getId());
|
290 |
+
|
291 |
+
$_finalPrice = $_finalPrice + $product_simple->getFinalPrice();
|
292 |
+
$_weight = $_weight + $product_simple->getWeight();
|
293 |
+
|
294 |
+
if (!$_skyboxCategoryId) { // Set SkyboxCategory from the first Simple Product
|
295 |
+
// $_skyboxCategoryId = $product_simple->getSkyboxCategoryId();
|
296 |
+
$_skyboxCategoryId = $product->getSkyboxCategoryId();
|
297 |
+
$_skyboxCategoryId = isset($_skyboxCategoryId) ? $_skyboxCategoryId : $this->getCommodityFromCategory($product);
|
298 |
+
}
|
299 |
+
}
|
300 |
+
|
301 |
+
$finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
|
302 |
+
|
303 |
+
if (!$weight) {
|
304 |
+
$weight = $_weight;
|
305 |
+
}
|
306 |
+
|
307 |
+
if (!$skyboxCategoryId) {
|
308 |
+
$skyboxCategoryId = $_skyboxCategoryId;
|
309 |
+
}
|
310 |
+
|
311 |
+
/*Mage::log("-------------------------", null, 'cart.log', true);
|
312 |
+
Mage::log("Product: " . $product->getName(), null, 'cart.log', true);
|
313 |
+
Mage::log("Price: " . $finalPrice, null, 'cart.log', true);
|
314 |
+
Mage::log("weight: " . $weight, null, 'cart.log', true);
|
315 |
+
Mage::log("sku: " . $sku, null, 'cart.log', true);*/
|
316 |
+
|
317 |
+
|
318 |
+
$volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
|
319 |
+
$_data = array(
|
320 |
+
'object_id' => 1,
|
321 |
+
'name' => $product->getName(),
|
322 |
+
'sku' => $sku,
|
323 |
+
'category_id' => $skyboxCategoryId,
|
324 |
+
'final_price' => $finalPrice,
|
325 |
+
'weight' => ($weight) ? $weight : 1,
|
326 |
+
'image_url' => $product->getImageUrl(),
|
327 |
+
'typeProduct' => $type,
|
328 |
+
'VolWeight' => $volWeight,
|
329 |
+
'merchantproductid' => $productId
|
330 |
+
);
|
331 |
+
|
332 |
+
// $this->_calculatePrice($_data);
|
333 |
+
break;
|
334 |
+
|
335 |
+
default:
|
336 |
+
Mage::log("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice",
|
337 |
+
null, 'skyboxcheckout.log', false);
|
338 |
+
trigger_error("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice");
|
339 |
+
$defaultSwitch = true;
|
340 |
+
break;
|
341 |
+
}
|
342 |
+
|
343 |
+
if (!$defaultSwitch) {
|
344 |
+
//Mage::log(print_r('EnableTax: ', true), null, 'tracer.log', true);
|
345 |
+
//Mage::log(print_r($this->getEnabledAddSumTaxToPrice(), true), null, 'tracer.log', true);
|
346 |
+
if ($this->getEnabledAddSumTaxToPrice()) {
|
347 |
+
$store = Mage::app()->getStore('default');
|
348 |
+
$taxCalculation = Mage::getModel('tax/calculation');
|
349 |
+
$request = $taxCalculation->getRateRequest(null, null, null, $store);
|
350 |
+
// $product = Mage::registry('current_product');
|
351 |
+
$taxClassId = $product->getTaxClassId();
|
352 |
+
$percentTax = $taxCalculation->getRate($request->setProductClassId($taxClassId));
|
353 |
+
|
354 |
+
$taxPrice = $_data['final_price'] * ($percentTax / 100);
|
355 |
+
|
356 |
+
//Mage::log(print_r('Id product: ' . $product->getId(), true), null, 'tracer.log', true);
|
357 |
+
//Mage::log(print_r('$taxPrice: ' . $taxPrice, true), null, 'tracer.log', true);
|
358 |
+
//Mage::log(print_r('price: ' . $_data['final_price'], true), null, 'tracer.log', true);
|
359 |
+
//Mage::log(print_r('$taxPrice+price: ' . ($taxPrice + $_data['final_price']), true), null, 'tracer.log', true);
|
360 |
+
$comissionSkybox = $_data['final_price'] * (10 / 100);
|
361 |
+
//Mage::log(print_r('comision skybox: ' . ($comissionSkybox), true), null, 'tracer.log', true);
|
362 |
+
//Mage::log(print_r('price+comision skybox: ' . ($_data['final_price'] + $comissionSkybox), true), null, 'tracer.log', true);
|
363 |
+
//Mage::log(print_r('$taxPrice+price+comision: ' . ($taxPrice + $_data['final_price'] + $comissionSkybox), true), null, 'tracer.log', true);
|
364 |
+
//Mage::log(print_r('comision true: ' . (($taxPrice + $_data['final_price']) * (10 / 100)), true), null, 'tracer.log', true);
|
365 |
+
$priceReally = ($taxPrice + $_data['final_price']) + ($taxPrice + $_data['final_price']) * (10 / 100);
|
366 |
+
//Mage::log(print_r('$taxPrice+price+comision true: ' . ($priceReally), true), null, 'tracer.log', true);
|
367 |
+
|
368 |
+
|
369 |
+
$_data['final_price'] = $_data['final_price'] + $taxPrice;
|
370 |
+
}
|
371 |
+
|
372 |
+
//Mage::log(print_r('####################### Data produc params #######################', true), null, 'tracer.log', true);
|
373 |
+
//Mage::log(print_r($_data, true), null, 'tracer.log', true);
|
374 |
+
// $this->_calculatePrice($_data);
|
375 |
+
try {
|
376 |
+
$this->_calculatePrice($_data);
|
377 |
+
} catch (\Exception $e) {
|
378 |
+
Mage::log($e->getMessage(), null, 'skyboxcheckout.log', false);
|
379 |
+
}
|
380 |
+
}
|
381 |
+
|
382 |
+
Mage::log("Product Class: " . get_class($product), null, 'skyboxcheckout.log', false);
|
383 |
+
Mage::log("Product Type: " . $type, null, 'skyboxcheckout.log', false);
|
384 |
+
Mage::log(print_r($_data, true), null, 'skyboxcheckout.log', false);
|
385 |
+
|
386 |
+
$this->_product_data = $_data;
|
387 |
+
$this->_product_id = $productId;
|
388 |
+
return $this;
|
389 |
+
}
|
390 |
+
|
391 |
+
private function _calculatePrice($data)
|
392 |
+
{
|
393 |
+
$msg = sprintf("CalculatePrice: [%s] - [%s] - [%s] - [Category_id: %s] - [Price: %s] - [weight: %s] - [typeProduct: %s]",
|
394 |
+
$data['object_id'],
|
395 |
+
$data['sku'],
|
396 |
+
$data['name'],
|
397 |
+
$data['category_id'],
|
398 |
+
$data['final_price'],
|
399 |
+
$data['weight'],
|
400 |
+
$data['typeProduct']
|
401 |
+
);
|
402 |
+
|
403 |
+
Mage::log($msg, null, 'skyboxcheckout.log', false);
|
404 |
+
|
405 |
+
$params = array(
|
406 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
407 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
|
408 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
|
409 |
+
'htmlobjectid' => $data['object_id'],
|
410 |
+
'storeproductcode' => $data['sku'],
|
411 |
+
'storeproductname' => $data['name'],
|
412 |
+
'storeproductcategory' => $data['category_id'],
|
413 |
+
'storeproductprice' => $data['final_price'],
|
414 |
+
//'storeproductprice' => $product->getFinalPrice(),
|
415 |
+
'weight' => ($data['weight']) ? $data['weight'] : 1,
|
416 |
+
'weightunit' => $this->getWeightUnit(),
|
417 |
+
'storeproductimgurl' => $data['image_url'],
|
418 |
+
'merchantproductid' => $data['merchantproductid']
|
419 |
+
);
|
420 |
+
$this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_CALCULATE, $params);
|
421 |
+
}
|
422 |
+
|
423 |
+
public function HtmlTemplateButton()
|
424 |
+
{
|
425 |
+
if (!$this->getErrorAuthenticate() && $this->_getApi()->getLocationAllow()) {
|
426 |
+
$params = array(
|
427 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
428 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
|
429 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi()
|
430 |
+
);
|
431 |
+
|
432 |
+
$this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_GET_TEMPLATE_BUTTON, $params);
|
433 |
+
}
|
434 |
+
|
435 |
+
return $this;
|
436 |
+
}
|
437 |
+
|
438 |
+
public function GetTemplateProduct()
|
439 |
+
{
|
440 |
+
Mage::log("ApiProduct ", null, 'orden.log', true);
|
441 |
+
if (!$this->getErrorAuthenticate() && $this->_getApi()->getLocationAllow() && !$this->_getApi()->ErrorServiceNotController()) {
|
442 |
+
//if (!$this->getErrorAuthenticate() && $this->_getApi()->getLocationAllow() && !$this->_getApi()->ErrorService()) {
|
443 |
+
$_productResult = $this->getResponse();
|
444 |
+
$template = $_productResult->TooltipButtonTemplate;
|
445 |
+
return $template;
|
446 |
+
// $templateButton = $this->getHtmlTemplateButton();
|
447 |
+
// if (empty($templateButton))
|
448 |
+
// $this->HtmlTemplateButton();
|
449 |
+
//
|
450 |
+
// /*if($_productResult->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_BUTTONERROR})
|
451 |
+
// {*/
|
452 |
+
// //Mage::log("_productResult--->" . json_decode($_productResult));
|
453 |
+
// $templateButton = $this->getHtmlTemplateButton();
|
454 |
+
// if (!empty($templateButton)) {
|
455 |
+
// $template = $this->getHtmlTemplateButton();
|
456 |
+
//// Mage::log(print_r('response template buttom', true), null, 'tracer.log', true);
|
457 |
+
//// Mage::log(print_r($_productResult, true), null, 'tracer.log', true);
|
458 |
+
// foreach ($_productResult as $key => $value) {
|
459 |
+
// $template = str_replace('{' . $key . '}', $value, $template);
|
460 |
+
// }
|
461 |
+
//
|
462 |
+
// // Just for {Block} crap
|
463 |
+
// $template = str_replace('{Block}', '', $template);
|
464 |
+
//
|
465 |
+
// return $template;
|
466 |
+
// }
|
467 |
+
//
|
468 |
+
// $displayUSD = "''"; //CartCountryIso
|
469 |
+
// /*}else{
|
470 |
+
// return "Plantilla de error";
|
471 |
+
// }*/
|
472 |
+
// //Mage::log(get_class($this) . " GetTemplateProduct() ", null, 'cart.log', true);
|
473 |
+
} else {
|
474 |
+
$template = '<div class="skx_content_button"></div>';
|
475 |
+
return $template;
|
476 |
+
}
|
477 |
+
return "";
|
478 |
+
}
|
479 |
+
|
480 |
+
protected $_isUSD = null;
|
481 |
+
|
482 |
+
public function IsUSD()
|
483 |
+
{
|
484 |
+
if (null == $this->_isUSD) {
|
485 |
+
$this->_isUSD = ($this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_CART_CURRENCY_ISO,
|
486 |
+
"") == Skybox_Core_Model_Config::SKYBOX_CURRENCY_USD);
|
487 |
+
}
|
488 |
+
return $this->_isUSD;
|
489 |
+
}
|
490 |
+
|
491 |
+
public function getCustoms()
|
492 |
+
{
|
493 |
+
return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_CUSTOMS, "0");
|
494 |
+
}
|
495 |
+
|
496 |
+
public function getShipping()
|
497 |
+
{
|
498 |
+
return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_SHIPPING, "0");
|
499 |
+
}
|
500 |
+
|
501 |
+
public function getInsurance()
|
502 |
+
{
|
503 |
+
return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_INSURANCE, "0");
|
504 |
+
}
|
505 |
+
|
506 |
+
public function getPrice()
|
507 |
+
{
|
508 |
+
return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_PRICE, "0");
|
509 |
+
}
|
510 |
+
|
511 |
+
public function getTotalPrice()
|
512 |
+
{
|
513 |
+
return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_TOTAL, "0");
|
514 |
+
}
|
515 |
+
|
516 |
+
public function getCustomsUSD()
|
517 |
+
{
|
518 |
+
return $this->IsUSD() ? $this->getCustoms() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_CUSTOMS_USD,
|
519 |
+
"0");
|
520 |
+
}
|
521 |
+
|
522 |
+
public function getShippingUSD()
|
523 |
+
{
|
524 |
+
return $this->IsUSD() ? $this->getShipping() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_SHIPPING_USD,
|
525 |
+
"0");
|
526 |
+
}
|
527 |
+
|
528 |
+
public function getInsuranceUSD()
|
529 |
+
{
|
530 |
+
return $this->IsUSD() ? $this->getInsurance() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_INSURANCE_USD,
|
531 |
+
"0");
|
532 |
+
}
|
533 |
+
|
534 |
+
public function getPriceUSD()
|
535 |
+
{
|
536 |
+
return $this->IsUSD() ? $this->getPrice() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_PRICE_USD,
|
537 |
+
"0");
|
538 |
+
}
|
539 |
+
|
540 |
+
public function getTotalPriceUSD()
|
541 |
+
{
|
542 |
+
return $this->IsUSD() ? $this->getTotalPrice() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_TOTAL_USD,
|
543 |
+
"0");
|
544 |
+
}
|
545 |
+
|
546 |
+
public function getGuidSkybox()
|
547 |
+
{
|
548 |
+
return $this->_getApi()->getGuidApi();
|
549 |
+
}
|
550 |
+
|
551 |
+
public function getBasePrice()
|
552 |
+
{
|
553 |
+
return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_BASE_PRICE, "0");
|
554 |
+
}
|
555 |
+
|
556 |
+
public function getBasePriceUSD()
|
557 |
+
{
|
558 |
+
return $this->IsUSD() ? $this->getBasePrice() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_BASE_PRICE_USD,
|
559 |
+
"0");
|
560 |
+
}
|
561 |
+
|
562 |
+
public function getAdjustPrice()
|
563 |
+
{
|
564 |
+
return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ADJUST_PRICE, "0");
|
565 |
+
}
|
566 |
+
|
567 |
+
public function getAdjustPriceUSD()
|
568 |
+
{
|
569 |
+
return $this->IsUSD() ? $this->getAdjustPrice() : $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ADJUST_PRICE_USD,
|
570 |
+
"0");
|
571 |
+
}
|
572 |
+
|
573 |
+
public function getAdjustLabel()
|
574 |
+
{
|
575 |
+
return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_LABEL_ADJUST, "");
|
576 |
+
}
|
577 |
+
|
578 |
+
/*Async Ini*/
|
579 |
+
|
580 |
+
public function getUrl($product, $request, $finalPrice = null, $type = null, $objectId = 1)
|
581 |
+
{
|
582 |
+
Mage::log("ApiProductCatalog ", null, 'orden.log', true);
|
583 |
+
|
584 |
+
//Mage::log(print_r('Product', true), null, 'tracer.log', true);
|
585 |
+
|
586 |
+
//if ($this->getErrorAuthenticate() && !$this->getLocationAllow()) {
|
587 |
+
if (!$this->getLocationAllow()) {
|
588 |
+
return $this;
|
589 |
+
}
|
590 |
+
|
591 |
+
if (!is_object($product)) {
|
592 |
+
$storeId = Mage::app()->getStore()->getStoreId();
|
593 |
+
$product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($product);
|
594 |
+
}
|
595 |
+
|
596 |
+
$productId = $product->getId();
|
597 |
+
$_data = null;
|
598 |
+
|
599 |
+
if ($type == null) {
|
600 |
+
$type = $product->getTypeId();
|
601 |
+
}
|
602 |
+
|
603 |
+
$defaultSwitch = true;
|
604 |
+
switch ($type) {
|
605 |
+
case 'simple':
|
606 |
+
$finalPrice = isset($finalPrice) ? $finalPrice : $product->getFinalPrice();
|
607 |
+
$category_id = $product->getSkyboxCategoryId();
|
608 |
+
$category_id = isset($category_id) ? $category_id : $this->getCommodityFromCategory($product);
|
609 |
+
$volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
|
610 |
+
|
611 |
+
$_data = array(
|
612 |
+
'object_id' => $product->getId(),
|
613 |
+
'name' => $product->getName(),
|
614 |
+
'sku' => $product->getSku(),
|
615 |
+
'category_id' => $category_id,
|
616 |
+
'final_price' => $finalPrice,
|
617 |
+
'weight' => ($product->getWeight()) ? $product->getWeight() : 1,
|
618 |
+
'image_url' => $product->getImageUrl(),
|
619 |
+
'typeProduct' => $type,
|
620 |
+
'VolWeight' => $volWeight,
|
621 |
+
'merchantproductid' => $productId
|
622 |
+
);
|
623 |
+
// $this->_calculatePrice($_data);
|
624 |
+
break;
|
625 |
+
|
626 |
+
case 'configurable':
|
627 |
+
|
628 |
+
$finalPrice = isset($finalPrice) ? $finalPrice : null;
|
629 |
+
$weight = $product->getTypeInstance(true)->getWeight($product);
|
630 |
+
$sku = $product->getSku();
|
631 |
+
|
632 |
+
Mage::log("CalculatePrice configurable : " . $finalPrice, null, 'skyboxcheckout.log', false);
|
633 |
+
|
634 |
+
if ($request) {
|
635 |
+
$childProduct = Mage::getModel('catalog/product_type_configurable')
|
636 |
+
->getProductByAttributes($request->getData('super_attribute'), $product);
|
637 |
+
|
638 |
+
$productId = $childProduct->getId();
|
639 |
+
$sku = $childProduct->getSku();
|
640 |
+
|
641 |
+
}
|
642 |
+
|
643 |
+
$parentItem = null;
|
644 |
+
|
645 |
+
if (isset($request) && !$finalPrice) {
|
646 |
+
Mage::log("CalculatePrice candidate INI", null, 'skyboxcheckout.log', false);
|
647 |
+
$_finalPrice = 0;
|
648 |
+
|
649 |
+
$cartCandidates = $product->getTypeInstance(true)
|
650 |
+
->prepareForCartAdvanced($request, $product, 'full');
|
651 |
+
|
652 |
+
foreach ($cartCandidates as $candidate) {
|
653 |
+
// Child items can be sticked together only within their parent
|
654 |
+
$stickWithinParent = $candidate->getParentProductId() ? $parentItem : null;
|
655 |
+
$candidate->setStickWithinParent($stickWithinParent);
|
656 |
+
|
657 |
+
$candidate_getFinalPrice = $candidate->getPriceModel()->getFinalPrice($request->getQty(),
|
658 |
+
$product);
|
659 |
+
Mage::log("CalculatePrice candidate getFinalPrice: " . $candidate_getFinalPrice, null,
|
660 |
+
'skyboxcheckout.log', false);
|
661 |
+
|
662 |
+
$_finalPrice = $_finalPrice + $candidate_getFinalPrice;
|
663 |
+
if ($_finalPrice) {
|
664 |
+
break;
|
665 |
+
}
|
666 |
+
}
|
667 |
+
$finalPrice = $_finalPrice;
|
668 |
+
Mage::log("CalculatePrice candidate FIN", null, 'skyboxcheckout.log', false);
|
669 |
+
}
|
670 |
+
|
671 |
+
$category_id = $product->getSkyboxCategoryId();
|
672 |
+
$category_id = isset($category_id) ? $category_id : $this->getCommodityFromCategory($product);
|
673 |
+
|
674 |
+
$volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
|
675 |
+
|
676 |
+
$_data = array(
|
677 |
+
'object_id' => $product->getId(),
|
678 |
+
'name' => $product->getName(),
|
679 |
+
//'sku' => $product->getSku(),
|
680 |
+
'sku' => $sku,
|
681 |
+
'category_id' => $category_id,
|
682 |
+
'final_price' => $finalPrice,
|
683 |
+
'weight' => $weight ? $weight : 1,
|
684 |
+
'image_url' => $product->getImageUrl(),
|
685 |
+
'typeProduct' => $type,
|
686 |
+
'VolWeight' => $volWeight,
|
687 |
+
'merchantproductid' => $productId
|
688 |
+
);
|
689 |
+
|
690 |
+
// $this->_calculatePrice($_data);
|
691 |
+
break;
|
692 |
+
|
693 |
+
case 'bundle':
|
694 |
+
//$_finalPrice = $product->getTotalBundleItemsPrice($product, $request->getQty());
|
695 |
+
//$finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
|
696 |
+
|
697 |
+
//Mage::log(print_r($product, true), null, 'cart.log', true);
|
698 |
+
//Mage::log("Product: [" . $product->getId() . "] - Class: " . get_class($product), null, 'skyboxcheckout.log', false);
|
699 |
+
|
700 |
+
//Mage::log(print_r($request, true), null, 'cart.log', true);
|
701 |
+
|
702 |
+
$finalPrice = isset($finalPrice) ? $finalPrice : null;
|
703 |
+
$weight = $product->getTypeInstance(true)->getWeight($product);
|
704 |
+
$sku = $product->getSku();
|
705 |
+
|
706 |
+
//if (isset($request) && !$finalPrice) {
|
707 |
+
if (isset($request)) {
|
708 |
+
|
709 |
+
$parentItem = null;
|
710 |
+
$_finalPrice = null;
|
711 |
+
$_weight = 0;
|
712 |
+
|
713 |
+
$cartCandidates = $product->getTypeInstance(true)
|
714 |
+
->prepareForCartAdvanced($request, $product, 'full');
|
715 |
+
|
716 |
+
foreach ($cartCandidates as $candidate) {
|
717 |
+
// Child items can be sticked together only within their parent
|
718 |
+
$stickWithinParent = $candidate->getParentProductId() ? $parentItem : null;
|
719 |
+
$candidate->setStickWithinParent($stickWithinParent);
|
720 |
+
|
721 |
+
if (!$_finalPrice) {
|
722 |
+
$_finalPrice = $candidate->getPriceModel()->getFinalPrice($request->getQty(), $product);
|
723 |
+
//break;
|
724 |
+
}
|
725 |
+
//$_weight = $_weight + $candidate->getPriceModel()->getWeight();
|
726 |
+
$_weight = $_weight + $candidate->getWeight();
|
727 |
+
}
|
728 |
+
|
729 |
+
$finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
|
730 |
+
if ($_weight > 0) {
|
731 |
+
$weight = $_weight;
|
732 |
+
}
|
733 |
+
}
|
734 |
+
|
735 |
+
//Mage::log("weight: " . $weight, null, 'cart.log', true);
|
736 |
+
//Mage::log("sku: " . $sku, null, 'cart.log', true);
|
737 |
+
|
738 |
+
$volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
|
739 |
+
$_data = array(
|
740 |
+
'object_id' => $product->getId(),
|
741 |
+
'name' => $product->getName(),
|
742 |
+
'sku' => $sku,
|
743 |
+
'category_id' => $product->getSkyboxCategoryId(),
|
744 |
+
'final_price' => $finalPrice,
|
745 |
+
'weight' => ($weight) ? $weight : 1,
|
746 |
+
'image_url' => $product->getImageUrl(),
|
747 |
+
'typeProduct' => $type,
|
748 |
+
'VolWeight' => $volWeight,
|
749 |
+
'merchantproductid' => $productId
|
750 |
+
);
|
751 |
+
// $this->_calculatePrice($_data);
|
752 |
+
break;
|
753 |
+
|
754 |
+
case 'bundle_fixed':
|
755 |
+
$finalPrice = isset($finalPrice) ? $finalPrice : null;
|
756 |
+
$skyboxCategoryId = $product->getSkyboxCategoryId();
|
757 |
+
$weight = $product->getTypeInstance(true)->getWeight($product);
|
758 |
+
$sku = $product->getSku();
|
759 |
+
|
760 |
+
$selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection(
|
761 |
+
$product->getTypeInstance(true)->getOptionsIds($product), $product
|
762 |
+
);
|
763 |
+
|
764 |
+
$_finalPrice = null;
|
765 |
+
$_weight = 0;
|
766 |
+
$_skyboxCategoryId = null;
|
767 |
+
|
768 |
+
foreach ($selectionCollection as $option) {
|
769 |
+
//if ($option->getData('is_default') == 0) continue;
|
770 |
+
|
771 |
+
$product_simple = Mage::getModel('catalog/product')
|
772 |
+
->load($option->getId());
|
773 |
+
|
774 |
+
$_finalPrice = $_finalPrice + $product_simple->getFinalPrice();
|
775 |
+
$_weight = $_weight + $product_simple->getWeight();
|
776 |
+
|
777 |
+
if (!$_skyboxCategoryId) { // Set SkyboxCategory from the first Simple Product
|
778 |
+
$_skyboxCategoryId = $product_simple->getSkyboxCategoryId();
|
779 |
+
}
|
780 |
+
}
|
781 |
+
|
782 |
+
$finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
|
783 |
+
|
784 |
+
if (!$weight) {
|
785 |
+
$weight = $_weight;
|
786 |
+
}
|
787 |
+
|
788 |
+
if (!$skyboxCategoryId) {
|
789 |
+
$skyboxCategoryId = $_skyboxCategoryId;
|
790 |
+
}
|
791 |
+
|
792 |
+
/*Mage::log("-------------------------", null, 'cart.log', true);
|
793 |
+
Mage::log("Product: " . $product->getName(), null, 'cart.log', true);
|
794 |
+
Mage::log("Price: " . $finalPrice, null, 'cart.log', true);
|
795 |
+
Mage::log("weight: " . $weight, null, 'cart.log', true);
|
796 |
+
Mage::log("sku: " . $sku, null, 'cart.log', true);*/
|
797 |
+
|
798 |
+
$volWeight = !empty(trim($product->getDimensionalWeight())) ? $product->getDimensionalWeight() : 0;
|
799 |
+
$_data = array(
|
800 |
+
'object_id' => $product->getId(),
|
801 |
+
'name' => $product->getName(),
|
802 |
+
'sku' => $sku,
|
803 |
+
'category_id' => $skyboxCategoryId,
|
804 |
+
'final_price' => $finalPrice,
|
805 |
+
'weight' => ($weight) ? $weight : 1,
|
806 |
+
'image_url' => $product->getImageUrl(),
|
807 |
+
'typeProduct' => $type,
|
808 |
+
'VolWeight' => $volWeight,
|
809 |
+
'merchantproductid' => $productId
|
810 |
+
);
|
811 |
+
|
812 |
+
// $this->_calculatePrice($_data);
|
813 |
+
break;
|
814 |
+
|
815 |
+
default:
|
816 |
+
Mage::log("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice",
|
817 |
+
null, 'skyboxcheckout.log', false);
|
818 |
+
trigger_error("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice");
|
819 |
+
$defaultSwitch = true;
|
820 |
+
break;
|
821 |
+
}
|
822 |
+
|
823 |
+
if (!$defaultSwitch) {
|
824 |
+
//Mage::log(print_r('EnableTax: ', true), null, 'tracer.log', true);
|
825 |
+
//Mage::log(print_r($this->getEnabledAddSumTaxToPrice(), true), null, 'tracer.log', true);
|
826 |
+
if ($this->getEnabledAddSumTaxToPrice()) {
|
827 |
+
$store = Mage::app()->getStore('default');
|
828 |
+
$taxCalculation = Mage::getModel('tax/calculation');
|
829 |
+
$request = $taxCalculation->getRateRequest(null, null, null, $store);
|
830 |
+
// $product = Mage::registry('current_product');
|
831 |
+
$taxClassId = $product->getTaxClassId();
|
832 |
+
$percentTax = $taxCalculation->getRate($request->setProductClassId($taxClassId));
|
833 |
+
|
834 |
+
$taxPrice = $_data['final_price'] * ($percentTax / 100);
|
835 |
+
|
836 |
+
//Mage::log(print_r('Id product: ' . $product->getId(), true), null, 'tracer.log', true);
|
837 |
+
//Mage::log(print_r('$taxPrice: ' . $taxPrice, true), null, 'tracer.log', true);
|
838 |
+
//Mage::log(print_r('price: ' . $_data['final_price'], true), null, 'tracer.log', true);
|
839 |
+
//Mage::log(print_r('$taxPrice+price: ' . ($taxPrice + $_data['final_price']), true), null, 'tracer.log', true);
|
840 |
+
$comissionSkybox = $_data['final_price'] * (10 / 100);
|
841 |
+
//Mage::log(print_r('comision skybox: ' . ($comissionSkybox), true), null, 'tracer.log', true);
|
842 |
+
//Mage::log(print_r('price+comision skybox: ' . ($_data['final_price'] + $comissionSkybox), true), null, 'tracer.log', true);
|
843 |
+
//Mage::log(print_r('$taxPrice+price+comision: ' . ($taxPrice + $_data['final_price'] + $comissionSkybox), true), null, 'tracer.log', true);
|
844 |
+
//Mage::log(print_r('comision true: ' . (($taxPrice + $_data['final_price']) * (10 / 100)), true), null, 'tracer.log', true);
|
845 |
+
$priceReally = ($taxPrice + $_data['final_price']) + ($taxPrice + $_data['final_price']) * (10 / 100);
|
846 |
+
//Mage::log(print_r('$taxPrice+price+comision true: ' . ($priceReally), true), null, 'tracer.log', true);
|
847 |
+
$_data['final_price'] = $_data['final_price'] + $taxPrice;
|
848 |
+
}
|
849 |
+
|
850 |
+
//Mage::log(print_r('####################### Data produc params #######################', true), null, 'tracer.log', true);
|
851 |
+
//Mage::log(print_r($_data, true), null, 'tracer.log', true);
|
852 |
+
try {
|
853 |
+
$this->_calculatePrice($_data);
|
854 |
+
} catch (\Exception $e) {
|
855 |
+
Mage::log($e->getMessage(), null, 'skyboxcheckout.log', false);
|
856 |
+
}
|
857 |
+
|
858 |
+
}
|
859 |
+
|
860 |
+
Mage::log("Product Class: " . get_class($product), null, 'skyboxcheckout.log', false);
|
861 |
+
Mage::log("Product Type: " . $type, null, 'skyboxcheckout.log', false);
|
862 |
+
Mage::log(print_r($_data, true), null, 'skyboxcheckout.log', false);
|
863 |
+
|
864 |
+
$data = $this->_callServiceSky($_data);
|
865 |
+
/*var_dump($this); exit;
|
866 |
+
$this->_product_data = $_data;
|
867 |
+
$this->_product_id = $productId;
|
868 |
+
$apiData = $this->_api;
|
869 |
+
var_dump($apiData); exit;*/
|
870 |
+
return $data;
|
871 |
+
}
|
872 |
+
|
873 |
+
/**
|
874 |
+
* Return the Commodity from Category or Root
|
875 |
+
*
|
876 |
+
* @param $product
|
877 |
+
* @return int
|
878 |
+
*/
|
879 |
+
public function getCommodityFromCategory($product)
|
880 |
+
{
|
881 |
+
$result = 0;
|
882 |
+
|
883 |
+
try {
|
884 |
+
$categoryIds = $product->getCategoryIds();
|
885 |
+
|
886 |
+
if (count($categoryIds)) {
|
887 |
+
$categoryId = $categoryIds[0];
|
888 |
+
$category = Mage::getModel('catalog/category')->load($categoryId);
|
889 |
+
$result = $category->getSkyboxCategoryIdSelect();
|
890 |
+
}
|
891 |
+
|
892 |
+
if (empty($result)) {
|
893 |
+
$categoryId = Mage::app()->getStore()->getRootCategoryId();
|
894 |
+
$category = Mage::getModel('catalog/category')->load($categoryId);
|
895 |
+
$result = $category->getSkyboxCategoryIdSelect();
|
896 |
+
}
|
897 |
+
|
898 |
+
$result = isset($result) ? $result : 0;
|
899 |
+
|
900 |
+
} catch (\Exception $e) {
|
901 |
+
\error_log("catch exception product_: " . $product . PHP_EOL, 3, BP . '/var/log/magento19.trace.log');
|
902 |
+
}
|
903 |
+
|
904 |
+
return $result;
|
905 |
+
}
|
906 |
+
|
907 |
+
private function _callServiceSky($data)
|
908 |
+
{
|
909 |
+
$msg = sprintf("CalculatePrice: [%s] - [%s] - [%s] - [Category_id: %s] - [Price: %s] - [weight: %s] - [typeProduct: %s]",
|
910 |
+
$data['object_id'],
|
911 |
+
$data['sku'],
|
912 |
+
$data['name'],
|
913 |
+
$data['category_id'],
|
914 |
+
$data['final_price'],
|
915 |
+
$data['weight'],
|
916 |
+
$data['typeProduct']
|
917 |
+
);
|
918 |
+
|
919 |
+
$params = array(
|
920 |
+
'htmlobjectid' => $data['object_id'],
|
921 |
+
'code' => $data['sku'],
|
922 |
+
'name' => $data['name'],
|
923 |
+
'category' => $data['category_id'],
|
924 |
+
'price' => $data['final_price'],
|
925 |
+
//'storeproductprice' => $product->getFinalPrice(),
|
926 |
+
'weight' => ($data['weight']) ? $data['weight'] : 1,
|
927 |
+
'weightunit' => $this->getWeightUnit(),
|
928 |
+
'imgurl' => $data['image_url'],
|
929 |
+
/*'volweight' => $data['VolWeight'],
|
930 |
+
'merchantproductid' => $data['merchantproductid']*/
|
931 |
+
);
|
932 |
+
//var_dump($params); exit;
|
933 |
+
return $params;
|
934 |
+
}
|
935 |
+
|
936 |
+
/*Async End*/
|
937 |
+
}
|
app/code/community/Skybox/Catalog/Model/Observer.php
CHANGED
@@ -1,271 +1,271 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Checkout
|
5 |
-
*
|
6 |
-
* @category Mage
|
7 |
-
* @package Skybox_Catalog
|
8 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
*
|
13 |
-
* Catalog Model Observer
|
14 |
-
*
|
15 |
-
* Note: For Magento 1.8.x issues with Block Caching
|
16 |
-
*/
|
17 |
-
class Skybox_Catalog_Model_Observer
|
18 |
-
{
|
19 |
-
private function getActive()
|
20 |
-
{
|
21 |
-
// $value = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
|
22 |
-
$value = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
23 |
-
return $value;
|
24 |
-
}
|
25 |
-
|
26 |
-
public function hookToControllerActionPreDispatch($observer)
|
27 |
-
{
|
28 |
-
$active = $this->getActive();
|
29 |
-
if (!$active) {
|
30 |
-
return;
|
31 |
-
}
|
32 |
-
|
33 |
-
//Mage::log('router tivoli: '.$observer->getEvent()->getControllerAction()->getFullActionName(), null, 'tracer.log', true);
|
34 |
-
if (($observer->getEvent()->getControllerAction()->getFullActionName() == 'checkout_cart_add')) {
|
35 |
-
|
36 |
-
//Mage::log('hookToControllerActionPreDispatch '.$observer->getEvent()->getControllerAction()->getFullActionName(),null, 'tracer.log', true);
|
37 |
-
Mage::dispatchEvent("add_to_cart_before", array('request' => $observer->getControllerAction()->getRequest()));
|
38 |
-
}
|
39 |
-
}
|
40 |
-
|
41 |
-
public function hookToControllerActionPostDispatch($observer)
|
42 |
-
{
|
43 |
-
$active = $this->getActive();
|
44 |
-
if (!$active) {
|
45 |
-
return;
|
46 |
-
}
|
47 |
-
|
48 |
-
//Mage::log('router tivoli: '.$observer->getEvent()->getControllerAction()->getFullActionName(), null, 'tracer.log', true);
|
49 |
-
if (($observer->getEvent()->getControllerAction()->getFullActionName() == 'checkout_cart_add')) {
|
50 |
-
|
51 |
-
//Mage::log('hookToControllerActionPostDispatch: '.$observer->getEvent()->getControllerAction()->getFullActionName(),null, 'tracer.log', true);
|
52 |
-
Mage::dispatchEvent("add_to_cart_after", array('request' => $observer->getControllerAction()->getRequest()));
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
-
public function hookToAddToCartBefore($observer)
|
57 |
-
{
|
58 |
-
$active = $this->getActive();
|
59 |
-
if (!$active) {
|
60 |
-
return;
|
61 |
-
}
|
62 |
-
|
63 |
-
//Mage::log('function hookToAddToCartBefore: ',null, 'tracer.log', true);
|
64 |
-
$key = Mage::getSingleton('core/session')->getFormKey();
|
65 |
-
$observer->getEvent()->getRequest()->setParam('form_key', $key);
|
66 |
-
$request = $observer->getEvent()->getRequest()->getParams();
|
67 |
-
}
|
68 |
-
|
69 |
-
public function hookToAddToCartAfter($observer)
|
70 |
-
{
|
71 |
-
$active = $this->getActive();
|
72 |
-
if (!$active) {
|
73 |
-
return;
|
74 |
-
}
|
75 |
-
|
76 |
-
$request = $observer->getEvent()->getRequest()->getParams();
|
77 |
-
Mage::log("hookToAddToCartAfter " . print_r($request, true) . " is added to cart.", null, 'cart.log', true);
|
78 |
-
}
|
79 |
-
|
80 |
-
public function injectTab(Varien_Event_Observer $observer)
|
81 |
-
{
|
82 |
-
// $active = $this->getActive();
|
83 |
-
// if (!$active) { return; }
|
84 |
-
|
85 |
-
// core_block_abstract_prepare_layout_after
|
86 |
-
|
87 |
-
/* $block Mage_Adminhtml_Block_Catalog_Category_Tabs */
|
88 |
-
$block = $observer->getEvent()->getBlock();
|
89 |
-
|
90 |
-
if ($block instanceof Mage_Adminhtml_Block_Catalog_Category_Tabs) {
|
91 |
-
|
92 |
-
if ($this->_getRequest()->getActionName() == 'edit' || $this->_getRequest()->getParam('type')) {
|
93 |
-
|
94 |
-
$tab_ids = $block->getTabsIds();
|
95 |
-
$tab_name = $tab_ids[3]; // SkyboxCheckout position
|
96 |
-
|
97 |
-
if ($tab_name) {
|
98 |
-
$block->removeTab($tab_name);
|
99 |
-
}
|
100 |
-
|
101 |
-
// SkyboxCheckout Tab
|
102 |
-
$block->addTab('custom_tab', array(
|
103 |
-
'label' => 'SkyboxCheckout',
|
104 |
-
'content' => $block->getLayout()
|
105 |
-
->createBlock('skyboxcatalog/catalog_category_tab_skyboxcheckout')
|
106 |
-
->toHtml()
|
107 |
-
));
|
108 |
-
}
|
109 |
-
}
|
110 |
-
}
|
111 |
-
|
112 |
-
public function saveCategory(Varien_Event_Observer $observer)
|
113 |
-
{
|
114 |
-
// catalog_category_prepare_save
|
115 |
-
|
116 |
-
// Note: Already know. this is a piece of crap
|
117 |
-
|
118 |
-
/* $category Mage_Catalog_Model_Category */
|
119 |
-
$category = $observer->getEvent()->getCategory();
|
120 |
-
|
121 |
-
$skybox_category_id = $this->_getRequest()->getPost('skybox_category_id');
|
122 |
-
$skybox_category_id_select = $this->_getRequest()->getPost('skybox_category_id_select');
|
123 |
-
$apply_button = $this->_getRequest()->getPost('apply_button');
|
124 |
-
|
125 |
-
if ($skybox_category_id != $category->getData('skybox_category_id')) {
|
126 |
-
//$category->setData('skybox_category_id', $skybox_category_id);
|
127 |
-
$category->setSkyboxCategoryId($skybox_category_id);
|
128 |
-
$msg = "[" . $category->getId() . "] saving skybox_category_id [" . $skybox_category_id . "]";
|
129 |
-
Mage::log($msg, null, 'skyboxcheckout.log', true);
|
130 |
-
}
|
131 |
-
|
132 |
-
if ($skybox_category_id_select != $category->getData('skybox_category_id_select')) {
|
133 |
-
//$category->setData('skybox_category_id_select', $skybox_category_id_select);
|
134 |
-
$category->setSkyboxCategoryIdSelect($skybox_category_id_select);
|
135 |
-
$msg = "[" . $category->getId() . "] saving skybox_category_id_select [" . $skybox_category_id_select . "]";
|
136 |
-
Mage::log($msg, null, 'skyboxcheckout.log', true);
|
137 |
-
}
|
138 |
-
|
139 |
-
if ($skybox_category_id || $skybox_category_id_select) {
|
140 |
-
Mage::log("Commodities saved!", null, 'skyboxcheckout.log', true);
|
141 |
-
try {
|
142 |
-
$category->getResource()->save($category);
|
143 |
-
} catch (Exception $ex) {
|
144 |
-
Mage::log("saveCategory() Exception: " . $ex->getMessage(), null, 'skyboxcheckout.log', true);
|
145 |
-
}
|
146 |
-
}
|
147 |
-
|
148 |
-
if (isset($apply_button) && $apply_button != 'nothing') {
|
149 |
-
|
150 |
-
$skybox_category_id_select = $this->_getRequest()->getPost('skybox_category_id_select');
|
151 |
-
$skybox_category_id_select = ($skybox_category_id_select) ?
|
152 |
-
$skybox_category_id_select :
|
153 |
-
$category->getData('skybox_category_id_select');
|
154 |
-
|
155 |
-
Mage::log("Apply Button: " . $apply_button, null, 'skyboxcheckout.log', true);
|
156 |
-
switch ($apply_button) {
|
157 |
-
case 'all_products':
|
158 |
-
$categoryIds = array($category->getId());
|
159 |
-
$this->_bulk_commodities($categoryIds, $skybox_category_id_select, true);
|
160 |
-
break;
|
161 |
-
|
162 |
-
case 'all_products_without_commoditites':
|
163 |
-
$categoryIds = array($category->getId());
|
164 |
-
$this->_bulk_commodities($categoryIds, $skybox_category_id_select, false);
|
165 |
-
break;
|
166 |
-
}
|
167 |
-
}
|
168 |
-
return $this;
|
169 |
-
}
|
170 |
-
|
171 |
-
public function setCommodityInForm(Varien_Event_Observer $observer)
|
172 |
-
{
|
173 |
-
// catalog_product_prepare_save
|
174 |
-
|
175 |
-
Mage::log('catalog_product_prepare_save', null, 'skyboxcheckout.log', true);
|
176 |
-
|
177 |
-
$product = $observer->getEvent()->getProduct();
|
178 |
-
$skybox_category_id = $this->_getRequest()->getPost('skybox_category_id');
|
179 |
-
$commodity = $product->getData('skybox_category_id');
|
180 |
-
|
181 |
-
// If the user change commodity manually
|
182 |
-
if ($skybox_category_id && ($skybox_category_id != $product->getData('skybox_category_id'))) {
|
183 |
-
$product->setData('skybox_category_id', $skybox_category_id);
|
184 |
-
$product->getResource()->save($product);
|
185 |
-
return $this;
|
186 |
-
}
|
187 |
-
|
188 |
-
// If commodity already set
|
189 |
-
if ($commodity) {
|
190 |
-
Mage::log('commodity_exist_true', null, 'skyboxcheckout.log', true);
|
191 |
-
return $this;
|
192 |
-
} else {
|
193 |
-
Mage::log('commodity_exist_false', null, 'skyboxcheckout.log', true);
|
194 |
-
$categoryIds = $product->getCategoryIds();
|
195 |
-
|
196 |
-
if (empty($categoryIds)) {
|
197 |
-
return $this;
|
198 |
-
}
|
199 |
-
|
200 |
-
$categoryId = reset($categoryIds); // current
|
201 |
-
|
202 |
-
/* $category Mage_Catalog_Model_Category */
|
203 |
-
$category = Mage::getModel('catalog/category')->load($categoryId);
|
204 |
-
|
205 |
-
$value = $category->getData('skybox_category_id');
|
206 |
-
|
207 |
-
if ($value) {
|
208 |
-
$product->setData('skybox_category_id', $value);
|
209 |
-
$product->getResource()->save($product);
|
210 |
-
} else {
|
211 |
-
Mage::getSingleton('adminhtml/session')->addError(
|
212 |
-
sprintf("The category %s doesn't have any associated commodity.", $category->getData('title'))
|
213 |
-
);
|
214 |
-
}
|
215 |
-
}
|
216 |
-
return $this;
|
217 |
-
}
|
218 |
-
|
219 |
-
/**
|
220 |
-
* Shortcut to getRequest
|
221 |
-
*/
|
222 |
-
protected function _getRequest()
|
223 |
-
{
|
224 |
-
return Mage::app()->getRequest();
|
225 |
-
}
|
226 |
-
|
227 |
-
private function _bulk_commodities($categoryIds, $value, $allProducts = true)
|
228 |
-
{
|
229 |
-
/* @var $collection Mage_Catalog_Model_Product */
|
230 |
-
$collection = Mage::getModel('catalog/product')
|
231 |
-
->getCollection()
|
232 |
-
->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
|
233 |
-
->addAttributeToSelect('*')
|
234 |
-
->addAttributeToFilter('category_id', array('in' => $categoryIds));
|
235 |
-
|
236 |
-
if (!$allProducts) {
|
237 |
-
$collection->addAttributeToFilter('skybox_category_id', array('null' => true));
|
238 |
-
}
|
239 |
-
|
240 |
-
$count = count($collection);
|
241 |
-
|
242 |
-
foreach ($collection as $product) {
|
243 |
-
try {
|
244 |
-
/** @var Mage_Catalog_Model_Product $product */
|
245 |
-
$product = $product;
|
246 |
-
|
247 |
-
if ($product->getTypeId() == 'configurable') {
|
248 |
-
/** @var Mage_Catalog_Model_Product $productChild */
|
249 |
-
// $childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product);
|
250 |
-
$childProducts = $product->getTypeInstance()->getUsedProductIds();
|
251 |
-
foreach ($childProducts as $key => $child) {
|
252 |
-
$productChild = Mage::getModel('catalog/product')->load($child);
|
253 |
-
$productChild->setData('skybox_category_id', $value);
|
254 |
-
$productChild->getResource()->save($productChild);
|
255 |
-
}
|
256 |
-
} else {
|
257 |
-
// Only setData if product->getTypeId() is 'simple'
|
258 |
-
$product->setData('skybox_category_id', $value);
|
259 |
-
$product->getResource()->save($product);
|
260 |
-
}
|
261 |
-
} catch (\Exception $ex) {
|
262 |
-
Mage::log("saveCategory() Exception: " . $ex->getMessage(), null, 'skyboxcheckout.log', true);
|
263 |
-
}
|
264 |
-
}
|
265 |
-
|
266 |
-
Mage::getSingleton('adminhtml/session')->addSuccess(
|
267 |
-
sprintf('%s products have been updated correctly.', $count)
|
268 |
-
);
|
269 |
-
}
|
270 |
-
|
271 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Checkout
|
5 |
+
*
|
6 |
+
* @category Mage
|
7 |
+
* @package Skybox_Catalog
|
8 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
*
|
13 |
+
* Catalog Model Observer
|
14 |
+
*
|
15 |
+
* Note: For Magento 1.8.x issues with Block Caching
|
16 |
+
*/
|
17 |
+
class Skybox_Catalog_Model_Observer
|
18 |
+
{
|
19 |
+
private function getActive()
|
20 |
+
{
|
21 |
+
// $value = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
|
22 |
+
$value = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
23 |
+
return $value;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function hookToControllerActionPreDispatch($observer)
|
27 |
+
{
|
28 |
+
$active = $this->getActive();
|
29 |
+
if (!$active) {
|
30 |
+
return;
|
31 |
+
}
|
32 |
+
|
33 |
+
//Mage::log('router tivoli: '.$observer->getEvent()->getControllerAction()->getFullActionName(), null, 'tracer.log', true);
|
34 |
+
if (($observer->getEvent()->getControllerAction()->getFullActionName() == 'checkout_cart_add')) {
|
35 |
+
|
36 |
+
//Mage::log('hookToControllerActionPreDispatch '.$observer->getEvent()->getControllerAction()->getFullActionName(),null, 'tracer.log', true);
|
37 |
+
Mage::dispatchEvent("add_to_cart_before", array('request' => $observer->getControllerAction()->getRequest()));
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
public function hookToControllerActionPostDispatch($observer)
|
42 |
+
{
|
43 |
+
$active = $this->getActive();
|
44 |
+
if (!$active) {
|
45 |
+
return;
|
46 |
+
}
|
47 |
+
|
48 |
+
//Mage::log('router tivoli: '.$observer->getEvent()->getControllerAction()->getFullActionName(), null, 'tracer.log', true);
|
49 |
+
if (($observer->getEvent()->getControllerAction()->getFullActionName() == 'checkout_cart_add')) {
|
50 |
+
|
51 |
+
//Mage::log('hookToControllerActionPostDispatch: '.$observer->getEvent()->getControllerAction()->getFullActionName(),null, 'tracer.log', true);
|
52 |
+
Mage::dispatchEvent("add_to_cart_after", array('request' => $observer->getControllerAction()->getRequest()));
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
public function hookToAddToCartBefore($observer)
|
57 |
+
{
|
58 |
+
$active = $this->getActive();
|
59 |
+
if (!$active) {
|
60 |
+
return;
|
61 |
+
}
|
62 |
+
|
63 |
+
//Mage::log('function hookToAddToCartBefore: ',null, 'tracer.log', true);
|
64 |
+
$key = Mage::getSingleton('core/session')->getFormKey();
|
65 |
+
$observer->getEvent()->getRequest()->setParam('form_key', $key);
|
66 |
+
$request = $observer->getEvent()->getRequest()->getParams();
|
67 |
+
}
|
68 |
+
|
69 |
+
public function hookToAddToCartAfter($observer)
|
70 |
+
{
|
71 |
+
$active = $this->getActive();
|
72 |
+
if (!$active) {
|
73 |
+
return;
|
74 |
+
}
|
75 |
+
|
76 |
+
$request = $observer->getEvent()->getRequest()->getParams();
|
77 |
+
Mage::log("hookToAddToCartAfter " . print_r($request, true) . " is added to cart.", null, 'cart.log', true);
|
78 |
+
}
|
79 |
+
|
80 |
+
public function injectTab(Varien_Event_Observer $observer)
|
81 |
+
{
|
82 |
+
// $active = $this->getActive();
|
83 |
+
// if (!$active) { return; }
|
84 |
+
|
85 |
+
// core_block_abstract_prepare_layout_after
|
86 |
+
|
87 |
+
/* $block Mage_Adminhtml_Block_Catalog_Category_Tabs */
|
88 |
+
$block = $observer->getEvent()->getBlock();
|
89 |
+
|
90 |
+
if ($block instanceof Mage_Adminhtml_Block_Catalog_Category_Tabs) {
|
91 |
+
|
92 |
+
if ($this->_getRequest()->getActionName() == 'edit' || $this->_getRequest()->getParam('type')) {
|
93 |
+
|
94 |
+
$tab_ids = $block->getTabsIds();
|
95 |
+
$tab_name = $tab_ids[3]; // SkyboxCheckout position
|
96 |
+
|
97 |
+
if ($tab_name) {
|
98 |
+
$block->removeTab($tab_name);
|
99 |
+
}
|
100 |
+
|
101 |
+
// SkyboxCheckout Tab
|
102 |
+
$block->addTab('custom_tab', array(
|
103 |
+
'label' => 'SkyboxCheckout',
|
104 |
+
'content' => $block->getLayout()
|
105 |
+
->createBlock('skyboxcatalog/catalog_category_tab_skyboxcheckout')
|
106 |
+
->toHtml()
|
107 |
+
));
|
108 |
+
}
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
public function saveCategory(Varien_Event_Observer $observer)
|
113 |
+
{
|
114 |
+
// catalog_category_prepare_save
|
115 |
+
|
116 |
+
// Note: Already know. this is a piece of crap
|
117 |
+
|
118 |
+
/* $category Mage_Catalog_Model_Category */
|
119 |
+
$category = $observer->getEvent()->getCategory();
|
120 |
+
|
121 |
+
$skybox_category_id = $this->_getRequest()->getPost('skybox_category_id');
|
122 |
+
$skybox_category_id_select = $this->_getRequest()->getPost('skybox_category_id_select');
|
123 |
+
$apply_button = $this->_getRequest()->getPost('apply_button');
|
124 |
+
|
125 |
+
if ($skybox_category_id != $category->getData('skybox_category_id')) {
|
126 |
+
//$category->setData('skybox_category_id', $skybox_category_id);
|
127 |
+
$category->setSkyboxCategoryId($skybox_category_id);
|
128 |
+
$msg = "[" . $category->getId() . "] saving skybox_category_id [" . $skybox_category_id . "]";
|
129 |
+
Mage::log($msg, null, 'skyboxcheckout.log', true);
|
130 |
+
}
|
131 |
+
|
132 |
+
if ($skybox_category_id_select != $category->getData('skybox_category_id_select')) {
|
133 |
+
//$category->setData('skybox_category_id_select', $skybox_category_id_select);
|
134 |
+
$category->setSkyboxCategoryIdSelect($skybox_category_id_select);
|
135 |
+
$msg = "[" . $category->getId() . "] saving skybox_category_id_select [" . $skybox_category_id_select . "]";
|
136 |
+
Mage::log($msg, null, 'skyboxcheckout.log', true);
|
137 |
+
}
|
138 |
+
|
139 |
+
if ($skybox_category_id || $skybox_category_id_select) {
|
140 |
+
Mage::log("Commodities saved!", null, 'skyboxcheckout.log', true);
|
141 |
+
try {
|
142 |
+
$category->getResource()->save($category);
|
143 |
+
} catch (Exception $ex) {
|
144 |
+
Mage::log("saveCategory() Exception: " . $ex->getMessage(), null, 'skyboxcheckout.log', true);
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
if (isset($apply_button) && $apply_button != 'nothing') {
|
149 |
+
|
150 |
+
$skybox_category_id_select = $this->_getRequest()->getPost('skybox_category_id_select');
|
151 |
+
$skybox_category_id_select = ($skybox_category_id_select) ?
|
152 |
+
$skybox_category_id_select :
|
153 |
+
$category->getData('skybox_category_id_select');
|
154 |
+
|
155 |
+
Mage::log("Apply Button: " . $apply_button, null, 'skyboxcheckout.log', true);
|
156 |
+
switch ($apply_button) {
|
157 |
+
case 'all_products':
|
158 |
+
$categoryIds = array($category->getId());
|
159 |
+
$this->_bulk_commodities($categoryIds, $skybox_category_id_select, true);
|
160 |
+
break;
|
161 |
+
|
162 |
+
case 'all_products_without_commoditites':
|
163 |
+
$categoryIds = array($category->getId());
|
164 |
+
$this->_bulk_commodities($categoryIds, $skybox_category_id_select, false);
|
165 |
+
break;
|
166 |
+
}
|
167 |
+
}
|
168 |
+
return $this;
|
169 |
+
}
|
170 |
+
|
171 |
+
public function setCommodityInForm(Varien_Event_Observer $observer)
|
172 |
+
{
|
173 |
+
// catalog_product_prepare_save
|
174 |
+
|
175 |
+
Mage::log('catalog_product_prepare_save', null, 'skyboxcheckout.log', true);
|
176 |
+
|
177 |
+
$product = $observer->getEvent()->getProduct();
|
178 |
+
$skybox_category_id = $this->_getRequest()->getPost('skybox_category_id');
|
179 |
+
$commodity = $product->getData('skybox_category_id');
|
180 |
+
|
181 |
+
// If the user change commodity manually
|
182 |
+
if ($skybox_category_id && ($skybox_category_id != $product->getData('skybox_category_id'))) {
|
183 |
+
$product->setData('skybox_category_id', $skybox_category_id);
|
184 |
+
$product->getResource()->save($product);
|
185 |
+
return $this;
|
186 |
+
}
|
187 |
+
|
188 |
+
// If commodity already set
|
189 |
+
if ($commodity) {
|
190 |
+
Mage::log('commodity_exist_true', null, 'skyboxcheckout.log', true);
|
191 |
+
return $this;
|
192 |
+
} else {
|
193 |
+
Mage::log('commodity_exist_false', null, 'skyboxcheckout.log', true);
|
194 |
+
$categoryIds = $product->getCategoryIds();
|
195 |
+
|
196 |
+
if (empty($categoryIds)) {
|
197 |
+
return $this;
|
198 |
+
}
|
199 |
+
|
200 |
+
$categoryId = reset($categoryIds); // current
|
201 |
+
|
202 |
+
/* $category Mage_Catalog_Model_Category */
|
203 |
+
$category = Mage::getModel('catalog/category')->load($categoryId);
|
204 |
+
|
205 |
+
$value = $category->getData('skybox_category_id');
|
206 |
+
|
207 |
+
if ($value) {
|
208 |
+
$product->setData('skybox_category_id', $value);
|
209 |
+
$product->getResource()->save($product);
|
210 |
+
} else {
|
211 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
212 |
+
sprintf("The category %s doesn't have any associated commodity.", $category->getData('title'))
|
213 |
+
);
|
214 |
+
}
|
215 |
+
}
|
216 |
+
return $this;
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Shortcut to getRequest
|
221 |
+
*/
|
222 |
+
protected function _getRequest()
|
223 |
+
{
|
224 |
+
return Mage::app()->getRequest();
|
225 |
+
}
|
226 |
+
|
227 |
+
private function _bulk_commodities($categoryIds, $value, $allProducts = true)
|
228 |
+
{
|
229 |
+
/* @var $collection Mage_Catalog_Model_Product */
|
230 |
+
$collection = Mage::getModel('catalog/product')
|
231 |
+
->getCollection()
|
232 |
+
->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
|
233 |
+
->addAttributeToSelect('*')
|
234 |
+
->addAttributeToFilter('category_id', array('in' => $categoryIds));
|
235 |
+
|
236 |
+
if (!$allProducts) {
|
237 |
+
$collection->addAttributeToFilter('skybox_category_id', array('null' => true));
|
238 |
+
}
|
239 |
+
|
240 |
+
$count = count($collection);
|
241 |
+
|
242 |
+
foreach ($collection as $product) {
|
243 |
+
try {
|
244 |
+
/** @var Mage_Catalog_Model_Product $product */
|
245 |
+
$product = $product;
|
246 |
+
|
247 |
+
if ($product->getTypeId() == 'configurable') {
|
248 |
+
/** @var Mage_Catalog_Model_Product $productChild */
|
249 |
+
// $childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product);
|
250 |
+
$childProducts = $product->getTypeInstance()->getUsedProductIds();
|
251 |
+
foreach ($childProducts as $key => $child) {
|
252 |
+
$productChild = Mage::getModel('catalog/product')->load($child);
|
253 |
+
$productChild->setData('skybox_category_id', $value);
|
254 |
+
$productChild->getResource()->save($productChild);
|
255 |
+
}
|
256 |
+
} else {
|
257 |
+
// Only setData if product->getTypeId() is 'simple'
|
258 |
+
$product->setData('skybox_category_id', $value);
|
259 |
+
$product->getResource()->save($product);
|
260 |
+
}
|
261 |
+
} catch (\Exception $ex) {
|
262 |
+
Mage::log("saveCategory() Exception: " . $ex->getMessage(), null, 'skyboxcheckout.log', true);
|
263 |
+
}
|
264 |
+
}
|
265 |
+
|
266 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
267 |
+
sprintf('%s products have been updated correctly.', $count)
|
268 |
+
);
|
269 |
+
}
|
270 |
+
|
271 |
}
|
app/code/community/Skybox/Catalog/Model/Product/Attribute/Source/Categories.php
CHANGED
@@ -1,39 +1,39 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Catalog
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Catalog
|
8 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Catalog_Model_Product_Attribute_Source_Categories extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
|
11 |
-
{
|
12 |
-
public $_options = null;
|
13 |
-
|
14 |
-
public function getAllOptions()
|
15 |
-
{
|
16 |
-
if ($this->_options === null) {
|
17 |
-
/* var @api_checkout Skybox_Checkout_Model_Api_Checkout */
|
18 |
-
$api_checkout = Mage::getModel('skyboxcheckout/api_checkout');
|
19 |
-
$categories = $api_checkout->GetCategories();
|
20 |
-
|
21 |
-
$item = array(
|
22 |
-
'value' => '',
|
23 |
-
'label' => '',
|
24 |
-
);
|
25 |
-
|
26 |
-
$data[] = $item;
|
27 |
-
|
28 |
-
foreach ($categories as $obj) {
|
29 |
-
$item = array(
|
30 |
-
'value' => $obj->IdCommoditie,
|
31 |
-
'label' => $obj->Description,
|
32 |
-
);
|
33 |
-
$data[] = $item;
|
34 |
-
}
|
35 |
-
$this->_options = $data;
|
36 |
-
}
|
37 |
-
return $this->_options;
|
38 |
-
}
|
39 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Catalog
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Catalog
|
8 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Catalog_Model_Product_Attribute_Source_Categories extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
|
11 |
+
{
|
12 |
+
public $_options = null;
|
13 |
+
|
14 |
+
public function getAllOptions()
|
15 |
+
{
|
16 |
+
if ($this->_options === null) {
|
17 |
+
/* var @api_checkout Skybox_Checkout_Model_Api_Checkout */
|
18 |
+
$api_checkout = Mage::getModel('skyboxcheckout/api_checkout');
|
19 |
+
$categories = $api_checkout->GetCategories();
|
20 |
+
|
21 |
+
$item = array(
|
22 |
+
'value' => '',
|
23 |
+
'label' => '',
|
24 |
+
);
|
25 |
+
|
26 |
+
$data[] = $item;
|
27 |
+
|
28 |
+
foreach ($categories as $obj) {
|
29 |
+
$item = array(
|
30 |
+
'value' => $obj->IdCommoditie,
|
31 |
+
'label' => $obj->Description,
|
32 |
+
);
|
33 |
+
$data[] = $item;
|
34 |
+
}
|
35 |
+
$this->_options = $data;
|
36 |
+
}
|
37 |
+
return $this->_options;
|
38 |
+
}
|
39 |
}
|
app/code/community/Skybox/Catalog/Model/Product/Type/Price.php
CHANGED
@@ -1,64 +1,64 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Skybox Checkout
|
4 |
-
*
|
5 |
-
* @category Skybox
|
6 |
-
* @package Skybox_Catalog
|
7 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
*
|
12 |
-
* Skybox overriding product type price
|
13 |
-
*
|
14 |
-
* @author César Tapia M. <ctapia@skyworldint.com>
|
15 |
-
*/
|
16 |
-
class Skybox_Catalog_Model_Product_Type_Price extends Mage_Catalog_Model_Product_Type_Price
|
17 |
-
{
|
18 |
-
protected $_typeApi = 'skyboxcatalog/api_product';
|
19 |
-
protected $_api = null;
|
20 |
-
|
21 |
-
protected function _getApi()
|
22 |
-
{
|
23 |
-
if(null === $this->_api)
|
24 |
-
{
|
25 |
-
$this->_api = Mage::getModel($this->_typeApi);
|
26 |
-
}
|
27 |
-
|
28 |
-
return $this->_api;
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Recupera el precio final del producto
|
33 |
-
*
|
34 |
-
* @param float|null $qty
|
35 |
-
* @param Mage_Catalog_Model_Product $product
|
36 |
-
* @return float
|
37 |
-
*/
|
38 |
-
public function getFinalPrice($qty = null, $product)
|
39 |
-
{
|
40 |
-
/*if(!$this->_getApi()->getErrorAuthenticate() && $this->_getApi()->getLocationAllow())
|
41 |
-
{
|
42 |
-
if(is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
|
43 |
-
return $product->getCalculatedFinalPrice();
|
44 |
-
}
|
45 |
-
|
46 |
-
$finalPrice= $this->getBasePrice($product, $qty);
|
47 |
-
$product->setFinalPrice($finalPrice);
|
48 |
-
|
49 |
-
Mage::dispatchEvent('catalog_product_get_final_price', array('product'=> $product, 'qty'=> $qty));
|
50 |
-
|
51 |
-
$finalPrice = $product->getData('final_price');
|
52 |
-
$finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
|
53 |
-
$finalPrice = max(0, $finalPrice);
|
54 |
-
//Call Calculate
|
55 |
-
$this->_getApi()->CalculatePrice($product->getId(), $finalPrice);
|
56 |
-
//Set final price for product
|
57 |
-
$finalPrice = $this->_getApi()->getResponse()->TotalProduct;
|
58 |
-
$product->setFinalPrice($finalPrice);
|
59 |
-
|
60 |
-
return $finalPrice;
|
61 |
-
}*/
|
62 |
-
return parent::getFinalPrice($qty, $product);
|
63 |
-
}
|
64 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Skybox Checkout
|
4 |
+
*
|
5 |
+
* @category Skybox
|
6 |
+
* @package Skybox_Catalog
|
7 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
*
|
12 |
+
* Skybox overriding product type price
|
13 |
+
*
|
14 |
+
* @author César Tapia M. <ctapia@skyworldint.com>
|
15 |
+
*/
|
16 |
+
class Skybox_Catalog_Model_Product_Type_Price extends Mage_Catalog_Model_Product_Type_Price
|
17 |
+
{
|
18 |
+
protected $_typeApi = 'skyboxcatalog/api_product';
|
19 |
+
protected $_api = null;
|
20 |
+
|
21 |
+
protected function _getApi()
|
22 |
+
{
|
23 |
+
if(null === $this->_api)
|
24 |
+
{
|
25 |
+
$this->_api = Mage::getModel($this->_typeApi);
|
26 |
+
}
|
27 |
+
|
28 |
+
return $this->_api;
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Recupera el precio final del producto
|
33 |
+
*
|
34 |
+
* @param float|null $qty
|
35 |
+
* @param Mage_Catalog_Model_Product $product
|
36 |
+
* @return float
|
37 |
+
*/
|
38 |
+
public function getFinalPrice($qty = null, $product)
|
39 |
+
{
|
40 |
+
/*if(!$this->_getApi()->getErrorAuthenticate() && $this->_getApi()->getLocationAllow())
|
41 |
+
{
|
42 |
+
if(is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
|
43 |
+
return $product->getCalculatedFinalPrice();
|
44 |
+
}
|
45 |
+
|
46 |
+
$finalPrice= $this->getBasePrice($product, $qty);
|
47 |
+
$product->setFinalPrice($finalPrice);
|
48 |
+
|
49 |
+
Mage::dispatchEvent('catalog_product_get_final_price', array('product'=> $product, 'qty'=> $qty));
|
50 |
+
|
51 |
+
$finalPrice = $product->getData('final_price');
|
52 |
+
$finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
|
53 |
+
$finalPrice = max(0, $finalPrice);
|
54 |
+
//Call Calculate
|
55 |
+
$this->_getApi()->CalculatePrice($product->getId(), $finalPrice);
|
56 |
+
//Set final price for product
|
57 |
+
$finalPrice = $this->_getApi()->getResponse()->TotalProduct;
|
58 |
+
$product->setFinalPrice($finalPrice);
|
59 |
+
|
60 |
+
return $finalPrice;
|
61 |
+
}*/
|
62 |
+
return parent::getFinalPrice($qty, $product);
|
63 |
+
}
|
64 |
+
}
|
app/code/community/Skybox/Catalog/Model/Resource/Setup.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Catalog
|
5 |
-
*
|
6 |
-
* @category Mage
|
7 |
-
* @package Skybox_Catalog
|
8 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Catalog_Model_Resource_Setup extends Mage_Sales_Model_Mysql4_Setup
|
11 |
-
{
|
12 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Catalog
|
5 |
+
*
|
6 |
+
* @category Mage
|
7 |
+
* @package Skybox_Catalog
|
8 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Catalog_Model_Resource_Setup extends Mage_Sales_Model_Mysql4_Setup
|
11 |
+
{
|
12 |
}
|
app/code/community/Skybox/Catalog/etc/config.xml
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
</default>
|
9 |
<modules>
|
10 |
<Skybox_Catalog>
|
11 |
-
<version>1.2.
|
12 |
<codePool>community</codePool>
|
13 |
</Skybox_Catalog>
|
14 |
</modules>
|
8 |
</default>
|
9 |
<modules>
|
10 |
<Skybox_Catalog>
|
11 |
+
<version>1.2.9</version>
|
12 |
<codePool>community</codePool>
|
13 |
</Skybox_Catalog>
|
14 |
</modules>
|
app/code/community/Skybox/Catalog/sql/skyboxcatalog_setup/mysql4-install-0.1.0.php
CHANGED
@@ -1,71 +1,71 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/* @var $installer Skybox_Catalog_Model_Resource_Setup */
|
4 |
-
$installer = $this;
|
5 |
-
$installer->startSetup();
|
6 |
-
|
7 |
-
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
|
8 |
-
|
9 |
-
// Product
|
10 |
-
$setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'skybox_category_id', array(
|
11 |
-
'group' => 'Prices',
|
12 |
-
'type' => Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
13 |
-
'backend' => 'eav/entity_attribute_backend_array',
|
14 |
-
'frontend' => '',
|
15 |
-
'label' => 'SkyboxCheckout Category',
|
16 |
-
'input' => 'select',
|
17 |
-
'class' => '',
|
18 |
-
'source' => 'skyboxcatalog/product_attribute_source_categories',
|
19 |
-
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
|
20 |
-
'visible' => true,
|
21 |
-
'required' => false,
|
22 |
-
'user_defined' => true,
|
23 |
-
'default' => '',
|
24 |
-
'searchable' => false,
|
25 |
-
'filterable' => true,
|
26 |
-
'comparable' => false,
|
27 |
-
'visible_on_front' => true,
|
28 |
-
'unique' => false,
|
29 |
-
'apply_to' => 'simple,configurable,virtual',
|
30 |
-
'is_configurable' => false
|
31 |
-
));
|
32 |
-
|
33 |
-
$setup->addAttributeToGroup(Mage_Catalog_Model_Product::ENTITY, 'Default', 'Prices', 'skybox_category_id', 100);
|
34 |
-
|
35 |
-
// Category
|
36 |
-
$setup->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'skybox_category_id', array(
|
37 |
-
//$setup->updateAttribute('catalog_category', 'skybox_category_id', array(
|
38 |
-
'group' => 'SkyboxCheckout',
|
39 |
-
'type' => Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
40 |
-
'backend' => 'eav/entity_attribute_backend_array',
|
41 |
-
'frontend' => '',
|
42 |
-
'label' => 'Default Commodity',
|
43 |
-
'input' => 'select',
|
44 |
-
'source' => 'skyboxcatalog/product_attribute_source_categories',
|
45 |
-
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
|
46 |
-
'visible' => true,
|
47 |
-
'required' => false,
|
48 |
-
'user_defined' => true,
|
49 |
-
'default' => ''
|
50 |
-
));
|
51 |
-
|
52 |
-
// Category
|
53 |
-
$setup->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'skybox_category_id_select', array(
|
54 |
-
//$setup->updateAttribute('catalog_category', 'skybox_category_id', array(
|
55 |
-
'group' => 'SkyboxCheckout',
|
56 |
-
'type' => Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
57 |
-
'backend' => 'eav/entity_attribute_backend_array',
|
58 |
-
'frontend' => '',
|
59 |
-
'label' => 'Select Commodity',
|
60 |
-
'input' => 'select',
|
61 |
-
'source' => 'skyboxcatalog/product_attribute_source_categories',
|
62 |
-
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
|
63 |
-
'visible' => true,
|
64 |
-
'required' => false,
|
65 |
-
'user_defined' => true,
|
66 |
-
'default' => ''
|
67 |
-
));
|
68 |
-
|
69 |
-
$setup->addAttributeToGroup(Mage_Catalog_Model_Category::ENTITY, 'Default', 'SkyboxCheckout', 'skybox_category_id', 100);
|
70 |
-
|
71 |
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* @var $installer Skybox_Catalog_Model_Resource_Setup */
|
4 |
+
$installer = $this;
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
|
8 |
+
|
9 |
+
// Product
|
10 |
+
$setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'skybox_category_id', array(
|
11 |
+
'group' => 'Prices',
|
12 |
+
'type' => Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
13 |
+
'backend' => 'eav/entity_attribute_backend_array',
|
14 |
+
'frontend' => '',
|
15 |
+
'label' => 'SkyboxCheckout Category',
|
16 |
+
'input' => 'select',
|
17 |
+
'class' => '',
|
18 |
+
'source' => 'skyboxcatalog/product_attribute_source_categories',
|
19 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
|
20 |
+
'visible' => true,
|
21 |
+
'required' => false,
|
22 |
+
'user_defined' => true,
|
23 |
+
'default' => '',
|
24 |
+
'searchable' => false,
|
25 |
+
'filterable' => true,
|
26 |
+
'comparable' => false,
|
27 |
+
'visible_on_front' => true,
|
28 |
+
'unique' => false,
|
29 |
+
'apply_to' => 'simple,configurable,virtual',
|
30 |
+
'is_configurable' => false
|
31 |
+
));
|
32 |
+
|
33 |
+
$setup->addAttributeToGroup(Mage_Catalog_Model_Product::ENTITY, 'Default', 'Prices', 'skybox_category_id', 100);
|
34 |
+
|
35 |
+
// Category
|
36 |
+
$setup->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'skybox_category_id', array(
|
37 |
+
//$setup->updateAttribute('catalog_category', 'skybox_category_id', array(
|
38 |
+
'group' => 'SkyboxCheckout',
|
39 |
+
'type' => Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
40 |
+
'backend' => 'eav/entity_attribute_backend_array',
|
41 |
+
'frontend' => '',
|
42 |
+
'label' => 'Default Commodity',
|
43 |
+
'input' => 'select',
|
44 |
+
'source' => 'skyboxcatalog/product_attribute_source_categories',
|
45 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
|
46 |
+
'visible' => true,
|
47 |
+
'required' => false,
|
48 |
+
'user_defined' => true,
|
49 |
+
'default' => ''
|
50 |
+
));
|
51 |
+
|
52 |
+
// Category
|
53 |
+
$setup->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'skybox_category_id_select', array(
|
54 |
+
//$setup->updateAttribute('catalog_category', 'skybox_category_id', array(
|
55 |
+
'group' => 'SkyboxCheckout',
|
56 |
+
'type' => Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
57 |
+
'backend' => 'eav/entity_attribute_backend_array',
|
58 |
+
'frontend' => '',
|
59 |
+
'label' => 'Select Commodity',
|
60 |
+
'input' => 'select',
|
61 |
+
'source' => 'skyboxcatalog/product_attribute_source_categories',
|
62 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
|
63 |
+
'visible' => true,
|
64 |
+
'required' => false,
|
65 |
+
'user_defined' => true,
|
66 |
+
'default' => ''
|
67 |
+
));
|
68 |
+
|
69 |
+
$setup->addAttributeToGroup(Mage_Catalog_Model_Category::ENTITY, 'Default', 'SkyboxCheckout', 'skybox_category_id', 100);
|
70 |
+
|
71 |
$installer->endSetup();
|
app/code/community/Skybox/Checkout/Block/Cart/Item/Renderer.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Checkout
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Checkout
|
8 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Checkout_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_Item_Renderer
|
11 |
-
{
|
12 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Checkout
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Checkout
|
8 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Checkout_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_Item_Renderer
|
11 |
+
{
|
12 |
}
|
app/code/community/Skybox/Checkout/Block/Cart/Sidebar.php
CHANGED
@@ -1,32 +1,32 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Checkout
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Checkout
|
8 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Checkout_Block_Cart_Sidebar extends Mage_Checkout_Block_Cart_Sidebar
|
11 |
-
{
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Get shopping cart subtotal.
|
15 |
-
*
|
16 |
-
* It will include tax, if required by config settings.
|
17 |
-
*
|
18 |
-
* @param bool $skipTax flag for getting price with tax or not. Ignored in case when we display just subtotal incl.tax
|
19 |
-
* @return decimal
|
20 |
-
*/
|
21 |
-
public function getSubtotal($skipTax = true)
|
22 |
-
{
|
23 |
-
$quote = $this->getQuote();
|
24 |
-
|
25 |
-
/* $address Mage_Sales_Model_Quote_Address */
|
26 |
-
$address = $quote->getShippingAddress();
|
27 |
-
|
28 |
-
//$subtotal = $address->getSubtotalSkybox();
|
29 |
-
$subtotal = $address->getSubtotal();
|
30 |
-
return $subtotal;
|
31 |
-
}
|
32 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Checkout
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Checkout
|
8 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Checkout_Block_Cart_Sidebar extends Mage_Checkout_Block_Cart_Sidebar
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Get shopping cart subtotal.
|
15 |
+
*
|
16 |
+
* It will include tax, if required by config settings.
|
17 |
+
*
|
18 |
+
* @param bool $skipTax flag for getting price with tax or not. Ignored in case when we display just subtotal incl.tax
|
19 |
+
* @return decimal
|
20 |
+
*/
|
21 |
+
public function getSubtotal($skipTax = true)
|
22 |
+
{
|
23 |
+
$quote = $this->getQuote();
|
24 |
+
|
25 |
+
/* $address Mage_Sales_Model_Quote_Address */
|
26 |
+
$address = $quote->getShippingAddress();
|
27 |
+
|
28 |
+
//$subtotal = $address->getSubtotalSkybox();
|
29 |
+
$subtotal = $address->getSubtotal();
|
30 |
+
return $subtotal;
|
31 |
+
}
|
32 |
+
}
|
app/code/community/Skybox/Checkout/Block/Cart/Totals.php
CHANGED
@@ -1,157 +1,157 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Checkout
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Checkout
|
8 |
-
* @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Checkout_Block_Cart_Totals extends Mage_Checkout_Block_Cart_Abstract
|
11 |
-
{
|
12 |
-
protected $_totalRenderers;
|
13 |
-
protected $_defaultRenderer = 'checkout/total_default';
|
14 |
-
protected $_totals = null;
|
15 |
-
|
16 |
-
public function getTotals()
|
17 |
-
{
|
18 |
-
if (is_null($this->_totals)) {
|
19 |
-
return parent::getTotals();
|
20 |
-
}
|
21 |
-
return $this->_totals;
|
22 |
-
}
|
23 |
-
|
24 |
-
public function setTotals($value)
|
25 |
-
{
|
26 |
-
$this->_totals = $value;
|
27 |
-
return $this;
|
28 |
-
}
|
29 |
-
|
30 |
-
protected function _getTotalRenderer($code)
|
31 |
-
{
|
32 |
-
$blockName = $code . '_total_renderer';
|
33 |
-
$block = $this->getLayout()->getBlock($blockName);
|
34 |
-
if (!$block) {
|
35 |
-
$block = $this->_defaultRenderer;
|
36 |
-
$config = Mage::getConfig()->getNode("global/sales/quote/totals/{$code}/renderer");
|
37 |
-
if ($config) {
|
38 |
-
$block = (string)$config;
|
39 |
-
}
|
40 |
-
|
41 |
-
$block = $this->getLayout()->createBlock($block, $blockName);
|
42 |
-
}
|
43 |
-
/**
|
44 |
-
* Transfer totals to renderer
|
45 |
-
*/
|
46 |
-
$block->setTotals($this->getTotals());
|
47 |
-
return $block;
|
48 |
-
}
|
49 |
-
|
50 |
-
public function renderTotal($total, $area = null, $colspan = 1)
|
51 |
-
{
|
52 |
-
$code = $total->getCode();
|
53 |
-
/**
|
54 |
-
* Integration 3 start, show price shop in cart*
|
55 |
-
*/
|
56 |
-
$allowRunByIntegration3 = true;
|
57 |
-
//$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
|
58 |
-
$typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
|
59 |
-
if ($typeIntegration == 3) {
|
60 |
-
$allowRunByIntegration3 = false;
|
61 |
-
}
|
62 |
-
|
63 |
-
$locationAllow = Mage::getModel('skyboxcheckout/api_checkout')->getLocationAllow();
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Integration 3 end, show price shop in cart*
|
67 |
-
*/
|
68 |
-
if ($allowRunByIntegration3 && $locationAllow) {
|
69 |
-
if ($code != "subtotal") {
|
70 |
-
if ($total->getAs()) {
|
71 |
-
$code = $total->getAs();
|
72 |
-
}
|
73 |
-
return $this->_getTotalRenderer($code)
|
74 |
-
->setTotal($total)
|
75 |
-
->setColspan($colspan)
|
76 |
-
->setRenderingArea(is_null($area) ? -1 : $area)
|
77 |
-
->toHtml();
|
78 |
-
}
|
79 |
-
} else {
|
80 |
-
if ($total->getAs()) {
|
81 |
-
$code = $total->getAs();
|
82 |
-
}
|
83 |
-
return $this->_getTotalRenderer($code)
|
84 |
-
->setTotal($total)
|
85 |
-
->setColspan($colspan)
|
86 |
-
->setRenderingArea(is_null($area) ? -1 : $area)
|
87 |
-
->toHtml();
|
88 |
-
|
89 |
-
}
|
90 |
-
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Render totals html for specific totals area (footer, body)
|
95 |
-
*
|
96 |
-
* @param null|string $area
|
97 |
-
* @param int $colspan
|
98 |
-
* @return string
|
99 |
-
*/
|
100 |
-
public function renderTotals($area = null, $colspan = 1)
|
101 |
-
{
|
102 |
-
$html = '';
|
103 |
-
foreach ($this->getTotals() as $total) {
|
104 |
-
if ($total->getArea() != $area && $area != -1) {
|
105 |
-
continue;
|
106 |
-
}
|
107 |
-
$html .= $this->renderTotal($total, $area, $colspan);
|
108 |
-
}
|
109 |
-
return $html;
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Check if we have display grand total in base currency
|
114 |
-
*
|
115 |
-
* @return bool
|
116 |
-
*/
|
117 |
-
public function needDisplayBaseGrandtotal()
|
118 |
-
{
|
119 |
-
$quote = $this->getQuote();
|
120 |
-
if ($quote->getBaseCurrencyCode() != $quote->getQuoteCurrencyCode()) {
|
121 |
-
return true;
|
122 |
-
}
|
123 |
-
return false;
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Get formated in base currency base grand total value
|
128 |
-
*
|
129 |
-
* @return string
|
130 |
-
*/
|
131 |
-
public function displayBaseGrandtotal()
|
132 |
-
{
|
133 |
-
$firstTotal = reset($this->_totals);
|
134 |
-
if ($firstTotal) {
|
135 |
-
$total = $firstTotal->getAddress()->getBaseGrandTotal();
|
136 |
-
return Mage::app()->getStore()->getBaseCurrency()->format($total, array(), true);
|
137 |
-
}
|
138 |
-
return '-';
|
139 |
-
}
|
140 |
-
|
141 |
-
/**
|
142 |
-
* Get active or custom quote
|
143 |
-
*
|
144 |
-
* @return Mage_Sales_Model_Quote
|
145 |
-
*/
|
146 |
-
public function getQuote()
|
147 |
-
{
|
148 |
-
if ($this->getCustomQuote()) {
|
149 |
-
return $this->getCustomQuote();
|
150 |
-
}
|
151 |
-
|
152 |
-
if (null === $this->_quote) {
|
153 |
-
$this->_quote = $this->getCheckout()->getQuote();
|
154 |
-
}
|
155 |
-
return $this->_quote;
|
156 |
-
}
|
157 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Checkout
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Checkout
|
8 |
+
* @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Checkout_Block_Cart_Totals extends Mage_Checkout_Block_Cart_Abstract
|
11 |
+
{
|
12 |
+
protected $_totalRenderers;
|
13 |
+
protected $_defaultRenderer = 'checkout/total_default';
|
14 |
+
protected $_totals = null;
|
15 |
+
|
16 |
+
public function getTotals()
|
17 |
+
{
|
18 |
+
if (is_null($this->_totals)) {
|
19 |
+
return parent::getTotals();
|
20 |
+
}
|
21 |
+
return $this->_totals;
|
22 |
+
}
|
23 |
+
|
24 |
+
public function setTotals($value)
|
25 |
+
{
|
26 |
+
$this->_totals = $value;
|
27 |
+
return $this;
|
28 |
+
}
|
29 |
+
|
30 |
+
protected function _getTotalRenderer($code)
|
31 |
+
{
|
32 |
+
$blockName = $code . '_total_renderer';
|
33 |
+
$block = $this->getLayout()->getBlock($blockName);
|
34 |
+
if (!$block) {
|
35 |
+
$block = $this->_defaultRenderer;
|
36 |
+
$config = Mage::getConfig()->getNode("global/sales/quote/totals/{$code}/renderer");
|
37 |
+
if ($config) {
|
38 |
+
$block = (string)$config;
|
39 |
+
}
|
40 |
+
|
41 |
+
$block = $this->getLayout()->createBlock($block, $blockName);
|
42 |
+
}
|
43 |
+
/**
|
44 |
+
* Transfer totals to renderer
|
45 |
+
*/
|
46 |
+
$block->setTotals($this->getTotals());
|
47 |
+
return $block;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function renderTotal($total, $area = null, $colspan = 1)
|
51 |
+
{
|
52 |
+
$code = $total->getCode();
|
53 |
+
/**
|
54 |
+
* Integration 3 start, show price shop in cart*
|
55 |
+
*/
|
56 |
+
$allowRunByIntegration3 = true;
|
57 |
+
//$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
|
58 |
+
$typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
|
59 |
+
if ($typeIntegration == 3) {
|
60 |
+
$allowRunByIntegration3 = false;
|
61 |
+
}
|
62 |
+
|
63 |
+
$locationAllow = Mage::getModel('skyboxcheckout/api_checkout')->getLocationAllow();
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Integration 3 end, show price shop in cart*
|
67 |
+
*/
|
68 |
+
if ($allowRunByIntegration3 && $locationAllow) {
|
69 |
+
if ($code != "subtotal") {
|
70 |
+
if ($total->getAs()) {
|
71 |
+
$code = $total->getAs();
|
72 |
+
}
|
73 |
+
return $this->_getTotalRenderer($code)
|
74 |
+
->setTotal($total)
|
75 |
+
->setColspan($colspan)
|
76 |
+
->setRenderingArea(is_null($area) ? -1 : $area)
|
77 |
+
->toHtml();
|
78 |
+
}
|
79 |
+
} else {
|
80 |
+
if ($total->getAs()) {
|
81 |
+
$code = $total->getAs();
|
82 |
+
}
|
83 |
+
return $this->_getTotalRenderer($code)
|
84 |
+
->setTotal($total)
|
85 |
+
->setColspan($colspan)
|
86 |
+
->setRenderingArea(is_null($area) ? -1 : $area)
|
87 |
+
->toHtml();
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Render totals html for specific totals area (footer, body)
|
95 |
+
*
|
96 |
+
* @param null|string $area
|
97 |
+
* @param int $colspan
|
98 |
+
* @return string
|
99 |
+
*/
|
100 |
+
public function renderTotals($area = null, $colspan = 1)
|
101 |
+
{
|
102 |
+
$html = '';
|
103 |
+
foreach ($this->getTotals() as $total) {
|
104 |
+
if ($total->getArea() != $area && $area != -1) {
|
105 |
+
continue;
|
106 |
+
}
|
107 |
+
$html .= $this->renderTotal($total, $area, $colspan);
|
108 |
+
}
|
109 |
+
return $html;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Check if we have display grand total in base currency
|
114 |
+
*
|
115 |
+
* @return bool
|
116 |
+
*/
|
117 |
+
public function needDisplayBaseGrandtotal()
|
118 |
+
{
|
119 |
+
$quote = $this->getQuote();
|
120 |
+
if ($quote->getBaseCurrencyCode() != $quote->getQuoteCurrencyCode()) {
|
121 |
+
return true;
|
122 |
+
}
|
123 |
+
return false;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Get formated in base currency base grand total value
|
128 |
+
*
|
129 |
+
* @return string
|
130 |
+
*/
|
131 |
+
public function displayBaseGrandtotal()
|
132 |
+
{
|
133 |
+
$firstTotal = reset($this->_totals);
|
134 |
+
if ($firstTotal) {
|
135 |
+
$total = $firstTotal->getAddress()->getBaseGrandTotal();
|
136 |
+
return Mage::app()->getStore()->getBaseCurrency()->format($total, array(), true);
|
137 |
+
}
|
138 |
+
return '-';
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Get active or custom quote
|
143 |
+
*
|
144 |
+
* @return Mage_Sales_Model_Quote
|
145 |
+
*/
|
146 |
+
public function getQuote()
|
147 |
+
{
|
148 |
+
if ($this->getCustomQuote()) {
|
149 |
+
return $this->getCustomQuote();
|
150 |
+
}
|
151 |
+
|
152 |
+
if (null === $this->_quote) {
|
153 |
+
$this->_quote = $this->getCheckout()->getQuote();
|
154 |
+
}
|
155 |
+
return $this->_quote;
|
156 |
+
}
|
157 |
+
}
|
app/code/community/Skybox/Checkout/Block/Checkout/Cart.php
CHANGED
@@ -1,45 +1,45 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_Checkout
|
23 |
-
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Shopping cart block
|
29 |
-
*
|
30 |
-
* @category Mage
|
31 |
-
* @package Mage_Checkout
|
32 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
-
*/
|
34 |
-
class Skybox_Checkout_Block_Checkout_Cart extends Mage_Checkout_Block_Cart
|
35 |
-
{
|
36 |
-
|
37 |
-
public function getCheckoutUrl()
|
38 |
-
{
|
39 |
-
if (!$this->helper('checkout')->isRewriteCheckoutLinksEnabled()){
|
40 |
-
return parent::getCheckoutUrl();
|
41 |
-
}
|
42 |
-
return $this->getUrl('skbcheckout/international', array('_secure'=>true));
|
43 |
-
}
|
44 |
-
|
45 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Mage_Checkout
|
23 |
+
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Shopping cart block
|
29 |
+
*
|
30 |
+
* @category Mage
|
31 |
+
* @package Mage_Checkout
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
class Skybox_Checkout_Block_Checkout_Cart extends Mage_Checkout_Block_Cart
|
35 |
+
{
|
36 |
+
|
37 |
+
public function getCheckoutUrl()
|
38 |
+
{
|
39 |
+
if (!$this->helper('checkout')->isRewriteCheckoutLinksEnabled()){
|
40 |
+
return parent::getCheckoutUrl();
|
41 |
+
}
|
42 |
+
return $this->getUrl('skbcheckout/international', array('_secure'=>true));
|
43 |
+
}
|
44 |
+
|
45 |
+
}
|
app/code/community/Skybox/Checkout/Block/Checkout/Cart/Sidebar.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
-
<?php
|
2 |
-
class Skybox_Checkout_Block_Checkout_Cart_Sidebar extends Mage_Checkout_Block_Cart_Sidebar
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Get one page checkout page url
|
6 |
-
*
|
7 |
-
* @return bool
|
8 |
-
*/
|
9 |
-
public function getCheckoutUrl()
|
10 |
-
{
|
11 |
-
if (!$this->helper('checkout')->isRewriteCheckoutLinksEnabled()){
|
12 |
-
return parent::getCheckoutUrl();
|
13 |
-
}
|
14 |
-
return $this->getUrl('skbcheckout/international', array('_secure'=>true));
|
15 |
-
}
|
16 |
-
}
|
1 |
+
<?php
|
2 |
+
class Skybox_Checkout_Block_Checkout_Cart_Sidebar extends Mage_Checkout_Block_Cart_Sidebar
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Get one page checkout page url
|
6 |
+
*
|
7 |
+
* @return bool
|
8 |
+
*/
|
9 |
+
public function getCheckoutUrl()
|
10 |
+
{
|
11 |
+
if (!$this->helper('checkout')->isRewriteCheckoutLinksEnabled()){
|
12 |
+
return parent::getCheckoutUrl();
|
13 |
+
}
|
14 |
+
return $this->getUrl('skbcheckout/international', array('_secure'=>true));
|
15 |
+
}
|
16 |
+
}
|
app/code/community/Skybox/Checkout/Block/Checkout/Links.php
CHANGED
@@ -1,26 +1,26 @@
|
|
1 |
-
<?php
|
2 |
-
class Skybox_Checkout_Block_Checkout_Links extends Mage_Checkout_Block_Links
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Add link on checkout page to parent block
|
6 |
-
*
|
7 |
-
* @return Mage_Checkout_Block_Links
|
8 |
-
*/
|
9 |
-
public function addCheckoutLink()
|
10 |
-
{
|
11 |
-
//Mage::log('get addCheckoutLink skybox', null, 'tracer.log', true);
|
12 |
-
|
13 |
-
if (!$this->helper('checkout')->isRewriteCheckoutLinksEnabled()){
|
14 |
-
return parent::addCheckoutLink();
|
15 |
-
}
|
16 |
-
|
17 |
-
if (!$this->helper('checkout')->canOnepageCheckout()) {
|
18 |
-
return $this;
|
19 |
-
}
|
20 |
-
if ($parentBlock = $this->getParentBlock()) {
|
21 |
-
$text = $this->__('Checkout');
|
22 |
-
$parentBlock->addLink($text, 'skbcheckout/international', $text, true, array('_secure'=>true), 60, null, 'class="top-link-skybox"');
|
23 |
-
}
|
24 |
-
return $this;
|
25 |
-
}
|
26 |
-
}
|
1 |
+
<?php
|
2 |
+
class Skybox_Checkout_Block_Checkout_Links extends Mage_Checkout_Block_Links
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Add link on checkout page to parent block
|
6 |
+
*
|
7 |
+
* @return Mage_Checkout_Block_Links
|
8 |
+
*/
|
9 |
+
public function addCheckoutLink()
|
10 |
+
{
|
11 |
+
//Mage::log('get addCheckoutLink skybox', null, 'tracer.log', true);
|
12 |
+
|
13 |
+
if (!$this->helper('checkout')->isRewriteCheckoutLinksEnabled()){
|
14 |
+
return parent::addCheckoutLink();
|
15 |
+
}
|
16 |
+
|
17 |
+
if (!$this->helper('checkout')->canOnepageCheckout()) {
|
18 |
+
return $this;
|
19 |
+
}
|
20 |
+
if ($parentBlock = $this->getParentBlock()) {
|
21 |
+
$text = $this->__('Checkout');
|
22 |
+
$parentBlock->addLink($text, 'skbcheckout/international', $text, true, array('_secure'=>true), 60, null, 'class="top-link-skybox"');
|
23 |
+
}
|
24 |
+
return $this;
|
25 |
+
}
|
26 |
+
}
|
app/code/community/Skybox/Checkout/Block/Checkout/Onepage/Link.php
CHANGED
@@ -1,43 +1,43 @@
|
|
1 |
-
<?php
|
2 |
-
class Skybox_Checkout_Block_Checkout_Onepage_Link extends Mage_Checkout_Block_Onepage_Link
|
3 |
-
{
|
4 |
-
public function getCheckoutUrl()
|
5 |
-
{
|
6 |
-
// TODO: Refactoring
|
7 |
-
|
8 |
-
// $isEnabled = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
|
9 |
-
$isEnabled = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Integration 3 start
|
13 |
-
* Give to button a url by default in case is type 3
|
14 |
-
*/
|
15 |
-
$api = Mage::getModel('skyboxcatalog/api_product');
|
16 |
-
//$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
|
17 |
-
$typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
|
18 |
-
if (($api->getLocationAllow()==3) && $typeIntegration==3) {
|
19 |
-
return parent::getCheckoutUrl();
|
20 |
-
}
|
21 |
-
/**
|
22 |
-
* Integration 3 end
|
23 |
-
*/
|
24 |
-
|
25 |
-
if($isEnabled) {
|
26 |
-
return $this->getUrl('skbcheckout/international', array('_secure'=>true));
|
27 |
-
}
|
28 |
-
/*
|
29 |
-
if (Mage::helper('onestepcheckout')->isRewriteCheckoutLinksEnabled()){
|
30 |
-
return $this->getUrl('onestepcheckout', array('_secure'=>true));
|
31 |
-
}
|
32 |
-
*/
|
33 |
-
/*
|
34 |
-
Mage::log('get getCheckoutUrl skybox', null, 'tracer.log', true);
|
35 |
-
if (!$this->helper('checkout')->isRewriteCheckoutLinksEnabled()){
|
36 |
-
return parent::getCheckoutUrl();
|
37 |
-
}
|
38 |
-
*/
|
39 |
-
|
40 |
-
return parent::getCheckoutUrl();
|
41 |
-
|
42 |
-
}
|
43 |
-
}
|
1 |
+
<?php
|
2 |
+
class Skybox_Checkout_Block_Checkout_Onepage_Link extends Mage_Checkout_Block_Onepage_Link
|
3 |
+
{
|
4 |
+
public function getCheckoutUrl()
|
5 |
+
{
|
6 |
+
// TODO: Refactoring
|
7 |
+
|
8 |
+
// $isEnabled = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
|
9 |
+
$isEnabled = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Integration 3 start
|
13 |
+
* Give to button a url by default in case is type 3
|
14 |
+
*/
|
15 |
+
$api = Mage::getModel('skyboxcatalog/api_product');
|
16 |
+
//$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
|
17 |
+
$typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
|
18 |
+
if (($api->getLocationAllow()==3) && $typeIntegration==3) {
|
19 |
+
return parent::getCheckoutUrl();
|
20 |
+
}
|
21 |
+
/**
|
22 |
+
* Integration 3 end
|
23 |
+
*/
|
24 |
+
|
25 |
+
if($isEnabled) {
|
26 |
+
return $this->getUrl('skbcheckout/international', array('_secure'=>true));
|
27 |
+
}
|
28 |
+
/*
|
29 |
+
if (Mage::helper('onestepcheckout')->isRewriteCheckoutLinksEnabled()){
|
30 |
+
return $this->getUrl('onestepcheckout', array('_secure'=>true));
|
31 |
+
}
|
32 |
+
*/
|
33 |
+
/*
|
34 |
+
Mage::log('get getCheckoutUrl skybox', null, 'tracer.log', true);
|
35 |
+
if (!$this->helper('checkout')->isRewriteCheckoutLinksEnabled()){
|
36 |
+
return parent::getCheckoutUrl();
|
37 |
+
}
|
38 |
+
*/
|
39 |
+
|
40 |
+
return parent::getCheckoutUrl();
|
41 |
+
|
42 |
+
}
|
43 |
+
}
|
app/code/community/Skybox/Checkout/Block/Sales/Order/Total.php
CHANGED
@@ -1,71 +1,71 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Checkout
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Checkout
|
8 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Checkout_Block_Sales_Order_Total extends Mage_Sales_Block_Order_Totals
|
11 |
-
{
|
12 |
-
public function initTotals()
|
13 |
-
{
|
14 |
-
parent::_initTotals();
|
15 |
-
|
16 |
-
if ($this->isEnable()) {
|
17 |
-
return $this;
|
18 |
-
}
|
19 |
-
|
20 |
-
$order = $this->getOrder();
|
21 |
-
|
22 |
-
//Mage::log('$order', null, 'tracer.log', true);
|
23 |
-
//Mage::log(print_r($order->debug(), true), null, 'tracer.log', true);
|
24 |
-
|
25 |
-
$ConceptsSkyboxjson = json_decode($order->getConceptsSkybox());
|
26 |
-
|
27 |
-
//Mage::log('$ConceptsSkyboxjson', null, 'tracer.log', true);
|
28 |
-
// Mage::log(print_r($ConceptsSkyboxjson, true), null, 'tracer.log', true);
|
29 |
-
if (count($ConceptsSkyboxjson) > 0) {
|
30 |
-
$i = 0;
|
31 |
-
foreach ($ConceptsSkyboxjson as $item) {
|
32 |
-
if ($item->Visible != 0) {
|
33 |
-
$i += 1;
|
34 |
-
$this->getParentBlock()->addTotal(new Varien_Object(array(
|
35 |
-
'code' => 'checkout_total' . $i,
|
36 |
-
'value' => $item->ValueUSD,//$item->Value
|
37 |
-
'base_value' => $item->ValueUSD,//$item->Value
|
38 |
-
'label' => $item->Concept,
|
39 |
-
)), 'subtotal', 'tax');
|
40 |
-
}
|
41 |
-
}
|
42 |
-
if ($order->getShippingAmount() == 0) {
|
43 |
-
$this->getParentBlock()->removeTotal('shipping');
|
44 |
-
}
|
45 |
-
}
|
46 |
-
|
47 |
-
return $this;
|
48 |
-
}
|
49 |
-
|
50 |
-
private function isEnable()
|
51 |
-
{
|
52 |
-
/** @var Skybox_Core_Model_Api_Restful $api_restful */
|
53 |
-
$api_restful = Mage::getModel('skyboxcore/api_restful');
|
54 |
-
$activation = $api_restful->isModuleEnable();
|
55 |
-
|
56 |
-
if (!$activation) {
|
57 |
-
return false;
|
58 |
-
}
|
59 |
-
|
60 |
-
/** @var Skybox_Core_Helper_Allow $allowHelper */
|
61 |
-
$allowHelper = Mage::helper('skyboxcore/allow');
|
62 |
-
|
63 |
-
$locationAllow = $allowHelper->getLocationAllow();
|
64 |
-
|
65 |
-
if (!$locationAllow) {
|
66 |
-
return false;
|
67 |
-
}
|
68 |
-
|
69 |
-
return true;
|
70 |
-
}
|
71 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Checkout
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Checkout
|
8 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Checkout_Block_Sales_Order_Total extends Mage_Sales_Block_Order_Totals
|
11 |
+
{
|
12 |
+
public function initTotals()
|
13 |
+
{
|
14 |
+
parent::_initTotals();
|
15 |
+
|
16 |
+
if ($this->isEnable()) {
|
17 |
+
return $this;
|
18 |
+
}
|
19 |
+
|
20 |
+
$order = $this->getOrder();
|
21 |
+
|
22 |
+
//Mage::log('$order', null, 'tracer.log', true);
|
23 |
+
//Mage::log(print_r($order->debug(), true), null, 'tracer.log', true);
|
24 |
+
|
25 |
+
$ConceptsSkyboxjson = json_decode($order->getConceptsSkybox());
|
26 |
+
|
27 |
+
//Mage::log('$ConceptsSkyboxjson', null, 'tracer.log', true);
|
28 |
+
// Mage::log(print_r($ConceptsSkyboxjson, true), null, 'tracer.log', true);
|
29 |
+
if (count($ConceptsSkyboxjson) > 0) {
|
30 |
+
$i = 0;
|
31 |
+
foreach ($ConceptsSkyboxjson as $item) {
|
32 |
+
if ($item->Visible != 0) {
|
33 |
+
$i += 1;
|
34 |
+
$this->getParentBlock()->addTotal(new Varien_Object(array(
|
35 |
+
'code' => 'checkout_total' . $i,
|
36 |
+
'value' => $item->ValueUSD,//$item->Value
|
37 |
+
'base_value' => $item->ValueUSD,//$item->Value
|
38 |
+
'label' => $item->Concept,
|
39 |
+
)), 'subtotal', 'tax');
|
40 |
+
}
|
41 |
+
}
|
42 |
+
if ($order->getShippingAmount() == 0) {
|
43 |
+
$this->getParentBlock()->removeTotal('shipping');
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
|
50 |
+
private function isEnable()
|
51 |
+
{
|
52 |
+
/** @var Skybox_Core_Model_Api_Restful $api_restful */
|
53 |
+
$api_restful = Mage::getModel('skyboxcore/api_restful');
|
54 |
+
$activation = $api_restful->isModuleEnable();
|
55 |
+
|
56 |
+
if (!$activation) {
|
57 |
+
return false;
|
58 |
+
}
|
59 |
+
|
60 |
+
/** @var Skybox_Core_Helper_Allow $allowHelper */
|
61 |
+
$allowHelper = Mage::helper('skyboxcore/allow');
|
62 |
+
|
63 |
+
$locationAllow = $allowHelper->getLocationAllow();
|
64 |
+
|
65 |
+
if (!$locationAllow) {
|
66 |
+
return false;
|
67 |
+
}
|
68 |
+
|
69 |
+
return true;
|
70 |
+
}
|
71 |
+
}
|
app/code/community/Skybox/Checkout/Helper/Data.php
CHANGED
@@ -1,156 +1,156 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Checkout
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Checkout
|
8 |
-
* @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Checkout_Helper_Data extends Mage_Checkout_Helper_Data
|
11 |
-
{
|
12 |
-
protected $_api = null;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Returns the helper for Location Allow
|
16 |
-
*
|
17 |
-
* @return Skybox_Core_Helper_Allow
|
18 |
-
*/
|
19 |
-
protected function _getAllowHelper()
|
20 |
-
{
|
21 |
-
return Mage::helper('skyboxcore/allow');
|
22 |
-
}
|
23 |
-
|
24 |
-
protected function _getApi()
|
25 |
-
{
|
26 |
-
if (null === $this->_api) {
|
27 |
-
$this->_api = Mage::getModel('skyboxcatalog/api_product');
|
28 |
-
}
|
29 |
-
return $this->_api;
|
30 |
-
}
|
31 |
-
|
32 |
-
public function formatPrice($price)
|
33 |
-
{
|
34 |
-
|
35 |
-
if (!$this->isRewriteCheckoutLinksEnabled()) {
|
36 |
-
return parent::formatPrice($price);
|
37 |
-
}
|
38 |
-
|
39 |
-
if (!$this->_getAllowHelper()->isPriceEnabled()) {
|
40 |
-
return parent::formatPrice($price);
|
41 |
-
}
|
42 |
-
|
43 |
-
/* @var $config Skybox_Core_Model_Config */
|
44 |
-
/*$config = Mage::getModel("skyboxcore/config");
|
45 |
-
$skybox_user = $config->getSession()->getSkyboxUser();
|
46 |
-
$currency = $skybox_user->CartCurrencySymbol;
|
47 |
-
//return '<span class="price">' . $currency . ' ' . number_format($price, 2) . '</span>';
|
48 |
-
return '<span class="price">' . $currency . ' ' . $price . '</span>';*/
|
49 |
-
/* @var $config Skybox_Core_Model_Config */
|
50 |
-
|
51 |
-
$config = Mage::getModel("skyboxcore/config");
|
52 |
-
$skybox_user = $config->getSession()->getSkyboxUser();
|
53 |
-
|
54 |
-
if ($this->_getApi()->getLocationAllow()) {
|
55 |
-
$currency = $skybox_user->CartCurrencySymbol;
|
56 |
-
} else {
|
57 |
-
$currency = Mage::app()->getLocale()->currency($currency_code)->getSymbol();
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Integration 3 Allow and not Allow start currency kind on cart
|
62 |
-
*
|
63 |
-
$request = Mage::app()->getRequest();
|
64 |
-
$module = $request->getModuleName();
|
65 |
-
$controller = $request->getControllerName();
|
66 |
-
$action = $request->getActionName();
|
67 |
-
//$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
|
68 |
-
$typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
|
69 |
-
|
70 |
-
if ($module == 'checkout' && $controller == 'cart' && $action == 'index') {
|
71 |
-
if ($typeIntegration == 3) {
|
72 |
-
$currency = Mage::app()->getLocale()->currency($currency_code)->getSymbol();
|
73 |
-
}
|
74 |
-
}
|
75 |
-
*/
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Integration 3 Allow and not Allow end currency kind on cart
|
79 |
-
*/
|
80 |
-
|
81 |
-
//Mage::log("currency".$currency, null, 'cartlabels.log', true);
|
82 |
-
$price = str_replace(',', '', $price);
|
83 |
-
//Mage::log("precio".$price, null, 'cartlabels.log', true);
|
84 |
-
$price = Mage::getModel('directory/currency')->setData("currency_code",
|
85 |
-
Mage::app()->getStore(null)->getCurrentCurrency()->getCode())->format(
|
86 |
-
$price, array('display' => Zend_Currency::NO_SYMBOL), false);
|
87 |
-
|
88 |
-
if ($price < 0) {
|
89 |
-
return '<span class="price">(' . $currency . " " . $price . ')</span>';
|
90 |
-
}
|
91 |
-
return '<span class="price">' . $currency . " " . $price . '</span>';
|
92 |
-
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* @deprecated
|
97 |
-
*/
|
98 |
-
public function getLayoutCheckoutSkybox()
|
99 |
-
{
|
100 |
-
$page_layout = Mage::getStoreConfig('customize_your_own');
|
101 |
-
|
102 |
-
if ($this->_getApi()->getLocationAllow()) {
|
103 |
-
$page_layout = 'skybox/checkout/onepage.phtml';
|
104 |
-
} else {
|
105 |
-
$page_layout = 'checkout/onepage.phtml';
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Integration 3 start
|
110 |
-
*
|
111 |
-
*/
|
112 |
-
//$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
|
113 |
-
$typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
|
114 |
-
if ($typeIntegration == 3 && $this->_getApi()->getLocationAllow() == 3) {
|
115 |
-
$page_layout = 'checkout/onepage.phtml';
|
116 |
-
}
|
117 |
-
/**
|
118 |
-
* Integration 3 end
|
119 |
-
*/
|
120 |
-
|
121 |
-
return $page_layout;
|
122 |
-
}
|
123 |
-
|
124 |
-
public function isRewriteCheckoutLinksEnabled()
|
125 |
-
{
|
126 |
-
// return (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
|
127 |
-
return Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
128 |
-
}
|
129 |
-
|
130 |
-
public function concatNameDetailProduct($product, $sku = null)
|
131 |
-
{
|
132 |
-
Mage::log('concatNameDetailProduct', null, 'tracer.log');
|
133 |
-
$attributesConcat = '';
|
134 |
-
if ($product->getData('type_id') == 'configurable') {
|
135 |
-
$options = $this->getAllAttributesVariantConfigurableProducts($product);
|
136 |
-
$attributesData = $options[$product->getId()][$sku];
|
137 |
-
$attributesConcat = implode(', ', $attributesData);
|
138 |
-
}
|
139 |
-
return $attributesConcat;
|
140 |
-
}
|
141 |
-
|
142 |
-
public function getAllAttributesVariantConfigurableProducts($configurableProduct)
|
143 |
-
{
|
144 |
-
$attributes = array();
|
145 |
-
$productAttributesOptions = $configurableProduct->getTypeInstance(true)->getConfigurableOptions($configurableProduct);
|
146 |
-
foreach ($productAttributesOptions as $productAttributeOption) {
|
147 |
-
$attributes[$configurableProduct->getId()] = array();
|
148 |
-
foreach ($productAttributeOption as $optionValues) {
|
149 |
-
$val = ($optionValues['option_title']);
|
150 |
-
$attributes[$configurableProduct->getId()][$optionValues['sku']][] = $optionValues['attribute_code'] . '-' . $val;
|
151 |
-
}
|
152 |
-
}
|
153 |
-
Mage::log(print_r($attributes, true), null, 'tracer.log');
|
154 |
-
return $attributes;
|
155 |
-
}
|
156 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Checkout
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Checkout
|
8 |
+
* @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Checkout_Helper_Data extends Mage_Checkout_Helper_Data
|
11 |
+
{
|
12 |
+
protected $_api = null;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Returns the helper for Location Allow
|
16 |
+
*
|
17 |
+
* @return Skybox_Core_Helper_Allow
|
18 |
+
*/
|
19 |
+
protected function _getAllowHelper()
|
20 |
+
{
|
21 |
+
return Mage::helper('skyboxcore/allow');
|
22 |
+
}
|
23 |
+
|
24 |
+
protected function _getApi()
|
25 |
+
{
|
26 |
+
if (null === $this->_api) {
|
27 |
+
$this->_api = Mage::getModel('skyboxcatalog/api_product');
|
28 |
+
}
|
29 |
+
return $this->_api;
|
30 |
+
}
|
31 |
+
|
32 |
+
public function formatPrice($price)
|
33 |
+
{
|
34 |
+
|
35 |
+
if (!$this->isRewriteCheckoutLinksEnabled()) {
|
36 |
+
return parent::formatPrice($price);
|
37 |
+
}
|
38 |
+
|
39 |
+
if (!$this->_getAllowHelper()->isPriceEnabled()) {
|
40 |
+
return parent::formatPrice($price);
|
41 |
+
}
|
42 |
+
|
43 |
+
/* @var $config Skybox_Core_Model_Config */
|
44 |
+
/*$config = Mage::getModel("skyboxcore/config");
|
45 |
+
$skybox_user = $config->getSession()->getSkyboxUser();
|
46 |
+
$currency = $skybox_user->CartCurrencySymbol;
|
47 |
+
//return '<span class="price">' . $currency . ' ' . number_format($price, 2) . '</span>';
|
48 |
+
return '<span class="price">' . $currency . ' ' . $price . '</span>';*/
|
49 |
+
/* @var $config Skybox_Core_Model_Config */
|
50 |
+
|
51 |
+
$config = Mage::getModel("skyboxcore/config");
|
52 |
+
$skybox_user = $config->getSession()->getSkyboxUser();
|
53 |
+
|
54 |
+
if ($this->_getApi()->getLocationAllow()) {
|
55 |
+
$currency = $skybox_user->CartCurrencySymbol;
|
56 |
+
} else {
|
57 |
+
$currency = Mage::app()->getLocale()->currency($currency_code)->getSymbol();
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Integration 3 Allow and not Allow start currency kind on cart
|
62 |
+
*
|
63 |
+
$request = Mage::app()->getRequest();
|
64 |
+
$module = $request->getModuleName();
|
65 |
+
$controller = $request->getControllerName();
|
66 |
+
$action = $request->getActionName();
|
67 |
+
//$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
|
68 |
+
$typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
|
69 |
+
|
70 |
+
if ($module == 'checkout' && $controller == 'cart' && $action == 'index') {
|
71 |
+
if ($typeIntegration == 3) {
|
72 |
+
$currency = Mage::app()->getLocale()->currency($currency_code)->getSymbol();
|
73 |
+
}
|
74 |
+
}
|
75 |
+
*/
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Integration 3 Allow and not Allow end currency kind on cart
|
79 |
+
*/
|
80 |
+
|
81 |
+
//Mage::log("currency".$currency, null, 'cartlabels.log', true);
|
82 |
+
$price = str_replace(',', '', $price);
|
83 |
+
//Mage::log("precio".$price, null, 'cartlabels.log', true);
|
84 |
+
$price = Mage::getModel('directory/currency')->setData("currency_code",
|
85 |
+
Mage::app()->getStore(null)->getCurrentCurrency()->getCode())->format(
|
86 |
+
$price, array('display' => Zend_Currency::NO_SYMBOL), false);
|
87 |
+
|
88 |
+
if ($price < 0) {
|
89 |
+
return '<span class="price">(' . $currency . " " . $price . ')</span>';
|
90 |
+
}
|
91 |
+
return '<span class="price">' . $currency . " " . $price . '</span>';
|
92 |
+
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* @deprecated
|
97 |
+
*/
|
98 |
+
public function getLayoutCheckoutSkybox()
|
99 |
+
{
|
100 |
+
$page_layout = Mage::getStoreConfig('customize_your_own');
|
101 |
+
|
102 |
+
if ($this->_getApi()->getLocationAllow()) {
|
103 |
+
$page_layout = 'skybox/checkout/onepage.phtml';
|
104 |
+
} else {
|
105 |
+
$page_layout = 'checkout/onepage.phtml';
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Integration 3 start
|
110 |
+
*
|
111 |
+
*/
|
112 |
+
//$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
|
113 |
+
$typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
|
114 |
+
if ($typeIntegration == 3 && $this->_getApi()->getLocationAllow() == 3) {
|
115 |
+
$page_layout = 'checkout/onepage.phtml';
|
116 |
+
}
|
117 |
+
/**
|
118 |
+
* Integration 3 end
|
119 |
+
*/
|
120 |
+
|
121 |
+
return $page_layout;
|
122 |
+
}
|
123 |
+
|
124 |
+
public function isRewriteCheckoutLinksEnabled()
|
125 |
+
{
|
126 |
+
// return (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
|
127 |
+
return Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
128 |
+
}
|
129 |
+
|
130 |
+
public function concatNameDetailProduct($product, $sku = null)
|
131 |
+
{
|
132 |
+
Mage::log('concatNameDetailProduct', null, 'tracer.log');
|
133 |
+
$attributesConcat = '';
|
134 |
+
if ($product->getData('type_id') == 'configurable') {
|
135 |
+
$options = $this->getAllAttributesVariantConfigurableProducts($product);
|
136 |
+
$attributesData = $options[$product->getId()][$sku];
|
137 |
+
$attributesConcat = implode(', ', $attributesData);
|
138 |
+
}
|
139 |
+
return $attributesConcat;
|
140 |
+
}
|
141 |
+
|
142 |
+
public function getAllAttributesVariantConfigurableProducts($configurableProduct)
|
143 |
+
{
|
144 |
+
$attributes = array();
|
145 |
+
$productAttributesOptions = $configurableProduct->getTypeInstance(true)->getConfigurableOptions($configurableProduct);
|
146 |
+
foreach ($productAttributesOptions as $productAttributeOption) {
|
147 |
+
$attributes[$configurableProduct->getId()] = array();
|
148 |
+
foreach ($productAttributeOption as $optionValues) {
|
149 |
+
$val = ($optionValues['option_title']);
|
150 |
+
$attributes[$configurableProduct->getId()][$optionValues['sku']][] = $optionValues['attribute_code'] . '-' . $val;
|
151 |
+
}
|
152 |
+
}
|
153 |
+
Mage::log(print_r($attributes, true), null, 'tracer.log');
|
154 |
+
return $attributes;
|
155 |
+
}
|
156 |
+
}
|
app/code/community/Skybox/Checkout/Helper/Url.php
CHANGED
@@ -1,59 +1,59 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_Checkout
|
23 |
-
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Checkout url helper
|
29 |
-
*
|
30 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
31 |
-
*/
|
32 |
-
class Skybox_Checkout_Helper_Url extends Mage_Checkout_Helper_Url
|
33 |
-
{
|
34 |
-
/**
|
35 |
-
* Retrieve checkout url
|
36 |
-
*
|
37 |
-
* @return string
|
38 |
-
*/
|
39 |
-
public function getCheckoutUrl()
|
40 |
-
{
|
41 |
-
|
42 |
-
// $isEnabled = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
|
43 |
-
$isEnabled = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
44 |
-
|
45 |
-
if ($isEnabled) {
|
46 |
-
return $this->_getUrl('skbcheckout/international', array('_secure'=>true));
|
47 |
-
}
|
48 |
-
|
49 |
-
/*if (Mage::helper('onestepcheckout')->isRewriteCheckoutLinksEnabled()){
|
50 |
-
return $this->_getUrl('onestepcheckout', array('_secure'=>true));
|
51 |
-
}*/
|
52 |
-
|
53 |
-
if (!Mage::helper('checkout')->isRewriteCheckoutLinksEnabled()){
|
54 |
-
return parent::getCheckoutUrl();
|
55 |
-
}
|
56 |
-
|
57 |
-
return parent::getCheckoutUrl();
|
58 |
-
}
|
59 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Mage_Checkout
|
23 |
+
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Checkout url helper
|
29 |
+
*
|
30 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
31 |
+
*/
|
32 |
+
class Skybox_Checkout_Helper_Url extends Mage_Checkout_Helper_Url
|
33 |
+
{
|
34 |
+
/**
|
35 |
+
* Retrieve checkout url
|
36 |
+
*
|
37 |
+
* @return string
|
38 |
+
*/
|
39 |
+
public function getCheckoutUrl()
|
40 |
+
{
|
41 |
+
|
42 |
+
// $isEnabled = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
|
43 |
+
$isEnabled = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
44 |
+
|
45 |
+
if ($isEnabled) {
|
46 |
+
return $this->_getUrl('skbcheckout/international', array('_secure'=>true));
|
47 |
+
}
|
48 |
+
|
49 |
+
/*if (Mage::helper('onestepcheckout')->isRewriteCheckoutLinksEnabled()){
|
50 |
+
return $this->_getUrl('onestepcheckout', array('_secure'=>true));
|
51 |
+
}*/
|
52 |
+
|
53 |
+
if (!Mage::helper('checkout')->isRewriteCheckoutLinksEnabled()){
|
54 |
+
return parent::getCheckoutUrl();
|
55 |
+
}
|
56 |
+
|
57 |
+
return parent::getCheckoutUrl();
|
58 |
+
}
|
59 |
}
|
app/code/community/Skybox/Checkout/Model/Api/Checkout.php
CHANGED
@@ -1,223 +1,223 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Checkout
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Checkout
|
8 |
-
* @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Checkout_Model_Api_Checkout extends Skybox_Core_Model_Standard
|
11 |
-
{
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Model instance
|
15 |
-
* @var Mage_Core_Catalog_Model_Product
|
16 |
-
*/
|
17 |
-
protected $_product = null;
|
18 |
-
|
19 |
-
protected $_currentProduct = null;
|
20 |
-
|
21 |
-
protected $_typeProduct = "catalog/product";
|
22 |
-
|
23 |
-
public function getProduct()
|
24 |
-
{
|
25 |
-
if (null === $this->_product)
|
26 |
-
$this->_product = Mage::getModel($this->_typeProduct);
|
27 |
-
|
28 |
-
return $this->_product;
|
29 |
-
}
|
30 |
-
|
31 |
-
public function InitializeBarSkybox()
|
32 |
-
{
|
33 |
-
//if(!$this->getErrorAuthenticate())
|
34 |
-
//{
|
35 |
-
//$this->_config = Mage::getModel('skyboxcore/config');
|
36 |
-
Mage::log("InitializeBarSkybox ", null, 'checkout.log', true);
|
37 |
-
|
38 |
-
$params = array(
|
39 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
40 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
|
41 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
|
42 |
-
'customeriplocal' => $this->_getConfig()->getHost(),
|
43 |
-
'customeripremote' => $this->_getConfig()->getRemoteAddr(),
|
44 |
-
'customeripproxy' => $this->_getConfig()->getProxy(),
|
45 |
-
'customerbrowser' => $this->_getConfig()->getUserAgent(),
|
46 |
-
'customerlanguages' => $this->_getConfig()->getLanguage()
|
47 |
-
);
|
48 |
-
|
49 |
-
//$response = $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_INITIALICE, $params)->getResponse();
|
50 |
-
/**
|
51 |
-
* only one time for call to service start
|
52 |
-
*/
|
53 |
-
$session = Mage::getSingleton("core/session", array("name"=>"frontend"));
|
54 |
-
$callToSkyBox = $session->getData("callToSkyBox");
|
55 |
-
|
56 |
-
//Mage::log($callToSkyBox, null, 'local.log', true);
|
57 |
-
$initialize = $this->_getConfig()->getSession()->getCartSkybox();
|
58 |
-
if (!empty($initialize) && (!$callToSkyBox)) {
|
59 |
-
$response = $initialize;
|
60 |
-
} else {
|
61 |
-
$response = $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_INITIALICE, $params)->getResponse();
|
62 |
-
$session->setData("callToSkyBox", false);
|
63 |
-
}
|
64 |
-
$response = $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_INITIALICE, $params)->getResponse();
|
65 |
-
$session->setData("callToSkyBox", false);
|
66 |
-
/**
|
67 |
-
* only one time for call to service end
|
68 |
-
*/
|
69 |
-
// Set SkyboxUser session
|
70 |
-
$this->_getConfig()->getSession()->setSkyboxUser($response);
|
71 |
-
|
72 |
-
//if ($this->getLocationAllow()) { // Rogged, la primera vez q usuario ingresa con un pais disabled, lanza error porq no se envia datos a url de popup
|
73 |
-
$this->_getConfig()->getSession()->setCartSkybox($response);
|
74 |
-
//}
|
75 |
-
//}
|
76 |
-
}
|
77 |
-
|
78 |
-
public function setCurrentProduct($product)
|
79 |
-
{
|
80 |
-
$this->_currentProduct = $product;
|
81 |
-
}
|
82 |
-
public function getCurrentProduct()
|
83 |
-
{
|
84 |
-
return $this->_currentProduct;
|
85 |
-
}
|
86 |
-
|
87 |
-
public function AddProductOfCart($data, $quantity)
|
88 |
-
{
|
89 |
-
$detailProduct = Mage::helper('checkout')->concatNameDetailProduct($this->getCurrentProduct(), $data['sku']);
|
90 |
-
|
91 |
-
//Mage::log("entro AddProductOfCart", null, 'tracer.log', true);
|
92 |
-
if ($this->getErrorAuthenticate() && !$this->getLocationAllow()) {
|
93 |
-
return $this;
|
94 |
-
}
|
95 |
-
|
96 |
-
Mage::log("AddProductOfCart: " . print_r($data, true), null, 'skyboxcheckout.log', true);
|
97 |
-
|
98 |
-
$storeProductName = $data['name'].' '.$detailProduct;
|
99 |
-
|
100 |
-
$params = array(
|
101 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
102 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
|
103 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
|
104 |
-
'productid' => "0",
|
105 |
-
'quantity' => $quantity,
|
106 |
-
'storeproductcode' => $data['sku'],
|
107 |
-
'storeproductname' => $storeProductName,
|
108 |
-
'storeproductcategory' => $data['category_id'],
|
109 |
-
'storeproductprice' => $data['final_price'],
|
110 |
-
'weight' => ($data['weight'])?($data['weight']):1,
|
111 |
-
'weightunit' => $this->getWeightUnit(),
|
112 |
-
'storeproductimgurl' => $data['image_url'],
|
113 |
-
'VolWeight' => $data['VolWeight'],
|
114 |
-
'merchantproductid' => $data['merchantproductid']
|
115 |
-
);
|
116 |
-
$this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_ADD_PRODUCT_CART, $params);
|
117 |
-
|
118 |
-
return $this;
|
119 |
-
}
|
120 |
-
|
121 |
-
public function GetTotalShoppingCart()
|
122 |
-
{
|
123 |
-
if ($this->getErrorAuthenticate() && !$this->getLocationAllow()) {
|
124 |
-
return $this;
|
125 |
-
}
|
126 |
-
|
127 |
-
$params = array(
|
128 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
129 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
|
130 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi()
|
131 |
-
);
|
132 |
-
|
133 |
-
$this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_GET_TOTAL_SHOPINGCART, $params);
|
134 |
-
|
135 |
-
return $this;
|
136 |
-
}
|
137 |
-
|
138 |
-
public function UpdateProductOfCart($productId, $quantity)
|
139 |
-
{
|
140 |
-
if (!$this->getErrorAuthenticate() && $this->getLocationAllow()) {
|
141 |
-
$this->getProduct()->load($productId);
|
142 |
-
$params = array(
|
143 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
144 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
|
145 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
|
146 |
-
'productid' => $productId,
|
147 |
-
'quantity' => $quantity
|
148 |
-
);
|
149 |
-
|
150 |
-
$this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_UPDATE_PRODUCT_CART, $params);
|
151 |
-
}
|
152 |
-
|
153 |
-
return $this;
|
154 |
-
}
|
155 |
-
|
156 |
-
public function DeleteProductOfCart($productId)
|
157 |
-
{
|
158 |
-
|
159 |
-
#if (!$this->getErrorAuthenticate() && $this->getLocationAllow()) { // Rogged
|
160 |
-
if (!$this->getErrorAuthenticate()) { // Rogged
|
161 |
-
$params = array(
|
162 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
163 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
|
164 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
|
165 |
-
'productid' => $productId
|
166 |
-
);
|
167 |
-
|
168 |
-
$this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_DELETE_PRODUCT_CART, $params);
|
169 |
-
}
|
170 |
-
|
171 |
-
return $this;
|
172 |
-
}
|
173 |
-
|
174 |
-
public function getCartSkybox()
|
175 |
-
{
|
176 |
-
if (!$this->getErrorAuthenticate() && $this->getLocationAllow()) {
|
177 |
-
//$this->_config = Mage::getModel('skyboxcore/config');
|
178 |
-
return $this->_getConfig()->getSession()->getCartSkybox();
|
179 |
-
}
|
180 |
-
return "";
|
181 |
-
}
|
182 |
-
|
183 |
-
/*
|
184 |
-
* Get Categories
|
185 |
-
*
|
186 |
-
* @return $data json
|
187 |
-
*/
|
188 |
-
|
189 |
-
public function GetCategories()
|
190 |
-
{
|
191 |
-
$params = array(
|
192 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
193 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken()
|
194 |
-
);
|
195 |
-
|
196 |
-
/* var $response Skybox_Core_Model_Standard */
|
197 |
-
$response = $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_CATEGORIES, $params);
|
198 |
-
$jsonData = $response->getResponse()->{'Categories'};
|
199 |
-
return $jsonData;
|
200 |
-
}
|
201 |
-
|
202 |
-
public function getValueAccessService()
|
203 |
-
{
|
204 |
-
$params = array(
|
205 |
-
"merchantCode" => $this->getMerchant(),
|
206 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
|
207 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
|
208 |
-
|
209 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
210 |
-
'customeriplocal' => $this->_getConfig()->getHost(),
|
211 |
-
'customeripremote' => $this->_getConfig()->getRemoteAddr(),
|
212 |
-
'customeripproxy' => $this->_getConfig()->getProxy(),
|
213 |
-
'customerbrowser' => $this->_getConfig()->getUserAgent(),
|
214 |
-
'customerlanguages' => $this->_getConfig()->getLanguage()
|
215 |
-
|
216 |
-
|
217 |
-
);
|
218 |
-
|
219 |
-
|
220 |
-
return $params;
|
221 |
-
|
222 |
-
}
|
223 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Checkout
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Checkout
|
8 |
+
* @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Checkout_Model_Api_Checkout extends Skybox_Core_Model_Standard
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Model instance
|
15 |
+
* @var Mage_Core_Catalog_Model_Product
|
16 |
+
*/
|
17 |
+
protected $_product = null;
|
18 |
+
|
19 |
+
protected $_currentProduct = null;
|
20 |
+
|
21 |
+
protected $_typeProduct = "catalog/product";
|
22 |
+
|
23 |
+
public function getProduct()
|
24 |
+
{
|
25 |
+
if (null === $this->_product)
|
26 |
+
$this->_product = Mage::getModel($this->_typeProduct);
|
27 |
+
|
28 |
+
return $this->_product;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function InitializeBarSkybox()
|
32 |
+
{
|
33 |
+
//if(!$this->getErrorAuthenticate())
|
34 |
+
//{
|
35 |
+
//$this->_config = Mage::getModel('skyboxcore/config');
|
36 |
+
Mage::log("InitializeBarSkybox ", null, 'checkout.log', true);
|
37 |
+
|
38 |
+
$params = array(
|
39 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
40 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
|
41 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
|
42 |
+
'customeriplocal' => $this->_getConfig()->getHost(),
|
43 |
+
'customeripremote' => $this->_getConfig()->getRemoteAddr(),
|
44 |
+
'customeripproxy' => $this->_getConfig()->getProxy(),
|
45 |
+
'customerbrowser' => $this->_getConfig()->getUserAgent(),
|
46 |
+
'customerlanguages' => $this->_getConfig()->getLanguage()
|
47 |
+
);
|
48 |
+
|
49 |
+
//$response = $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_INITIALICE, $params)->getResponse();
|
50 |
+
/**
|
51 |
+
* only one time for call to service start
|
52 |
+
*/
|
53 |
+
$session = Mage::getSingleton("core/session", array("name"=>"frontend"));
|
54 |
+
$callToSkyBox = $session->getData("callToSkyBox");
|
55 |
+
|
56 |
+
//Mage::log($callToSkyBox, null, 'local.log', true);
|
57 |
+
$initialize = $this->_getConfig()->getSession()->getCartSkybox();
|
58 |
+
if (!empty($initialize) && (!$callToSkyBox)) {
|
59 |
+
$response = $initialize;
|
60 |
+
} else {
|
61 |
+
$response = $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_INITIALICE, $params)->getResponse();
|
62 |
+
$session->setData("callToSkyBox", false);
|
63 |
+
}
|
64 |
+
// $response = $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_INITIALICE, $params)->getResponse();
|
65 |
+
// $session->setData("callToSkyBox", false);
|
66 |
+
/**
|
67 |
+
* only one time for call to service end
|
68 |
+
*/
|
69 |
+
// Set SkyboxUser session
|
70 |
+
$this->_getConfig()->getSession()->setSkyboxUser($response);
|
71 |
+
|
72 |
+
//if ($this->getLocationAllow()) { // Rogged, la primera vez q usuario ingresa con un pais disabled, lanza error porq no se envia datos a url de popup
|
73 |
+
$this->_getConfig()->getSession()->setCartSkybox($response);
|
74 |
+
//}
|
75 |
+
//}
|
76 |
+
}
|
77 |
+
|
78 |
+
public function setCurrentProduct($product)
|
79 |
+
{
|
80 |
+
$this->_currentProduct = $product;
|
81 |
+
}
|
82 |
+
public function getCurrentProduct()
|
83 |
+
{
|
84 |
+
return $this->_currentProduct;
|
85 |
+
}
|
86 |
+
|
87 |
+
public function AddProductOfCart($data, $quantity)
|
88 |
+
{
|
89 |
+
$detailProduct = Mage::helper('checkout')->concatNameDetailProduct($this->getCurrentProduct(), $data['sku']);
|
90 |
+
|
91 |
+
//Mage::log("entro AddProductOfCart", null, 'tracer.log', true);
|
92 |
+
if ($this->getErrorAuthenticate() && !$this->getLocationAllow()) {
|
93 |
+
return $this;
|
94 |
+
}
|
95 |
+
|
96 |
+
Mage::log("AddProductOfCart: " . print_r($data, true), null, 'skyboxcheckout.log', true);
|
97 |
+
|
98 |
+
$storeProductName = $data['name'].' '.$detailProduct;
|
99 |
+
|
100 |
+
$params = array(
|
101 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
102 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
|
103 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
|
104 |
+
'productid' => "0",
|
105 |
+
'quantity' => $quantity,
|
106 |
+
'storeproductcode' => $data['sku'],
|
107 |
+
'storeproductname' => $storeProductName,
|
108 |
+
'storeproductcategory' => $data['category_id'],
|
109 |
+
'storeproductprice' => $data['final_price'],
|
110 |
+
'weight' => ($data['weight'])?($data['weight']):1,
|
111 |
+
'weightunit' => $this->getWeightUnit(),
|
112 |
+
'storeproductimgurl' => $data['image_url'],
|
113 |
+
'VolWeight' => $data['VolWeight'],
|
114 |
+
'merchantproductid' => $data['merchantproductid']
|
115 |
+
);
|
116 |
+
$this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_ADD_PRODUCT_CART, $params);
|
117 |
+
|
118 |
+
return $this;
|
119 |
+
}
|
120 |
+
|
121 |
+
public function GetTotalShoppingCart()
|
122 |
+
{
|
123 |
+
if ($this->getErrorAuthenticate() && !$this->getLocationAllow()) {
|
124 |
+
return $this;
|
125 |
+
}
|
126 |
+
|
127 |
+
$params = array(
|
128 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
129 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
|
130 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi()
|
131 |
+
);
|
132 |
+
|
133 |
+
$this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_GET_TOTAL_SHOPINGCART, $params);
|
134 |
+
|
135 |
+
return $this;
|
136 |
+
}
|
137 |
+
|
138 |
+
public function UpdateProductOfCart($productId, $quantity)
|
139 |
+
{
|
140 |
+
if (!$this->getErrorAuthenticate() && $this->getLocationAllow()) {
|
141 |
+
$this->getProduct()->load($productId);
|
142 |
+
$params = array(
|
143 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
144 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
|
145 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
|
146 |
+
'productid' => $productId,
|
147 |
+
'quantity' => $quantity
|
148 |
+
);
|
149 |
+
|
150 |
+
$this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_UPDATE_PRODUCT_CART, $params);
|
151 |
+
}
|
152 |
+
|
153 |
+
return $this;
|
154 |
+
}
|
155 |
+
|
156 |
+
public function DeleteProductOfCart($productId)
|
157 |
+
{
|
158 |
+
|
159 |
+
#if (!$this->getErrorAuthenticate() && $this->getLocationAllow()) { // Rogged
|
160 |
+
if (!$this->getErrorAuthenticate()) { // Rogged
|
161 |
+
$params = array(
|
162 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
163 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
|
164 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
|
165 |
+
'productid' => $productId
|
166 |
+
);
|
167 |
+
|
168 |
+
$this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_DELETE_PRODUCT_CART, $params);
|
169 |
+
}
|
170 |
+
|
171 |
+
return $this;
|
172 |
+
}
|
173 |
+
|
174 |
+
public function getCartSkybox()
|
175 |
+
{
|
176 |
+
if (!$this->getErrorAuthenticate() && $this->getLocationAllow()) {
|
177 |
+
//$this->_config = Mage::getModel('skyboxcore/config');
|
178 |
+
return $this->_getConfig()->getSession()->getCartSkybox();
|
179 |
+
}
|
180 |
+
return "";
|
181 |
+
}
|
182 |
+
|
183 |
+
/*
|
184 |
+
* Get Categories
|
185 |
+
*
|
186 |
+
* @return $data json
|
187 |
+
*/
|
188 |
+
|
189 |
+
public function GetCategories()
|
190 |
+
{
|
191 |
+
$params = array(
|
192 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
193 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken()
|
194 |
+
);
|
195 |
+
|
196 |
+
/* var $response Skybox_Core_Model_Standard */
|
197 |
+
$response = $this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_CATEGORIES, $params);
|
198 |
+
$jsonData = $response->getResponse()->{'Categories'};
|
199 |
+
return $jsonData;
|
200 |
+
}
|
201 |
+
|
202 |
+
public function getValueAccessService()
|
203 |
+
{
|
204 |
+
$params = array(
|
205 |
+
"merchantCode" => $this->getMerchant(),
|
206 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
|
207 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
|
208 |
+
|
209 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
210 |
+
'customeriplocal' => $this->_getConfig()->getHost(),
|
211 |
+
'customeripremote' => $this->_getConfig()->getRemoteAddr(),
|
212 |
+
'customeripproxy' => $this->_getConfig()->getProxy(),
|
213 |
+
'customerbrowser' => $this->_getConfig()->getUserAgent(),
|
214 |
+
'customerlanguages' => $this->_getConfig()->getLanguage()
|
215 |
+
|
216 |
+
|
217 |
+
);
|
218 |
+
|
219 |
+
|
220 |
+
return $params;
|
221 |
+
|
222 |
+
}
|
223 |
}
|
app/code/community/Skybox/Checkout/Model/Carrier.php
CHANGED
@@ -1,37 +1,37 @@
|
|
1 |
-
<?php
|
2 |
-
class Skybox_Checkout_Model_Carrier extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface
|
3 |
-
{
|
4 |
-
protected $_code = 'skyboxcheckout_shipping';
|
5 |
-
|
6 |
-
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
7 |
-
{
|
8 |
-
if (!$this->getConfigData('active') /*|| !Mage::helper('skyboxinternational')->getActive()*/) {
|
9 |
-
return false;
|
10 |
-
}
|
11 |
-
$result = Mage::getModel('shipping/rate_result');
|
12 |
-
$result->append($this->_getDefaultRate());
|
13 |
-
|
14 |
-
return $result;
|
15 |
-
}
|
16 |
-
|
17 |
-
public function getAllowedMethods()
|
18 |
-
{
|
19 |
-
return array(
|
20 |
-
'skyboxcheckout' => 'skybox delivery'//$this->getConfigData('name'),
|
21 |
-
);
|
22 |
-
}
|
23 |
-
|
24 |
-
protected function _getDefaultRate()
|
25 |
-
{
|
26 |
-
$rate = Mage::getModel('shipping/rate_result_method');
|
27 |
-
|
28 |
-
$rate->setCarrier($this->_code);
|
29 |
-
$rate->setCarrierTitle($this->getConfigData('title'));
|
30 |
-
$rate->setMethod('skyboxcheckout');//$this->_code
|
31 |
-
$rate->setMethodTitle($this->getConfigData('title'));
|
32 |
-
$rate->setPrice($this->getConfigData('price'));
|
33 |
-
$rate->setCost(0);
|
34 |
-
|
35 |
-
return $rate;
|
36 |
-
}
|
37 |
}
|
1 |
+
<?php
|
2 |
+
class Skybox_Checkout_Model_Carrier extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface
|
3 |
+
{
|
4 |
+
protected $_code = 'skyboxcheckout_shipping';
|
5 |
+
|
6 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
7 |
+
{
|
8 |
+
if (!$this->getConfigData('active') /*|| !Mage::helper('skyboxinternational')->getActive()*/) {
|
9 |
+
return false;
|
10 |
+
}
|
11 |
+
$result = Mage::getModel('shipping/rate_result');
|
12 |
+
$result->append($this->_getDefaultRate());
|
13 |
+
|
14 |
+
return $result;
|
15 |
+
}
|
16 |
+
|
17 |
+
public function getAllowedMethods()
|
18 |
+
{
|
19 |
+
return array(
|
20 |
+
'skyboxcheckout' => 'skybox delivery'//$this->getConfigData('name'),
|
21 |
+
);
|
22 |
+
}
|
23 |
+
|
24 |
+
protected function _getDefaultRate()
|
25 |
+
{
|
26 |
+
$rate = Mage::getModel('shipping/rate_result_method');
|
27 |
+
|
28 |
+
$rate->setCarrier($this->_code);
|
29 |
+
$rate->setCarrierTitle($this->getConfigData('title'));
|
30 |
+
$rate->setMethod('skyboxcheckout');//$this->_code
|
31 |
+
$rate->setMethodTitle($this->getConfigData('title'));
|
32 |
+
$rate->setPrice($this->getConfigData('price'));
|
33 |
+
$rate->setCost(0);
|
34 |
+
|
35 |
+
return $rate;
|
36 |
+
}
|
37 |
}
|
app/code/community/Skybox/Checkout/Model/Cart.php
CHANGED
@@ -1,717 +1,717 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Checkout
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Checkout
|
8 |
-
* @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Checkout_Model_Cart extends Mage_Checkout_Model_Cart
|
11 |
-
{
|
12 |
-
const MESSAGE_FAIL_TO_ADD_PRODUCT = '[sales] Failed to add the product to the cart.';
|
13 |
-
|
14 |
-
protected $_api = null;
|
15 |
-
protected $_product = null;
|
16 |
-
protected $_enable = null;
|
17 |
-
|
18 |
-
/* @return Skybox_Checkout_Model_Api_Checkout */
|
19 |
-
protected function _getApi()
|
20 |
-
{
|
21 |
-
if (null === $this->_api) {
|
22 |
-
$this->_api = Mage::getModel('skyboxcheckout/api_checkout');
|
23 |
-
}
|
24 |
-
return $this->_api;
|
25 |
-
}
|
26 |
-
|
27 |
-
protected function _getAllowHelper()
|
28 |
-
{
|
29 |
-
return Mage::helper('skyboxcore/allow');
|
30 |
-
}
|
31 |
-
|
32 |
-
// @todo : Move this logic to a helper
|
33 |
-
private function isEnable()
|
34 |
-
{
|
35 |
-
if ($this->_enable == null) {
|
36 |
-
|
37 |
-
$isActive = boolval(Mage::helper('skyboxinternational/data')->getActive());
|
38 |
-
|
39 |
-
if (!$isActive) {
|
40 |
-
return false;
|
41 |
-
}
|
42 |
-
|
43 |
-
$isEnable = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
44 |
-
|
45 |
-
if (!$isEnable) {
|
46 |
-
return false;
|
47 |
-
}
|
48 |
-
|
49 |
-
$allowHelper = Mage::helper('skyboxcore/allow');
|
50 |
-
|
51 |
-
if (!$allowHelper->isOperationCartEnabled()) {
|
52 |
-
return false;
|
53 |
-
}
|
54 |
-
|
55 |
-
$api_mproduct = Mage::getModel('skyboxcatalog/api_product');
|
56 |
-
|
57 |
-
if (!$api_mproduct->getLocationAllow()) {
|
58 |
-
return false;
|
59 |
-
}
|
60 |
-
|
61 |
-
$this->_enable = true;
|
62 |
-
}
|
63 |
-
return $this->_enable;
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Return Skybox API Product
|
68 |
-
*
|
69 |
-
* @return Skybox_Catalog_Model_Api_Product
|
70 |
-
*/
|
71 |
-
protected function _getProductApi()
|
72 |
-
{
|
73 |
-
if (null === $this->_product) {
|
74 |
-
$this->_product = Mage::getModel('skyboxcatalog/api_product');
|
75 |
-
}
|
76 |
-
return $this->_product;
|
77 |
-
}
|
78 |
-
|
79 |
-
/*
|
80 |
-
* Grouped Product
|
81 |
-
*/
|
82 |
-
public function addGroupedProduct($productInfo, $requestInfo = null)
|
83 |
-
{
|
84 |
-
//Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter addBundleProduct', null, 'tracer.log', true);
|
85 |
-
$product = $this->_getProduct($productInfo);
|
86 |
-
$request = $this->_getProductRequest($requestInfo);
|
87 |
-
|
88 |
-
$quote = parent::addProduct($productInfo, $requestInfo);
|
89 |
-
|
90 |
-
$super_group = $request->getData('super_group');
|
91 |
-
//Mage::log(print_r($super_group, true), null, 'cart.log', true);
|
92 |
-
|
93 |
-
foreach ($super_group as $item => $qty) {
|
94 |
-
if ($qty <= 0) {
|
95 |
-
continue;
|
96 |
-
}
|
97 |
-
|
98 |
-
//Mage::log("Product: " . $item . " - " . $qty, null, 'cart.log', true);
|
99 |
-
|
100 |
-
$product = Mage::getModel('catalog/product')
|
101 |
-
->setStoreId(Mage::app()->getStore()->getId())
|
102 |
-
->load($item);
|
103 |
-
|
104 |
-
$productId = $product->getId();
|
105 |
-
|
106 |
-
if ($product->getStockItem()) {
|
107 |
-
$minimumQty = $product->getStockItem()->getMinSaleQty();
|
108 |
-
//If product was not found in cart and there is set minimal qty for it
|
109 |
-
if ($minimumQty && $minimumQty > 0 && $qty < $minimumQty
|
110 |
-
&& !$this->getQuote()->hasProductId($productId)
|
111 |
-
) {
|
112 |
-
$request->setQty($minimumQty);
|
113 |
-
}
|
114 |
-
}
|
115 |
-
|
116 |
-
$this->_getProductApi()->CalculatePrice($product, null);
|
117 |
-
|
118 |
-
if ($this->_getProductApi()->HasError()) {
|
119 |
-
|
120 |
-
$message = self::MESSAGE_FAIL_TO_ADD_PRODUCT;
|
121 |
-
|
122 |
-
if ($this->_getProductApi()->_getApi()->ErrorRatesNotFound()) {
|
123 |
-
$languageId = $this->getLanguageId();
|
124 |
-
$message = $this->_getProductApi()->_getApi()->getErrorRatesNotFoundMessage($languageId);
|
125 |
-
}
|
126 |
-
Mage::throwException(
|
127 |
-
Mage::helper('sales')->__($message)
|
128 |
-
);
|
129 |
-
return $this;
|
130 |
-
}
|
131 |
-
|
132 |
-
$productId = $this->_getProductApi()->getProductId();
|
133 |
-
|
134 |
-
$_data = $this->_getProductApi()->getProductData();
|
135 |
-
$this->_getApi()->AddProductOfCart($_data, $qty);
|
136 |
-
|
137 |
-
if ($this->_getApi()->HasError()) {
|
138 |
-
Mage::throwException(Mage::helper('checkout')->__('[checkout] Failed to add the product to the cart.'));
|
139 |
-
return $this;
|
140 |
-
}
|
141 |
-
|
142 |
-
$productIdSkybox = $this->_getApi()->getParameter(
|
143 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID, "0");
|
144 |
-
|
145 |
-
$this->_updateQuoteItem($productId, $productIdSkybox);
|
146 |
-
}
|
147 |
-
|
148 |
-
return $quote;
|
149 |
-
}
|
150 |
-
|
151 |
-
/*
|
152 |
-
* Bundle Product
|
153 |
-
*/
|
154 |
-
public function addBundleProduct($productInfo, $requestInfo = null)
|
155 |
-
{
|
156 |
-
//Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter addBundleProduct', null, 'tracer.log', true);
|
157 |
-
$product = $this->_getProduct($productInfo);
|
158 |
-
$request = $this->_getProductRequest($requestInfo);
|
159 |
-
|
160 |
-
//Mage::log(print_r($request, true), null, 'cart.log', true);
|
161 |
-
|
162 |
-
$quote = parent::addProduct($productInfo, $requestInfo);
|
163 |
-
|
164 |
-
// SkyBox Checkout
|
165 |
-
$this->_getProductApi()->CalculatePrice($product, $request);
|
166 |
-
|
167 |
-
if ($this->_getProductApi()->HasError()) {
|
168 |
-
|
169 |
-
$message = self::MESSAGE_FAIL_TO_ADD_PRODUCT;
|
170 |
-
|
171 |
-
if ($this->_getProductApi()->_getApi()->ErrorRatesNotFound()) {
|
172 |
-
$languageId = $this->getLanguageId();
|
173 |
-
$message = $this->_getProductApi()->_getApi()->getErrorRatesNotFoundMessage($languageId);
|
174 |
-
}
|
175 |
-
Mage::throwException(
|
176 |
-
Mage::helper('sales')->__($message)
|
177 |
-
);
|
178 |
-
return $this;
|
179 |
-
}
|
180 |
-
|
181 |
-
//$productId = $product->getId();
|
182 |
-
$productId = $this->_getProductApi()->getProductId();
|
183 |
-
|
184 |
-
Mage::dispatchEvent('checkout_cart_product_add_before', array(
|
185 |
-
'product' => $product,
|
186 |
-
'request' => $request
|
187 |
-
));
|
188 |
-
|
189 |
-
$_data = $this->_getProductApi()->getProductData();
|
190 |
-
|
191 |
-
Mage::log("Bundleproduct=Cart=" . print_r($_data, true), null, 'cart.log', true);
|
192 |
-
|
193 |
-
$this->_getApi()->AddProductOfCart($_data, $request->getQty());
|
194 |
-
|
195 |
-
if ($this->_getApi()->HasError()) {
|
196 |
-
Mage::throwException(Mage::helper('checkout')->__('[checkout] Failed to add the product to the cart.'));
|
197 |
-
return $this;
|
198 |
-
}
|
199 |
-
|
200 |
-
$productIdSkybox = $this->_getApi()->getParameter(
|
201 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID, "0");
|
202 |
-
|
203 |
-
$this->_updateQuoteItem($productId, $productIdSkybox);
|
204 |
-
return $quote;
|
205 |
-
}
|
206 |
-
|
207 |
-
/**
|
208 |
-
* Add product to shopping cart (quote)
|
209 |
-
*
|
210 |
-
* @param int|Mage_Catalog_Model_Product $productInfo
|
211 |
-
* @param mixed $requestInfo
|
212 |
-
* @return Mage_Checkout_Model_Cart
|
213 |
-
*/
|
214 |
-
public function addProduct($productInfo, $requestInfo = null)
|
215 |
-
{
|
216 |
-
if (!$this->isEnable()) {
|
217 |
-
parent::addProduct($productInfo, $requestInfo);
|
218 |
-
return $this;
|
219 |
-
}
|
220 |
-
|
221 |
-
$api_mproduct = Mage::getModel('skyboxcatalog/api_product');
|
222 |
-
|
223 |
-
if (!$api_mproduct->getLocationAllow()) {
|
224 |
-
parent::addProduct($productInfo, $requestInfo);
|
225 |
-
return $this;
|
226 |
-
}
|
227 |
-
|
228 |
-
//Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter addProduct', null, 'tracer.log', true);
|
229 |
-
$product = $this->_getProduct($productInfo);
|
230 |
-
$request = $this->_getProductRequest($requestInfo);
|
231 |
-
|
232 |
-
if ($product->isGrouped()) {
|
233 |
-
Mage::log("Product: " . $product->getName() . " is Grouped", null, 'cart.log', true);
|
234 |
-
return $this->addGroupedProduct($productInfo, $requestInfo);
|
235 |
-
}
|
236 |
-
|
237 |
-
if ($product->getTypeId() == 'bundle') {
|
238 |
-
Mage::log("Product: " . $product->getName() . " is Bundle", null, 'cart.log', true);
|
239 |
-
return $this->addBundleProduct($productInfo, $requestInfo);
|
240 |
-
}
|
241 |
-
|
242 |
-
// SkyBox Checkout
|
243 |
-
$this->_getProductApi()->CalculatePrice($product, $request);
|
244 |
-
|
245 |
-
if ($this->_getProductApi()->HasError()) {
|
246 |
-
|
247 |
-
$message = self::MESSAGE_FAIL_TO_ADD_PRODUCT;
|
248 |
-
|
249 |
-
if ($this->_getProductApi()->_getApi()->ErrorRatesNotFound()) {
|
250 |
-
$languageId = $this->getLanguageId();
|
251 |
-
$message = $this->_getProductApi()->_getApi()->getErrorRatesNotFoundMessage($languageId);
|
252 |
-
}
|
253 |
-
Mage::throwException(
|
254 |
-
Mage::helper('sales')->__($message)
|
255 |
-
);
|
256 |
-
return $this;
|
257 |
-
}
|
258 |
-
|
259 |
-
// $productId = $product->getId();
|
260 |
-
$productId = $this->_getProductApi()->getProductId();
|
261 |
-
|
262 |
-
if ($product->getStockItem()) {
|
263 |
-
$minimumQty = $product->getStockItem()->getMinSaleQty();
|
264 |
-
//If product was not found in cart and there is set minimal qty for it
|
265 |
-
if ($minimumQty && $minimumQty > 0 && $request->getQty() < $minimumQty
|
266 |
-
&& !$this->getQuote()->hasProductId($productId)
|
267 |
-
) {
|
268 |
-
$request->setQty($minimumQty);
|
269 |
-
}
|
270 |
-
}
|
271 |
-
|
272 |
-
/*$product->setTaxPercent(0);
|
273 |
-
$product->setTaxAmount(0);
|
274 |
-
$product->setBaseTaxAmount(0);*/
|
275 |
-
|
276 |
-
Mage::dispatchEvent('checkout_cart_product_add_before', array(
|
277 |
-
'product' => $product,
|
278 |
-
'request' => $request
|
279 |
-
));
|
280 |
-
|
281 |
-
$_data = $this->_getProductApi()->getProductData();
|
282 |
-
Mage::log("product=Cart=" . print_r($_data, true), null, 'cart.log', true);
|
283 |
-
$this->_getApi()->setCurrentProduct($product);
|
284 |
-
$this->_getApi()->AddProductOfCart($_data, $request->getQty());
|
285 |
-
|
286 |
-
if ($this->_getApi()->HasError()) {
|
287 |
-
Mage::throwException(Mage::helper('checkout')->__('[checkout] Failed to add the product to the cart.'));
|
288 |
-
return $this;
|
289 |
-
}
|
290 |
-
|
291 |
-
$productIdSkybox = $this->_getApi()->getParameter(
|
292 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID, "0");
|
293 |
-
|
294 |
-
try {
|
295 |
-
$quote = parent::addProduct($productInfo, $requestInfo);
|
296 |
-
$this->_updateQuoteItem($productId, $productIdSkybox);
|
297 |
-
} catch (\Exception $e) {
|
298 |
-
Mage::log($e->getMessage(), null, 'tracer.log', true);
|
299 |
-
}
|
300 |
-
|
301 |
-
return $quote;
|
302 |
-
}
|
303 |
-
|
304 |
-
// protected function _getProduct($productInfo){
|
305 |
-
// Mage::log('Entro skybox _getProduct', null, 'tracer.log', true);
|
306 |
-
// Mage::log(print_r($productInfo,true), null, 'tracer.log', true);
|
307 |
-
// $product = parent::_getProduct($productInfo);
|
308 |
-
// return $product;
|
309 |
-
// }
|
310 |
-
|
311 |
-
public function addProductsByIds($productIds)
|
312 |
-
{
|
313 |
-
if (!$this->isEnable()) {
|
314 |
-
parent::addProductsByIds($productIds);
|
315 |
-
return $this;
|
316 |
-
}
|
317 |
-
|
318 |
-
//Mage::log('Entro skybox addProductsByIds', null, 'tracer.log', true);
|
319 |
-
//Mage::log(print_r($productIds,true), null, 'tracer.log', true);
|
320 |
-
if (count($productIds) > 0) {
|
321 |
-
foreach ($productIds as $idproduct) {
|
322 |
-
$idproduct = trim($idproduct);
|
323 |
-
if (empty($idproduct)) {
|
324 |
-
continue;
|
325 |
-
}
|
326 |
-
$this->addProduct($idproduct);
|
327 |
-
}
|
328 |
-
}
|
329 |
-
// $quote = parent::addProductsByIds($productIds);
|
330 |
-
return $this;
|
331 |
-
}
|
332 |
-
|
333 |
-
private function _updateQuoteItem($productId, $productIdSkybox)
|
334 |
-
{
|
335 |
-
Mage::log('pas x aqui2', null, 'minicars.log', true);
|
336 |
-
|
337 |
-
|
338 |
-
/**
|
339 |
-
* only one time for call to service start - Active
|
340 |
-
* when do add to cart
|
341 |
-
*/
|
342 |
-
$session = Mage::getSingleton("core/session", array("name" => "frontend"));
|
343 |
-
$session->setData("callToSkyBox", true);
|
344 |
-
//Mage::log("Call true: add to cart", null, 'local.log', true);
|
345 |
-
/**
|
346 |
-
* when do add to cart end - Active
|
347 |
-
*/
|
348 |
-
foreach ($this->getQuote()->getAllItems() as $item) {
|
349 |
-
|
350 |
-
if ($item->getProductId() == $productId) {
|
351 |
-
|
352 |
-
if ($item instanceof Mage_Sales_Model_Quote_Item) {
|
353 |
-
$parentItem = $item->getParentItem();
|
354 |
-
if ($parentItem) {
|
355 |
-
$item = $parentItem;
|
356 |
-
}
|
357 |
-
}
|
358 |
-
/**
|
359 |
-
* Integration 3 start, show price shop in cart*
|
360 |
-
*/
|
361 |
-
$isLocationAllow = false;
|
362 |
-
//$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
|
363 |
-
$typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
|
364 |
-
if ($typeIntegration == 3) {
|
365 |
-
$isLocationAllow = true;
|
366 |
-
}
|
367 |
-
/**
|
368 |
-
* Integration 3 end, show price shop in cart*
|
369 |
-
*/
|
370 |
-
if ($isLocationAllow) {
|
371 |
-
$productModel = Mage::getModel('catalog/product')->load($productId);
|
372 |
-
$total = str_replace(",", "", $productModel->getTotalPriceUSD());
|
373 |
-
$item->setIdProductSkybox($productIdSkybox);
|
374 |
-
|
375 |
-
// Currency amounts in the default currency of that customer
|
376 |
-
$item->setCustomsSkybox($productModel->getCustoms());
|
377 |
-
$item->setShippingSkybox($productModel->getShipping());
|
378 |
-
$item->setInsuranceSkybox($productModel->getInsurance());
|
379 |
-
$item->setPriceSkybox($productModel->getPrice());
|
380 |
-
$item->setTotalSkybox($productModel->getTotalPrice());
|
381 |
-
$item->setRowTotal($total);
|
382 |
-
|
383 |
-
// Currency amounts in the USD Currency
|
384 |
-
$item->setCustomsUsdSkybox($productModel->getCustomsUSD());
|
385 |
-
$item->setShippingUsdSkybox($productModel->getShippingUSD());
|
386 |
-
$item->setInsuranceUsdSkybox($productModel->getInsuranceUSD());
|
387 |
-
$item->setPriceUsdSkybox($productModel->getPriceUSD());
|
388 |
-
$item->setTotalUsdSkybox($productModel->getTotalPriceUSD());
|
389 |
-
|
390 |
-
$item->setGuidSkybox($productModel->getGuidSkybox()); //Set GUID
|
391 |
-
|
392 |
-
|
393 |
-
$item->setBasePriceSkybox($productModel->getBasePrice());
|
394 |
-
$item->setBasePriceUsdSkybox($productModel->getBasePriceUSD());
|
395 |
-
$item->setAdjustTotalSkybox($productModel->getAdjustPrice());
|
396 |
-
$item->setAdjustTotalUsdSkybox($productModel->getAdjustPriceUSD());
|
397 |
-
$item->setAdjustLabelSkybox($productModel->getAdjustLabel());
|
398 |
-
|
399 |
-
//$item->setOriginalCustomPrice($this->_getProductApi()->getTotalPriceUSD());
|
400 |
-
//$item->setOriginalCustomPrice($total);
|
401 |
-
// $item->setOriginalCustomPrice($this->_getProductApi()->getPrice());
|
402 |
-
$prices = str_replace(',', '', $productModel->getPrice());
|
403 |
-
$prices = number_format((float)($prices), 2, ',', '.');
|
404 |
-
$item->setOriginalCustomPrice($prices);
|
405 |
-
//$skybox_total = str_replace(",", "", $this->_getProductApi()->getTotalPrice());
|
406 |
-
$skybox_total = str_replace(",", "", $productModel->getPrice());
|
407 |
-
$row_total = floatval($skybox_total) * $item->getQty();
|
408 |
-
$item->setRowTotalSkybox($row_total);
|
409 |
-
} else {
|
410 |
-
$total = str_replace(",", "", $this->_getProductApi()->getTotalPriceUSD());
|
411 |
-
$item->setIdProductSkybox($productIdSkybox);
|
412 |
-
|
413 |
-
// Currency amounts in the default currency of that customer
|
414 |
-
$item->setCustomsSkybox($this->_getProductApi()->getCustoms());
|
415 |
-
$item->setShippingSkybox($this->_getProductApi()->getShipping());
|
416 |
-
$item->setInsuranceSkybox($this->_getProductApi()->getInsurance());
|
417 |
-
$item->setPriceSkybox($this->_getProductApi()->getPrice());
|
418 |
-
$item->setTotalSkybox($this->_getProductApi()->getTotalPrice());
|
419 |
-
$item->setRowTotal($total);
|
420 |
-
|
421 |
-
// Currency amounts in the USD Currency
|
422 |
-
$item->setCustomsUsdSkybox($this->_getProductApi()->getCustomsUSD());
|
423 |
-
$item->setShippingUsdSkybox($this->_getProductApi()->getShippingUSD());
|
424 |
-
$item->setInsuranceUsdSkybox($this->_getProductApi()->getInsuranceUSD());
|
425 |
-
$item->setPriceUsdSkybox($this->_getProductApi()->getPriceUSD());
|
426 |
-
$item->setTotalUsdSkybox($this->_getProductApi()->getTotalPriceUSD());
|
427 |
-
|
428 |
-
$item->setGuidSkybox($this->_getProductApi()->getGuidSkybox()); //Set GUID
|
429 |
-
|
430 |
-
|
431 |
-
$item->setBasePriceSkybox($this->_getProductApi()->getBasePrice());
|
432 |
-
$item->setBasePriceUsdSkybox($this->_getProductApi()->getBasePriceUSD());
|
433 |
-
$item->setAdjustTotalSkybox($this->_getProductApi()->getAdjustPrice());
|
434 |
-
$item->setAdjustTotalUsdSkybox($this->_getProductApi()->getAdjustPriceUSD());
|
435 |
-
$item->setAdjustLabelSkybox($this->_getProductApi()->getAdjustLabel());
|
436 |
-
|
437 |
-
//$item->setOriginalCustomPrice($this->_getProductApi()->getTotalPriceUSD());
|
438 |
-
//$item->setOriginalCustomPrice($total);
|
439 |
-
// $item->setOriginalCustomPrice($this->_getProductApi()->getPrice());
|
440 |
-
$prices = str_replace(',', '', $this->_getProductApi()->getPrice());
|
441 |
-
$prices = number_format((float)($prices), 2, ',', '.');
|
442 |
-
$item->setOriginalCustomPrice($prices);
|
443 |
-
//$skybox_total = str_replace(",", "", $this->_getProductApi()->getTotalPrice());
|
444 |
-
$skybox_total = str_replace(",", "", $this->_getProductApi()->getPrice());
|
445 |
-
$row_total = floatval($skybox_total) * $item->getQty();
|
446 |
-
$item->setRowTotalSkybox($row_total);
|
447 |
-
}
|
448 |
-
|
449 |
-
|
450 |
-
break;
|
451 |
-
}
|
452 |
-
}
|
453 |
-
|
454 |
-
}
|
455 |
-
|
456 |
-
private function _updateQuoteItem_backup($productId, $productIdSkybox)
|
457 |
-
{
|
458 |
-
Mage::log('pas x aqui2', null, 'minicars.log', true);
|
459 |
-
|
460 |
-
foreach ($this->getQuote()->getAllItems() as $item) {
|
461 |
-
|
462 |
-
if ($item->getProductId() == $productId) {
|
463 |
-
|
464 |
-
if ($item instanceof Mage_Sales_Model_Quote_Item) {
|
465 |
-
$parentItem = $item->getParentItem();
|
466 |
-
if ($parentItem) {
|
467 |
-
$item = $parentItem;
|
468 |
-
}
|
469 |
-
}
|
470 |
-
|
471 |
-
$total = str_replace(",", "", $this->_getProductApi()->getTotalPriceUSD());
|
472 |
-
$item->setIdProductSkybox($productIdSkybox);
|
473 |
-
|
474 |
-
// Currency amounts in the default currency of that customer
|
475 |
-
$item->setCustomsSkybox($this->_getProductApi()->getCustoms());
|
476 |
-
$item->setShippingSkybox($this->_getProductApi()->getShipping());
|
477 |
-
$item->setInsuranceSkybox($this->_getProductApi()->getInsurance());
|
478 |
-
$item->setPriceSkybox($this->_getProductApi()->getPrice());
|
479 |
-
$item->setTotalSkybox($this->_getProductApi()->getTotalPrice());
|
480 |
-
$item->setRowTotal($total);
|
481 |
-
|
482 |
-
// Currency amounts in the USD Currency
|
483 |
-
$item->setCustomsUsdSkybox($this->_getProductApi()->getCustomsUSD());
|
484 |
-
$item->setShippingUsdSkybox($this->_getProductApi()->getShippingUSD());
|
485 |
-
$item->setInsuranceUsdSkybox($this->_getProductApi()->getInsuranceUSD());
|
486 |
-
$item->setPriceUsdSkybox($this->_getProductApi()->getPriceUSD());
|
487 |
-
$item->setTotalUsdSkybox($this->_getProductApi()->getTotalPriceUSD());
|
488 |
-
|
489 |
-
$item->setGuidSkybox($this->_getProductApi()->getGuidSkybox()); //Set GUID
|
490 |
-
|
491 |
-
|
492 |
-
$item->setBasePriceSkybox($this->_getProductApi()->getBasePrice());
|
493 |
-
$item->setBasePriceUsdSkybox($this->_getProductApi()->getBasePriceUSD());
|
494 |
-
$item->setAdjustTotalSkybox($this->_getProductApi()->getAdjustPrice());
|
495 |
-
$item->setAdjustTotalUsdSkybox($this->_getProductApi()->getAdjustPriceUSD());
|
496 |
-
$item->setAdjustLabelSkybox($this->_getProductApi()->getAdjustLabel());
|
497 |
-
|
498 |
-
//$item->setOriginalCustomPrice($this->_getProductApi()->getTotalPriceUSD());
|
499 |
-
//$item->setOriginalCustomPrice($total);
|
500 |
-
// $item->setOriginalCustomPrice($this->_getProductApi()->getPrice());
|
501 |
-
$prices = str_replace(',', '', $this->_getProductApi()->getPrice());
|
502 |
-
$prices = number_format((float)($prices), 2, ',', '.');
|
503 |
-
$item->setOriginalCustomPrice($prices);
|
504 |
-
//$skybox_total = str_replace(",", "", $this->_getProductApi()->getTotalPrice());
|
505 |
-
$skybox_total = str_replace(",", "", $this->_getProductApi()->getPrice());
|
506 |
-
$row_total = floatval($skybox_total) * $item->getQty();
|
507 |
-
$item->setRowTotalSkybox($row_total);
|
508 |
-
|
509 |
-
break;
|
510 |
-
}
|
511 |
-
}
|
512 |
-
|
513 |
-
}
|
514 |
-
|
515 |
-
/**
|
516 |
-
* Remove item from cart
|
517 |
-
*
|
518 |
-
* @param int $itemId
|
519 |
-
* @return Mage_Checkout_Model_Cart
|
520 |
-
*/
|
521 |
-
public function removeItem($itemId)
|
522 |
-
{
|
523 |
-
/**
|
524 |
-
* only one time for call to service start - Active
|
525 |
-
* when do remove
|
526 |
-
*/
|
527 |
-
$session = Mage::getSingleton("core/session", array("name" => "frontend"));
|
528 |
-
$session->setData("callToSkyBox", true);
|
529 |
-
//Mage::log("Call true: remove", null, 'local.log', true);
|
530 |
-
/**
|
531 |
-
* when do remove
|
532 |
-
*/
|
533 |
-
if (!$this->isEnable()) {
|
534 |
-
parent::removeItem($itemId);
|
535 |
-
return $this;
|
536 |
-
}
|
537 |
-
|
538 |
-
$quoteItem = $this->getQuote()->getItemById($itemId);
|
539 |
-
|
540 |
-
if (!$quoteItem) {
|
541 |
-
Mage::throwException(Mage::helper('checkout')->__('ID incorrecto de producto.'));
|
542 |
-
return $this;
|
543 |
-
}
|
544 |
-
Mage::log("|removeItem|" . $quoteItem->getIdProductSkybox());
|
545 |
-
//Realizar llamada al servicio de agregar producto al carrito.
|
546 |
-
$idProductSkybox = $quoteItem->getIdProductSkybox();
|
547 |
-
$this->_getApi()->DeleteProductOfCart($idProductSkybox);
|
548 |
-
|
549 |
-
if ($this->_getApi()->HasError()) {
|
550 |
-
Mage::throwException(Mage::helper('checkout')->__('Error al eliminar producto al carrito.'));
|
551 |
-
return $this;
|
552 |
-
}
|
553 |
-
|
554 |
-
return parent::removeItem($itemId);
|
555 |
-
}
|
556 |
-
|
557 |
-
/**
|
558 |
-
* Update cart items information
|
559 |
-
*
|
560 |
-
* @param array $data
|
561 |
-
* @return Mage_Checkout_Model_Cart
|
562 |
-
*/
|
563 |
-
public function updateItems($data)
|
564 |
-
{
|
565 |
-
/**
|
566 |
-
* only one time for call to service start - Active
|
567 |
-
* when do remove
|
568 |
-
*/
|
569 |
-
$session = Mage::getSingleton("core/session", array("name" => "frontend"));
|
570 |
-
$session->setData("callToSkyBox", true);
|
571 |
-
//Mage::log("Call true: update cart", null, 'local.log', true);
|
572 |
-
/**
|
573 |
-
* when do remove
|
574 |
-
*/
|
575 |
-
if (!$this->isEnable()) {
|
576 |
-
parent::updateItems($data);
|
577 |
-
return $this;
|
578 |
-
}
|
579 |
-
|
580 |
-
Mage::log('pas x aqui5', null, 'cartdetail.log', true);
|
581 |
-
//Mage::log(print_r($data, true), null, 'tracer.log', true);
|
582 |
-
//Mage::log("Skybox_Checkout_Checkout_Model_Cart updateItem");
|
583 |
-
//return parent::updateItems($data);
|
584 |
-
// Mage::dispatchEvent('checkout_cart_update_items_before', array('cart'=>$this, 'info'=>$data));
|
585 |
-
|
586 |
-
foreach ($data as $itemId => $itemInfo) {
|
587 |
-
$item = $this->getQuote()->getItemById($itemId);
|
588 |
-
//Mage::log('item:', null, 'tracer.log', true);
|
589 |
-
//Mage::log(print_r($item->debug(), true), null, 'tracer.log', true);
|
590 |
-
//Mage::log(print_r($itemInfo, true), null, 'tracer.log', true);
|
591 |
-
//Mage::log('updateItems foreach', null, 'tracer.log', true);
|
592 |
-
if (!$item) {
|
593 |
-
//Mage::log('no item', null, 'tracer.log', true);
|
594 |
-
continue;
|
595 |
-
}
|
596 |
-
|
597 |
-
// if(isset($itemInfo['price']) && !empty($itemInfo['price'])) {
|
598 |
-
// //price, base_price, custom_price, row_total, base_row_total, row_total_with_discount, original_custom_price
|
599 |
-
// $price = (float) $itemInfo['price'];
|
600 |
-
// $item->setPrice($price);
|
601 |
-
// $item->setRowTotal($price);
|
602 |
-
// $item->setBasePrice($price);
|
603 |
-
// continue;
|
604 |
-
// }
|
605 |
-
|
606 |
-
if (!empty($itemInfo['remove']) || (isset($itemInfo['qty']) && $itemInfo['qty'] == '0')) {
|
607 |
-
$this->removeItem($itemId);
|
608 |
-
continue;
|
609 |
-
}
|
610 |
-
|
611 |
-
$qty = isset($itemInfo['qty']) ? (float)$itemInfo['qty'] : false;
|
612 |
-
//Mage::log('cantidad: '.$qty, null, 'tracer.log', true);
|
613 |
-
if ($qty > 0) {
|
614 |
-
|
615 |
-
$idProductSkybox = $item->getIdProductSkybox();
|
616 |
-
|
617 |
-
// $this->_getApi()->UpdateProductOfCart($idProductSkybox, $qty);
|
618 |
-
|
619 |
-
$item->setQty($qty);
|
620 |
-
|
621 |
-
//$skybox_total = str_replace(",", "", $item->getTotalSkybox());
|
622 |
-
$skybox_total = str_replace(",", "", $item->getPriceSkybox());
|
623 |
-
|
624 |
-
|
625 |
-
$row_total = floatval($skybox_total) * $item->getQty();
|
626 |
-
$item->setRowTotalSkybox($row_total);
|
627 |
-
|
628 |
-
//Mage::log('fin qty', null, 'tracer.log', true);
|
629 |
-
}
|
630 |
-
}
|
631 |
-
|
632 |
-
// Mage::dispatchEvent('checkout_cart_update_items_after', array('cart'=>$this, 'info'=>$data));
|
633 |
-
$current = parent::updateItems($data);
|
634 |
-
return $current;
|
635 |
-
}
|
636 |
-
|
637 |
-
/**
|
638 |
-
* Mark all quote items as deleted (empty shopping cart)
|
639 |
-
*
|
640 |
-
* @return Mage_Checkout_Model_Cart
|
641 |
-
*/
|
642 |
-
public function truncate()
|
643 |
-
{
|
644 |
-
foreach ($this->getQuote()->getAllItems() as $item) {
|
645 |
-
//Mage::log("truncate() ". $item->getId(), null, 'api.log', true);
|
646 |
-
$this->removeItem($item->getId());
|
647 |
-
}
|
648 |
-
|
649 |
-
parent::truncate();
|
650 |
-
return $this;
|
651 |
-
}
|
652 |
-
|
653 |
-
/**
|
654 |
-
* Mark all quote items as deleted (empty shopping cart)
|
655 |
-
* @return $this
|
656 |
-
*/
|
657 |
-
public function truncateMgCart()
|
658 |
-
{
|
659 |
-
parent::truncate();
|
660 |
-
return $this;
|
661 |
-
}
|
662 |
-
|
663 |
-
/**
|
664 |
-
* Update item in shopping cart (quote)
|
665 |
-
* $requestInfo - either qty (int) or buyRequest in form of array or Varien_Object
|
666 |
-
* $updatingParams - information on how to perform update, passed to Quote->updateItem() method
|
667 |
-
*/
|
668 |
-
public function updateItem($itemId, $requestInfo = null, $updatingParams = null)
|
669 |
-
{
|
670 |
-
if (!$this->isEnable()) {
|
671 |
-
$result = parent::updateItem($itemId, $requestInfo, $updatingParams);
|
672 |
-
return $result;
|
673 |
-
}
|
674 |
-
|
675 |
-
$item = $this->getQuote()->getItemById($itemId);
|
676 |
-
$skyboxProductId = $item->getIdProductSkybox();
|
677 |
-
$_quoteItemId = $item->getId();
|
678 |
-
$_qty = $item->getQty();
|
679 |
-
|
680 |
-
/** @var Mage_Sales_Model_Quote_Item $result */
|
681 |
-
$result = parent::updateItem($itemId, $requestInfo, $updatingParams);
|
682 |
-
$quoteItemId = $result->getId();
|
683 |
-
$qty = $result->getQty();
|
684 |
-
|
685 |
-
// Update Product
|
686 |
-
if ($quoteItemId == $_quoteItemId) {
|
687 |
-
$this->_getApi()->UpdateProductOfCart($skyboxProductId, $qty);
|
688 |
-
} else {
|
689 |
-
// Delete and Add a New Product
|
690 |
-
$this->_getApi()->DeleteProductOfCart($skyboxProductId);
|
691 |
-
|
692 |
-
$product = $result->getProduct();
|
693 |
-
$this->_getProductApi()->CalculatePrice($product, $requestInfo);
|
694 |
-
|
695 |
-
$_data = $this->_getProductApi()->getProductData();
|
696 |
-
$this->_getApi()->setCurrentProduct($product);
|
697 |
-
$this->_getApi()->AddProductOfCart($_data, $qty);
|
698 |
-
|
699 |
-
$productId = $result->getProduct()->getId();
|
700 |
-
$skyboxProductId = $this->_getApi()->getParameter(
|
701 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID, "0");
|
702 |
-
|
703 |
-
$this->_updateQuoteItem($productId, $skyboxProductId);
|
704 |
-
}
|
705 |
-
|
706 |
-
return $result;
|
707 |
-
}
|
708 |
-
|
709 |
-
private function getLanguageId()
|
710 |
-
{
|
711 |
-
$_config = Mage::getModel('skyboxcore/config');
|
712 |
-
$cart = $_config->getSession()->getCartSkybox();
|
713 |
-
$id = $cart->{'LanguageId'};
|
714 |
-
return intval($id);
|
715 |
-
}
|
716 |
-
|
717 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Checkout
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Checkout
|
8 |
+
* @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Checkout_Model_Cart extends Mage_Checkout_Model_Cart
|
11 |
+
{
|
12 |
+
const MESSAGE_FAIL_TO_ADD_PRODUCT = '[sales] Failed to add the product to the cart.';
|
13 |
+
|
14 |
+
protected $_api = null;
|
15 |
+
protected $_product = null;
|
16 |
+
protected $_enable = null;
|
17 |
+
|
18 |
+
/* @return Skybox_Checkout_Model_Api_Checkout */
|
19 |
+
protected function _getApi()
|
20 |
+
{
|
21 |
+
if (null === $this->_api) {
|
22 |
+
$this->_api = Mage::getModel('skyboxcheckout/api_checkout');
|
23 |
+
}
|
24 |
+
return $this->_api;
|
25 |
+
}
|
26 |
+
|
27 |
+
protected function _getAllowHelper()
|
28 |
+
{
|
29 |
+
return Mage::helper('skyboxcore/allow');
|
30 |
+
}
|
31 |
+
|
32 |
+
// @todo : Move this logic to a helper
|
33 |
+
private function isEnable()
|
34 |
+
{
|
35 |
+
if ($this->_enable == null) {
|
36 |
+
|
37 |
+
$isActive = boolval(Mage::helper('skyboxinternational/data')->getActive());
|
38 |
+
|
39 |
+
if (!$isActive) {
|
40 |
+
return false;
|
41 |
+
}
|
42 |
+
|
43 |
+
$isEnable = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
44 |
+
|
45 |
+
if (!$isEnable) {
|
46 |
+
return false;
|
47 |
+
}
|
48 |
+
|
49 |
+
$allowHelper = Mage::helper('skyboxcore/allow');
|
50 |
+
|
51 |
+
if (!$allowHelper->isOperationCartEnabled()) {
|
52 |
+
return false;
|
53 |
+
}
|
54 |
+
|
55 |
+
$api_mproduct = Mage::getModel('skyboxcatalog/api_product');
|
56 |
+
|
57 |
+
if (!$api_mproduct->getLocationAllow()) {
|
58 |
+
return false;
|
59 |
+
}
|
60 |
+
|
61 |
+
$this->_enable = true;
|
62 |
+
}
|
63 |
+
return $this->_enable;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Return Skybox API Product
|
68 |
+
*
|
69 |
+
* @return Skybox_Catalog_Model_Api_Product
|
70 |
+
*/
|
71 |
+
protected function _getProductApi()
|
72 |
+
{
|
73 |
+
if (null === $this->_product) {
|
74 |
+
$this->_product = Mage::getModel('skyboxcatalog/api_product');
|
75 |
+
}
|
76 |
+
return $this->_product;
|
77 |
+
}
|
78 |
+
|
79 |
+
/*
|
80 |
+
* Grouped Product
|
81 |
+
*/
|
82 |
+
public function addGroupedProduct($productInfo, $requestInfo = null)
|
83 |
+
{
|
84 |
+
//Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter addBundleProduct', null, 'tracer.log', true);
|
85 |
+
$product = $this->_getProduct($productInfo);
|
86 |
+
$request = $this->_getProductRequest($requestInfo);
|
87 |
+
|
88 |
+
$quote = parent::addProduct($productInfo, $requestInfo);
|
89 |
+
|
90 |
+
$super_group = $request->getData('super_group');
|
91 |
+
//Mage::log(print_r($super_group, true), null, 'cart.log', true);
|
92 |
+
|
93 |
+
foreach ($super_group as $item => $qty) {
|
94 |
+
if ($qty <= 0) {
|
95 |
+
continue;
|
96 |
+
}
|
97 |
+
|
98 |
+
//Mage::log("Product: " . $item . " - " . $qty, null, 'cart.log', true);
|
99 |
+
|
100 |
+
$product = Mage::getModel('catalog/product')
|
101 |
+
->setStoreId(Mage::app()->getStore()->getId())
|
102 |
+
->load($item);
|
103 |
+
|
104 |
+
$productId = $product->getId();
|
105 |
+
|
106 |
+
if ($product->getStockItem()) {
|
107 |
+
$minimumQty = $product->getStockItem()->getMinSaleQty();
|
108 |
+
//If product was not found in cart and there is set minimal qty for it
|
109 |
+
if ($minimumQty && $minimumQty > 0 && $qty < $minimumQty
|
110 |
+
&& !$this->getQuote()->hasProductId($productId)
|
111 |
+
) {
|
112 |
+
$request->setQty($minimumQty);
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
$this->_getProductApi()->CalculatePrice($product, null);
|
117 |
+
|
118 |
+
if ($this->_getProductApi()->HasError()) {
|
119 |
+
|
120 |
+
$message = self::MESSAGE_FAIL_TO_ADD_PRODUCT;
|
121 |
+
|
122 |
+
if ($this->_getProductApi()->_getApi()->ErrorRatesNotFound()) {
|
123 |
+
$languageId = $this->getLanguageId();
|
124 |
+
$message = $this->_getProductApi()->_getApi()->getErrorRatesNotFoundMessage($languageId);
|
125 |
+
}
|
126 |
+
Mage::throwException(
|
127 |
+
Mage::helper('sales')->__($message)
|
128 |
+
);
|
129 |
+
return $this;
|
130 |
+
}
|
131 |
+
|
132 |
+
$productId = $this->_getProductApi()->getProductId();
|
133 |
+
|
134 |
+
$_data = $this->_getProductApi()->getProductData();
|
135 |
+
$this->_getApi()->AddProductOfCart($_data, $qty);
|
136 |
+
|
137 |
+
if ($this->_getApi()->HasError()) {
|
138 |
+
Mage::throwException(Mage::helper('checkout')->__('[checkout] Failed to add the product to the cart.'));
|
139 |
+
return $this;
|
140 |
+
}
|
141 |
+
|
142 |
+
$productIdSkybox = $this->_getApi()->getParameter(
|
143 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID, "0");
|
144 |
+
|
145 |
+
$this->_updateQuoteItem($productId, $productIdSkybox);
|
146 |
+
}
|
147 |
+
|
148 |
+
return $quote;
|
149 |
+
}
|
150 |
+
|
151 |
+
/*
|
152 |
+
* Bundle Product
|
153 |
+
*/
|
154 |
+
public function addBundleProduct($productInfo, $requestInfo = null)
|
155 |
+
{
|
156 |
+
//Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter addBundleProduct', null, 'tracer.log', true);
|
157 |
+
$product = $this->_getProduct($productInfo);
|
158 |
+
$request = $this->_getProductRequest($requestInfo);
|
159 |
+
|
160 |
+
//Mage::log(print_r($request, true), null, 'cart.log', true);
|
161 |
+
|
162 |
+
$quote = parent::addProduct($productInfo, $requestInfo);
|
163 |
+
|
164 |
+
// SkyBox Checkout
|
165 |
+
$this->_getProductApi()->CalculatePrice($product, $request);
|
166 |
+
|
167 |
+
if ($this->_getProductApi()->HasError()) {
|
168 |
+
|
169 |
+
$message = self::MESSAGE_FAIL_TO_ADD_PRODUCT;
|
170 |
+
|
171 |
+
if ($this->_getProductApi()->_getApi()->ErrorRatesNotFound()) {
|
172 |
+
$languageId = $this->getLanguageId();
|
173 |
+
$message = $this->_getProductApi()->_getApi()->getErrorRatesNotFoundMessage($languageId);
|
174 |
+
}
|
175 |
+
Mage::throwException(
|
176 |
+
Mage::helper('sales')->__($message)
|
177 |
+
);
|
178 |
+
return $this;
|
179 |
+
}
|
180 |
+
|
181 |
+
//$productId = $product->getId();
|
182 |
+
$productId = $this->_getProductApi()->getProductId();
|
183 |
+
|
184 |
+
Mage::dispatchEvent('checkout_cart_product_add_before', array(
|
185 |
+
'product' => $product,
|
186 |
+
'request' => $request
|
187 |
+
));
|
188 |
+
|
189 |
+
$_data = $this->_getProductApi()->getProductData();
|
190 |
+
|
191 |
+
Mage::log("Bundleproduct=Cart=" . print_r($_data, true), null, 'cart.log', true);
|
192 |
+
|
193 |
+
$this->_getApi()->AddProductOfCart($_data, $request->getQty());
|
194 |
+
|
195 |
+
if ($this->_getApi()->HasError()) {
|
196 |
+
Mage::throwException(Mage::helper('checkout')->__('[checkout] Failed to add the product to the cart.'));
|
197 |
+
return $this;
|
198 |
+
}
|
199 |
+
|
200 |
+
$productIdSkybox = $this->_getApi()->getParameter(
|
201 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID, "0");
|
202 |
+
|
203 |
+
$this->_updateQuoteItem($productId, $productIdSkybox);
|
204 |
+
return $quote;
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Add product to shopping cart (quote)
|
209 |
+
*
|
210 |
+
* @param int|Mage_Catalog_Model_Product $productInfo
|
211 |
+
* @param mixed $requestInfo
|
212 |
+
* @return Mage_Checkout_Model_Cart
|
213 |
+
*/
|
214 |
+
public function addProduct($productInfo, $requestInfo = null)
|
215 |
+
{
|
216 |
+
if (!$this->isEnable()) {
|
217 |
+
parent::addProduct($productInfo, $requestInfo);
|
218 |
+
return $this;
|
219 |
+
}
|
220 |
+
|
221 |
+
$api_mproduct = Mage::getModel('skyboxcatalog/api_product');
|
222 |
+
|
223 |
+
if (!$api_mproduct->getLocationAllow()) {
|
224 |
+
parent::addProduct($productInfo, $requestInfo);
|
225 |
+
return $this;
|
226 |
+
}
|
227 |
+
|
228 |
+
//Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter addProduct', null, 'tracer.log', true);
|
229 |
+
$product = $this->_getProduct($productInfo);
|
230 |
+
$request = $this->_getProductRequest($requestInfo);
|
231 |
+
|
232 |
+
if ($product->isGrouped()) {
|
233 |
+
Mage::log("Product: " . $product->getName() . " is Grouped", null, 'cart.log', true);
|
234 |
+
return $this->addGroupedProduct($productInfo, $requestInfo);
|
235 |
+
}
|
236 |
+
|
237 |
+
if ($product->getTypeId() == 'bundle') {
|
238 |
+
Mage::log("Product: " . $product->getName() . " is Bundle", null, 'cart.log', true);
|
239 |
+
return $this->addBundleProduct($productInfo, $requestInfo);
|
240 |
+
}
|
241 |
+
|
242 |
+
// SkyBox Checkout
|
243 |
+
$this->_getProductApi()->CalculatePrice($product, $request);
|
244 |
+
|
245 |
+
if ($this->_getProductApi()->HasError()) {
|
246 |
+
|
247 |
+
$message = self::MESSAGE_FAIL_TO_ADD_PRODUCT;
|
248 |
+
|
249 |
+
if ($this->_getProductApi()->_getApi()->ErrorRatesNotFound()) {
|
250 |
+
$languageId = $this->getLanguageId();
|
251 |
+
$message = $this->_getProductApi()->_getApi()->getErrorRatesNotFoundMessage($languageId);
|
252 |
+
}
|
253 |
+
Mage::throwException(
|
254 |
+
Mage::helper('sales')->__($message)
|
255 |
+
);
|
256 |
+
return $this;
|
257 |
+
}
|
258 |
+
|
259 |
+
// $productId = $product->getId();
|
260 |
+
$productId = $this->_getProductApi()->getProductId();
|
261 |
+
|
262 |
+
if ($product->getStockItem()) {
|
263 |
+
$minimumQty = $product->getStockItem()->getMinSaleQty();
|
264 |
+
//If product was not found in cart and there is set minimal qty for it
|
265 |
+
if ($minimumQty && $minimumQty > 0 && $request->getQty() < $minimumQty
|
266 |
+
&& !$this->getQuote()->hasProductId($productId)
|
267 |
+
) {
|
268 |
+
$request->setQty($minimumQty);
|
269 |
+
}
|
270 |
+
}
|
271 |
+
|
272 |
+
/*$product->setTaxPercent(0);
|
273 |
+
$product->setTaxAmount(0);
|
274 |
+
$product->setBaseTaxAmount(0);*/
|
275 |
+
|
276 |
+
Mage::dispatchEvent('checkout_cart_product_add_before', array(
|
277 |
+
'product' => $product,
|
278 |
+
'request' => $request
|
279 |
+
));
|
280 |
+
|
281 |
+
$_data = $this->_getProductApi()->getProductData();
|
282 |
+
Mage::log("product=Cart=" . print_r($_data, true), null, 'cart.log', true);
|
283 |
+
$this->_getApi()->setCurrentProduct($product);
|
284 |
+
$this->_getApi()->AddProductOfCart($_data, $request->getQty());
|
285 |
+
|
286 |
+
if ($this->_getApi()->HasError()) {
|
287 |
+
Mage::throwException(Mage::helper('checkout')->__('[checkout] Failed to add the product to the cart.'));
|
288 |
+
return $this;
|
289 |
+
}
|
290 |
+
|
291 |
+
$productIdSkybox = $this->_getApi()->getParameter(
|
292 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID, "0");
|
293 |
+
|
294 |
+
try {
|
295 |
+
$quote = parent::addProduct($productInfo, $requestInfo);
|
296 |
+
$this->_updateQuoteItem($productId, $productIdSkybox);
|
297 |
+
} catch (\Exception $e) {
|
298 |
+
Mage::log($e->getMessage(), null, 'tracer.log', true);
|
299 |
+
}
|
300 |
+
|
301 |
+
return $quote;
|
302 |
+
}
|
303 |
+
|
304 |
+
// protected function _getProduct($productInfo){
|
305 |
+
// Mage::log('Entro skybox _getProduct', null, 'tracer.log', true);
|
306 |
+
// Mage::log(print_r($productInfo,true), null, 'tracer.log', true);
|
307 |
+
// $product = parent::_getProduct($productInfo);
|
308 |
+
// return $product;
|
309 |
+
// }
|
310 |
+
|
311 |
+
public function addProductsByIds($productIds)
|
312 |
+
{
|
313 |
+
if (!$this->isEnable()) {
|
314 |
+
parent::addProductsByIds($productIds);
|
315 |
+
return $this;
|
316 |
+
}
|
317 |
+
|
318 |
+
//Mage::log('Entro skybox addProductsByIds', null, 'tracer.log', true);
|
319 |
+
//Mage::log(print_r($productIds,true), null, 'tracer.log', true);
|
320 |
+
if (count($productIds) > 0) {
|
321 |
+
foreach ($productIds as $idproduct) {
|
322 |
+
$idproduct = trim($idproduct);
|
323 |
+
if (empty($idproduct)) {
|
324 |
+
continue;
|
325 |
+
}
|
326 |
+
$this->addProduct($idproduct);
|
327 |
+
}
|
328 |
+
}
|
329 |
+
// $quote = parent::addProductsByIds($productIds);
|
330 |
+
return $this;
|
331 |
+
}
|
332 |
+
|
333 |
+
private function _updateQuoteItem($productId, $productIdSkybox)
|
334 |
+
{
|
335 |
+
Mage::log('pas x aqui2', null, 'minicars.log', true);
|
336 |
+
|
337 |
+
|
338 |
+
/**
|
339 |
+
* only one time for call to service start - Active
|
340 |
+
* when do add to cart
|
341 |
+
*/
|
342 |
+
$session = Mage::getSingleton("core/session", array("name" => "frontend"));
|
343 |
+
$session->setData("callToSkyBox", true);
|
344 |
+
//Mage::log("Call true: add to cart", null, 'local.log', true);
|
345 |
+
/**
|
346 |
+
* when do add to cart end - Active
|
347 |
+
*/
|
348 |
+
foreach ($this->getQuote()->getAllItems() as $item) {
|
349 |
+
|
350 |
+
if ($item->getProductId() == $productId) {
|
351 |
+
|
352 |
+
if ($item instanceof Mage_Sales_Model_Quote_Item) {
|
353 |
+
$parentItem = $item->getParentItem();
|
354 |
+
if ($parentItem) {
|
355 |
+
$item = $parentItem;
|
356 |
+
}
|
357 |
+
}
|
358 |
+
/**
|
359 |
+
* Integration 3 start, show price shop in cart*
|
360 |
+
*/
|
361 |
+
$isLocationAllow = false;
|
362 |
+
//$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
|
363 |
+
$typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
|
364 |
+
if ($typeIntegration == 3) {
|
365 |
+
$isLocationAllow = true;
|
366 |
+
}
|
367 |
+
/**
|
368 |
+
* Integration 3 end, show price shop in cart*
|
369 |
+
*/
|
370 |
+
if ($isLocationAllow) {
|
371 |
+
$productModel = Mage::getModel('catalog/product')->load($productId);
|
372 |
+
$total = str_replace(",", "", $productModel->getTotalPriceUSD());
|
373 |
+
$item->setIdProductSkybox($productIdSkybox);
|
374 |
+
|
375 |
+
// Currency amounts in the default currency of that customer
|
376 |
+
$item->setCustomsSkybox($productModel->getCustoms());
|
377 |
+
$item->setShippingSkybox($productModel->getShipping());
|
378 |
+
$item->setInsuranceSkybox($productModel->getInsurance());
|
379 |
+
$item->setPriceSkybox($productModel->getPrice());
|
380 |
+
$item->setTotalSkybox($productModel->getTotalPrice());
|
381 |
+
$item->setRowTotal($total);
|
382 |
+
|
383 |
+
// Currency amounts in the USD Currency
|
384 |
+
$item->setCustomsUsdSkybox($productModel->getCustomsUSD());
|
385 |
+
$item->setShippingUsdSkybox($productModel->getShippingUSD());
|
386 |
+
$item->setInsuranceUsdSkybox($productModel->getInsuranceUSD());
|
387 |
+
$item->setPriceUsdSkybox($productModel->getPriceUSD());
|
388 |
+
$item->setTotalUsdSkybox($productModel->getTotalPriceUSD());
|
389 |
+
|
390 |
+
$item->setGuidSkybox($productModel->getGuidSkybox()); //Set GUID
|
391 |
+
|
392 |
+
|
393 |
+
$item->setBasePriceSkybox($productModel->getBasePrice());
|
394 |
+
$item->setBasePriceUsdSkybox($productModel->getBasePriceUSD());
|
395 |
+
$item->setAdjustTotalSkybox($productModel->getAdjustPrice());
|
396 |
+
$item->setAdjustTotalUsdSkybox($productModel->getAdjustPriceUSD());
|
397 |
+
$item->setAdjustLabelSkybox($productModel->getAdjustLabel());
|
398 |
+
|
399 |
+
//$item->setOriginalCustomPrice($this->_getProductApi()->getTotalPriceUSD());
|
400 |
+
//$item->setOriginalCustomPrice($total);
|
401 |
+
// $item->setOriginalCustomPrice($this->_getProductApi()->getPrice());
|
402 |
+
$prices = str_replace(',', '', $productModel->getPrice());
|
403 |
+
$prices = number_format((float)($prices), 2, ',', '.');
|
404 |
+
$item->setOriginalCustomPrice($prices);
|
405 |
+
//$skybox_total = str_replace(",", "", $this->_getProductApi()->getTotalPrice());
|
406 |
+
$skybox_total = str_replace(",", "", $productModel->getPrice());
|
407 |
+
$row_total = floatval($skybox_total) * $item->getQty();
|
408 |
+
$item->setRowTotalSkybox($row_total);
|
409 |
+
} else {
|
410 |
+
$total = str_replace(",", "", $this->_getProductApi()->getTotalPriceUSD());
|
411 |
+
$item->setIdProductSkybox($productIdSkybox);
|
412 |
+
|
413 |
+
// Currency amounts in the default currency of that customer
|
414 |
+
$item->setCustomsSkybox($this->_getProductApi()->getCustoms());
|
415 |
+
$item->setShippingSkybox($this->_getProductApi()->getShipping());
|
416 |
+
$item->setInsuranceSkybox($this->_getProductApi()->getInsurance());
|
417 |
+
$item->setPriceSkybox($this->_getProductApi()->getPrice());
|
418 |
+
$item->setTotalSkybox($this->_getProductApi()->getTotalPrice());
|
419 |
+
$item->setRowTotal($total);
|
420 |
+
|
421 |
+
// Currency amounts in the USD Currency
|
422 |
+
$item->setCustomsUsdSkybox($this->_getProductApi()->getCustomsUSD());
|
423 |
+
$item->setShippingUsdSkybox($this->_getProductApi()->getShippingUSD());
|
424 |
+
$item->setInsuranceUsdSkybox($this->_getProductApi()->getInsuranceUSD());
|
425 |
+
$item->setPriceUsdSkybox($this->_getProductApi()->getPriceUSD());
|
426 |
+
$item->setTotalUsdSkybox($this->_getProductApi()->getTotalPriceUSD());
|
427 |
+
|
428 |
+
$item->setGuidSkybox($this->_getProductApi()->getGuidSkybox()); //Set GUID
|
429 |
+
|
430 |
+
|
431 |
+
$item->setBasePriceSkybox($this->_getProductApi()->getBasePrice());
|
432 |
+
$item->setBasePriceUsdSkybox($this->_getProductApi()->getBasePriceUSD());
|
433 |
+
$item->setAdjustTotalSkybox($this->_getProductApi()->getAdjustPrice());
|
434 |
+
$item->setAdjustTotalUsdSkybox($this->_getProductApi()->getAdjustPriceUSD());
|
435 |
+
$item->setAdjustLabelSkybox($this->_getProductApi()->getAdjustLabel());
|
436 |
+
|
437 |
+
//$item->setOriginalCustomPrice($this->_getProductApi()->getTotalPriceUSD());
|
438 |
+
//$item->setOriginalCustomPrice($total);
|
439 |
+
// $item->setOriginalCustomPrice($this->_getProductApi()->getPrice());
|
440 |
+
$prices = str_replace(',', '', $this->_getProductApi()->getPrice());
|
441 |
+
$prices = number_format((float)($prices), 2, ',', '.');
|
442 |
+
$item->setOriginalCustomPrice($prices);
|
443 |
+
//$skybox_total = str_replace(",", "", $this->_getProductApi()->getTotalPrice());
|
444 |
+
$skybox_total = str_replace(",", "", $this->_getProductApi()->getPrice());
|
445 |
+
$row_total = floatval($skybox_total) * $item->getQty();
|
446 |
+
$item->setRowTotalSkybox($row_total);
|
447 |
+
}
|
448 |
+
|
449 |
+
|
450 |
+
break;
|
451 |
+
}
|
452 |
+
}
|
453 |
+
|
454 |
+
}
|
455 |
+
|
456 |
+
private function _updateQuoteItem_backup($productId, $productIdSkybox)
|
457 |
+
{
|
458 |
+
Mage::log('pas x aqui2', null, 'minicars.log', true);
|
459 |
+
|
460 |
+
foreach ($this->getQuote()->getAllItems() as $item) {
|
461 |
+
|
462 |
+
if ($item->getProductId() == $productId) {
|
463 |
+
|
464 |
+
if ($item instanceof Mage_Sales_Model_Quote_Item) {
|
465 |
+
$parentItem = $item->getParentItem();
|
466 |
+
if ($parentItem) {
|
467 |
+
$item = $parentItem;
|
468 |
+
}
|
469 |
+
}
|
470 |
+
|
471 |
+
$total = str_replace(",", "", $this->_getProductApi()->getTotalPriceUSD());
|
472 |
+
$item->setIdProductSkybox($productIdSkybox);
|
473 |
+
|
474 |
+
// Currency amounts in the default currency of that customer
|
475 |
+
$item->setCustomsSkybox($this->_getProductApi()->getCustoms());
|
476 |
+
$item->setShippingSkybox($this->_getProductApi()->getShipping());
|
477 |
+
$item->setInsuranceSkybox($this->_getProductApi()->getInsurance());
|
478 |
+
$item->setPriceSkybox($this->_getProductApi()->getPrice());
|
479 |
+
$item->setTotalSkybox($this->_getProductApi()->getTotalPrice());
|
480 |
+
$item->setRowTotal($total);
|
481 |
+
|
482 |
+
// Currency amounts in the USD Currency
|
483 |
+
$item->setCustomsUsdSkybox($this->_getProductApi()->getCustomsUSD());
|
484 |
+
$item->setShippingUsdSkybox($this->_getProductApi()->getShippingUSD());
|
485 |
+
$item->setInsuranceUsdSkybox($this->_getProductApi()->getInsuranceUSD());
|
486 |
+
$item->setPriceUsdSkybox($this->_getProductApi()->getPriceUSD());
|
487 |
+
$item->setTotalUsdSkybox($this->_getProductApi()->getTotalPriceUSD());
|
488 |
+
|
489 |
+
$item->setGuidSkybox($this->_getProductApi()->getGuidSkybox()); //Set GUID
|
490 |
+
|
491 |
+
|
492 |
+
$item->setBasePriceSkybox($this->_getProductApi()->getBasePrice());
|
493 |
+
$item->setBasePriceUsdSkybox($this->_getProductApi()->getBasePriceUSD());
|
494 |
+
$item->setAdjustTotalSkybox($this->_getProductApi()->getAdjustPrice());
|
495 |
+
$item->setAdjustTotalUsdSkybox($this->_getProductApi()->getAdjustPriceUSD());
|
496 |
+
$item->setAdjustLabelSkybox($this->_getProductApi()->getAdjustLabel());
|
497 |
+
|
498 |
+
//$item->setOriginalCustomPrice($this->_getProductApi()->getTotalPriceUSD());
|
499 |
+
//$item->setOriginalCustomPrice($total);
|
500 |
+
// $item->setOriginalCustomPrice($this->_getProductApi()->getPrice());
|
501 |
+
$prices = str_replace(',', '', $this->_getProductApi()->getPrice());
|
502 |
+
$prices = number_format((float)($prices), 2, ',', '.');
|
503 |
+
$item->setOriginalCustomPrice($prices);
|
504 |
+
//$skybox_total = str_replace(",", "", $this->_getProductApi()->getTotalPrice());
|
505 |
+
$skybox_total = str_replace(",", "", $this->_getProductApi()->getPrice());
|
506 |
+
$row_total = floatval($skybox_total) * $item->getQty();
|
507 |
+
$item->setRowTotalSkybox($row_total);
|
508 |
+
|
509 |
+
break;
|
510 |
+
}
|
511 |
+
}
|
512 |
+
|
513 |
+
}
|
514 |
+
|
515 |
+
/**
|
516 |
+
* Remove item from cart
|
517 |
+
*
|
518 |
+
* @param int $itemId
|
519 |
+
* @return Mage_Checkout_Model_Cart
|
520 |
+
*/
|
521 |
+
public function removeItem($itemId)
|
522 |
+
{
|
523 |
+
/**
|
524 |
+
* only one time for call to service start - Active
|
525 |
+
* when do remove
|
526 |
+
*/
|
527 |
+
$session = Mage::getSingleton("core/session", array("name" => "frontend"));
|
528 |
+
$session->setData("callToSkyBox", true);
|
529 |
+
//Mage::log("Call true: remove", null, 'local.log', true);
|
530 |
+
/**
|
531 |
+
* when do remove
|
532 |
+
*/
|
533 |
+
if (!$this->isEnable()) {
|
534 |
+
parent::removeItem($itemId);
|
535 |
+
return $this;
|
536 |
+
}
|
537 |
+
|
538 |
+
$quoteItem = $this->getQuote()->getItemById($itemId);
|
539 |
+
|
540 |
+
if (!$quoteItem) {
|
541 |
+
Mage::throwException(Mage::helper('checkout')->__('ID incorrecto de producto.'));
|
542 |
+
return $this;
|
543 |
+
}
|
544 |
+
Mage::log("|removeItem|" . $quoteItem->getIdProductSkybox());
|
545 |
+
//Realizar llamada al servicio de agregar producto al carrito.
|
546 |
+
$idProductSkybox = $quoteItem->getIdProductSkybox();
|
547 |
+
$this->_getApi()->DeleteProductOfCart($idProductSkybox);
|
548 |
+
|
549 |
+
if ($this->_getApi()->HasError()) {
|
550 |
+
Mage::throwException(Mage::helper('checkout')->__('Error al eliminar producto al carrito.'));
|
551 |
+
return $this;
|
552 |
+
}
|
553 |
+
|
554 |
+
return parent::removeItem($itemId);
|
555 |
+
}
|
556 |
+
|
557 |
+
/**
|
558 |
+
* Update cart items information
|
559 |
+
*
|
560 |
+
* @param array $data
|
561 |
+
* @return Mage_Checkout_Model_Cart
|
562 |
+
*/
|
563 |
+
public function updateItems($data)
|
564 |
+
{
|
565 |
+
/**
|
566 |
+
* only one time for call to service start - Active
|
567 |
+
* when do remove
|
568 |
+
*/
|
569 |
+
$session = Mage::getSingleton("core/session", array("name" => "frontend"));
|
570 |
+
$session->setData("callToSkyBox", true);
|
571 |
+
//Mage::log("Call true: update cart", null, 'local.log', true);
|
572 |
+
/**
|
573 |
+
* when do remove
|
574 |
+
*/
|
575 |
+
if (!$this->isEnable()) {
|
576 |
+
parent::updateItems($data);
|
577 |
+
return $this;
|
578 |
+
}
|
579 |
+
|
580 |
+
Mage::log('pas x aqui5', null, 'cartdetail.log', true);
|
581 |
+
//Mage::log(print_r($data, true), null, 'tracer.log', true);
|
582 |
+
//Mage::log("Skybox_Checkout_Checkout_Model_Cart updateItem");
|
583 |
+
//return parent::updateItems($data);
|
584 |
+
// Mage::dispatchEvent('checkout_cart_update_items_before', array('cart'=>$this, 'info'=>$data));
|
585 |
+
|
586 |
+
foreach ($data as $itemId => $itemInfo) {
|
587 |
+
$item = $this->getQuote()->getItemById($itemId);
|
588 |
+
//Mage::log('item:', null, 'tracer.log', true);
|
589 |
+
//Mage::log(print_r($item->debug(), true), null, 'tracer.log', true);
|
590 |
+
//Mage::log(print_r($itemInfo, true), null, 'tracer.log', true);
|
591 |
+
//Mage::log('updateItems foreach', null, 'tracer.log', true);
|
592 |
+
if (!$item) {
|
593 |
+
//Mage::log('no item', null, 'tracer.log', true);
|
594 |
+
continue;
|
595 |
+
}
|
596 |
+
|
597 |
+
// if(isset($itemInfo['price']) && !empty($itemInfo['price'])) {
|
598 |
+
// //price, base_price, custom_price, row_total, base_row_total, row_total_with_discount, original_custom_price
|
599 |
+
// $price = (float) $itemInfo['price'];
|
600 |
+
// $item->setPrice($price);
|
601 |
+
// $item->setRowTotal($price);
|
602 |
+
// $item->setBasePrice($price);
|
603 |
+
// continue;
|
604 |
+
// }
|
605 |
+
|
606 |
+
if (!empty($itemInfo['remove']) || (isset($itemInfo['qty']) && $itemInfo['qty'] == '0')) {
|
607 |
+
$this->removeItem($itemId);
|
608 |
+
continue;
|
609 |
+
}
|
610 |
+
|
611 |
+
$qty = isset($itemInfo['qty']) ? (float)$itemInfo['qty'] : false;
|
612 |
+
//Mage::log('cantidad: '.$qty, null, 'tracer.log', true);
|
613 |
+
if ($qty > 0) {
|
614 |
+
|
615 |
+
$idProductSkybox = $item->getIdProductSkybox();
|
616 |
+
|
617 |
+
// $this->_getApi()->UpdateProductOfCart($idProductSkybox, $qty);
|
618 |
+
|
619 |
+
$item->setQty($qty);
|
620 |
+
|
621 |
+
//$skybox_total = str_replace(",", "", $item->getTotalSkybox());
|
622 |
+
$skybox_total = str_replace(",", "", $item->getPriceSkybox());
|
623 |
+
|
624 |
+
|
625 |
+
$row_total = floatval($skybox_total) * $item->getQty();
|
626 |
+
$item->setRowTotalSkybox($row_total);
|
627 |
+
|
628 |
+
//Mage::log('fin qty', null, 'tracer.log', true);
|
629 |
+
}
|
630 |
+
}
|
631 |
+
|
632 |
+
// Mage::dispatchEvent('checkout_cart_update_items_after', array('cart'=>$this, 'info'=>$data));
|
633 |
+
$current = parent::updateItems($data);
|
634 |
+
return $current;
|
635 |
+
}
|
636 |
+
|
637 |
+
/**
|
638 |
+
* Mark all quote items as deleted (empty shopping cart)
|
639 |
+
*
|
640 |
+
* @return Mage_Checkout_Model_Cart
|
641 |
+
*/
|
642 |
+
public function truncate()
|
643 |
+
{
|
644 |
+
foreach ($this->getQuote()->getAllItems() as $item) {
|
645 |
+
//Mage::log("truncate() ". $item->getId(), null, 'api.log', true);
|
646 |
+
$this->removeItem($item->getId());
|
647 |
+
}
|
648 |
+
|
649 |
+
parent::truncate();
|
650 |
+
return $this;
|
651 |
+
}
|
652 |
+
|
653 |
+
/**
|
654 |
+
* Mark all quote items as deleted (empty shopping cart)
|
655 |
+
* @return $this
|
656 |
+
*/
|
657 |
+
public function truncateMgCart()
|
658 |
+
{
|
659 |
+
parent::truncate();
|
660 |
+
return $this;
|
661 |
+
}
|
662 |
+
|
663 |
+
/**
|
664 |
+
* Update item in shopping cart (quote)
|
665 |
+
* $requestInfo - either qty (int) or buyRequest in form of array or Varien_Object
|
666 |
+
* $updatingParams - information on how to perform update, passed to Quote->updateItem() method
|
667 |
+
*/
|
668 |
+
public function updateItem($itemId, $requestInfo = null, $updatingParams = null)
|
669 |
+
{
|
670 |
+
if (!$this->isEnable()) {
|
671 |
+
$result = parent::updateItem($itemId, $requestInfo, $updatingParams);
|
672 |
+
return $result;
|
673 |
+
}
|
674 |
+
|
675 |
+
$item = $this->getQuote()->getItemById($itemId);
|
676 |
+
$skyboxProductId = $item->getIdProductSkybox();
|
677 |
+
$_quoteItemId = $item->getId();
|
678 |
+
$_qty = $item->getQty();
|
679 |
+
|
680 |
+
/** @var Mage_Sales_Model_Quote_Item $result */
|
681 |
+
$result = parent::updateItem($itemId, $requestInfo, $updatingParams);
|
682 |
+
$quoteItemId = $result->getId();
|
683 |
+
$qty = $result->getQty();
|
684 |
+
|
685 |
+
// Update Product
|
686 |
+
if ($quoteItemId == $_quoteItemId) {
|
687 |
+
$this->_getApi()->UpdateProductOfCart($skyboxProductId, $qty);
|
688 |
+
} else {
|
689 |
+
// Delete and Add a New Product
|
690 |
+
$this->_getApi()->DeleteProductOfCart($skyboxProductId);
|
691 |
+
|
692 |
+
$product = $result->getProduct();
|
693 |
+
$this->_getProductApi()->CalculatePrice($product, $requestInfo);
|
694 |
+
|
695 |
+
$_data = $this->_getProductApi()->getProductData();
|
696 |
+
$this->_getApi()->setCurrentProduct($product);
|
697 |
+
$this->_getApi()->AddProductOfCart($_data, $qty);
|
698 |
+
|
699 |
+
$productId = $result->getProduct()->getId();
|
700 |
+
$skyboxProductId = $this->_getApi()->getParameter(
|
701 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID, "0");
|
702 |
+
|
703 |
+
$this->_updateQuoteItem($productId, $skyboxProductId);
|
704 |
+
}
|
705 |
+
|
706 |
+
return $result;
|
707 |
+
}
|
708 |
+
|
709 |
+
private function getLanguageId()
|
710 |
+
{
|
711 |
+
$_config = Mage::getModel('skyboxcore/config');
|
712 |
+
$cart = $_config->getSession()->getCartSkybox();
|
713 |
+
$id = $cart->{'LanguageId'};
|
714 |
+
return intval($id);
|
715 |
+
}
|
716 |
+
|
717 |
+
}
|
app/code/community/Skybox/Checkout/Model/Creditmemo/Total.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Skybox_Checkout_Model_Creditmemo_Total extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract{
|
4 |
-
|
5 |
-
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
|
6 |
-
{
|
7 |
-
|
8 |
-
Mage::log("==============================ini", null, 'invoice.log', true);
|
9 |
-
$order = $creditmemo->getOrder();
|
10 |
-
$amount = 20;
|
11 |
-
if ($amount) {
|
12 |
-
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $amount);
|
13 |
-
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $amount);
|
14 |
-
}
|
15 |
-
|
16 |
-
return $this;
|
17 |
-
}
|
18 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Skybox_Checkout_Model_Creditmemo_Total extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract{
|
4 |
+
|
5 |
+
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
|
6 |
+
{
|
7 |
+
|
8 |
+
Mage::log("==============================ini", null, 'invoice.log', true);
|
9 |
+
$order = $creditmemo->getOrder();
|
10 |
+
$amount = 20;
|
11 |
+
if ($amount) {
|
12 |
+
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $amount);
|
13 |
+
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $amount);
|
14 |
+
}
|
15 |
+
|
16 |
+
return $this;
|
17 |
+
}
|
18 |
}
|
app/code/community/Skybox/Checkout/Model/Invoice/Total.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Skybox_Checkout_Model_Invoice_Total extends Mage_Sales_Model_Order_Invoice_Total_Abstract
|
4 |
-
{
|
5 |
-
public function collect($invoice)
|
6 |
-
{
|
7 |
-
|
8 |
-
/*Mage::log("==============================ini", null, 'invoice.log', true);
|
9 |
-
$order = $invoice->getOrder();
|
10 |
-
$amount = 40;
|
11 |
-
if ($amount) {
|
12 |
-
$invoice->setGrandTotal($invoice->getGrandTotal() + $amount);
|
13 |
-
$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $amount);
|
14 |
-
}*/
|
15 |
-
|
16 |
-
return $this;
|
17 |
-
}
|
18 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Skybox_Checkout_Model_Invoice_Total extends Mage_Sales_Model_Order_Invoice_Total_Abstract
|
4 |
+
{
|
5 |
+
public function collect($invoice)
|
6 |
+
{
|
7 |
+
|
8 |
+
/*Mage::log("==============================ini", null, 'invoice.log', true);
|
9 |
+
$order = $invoice->getOrder();
|
10 |
+
$amount = 40;
|
11 |
+
if ($amount) {
|
12 |
+
$invoice->setGrandTotal($invoice->getGrandTotal() + $amount);
|
13 |
+
$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $amount);
|
14 |
+
}*/
|
15 |
+
|
16 |
+
return $this;
|
17 |
+
}
|
18 |
+
}
|
app/code/community/Skybox/Checkout/Model/Observer.php
CHANGED
@@ -1,328 +1,328 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Checkout
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Checkout
|
8 |
-
* @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Checkout_Model_Observer
|
11 |
-
{
|
12 |
-
protected $_typeApi = 'skyboxcheckout/api_checkout';
|
13 |
-
/**
|
14 |
-
* Model instance
|
15 |
-
*
|
16 |
-
* @var Skybox_Checkout_Model_Api_Checkout
|
17 |
-
*/
|
18 |
-
protected $_api = null;
|
19 |
-
|
20 |
-
protected function _getApi()
|
21 |
-
{
|
22 |
-
if (null === $this->_api) {
|
23 |
-
$this->_api = Mage::getModel($this->_typeApi);
|
24 |
-
}
|
25 |
-
|
26 |
-
return $this->_api;
|
27 |
-
}
|
28 |
-
|
29 |
-
protected $_typeProduct = 'skyboxcatalog/api_product';
|
30 |
-
protected $_product = null;
|
31 |
-
protected $_enable = null;
|
32 |
-
|
33 |
-
protected function _getProduct()
|
34 |
-
{
|
35 |
-
if (null === $this->_product) {
|
36 |
-
$this->_product = Mage::getModel($this->_typeProduct);
|
37 |
-
}
|
38 |
-
|
39 |
-
return $this->_product;
|
40 |
-
}
|
41 |
-
|
42 |
-
private function isEnable()
|
43 |
-
{
|
44 |
-
if ($this->_enable === null) {
|
45 |
-
// $value = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
|
46 |
-
$value = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
47 |
-
$this->_enable = $value;
|
48 |
-
}
|
49 |
-
return $this->_enable;
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Metodo inicializador de Skybox Checkout
|
54 |
-
*/
|
55 |
-
public function InitializeSkybox($observer)
|
56 |
-
{
|
57 |
-
$event = $observer->getEvent();
|
58 |
-
Mage::log($event->getName());
|
59 |
-
$this->_getApi()->InitializeBarSkybox();
|
60 |
-
}
|
61 |
-
|
62 |
-
public function RemoveTax(Varien_Event_Observer $observer)
|
63 |
-
{
|
64 |
-
if (!$this->isEnable()) {
|
65 |
-
return;
|
66 |
-
}
|
67 |
-
|
68 |
-
Mage::log('RemoveTax->ini', null, 'SkyObserver.log', true);
|
69 |
-
$customer_id = Mage::getSingleton('customer/session')->getId();
|
70 |
-
$customer = Mage::getModel("customer/customer")->load($customer_id);
|
71 |
-
|
72 |
-
if ($customer->getIsTaxExempt() == 1) {
|
73 |
-
$items = $observer->getEvent()->getQuote()->getAllVisibleItems();
|
74 |
-
foreach ($items as $item) {
|
75 |
-
$item->getProduct()->setTaxClassId(0);
|
76 |
-
}
|
77 |
-
Mage::log('RemoveTax->Tax', null, 'SkyObserver.log', true);
|
78 |
-
}
|
79 |
-
Mage::log('RemoveTax->fin', null, 'SkyObserver.log', true);
|
80 |
-
}
|
81 |
-
|
82 |
-
public function CalculatePriceQuoteItem(Varien_Event_Observer $observer)
|
83 |
-
{
|
84 |
-
if (!$this->isEnable()) {
|
85 |
-
return $this;
|
86 |
-
}
|
87 |
-
Mage::log('Observer->CalculatePriceQuoteItem->ini', null, 'cart.log', true);
|
88 |
-
|
89 |
-
$event = $observer->getEvent();
|
90 |
-
$quote_item = $event->getQuoteItem();
|
91 |
-
|
92 |
-
/*if (count($quote_item)) {
|
93 |
-
foreach ($quote_item as $item) {
|
94 |
-
|
95 |
-
$item->setTaxPercent(0);
|
96 |
-
$item->setTaxAmount(0);
|
97 |
-
$item->setBaseTaxAmount(0);
|
98 |
-
|
99 |
-
$item->setPriceInclTax($item->getPrice());
|
100 |
-
$item->setBasePriceInclTax($item->getBasePrice());
|
101 |
-
$item->setBaseRowTotalInclTax($item->setBaseRowTotal());
|
102 |
-
|
103 |
-
}
|
104 |
-
|
105 |
-
//$quote_item->save();
|
106 |
-
Mage::log('|UpdateParametersQuoteItem|fin', null, 'cart.log', true);
|
107 |
-
}*/
|
108 |
-
|
109 |
-
return $this;
|
110 |
-
|
111 |
-
//$product = $quote_item->getProduct();
|
112 |
-
|
113 |
-
/*$quote = Mage::getSingleton('checkout/session');
|
114 |
-
foreach ($quote->getQuote()->getAllItems() as $item) {
|
115 |
-
if($item->getProductId() == $quote_item->getProductId())
|
116 |
-
{
|
117 |
-
Mage::throwException(
|
118 |
-
Mage::helper('sales')->__('Error al agregar producto al carrito.' . $item->getQty())
|
119 |
-
);
|
120 |
-
break;
|
121 |
-
}
|
122 |
-
}
|
123 |
-
Mage::throwException(
|
124 |
-
Mage::helper('sales')->__('Error al agregar producto al carrito.-')
|
125 |
-
);*/
|
126 |
-
/*$this->_getProduct()->CalculatePrice($quote_item->getProductId(), $product->getFInalPrice());
|
127 |
-
|
128 |
-
if($this->_getProduct()->HasError())
|
129 |
-
{
|
130 |
-
Mage::throwException(
|
131 |
-
Mage::helper('sales')->__('Error al agregar producto al carrito.')
|
132 |
-
);
|
133 |
-
//return $this;
|
134 |
-
}
|
135 |
-
|
136 |
-
Mage::log(json_encode($this->_getProduct()->getResponse()));
|
137 |
-
|
138 |
-
$this->_getApi()->AddProductOfCart($quote_item->getProductId(), 1);
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
if($this->_getApi()->HasError())
|
143 |
-
{
|
144 |
-
Mage::throwException(
|
145 |
-
Mage::helper('sales')->__('Error al agregar producto al carrito')
|
146 |
-
);
|
147 |
-
//return $this;
|
148 |
-
}
|
149 |
-
|
150 |
-
$idProductSkybox = $this->_getApi()->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID, "0");
|
151 |
-
$customsSkybox = $this->_getProduct()->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_CUSTOMS, "0");
|
152 |
-
$shippingSkybox = $this->_getProduct()->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_SHIPPING, "0");
|
153 |
-
$insuranceSkybox = $this->_getProduct()->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_INSURANCE, "0");
|
154 |
-
$totalPrice = $this->_getProduct()->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_TOTAL, "0");
|
155 |
-
|
156 |
-
$quote_item->setIdProductSkybox($idProductSkybox);
|
157 |
-
$quote_item->setCustomsSkybox($customsSkybox);
|
158 |
-
$quote_item->setShippingSkybox($shippingSkybox);
|
159 |
-
$quote_item->setInsureSkybox($insuranceSkybox);
|
160 |
-
$quote_item->setOriginalCustomPrice($totalPrice);
|
161 |
-
|
162 |
-
$quote_item->save();
|
163 |
-
*/
|
164 |
-
//Mage::log('|UpdateParametersQuoteItem| id->' . $quote_item->getId() . " quty->" . $quote_item->getQty(), null, 'cart.log', true);
|
165 |
-
}
|
166 |
-
|
167 |
-
public function changeQuoteAddressSkybox(Varien_Event_Observer $observer)
|
168 |
-
{
|
169 |
-
/**
|
170 |
-
* only one time for call to service start - Active
|
171 |
-
* This always run when you do alter to product as change/delete product
|
172 |
-
*/
|
173 |
-
//$session = Mage::getSingleton("core/session", array("name"=>"frontend"));
|
174 |
-
//$session->setData("callToSkyBox", true);
|
175 |
-
|
176 |
-
/**
|
177 |
-
* only one time for call to service end - Active
|
178 |
-
*/
|
179 |
-
|
180 |
-
if (!$this->isEnable()) {
|
181 |
-
return $this;
|
182 |
-
}
|
183 |
-
|
184 |
-
/**
|
185 |
-
* Integration 3 start, show price shop in cart*
|
186 |
-
*/
|
187 |
-
$allowRunByIntegration3 = true;
|
188 |
-
//$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
|
189 |
-
$typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
|
190 |
-
if ($typeIntegration == 3) {
|
191 |
-
$allowRunByIntegration3 = false;
|
192 |
-
}
|
193 |
-
//Mage::log("Call true22: changeQuoteAddressSkybox", null, 'local.log', true);
|
194 |
-
/**
|
195 |
-
* Integration 3 end, show price shop in cart*
|
196 |
-
*/
|
197 |
-
if ($allowRunByIntegration3) {
|
198 |
-
if ($this->_getApi()->getLocationAllow()) {
|
199 |
-
Mage::log('Observer->changeQuoteAddressSkybox : ini', null, 'TotalSales.log', true);
|
200 |
-
/* $quote Mage_Sales_Model_Quote */
|
201 |
-
$quote = $observer->getEvent()->getQuote();
|
202 |
-
|
203 |
-
/* $address Mage_Sales_Model_Quote_Address */
|
204 |
-
$address = $quote->getShippingAddress();
|
205 |
-
|
206 |
-
$totals = 0;
|
207 |
-
$baseTotals = 0;
|
208 |
-
$totalTax = 0;
|
209 |
-
|
210 |
-
foreach ($quote->getAllItems() as $item) {
|
211 |
-
|
212 |
-
//Estas lineas se agregaron para elimnar el Tax del Carrito
|
213 |
-
/*$item->setTaxPercent(0);
|
214 |
-
$item->setTaxAmount(0);
|
215 |
-
$item->setBaseTaxAmount(0);
|
216 |
-
|
217 |
-
$item->setPriceInclTax($item->getPrice());
|
218 |
-
$item->setBasePriceInclTax($item->getBasePrice());
|
219 |
-
$item->setBaseRowTotalInclTax($item->setBaseRowTotal());*/
|
220 |
-
//------------------------------------------------------------>
|
221 |
-
|
222 |
-
Mage::log('Observer->changeQuoteAddressSkybox->Item->getRowTotalSkybox->' . $item->getRowTotalSkybox(),
|
223 |
-
null, 'TotalSales.log', true);
|
224 |
-
|
225 |
-
$totals += $item->getRowTotalSkybox();
|
226 |
-
}
|
227 |
-
|
228 |
-
$quote->save();
|
229 |
-
|
230 |
-
$baseTotals = $totals;
|
231 |
-
|
232 |
-
//$totalTax1= $address->getTaxAmount();
|
233 |
-
|
234 |
-
//Estas lineas se agregaron para elimnar el Tax del Carrito
|
235 |
-
$address->setTaxAmount(0);
|
236 |
-
$address->setBaseTaxAmount(0);
|
237 |
-
|
238 |
-
$applied_taxes = array();
|
239 |
-
|
240 |
-
$address->setAppliedTaxes($applied_taxes);
|
241 |
-
//------------------------------------------------------------>
|
242 |
-
|
243 |
-
//$address->save();
|
244 |
-
|
245 |
-
//$totales = $address->getTotalAmount("checkout_total1");
|
246 |
-
|
247 |
-
//$tamanio = count($totales);
|
248 |
-
//for ($x=0;$x<$tamanio; $x++) Mage::log('Observer->changeQuoteAddressSkybox->total->' . $totales[$x], null, 'TotalSales.log', true);
|
249 |
-
|
250 |
-
//Mage::log('Observer->changeQuoteAddressSkybox->totales->' . var_dump($totales["subtotal"]), null, 'TotalSales.log', true);
|
251 |
-
//Mage::log('Observer->changeQuoteAddressSkybox->totales->' . $totales, null, 'TotalSales.log', true);
|
252 |
-
|
253 |
-
$totalTax = 0; //$address->getTaxAmount(); //Comentado
|
254 |
-
|
255 |
-
//Recorremos los conceptos agrupados (esto debe modificarse no es lo optimo)
|
256 |
-
/*$conceptsSkybox = json_decode($address->getConceptsSkybox());
|
257 |
-
foreach ($conceptsSkybox as $concept) {
|
258 |
-
$totalTax = $totalTax + $concept->Value;
|
259 |
-
}*/
|
260 |
-
|
261 |
-
$totalRmt = 0;
|
262 |
-
//Recorremos los conceptos agrupados (esto debe modificarse no es lo optimo)
|
263 |
-
/*$rmtSkybox = json_decode($address->getRmtSkybox());
|
264 |
-
foreach ($rmtSkybox as $rmt) {
|
265 |
-
$totalRmt = $totalRmt + $rmt->Value;
|
266 |
-
}*/
|
267 |
-
|
268 |
-
//Mage::log('Observer->changeQuoteAddressSkybox->totalTax1->' . $totalTax1 . ' &totalbase->' . $baseTotals, null, 'TotalSales.log', true);
|
269 |
-
//Mage::log('Observer->changeQuoteAddressSkybox->totalTax->' . $totalTax . ' &totalbase->' . $baseTotals, null, 'TotalSales.log', true);
|
270 |
-
|
271 |
-
/*$address->setSubtotalSkybox($totals);
|
272 |
-
$address->setBaseSubtotalSkybox($baseTotals);
|
273 |
-
$address->setGrandTotalSkybox($totals+$totalTax);
|
274 |
-
$address->setBaseGrandTotalSkybox($baseTotals+$totalTax);*/
|
275 |
-
|
276 |
-
$baseTotals = $address->getBaseGrandTotalSkybox();
|
277 |
-
$totals = $address->getGrandTotalSkybox();
|
278 |
-
|
279 |
-
$address->setPriceInclTax($totals);
|
280 |
-
$address->setBasePriceInclTax($baseTotals);
|
281 |
-
|
282 |
-
$totals = floatval(preg_replace("/[^-0-9\.]/", "", $totals));
|
283 |
-
//$address->setGrandTotal($totals+$totalTax);
|
284 |
-
$address->setGrandTotal($totals + $totalTax);
|
285 |
-
$address->setBaseGrandTotal($baseTotals + $totalTax);
|
286 |
-
|
287 |
-
//$address->save();
|
288 |
-
|
289 |
-
Mage::log('Observer->changeQuoteAddressSkybox : fin', null, 'TotalSales.log', true);
|
290 |
-
|
291 |
-
return $this;
|
292 |
-
}
|
293 |
-
return $this;
|
294 |
-
}
|
295 |
-
|
296 |
-
}
|
297 |
-
|
298 |
-
/**
|
299 |
-
* Hide Skybox Shipping Method
|
300 |
-
* @param Varien_Event_Observer $observer
|
301 |
-
*/
|
302 |
-
public function hideShippingMethod(Varien_Event_Observer $observer)
|
303 |
-
{
|
304 |
-
if (Mage::getDesign()->getArea() === Mage_Core_Model_App_Area::AREA_FRONTEND) {
|
305 |
-
$quote = $observer->getEvent()->getQuote();
|
306 |
-
$store = Mage::app()->getStore($quote->getStoreId());
|
307 |
-
$carriers = Mage::getStoreConfig('carriers', $store);
|
308 |
-
|
309 |
-
$hiddenMethodCode = 'skyboxcheckout_shipping';
|
310 |
-
|
311 |
-
foreach ($carriers as $carrierCode => $carrierConfig) {
|
312 |
-
if ($carrierCode == $hiddenMethodCode) {
|
313 |
-
$store->setConfig("carriers/{$carrierCode}/active", '0');
|
314 |
-
}
|
315 |
-
}
|
316 |
-
}
|
317 |
-
}
|
318 |
-
|
319 |
-
public function paymentMethodIsActive(Varien_Event_Observer $observer)
|
320 |
-
{
|
321 |
-
$event = $observer->getEvent();
|
322 |
-
$result = $event->getResult();
|
323 |
-
|
324 |
-
$allowHelper = Mage::helper('skyboxcore/allow');
|
325 |
-
$result->isAvailable = ($allowHelper->isPriceEnabled()) ? false : true ;
|
326 |
-
|
327 |
-
}
|
328 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Checkout
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Checkout
|
8 |
+
* @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Checkout_Model_Observer
|
11 |
+
{
|
12 |
+
protected $_typeApi = 'skyboxcheckout/api_checkout';
|
13 |
+
/**
|
14 |
+
* Model instance
|
15 |
+
*
|
16 |
+
* @var Skybox_Checkout_Model_Api_Checkout
|
17 |
+
*/
|
18 |
+
protected $_api = null;
|
19 |
+
|
20 |
+
protected function _getApi()
|
21 |
+
{
|
22 |
+
if (null === $this->_api) {
|
23 |
+
$this->_api = Mage::getModel($this->_typeApi);
|
24 |
+
}
|
25 |
+
|
26 |
+
return $this->_api;
|
27 |
+
}
|
28 |
+
|
29 |
+
protected $_typeProduct = 'skyboxcatalog/api_product';
|
30 |
+
protected $_product = null;
|
31 |
+
protected $_enable = null;
|
32 |
+
|
33 |
+
protected function _getProduct()
|
34 |
+
{
|
35 |
+
if (null === $this->_product) {
|
36 |
+
$this->_product = Mage::getModel($this->_typeProduct);
|
37 |
+
}
|
38 |
+
|
39 |
+
return $this->_product;
|
40 |
+
}
|
41 |
+
|
42 |
+
private function isEnable()
|
43 |
+
{
|
44 |
+
if ($this->_enable === null) {
|
45 |
+
// $value = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
|
46 |
+
$value = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
47 |
+
$this->_enable = $value;
|
48 |
+
}
|
49 |
+
return $this->_enable;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Metodo inicializador de Skybox Checkout
|
54 |
+
*/
|
55 |
+
public function InitializeSkybox($observer)
|
56 |
+
{
|
57 |
+
$event = $observer->getEvent();
|
58 |
+
Mage::log($event->getName());
|
59 |
+
$this->_getApi()->InitializeBarSkybox();
|
60 |
+
}
|
61 |
+
|
62 |
+
public function RemoveTax(Varien_Event_Observer $observer)
|
63 |
+
{
|
64 |
+
if (!$this->isEnable()) {
|
65 |
+
return;
|
66 |
+
}
|
67 |
+
|
68 |
+
Mage::log('RemoveTax->ini', null, 'SkyObserver.log', true);
|
69 |
+
$customer_id = Mage::getSingleton('customer/session')->getId();
|
70 |
+
$customer = Mage::getModel("customer/customer")->load($customer_id);
|
71 |
+
|
72 |
+
if ($customer->getIsTaxExempt() == 1) {
|
73 |
+
$items = $observer->getEvent()->getQuote()->getAllVisibleItems();
|
74 |
+
foreach ($items as $item) {
|
75 |
+
$item->getProduct()->setTaxClassId(0);
|
76 |
+
}
|
77 |
+
Mage::log('RemoveTax->Tax', null, 'SkyObserver.log', true);
|
78 |
+
}
|
79 |
+
Mage::log('RemoveTax->fin', null, 'SkyObserver.log', true);
|
80 |
+
}
|
81 |
+
|
82 |
+
public function CalculatePriceQuoteItem(Varien_Event_Observer $observer)
|
83 |
+
{
|
84 |
+
if (!$this->isEnable()) {
|
85 |
+
return $this;
|
86 |
+
}
|
87 |
+
Mage::log('Observer->CalculatePriceQuoteItem->ini', null, 'cart.log', true);
|
88 |
+
|
89 |
+
$event = $observer->getEvent();
|
90 |
+
$quote_item = $event->getQuoteItem();
|
91 |
+
|
92 |
+
/*if (count($quote_item)) {
|
93 |
+
foreach ($quote_item as $item) {
|
94 |
+
|
95 |
+
$item->setTaxPercent(0);
|
96 |
+
$item->setTaxAmount(0);
|
97 |
+
$item->setBaseTaxAmount(0);
|
98 |
+
|
99 |
+
$item->setPriceInclTax($item->getPrice());
|
100 |
+
$item->setBasePriceInclTax($item->getBasePrice());
|
101 |
+
$item->setBaseRowTotalInclTax($item->setBaseRowTotal());
|
102 |
+
|
103 |
+
}
|
104 |
+
|
105 |
+
//$quote_item->save();
|
106 |
+
Mage::log('|UpdateParametersQuoteItem|fin', null, 'cart.log', true);
|
107 |
+
}*/
|
108 |
+
|
109 |
+
return $this;
|
110 |
+
|
111 |
+
//$product = $quote_item->getProduct();
|
112 |
+
|
113 |
+
/*$quote = Mage::getSingleton('checkout/session');
|
114 |
+
foreach ($quote->getQuote()->getAllItems() as $item) {
|
115 |
+
if($item->getProductId() == $quote_item->getProductId())
|
116 |
+
{
|
117 |
+
Mage::throwException(
|
118 |
+
Mage::helper('sales')->__('Error al agregar producto al carrito.' . $item->getQty())
|
119 |
+
);
|
120 |
+
break;
|
121 |
+
}
|
122 |
+
}
|
123 |
+
Mage::throwException(
|
124 |
+
Mage::helper('sales')->__('Error al agregar producto al carrito.-')
|
125 |
+
);*/
|
126 |
+
/*$this->_getProduct()->CalculatePrice($quote_item->getProductId(), $product->getFInalPrice());
|
127 |
+
|
128 |
+
if($this->_getProduct()->HasError())
|
129 |
+
{
|
130 |
+
Mage::throwException(
|
131 |
+
Mage::helper('sales')->__('Error al agregar producto al carrito.')
|
132 |
+
);
|
133 |
+
//return $this;
|
134 |
+
}
|
135 |
+
|
136 |
+
Mage::log(json_encode($this->_getProduct()->getResponse()));
|
137 |
+
|
138 |
+
$this->_getApi()->AddProductOfCart($quote_item->getProductId(), 1);
|
139 |
+
|
140 |
+
|
141 |
+
|
142 |
+
if($this->_getApi()->HasError())
|
143 |
+
{
|
144 |
+
Mage::throwException(
|
145 |
+
Mage::helper('sales')->__('Error al agregar producto al carrito')
|
146 |
+
);
|
147 |
+
//return $this;
|
148 |
+
}
|
149 |
+
|
150 |
+
$idProductSkybox = $this->_getApi()->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID, "0");
|
151 |
+
$customsSkybox = $this->_getProduct()->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_CUSTOMS, "0");
|
152 |
+
$shippingSkybox = $this->_getProduct()->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_SHIPPING, "0");
|
153 |
+
$insuranceSkybox = $this->_getProduct()->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_INSURANCE, "0");
|
154 |
+
$totalPrice = $this->_getProduct()->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_TOTAL, "0");
|
155 |
+
|
156 |
+
$quote_item->setIdProductSkybox($idProductSkybox);
|
157 |
+
$quote_item->setCustomsSkybox($customsSkybox);
|
158 |
+
$quote_item->setShippingSkybox($shippingSkybox);
|
159 |
+
$quote_item->setInsureSkybox($insuranceSkybox);
|
160 |
+
$quote_item->setOriginalCustomPrice($totalPrice);
|
161 |
+
|
162 |
+
$quote_item->save();
|
163 |
+
*/
|
164 |
+
//Mage::log('|UpdateParametersQuoteItem| id->' . $quote_item->getId() . " quty->" . $quote_item->getQty(), null, 'cart.log', true);
|
165 |
+
}
|
166 |
+
|
167 |
+
public function changeQuoteAddressSkybox(Varien_Event_Observer $observer)
|
168 |
+
{
|
169 |
+
/**
|
170 |
+
* only one time for call to service start - Active
|
171 |
+
* This always run when you do alter to product as change/delete product
|
172 |
+
*/
|
173 |
+
//$session = Mage::getSingleton("core/session", array("name"=>"frontend"));
|
174 |
+
//$session->setData("callToSkyBox", true);
|
175 |
+
|
176 |
+
/**
|
177 |
+
* only one time for call to service end - Active
|
178 |
+
*/
|
179 |
+
|
180 |
+
if (!$this->isEnable()) {
|
181 |
+
return $this;
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Integration 3 start, show price shop in cart*
|
186 |
+
*/
|
187 |
+
$allowRunByIntegration3 = true;
|
188 |
+
//$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
|
189 |
+
$typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
|
190 |
+
if ($typeIntegration == 3) {
|
191 |
+
$allowRunByIntegration3 = false;
|
192 |
+
}
|
193 |
+
//Mage::log("Call true22: changeQuoteAddressSkybox", null, 'local.log', true);
|
194 |
+
/**
|
195 |
+
* Integration 3 end, show price shop in cart*
|
196 |
+
*/
|
197 |
+
if ($allowRunByIntegration3) {
|
198 |
+
if ($this->_getApi()->getLocationAllow()) {
|
199 |
+
Mage::log('Observer->changeQuoteAddressSkybox : ini', null, 'TotalSales.log', true);
|
200 |
+
/* $quote Mage_Sales_Model_Quote */
|
201 |
+
$quote = $observer->getEvent()->getQuote();
|
202 |
+
|
203 |
+
/* $address Mage_Sales_Model_Quote_Address */
|
204 |
+
$address = $quote->getShippingAddress();
|
205 |
+
|
206 |
+
$totals = 0;
|
207 |
+
$baseTotals = 0;
|
208 |
+
$totalTax = 0;
|
209 |
+
|
210 |
+
foreach ($quote->getAllItems() as $item) {
|
211 |
+
|
212 |
+
//Estas lineas se agregaron para elimnar el Tax del Carrito
|
213 |
+
/*$item->setTaxPercent(0);
|
214 |
+
$item->setTaxAmount(0);
|
215 |
+
$item->setBaseTaxAmount(0);
|
216 |
+
|
217 |
+
$item->setPriceInclTax($item->getPrice());
|
218 |
+
$item->setBasePriceInclTax($item->getBasePrice());
|
219 |
+
$item->setBaseRowTotalInclTax($item->setBaseRowTotal());*/
|
220 |
+
//------------------------------------------------------------>
|
221 |
+
|
222 |
+
Mage::log('Observer->changeQuoteAddressSkybox->Item->getRowTotalSkybox->' . $item->getRowTotalSkybox(),
|
223 |
+
null, 'TotalSales.log', true);
|
224 |
+
|
225 |
+
$totals += $item->getRowTotalSkybox();
|
226 |
+
}
|
227 |
+
|
228 |
+
$quote->save();
|
229 |
+
|
230 |
+
$baseTotals = $totals;
|
231 |
+
|
232 |
+
//$totalTax1= $address->getTaxAmount();
|
233 |
+
|
234 |
+
//Estas lineas se agregaron para elimnar el Tax del Carrito
|
235 |
+
$address->setTaxAmount(0);
|
236 |
+
$address->setBaseTaxAmount(0);
|
237 |
+
|
238 |
+
$applied_taxes = array();
|
239 |
+
|
240 |
+
$address->setAppliedTaxes($applied_taxes);
|
241 |
+
//------------------------------------------------------------>
|
242 |
+
|
243 |
+
//$address->save();
|
244 |
+
|
245 |
+
//$totales = $address->getTotalAmount("checkout_total1");
|
246 |
+
|
247 |
+
//$tamanio = count($totales);
|
248 |
+
//for ($x=0;$x<$tamanio; $x++) Mage::log('Observer->changeQuoteAddressSkybox->total->' . $totales[$x], null, 'TotalSales.log', true);
|
249 |
+
|
250 |
+
//Mage::log('Observer->changeQuoteAddressSkybox->totales->' . var_dump($totales["subtotal"]), null, 'TotalSales.log', true);
|
251 |
+
//Mage::log('Observer->changeQuoteAddressSkybox->totales->' . $totales, null, 'TotalSales.log', true);
|
252 |
+
|
253 |
+
$totalTax = 0; //$address->getTaxAmount(); //Comentado
|
254 |
+
|
255 |
+
//Recorremos los conceptos agrupados (esto debe modificarse no es lo optimo)
|
256 |
+
/*$conceptsSkybox = json_decode($address->getConceptsSkybox());
|
257 |
+
foreach ($conceptsSkybox as $concept) {
|
258 |
+
$totalTax = $totalTax + $concept->Value;
|
259 |
+
}*/
|
260 |
+
|
261 |
+
$totalRmt = 0;
|
262 |
+
//Recorremos los conceptos agrupados (esto debe modificarse no es lo optimo)
|
263 |
+
/*$rmtSkybox = json_decode($address->getRmtSkybox());
|
264 |
+
foreach ($rmtSkybox as $rmt) {
|
265 |
+
$totalRmt = $totalRmt + $rmt->Value;
|
266 |
+
}*/
|
267 |
+
|
268 |
+
//Mage::log('Observer->changeQuoteAddressSkybox->totalTax1->' . $totalTax1 . ' &totalbase->' . $baseTotals, null, 'TotalSales.log', true);
|
269 |
+
//Mage::log('Observer->changeQuoteAddressSkybox->totalTax->' . $totalTax . ' &totalbase->' . $baseTotals, null, 'TotalSales.log', true);
|
270 |
+
|
271 |
+
/*$address->setSubtotalSkybox($totals);
|
272 |
+
$address->setBaseSubtotalSkybox($baseTotals);
|
273 |
+
$address->setGrandTotalSkybox($totals+$totalTax);
|
274 |
+
$address->setBaseGrandTotalSkybox($baseTotals+$totalTax);*/
|
275 |
+
|
276 |
+
$baseTotals = $address->getBaseGrandTotalSkybox();
|
277 |
+
$totals = $address->getGrandTotalSkybox();
|
278 |
+
|
279 |
+
$address->setPriceInclTax($totals);
|
280 |
+
$address->setBasePriceInclTax($baseTotals);
|
281 |
+
|
282 |
+
$totals = floatval(preg_replace("/[^-0-9\.]/", "", $totals));
|
283 |
+
//$address->setGrandTotal($totals+$totalTax);
|
284 |
+
$address->setGrandTotal($totals + $totalTax);
|
285 |
+
$address->setBaseGrandTotal($baseTotals + $totalTax);
|
286 |
+
|
287 |
+
//$address->save();
|
288 |
+
|
289 |
+
Mage::log('Observer->changeQuoteAddressSkybox : fin', null, 'TotalSales.log', true);
|
290 |
+
|
291 |
+
return $this;
|
292 |
+
}
|
293 |
+
return $this;
|
294 |
+
}
|
295 |
+
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* Hide Skybox Shipping Method
|
300 |
+
* @param Varien_Event_Observer $observer
|
301 |
+
*/
|
302 |
+
public function hideShippingMethod(Varien_Event_Observer $observer)
|
303 |
+
{
|
304 |
+
if (Mage::getDesign()->getArea() === Mage_Core_Model_App_Area::AREA_FRONTEND) {
|
305 |
+
$quote = $observer->getEvent()->getQuote();
|
306 |
+
$store = Mage::app()->getStore($quote->getStoreId());
|
307 |
+
$carriers = Mage::getStoreConfig('carriers', $store);
|
308 |
+
|
309 |
+
$hiddenMethodCode = 'skyboxcheckout_shipping';
|
310 |
+
|
311 |
+
foreach ($carriers as $carrierCode => $carrierConfig) {
|
312 |
+
if ($carrierCode == $hiddenMethodCode) {
|
313 |
+
$store->setConfig("carriers/{$carrierCode}/active", '0');
|
314 |
+
}
|
315 |
+
}
|
316 |
+
}
|
317 |
+
}
|
318 |
+
|
319 |
+
public function paymentMethodIsActive(Varien_Event_Observer $observer)
|
320 |
+
{
|
321 |
+
$event = $observer->getEvent();
|
322 |
+
$result = $event->getResult();
|
323 |
+
|
324 |
+
$allowHelper = Mage::helper('skyboxcore/allow');
|
325 |
+
$result->isAvailable = ($allowHelper->isPriceEnabled()) ? false : true ;
|
326 |
+
|
327 |
+
}
|
328 |
+
}
|
app/code/community/Skybox/Checkout/Model/Pay.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
<?php
|
2 |
-
class Skybox_Checkout_Model_Pay extends Mage_Payment_Model_Method_Abstract
|
3 |
-
{
|
4 |
-
|
5 |
-
protected $_code = 'skyboxcheckout_pay';
|
6 |
-
|
7 |
-
protected $_isInitializeNeeded = true;
|
8 |
-
protected $_canUseInternal = true;
|
9 |
-
protected $_canUseForMultishipping = false;
|
10 |
-
protected $_canUseCheckout = false;
|
11 |
-
|
12 |
}
|
1 |
+
<?php
|
2 |
+
class Skybox_Checkout_Model_Pay extends Mage_Payment_Model_Method_Abstract
|
3 |
+
{
|
4 |
+
|
5 |
+
protected $_code = 'skyboxcheckout_pay';
|
6 |
+
|
7 |
+
protected $_isInitializeNeeded = true;
|
8 |
+
protected $_canUseInternal = true;
|
9 |
+
protected $_canUseForMultishipping = false;
|
10 |
+
protected $_canUseCheckout = false;
|
11 |
+
|
12 |
}
|
app/code/community/Skybox/Checkout/Model/Quote/Address/Total/Rmt.php
CHANGED
@@ -1,112 +1,112 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Checkout
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Checkout
|
8 |
-
* @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Checkout_Model_Quote_Address_Total_Rmt extends Mage_Sales_Model_Quote_Address_Total_Abstract
|
11 |
-
{
|
12 |
-
/**
|
13 |
-
* Esta función es llamada cada vez que Magento requiere calcular los
|
14 |
-
* totales por cualquier motivo: carrito actualizado, usuario se logea,
|
15 |
-
* aplicar un cupón, selección de medios de envío, de pago, etc.
|
16 |
-
*
|
17 |
-
* Se trata de calcular lo que queremos añadir de recargo y actualizar
|
18 |
-
* el total del carrito (Magento itera sobre los totales y cada uno añade
|
19 |
-
* su parte)
|
20 |
-
**/
|
21 |
-
public function collect(Mage_Sales_Model_Quote_Address $address)
|
22 |
-
{
|
23 |
-
|
24 |
-
parent::collect($address); //Comentado por verificar
|
25 |
-
|
26 |
-
// Si no hay items, no hay nada que hacer
|
27 |
-
$items = $this->_getAddressItems($address);
|
28 |
-
if (!count($items)) {
|
29 |
-
return $this;
|
30 |
-
}
|
31 |
-
|
32 |
-
$quote = $address->getQuote();
|
33 |
-
if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
|
34 |
-
return $this;
|
35 |
-
}
|
36 |
-
|
37 |
-
//Verificar esta parte porque se podria raelizar desde el Total
|
38 |
-
|
39 |
-
|
40 |
-
return $this;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Esta función es llamada por Magento cuando quiere mostrar los totales en pantalla.
|
45 |
-
*
|
46 |
-
* El cálculo ya se habrá hecho y deberíamos guardarlo en algún sitio para aquí,
|
47 |
-
* simplemente retornar el valor formateado y que Magento lo muestre.
|
48 |
-
*/
|
49 |
-
public function fetch(Mage_Sales_Model_Quote_Address $address)
|
50 |
-
{
|
51 |
-
parent::fetch($address);
|
52 |
-
|
53 |
-
if (!$this->isEnable()) {
|
54 |
-
return $this;
|
55 |
-
}
|
56 |
-
|
57 |
-
$quote = $address->getQuote();
|
58 |
-
if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
|
59 |
-
return $this;
|
60 |
-
}
|
61 |
-
|
62 |
-
$skyboxRMT = $address->getRmtSkybox();
|
63 |
-
|
64 |
-
if ($skyboxRMT) {
|
65 |
-
$RmtSkyboxjson = json_decode($skyboxRMT);
|
66 |
-
|
67 |
-
Mage::log("quote->address->rmt->fetch : ini", null, 'TotalSales.log', true);
|
68 |
-
|
69 |
-
$i = 0;
|
70 |
-
foreach ($RmtSkyboxjson as $item) {
|
71 |
-
$i += 1;
|
72 |
-
$value = $item->Value;
|
73 |
-
$value = str_replace(',', '', $value);
|
74 |
-
// $value = abs($value);
|
75 |
-
|
76 |
-
$address->addTotal(array(
|
77 |
-
'code' => 'checkout_total_rmt' . $i,
|
78 |
-
'title' => $item->Concept,
|
79 |
-
'value' => $value
|
80 |
-
));
|
81 |
-
Mage::log("quote->address->rmt->fetch(Concepts)->" . $item->Concept . "=" . $item->Value, null,
|
82 |
-
'TotalSales.log', true);
|
83 |
-
}
|
84 |
-
|
85 |
-
Mage::log("quote->address->rmt->fetch : fini", null, 'TotalSales.log', true);
|
86 |
-
|
87 |
-
}
|
88 |
-
return $this;
|
89 |
-
}
|
90 |
-
|
91 |
-
private function isEnable()
|
92 |
-
{
|
93 |
-
/** @var Skybox_Core_Model_Api_Restful $api_restful */
|
94 |
-
$api_restful = Mage::getModel('skyboxcore/api_restful');
|
95 |
-
$activation = $api_restful->isModuleEnable();
|
96 |
-
|
97 |
-
if (!$activation) {
|
98 |
-
return false;
|
99 |
-
}
|
100 |
-
|
101 |
-
/** @var Skybox_Core_Helper_Allow $allowHelper */
|
102 |
-
$allowHelper = Mage::helper('skyboxcore/allow');
|
103 |
-
|
104 |
-
$locationAllow = $allowHelper->getLocationAllow();
|
105 |
-
|
106 |
-
if (!$locationAllow) {
|
107 |
-
return false;
|
108 |
-
}
|
109 |
-
|
110 |
-
return true;
|
111 |
-
}
|
112 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Checkout
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Checkout
|
8 |
+
* @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Checkout_Model_Quote_Address_Total_Rmt extends Mage_Sales_Model_Quote_Address_Total_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Esta función es llamada cada vez que Magento requiere calcular los
|
14 |
+
* totales por cualquier motivo: carrito actualizado, usuario se logea,
|
15 |
+
* aplicar un cupón, selección de medios de envío, de pago, etc.
|
16 |
+
*
|
17 |
+
* Se trata de calcular lo que queremos añadir de recargo y actualizar
|
18 |
+
* el total del carrito (Magento itera sobre los totales y cada uno añade
|
19 |
+
* su parte)
|
20 |
+
**/
|
21 |
+
public function collect(Mage_Sales_Model_Quote_Address $address)
|
22 |
+
{
|
23 |
+
|
24 |
+
parent::collect($address); //Comentado por verificar
|
25 |
+
|
26 |
+
// Si no hay items, no hay nada que hacer
|
27 |
+
$items = $this->_getAddressItems($address);
|
28 |
+
if (!count($items)) {
|
29 |
+
return $this;
|
30 |
+
}
|
31 |
+
|
32 |
+
$quote = $address->getQuote();
|
33 |
+
if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
|
34 |
+
return $this;
|
35 |
+
}
|
36 |
+
|
37 |
+
//Verificar esta parte porque se podria raelizar desde el Total
|
38 |
+
|
39 |
+
|
40 |
+
return $this;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Esta función es llamada por Magento cuando quiere mostrar los totales en pantalla.
|
45 |
+
*
|
46 |
+
* El cálculo ya se habrá hecho y deberíamos guardarlo en algún sitio para aquí,
|
47 |
+
* simplemente retornar el valor formateado y que Magento lo muestre.
|
48 |
+
*/
|
49 |
+
public function fetch(Mage_Sales_Model_Quote_Address $address)
|
50 |
+
{
|
51 |
+
parent::fetch($address);
|
52 |
+
|
53 |
+
if (!$this->isEnable()) {
|
54 |
+
return $this;
|
55 |
+
}
|
56 |
+
|
57 |
+
$quote = $address->getQuote();
|
58 |
+
if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
|
59 |
+
return $this;
|
60 |
+
}
|
61 |
+
|
62 |
+
$skyboxRMT = $address->getRmtSkybox();
|
63 |
+
|
64 |
+
if ($skyboxRMT) {
|
65 |
+
$RmtSkyboxjson = json_decode($skyboxRMT);
|
66 |
+
|
67 |
+
Mage::log("quote->address->rmt->fetch : ini", null, 'TotalSales.log', true);
|
68 |
+
|
69 |
+
$i = 0;
|
70 |
+
foreach ($RmtSkyboxjson as $item) {
|
71 |
+
$i += 1;
|
72 |
+
$value = $item->Value;
|
73 |
+
$value = str_replace(',', '', $value);
|
74 |
+
// $value = abs($value);
|
75 |
+
|
76 |
+
$address->addTotal(array(
|
77 |
+
'code' => 'checkout_total_rmt' . $i,
|
78 |
+
'title' => $item->Concept,
|
79 |
+
'value' => $value
|
80 |
+
));
|
81 |
+
Mage::log("quote->address->rmt->fetch(Concepts)->" . $item->Concept . "=" . $item->Value, null,
|
82 |
+
'TotalSales.log', true);
|
83 |
+
}
|
84 |
+
|
85 |
+
Mage::log("quote->address->rmt->fetch : fini", null, 'TotalSales.log', true);
|
86 |
+
|
87 |
+
}
|
88 |
+
return $this;
|
89 |
+
}
|
90 |
+
|
91 |
+
private function isEnable()
|
92 |
+
{
|
93 |
+
/** @var Skybox_Core_Model_Api_Restful $api_restful */
|
94 |
+
$api_restful = Mage::getModel('skyboxcore/api_restful');
|
95 |
+
$activation = $api_restful->isModuleEnable();
|
96 |
+
|
97 |
+
if (!$activation) {
|
98 |
+
return false;
|
99 |
+
}
|
100 |
+
|
101 |
+
/** @var Skybox_Core_Helper_Allow $allowHelper */
|
102 |
+
$allowHelper = Mage::helper('skyboxcore/allow');
|
103 |
+
|
104 |
+
$locationAllow = $allowHelper->getLocationAllow();
|
105 |
+
|
106 |
+
if (!$locationAllow) {
|
107 |
+
return false;
|
108 |
+
}
|
109 |
+
|
110 |
+
return true;
|
111 |
+
}
|
112 |
+
}
|
app/code/community/Skybox/Checkout/Model/Quote/Address/Total/Tax.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Skybox_Checkout_Model_Quote_Address_Total_Tax extends Mage_Sales_Model_Quote_Address_Total_Abstract
|
4 |
-
{
|
5 |
-
|
6 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Skybox_Checkout_Model_Quote_Address_Total_Tax extends Mage_Sales_Model_Quote_Address_Total_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
}
|
app/code/community/Skybox/Checkout/Model/Quote/Item.php
CHANGED
@@ -1,36 +1,36 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Checkout
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Checkout
|
8 |
-
* @copyright Copyright (c) 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Checkout_Model_Quote_Item extends Mage_Sales_Model_Quote_Item
|
11 |
-
{
|
12 |
-
/**
|
13 |
-
* Declare quote item quantity
|
14 |
-
*
|
15 |
-
* @param float $qty
|
16 |
-
* @return Mage_Sales_Model_Quote_Item
|
17 |
-
*/
|
18 |
-
public function setQty($qty)
|
19 |
-
{
|
20 |
-
$oldQty = $this->_getData('qty');
|
21 |
-
|
22 |
-
parent::setQty($qty);
|
23 |
-
$qty = $this->getQty();
|
24 |
-
|
25 |
-
if ($oldQty != $qty) {
|
26 |
-
$skyboxProductId = $this->getIdProductSkybox();
|
27 |
-
|
28 |
-
if ($skyboxProductId) {
|
29 |
-
$api_checkout = Mage::getModel('skyboxcheckout/api_checkout');
|
30 |
-
$api_checkout->UpdateProductOfCart($skyboxProductId, $qty);
|
31 |
-
}
|
32 |
-
}
|
33 |
-
return $this;
|
34 |
-
}
|
35 |
-
|
36 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Checkout
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Checkout
|
8 |
+
* @copyright Copyright (c) 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Checkout_Model_Quote_Item extends Mage_Sales_Model_Quote_Item
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Declare quote item quantity
|
14 |
+
*
|
15 |
+
* @param float $qty
|
16 |
+
* @return Mage_Sales_Model_Quote_Item
|
17 |
+
*/
|
18 |
+
public function setQty($qty)
|
19 |
+
{
|
20 |
+
$oldQty = $this->_getData('qty');
|
21 |
+
|
22 |
+
parent::setQty($qty);
|
23 |
+
$qty = $this->getQty();
|
24 |
+
|
25 |
+
if ($oldQty != $qty) {
|
26 |
+
$skyboxProductId = $this->getIdProductSkybox();
|
27 |
+
|
28 |
+
if ($skyboxProductId) {
|
29 |
+
$api_checkout = Mage::getModel('skyboxcheckout/api_checkout');
|
30 |
+
$api_checkout->UpdateProductOfCart($skyboxProductId, $qty);
|
31 |
+
}
|
32 |
+
}
|
33 |
+
return $this;
|
34 |
+
}
|
35 |
+
|
36 |
+
}
|
app/code/community/Skybox/Checkout/Model/Quote/SubTotal.php
CHANGED
@@ -1,136 +1,136 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Skybox_Checkout_Model_Quote_SubTotal extends Mage_Sales_Model_Quote_Address_Total_Abstract
|
4 |
-
{
|
5 |
-
|
6 |
-
// Cantidad del recargo sin impuestos
|
7 |
-
var $_amount;
|
8 |
-
|
9 |
-
protected $_api = null;
|
10 |
-
protected $_product = null;
|
11 |
-
|
12 |
-
/* @return Skybox_Checkout_Model_Api_Checkout */
|
13 |
-
protected function _getApi()
|
14 |
-
{
|
15 |
-
if (null === $this->_api) {
|
16 |
-
$this->_api = Mage::getModel('skyboxcheckout/api_checkout');
|
17 |
-
}
|
18 |
-
return $this->_api;
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Return Skybox API Product
|
23 |
-
*
|
24 |
-
* @return Skybox_Catalogo_Model_Api_Product
|
25 |
-
*/
|
26 |
-
protected function _getProductApi()
|
27 |
-
{
|
28 |
-
if (null === $this->_product) {
|
29 |
-
$this->_product = Mage::getModel('skyboxcatalog/api_product');
|
30 |
-
}
|
31 |
-
return $this->_product;
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Esta función es llamada cada vez que Magento requiere calcular los
|
36 |
-
* totales por cualquier motivo: carrito actualizado, usuario se logea,
|
37 |
-
* aplicar un cupón, selección de medios de envío, de pago, etc.
|
38 |
-
*
|
39 |
-
* Se trata de calcular lo que queremos añadir de recargo y actualizar
|
40 |
-
* el total del carrito (Magento itera sobre los totales y cada uno añade
|
41 |
-
* su parte)
|
42 |
-
**/
|
43 |
-
public function collect(Mage_Sales_Model_Quote_Address $address)
|
44 |
-
{
|
45 |
-
|
46 |
-
parent::collect($address); //Comentado por verificar
|
47 |
-
|
48 |
-
// Si no hay items, no hay nada que hacer
|
49 |
-
$items = $this->_getAddressItems($address);
|
50 |
-
if (!count($items)) {
|
51 |
-
return $this;
|
52 |
-
}
|
53 |
-
|
54 |
-
$quote = $address->getQuote();
|
55 |
-
if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
|
56 |
-
return $this;
|
57 |
-
}
|
58 |
-
|
59 |
-
|
60 |
-
//$address->setSubTotal(100);
|
61 |
-
//$address->setBaseSubTotal(100);
|
62 |
-
|
63 |
-
$address->setRowtotalResult(100);
|
64 |
-
|
65 |
-
//$address->setTaxAmount(0);
|
66 |
-
|
67 |
-
//$address->save(); //Guardamos los Cambios
|
68 |
-
Mage::log("quote->address->collect->getSubTotal->" . $address->getSubTotal(), null, 'SubTotalSales.log', true);
|
69 |
-
Mage::log("quote->address->collect->getGrandTotal->" . $address->getGrandTotal(), null, 'SubTotalSales.log',
|
70 |
-
true);
|
71 |
-
|
72 |
-
Mage::log("quote->address->collect->Total->" . $totalskybox, null, 'SubTotalSales.log', true);
|
73 |
-
Mage::log("quote->address->collect : fin", null, 'SubTotalSales.log', true);
|
74 |
-
|
75 |
-
return $this;
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Esta función es llamada por Magento cuando quiere mostrar los totales en pantalla.
|
80 |
-
*
|
81 |
-
* El cálculo ya se habrá hecho y deberíamos guardarlo en algún sitio para aquí,
|
82 |
-
* simplemente retornar el valor formateado y que Magento lo muestre.
|
83 |
-
*/
|
84 |
-
public function fetch(Mage_Sales_Model_Quote_Address $address)
|
85 |
-
{
|
86 |
-
parent::fetch($address); //Comentado por verificar
|
87 |
-
|
88 |
-
if (!$this->isEnable()) {
|
89 |
-
return $this;
|
90 |
-
}
|
91 |
-
|
92 |
-
$quote = $address->getQuote();
|
93 |
-
if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
|
94 |
-
return $this;
|
95 |
-
}
|
96 |
-
|
97 |
-
$_conceptsSkybox = $address->getConceptsSkybox();
|
98 |
-
|
99 |
-
if ($_conceptsSkybox) {
|
100 |
-
|
101 |
-
$ConceptsSkyboxjson = json_decode($address->getConceptsSkybox());
|
102 |
-
|
103 |
-
$address->addTotal(array(
|
104 |
-
'code' => 'subtotal',
|
105 |
-
'title' => 'Sub Total',
|
106 |
-
'value' => 150
|
107 |
-
));
|
108 |
-
Mage::log("quote->address->fetch : fin", null, 'SubTotalSales.log', true);
|
109 |
-
}
|
110 |
-
|
111 |
-
return $this;
|
112 |
-
}
|
113 |
-
|
114 |
-
private function isEnable()
|
115 |
-
{
|
116 |
-
/** @var Skybox_Core_Model_Api_Restful $api_restful */
|
117 |
-
$api_restful = Mage::getModel('skyboxcore/api_restful');
|
118 |
-
$activation = $api_restful->isModuleEnable();
|
119 |
-
|
120 |
-
if (!$activation) {
|
121 |
-
return false;
|
122 |
-
}
|
123 |
-
|
124 |
-
/** @var Skybox_Core_Helper_Allow $allowHelper */
|
125 |
-
$allowHelper = Mage::helper('skyboxcore/allow');
|
126 |
-
|
127 |
-
$locationAllow = $allowHelper->getLocationAllow();
|
128 |
-
|
129 |
-
if (!$locationAllow) {
|
130 |
-
return false;
|
131 |
-
}
|
132 |
-
|
133 |
-
return true;
|
134 |
-
}
|
135 |
-
}
|
136 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Skybox_Checkout_Model_Quote_SubTotal extends Mage_Sales_Model_Quote_Address_Total_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
// Cantidad del recargo sin impuestos
|
7 |
+
var $_amount;
|
8 |
+
|
9 |
+
protected $_api = null;
|
10 |
+
protected $_product = null;
|
11 |
+
|
12 |
+
/* @return Skybox_Checkout_Model_Api_Checkout */
|
13 |
+
protected function _getApi()
|
14 |
+
{
|
15 |
+
if (null === $this->_api) {
|
16 |
+
$this->_api = Mage::getModel('skyboxcheckout/api_checkout');
|
17 |
+
}
|
18 |
+
return $this->_api;
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Return Skybox API Product
|
23 |
+
*
|
24 |
+
* @return Skybox_Catalogo_Model_Api_Product
|
25 |
+
*/
|
26 |
+
protected function _getProductApi()
|
27 |
+
{
|
28 |
+
if (null === $this->_product) {
|
29 |
+
$this->_product = Mage::getModel('skyboxcatalog/api_product');
|
30 |
+
}
|
31 |
+
return $this->_product;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Esta función es llamada cada vez que Magento requiere calcular los
|
36 |
+
* totales por cualquier motivo: carrito actualizado, usuario se logea,
|
37 |
+
* aplicar un cupón, selección de medios de envío, de pago, etc.
|
38 |
+
*
|
39 |
+
* Se trata de calcular lo que queremos añadir de recargo y actualizar
|
40 |
+
* el total del carrito (Magento itera sobre los totales y cada uno añade
|
41 |
+
* su parte)
|
42 |
+
**/
|
43 |
+
public function collect(Mage_Sales_Model_Quote_Address $address)
|
44 |
+
{
|
45 |
+
|
46 |
+
parent::collect($address); //Comentado por verificar
|
47 |
+
|
48 |
+
// Si no hay items, no hay nada que hacer
|
49 |
+
$items = $this->_getAddressItems($address);
|
50 |
+
if (!count($items)) {
|
51 |
+
return $this;
|
52 |
+
}
|
53 |
+
|
54 |
+
$quote = $address->getQuote();
|
55 |
+
if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
|
56 |
+
return $this;
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
//$address->setSubTotal(100);
|
61 |
+
//$address->setBaseSubTotal(100);
|
62 |
+
|
63 |
+
$address->setRowtotalResult(100);
|
64 |
+
|
65 |
+
//$address->setTaxAmount(0);
|
66 |
+
|
67 |
+
//$address->save(); //Guardamos los Cambios
|
68 |
+
Mage::log("quote->address->collect->getSubTotal->" . $address->getSubTotal(), null, 'SubTotalSales.log', true);
|
69 |
+
Mage::log("quote->address->collect->getGrandTotal->" . $address->getGrandTotal(), null, 'SubTotalSales.log',
|
70 |
+
true);
|
71 |
+
|
72 |
+
Mage::log("quote->address->collect->Total->" . $totalskybox, null, 'SubTotalSales.log', true);
|
73 |
+
Mage::log("quote->address->collect : fin", null, 'SubTotalSales.log', true);
|
74 |
+
|
75 |
+
return $this;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Esta función es llamada por Magento cuando quiere mostrar los totales en pantalla.
|
80 |
+
*
|
81 |
+
* El cálculo ya se habrá hecho y deberíamos guardarlo en algún sitio para aquí,
|
82 |
+
* simplemente retornar el valor formateado y que Magento lo muestre.
|
83 |
+
*/
|
84 |
+
public function fetch(Mage_Sales_Model_Quote_Address $address)
|
85 |
+
{
|
86 |
+
parent::fetch($address); //Comentado por verificar
|
87 |
+
|
88 |
+
if (!$this->isEnable()) {
|
89 |
+
return $this;
|
90 |
+
}
|
91 |
+
|
92 |
+
$quote = $address->getQuote();
|
93 |
+
if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
|
94 |
+
return $this;
|
95 |
+
}
|
96 |
+
|
97 |
+
$_conceptsSkybox = $address->getConceptsSkybox();
|
98 |
+
|
99 |
+
if ($_conceptsSkybox) {
|
100 |
+
|
101 |
+
$ConceptsSkyboxjson = json_decode($address->getConceptsSkybox());
|
102 |
+
|
103 |
+
$address->addTotal(array(
|
104 |
+
'code' => 'subtotal',
|
105 |
+
'title' => 'Sub Total',
|
106 |
+
'value' => 150
|
107 |
+
));
|
108 |
+
Mage::log("quote->address->fetch : fin", null, 'SubTotalSales.log', true);
|
109 |
+
}
|
110 |
+
|
111 |
+
return $this;
|
112 |
+
}
|
113 |
+
|
114 |
+
private function isEnable()
|
115 |
+
{
|
116 |
+
/** @var Skybox_Core_Model_Api_Restful $api_restful */
|
117 |
+
$api_restful = Mage::getModel('skyboxcore/api_restful');
|
118 |
+
$activation = $api_restful->isModuleEnable();
|
119 |
+
|
120 |
+
if (!$activation) {
|
121 |
+
return false;
|
122 |
+
}
|
123 |
+
|
124 |
+
/** @var Skybox_Core_Helper_Allow $allowHelper */
|
125 |
+
$allowHelper = Mage::helper('skyboxcore/allow');
|
126 |
+
|
127 |
+
$locationAllow = $allowHelper->getLocationAllow();
|
128 |
+
|
129 |
+
if (!$locationAllow) {
|
130 |
+
return false;
|
131 |
+
}
|
132 |
+
|
133 |
+
return true;
|
134 |
+
}
|
135 |
+
}
|
136 |
+
|
app/code/community/Skybox/Checkout/Model/Quote/Total.php
CHANGED
@@ -1,304 +1,304 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Checkout
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Checkout
|
8 |
-
* @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Checkout_Model_Quote_Total extends Mage_Sales_Model_Quote_Address_Total_Abstract
|
11 |
-
{
|
12 |
-
|
13 |
-
// Cantidad del recargo sin impuestos
|
14 |
-
// var $_amount;
|
15 |
-
|
16 |
-
protected $_api = null;
|
17 |
-
protected $_product = null;
|
18 |
-
|
19 |
-
/* @return Skybox_Checkout_Model_Api_Checkout */
|
20 |
-
protected function _getApi()
|
21 |
-
{
|
22 |
-
if (null === $this->_api) {
|
23 |
-
$this->_api = Mage::getModel('skyboxcheckout/api_checkout');
|
24 |
-
}
|
25 |
-
return $this->_api;
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Return Skybox API Product
|
30 |
-
*
|
31 |
-
* @return Skybox_Catalogo_Model_Api_Product
|
32 |
-
*/
|
33 |
-
protected function _getProductApi()
|
34 |
-
{
|
35 |
-
if (null === $this->_product) {
|
36 |
-
$this->_product = Mage::getModel('skyboxcatalog/api_product');
|
37 |
-
}
|
38 |
-
return $this->_product;
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Esta función es llamada cada vez que Magento requiere calcular los
|
43 |
-
* totales por cualquier motivo: carrito actualizado, usuario se logea,
|
44 |
-
* aplicar un cupón, selección de medios de envío, de pago, etc.
|
45 |
-
*
|
46 |
-
* Se trata de calcular lo que queremos añadir de recargo y actualizar
|
47 |
-
* el total del carrito (Magento itera sobre los totales y cada uno añade
|
48 |
-
* su parte)
|
49 |
-
**/
|
50 |
-
public function collect(Mage_Sales_Model_Quote_Address $address)
|
51 |
-
{
|
52 |
-
$activation = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
53 |
-
if (!$activation) {
|
54 |
-
return $this;
|
55 |
-
}
|
56 |
-
$isIntegration3 = false;
|
57 |
-
$typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
|
58 |
-
if ($typeIntegration == 3) {
|
59 |
-
$isIntegration3 = true;
|
60 |
-
}
|
61 |
-
|
62 |
-
$locationAllow = $this->_getApi()->getLocationAllow();
|
63 |
-
|
64 |
-
if (!$isIntegration3 && $locationAllow) {
|
65 |
-
if ($this->_getApi()->getLocationAllow()) {
|
66 |
-
|
67 |
-
|
68 |
-
parent::collect($address); //Comentado por verificar
|
69 |
-
|
70 |
-
// Si no hay items, no hay nada que hacer
|
71 |
-
$items = $this->_getAddressItems($address);
|
72 |
-
if (!count($items)) {
|
73 |
-
return $this;
|
74 |
-
}
|
75 |
-
|
76 |
-
$quote = $address->getQuote();
|
77 |
-
|
78 |
-
// $quote = Mage::helper('checkout/cart')->getCart()->getQuote();
|
79 |
-
$shippingMethod = $quote->getShippingAddress()->getShippingMethod();
|
80 |
-
if ($shippingMethod) {
|
81 |
-
Mage::log('set shipping method null', null, 'tracer.log', true);
|
82 |
-
$quote->getShippingAddress()->setShippingMethod(null); //setting method to null
|
83 |
-
$quote->save();
|
84 |
-
}
|
85 |
-
|
86 |
-
if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
|
87 |
-
return $this;
|
88 |
-
}
|
89 |
-
|
90 |
-
//$quote->setCustomerTaxClassId(0);
|
91 |
-
|
92 |
-
//Limpiamos los Valores de Impuestos
|
93 |
-
/*$rates = array();
|
94 |
-
$address->setAppliedTaxes($rates);*/
|
95 |
-
|
96 |
-
/*--------Nuevos conceptos---------*/
|
97 |
-
$totals = $this->_getApi()->GetTotalShoppingCart();
|
98 |
-
|
99 |
-
if ($this->_getApi()->HasError()) {
|
100 |
-
Mage::log("StatusCode: Error", null, 'TotalSales.log', true);
|
101 |
-
return $this;
|
102 |
-
}
|
103 |
-
|
104 |
-
Mage::log("quote->address->collect : ini", null, 'TotalSales.log', true);
|
105 |
-
|
106 |
-
//$StatusCode = $totals->getParameter('StatusCode');
|
107 |
-
//$StatusCode = $totals->getParameter('StatusCode');//Comentado por estar repetido
|
108 |
-
|
109 |
-
$Customs = $totals->getParameter('Customs');
|
110 |
-
$CustomsUSD = $totals->getParameter('CustomsUSD');
|
111 |
-
|
112 |
-
$Shipping = $totals->getParameter('Shipping');
|
113 |
-
$ShippingUSD = $totals->getParameter('ShippingUSD');
|
114 |
-
|
115 |
-
$Insurance = $totals->getParameter('Insurance');
|
116 |
-
$InsuranceUSD = $totals->getParameter('InsuranceUSD');
|
117 |
-
|
118 |
-
$Taxes = $totals->getParameter('Taxes');
|
119 |
-
$TaxesUSD = $totals->getParameter('TaxesUSD');
|
120 |
-
|
121 |
-
$Duties = $totals->getParameter('Duties');
|
122 |
-
$DutiesUSD = $totals->getParameter('DutiesUSD');
|
123 |
-
|
124 |
-
$Handling = $totals->getParameter('Handling');
|
125 |
-
$HandlingUSD = $totals->getParameter('HandlingUSD');
|
126 |
-
|
127 |
-
$Clearence = $totals->getParameter('Clearence');
|
128 |
-
$ClearenceUSD = $totals->getParameter('ClearenceUSD');
|
129 |
-
|
130 |
-
$Others = $totals->getParameter('Others');
|
131 |
-
$OthersUSD = $totals->getParameter('OthersUSD');
|
132 |
-
|
133 |
-
$Adjustment = $totals->getParameter('Adjustment');
|
134 |
-
$AdjustmentUSD = $totals->getParameter('AdjustmentUSD');
|
135 |
-
|
136 |
-
$listAdjustjson = $totals->getResponse()->{'ListDetailConcepts'};
|
137 |
-
|
138 |
-
$listRmtjson = $totals->getResponse()->{'ListDetailAdjusts'};
|
139 |
-
|
140 |
-
/*--------------------------------*/
|
141 |
-
// Apuntamos lo que hemos calculado para usarlo luego
|
142 |
-
// Idealmente esto debería ir a parar a la base de datos a un campo
|
143 |
-
// creado a los efectos
|
144 |
-
$address->setCustomsTotalSkybox($Customs);
|
145 |
-
$address->setCustomsTotalUsdSkybox($CustomsUSD);
|
146 |
-
|
147 |
-
$address->setShippingTotalSkybox($Shipping);
|
148 |
-
$address->setShippingTotalUsdSkybox($ShippingUSD);
|
149 |
-
|
150 |
-
$address->setInsuranceTotalSkybox($Insurance);
|
151 |
-
$address->setInsuranceTotalUsdSkybox($InsuranceUSD);
|
152 |
-
|
153 |
-
$address->setTaxesTotalSkybox($Taxes);
|
154 |
-
$address->setTaxesTotalUsdSkybox($TaxesUSD);
|
155 |
-
|
156 |
-
$address->setDutiesTotalSkybox($Duties);
|
157 |
-
$address->setDutiesTotalUsdSkybox($DutiesUSD);
|
158 |
-
|
159 |
-
$address->setHandlingTotalSkybox($Handling);
|
160 |
-
$address->setHandlingTotalUsdSkybox($HandlingUSD);
|
161 |
-
|
162 |
-
$address->setClearenceTotalSkybox($Clearence);
|
163 |
-
$address->setClearenceTotalUsdSkybox($ClearenceUSD);
|
164 |
-
|
165 |
-
$address->setOthersTotalSkybox($Others);
|
166 |
-
$address->setOthersTotalUsdSkybox($OthersUSD);
|
167 |
-
|
168 |
-
$address->setAdjustTotalSkybox($Adjustment);
|
169 |
-
$address->setAdjustTotalUsdSkybox($AdjustmentUSD);
|
170 |
-
|
171 |
-
$address->setConceptsSkybox(json_encode($listAdjustjson));
|
172 |
-
|
173 |
-
$address->setRmtSkybox(json_encode($listRmtjson));
|
174 |
-
|
175 |
-
$totalskybox = 0;
|
176 |
-
//$totalskybox=$Taxes+$Handling+$Shipping+$Insurance+$Clearence+$Duties+$Others-$Adjustment;
|
177 |
-
$subtotalskybox = $totals->getResponse()->{'StoreProductPrice'};
|
178 |
-
$totalskybox = $totals->getResponse()->{'TotalProduct'};
|
179 |
-
//$totalskyboxbase=$TaxesUSD+$HandlingUSD+$ShippingUSD+$InsuranceUSD+$ClearenceUSD+$DutiesUSD+$OthersUSD-$AdjustmentUSD;
|
180 |
-
$subtotalskyboxbase = $totals->getResponse()->{'StoreProductPriceUSD'};
|
181 |
-
$totalskyboxbase = $totals->getResponse()->{'TotalProductUSD'};
|
182 |
-
/*$address->setBasePaypalfeeAmount($this->_amount);*/
|
183 |
-
|
184 |
-
// Actualizamos el total de la quote
|
185 |
-
//$address->setGrandTotal($address->getGrandTotal() +$totalskybox);
|
186 |
-
//$address->setBaseGrandTotal($address->getBaseGrandTotal() + $totalskyboxbase);
|
187 |
-
|
188 |
-
$address->setSubTotal(100);
|
189 |
-
$address->setBaseSubTotal(100);
|
190 |
-
$address->setGrandTotal($totalskybox);/*this is total variable on cart checkout*/
|
191 |
-
$address->setBaseGrandTotal($totalskyboxbase);
|
192 |
-
|
193 |
-
//$address->setGrandTotalSkybox($address->getGrandTotal() + $totalskybox);
|
194 |
-
//$address->setBaseGrandTotalSkybox($address->getBaseGrandTotal() + $totalskyboxbase);
|
195 |
-
|
196 |
-
$address->setSubtotalSkybox($subtotalskybox);
|
197 |
-
$address->setBaseSubtotalSkybox($totalskyboxbase);
|
198 |
-
$address->setGrandTotalSkybox($totalskybox);
|
199 |
-
$address->setBaseGrandTotalSkybox($totalskyboxbase);
|
200 |
-
|
201 |
-
//$address->setTaxAmount(0);
|
202 |
-
|
203 |
-
//$address->save(); //Guardamos los Cambios
|
204 |
-
Mage::log("quote->address->collect->getSubTotal->" . $address->getSubTotal(), null, 'TotalSales.log',
|
205 |
-
true);
|
206 |
-
Mage::log("quote->address->collect->getGrandTotal->" . $address->getGrandTotal(), null,
|
207 |
-
'TotalSales.log', true);
|
208 |
-
|
209 |
-
Mage::log("quote->address->collect->Total->" . $totalskybox, null, 'TotalSales.log', true);
|
210 |
-
Mage::log("quote->address->collect : fin", null, 'TotalSales.log', true);
|
211 |
-
|
212 |
-
return $this;
|
213 |
-
} else {
|
214 |
-
parent::collect($address);
|
215 |
-
}
|
216 |
-
}
|
217 |
-
return $this;
|
218 |
-
|
219 |
-
}
|
220 |
-
|
221 |
-
/**
|
222 |
-
* Esta función es llamada por Magento cuando quiere mostrar los totales en pantalla.
|
223 |
-
*
|
224 |
-
* El cálculo ya se habrá hecho y deberíamos guardarlo en algún sitio para aquí,
|
225 |
-
* simplemente retornar el valor formateado y que Magento lo muestre.
|
226 |
-
*/
|
227 |
-
public function fetch(Mage_Sales_Model_Quote_Address $address)
|
228 |
-
{
|
229 |
-
$activation = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
230 |
-
if (!$activation) {
|
231 |
-
return $this;
|
232 |
-
}
|
233 |
-
/**
|
234 |
-
* Integration 3 start, show price shop in cart*
|
235 |
-
*/
|
236 |
-
$allowRunByIntegration3 = true;
|
237 |
-
//$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
|
238 |
-
$typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
|
239 |
-
if ($typeIntegration == 3) {
|
240 |
-
$allowRunByIntegration3 = false;
|
241 |
-
}
|
242 |
-
/**
|
243 |
-
* Integration 3 end, show price shop in cart*
|
244 |
-
*/
|
245 |
-
if ($allowRunByIntegration3) {
|
246 |
-
|
247 |
-
if ($this->_getApi()->getLocationAllow()) {
|
248 |
-
parent::fetch($address); // check
|
249 |
-
|
250 |
-
$quote = $address->getQuote();
|
251 |
-
if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
|
252 |
-
return $this;
|
253 |
-
}
|
254 |
-
|
255 |
-
$ConceptsSkyboxjson = json_decode($address->getConceptsSkybox());
|
256 |
-
|
257 |
-
Mage::log("quote->address->fetch : ini", null, 'TotalSales.log', true);
|
258 |
-
Mage::log("quote->address->fetch->getSubTotal->" . $address->getSubTotal(), null, 'TotalSales.log',
|
259 |
-
true);
|
260 |
-
Mage::log("quote->address->fetch->getGrandTotal->" . $address->getGrandTotal(), null, 'TotalSales.log',
|
261 |
-
true);
|
262 |
-
|
263 |
-
/*
|
264 |
-
* Reescribimos el monto del SubTotal a Mostrar
|
265 |
-
*/
|
266 |
-
|
267 |
-
// @todo: Make this code better!
|
268 |
-
$skyboxSubtotal = $address->getSubtotalSkybox();
|
269 |
-
$skyboxSubtotal = str_replace(',', '', $skyboxSubtotal);
|
270 |
-
|
271 |
-
$address->addTotal(array(
|
272 |
-
'code' => 'subtotal',
|
273 |
-
'title' => Mage::helper('sales')->__('Subtotal'),
|
274 |
-
'value' => $skyboxSubtotal
|
275 |
-
));
|
276 |
-
|
277 |
-
/*
|
278 |
-
* Reescribimos el monto de los conceptos a Mostrar
|
279 |
-
*/
|
280 |
-
$i = 0;
|
281 |
-
foreach ($ConceptsSkyboxjson as $item) {
|
282 |
-
if ($item->Visible != 0) {
|
283 |
-
$i += 1;
|
284 |
-
$address->addTotal(array(
|
285 |
-
'code' => 'checkout_total' . $i,
|
286 |
-
'title' => $item->Concept,
|
287 |
-
'value' => $item->Value
|
288 |
-
));
|
289 |
-
Mage::log("quote->address->fetch(Concepts)->" . $item->Concept . "=" . $item->Value, null,
|
290 |
-
'TotalSales.log', true);
|
291 |
-
}
|
292 |
-
}
|
293 |
-
Mage::log("quote->address->fetch : fin", null, 'TotalSales.log', true);
|
294 |
-
// Retornamos el total con su título
|
295 |
-
return $this;
|
296 |
-
} else {
|
297 |
-
parent::fetch($address);
|
298 |
-
return $this;
|
299 |
-
}
|
300 |
-
}
|
301 |
-
|
302 |
-
}
|
303 |
-
}
|
304 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Checkout
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Checkout
|
8 |
+
* @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Checkout_Model_Quote_Total extends Mage_Sales_Model_Quote_Address_Total_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
// Cantidad del recargo sin impuestos
|
14 |
+
// var $_amount;
|
15 |
+
|
16 |
+
protected $_api = null;
|
17 |
+
protected $_product = null;
|
18 |
+
|
19 |
+
/* @return Skybox_Checkout_Model_Api_Checkout */
|
20 |
+
protected function _getApi()
|
21 |
+
{
|
22 |
+
if (null === $this->_api) {
|
23 |
+
$this->_api = Mage::getModel('skyboxcheckout/api_checkout');
|
24 |
+
}
|
25 |
+
return $this->_api;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Return Skybox API Product
|
30 |
+
*
|
31 |
+
* @return Skybox_Catalogo_Model_Api_Product
|
32 |
+
*/
|
33 |
+
protected function _getProductApi()
|
34 |
+
{
|
35 |
+
if (null === $this->_product) {
|
36 |
+
$this->_product = Mage::getModel('skyboxcatalog/api_product');
|
37 |
+
}
|
38 |
+
return $this->_product;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Esta función es llamada cada vez que Magento requiere calcular los
|
43 |
+
* totales por cualquier motivo: carrito actualizado, usuario se logea,
|
44 |
+
* aplicar un cupón, selección de medios de envío, de pago, etc.
|
45 |
+
*
|
46 |
+
* Se trata de calcular lo que queremos añadir de recargo y actualizar
|
47 |
+
* el total del carrito (Magento itera sobre los totales y cada uno añade
|
48 |
+
* su parte)
|
49 |
+
**/
|
50 |
+
public function collect(Mage_Sales_Model_Quote_Address $address)
|
51 |
+
{
|
52 |
+
$activation = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
53 |
+
if (!$activation) {
|
54 |
+
return $this;
|
55 |
+
}
|
56 |
+
$isIntegration3 = false;
|
57 |
+
$typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
|
58 |
+
if ($typeIntegration == 3) {
|
59 |
+
$isIntegration3 = true;
|
60 |
+
}
|
61 |
+
|
62 |
+
$locationAllow = $this->_getApi()->getLocationAllow();
|
63 |
+
|
64 |
+
if (!$isIntegration3 && $locationAllow) {
|
65 |
+
if ($this->_getApi()->getLocationAllow()) {
|
66 |
+
|
67 |
+
|
68 |
+
parent::collect($address); //Comentado por verificar
|
69 |
+
|
70 |
+
// Si no hay items, no hay nada que hacer
|
71 |
+
$items = $this->_getAddressItems($address);
|
72 |
+
if (!count($items)) {
|
73 |
+
return $this;
|
74 |
+
}
|
75 |
+
|
76 |
+
$quote = $address->getQuote();
|
77 |
+
|
78 |
+
// $quote = Mage::helper('checkout/cart')->getCart()->getQuote();
|
79 |
+
$shippingMethod = $quote->getShippingAddress()->getShippingMethod();
|
80 |
+
if ($shippingMethod) {
|
81 |
+
Mage::log('set shipping method null', null, 'tracer.log', true);
|
82 |
+
$quote->getShippingAddress()->setShippingMethod(null); //setting method to null
|
83 |
+
$quote->save();
|
84 |
+
}
|
85 |
+
|
86 |
+
if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
|
87 |
+
return $this;
|
88 |
+
}
|
89 |
+
|
90 |
+
//$quote->setCustomerTaxClassId(0);
|
91 |
+
|
92 |
+
//Limpiamos los Valores de Impuestos
|
93 |
+
/*$rates = array();
|
94 |
+
$address->setAppliedTaxes($rates);*/
|
95 |
+
|
96 |
+
/*--------Nuevos conceptos---------*/
|
97 |
+
$totals = $this->_getApi()->GetTotalShoppingCart();
|
98 |
+
|
99 |
+
if ($this->_getApi()->HasError()) {
|
100 |
+
Mage::log("StatusCode: Error", null, 'TotalSales.log', true);
|
101 |
+
return $this;
|
102 |
+
}
|
103 |
+
|
104 |
+
Mage::log("quote->address->collect : ini", null, 'TotalSales.log', true);
|
105 |
+
|
106 |
+
//$StatusCode = $totals->getParameter('StatusCode');
|
107 |
+
//$StatusCode = $totals->getParameter('StatusCode');//Comentado por estar repetido
|
108 |
+
|
109 |
+
$Customs = $totals->getParameter('Customs');
|
110 |
+
$CustomsUSD = $totals->getParameter('CustomsUSD');
|
111 |
+
|
112 |
+
$Shipping = $totals->getParameter('Shipping');
|
113 |
+
$ShippingUSD = $totals->getParameter('ShippingUSD');
|
114 |
+
|
115 |
+
$Insurance = $totals->getParameter('Insurance');
|
116 |
+
$InsuranceUSD = $totals->getParameter('InsuranceUSD');
|
117 |
+
|
118 |
+
$Taxes = $totals->getParameter('Taxes');
|
119 |
+
$TaxesUSD = $totals->getParameter('TaxesUSD');
|
120 |
+
|
121 |
+
$Duties = $totals->getParameter('Duties');
|
122 |
+
$DutiesUSD = $totals->getParameter('DutiesUSD');
|
123 |
+
|
124 |
+
$Handling = $totals->getParameter('Handling');
|
125 |
+
$HandlingUSD = $totals->getParameter('HandlingUSD');
|
126 |
+
|
127 |
+
$Clearence = $totals->getParameter('Clearence');
|
128 |
+
$ClearenceUSD = $totals->getParameter('ClearenceUSD');
|
129 |
+
|
130 |
+
$Others = $totals->getParameter('Others');
|
131 |
+
$OthersUSD = $totals->getParameter('OthersUSD');
|
132 |
+
|
133 |
+
$Adjustment = $totals->getParameter('Adjustment');
|
134 |
+
$AdjustmentUSD = $totals->getParameter('AdjustmentUSD');
|
135 |
+
|
136 |
+
$listAdjustjson = $totals->getResponse()->{'ListDetailConcepts'};
|
137 |
+
|
138 |
+
$listRmtjson = $totals->getResponse()->{'ListDetailAdjusts'};
|
139 |
+
|
140 |
+
/*--------------------------------*/
|
141 |
+
// Apuntamos lo que hemos calculado para usarlo luego
|
142 |
+
// Idealmente esto debería ir a parar a la base de datos a un campo
|
143 |
+
// creado a los efectos
|
144 |
+
$address->setCustomsTotalSkybox($Customs);
|
145 |
+
$address->setCustomsTotalUsdSkybox($CustomsUSD);
|
146 |
+
|
147 |
+
$address->setShippingTotalSkybox($Shipping);
|
148 |
+
$address->setShippingTotalUsdSkybox($ShippingUSD);
|
149 |
+
|
150 |
+
$address->setInsuranceTotalSkybox($Insurance);
|
151 |
+
$address->setInsuranceTotalUsdSkybox($InsuranceUSD);
|
152 |
+
|
153 |
+
$address->setTaxesTotalSkybox($Taxes);
|
154 |
+
$address->setTaxesTotalUsdSkybox($TaxesUSD);
|
155 |
+
|
156 |
+
$address->setDutiesTotalSkybox($Duties);
|
157 |
+
$address->setDutiesTotalUsdSkybox($DutiesUSD);
|
158 |
+
|
159 |
+
$address->setHandlingTotalSkybox($Handling);
|
160 |
+
$address->setHandlingTotalUsdSkybox($HandlingUSD);
|
161 |
+
|
162 |
+
$address->setClearenceTotalSkybox($Clearence);
|
163 |
+
$address->setClearenceTotalUsdSkybox($ClearenceUSD);
|
164 |
+
|
165 |
+
$address->setOthersTotalSkybox($Others);
|
166 |
+
$address->setOthersTotalUsdSkybox($OthersUSD);
|
167 |
+
|
168 |
+
$address->setAdjustTotalSkybox($Adjustment);
|
169 |
+
$address->setAdjustTotalUsdSkybox($AdjustmentUSD);
|
170 |
+
|
171 |
+
$address->setConceptsSkybox(json_encode($listAdjustjson));
|
172 |
+
|
173 |
+
$address->setRmtSkybox(json_encode($listRmtjson));
|
174 |
+
|
175 |
+
$totalskybox = 0;
|
176 |
+
//$totalskybox=$Taxes+$Handling+$Shipping+$Insurance+$Clearence+$Duties+$Others-$Adjustment;
|
177 |
+
$subtotalskybox = $totals->getResponse()->{'StoreProductPrice'};
|
178 |
+
$totalskybox = $totals->getResponse()->{'TotalProduct'};
|
179 |
+
//$totalskyboxbase=$TaxesUSD+$HandlingUSD+$ShippingUSD+$InsuranceUSD+$ClearenceUSD+$DutiesUSD+$OthersUSD-$AdjustmentUSD;
|
180 |
+
$subtotalskyboxbase = $totals->getResponse()->{'StoreProductPriceUSD'};
|
181 |
+
$totalskyboxbase = $totals->getResponse()->{'TotalProductUSD'};
|
182 |
+
/*$address->setBasePaypalfeeAmount($this->_amount);*/
|
183 |
+
|
184 |
+
// Actualizamos el total de la quote
|
185 |
+
//$address->setGrandTotal($address->getGrandTotal() +$totalskybox);
|
186 |
+
//$address->setBaseGrandTotal($address->getBaseGrandTotal() + $totalskyboxbase);
|
187 |
+
|
188 |
+
$address->setSubTotal(100);
|
189 |
+
$address->setBaseSubTotal(100);
|
190 |
+
$address->setGrandTotal($totalskybox);/*this is total variable on cart checkout*/
|
191 |
+
$address->setBaseGrandTotal($totalskyboxbase);
|
192 |
+
|
193 |
+
//$address->setGrandTotalSkybox($address->getGrandTotal() + $totalskybox);
|
194 |
+
//$address->setBaseGrandTotalSkybox($address->getBaseGrandTotal() + $totalskyboxbase);
|
195 |
+
|
196 |
+
$address->setSubtotalSkybox($subtotalskybox);
|
197 |
+
$address->setBaseSubtotalSkybox($totalskyboxbase);
|
198 |
+
$address->setGrandTotalSkybox($totalskybox);
|
199 |
+
$address->setBaseGrandTotalSkybox($totalskyboxbase);
|
200 |
+
|
201 |
+
//$address->setTaxAmount(0);
|
202 |
+
|
203 |
+
//$address->save(); //Guardamos los Cambios
|
204 |
+
Mage::log("quote->address->collect->getSubTotal->" . $address->getSubTotal(), null, 'TotalSales.log',
|
205 |
+
true);
|
206 |
+
Mage::log("quote->address->collect->getGrandTotal->" . $address->getGrandTotal(), null,
|
207 |
+
'TotalSales.log', true);
|
208 |
+
|
209 |
+
Mage::log("quote->address->collect->Total->" . $totalskybox, null, 'TotalSales.log', true);
|
210 |
+
Mage::log("quote->address->collect : fin", null, 'TotalSales.log', true);
|
211 |
+
|
212 |
+
return $this;
|
213 |
+
} else {
|
214 |
+
parent::collect($address);
|
215 |
+
}
|
216 |
+
}
|
217 |
+
return $this;
|
218 |
+
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Esta función es llamada por Magento cuando quiere mostrar los totales en pantalla.
|
223 |
+
*
|
224 |
+
* El cálculo ya se habrá hecho y deberíamos guardarlo en algún sitio para aquí,
|
225 |
+
* simplemente retornar el valor formateado y que Magento lo muestre.
|
226 |
+
*/
|
227 |
+
public function fetch(Mage_Sales_Model_Quote_Address $address)
|
228 |
+
{
|
229 |
+
$activation = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
230 |
+
if (!$activation) {
|
231 |
+
return $this;
|
232 |
+
}
|
233 |
+
/**
|
234 |
+
* Integration 3 start, show price shop in cart*
|
235 |
+
*/
|
236 |
+
$allowRunByIntegration3 = true;
|
237 |
+
//$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
|
238 |
+
$typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
|
239 |
+
if ($typeIntegration == 3) {
|
240 |
+
$allowRunByIntegration3 = false;
|
241 |
+
}
|
242 |
+
/**
|
243 |
+
* Integration 3 end, show price shop in cart*
|
244 |
+
*/
|
245 |
+
if ($allowRunByIntegration3) {
|
246 |
+
|
247 |
+
if ($this->_getApi()->getLocationAllow()) {
|
248 |
+
parent::fetch($address); // check
|
249 |
+
|
250 |
+
$quote = $address->getQuote();
|
251 |
+
if (!$quote->isVirtual() && $address->getAddressType() == 'billing') {
|
252 |
+
return $this;
|
253 |
+
}
|
254 |
+
|
255 |
+
$ConceptsSkyboxjson = json_decode($address->getConceptsSkybox());
|
256 |
+
|
257 |
+
Mage::log("quote->address->fetch : ini", null, 'TotalSales.log', true);
|
258 |
+
Mage::log("quote->address->fetch->getSubTotal->" . $address->getSubTotal(), null, 'TotalSales.log',
|
259 |
+
true);
|
260 |
+
Mage::log("quote->address->fetch->getGrandTotal->" . $address->getGrandTotal(), null, 'TotalSales.log',
|
261 |
+
true);
|
262 |
+
|
263 |
+
/*
|
264 |
+
* Reescribimos el monto del SubTotal a Mostrar
|
265 |
+
*/
|
266 |
+
|
267 |
+
// @todo: Make this code better!
|
268 |
+
$skyboxSubtotal = $address->getSubtotalSkybox();
|
269 |
+
$skyboxSubtotal = str_replace(',', '', $skyboxSubtotal);
|
270 |
+
|
271 |
+
$address->addTotal(array(
|
272 |
+
'code' => 'subtotal',
|
273 |
+
'title' => Mage::helper('sales')->__('Subtotal'),
|
274 |
+
'value' => $skyboxSubtotal
|
275 |
+
));
|
276 |
+
|
277 |
+
/*
|
278 |
+
* Reescribimos el monto de los conceptos a Mostrar
|
279 |
+
*/
|
280 |
+
$i = 0;
|
281 |
+
foreach ($ConceptsSkyboxjson as $item) {
|
282 |
+
if ($item->Visible != 0) {
|
283 |
+
$i += 1;
|
284 |
+
$address->addTotal(array(
|
285 |
+
'code' => 'checkout_total' . $i,
|
286 |
+
'title' => $item->Concept,
|
287 |
+
'value' => $item->Value
|
288 |
+
));
|
289 |
+
Mage::log("quote->address->fetch(Concepts)->" . $item->Concept . "=" . $item->Value, null,
|
290 |
+
'TotalSales.log', true);
|
291 |
+
}
|
292 |
+
}
|
293 |
+
Mage::log("quote->address->fetch : fin", null, 'TotalSales.log', true);
|
294 |
+
// Retornamos el total con su título
|
295 |
+
return $this;
|
296 |
+
} else {
|
297 |
+
parent::fetch($address);
|
298 |
+
return $this;
|
299 |
+
}
|
300 |
+
}
|
301 |
+
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
app/code/community/Skybox/Checkout/Model/Quote/Total2.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Skybox_Checkout_Model_Quote_Total2 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
|
4 |
-
|
5 |
-
|
6 |
-
}
|
7 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Skybox_Checkout_Model_Quote_Total2 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
|
4 |
+
|
5 |
+
|
6 |
+
}
|
7 |
+
|
app/code/community/Skybox/Checkout/Model/Quote/Total3.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Skybox_Checkout_Model_Quote_Total3 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
|
4 |
-
|
5 |
-
}
|
6 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Skybox_Checkout_Model_Quote_Total3 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
|
4 |
+
|
5 |
+
}
|
6 |
+
|
app/code/community/Skybox/Checkout/Model/Quote/Total4.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Skybox_Checkout_Model_Quote_Total4 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
|
4 |
-
|
5 |
-
}
|
6 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Skybox_Checkout_Model_Quote_Total4 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
|
4 |
+
|
5 |
+
}
|
6 |
+
|
app/code/community/Skybox/Checkout/Model/Quote/Total5.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Skybox_Checkout_Model_Quote_Total5 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
|
4 |
-
|
5 |
-
}
|
6 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Skybox_Checkout_Model_Quote_Total5 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
|
4 |
+
|
5 |
+
}
|
6 |
+
|
app/code/community/Skybox/Checkout/Model/Quote/Total6.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Skybox_Checkout_Model_Quote_Total6 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
|
4 |
-
|
5 |
-
}
|
6 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Skybox_Checkout_Model_Quote_Total6 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
|
4 |
+
|
5 |
+
}
|
6 |
+
|
app/code/community/Skybox/Checkout/Model/Quote/Total7.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Skybox_Checkout_Model_Quote_Total7 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
|
4 |
-
|
5 |
-
}
|
6 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Skybox_Checkout_Model_Quote_Total7 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
|
4 |
+
|
5 |
+
}
|
6 |
+
|
app/code/community/Skybox/Checkout/Model/Quote/Total8.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Skybox_Checkout_Model_Quote_Total8 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
|
4 |
-
|
5 |
-
|
6 |
-
}
|
7 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Skybox_Checkout_Model_Quote_Total8 extends Mage_Sales_Model_Quote_Address_Total_Abstract{
|
4 |
+
|
5 |
+
|
6 |
+
}
|
7 |
+
|
app/code/community/Skybox/Checkout/controllers/CalculateController.php
CHANGED
@@ -1,138 +1,138 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Checkout
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Checkout
|
8 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Checkout_CalculateController extends Mage_Core_Controller_Front_Action
|
11 |
-
{
|
12 |
-
public function indexAction()
|
13 |
-
{
|
14 |
-
$isAjax = Mage::app()->getRequest()->isAjax();
|
15 |
-
|
16 |
-
if ($isAjax) {
|
17 |
-
|
18 |
-
$productId = ($this->getRequest()->getParam('product_id')) ?
|
19 |
-
$this->getRequest()->getParam('product_id') : null;
|
20 |
-
|
21 |
-
$price = ($this->getRequest()->getParam('price')) ?
|
22 |
-
$this->getRequest()->getParam('price') : null;
|
23 |
-
|
24 |
-
$_request = ($this->getRequest()->getParam('request')) ?
|
25 |
-
$this->getRequest()->getParam('request') : null;
|
26 |
-
|
27 |
-
if (!isset($productId) || !isset($price)) {
|
28 |
-
//trigger_error('Invalid Product or Price.');
|
29 |
-
$this->_error('Invalid Product or Price.');
|
30 |
-
}
|
31 |
-
|
32 |
-
if ($_request) {
|
33 |
-
parse_str($_request, $request);
|
34 |
-
$request = $this->_array_filter_recursive($request);
|
35 |
-
$request = $this->_getProductRequest($request);
|
36 |
-
//Mage::log(print_r($request, true), null, 'cart.log', true);
|
37 |
-
}
|
38 |
-
|
39 |
-
/** @var Skybox_Catalog_Model_Api_Product $productAPI */
|
40 |
-
$productAPI = Mage::getModel('skyboxcatalog/api_product');
|
41 |
-
$locationAllow = $productAPI->getLocationAllow();
|
42 |
-
|
43 |
-
if($locationAllow != "1"){
|
44 |
-
// Mage::log("getLocationAllow:::::[0]". $locationAllow, null, 'data.log', true);
|
45 |
-
}else {
|
46 |
-
// Mage::log("getLocationAllow:::::[1]". $locationAllow, null, 'data.log', true);
|
47 |
-
/* $product Mage_Catalog_Model_Product */
|
48 |
-
$product = Mage::getModel('catalog/product')->load($productId);
|
49 |
-
$type = $product->getTypeId();
|
50 |
-
$template = null;
|
51 |
-
//Mage::log(print_r('calculateController: '.$type, true), null, 'tracer.log', true);
|
52 |
-
switch ($type) {
|
53 |
-
case 'simple':
|
54 |
-
Mage::log("catch_exception_pendejerete_simple", null, 'tracerlog.log', true);
|
55 |
-
$template = $productAPI->CalculatePrice($product->getId(), null, $product->getFinalPrice(),
|
56 |
-
'simple')
|
57 |
-
->GetTemplateProduct();
|
58 |
-
break;
|
59 |
-
case 'configurable':
|
60 |
-
Mage::log("catch_exception_pendejerete_configurable", null, 'tracerlog.log', true);
|
61 |
-
$template = $productAPI->CalculatePrice($product->getId(), null, $price, $product->getTypeId())
|
62 |
-
->GetTemplateProduct();
|
63 |
-
break;
|
64 |
-
case 'bundle':
|
65 |
-
try {
|
66 |
-
Mage::log("catch_exception_pendejerete_bundle", null, 'tracerlog.log', true);
|
67 |
-
$template = $productAPI->CalculatePrice($product->getId(), $request, $price, 'bundle')
|
68 |
-
->GetTemplateProduct();
|
69 |
-
} catch (Exception $e) {
|
70 |
-
Mage::log("catch_exception_pendejerete", null, 'tracerlog.log', true);
|
71 |
-
Mage::logException($e);
|
72 |
-
$template = '';
|
73 |
-
}
|
74 |
-
break;
|
75 |
-
default;
|
76 |
-
$this->_error('Invalid or not supported Product Type.');
|
77 |
-
break;
|
78 |
-
}
|
79 |
-
|
80 |
-
$extraHtml = '<div id="skybox-configurable-price-from-'
|
81 |
-
. $product->getId()
|
82 |
-
//. $this->getIdSuffix()
|
83 |
-
. ''
|
84 |
-
. '">'
|
85 |
-
. $template
|
86 |
-
. '</div>'
|
87 |
-
. '<div style="clear:both"></div>';
|
88 |
-
|
89 |
-
$this->getResponse()->setBody($extraHtml);
|
90 |
-
}
|
91 |
-
}
|
92 |
-
}
|
93 |
-
|
94 |
-
private function _error($message = null)
|
95 |
-
{
|
96 |
-
if ($message == null) {
|
97 |
-
$message = "Unexpected error";
|
98 |
-
}
|
99 |
-
return $this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array('error' => $message)));
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Get request for product
|
104 |
-
*
|
105 |
-
* @param mixed $requestInfo
|
106 |
-
* @return Varien_Object
|
107 |
-
*/
|
108 |
-
private function _getProductRequest($requestInfo)
|
109 |
-
{
|
110 |
-
if ($requestInfo instanceof Varien_Object) {
|
111 |
-
$request = $requestInfo;
|
112 |
-
} elseif (is_numeric($requestInfo)) {
|
113 |
-
$request = new Varien_Object(array('qty' => $requestInfo));
|
114 |
-
} else {
|
115 |
-
$request = new Varien_Object($requestInfo);
|
116 |
-
}
|
117 |
-
|
118 |
-
if (!$request->hasQty()) {
|
119 |
-
$request->setQty(1);
|
120 |
-
}
|
121 |
-
|
122 |
-
return $request;
|
123 |
-
}
|
124 |
-
|
125 |
-
/*
|
126 |
-
* Array Filter Recursive (utils)
|
127 |
-
*/
|
128 |
-
private function _array_filter_recursive($input)
|
129 |
-
{
|
130 |
-
foreach ($input as &$value) {
|
131 |
-
if (is_array($value)) {
|
132 |
-
$value = $this->_array_filter_recursive($value);
|
133 |
-
}
|
134 |
-
}
|
135 |
-
|
136 |
-
return array_filter($input);
|
137 |
-
}
|
138 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Checkout
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Checkout
|
8 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Checkout_CalculateController extends Mage_Core_Controller_Front_Action
|
11 |
+
{
|
12 |
+
public function indexAction()
|
13 |
+
{
|
14 |
+
$isAjax = Mage::app()->getRequest()->isAjax();
|
15 |
+
|
16 |
+
if ($isAjax) {
|
17 |
+
|
18 |
+
$productId = ($this->getRequest()->getParam('product_id')) ?
|
19 |
+
$this->getRequest()->getParam('product_id') : null;
|
20 |
+
|
21 |
+
$price = ($this->getRequest()->getParam('price')) ?
|
22 |
+
$this->getRequest()->getParam('price') : null;
|
23 |
+
|
24 |
+
$_request = ($this->getRequest()->getParam('request')) ?
|
25 |
+
$this->getRequest()->getParam('request') : null;
|
26 |
+
|
27 |
+
if (!isset($productId) || !isset($price)) {
|
28 |
+
//trigger_error('Invalid Product or Price.');
|
29 |
+
$this->_error('Invalid Product or Price.');
|
30 |
+
}
|
31 |
+
|
32 |
+
if ($_request) {
|
33 |
+
parse_str($_request, $request);
|
34 |
+
$request = $this->_array_filter_recursive($request);
|
35 |
+
$request = $this->_getProductRequest($request);
|
36 |
+
//Mage::log(print_r($request, true), null, 'cart.log', true);
|
37 |
+
}
|
38 |
+
|
39 |
+
/** @var Skybox_Catalog_Model_Api_Product $productAPI */
|
40 |
+
$productAPI = Mage::getModel('skyboxcatalog/api_product');
|
41 |
+
$locationAllow = $productAPI->getLocationAllow();
|
42 |
+
|
43 |
+
if($locationAllow != "1"){
|
44 |
+
// Mage::log("getLocationAllow:::::[0]". $locationAllow, null, 'data.log', true);
|
45 |
+
}else {
|
46 |
+
// Mage::log("getLocationAllow:::::[1]". $locationAllow, null, 'data.log', true);
|
47 |
+
/* $product Mage_Catalog_Model_Product */
|
48 |
+
$product = Mage::getModel('catalog/product')->load($productId);
|
49 |
+
$type = $product->getTypeId();
|
50 |
+
$template = null;
|
51 |
+
//Mage::log(print_r('calculateController: '.$type, true), null, 'tracer.log', true);
|
52 |
+
switch ($type) {
|
53 |
+
case 'simple':
|
54 |
+
Mage::log("catch_exception_pendejerete_simple", null, 'tracerlog.log', true);
|
55 |
+
$template = $productAPI->CalculatePrice($product->getId(), null, $product->getFinalPrice(),
|
56 |
+
'simple')
|
57 |
+
->GetTemplateProduct();
|
58 |
+
break;
|
59 |
+
case 'configurable':
|
60 |
+
Mage::log("catch_exception_pendejerete_configurable", null, 'tracerlog.log', true);
|
61 |
+
$template = $productAPI->CalculatePrice($product->getId(), null, $price, $product->getTypeId())
|
62 |
+
->GetTemplateProduct();
|
63 |
+
break;
|
64 |
+
case 'bundle':
|
65 |
+
try {
|
66 |
+
Mage::log("catch_exception_pendejerete_bundle", null, 'tracerlog.log', true);
|
67 |
+
$template = $productAPI->CalculatePrice($product->getId(), $request, $price, 'bundle')
|
68 |
+
->GetTemplateProduct();
|
69 |
+
} catch (Exception $e) {
|
70 |
+
Mage::log("catch_exception_pendejerete", null, 'tracerlog.log', true);
|
71 |
+
Mage::logException($e);
|
72 |
+
$template = '';
|
73 |
+
}
|
74 |
+
break;
|
75 |
+
default;
|
76 |
+
$this->_error('Invalid or not supported Product Type.');
|
77 |
+
break;
|
78 |
+
}
|
79 |
+
|
80 |
+
$extraHtml = '<div id="skybox-configurable-price-from-'
|
81 |
+
. $product->getId()
|
82 |
+
//. $this->getIdSuffix()
|
83 |
+
. ''
|
84 |
+
. '">'
|
85 |
+
. $template
|
86 |
+
. '</div>'
|
87 |
+
. '<div style="clear:both"></div>';
|
88 |
+
|
89 |
+
$this->getResponse()->setBody($extraHtml);
|
90 |
+
}
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
private function _error($message = null)
|
95 |
+
{
|
96 |
+
if ($message == null) {
|
97 |
+
$message = "Unexpected error";
|
98 |
+
}
|
99 |
+
return $this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array('error' => $message)));
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Get request for product
|
104 |
+
*
|
105 |
+
* @param mixed $requestInfo
|
106 |
+
* @return Varien_Object
|
107 |
+
*/
|
108 |
+
private function _getProductRequest($requestInfo)
|
109 |
+
{
|
110 |
+
if ($requestInfo instanceof Varien_Object) {
|
111 |
+
$request = $requestInfo;
|
112 |
+
} elseif (is_numeric($requestInfo)) {
|
113 |
+
$request = new Varien_Object(array('qty' => $requestInfo));
|
114 |
+
} else {
|
115 |
+
$request = new Varien_Object($requestInfo);
|
116 |
+
}
|
117 |
+
|
118 |
+
if (!$request->hasQty()) {
|
119 |
+
$request->setQty(1);
|
120 |
+
}
|
121 |
+
|
122 |
+
return $request;
|
123 |
+
}
|
124 |
+
|
125 |
+
/*
|
126 |
+
* Array Filter Recursive (utils)
|
127 |
+
*/
|
128 |
+
private function _array_filter_recursive($input)
|
129 |
+
{
|
130 |
+
foreach ($input as &$value) {
|
131 |
+
if (is_array($value)) {
|
132 |
+
$value = $this->_array_filter_recursive($value);
|
133 |
+
}
|
134 |
+
}
|
135 |
+
|
136 |
+
return array_filter($input);
|
137 |
+
}
|
138 |
+
}
|
app/code/community/Skybox/Checkout/controllers/InternationalController.php
CHANGED
@@ -1,89 +1,89 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Checkout
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Checkout
|
8 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Checkout_InternationalController extends Mage_Core_Controller_Front_Action
|
11 |
-
{
|
12 |
-
public function indexAction()
|
13 |
-
{
|
14 |
-
/** @var $checkout_cart Mage_Checkout_Model_Session */
|
15 |
-
$checkout_cart = Mage::getSingleton('checkout/cart');
|
16 |
-
$items = $checkout_cart->getItems();
|
17 |
-
|
18 |
-
if (!$items) {
|
19 |
-
$this->getResponse()->setRedirect(
|
20 |
-
Mage::getUrl('checkout/cart')
|
21 |
-
);
|
22 |
-
}
|
23 |
-
|
24 |
-
$cart_count = Mage::helper('checkout/cart')->getSummaryCount();
|
25 |
-
|
26 |
-
/** @var $config Skybox_Checkout_Model_Config */
|
27 |
-
$config = Mage::getModel('skyboxcore/config');
|
28 |
-
$cart = $config->getSession()->getCartSkybox();
|
29 |
-
|
30 |
-
$cartItemCount = 0;
|
31 |
-
if (!empty($cart)) {
|
32 |
-
$cartItemCount = intval($cart->{'CartItemCount'});
|
33 |
-
}
|
34 |
-
|
35 |
-
/** @var $api_mproduct Skybox_Catalog_Model_Api_Product */
|
36 |
-
$api_mproduct = Mage::getModel('skyboxcatalog/api_product');
|
37 |
-
|
38 |
-
if ($cart_count != $cartItemCount && $api_mproduct->getLocationAllow()) {
|
39 |
-
|
40 |
-
$processUrl = Mage::getUrl() . 'skbcheckout/process';
|
41 |
-
$returnUrl = Mage::getUrl() . 'skbcheckout/international';
|
42 |
-
|
43 |
-
$url = $processUrl . '?return_url=' . $returnUrl;
|
44 |
-
$this->getResponse()->setRedirect($url);
|
45 |
-
}
|
46 |
-
|
47 |
-
$this->loadLayout();
|
48 |
-
$this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
|
49 |
-
//$this->getLayout()->getBlock('root')->setTemplate('skybox/checkout/pagecheckout.phtml');
|
50 |
-
$this->renderLayout();
|
51 |
-
}
|
52 |
-
|
53 |
-
public function successAction()
|
54 |
-
{
|
55 |
-
// Mage::log("Call true: successAction limpiar carro", null, 'local.log', true);
|
56 |
-
// Mage::getSingleton('checkout/cart')->truncate()->save();
|
57 |
-
Mage::getSingleton('checkout/cart')->truncateMgCart()->save();
|
58 |
-
|
59 |
-
$_config = Mage::getModel('skyboxcore/config');
|
60 |
-
$cart = $_config->getSession()->getCartSkybox();
|
61 |
-
$id = $cart->{'LanguageId'};
|
62 |
-
|
63 |
-
$message_success = $this->languages($id);
|
64 |
-
|
65 |
-
Mage::getSingleton('core/session')->setSkyboxSuccessMsg($message_success);
|
66 |
-
|
67 |
-
$this->loadLayout();
|
68 |
-
$this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
|
69 |
-
$this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
|
70 |
-
$this->renderLayout();
|
71 |
-
}
|
72 |
-
|
73 |
-
private function languages($id)
|
74 |
-
{
|
75 |
-
$languages = array(
|
76 |
-
0 => "Thanks for your purchase, We have received your order and we will contact you. We will send you a confirmation email.",
|
77 |
-
1 => "Thanks for your purchase, We have received your order and we will contact you. We will send you a confirmation email.",
|
78 |
-
// 2 => "!Gracias por su compra! Hemos recibido su orden y nos pondremos en contacto contigo. Le enviaremos un correo electrónico de confirmación",
|
79 |
-
2 => "Gracias por su compra! Le enviaremos un correo electrónico de confirmación.",
|
80 |
-
3 => "'Obrigado por sua compra, Recebemos seu pedido e entraremos em contato com você. Nós lhe enviaremos um e-mail de confirmação.",
|
81 |
-
);
|
82 |
-
if (isset($languages[$id])) {
|
83 |
-
return $languages[$id];
|
84 |
-
} else {
|
85 |
-
return $languages[0];
|
86 |
-
}
|
87 |
-
}
|
88 |
-
|
89 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Checkout
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Checkout
|
8 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Checkout_InternationalController extends Mage_Core_Controller_Front_Action
|
11 |
+
{
|
12 |
+
public function indexAction()
|
13 |
+
{
|
14 |
+
/** @var $checkout_cart Mage_Checkout_Model_Session */
|
15 |
+
$checkout_cart = Mage::getSingleton('checkout/cart');
|
16 |
+
$items = $checkout_cart->getItems();
|
17 |
+
|
18 |
+
if (!$items) {
|
19 |
+
$this->getResponse()->setRedirect(
|
20 |
+
Mage::getUrl('checkout/cart')
|
21 |
+
);
|
22 |
+
}
|
23 |
+
|
24 |
+
$cart_count = Mage::helper('checkout/cart')->getSummaryCount();
|
25 |
+
|
26 |
+
/** @var $config Skybox_Checkout_Model_Config */
|
27 |
+
$config = Mage::getModel('skyboxcore/config');
|
28 |
+
$cart = $config->getSession()->getCartSkybox();
|
29 |
+
|
30 |
+
$cartItemCount = 0;
|
31 |
+
if (!empty($cart)) {
|
32 |
+
$cartItemCount = intval($cart->{'CartItemCount'});
|
33 |
+
}
|
34 |
+
|
35 |
+
/** @var $api_mproduct Skybox_Catalog_Model_Api_Product */
|
36 |
+
$api_mproduct = Mage::getModel('skyboxcatalog/api_product');
|
37 |
+
|
38 |
+
if ($cart_count != $cartItemCount && $api_mproduct->getLocationAllow()) {
|
39 |
+
|
40 |
+
$processUrl = Mage::getUrl() . 'skbcheckout/process';
|
41 |
+
$returnUrl = Mage::getUrl() . 'skbcheckout/international';
|
42 |
+
|
43 |
+
$url = $processUrl . '?return_url=' . $returnUrl;
|
44 |
+
$this->getResponse()->setRedirect($url);
|
45 |
+
}
|
46 |
+
|
47 |
+
$this->loadLayout();
|
48 |
+
$this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
|
49 |
+
//$this->getLayout()->getBlock('root')->setTemplate('skybox/checkout/pagecheckout.phtml');
|
50 |
+
$this->renderLayout();
|
51 |
+
}
|
52 |
+
|
53 |
+
public function successAction()
|
54 |
+
{
|
55 |
+
// Mage::log("Call true: successAction limpiar carro", null, 'local.log', true);
|
56 |
+
// Mage::getSingleton('checkout/cart')->truncate()->save();
|
57 |
+
Mage::getSingleton('checkout/cart')->truncateMgCart()->save();
|
58 |
+
|
59 |
+
$_config = Mage::getModel('skyboxcore/config');
|
60 |
+
$cart = $_config->getSession()->getCartSkybox();
|
61 |
+
$id = $cart->{'LanguageId'};
|
62 |
+
|
63 |
+
$message_success = $this->languages($id);
|
64 |
+
|
65 |
+
Mage::getSingleton('core/session')->setSkyboxSuccessMsg($message_success);
|
66 |
+
|
67 |
+
$this->loadLayout();
|
68 |
+
$this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
|
69 |
+
$this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
|
70 |
+
$this->renderLayout();
|
71 |
+
}
|
72 |
+
|
73 |
+
private function languages($id)
|
74 |
+
{
|
75 |
+
$languages = array(
|
76 |
+
0 => "Thanks for your purchase, We have received your order and we will contact you. We will send you a confirmation email.",
|
77 |
+
1 => "Thanks for your purchase, We have received your order and we will contact you. We will send you a confirmation email.",
|
78 |
+
// 2 => "!Gracias por su compra! Hemos recibido su orden y nos pondremos en contacto contigo. Le enviaremos un correo electrónico de confirmación",
|
79 |
+
2 => "Gracias por su compra! Le enviaremos un correo electrónico de confirmación.",
|
80 |
+
3 => "'Obrigado por sua compra, Recebemos seu pedido e entraremos em contato com você. Nós lhe enviaremos um e-mail de confirmação.",
|
81 |
+
);
|
82 |
+
if (isset($languages[$id])) {
|
83 |
+
return $languages[$id];
|
84 |
+
} else {
|
85 |
+
return $languages[0];
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
}
|
app/code/community/Skybox/Checkout/controllers/ProcessController.php
CHANGED
@@ -1,352 +1,352 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Checkout
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Checkout
|
8 |
-
* @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Checkout_ProcessController extends Mage_Core_Controller_Front_Action
|
11 |
-
{
|
12 |
-
public function indexAction()
|
13 |
-
{
|
14 |
-
// Mage::log(":::-----------------------------------:::", null, 'pendejerete.log', true);
|
15 |
-
/**
|
16 |
-
* only one time for call to service start - Active
|
17 |
-
* This always run when you do change country
|
18 |
-
*/
|
19 |
-
$session = Mage::getSingleton("core/session", array("name" => "frontend"));
|
20 |
-
$session->setData("callToSkyBox", true);
|
21 |
-
//Mage::log("Call true: Skybox_Checkout_ProcessController", null, 'local.log', true);
|
22 |
-
/**
|
23 |
-
* only one time for call to service end - Active
|
24 |
-
*/
|
25 |
-
/**
|
26 |
-
* Integration 3 start, show price shop in cart*
|
27 |
-
*/
|
28 |
-
$isLocationAllow = false;
|
29 |
-
//$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
|
30 |
-
$typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
|
31 |
-
if ($typeIntegration == 3) $isLocationAllow = true;
|
32 |
-
/**
|
33 |
-
* Integration 3 end, show price shop in cart*
|
34 |
-
*/
|
35 |
-
//Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter index', null, 'tracer.log', true);
|
36 |
-
$_checkout = Mage::getModel('skyboxcheckout/api_checkout');
|
37 |
-
$_checkout->InitializeBarSkybox();
|
38 |
-
|
39 |
-
$return_url = ($this->getRequest()->getParam('return_url')) ?
|
40 |
-
$this->getRequest()->getParam('return_url') :
|
41 |
-
Mage::helper('core/url')->getHomeUrl();
|
42 |
-
|
43 |
-
// Mage::log("returnUrl:::". $return_url, null, 'pendejerete.log', true);
|
44 |
-
|
45 |
-
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
46 |
-
$product_api = Mage::getSingleton('skyboxcatalog/api_product');
|
47 |
-
|
48 |
-
// Mage::log("product_api:::".print_r($product_api,1), null, 'pendejerete.log', true);
|
49 |
-
// Mage::log("product_api-GetLocationAllow:::".$product_api->getLocationAllow(), null, 'pendejerete.log', true);
|
50 |
-
|
51 |
-
/*---------------- Rogged ------------------*/
|
52 |
-
$_config = Mage::getModel('skyboxcore/config');
|
53 |
-
$cart = $_config->getSession()->getCartSkybox();
|
54 |
-
$CartItemCount = 0;
|
55 |
-
if (!empty($cart)) {
|
56 |
-
$CartItemCount = intval($cart->{'CartItemCount'});
|
57 |
-
}
|
58 |
-
# check if local skybox shopping cart and skybox-checkout match
|
59 |
-
$differentqty = 0;
|
60 |
-
// $api_mproduct = Mage::getModel('skyboxcatalog/api_product');
|
61 |
-
|
62 |
-
// Mage::log('entro getAllItems $CartItemCount',null,'tracer.log',true);
|
63 |
-
// Mage::log((int)$quote->getItemsQty() .'-'.$CartItemCount,null,'tracer.log',true);
|
64 |
-
if (!$isLocationAllow) {
|
65 |
-
// Mage::log('entro !$isLocationAllow::: ',null,'tracer.log',true);
|
66 |
-
if ((int)$quote->getItemsQty() != $CartItemCount && $product_api->getLocationAllow()) {
|
67 |
-
$differentqty = 1;
|
68 |
-
}
|
69 |
-
}
|
70 |
-
|
71 |
-
// Mage::log("product_api-QuoteAllItems:::".print_r($quote->getAllItems(),1), null, 'pendejerete.log', true);
|
72 |
-
|
73 |
-
/*-----------------------------------------*/
|
74 |
-
foreach ($quote->getAllItems() as $item) {
|
75 |
-
$parentItem = $item->getParentItem();
|
76 |
-
$parentItemId = $item->getParentItemId();
|
77 |
-
/*---------------- Rogged ------------------*/
|
78 |
-
if ($differentqty == 1) {
|
79 |
-
// Mage::log("differentqty:::", null, 'pendejerete.log', true);
|
80 |
-
$cart = Mage::getModel('skyboxcheckout/cart');
|
81 |
-
|
82 |
-
if ($item->getProductType() === 'simple' && !$parentItem) {
|
83 |
-
$productModel = Mage::getModel('catalog/product')->load($item->getProductId());
|
84 |
-
$paramsRequest = array();
|
85 |
-
$paramsRequest['product'] = $item->getProductId();
|
86 |
-
$paramsRequest['qty'] = $item->getQty();
|
87 |
-
$cart->removeItem($item->getItemId());
|
88 |
-
$cart->addProduct($productModel, $paramsRequest);
|
89 |
-
}
|
90 |
-
/* end */
|
91 |
-
|
92 |
-
if ($item->getProductType() === 'simple' && $parentItem) {
|
93 |
-
$paramsRequest = array();
|
94 |
-
$productParentId= Mage::getModel('catalog/product_type_configurable')
|
95 |
-
->getParentIdsByChild($item->getProductId());
|
96 |
-
$productParentId= $productParentId[0];
|
97 |
-
|
98 |
-
// Mage::log("productParentId:::". print_r($productParentId), null, 'pendejerete.log', true);
|
99 |
-
// Mage::log("productParentId[0]:::". $productParentId, null, 'pendejerete.log', true);
|
100 |
-
|
101 |
-
$productModel = Mage::getModel('catalog/product')->load($productParentId);
|
102 |
-
$_typeInstance = $productModel->getTypeInstance(true);
|
103 |
-
$_children = $_typeInstance->getUsedProducts(null, $productModel);
|
104 |
-
$_attributes = $_typeInstance->getUsedProductAttributes($productModel);
|
105 |
-
|
106 |
-
foreach ($_children as $_child) {
|
107 |
-
if ($_child->entity_id == $item->getProductId()) {
|
108 |
-
$_superAttributes = array();
|
109 |
-
foreach ($_attributes as $_attribute) {
|
110 |
-
$_superAttributes[$_attribute->getAttributeId()] = $_child->getData($_attribute->getAttributeCode());
|
111 |
-
}
|
112 |
-
}
|
113 |
-
}
|
114 |
-
$paramsRequest['product'] = $item->getProductId();
|
115 |
-
$paramsRequest['qty'] = $item->getQty();
|
116 |
-
$paramsRequest['super_attribute'] = $_superAttributes;
|
117 |
-
$cart->removeItem($parentItemId);
|
118 |
-
$cart->addProduct($productModel, $paramsRequest);
|
119 |
-
}
|
120 |
-
// if ($item->getProductType() === 'simple' && !$parentItem && $item->getPriceSkybox()) {
|
121 |
-
// $productModel = Mage::getModel('catalog/product')->load($item->getProductId());
|
122 |
-
// $paramsRequest=array();
|
123 |
-
// $paramsRequest['product']=$item->getProductId();
|
124 |
-
// $paramsRequest['qty']=$item->getQty();
|
125 |
-
// $cart->removeItem($item->getItemId());
|
126 |
-
// $cart->addProduct($productModel,$paramsRequest);
|
127 |
-
// }
|
128 |
-
}
|
129 |
-
/*----------------------------------------*/
|
130 |
-
|
131 |
-
|
132 |
-
// Mage::log("process", null, 'process.log', true);
|
133 |
-
//Mage::log("ITEM Class: " . get_class($item), null, 'cart.log', true);
|
134 |
-
//Mage::log("ITEM Id: " . $item->getProductId(), null, 'cart.log', true);
|
135 |
-
|
136 |
-
|
137 |
-
/*if ($item->getProductType() === 'configurable') continue;
|
138 |
-
if ($item->getProductType() === 'simple' && $parentItem && !$item->getPriceSkybox()) continue;
|
139 |
-
|
140 |
-
// Simple Product
|
141 |
-
if ($item->getProductType() === 'simple' && !$parentItem && $item->getPriceSkybox()) {
|
142 |
-
$product_api->CalculatePrice($item->getProductId(), null, null);
|
143 |
-
}
|
144 |
-
|
145 |
-
// Configurable Product
|
146 |
-
if ($item->getProductType() === 'simple' && $parentItem) {
|
147 |
-
$item = $parentItem;
|
148 |
-
$product_api->CalculatePrice($item->getProductId(), null, $item->getPriceUsdSkybox());
|
149 |
-
}
|
150 |
-
|
151 |
-
// Bundle Product
|
152 |
-
if ($item->getProductType() === 'bundle') {
|
153 |
-
$product_api->CalculatePrice($item->getProductId(), null, $item->getPriceUsdSkybox());
|
154 |
-
};
|
155 |
-
|
156 |
-
$total = str_replace(",", "", $product_api->getTotalPriceUSD());*/
|
157 |
-
|
158 |
-
/* -- Rogged --*/
|
159 |
-
/* Cuando se cambia de country no allow a otro country allow, no hay precio en skybox registrado, por eso tomamos el precio de tienda */
|
160 |
-
/** @var Mage_Catalog_Model_Resource_Product $productModel */
|
161 |
-
// $productModel = Mage::getModel('catalog/product')->load($item->getProductId());
|
162 |
-
|
163 |
-
/** @var Mage_Catalog_Model_Product $productModel */
|
164 |
-
$productModel = Mage::getModel('catalog/product')->load($item->getProductId());
|
165 |
-
|
166 |
-
if (!$isLocationAllow) {
|
167 |
-
if ($product_api->getLocationAllow() && !$item->getPriceSkybox()) {
|
168 |
-
$item->setPriceSkybox($productModel->getPrice());
|
169 |
-
}
|
170 |
-
}
|
171 |
-
|
172 |
-
/* -- ----- --*/
|
173 |
-
|
174 |
-
#echo $item->getPrice()." - ".$item->getPriceSkybox()."<br>";
|
175 |
-
|
176 |
-
|
177 |
-
// Mage::log(print_r($productModel->getFinalPrice(), true), null, 'processcontroller.log', true);
|
178 |
-
|
179 |
-
if ($item->getProductType() === 'configurable') {
|
180 |
-
|
181 |
-
$product_api->CalculatePrice($item->getProductId(), null, $productModel->getPriceUsdSkybox(),
|
182 |
-
$item->getProductType(), null);
|
183 |
-
// Mage::log("configurable", null, 'processcontroller.log', true);
|
184 |
-
}
|
185 |
-
if ($item->getProductType() === 'simple' && $parentItem && !$item->getPriceSkybox()) {
|
186 |
-
|
187 |
-
$product_api->CalculatePrice($item->getProductId(), null, $productModel->getPriceUsdSkybox(),
|
188 |
-
$item->getProductType(), null);
|
189 |
-
// Mage::log("simple1", null, 'processcontroller.log', true);
|
190 |
-
}
|
191 |
-
|
192 |
-
// Simple Product
|
193 |
-
if ($item->getProductType() === 'simple' && !$parentItem && $item->getPriceSkybox()) {
|
194 |
-
|
195 |
-
$product_api->CalculatePrice($item->getProductId(), null, null);
|
196 |
-
// Mage::log("simple2", null, 'processcontroller.log', true);
|
197 |
-
}
|
198 |
-
|
199 |
-
// Configurable Product
|
200 |
-
if ($item->getProductType() === 'simple' && $parentItem) {
|
201 |
-
|
202 |
-
$item = $parentItem;
|
203 |
-
// $product_api->CalculatePrice($item->getProductId(), null, $productModel->getFinalPrice());
|
204 |
-
|
205 |
-
$_price = $productModel->getFinalPrice();
|
206 |
-
$_price = isset($_price) ? $productModel->getFinalPrice() : $productModel->getPrice();
|
207 |
-
$product_api->CalculatePrice($item->getProductId(), null, $_price);
|
208 |
-
// Mage::log("simple3", null, 'processcontroller.log', true);
|
209 |
-
}
|
210 |
-
|
211 |
-
// Bundle Product
|
212 |
-
if ($item->getProductType() === 'bundle') {
|
213 |
-
|
214 |
-
$product_api->CalculatePrice($item->getProductId(), null, $productModel->getPriceUsdSkybox());
|
215 |
-
// Mage::log("bundle", null, 'processcontroller.log', true);
|
216 |
-
};
|
217 |
-
|
218 |
-
if ($isLocationAllow) {
|
219 |
-
//$total = str_replace(",", "", $product_api->getPriceUSD());
|
220 |
-
$total = str_replace(",", "", $productModel->getTotalPriceUSD());
|
221 |
-
|
222 |
-
/**
|
223 |
-
* Currency amounts in the default currency of that customer
|
224 |
-
*/
|
225 |
-
$item->setCustomsSkybox($productModel->getCustoms());
|
226 |
-
$item->setShippingSkybox($productModel->getShipping());
|
227 |
-
$item->setInsuranceSkybox($productModel->getInsurance());
|
228 |
-
$item->setPriceSkybox($productModel->getPrice());
|
229 |
-
$item->setTotalSkybox($productModel->getTotalPrice());
|
230 |
-
$item->setRowTotal($total);
|
231 |
-
|
232 |
-
/*
|
233 |
-
* Currency amounts in the USD Currency
|
234 |
-
*/
|
235 |
-
$item->setCustomsUsdSkybox($productModel->getCustomsUSD());
|
236 |
-
$item->setShippingUsdSkybox($productModel->getShippingUSD());
|
237 |
-
$item->setInsuranceUsdSkybox($productModel->getInsuranceUSD());
|
238 |
-
$item->setPriceUsdSkybox($productModel->getPriceUSD());
|
239 |
-
$item->setTotalUsdSkybox($productModel->getTotalPriceUSD());
|
240 |
-
|
241 |
-
// Set GUID
|
242 |
-
$item->setGuidSkybox($productModel->getGuidSkybox());
|
243 |
-
|
244 |
-
$item->setBasePriceSkybox($productModel->getBasePrice());
|
245 |
-
$item->setBasePriceUsdSkybox($productModel->getBasePriceUSD());
|
246 |
-
$item->setAdjustTotalSkybox($productModel->getAdjustPrice());
|
247 |
-
$item->setAdjustTotalUsdSkybox($productModel->getAdjustPriceUSD());
|
248 |
-
$item->setAdjustLabelSkybox($productModel->getAdjustLabel());
|
249 |
-
|
250 |
-
/**
|
251 |
-
* Registramos el monto total en USD
|
252 |
-
*/
|
253 |
-
//$item->setOriginalCustomPrice($product_api->getTotalPriceUSD());
|
254 |
-
//$item->setOriginalCustomPrice($total);
|
255 |
-
$prices = str_replace(',', '', $productModel->getPrice());
|
256 |
-
$prices = number_format((float)($prices), 2, ',', '.');
|
257 |
-
$item->setOriginalCustomPrice($prices);
|
258 |
-
//$item->setOriginalCustomPrice($product_api->getPrice());
|
259 |
-
//$skybox_total = str_replace(",", "", $product_api->getTotalPrice());
|
260 |
-
$skybox_total = str_replace(",", "", $productModel->getPrice());
|
261 |
-
$row_total = floatval($skybox_total) * $item->getQty();
|
262 |
-
$item->setRowTotalSkybox($row_total);
|
263 |
-
} else {
|
264 |
-
//$total = str_replace(",", "", $product_api->getPriceUSD());
|
265 |
-
$total = str_replace(",", "", $product_api->getTotalPriceUSD());
|
266 |
-
|
267 |
-
/**
|
268 |
-
* Currency amounts in the default currency of that customer
|
269 |
-
*/
|
270 |
-
$item->setCustomsSkybox($product_api->getCustoms());
|
271 |
-
$item->setShippingSkybox($product_api->getShipping());
|
272 |
-
$item->setInsuranceSkybox($product_api->getInsurance());
|
273 |
-
$item->setPriceSkybox($product_api->getPrice());
|
274 |
-
$item->setTotalSkybox($product_api->getTotalPrice());
|
275 |
-
$item->setRowTotal($total);
|
276 |
-
|
277 |
-
/*
|
278 |
-
* Currency amounts in the USD Currency
|
279 |
-
*/
|
280 |
-
$item->setCustomsUsdSkybox($product_api->getCustomsUSD());
|
281 |
-
$item->setShippingUsdSkybox($product_api->getShippingUSD());
|
282 |
-
$item->setInsuranceUsdSkybox($product_api->getInsuranceUSD());
|
283 |
-
$item->setPriceUsdSkybox($product_api->getPriceUSD());
|
284 |
-
$item->setTotalUsdSkybox($product_api->getTotalPriceUSD());
|
285 |
-
|
286 |
-
// Set GUID
|
287 |
-
$item->setGuidSkybox($product_api->getGuidSkybox());
|
288 |
-
|
289 |
-
$item->setBasePriceSkybox($product_api->getBasePrice());
|
290 |
-
$item->setBasePriceUsdSkybox($product_api->getBasePriceUSD());
|
291 |
-
$item->setAdjustTotalSkybox($product_api->getAdjustPrice());
|
292 |
-
$item->setAdjustTotalUsdSkybox($product_api->getAdjustPriceUSD());
|
293 |
-
$item->setAdjustLabelSkybox($product_api->getAdjustLabel());
|
294 |
-
|
295 |
-
/**
|
296 |
-
* Registramos el monto total en USD
|
297 |
-
*/
|
298 |
-
//$item->setOriginalCustomPrice($product_api->getTotalPriceUSD());
|
299 |
-
//$item->setOriginalCustomPrice($total);
|
300 |
-
|
301 |
-
// $prices = str_replace(',', '', $product_api->getPrice());
|
302 |
-
// $prices = number_format((float)($prices), 2, ',', '.');
|
303 |
-
|
304 |
-
$prices = $this->getFormatPrice($product_api->getPrice());
|
305 |
-
|
306 |
-
$item->setOriginalCustomPrice($prices);
|
307 |
-
|
308 |
-
// @todo: Rewrite custom Quote and LocationAllow logic.
|
309 |
-
if ($product_api->getLocationAllow() == 0) {
|
310 |
-
// Mage::log("The country is not allow", null, 'bueyada.log', true);
|
311 |
-
$item->setOriginalCustomPrice($productModel->getPrice());
|
312 |
-
}
|
313 |
-
//$item->setOriginalCustomPrice($product_api->getPrice());
|
314 |
-
//$skybox_total = str_replace(",", "", $product_api->getTotalPrice());
|
315 |
-
$skybox_total = str_replace(",", "", $product_api->getPrice());
|
316 |
-
$row_total = floatval($skybox_total) * $item->getQty();
|
317 |
-
$item->setRowTotalSkybox($row_total);
|
318 |
-
}
|
319 |
-
|
320 |
-
}
|
321 |
-
|
322 |
-
$quote->save();
|
323 |
-
|
324 |
-
$_getSession = Mage::getSingleton('checkout/session');
|
325 |
-
$_getSession->setCartWasUpdated(true);
|
326 |
-
|
327 |
-
// @note: Force to load Home Page due cache issue. (minicart)
|
328 |
-
if (strpos($return_url, 'force_reload')) {
|
329 |
-
$return_url = str_replace('force_reload', '', $return_url);
|
330 |
-
|
331 |
-
/** @var Skybox_Core_Model_Config $config */
|
332 |
-
$config = Mage::getModel("skyboxcore/config");
|
333 |
-
$forceReload = 1;
|
334 |
-
$config->getSession()->setChangeCountryHomePage($forceReload);
|
335 |
-
}
|
336 |
-
|
337 |
-
//$this->getResponse()->setRedirect($return_url);
|
338 |
-
Mage::app()->getResponse()->setRedirect($return_url);
|
339 |
-
}
|
340 |
-
|
341 |
-
/**
|
342 |
-
* Skybox Format Price
|
343 |
-
* @param $price
|
344 |
-
* @return mixed|string
|
345 |
-
*/
|
346 |
-
function getFormatPrice($price)
|
347 |
-
{
|
348 |
-
$value = str_replace(',', '', $price);
|
349 |
-
$value = number_format((float)($value), 2, ',', '.');
|
350 |
-
return $value;
|
351 |
-
}
|
352 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Checkout
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Checkout
|
8 |
+
* @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Checkout_ProcessController extends Mage_Core_Controller_Front_Action
|
11 |
+
{
|
12 |
+
public function indexAction()
|
13 |
+
{
|
14 |
+
// Mage::log(":::-----------------------------------:::", null, 'pendejerete.log', true);
|
15 |
+
/**
|
16 |
+
* only one time for call to service start - Active
|
17 |
+
* This always run when you do change country
|
18 |
+
*/
|
19 |
+
$session = Mage::getSingleton("core/session", array("name" => "frontend"));
|
20 |
+
$session->setData("callToSkyBox", true);
|
21 |
+
//Mage::log("Call true: Skybox_Checkout_ProcessController", null, 'local.log', true);
|
22 |
+
/**
|
23 |
+
* only one time for call to service end - Active
|
24 |
+
*/
|
25 |
+
/**
|
26 |
+
* Integration 3 start, show price shop in cart*
|
27 |
+
*/
|
28 |
+
$isLocationAllow = false;
|
29 |
+
//$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
|
30 |
+
$typeIntegration = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
|
31 |
+
if ($typeIntegration == 3) $isLocationAllow = true;
|
32 |
+
/**
|
33 |
+
* Integration 3 end, show price shop in cart*
|
34 |
+
*/
|
35 |
+
//Mage::log(__FILE__.' # '.__LINE__.' ~ '. __METHOD__.' => enter index', null, 'tracer.log', true);
|
36 |
+
$_checkout = Mage::getModel('skyboxcheckout/api_checkout');
|
37 |
+
$_checkout->InitializeBarSkybox();
|
38 |
+
|
39 |
+
$return_url = ($this->getRequest()->getParam('return_url')) ?
|
40 |
+
$this->getRequest()->getParam('return_url') :
|
41 |
+
Mage::helper('core/url')->getHomeUrl();
|
42 |
+
|
43 |
+
// Mage::log("returnUrl:::". $return_url, null, 'pendejerete.log', true);
|
44 |
+
|
45 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
46 |
+
$product_api = Mage::getSingleton('skyboxcatalog/api_product');
|
47 |
+
|
48 |
+
// Mage::log("product_api:::".print_r($product_api,1), null, 'pendejerete.log', true);
|
49 |
+
// Mage::log("product_api-GetLocationAllow:::".$product_api->getLocationAllow(), null, 'pendejerete.log', true);
|
50 |
+
|
51 |
+
/*---------------- Rogged ------------------*/
|
52 |
+
$_config = Mage::getModel('skyboxcore/config');
|
53 |
+
$cart = $_config->getSession()->getCartSkybox();
|
54 |
+
$CartItemCount = 0;
|
55 |
+
if (!empty($cart)) {
|
56 |
+
$CartItemCount = intval($cart->{'CartItemCount'});
|
57 |
+
}
|
58 |
+
# check if local skybox shopping cart and skybox-checkout match
|
59 |
+
$differentqty = 0;
|
60 |
+
// $api_mproduct = Mage::getModel('skyboxcatalog/api_product');
|
61 |
+
|
62 |
+
// Mage::log('entro getAllItems $CartItemCount',null,'tracer.log',true);
|
63 |
+
// Mage::log((int)$quote->getItemsQty() .'-'.$CartItemCount,null,'tracer.log',true);
|
64 |
+
if (!$isLocationAllow) {
|
65 |
+
// Mage::log('entro !$isLocationAllow::: ',null,'tracer.log',true);
|
66 |
+
if ((int)$quote->getItemsQty() != $CartItemCount && $product_api->getLocationAllow()) {
|
67 |
+
$differentqty = 1;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
// Mage::log("product_api-QuoteAllItems:::".print_r($quote->getAllItems(),1), null, 'pendejerete.log', true);
|
72 |
+
|
73 |
+
/*-----------------------------------------*/
|
74 |
+
foreach ($quote->getAllItems() as $item) {
|
75 |
+
$parentItem = $item->getParentItem();
|
76 |
+
$parentItemId = $item->getParentItemId();
|
77 |
+
/*---------------- Rogged ------------------*/
|
78 |
+
if ($differentqty == 1) {
|
79 |
+
// Mage::log("differentqty:::", null, 'pendejerete.log', true);
|
80 |
+
$cart = Mage::getModel('skyboxcheckout/cart');
|
81 |
+
|
82 |
+
if ($item->getProductType() === 'simple' && !$parentItem) {
|
83 |
+
$productModel = Mage::getModel('catalog/product')->load($item->getProductId());
|
84 |
+
$paramsRequest = array();
|
85 |
+
$paramsRequest['product'] = $item->getProductId();
|
86 |
+
$paramsRequest['qty'] = $item->getQty();
|
87 |
+
$cart->removeItem($item->getItemId());
|
88 |
+
$cart->addProduct($productModel, $paramsRequest);
|
89 |
+
}
|
90 |
+
/* end */
|
91 |
+
|
92 |
+
if ($item->getProductType() === 'simple' && $parentItem) {
|
93 |
+
$paramsRequest = array();
|
94 |
+
$productParentId= Mage::getModel('catalog/product_type_configurable')
|
95 |
+
->getParentIdsByChild($item->getProductId());
|
96 |
+
$productParentId= $productParentId[0];
|
97 |
+
|
98 |
+
// Mage::log("productParentId:::". print_r($productParentId), null, 'pendejerete.log', true);
|
99 |
+
// Mage::log("productParentId[0]:::". $productParentId, null, 'pendejerete.log', true);
|
100 |
+
|
101 |
+
$productModel = Mage::getModel('catalog/product')->load($productParentId);
|
102 |
+
$_typeInstance = $productModel->getTypeInstance(true);
|
103 |
+
$_children = $_typeInstance->getUsedProducts(null, $productModel);
|
104 |
+
$_attributes = $_typeInstance->getUsedProductAttributes($productModel);
|
105 |
+
|
106 |
+
foreach ($_children as $_child) {
|
107 |
+
if ($_child->entity_id == $item->getProductId()) {
|
108 |
+
$_superAttributes = array();
|
109 |
+
foreach ($_attributes as $_attribute) {
|
110 |
+
$_superAttributes[$_attribute->getAttributeId()] = $_child->getData($_attribute->getAttributeCode());
|
111 |
+
}
|
112 |
+
}
|
113 |
+
}
|
114 |
+
$paramsRequest['product'] = $item->getProductId();
|
115 |
+
$paramsRequest['qty'] = $item->getQty();
|
116 |
+
$paramsRequest['super_attribute'] = $_superAttributes;
|
117 |
+
$cart->removeItem($parentItemId);
|
118 |
+
$cart->addProduct($productModel, $paramsRequest);
|
119 |
+
}
|
120 |
+
// if ($item->getProductType() === 'simple' && !$parentItem && $item->getPriceSkybox()) {
|
121 |
+
// $productModel = Mage::getModel('catalog/product')->load($item->getProductId());
|
122 |
+
// $paramsRequest=array();
|
123 |
+
// $paramsRequest['product']=$item->getProductId();
|
124 |
+
// $paramsRequest['qty']=$item->getQty();
|
125 |
+
// $cart->removeItem($item->getItemId());
|
126 |
+
// $cart->addProduct($productModel,$paramsRequest);
|
127 |
+
// }
|
128 |
+
}
|
129 |
+
/*----------------------------------------*/
|
130 |
+
|
131 |
+
|
132 |
+
// Mage::log("process", null, 'process.log', true);
|
133 |
+
//Mage::log("ITEM Class: " . get_class($item), null, 'cart.log', true);
|
134 |
+
//Mage::log("ITEM Id: " . $item->getProductId(), null, 'cart.log', true);
|
135 |
+
|
136 |
+
|
137 |
+
/*if ($item->getProductType() === 'configurable') continue;
|
138 |
+
if ($item->getProductType() === 'simple' && $parentItem && !$item->getPriceSkybox()) continue;
|
139 |
+
|
140 |
+
// Simple Product
|
141 |
+
if ($item->getProductType() === 'simple' && !$parentItem && $item->getPriceSkybox()) {
|
142 |
+
$product_api->CalculatePrice($item->getProductId(), null, null);
|
143 |
+
}
|
144 |
+
|
145 |
+
// Configurable Product
|
146 |
+
if ($item->getProductType() === 'simple' && $parentItem) {
|
147 |
+
$item = $parentItem;
|
148 |
+
$product_api->CalculatePrice($item->getProductId(), null, $item->getPriceUsdSkybox());
|
149 |
+
}
|
150 |
+
|
151 |
+
// Bundle Product
|
152 |
+
if ($item->getProductType() === 'bundle') {
|
153 |
+
$product_api->CalculatePrice($item->getProductId(), null, $item->getPriceUsdSkybox());
|
154 |
+
};
|
155 |
+
|
156 |
+
$total = str_replace(",", "", $product_api->getTotalPriceUSD());*/
|
157 |
+
|
158 |
+
/* -- Rogged --*/
|
159 |
+
/* Cuando se cambia de country no allow a otro country allow, no hay precio en skybox registrado, por eso tomamos el precio de tienda */
|
160 |
+
/** @var Mage_Catalog_Model_Resource_Product $productModel */
|
161 |
+
// $productModel = Mage::getModel('catalog/product')->load($item->getProductId());
|
162 |
+
|
163 |
+
/** @var Mage_Catalog_Model_Product $productModel */
|
164 |
+
$productModel = Mage::getModel('catalog/product')->load($item->getProductId());
|
165 |
+
|
166 |
+
if (!$isLocationAllow) {
|
167 |
+
if ($product_api->getLocationAllow() && !$item->getPriceSkybox()) {
|
168 |
+
$item->setPriceSkybox($productModel->getPrice());
|
169 |
+
}
|
170 |
+
}
|
171 |
+
|
172 |
+
/* -- ----- --*/
|
173 |
+
|
174 |
+
#echo $item->getPrice()." - ".$item->getPriceSkybox()."<br>";
|
175 |
+
|
176 |
+
|
177 |
+
// Mage::log(print_r($productModel->getFinalPrice(), true), null, 'processcontroller.log', true);
|
178 |
+
|
179 |
+
if ($item->getProductType() === 'configurable') {
|
180 |
+
|
181 |
+
$product_api->CalculatePrice($item->getProductId(), null, $productModel->getPriceUsdSkybox(),
|
182 |
+
$item->getProductType(), null);
|
183 |
+
// Mage::log("configurable", null, 'processcontroller.log', true);
|
184 |
+
}
|
185 |
+
if ($item->getProductType() === 'simple' && $parentItem && !$item->getPriceSkybox()) {
|
186 |
+
|
187 |
+
$product_api->CalculatePrice($item->getProductId(), null, $productModel->getPriceUsdSkybox(),
|
188 |
+
$item->getProductType(), null);
|
189 |
+
// Mage::log("simple1", null, 'processcontroller.log', true);
|
190 |
+
}
|
191 |
+
|
192 |
+
// Simple Product
|
193 |
+
if ($item->getProductType() === 'simple' && !$parentItem && $item->getPriceSkybox()) {
|
194 |
+
|
195 |
+
$product_api->CalculatePrice($item->getProductId(), null, null);
|
196 |
+
// Mage::log("simple2", null, 'processcontroller.log', true);
|
197 |
+
}
|
198 |
+
|
199 |
+
// Configurable Product
|
200 |
+
if ($item->getProductType() === 'simple' && $parentItem) {
|
201 |
+
|
202 |
+
$item = $parentItem;
|
203 |
+
// $product_api->CalculatePrice($item->getProductId(), null, $productModel->getFinalPrice());
|
204 |
+
|
205 |
+
$_price = $productModel->getFinalPrice();
|
206 |
+
$_price = isset($_price) ? $productModel->getFinalPrice() : $productModel->getPrice();
|
207 |
+
$product_api->CalculatePrice($item->getProductId(), null, $_price);
|
208 |
+
// Mage::log("simple3", null, 'processcontroller.log', true);
|
209 |
+
}
|
210 |
+
|
211 |
+
// Bundle Product
|
212 |
+
if ($item->getProductType() === 'bundle') {
|
213 |
+
|
214 |
+
$product_api->CalculatePrice($item->getProductId(), null, $productModel->getPriceUsdSkybox());
|
215 |
+
// Mage::log("bundle", null, 'processcontroller.log', true);
|
216 |
+
};
|
217 |
+
|
218 |
+
if ($isLocationAllow) {
|
219 |
+
//$total = str_replace(",", "", $product_api->getPriceUSD());
|
220 |
+
$total = str_replace(",", "", $productModel->getTotalPriceUSD());
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Currency amounts in the default currency of that customer
|
224 |
+
*/
|
225 |
+
$item->setCustomsSkybox($productModel->getCustoms());
|
226 |
+
$item->setShippingSkybox($productModel->getShipping());
|
227 |
+
$item->setInsuranceSkybox($productModel->getInsurance());
|
228 |
+
$item->setPriceSkybox($productModel->getPrice());
|
229 |
+
$item->setTotalSkybox($productModel->getTotalPrice());
|
230 |
+
$item->setRowTotal($total);
|
231 |
+
|
232 |
+
/*
|
233 |
+
* Currency amounts in the USD Currency
|
234 |
+
*/
|
235 |
+
$item->setCustomsUsdSkybox($productModel->getCustomsUSD());
|
236 |
+
$item->setShippingUsdSkybox($productModel->getShippingUSD());
|
237 |
+
$item->setInsuranceUsdSkybox($productModel->getInsuranceUSD());
|
238 |
+
$item->setPriceUsdSkybox($productModel->getPriceUSD());
|
239 |
+
$item->setTotalUsdSkybox($productModel->getTotalPriceUSD());
|
240 |
+
|
241 |
+
// Set GUID
|
242 |
+
$item->setGuidSkybox($productModel->getGuidSkybox());
|
243 |
+
|
244 |
+
$item->setBasePriceSkybox($productModel->getBasePrice());
|
245 |
+
$item->setBasePriceUsdSkybox($productModel->getBasePriceUSD());
|
246 |
+
$item->setAdjustTotalSkybox($productModel->getAdjustPrice());
|
247 |
+
$item->setAdjustTotalUsdSkybox($productModel->getAdjustPriceUSD());
|
248 |
+
$item->setAdjustLabelSkybox($productModel->getAdjustLabel());
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Registramos el monto total en USD
|
252 |
+
*/
|
253 |
+
//$item->setOriginalCustomPrice($product_api->getTotalPriceUSD());
|
254 |
+
//$item->setOriginalCustomPrice($total);
|
255 |
+
$prices = str_replace(',', '', $productModel->getPrice());
|
256 |
+
$prices = number_format((float)($prices), 2, ',', '.');
|
257 |
+
$item->setOriginalCustomPrice($prices);
|
258 |
+
//$item->setOriginalCustomPrice($product_api->getPrice());
|
259 |
+
//$skybox_total = str_replace(",", "", $product_api->getTotalPrice());
|
260 |
+
$skybox_total = str_replace(",", "", $productModel->getPrice());
|
261 |
+
$row_total = floatval($skybox_total) * $item->getQty();
|
262 |
+
$item->setRowTotalSkybox($row_total);
|
263 |
+
} else {
|
264 |
+
//$total = str_replace(",", "", $product_api->getPriceUSD());
|
265 |
+
$total = str_replace(",", "", $product_api->getTotalPriceUSD());
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Currency amounts in the default currency of that customer
|
269 |
+
*/
|
270 |
+
$item->setCustomsSkybox($product_api->getCustoms());
|
271 |
+
$item->setShippingSkybox($product_api->getShipping());
|
272 |
+
$item->setInsuranceSkybox($product_api->getInsurance());
|
273 |
+
$item->setPriceSkybox($product_api->getPrice());
|
274 |
+
$item->setTotalSkybox($product_api->getTotalPrice());
|
275 |
+
$item->setRowTotal($total);
|
276 |
+
|
277 |
+
/*
|
278 |
+
* Currency amounts in the USD Currency
|
279 |
+
*/
|
280 |
+
$item->setCustomsUsdSkybox($product_api->getCustomsUSD());
|
281 |
+
$item->setShippingUsdSkybox($product_api->getShippingUSD());
|
282 |
+
$item->setInsuranceUsdSkybox($product_api->getInsuranceUSD());
|
283 |
+
$item->setPriceUsdSkybox($product_api->getPriceUSD());
|
284 |
+
$item->setTotalUsdSkybox($product_api->getTotalPriceUSD());
|
285 |
+
|
286 |
+
// Set GUID
|
287 |
+
$item->setGuidSkybox($product_api->getGuidSkybox());
|
288 |
+
|
289 |
+
$item->setBasePriceSkybox($product_api->getBasePrice());
|
290 |
+
$item->setBasePriceUsdSkybox($product_api->getBasePriceUSD());
|
291 |
+
$item->setAdjustTotalSkybox($product_api->getAdjustPrice());
|
292 |
+
$item->setAdjustTotalUsdSkybox($product_api->getAdjustPriceUSD());
|
293 |
+
$item->setAdjustLabelSkybox($product_api->getAdjustLabel());
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Registramos el monto total en USD
|
297 |
+
*/
|
298 |
+
//$item->setOriginalCustomPrice($product_api->getTotalPriceUSD());
|
299 |
+
//$item->setOriginalCustomPrice($total);
|
300 |
+
|
301 |
+
// $prices = str_replace(',', '', $product_api->getPrice());
|
302 |
+
// $prices = number_format((float)($prices), 2, ',', '.');
|
303 |
+
|
304 |
+
$prices = $this->getFormatPrice($product_api->getPrice());
|
305 |
+
|
306 |
+
$item->setOriginalCustomPrice($prices);
|
307 |
+
|
308 |
+
// @todo: Rewrite custom Quote and LocationAllow logic.
|
309 |
+
if ($product_api->getLocationAllow() == 0) {
|
310 |
+
// Mage::log("The country is not allow", null, 'bueyada.log', true);
|
311 |
+
$item->setOriginalCustomPrice($productModel->getPrice());
|
312 |
+
}
|
313 |
+
//$item->setOriginalCustomPrice($product_api->getPrice());
|
314 |
+
//$skybox_total = str_replace(",", "", $product_api->getTotalPrice());
|
315 |
+
$skybox_total = str_replace(",", "", $product_api->getPrice());
|
316 |
+
$row_total = floatval($skybox_total) * $item->getQty();
|
317 |
+
$item->setRowTotalSkybox($row_total);
|
318 |
+
}
|
319 |
+
|
320 |
+
}
|
321 |
+
|
322 |
+
$quote->save();
|
323 |
+
|
324 |
+
$_getSession = Mage::getSingleton('checkout/session');
|
325 |
+
$_getSession->setCartWasUpdated(true);
|
326 |
+
|
327 |
+
// @note: Force to load Home Page due cache issue. (minicart)
|
328 |
+
if (strpos($return_url, 'force_reload')) {
|
329 |
+
$return_url = str_replace('force_reload', '', $return_url);
|
330 |
+
|
331 |
+
/** @var Skybox_Core_Model_Config $config */
|
332 |
+
$config = Mage::getModel("skyboxcore/config");
|
333 |
+
$forceReload = 1;
|
334 |
+
$config->getSession()->setChangeCountryHomePage($forceReload);
|
335 |
+
}
|
336 |
+
|
337 |
+
//$this->getResponse()->setRedirect($return_url);
|
338 |
+
Mage::app()->getResponse()->setRedirect($return_url);
|
339 |
+
}
|
340 |
+
|
341 |
+
/**
|
342 |
+
* Skybox Format Price
|
343 |
+
* @param $price
|
344 |
+
* @return mixed|string
|
345 |
+
*/
|
346 |
+
function getFormatPrice($price)
|
347 |
+
{
|
348 |
+
$value = str_replace(',', '', $price);
|
349 |
+
$value = number_format((float)($value), 2, ',', '.');
|
350 |
+
return $value;
|
351 |
+
}
|
352 |
+
}
|
app/code/community/Skybox/Checkout/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Skybox_Checkout>
|
5 |
-
<version>1.2.
|
6 |
<codePool>community</codePool>
|
7 |
</Skybox_Checkout>
|
8 |
</modules>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Skybox_Checkout>
|
5 |
+
<version>1.2.9</version>
|
6 |
<codePool>community</codePool>
|
7 |
</Skybox_Checkout>
|
8 |
</modules>
|
app/code/community/Skybox/Checkout/etc/system.xml
CHANGED
@@ -1,127 +1,127 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<config>
|
3 |
-
<sections>
|
4 |
-
<carriers translate="label" module="shipping">
|
5 |
-
<groups>
|
6 |
-
<skyboxcheckout_shipping translate="label">
|
7 |
-
<label>Shipping SkyboxCheckout</label>
|
8 |
-
<frontend_type>text</frontend_type>
|
9 |
-
<sort_order>0</sort_order>
|
10 |
-
<show_in_default>1</show_in_default>
|
11 |
-
<show_in_website>1</show_in_website>
|
12 |
-
<show_in_store>1</show_in_store>
|
13 |
-
<fields>
|
14 |
-
<active translate="label">
|
15 |
-
<label>Enabled</label>
|
16 |
-
<frontend_type>select</frontend_type>
|
17 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
18 |
-
<sort_order>1</sort_order>
|
19 |
-
<show_in_default>1</show_in_default>
|
20 |
-
<show_in_website>1</show_in_website>
|
21 |
-
<show_in_store>1</show_in_store>
|
22 |
-
</active>
|
23 |
-
<title translate="label">
|
24 |
-
<label>Title</label>
|
25 |
-
<frontend_type>text</frontend_type>
|
26 |
-
<sort_order>2</sort_order>
|
27 |
-
<show_in_default>1</show_in_default>
|
28 |
-
<show_in_website>1</show_in_website>
|
29 |
-
<show_in_store>1</show_in_store>
|
30 |
-
</title>
|
31 |
-
<sort_order translate="label">
|
32 |
-
<label>Sort Order</label>
|
33 |
-
<frontend_type>text</frontend_type>
|
34 |
-
<sort_order>100</sort_order>
|
35 |
-
<show_in_default>1</show_in_default>
|
36 |
-
<show_in_website>1</show_in_website>
|
37 |
-
<show_in_store>0</show_in_store>
|
38 |
-
</sort_order>
|
39 |
-
<price translate="label">
|
40 |
-
<label>Price</label>
|
41 |
-
<frontend_type>text</frontend_type>
|
42 |
-
<sort_order>3</sort_order>
|
43 |
-
<show_in_default>1</show_in_default>
|
44 |
-
<show_in_website>1</show_in_website>
|
45 |
-
<show_in_store>1</show_in_store>
|
46 |
-
</price>
|
47 |
-
<!--
|
48 |
-
This value is used to specify whether
|
49 |
-
the carrier is available only for
|
50 |
-
specific countries or all countries
|
51 |
-
available in the current Magento
|
52 |
-
installation.
|
53 |
-
-->
|
54 |
-
<!--<sallowspecific translate="label">-->
|
55 |
-
<!--<label>Ship to Applicable Countries</label>-->
|
56 |
-
<!--<frontend_type>select</frontend_type>-->
|
57 |
-
<!--<sort_order>90</sort_order>-->
|
58 |
-
<!--<frontend_class>shipping-applicable-country</frontend_class>-->
|
59 |
-
<!--<source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>-->
|
60 |
-
<!--<show_in_default>1</show_in_default>-->
|
61 |
-
<!--<show_in_website>1</show_in_website>-->
|
62 |
-
<!--<show_in_store>0</show_in_store>-->
|
63 |
-
<!--</sallowspecific>-->
|
64 |
-
<!--
|
65 |
-
If 'specific countries' is chosen
|
66 |
-
in the previous option, then this field
|
67 |
-
allows the administrator to specify
|
68 |
-
which specific countries this carrier
|
69 |
-
should be available for.
|
70 |
-
-->
|
71 |
-
<!--<specificcountry translate="label">-->
|
72 |
-
<!--<label>Ship to Specific Countries</label>-->
|
73 |
-
<!--<frontend_type>multiselect</frontend_type>-->
|
74 |
-
<!--<sort_order>91</sort_order>-->
|
75 |
-
<!--<source_model>adminhtml/system_config_source_country</source_model>-->
|
76 |
-
<!--<show_in_default>1</show_in_default>-->
|
77 |
-
<!--<show_in_website>1</show_in_website>-->
|
78 |
-
<!--<show_in_store>0</show_in_store>-->
|
79 |
-
<!--<can_be_empty>1</can_be_empty>-->
|
80 |
-
<!--</specificcountry>-->
|
81 |
-
</fields>
|
82 |
-
</skyboxcheckout_shipping>
|
83 |
-
</groups>
|
84 |
-
</carriers>
|
85 |
-
<payment>
|
86 |
-
<groups>
|
87 |
-
<skyboxcheckout_pay translate="label">
|
88 |
-
<label>Skybox Payment Module</label>
|
89 |
-
<sort_order>0</sort_order>
|
90 |
-
<show_in_default>1</show_in_default>
|
91 |
-
<show_in_website>1</show_in_website>
|
92 |
-
<show_in_store>0</show_in_store>
|
93 |
-
<fields>
|
94 |
-
<active translate="label">
|
95 |
-
<label>Enabled</label>
|
96 |
-
<frontend_type>select</frontend_type>
|
97 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
98 |
-
<sort_order>1</sort_order>
|
99 |
-
<show_in_default>1</show_in_default>
|
100 |
-
<show_in_website>1</show_in_website>
|
101 |
-
<show_in_store>0</show_in_store>
|
102 |
-
</active>
|
103 |
-
<order_status translate="label">
|
104 |
-
<label>New order status</label>
|
105 |
-
<frontend_type>select</frontend_type>
|
106 |
-
<source_model>adminhtml/system_config_source_order_status</source_model>
|
107 |
-
<!--<source_model>adminhtml/system_config_source_order_status_new</source_model>-->
|
108 |
-
<!--<source_model>adminhtml/system_config_source_order_status_processing</source_model>-->
|
109 |
-
<sort_order>2</sort_order>
|
110 |
-
<show_in_default>1</show_in_default>
|
111 |
-
<show_in_website>1</show_in_website>
|
112 |
-
<show_in_store>0</show_in_store>
|
113 |
-
</order_status>
|
114 |
-
<title translate="label">
|
115 |
-
<label>Title</label>
|
116 |
-
<frontend_type>text</frontend_type>
|
117 |
-
<sort_order>3</sort_order>
|
118 |
-
<show_in_default>1</show_in_default>
|
119 |
-
<show_in_website>1</show_in_website>
|
120 |
-
<show_in_store>0</show_in_store>
|
121 |
-
</title>
|
122 |
-
</fields>
|
123 |
-
</skyboxcheckout_pay>
|
124 |
-
</groups>
|
125 |
-
</payment>
|
126 |
-
</sections>
|
127 |
-
</config>
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<carriers translate="label" module="shipping">
|
5 |
+
<groups>
|
6 |
+
<skyboxcheckout_shipping translate="label">
|
7 |
+
<label>Shipping SkyboxCheckout</label>
|
8 |
+
<frontend_type>text</frontend_type>
|
9 |
+
<sort_order>0</sort_order>
|
10 |
+
<show_in_default>1</show_in_default>
|
11 |
+
<show_in_website>1</show_in_website>
|
12 |
+
<show_in_store>1</show_in_store>
|
13 |
+
<fields>
|
14 |
+
<active translate="label">
|
15 |
+
<label>Enabled</label>
|
16 |
+
<frontend_type>select</frontend_type>
|
17 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
18 |
+
<sort_order>1</sort_order>
|
19 |
+
<show_in_default>1</show_in_default>
|
20 |
+
<show_in_website>1</show_in_website>
|
21 |
+
<show_in_store>1</show_in_store>
|
22 |
+
</active>
|
23 |
+
<title translate="label">
|
24 |
+
<label>Title</label>
|
25 |
+
<frontend_type>text</frontend_type>
|
26 |
+
<sort_order>2</sort_order>
|
27 |
+
<show_in_default>1</show_in_default>
|
28 |
+
<show_in_website>1</show_in_website>
|
29 |
+
<show_in_store>1</show_in_store>
|
30 |
+
</title>
|
31 |
+
<sort_order translate="label">
|
32 |
+
<label>Sort Order</label>
|
33 |
+
<frontend_type>text</frontend_type>
|
34 |
+
<sort_order>100</sort_order>
|
35 |
+
<show_in_default>1</show_in_default>
|
36 |
+
<show_in_website>1</show_in_website>
|
37 |
+
<show_in_store>0</show_in_store>
|
38 |
+
</sort_order>
|
39 |
+
<price translate="label">
|
40 |
+
<label>Price</label>
|
41 |
+
<frontend_type>text</frontend_type>
|
42 |
+
<sort_order>3</sort_order>
|
43 |
+
<show_in_default>1</show_in_default>
|
44 |
+
<show_in_website>1</show_in_website>
|
45 |
+
<show_in_store>1</show_in_store>
|
46 |
+
</price>
|
47 |
+
<!--
|
48 |
+
This value is used to specify whether
|
49 |
+
the carrier is available only for
|
50 |
+
specific countries or all countries
|
51 |
+
available in the current Magento
|
52 |
+
installation.
|
53 |
+
-->
|
54 |
+
<!--<sallowspecific translate="label">-->
|
55 |
+
<!--<label>Ship to Applicable Countries</label>-->
|
56 |
+
<!--<frontend_type>select</frontend_type>-->
|
57 |
+
<!--<sort_order>90</sort_order>-->
|
58 |
+
<!--<frontend_class>shipping-applicable-country</frontend_class>-->
|
59 |
+
<!--<source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>-->
|
60 |
+
<!--<show_in_default>1</show_in_default>-->
|
61 |
+
<!--<show_in_website>1</show_in_website>-->
|
62 |
+
<!--<show_in_store>0</show_in_store>-->
|
63 |
+
<!--</sallowspecific>-->
|
64 |
+
<!--
|
65 |
+
If 'specific countries' is chosen
|
66 |
+
in the previous option, then this field
|
67 |
+
allows the administrator to specify
|
68 |
+
which specific countries this carrier
|
69 |
+
should be available for.
|
70 |
+
-->
|
71 |
+
<!--<specificcountry translate="label">-->
|
72 |
+
<!--<label>Ship to Specific Countries</label>-->
|
73 |
+
<!--<frontend_type>multiselect</frontend_type>-->
|
74 |
+
<!--<sort_order>91</sort_order>-->
|
75 |
+
<!--<source_model>adminhtml/system_config_source_country</source_model>-->
|
76 |
+
<!--<show_in_default>1</show_in_default>-->
|
77 |
+
<!--<show_in_website>1</show_in_website>-->
|
78 |
+
<!--<show_in_store>0</show_in_store>-->
|
79 |
+
<!--<can_be_empty>1</can_be_empty>-->
|
80 |
+
<!--</specificcountry>-->
|
81 |
+
</fields>
|
82 |
+
</skyboxcheckout_shipping>
|
83 |
+
</groups>
|
84 |
+
</carriers>
|
85 |
+
<payment>
|
86 |
+
<groups>
|
87 |
+
<skyboxcheckout_pay translate="label">
|
88 |
+
<label>Skybox Payment Module</label>
|
89 |
+
<sort_order>0</sort_order>
|
90 |
+
<show_in_default>1</show_in_default>
|
91 |
+
<show_in_website>1</show_in_website>
|
92 |
+
<show_in_store>0</show_in_store>
|
93 |
+
<fields>
|
94 |
+
<active translate="label">
|
95 |
+
<label>Enabled</label>
|
96 |
+
<frontend_type>select</frontend_type>
|
97 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
98 |
+
<sort_order>1</sort_order>
|
99 |
+
<show_in_default>1</show_in_default>
|
100 |
+
<show_in_website>1</show_in_website>
|
101 |
+
<show_in_store>0</show_in_store>
|
102 |
+
</active>
|
103 |
+
<order_status translate="label">
|
104 |
+
<label>New order status</label>
|
105 |
+
<frontend_type>select</frontend_type>
|
106 |
+
<source_model>adminhtml/system_config_source_order_status</source_model>
|
107 |
+
<!--<source_model>adminhtml/system_config_source_order_status_new</source_model>-->
|
108 |
+
<!--<source_model>adminhtml/system_config_source_order_status_processing</source_model>-->
|
109 |
+
<sort_order>2</sort_order>
|
110 |
+
<show_in_default>1</show_in_default>
|
111 |
+
<show_in_website>1</show_in_website>
|
112 |
+
<show_in_store>0</show_in_store>
|
113 |
+
</order_status>
|
114 |
+
<title translate="label">
|
115 |
+
<label>Title</label>
|
116 |
+
<frontend_type>text</frontend_type>
|
117 |
+
<sort_order>3</sort_order>
|
118 |
+
<show_in_default>1</show_in_default>
|
119 |
+
<show_in_website>1</show_in_website>
|
120 |
+
<show_in_store>0</show_in_store>
|
121 |
+
</title>
|
122 |
+
</fields>
|
123 |
+
</skyboxcheckout_pay>
|
124 |
+
</groups>
|
125 |
+
</payment>
|
126 |
+
</sections>
|
127 |
+
</config>
|
app/code/community/Skybox/Checkout/sql/skyboxcheckout_setup/mysql4-install-0.1.0.php
CHANGED
@@ -1,133 +1,133 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
|
4 |
-
$installer->startSetup();
|
5 |
-
|
6 |
-
// Table: sales_flat_quote_address
|
7 |
-
|
8 |
-
$installer->addAttribute('quote_address', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
9 |
-
$installer->addAttribute('quote_address', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
10 |
-
$installer->addAttribute('quote_address', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
11 |
-
$installer->addAttribute('quote_address', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
12 |
-
|
13 |
-
$installer->addAttribute('quote_address', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
14 |
-
$installer->addAttribute('quote_address', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
15 |
-
|
16 |
-
$installer->addAttribute('quote_address', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
17 |
-
$installer->addAttribute('quote_address', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
18 |
-
|
19 |
-
$installer->addAttribute('quote_address', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
20 |
-
$installer->addAttribute('quote_address', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
21 |
-
|
22 |
-
$installer->addAttribute('quote_address', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
23 |
-
$installer->addAttribute('quote_address', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
24 |
-
|
25 |
-
$installer->addAttribute('quote_address', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
26 |
-
$installer->addAttribute('quote_address', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
27 |
-
|
28 |
-
$installer->addAttribute('quote_address', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
29 |
-
$installer->addAttribute('quote_address', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
30 |
-
|
31 |
-
$installer->addAttribute('quote_address', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
32 |
-
$installer->addAttribute('quote_address', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
33 |
-
|
34 |
-
$installer->addAttribute('quote_address', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
35 |
-
$installer->addAttribute('quote_address', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
36 |
-
|
37 |
-
$installer->addAttribute('quote_address', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
38 |
-
$installer->addAttribute('quote_address', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
39 |
-
|
40 |
-
$installer->addAttribute('quote_address', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
41 |
-
$installer->addAttribute('quote_address', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
42 |
-
|
43 |
-
// Table: sales_flat_quote_item
|
44 |
-
|
45 |
-
$installer->addAttribute('quote_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
46 |
-
$installer->addAttribute('quote_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
47 |
-
$installer->addAttribute('quote_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
48 |
-
$installer->addAttribute('quote_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
49 |
-
$installer->addAttribute('quote_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
50 |
-
$installer->addAttribute('quote_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
51 |
-
|
52 |
-
$installer->addAttribute('quote_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
53 |
-
$installer->addAttribute('quote_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
54 |
-
$installer->addAttribute('quote_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
55 |
-
$installer->addAttribute('quote_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
56 |
-
$installer->addAttribute('quote_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
57 |
-
$installer->addAttribute('quote_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
58 |
-
$installer->addAttribute('quote_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
59 |
-
|
60 |
-
$installer->addAttribute('quote_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
61 |
-
$installer->addAttribute('quote_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
62 |
-
$installer->addAttribute('quote_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
63 |
-
$installer->addAttribute('quote_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
64 |
-
$installer->addAttribute('quote_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
65 |
-
$installer->addAttribute('quote_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
66 |
-
$installer->addAttribute('quote_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
67 |
-
|
68 |
-
|
69 |
-
// Table: sales_flat_order_item
|
70 |
-
|
71 |
-
$installer->addAttribute('order_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
72 |
-
$installer->addAttribute('order_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
73 |
-
$installer->addAttribute('order_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
74 |
-
$installer->addAttribute('order_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
75 |
-
$installer->addAttribute('order_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
76 |
-
$installer->addAttribute('order_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
77 |
-
|
78 |
-
$installer->addAttribute('order_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
79 |
-
$installer->addAttribute('order_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
80 |
-
$installer->addAttribute('order_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
81 |
-
$installer->addAttribute('order_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
82 |
-
$installer->addAttribute('order_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
83 |
-
$installer->addAttribute('order_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
84 |
-
$installer->addAttribute('order_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
85 |
-
|
86 |
-
$installer->addAttribute('order_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
87 |
-
$installer->addAttribute('order_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
88 |
-
$installer->addAttribute('order_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
89 |
-
$installer->addAttribute('order_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
90 |
-
$installer->addAttribute('order_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
91 |
-
$installer->addAttribute('order_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
92 |
-
$installer->addAttribute('order_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
93 |
-
|
94 |
-
|
95 |
-
// Table: sales_flat_order
|
96 |
-
|
97 |
-
$installer->addAttribute('order', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
98 |
-
$installer->addAttribute('order', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
99 |
-
$installer->addAttribute('order', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
100 |
-
$installer->addAttribute('order', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
101 |
-
|
102 |
-
$installer->addAttribute('order', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
103 |
-
$installer->addAttribute('order', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
104 |
-
|
105 |
-
$installer->addAttribute('order', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
106 |
-
$installer->addAttribute('order', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
107 |
-
|
108 |
-
$installer->addAttribute('order', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
109 |
-
$installer->addAttribute('order', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
110 |
-
|
111 |
-
$installer->addAttribute('order', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
112 |
-
$installer->addAttribute('order', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
113 |
-
|
114 |
-
$installer->addAttribute('order', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
115 |
-
$installer->addAttribute('order', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
116 |
-
|
117 |
-
$installer->addAttribute('order', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
118 |
-
$installer->addAttribute('order', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
119 |
-
|
120 |
-
$installer->addAttribute('order', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
121 |
-
$installer->addAttribute('order', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
122 |
-
|
123 |
-
$installer->addAttribute('order', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
124 |
-
$installer->addAttribute('order', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
125 |
-
|
126 |
-
$installer->addAttribute('order', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
127 |
-
$installer->addAttribute('order', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
128 |
-
|
129 |
-
$installer->addAttribute('order', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
130 |
-
$installer->addAttribute('order', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
131 |
-
|
132 |
-
|
133 |
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
|
4 |
+
$installer->startSetup();
|
5 |
+
|
6 |
+
// Table: sales_flat_quote_address
|
7 |
+
|
8 |
+
$installer->addAttribute('quote_address', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
9 |
+
$installer->addAttribute('quote_address', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
10 |
+
$installer->addAttribute('quote_address', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
11 |
+
$installer->addAttribute('quote_address', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
12 |
+
|
13 |
+
$installer->addAttribute('quote_address', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
14 |
+
$installer->addAttribute('quote_address', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
15 |
+
|
16 |
+
$installer->addAttribute('quote_address', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
17 |
+
$installer->addAttribute('quote_address', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
18 |
+
|
19 |
+
$installer->addAttribute('quote_address', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
20 |
+
$installer->addAttribute('quote_address', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
21 |
+
|
22 |
+
$installer->addAttribute('quote_address', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
23 |
+
$installer->addAttribute('quote_address', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
24 |
+
|
25 |
+
$installer->addAttribute('quote_address', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
26 |
+
$installer->addAttribute('quote_address', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
27 |
+
|
28 |
+
$installer->addAttribute('quote_address', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
29 |
+
$installer->addAttribute('quote_address', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
30 |
+
|
31 |
+
$installer->addAttribute('quote_address', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
32 |
+
$installer->addAttribute('quote_address', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
33 |
+
|
34 |
+
$installer->addAttribute('quote_address', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
35 |
+
$installer->addAttribute('quote_address', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
36 |
+
|
37 |
+
$installer->addAttribute('quote_address', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
38 |
+
$installer->addAttribute('quote_address', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
39 |
+
|
40 |
+
$installer->addAttribute('quote_address', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
41 |
+
$installer->addAttribute('quote_address', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
42 |
+
|
43 |
+
// Table: sales_flat_quote_item
|
44 |
+
|
45 |
+
$installer->addAttribute('quote_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
46 |
+
$installer->addAttribute('quote_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
47 |
+
$installer->addAttribute('quote_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
48 |
+
$installer->addAttribute('quote_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
49 |
+
$installer->addAttribute('quote_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
50 |
+
$installer->addAttribute('quote_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
51 |
+
|
52 |
+
$installer->addAttribute('quote_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
53 |
+
$installer->addAttribute('quote_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
54 |
+
$installer->addAttribute('quote_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
55 |
+
$installer->addAttribute('quote_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
56 |
+
$installer->addAttribute('quote_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
57 |
+
$installer->addAttribute('quote_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
58 |
+
$installer->addAttribute('quote_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
59 |
+
|
60 |
+
$installer->addAttribute('quote_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
61 |
+
$installer->addAttribute('quote_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
62 |
+
$installer->addAttribute('quote_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
63 |
+
$installer->addAttribute('quote_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
64 |
+
$installer->addAttribute('quote_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
65 |
+
$installer->addAttribute('quote_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
66 |
+
$installer->addAttribute('quote_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
67 |
+
|
68 |
+
|
69 |
+
// Table: sales_flat_order_item
|
70 |
+
|
71 |
+
$installer->addAttribute('order_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
72 |
+
$installer->addAttribute('order_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
73 |
+
$installer->addAttribute('order_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
74 |
+
$installer->addAttribute('order_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
75 |
+
$installer->addAttribute('order_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
76 |
+
$installer->addAttribute('order_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
77 |
+
|
78 |
+
$installer->addAttribute('order_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
79 |
+
$installer->addAttribute('order_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
80 |
+
$installer->addAttribute('order_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
81 |
+
$installer->addAttribute('order_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
82 |
+
$installer->addAttribute('order_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
83 |
+
$installer->addAttribute('order_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
84 |
+
$installer->addAttribute('order_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
85 |
+
|
86 |
+
$installer->addAttribute('order_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
87 |
+
$installer->addAttribute('order_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
88 |
+
$installer->addAttribute('order_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
89 |
+
$installer->addAttribute('order_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
90 |
+
$installer->addAttribute('order_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
91 |
+
$installer->addAttribute('order_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
92 |
+
$installer->addAttribute('order_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
93 |
+
|
94 |
+
|
95 |
+
// Table: sales_flat_order
|
96 |
+
|
97 |
+
$installer->addAttribute('order', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
98 |
+
$installer->addAttribute('order', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
99 |
+
$installer->addAttribute('order', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
100 |
+
$installer->addAttribute('order', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
101 |
+
|
102 |
+
$installer->addAttribute('order', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
103 |
+
$installer->addAttribute('order', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
104 |
+
|
105 |
+
$installer->addAttribute('order', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
106 |
+
$installer->addAttribute('order', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
107 |
+
|
108 |
+
$installer->addAttribute('order', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
109 |
+
$installer->addAttribute('order', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
110 |
+
|
111 |
+
$installer->addAttribute('order', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
112 |
+
$installer->addAttribute('order', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
113 |
+
|
114 |
+
$installer->addAttribute('order', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
115 |
+
$installer->addAttribute('order', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
116 |
+
|
117 |
+
$installer->addAttribute('order', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
118 |
+
$installer->addAttribute('order', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
119 |
+
|
120 |
+
$installer->addAttribute('order', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
121 |
+
$installer->addAttribute('order', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
122 |
+
|
123 |
+
$installer->addAttribute('order', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
124 |
+
$installer->addAttribute('order', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
125 |
+
|
126 |
+
$installer->addAttribute('order', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
127 |
+
$installer->addAttribute('order', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
128 |
+
|
129 |
+
$installer->addAttribute('order', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
130 |
+
$installer->addAttribute('order', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
131 |
+
|
132 |
+
|
133 |
$installer->endSetup();
|
app/code/community/Skybox/Checkout/sql/skyboxcheckout_setup/mysql4-upgrade-0.1.0-0.1.1.php
CHANGED
@@ -1,68 +1,68 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
echo 'Running This Upgrade: ' . get_class($this) . "\n <br /> \n";
|
4 |
-
|
5 |
-
|
6 |
-
$installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
|
7 |
-
$installer->startSetup();
|
8 |
-
/*
|
9 |
-
$installer->addAttribute('quote_address', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
10 |
-
$installer->addAttribute('quote_address', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
11 |
-
|
12 |
-
$installer->addAttribute('quote_address', 'Taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
13 |
-
$installer->addAttribute('quote_address', 'Taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
14 |
-
|
15 |
-
$installer->addAttribute('quote_address', 'Handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
16 |
-
$installer->addAttribute('quote_address', 'Handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
17 |
-
|
18 |
-
$installer->addAttribute('quote_address', 'Shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
19 |
-
$installer->addAttribute('quote_address', 'Shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
20 |
-
|
21 |
-
$installer->addAttribute('quote_address', 'Insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
22 |
-
$installer->addAttribute('quote_address', 'Insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
23 |
-
|
24 |
-
$installer->addAttribute('quote_address', 'Clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
25 |
-
$installer->addAttribute('quote_address', 'Clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
26 |
-
|
27 |
-
$installer->addAttribute('quote_address', 'Duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
28 |
-
$installer->addAttribute('quote_address', 'Duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
29 |
-
|
30 |
-
$installer->addAttribute('quote_address', 'Adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
31 |
-
$installer->addAttribute('quote_address', 'Adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));*/
|
32 |
-
|
33 |
-
/*$installer->addAttribute('quote_address', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));*/
|
34 |
-
|
35 |
-
|
36 |
-
/*$installer->addAttribute('order', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
37 |
-
$installer->addAttribute('order', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
38 |
-
$installer->addAttribute('order', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
39 |
-
$installer->addAttribute('order', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
40 |
-
|
41 |
-
$installer->addAttribute('order', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
42 |
-
$installer->addAttribute('order', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
43 |
-
|
44 |
-
$installer->addAttribute('order', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
45 |
-
$installer->addAttribute('order', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
46 |
-
|
47 |
-
$installer->addAttribute('order', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
48 |
-
$installer->addAttribute('order', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
49 |
-
|
50 |
-
$installer->addAttribute('order', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
51 |
-
$installer->addAttribute('order', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
52 |
-
|
53 |
-
$installer->addAttribute('order', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
54 |
-
$installer->addAttribute('order', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
55 |
-
|
56 |
-
$installer->addAttribute('order', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
57 |
-
$installer->addAttribute('order', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
58 |
-
|
59 |
-
$installer->addAttribute('order', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
60 |
-
$installer->addAttribute('order', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
61 |
-
|
62 |
-
$installer->addAttribute('order', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
63 |
-
$installer->addAttribute('order', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
64 |
-
|
65 |
-
$installer->addAttribute('order', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
66 |
-
*/
|
67 |
-
|
68 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
echo 'Running This Upgrade: ' . get_class($this) . "\n <br /> \n";
|
4 |
+
|
5 |
+
|
6 |
+
$installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
|
7 |
+
$installer->startSetup();
|
8 |
+
/*
|
9 |
+
$installer->addAttribute('quote_address', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
10 |
+
$installer->addAttribute('quote_address', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
11 |
+
|
12 |
+
$installer->addAttribute('quote_address', 'Taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
13 |
+
$installer->addAttribute('quote_address', 'Taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
14 |
+
|
15 |
+
$installer->addAttribute('quote_address', 'Handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
16 |
+
$installer->addAttribute('quote_address', 'Handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
17 |
+
|
18 |
+
$installer->addAttribute('quote_address', 'Shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
19 |
+
$installer->addAttribute('quote_address', 'Shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
20 |
+
|
21 |
+
$installer->addAttribute('quote_address', 'Insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
22 |
+
$installer->addAttribute('quote_address', 'Insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
23 |
+
|
24 |
+
$installer->addAttribute('quote_address', 'Clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
25 |
+
$installer->addAttribute('quote_address', 'Clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
26 |
+
|
27 |
+
$installer->addAttribute('quote_address', 'Duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
28 |
+
$installer->addAttribute('quote_address', 'Duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
29 |
+
|
30 |
+
$installer->addAttribute('quote_address', 'Adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
31 |
+
$installer->addAttribute('quote_address', 'Adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));*/
|
32 |
+
|
33 |
+
/*$installer->addAttribute('quote_address', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));*/
|
34 |
+
|
35 |
+
|
36 |
+
/*$installer->addAttribute('order', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
37 |
+
$installer->addAttribute('order', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
38 |
+
$installer->addAttribute('order', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
39 |
+
$installer->addAttribute('order', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
40 |
+
|
41 |
+
$installer->addAttribute('order', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
42 |
+
$installer->addAttribute('order', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
43 |
+
|
44 |
+
$installer->addAttribute('order', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
45 |
+
$installer->addAttribute('order', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
46 |
+
|
47 |
+
$installer->addAttribute('order', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
48 |
+
$installer->addAttribute('order', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
49 |
+
|
50 |
+
$installer->addAttribute('order', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
51 |
+
$installer->addAttribute('order', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
52 |
+
|
53 |
+
$installer->addAttribute('order', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
54 |
+
$installer->addAttribute('order', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
55 |
+
|
56 |
+
$installer->addAttribute('order', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
57 |
+
$installer->addAttribute('order', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
58 |
+
|
59 |
+
$installer->addAttribute('order', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
60 |
+
$installer->addAttribute('order', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
61 |
+
|
62 |
+
$installer->addAttribute('order', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
63 |
+
$installer->addAttribute('order', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
64 |
+
|
65 |
+
$installer->addAttribute('order', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
66 |
+
*/
|
67 |
+
|
68 |
+
$installer->endSetup();
|
app/code/community/Skybox/Checkout/sql/skyboxcheckout_setup/mysql4-upgrade-0.1.0-0.1.2.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";
|
4 |
-
|
5 |
-
|
6 |
-
$installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
|
7 |
-
$installer->startSetup();
|
8 |
-
/*
|
9 |
-
$installer->addAttribute('quote_address', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
10 |
-
$installer->addAttribute('quote_address', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
11 |
-
|
12 |
-
$installer->addAttribute('order', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
13 |
-
$installer->addAttribute('order', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
14 |
-
*/
|
15 |
-
$installer->endSetup();
|
16 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";
|
4 |
+
|
5 |
+
|
6 |
+
$installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
|
7 |
+
$installer->startSetup();
|
8 |
+
/*
|
9 |
+
$installer->addAttribute('quote_address', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
10 |
+
$installer->addAttribute('quote_address', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
11 |
+
|
12 |
+
$installer->addAttribute('order', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
13 |
+
$installer->addAttribute('order', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
14 |
+
*/
|
15 |
+
$installer->endSetup();
|
16 |
+
|
app/code/community/Skybox/Checkout/sql/skyboxcheckout_setup/mysql4-upgrade-1.2.5-1.2.5.2.php
CHANGED
@@ -1,138 +1,138 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";
|
4 |
-
|
5 |
-
|
6 |
-
// @note: Force Table entities created!
|
7 |
-
|
8 |
-
$installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
|
9 |
-
$installer->startSetup();
|
10 |
-
|
11 |
-
// Table: sales_flat_quote_address
|
12 |
-
|
13 |
-
$installer->addAttribute('quote_address', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
14 |
-
$installer->addAttribute('quote_address', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
15 |
-
$installer->addAttribute('quote_address', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
16 |
-
$installer->addAttribute('quote_address', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
17 |
-
|
18 |
-
$installer->addAttribute('quote_address', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
19 |
-
$installer->addAttribute('quote_address', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
20 |
-
|
21 |
-
$installer->addAttribute('quote_address', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
22 |
-
$installer->addAttribute('quote_address', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
23 |
-
|
24 |
-
$installer->addAttribute('quote_address', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
25 |
-
$installer->addAttribute('quote_address', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
26 |
-
|
27 |
-
$installer->addAttribute('quote_address', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
28 |
-
$installer->addAttribute('quote_address', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
29 |
-
|
30 |
-
$installer->addAttribute('quote_address', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
31 |
-
$installer->addAttribute('quote_address', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
32 |
-
|
33 |
-
$installer->addAttribute('quote_address', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
34 |
-
$installer->addAttribute('quote_address', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
35 |
-
|
36 |
-
$installer->addAttribute('quote_address', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
37 |
-
$installer->addAttribute('quote_address', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
38 |
-
|
39 |
-
$installer->addAttribute('quote_address', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
40 |
-
$installer->addAttribute('quote_address', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
41 |
-
|
42 |
-
$installer->addAttribute('quote_address', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
43 |
-
$installer->addAttribute('quote_address', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
44 |
-
|
45 |
-
$installer->addAttribute('quote_address', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
46 |
-
$installer->addAttribute('quote_address', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
47 |
-
|
48 |
-
// Table: sales_flat_quote_item
|
49 |
-
|
50 |
-
$installer->addAttribute('quote_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
51 |
-
$installer->addAttribute('quote_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
52 |
-
$installer->addAttribute('quote_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
53 |
-
$installer->addAttribute('quote_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
54 |
-
$installer->addAttribute('quote_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
55 |
-
$installer->addAttribute('quote_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
56 |
-
|
57 |
-
$installer->addAttribute('quote_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
58 |
-
$installer->addAttribute('quote_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
59 |
-
$installer->addAttribute('quote_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
60 |
-
$installer->addAttribute('quote_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
61 |
-
$installer->addAttribute('quote_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
62 |
-
$installer->addAttribute('quote_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
63 |
-
$installer->addAttribute('quote_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
64 |
-
|
65 |
-
$installer->addAttribute('quote_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
66 |
-
$installer->addAttribute('quote_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
67 |
-
$installer->addAttribute('quote_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
68 |
-
$installer->addAttribute('quote_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
69 |
-
$installer->addAttribute('quote_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
70 |
-
$installer->addAttribute('quote_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
71 |
-
$installer->addAttribute('quote_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
72 |
-
|
73 |
-
|
74 |
-
// Table: sales_flat_order_item
|
75 |
-
|
76 |
-
$installer->addAttribute('order_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
77 |
-
$installer->addAttribute('order_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
78 |
-
$installer->addAttribute('order_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
79 |
-
$installer->addAttribute('order_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
80 |
-
$installer->addAttribute('order_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
81 |
-
$installer->addAttribute('order_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
82 |
-
|
83 |
-
$installer->addAttribute('order_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
84 |
-
$installer->addAttribute('order_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
85 |
-
$installer->addAttribute('order_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
86 |
-
$installer->addAttribute('order_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
87 |
-
$installer->addAttribute('order_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
88 |
-
$installer->addAttribute('order_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
89 |
-
$installer->addAttribute('order_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
90 |
-
|
91 |
-
$installer->addAttribute('order_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
92 |
-
$installer->addAttribute('order_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
93 |
-
$installer->addAttribute('order_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
94 |
-
$installer->addAttribute('order_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
95 |
-
$installer->addAttribute('order_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
96 |
-
$installer->addAttribute('order_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
97 |
-
$installer->addAttribute('order_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
98 |
-
|
99 |
-
|
100 |
-
// Table: sales_flat_order
|
101 |
-
|
102 |
-
$installer->addAttribute('order', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
103 |
-
$installer->addAttribute('order', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
104 |
-
$installer->addAttribute('order', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
105 |
-
$installer->addAttribute('order', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
106 |
-
|
107 |
-
$installer->addAttribute('order', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
108 |
-
$installer->addAttribute('order', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
109 |
-
|
110 |
-
$installer->addAttribute('order', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
111 |
-
$installer->addAttribute('order', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
112 |
-
|
113 |
-
$installer->addAttribute('order', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
114 |
-
$installer->addAttribute('order', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
115 |
-
|
116 |
-
$installer->addAttribute('order', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
117 |
-
$installer->addAttribute('order', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
118 |
-
|
119 |
-
$installer->addAttribute('order', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
120 |
-
$installer->addAttribute('order', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
121 |
-
|
122 |
-
$installer->addAttribute('order', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
123 |
-
$installer->addAttribute('order', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
124 |
-
|
125 |
-
$installer->addAttribute('order', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
126 |
-
$installer->addAttribute('order', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
127 |
-
|
128 |
-
$installer->addAttribute('order', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
129 |
-
$installer->addAttribute('order', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
130 |
-
|
131 |
-
$installer->addAttribute('order', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
132 |
-
$installer->addAttribute('order', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
133 |
-
|
134 |
-
$installer->addAttribute('order', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
135 |
-
$installer->addAttribute('order', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
136 |
-
|
137 |
-
|
138 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";
|
4 |
+
|
5 |
+
|
6 |
+
// @note: Force Table entities created!
|
7 |
+
|
8 |
+
$installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
|
9 |
+
$installer->startSetup();
|
10 |
+
|
11 |
+
// Table: sales_flat_quote_address
|
12 |
+
|
13 |
+
$installer->addAttribute('quote_address', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
14 |
+
$installer->addAttribute('quote_address', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
15 |
+
$installer->addAttribute('quote_address', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
16 |
+
$installer->addAttribute('quote_address', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
17 |
+
|
18 |
+
$installer->addAttribute('quote_address', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
19 |
+
$installer->addAttribute('quote_address', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
20 |
+
|
21 |
+
$installer->addAttribute('quote_address', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
22 |
+
$installer->addAttribute('quote_address', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
23 |
+
|
24 |
+
$installer->addAttribute('quote_address', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
25 |
+
$installer->addAttribute('quote_address', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
26 |
+
|
27 |
+
$installer->addAttribute('quote_address', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
28 |
+
$installer->addAttribute('quote_address', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
29 |
+
|
30 |
+
$installer->addAttribute('quote_address', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
31 |
+
$installer->addAttribute('quote_address', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
32 |
+
|
33 |
+
$installer->addAttribute('quote_address', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
34 |
+
$installer->addAttribute('quote_address', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
35 |
+
|
36 |
+
$installer->addAttribute('quote_address', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
37 |
+
$installer->addAttribute('quote_address', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
38 |
+
|
39 |
+
$installer->addAttribute('quote_address', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
40 |
+
$installer->addAttribute('quote_address', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
41 |
+
|
42 |
+
$installer->addAttribute('quote_address', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
43 |
+
$installer->addAttribute('quote_address', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
44 |
+
|
45 |
+
$installer->addAttribute('quote_address', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
46 |
+
$installer->addAttribute('quote_address', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
47 |
+
|
48 |
+
// Table: sales_flat_quote_item
|
49 |
+
|
50 |
+
$installer->addAttribute('quote_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
51 |
+
$installer->addAttribute('quote_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
52 |
+
$installer->addAttribute('quote_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
53 |
+
$installer->addAttribute('quote_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
54 |
+
$installer->addAttribute('quote_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
55 |
+
$installer->addAttribute('quote_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
56 |
+
|
57 |
+
$installer->addAttribute('quote_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
58 |
+
$installer->addAttribute('quote_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
59 |
+
$installer->addAttribute('quote_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
60 |
+
$installer->addAttribute('quote_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
61 |
+
$installer->addAttribute('quote_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
62 |
+
$installer->addAttribute('quote_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
63 |
+
$installer->addAttribute('quote_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
64 |
+
|
65 |
+
$installer->addAttribute('quote_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
66 |
+
$installer->addAttribute('quote_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
67 |
+
$installer->addAttribute('quote_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
68 |
+
$installer->addAttribute('quote_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
69 |
+
$installer->addAttribute('quote_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
70 |
+
$installer->addAttribute('quote_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
71 |
+
$installer->addAttribute('quote_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
72 |
+
|
73 |
+
|
74 |
+
// Table: sales_flat_order_item
|
75 |
+
|
76 |
+
$installer->addAttribute('order_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
77 |
+
$installer->addAttribute('order_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
78 |
+
$installer->addAttribute('order_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
79 |
+
$installer->addAttribute('order_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
80 |
+
$installer->addAttribute('order_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
81 |
+
$installer->addAttribute('order_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
82 |
+
|
83 |
+
$installer->addAttribute('order_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
84 |
+
$installer->addAttribute('order_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
85 |
+
$installer->addAttribute('order_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
86 |
+
$installer->addAttribute('order_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
87 |
+
$installer->addAttribute('order_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
88 |
+
$installer->addAttribute('order_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
89 |
+
$installer->addAttribute('order_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
90 |
+
|
91 |
+
$installer->addAttribute('order_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
92 |
+
$installer->addAttribute('order_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
93 |
+
$installer->addAttribute('order_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
94 |
+
$installer->addAttribute('order_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
95 |
+
$installer->addAttribute('order_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
96 |
+
$installer->addAttribute('order_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
97 |
+
$installer->addAttribute('order_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
98 |
+
|
99 |
+
|
100 |
+
// Table: sales_flat_order
|
101 |
+
|
102 |
+
$installer->addAttribute('order', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
103 |
+
$installer->addAttribute('order', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
104 |
+
$installer->addAttribute('order', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
105 |
+
$installer->addAttribute('order', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
106 |
+
|
107 |
+
$installer->addAttribute('order', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
108 |
+
$installer->addAttribute('order', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
109 |
+
|
110 |
+
$installer->addAttribute('order', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
111 |
+
$installer->addAttribute('order', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
112 |
+
|
113 |
+
$installer->addAttribute('order', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
114 |
+
$installer->addAttribute('order', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
115 |
+
|
116 |
+
$installer->addAttribute('order', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
117 |
+
$installer->addAttribute('order', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
118 |
+
|
119 |
+
$installer->addAttribute('order', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
120 |
+
$installer->addAttribute('order', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
121 |
+
|
122 |
+
$installer->addAttribute('order', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
123 |
+
$installer->addAttribute('order', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
124 |
+
|
125 |
+
$installer->addAttribute('order', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
126 |
+
$installer->addAttribute('order', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
127 |
+
|
128 |
+
$installer->addAttribute('order', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
129 |
+
$installer->addAttribute('order', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
130 |
+
|
131 |
+
$installer->addAttribute('order', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
132 |
+
$installer->addAttribute('order', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
133 |
+
|
134 |
+
$installer->addAttribute('order', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
135 |
+
$installer->addAttribute('order', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
136 |
+
|
137 |
+
|
138 |
+
$installer->endSetup();
|
app/code/community/Skybox/Checkout/sql/skyboxcheckout_setup/mysql4-upgrade-1.2.5.2-1.2.6.php
CHANGED
@@ -1,138 +1,138 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";
|
4 |
-
|
5 |
-
|
6 |
-
// @note: Force Table entities created!
|
7 |
-
|
8 |
-
$installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
|
9 |
-
$installer->startSetup();
|
10 |
-
|
11 |
-
// Table: sales_flat_quote_address
|
12 |
-
|
13 |
-
$installer->addAttribute('quote_address', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
14 |
-
$installer->addAttribute('quote_address', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
15 |
-
$installer->addAttribute('quote_address', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
16 |
-
$installer->addAttribute('quote_address', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
17 |
-
|
18 |
-
$installer->addAttribute('quote_address', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
19 |
-
$installer->addAttribute('quote_address', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
20 |
-
|
21 |
-
$installer->addAttribute('quote_address', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
22 |
-
$installer->addAttribute('quote_address', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
23 |
-
|
24 |
-
$installer->addAttribute('quote_address', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
25 |
-
$installer->addAttribute('quote_address', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
26 |
-
|
27 |
-
$installer->addAttribute('quote_address', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
28 |
-
$installer->addAttribute('quote_address', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
29 |
-
|
30 |
-
$installer->addAttribute('quote_address', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
31 |
-
$installer->addAttribute('quote_address', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
32 |
-
|
33 |
-
$installer->addAttribute('quote_address', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
34 |
-
$installer->addAttribute('quote_address', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
35 |
-
|
36 |
-
$installer->addAttribute('quote_address', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
37 |
-
$installer->addAttribute('quote_address', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
38 |
-
|
39 |
-
$installer->addAttribute('quote_address', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
40 |
-
$installer->addAttribute('quote_address', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
41 |
-
|
42 |
-
$installer->addAttribute('quote_address', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
43 |
-
$installer->addAttribute('quote_address', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
44 |
-
|
45 |
-
$installer->addAttribute('quote_address', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
46 |
-
$installer->addAttribute('quote_address', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
47 |
-
|
48 |
-
// Table: sales_flat_quote_item
|
49 |
-
|
50 |
-
$installer->addAttribute('quote_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
51 |
-
$installer->addAttribute('quote_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
52 |
-
$installer->addAttribute('quote_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
53 |
-
$installer->addAttribute('quote_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
54 |
-
$installer->addAttribute('quote_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
55 |
-
$installer->addAttribute('quote_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
56 |
-
|
57 |
-
$installer->addAttribute('quote_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
58 |
-
$installer->addAttribute('quote_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
59 |
-
$installer->addAttribute('quote_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
60 |
-
$installer->addAttribute('quote_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
61 |
-
$installer->addAttribute('quote_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
62 |
-
$installer->addAttribute('quote_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
63 |
-
$installer->addAttribute('quote_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
64 |
-
|
65 |
-
$installer->addAttribute('quote_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
66 |
-
$installer->addAttribute('quote_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
67 |
-
$installer->addAttribute('quote_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
68 |
-
$installer->addAttribute('quote_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
69 |
-
$installer->addAttribute('quote_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
70 |
-
$installer->addAttribute('quote_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
71 |
-
$installer->addAttribute('quote_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
72 |
-
|
73 |
-
|
74 |
-
// Table: sales_flat_order_item
|
75 |
-
|
76 |
-
$installer->addAttribute('order_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
77 |
-
$installer->addAttribute('order_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
78 |
-
$installer->addAttribute('order_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
79 |
-
$installer->addAttribute('order_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
80 |
-
$installer->addAttribute('order_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
81 |
-
$installer->addAttribute('order_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
82 |
-
|
83 |
-
$installer->addAttribute('order_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
84 |
-
$installer->addAttribute('order_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
85 |
-
$installer->addAttribute('order_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
86 |
-
$installer->addAttribute('order_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
87 |
-
$installer->addAttribute('order_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
88 |
-
$installer->addAttribute('order_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
89 |
-
$installer->addAttribute('order_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
90 |
-
|
91 |
-
$installer->addAttribute('order_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
92 |
-
$installer->addAttribute('order_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
93 |
-
$installer->addAttribute('order_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
94 |
-
$installer->addAttribute('order_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
95 |
-
$installer->addAttribute('order_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
96 |
-
$installer->addAttribute('order_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
97 |
-
$installer->addAttribute('order_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
98 |
-
|
99 |
-
|
100 |
-
// Table: sales_flat_order
|
101 |
-
|
102 |
-
$installer->addAttribute('order', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
103 |
-
$installer->addAttribute('order', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
104 |
-
$installer->addAttribute('order', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
105 |
-
$installer->addAttribute('order', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
106 |
-
|
107 |
-
$installer->addAttribute('order', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
108 |
-
$installer->addAttribute('order', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
109 |
-
|
110 |
-
$installer->addAttribute('order', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
111 |
-
$installer->addAttribute('order', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
112 |
-
|
113 |
-
$installer->addAttribute('order', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
114 |
-
$installer->addAttribute('order', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
115 |
-
|
116 |
-
$installer->addAttribute('order', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
117 |
-
$installer->addAttribute('order', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
118 |
-
|
119 |
-
$installer->addAttribute('order', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
120 |
-
$installer->addAttribute('order', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
121 |
-
|
122 |
-
$installer->addAttribute('order', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
123 |
-
$installer->addAttribute('order', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
124 |
-
|
125 |
-
$installer->addAttribute('order', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
126 |
-
$installer->addAttribute('order', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
127 |
-
|
128 |
-
$installer->addAttribute('order', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
129 |
-
$installer->addAttribute('order', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
130 |
-
|
131 |
-
$installer->addAttribute('order', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
132 |
-
$installer->addAttribute('order', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
133 |
-
|
134 |
-
$installer->addAttribute('order', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
135 |
-
$installer->addAttribute('order', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
136 |
-
|
137 |
-
|
138 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";
|
4 |
+
|
5 |
+
|
6 |
+
// @note: Force Table entities created!
|
7 |
+
|
8 |
+
$installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
|
9 |
+
$installer->startSetup();
|
10 |
+
|
11 |
+
// Table: sales_flat_quote_address
|
12 |
+
|
13 |
+
$installer->addAttribute('quote_address', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
14 |
+
$installer->addAttribute('quote_address', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
15 |
+
$installer->addAttribute('quote_address', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
16 |
+
$installer->addAttribute('quote_address', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
17 |
+
|
18 |
+
$installer->addAttribute('quote_address', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
19 |
+
$installer->addAttribute('quote_address', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
20 |
+
|
21 |
+
$installer->addAttribute('quote_address', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
22 |
+
$installer->addAttribute('quote_address', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
23 |
+
|
24 |
+
$installer->addAttribute('quote_address', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
25 |
+
$installer->addAttribute('quote_address', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
26 |
+
|
27 |
+
$installer->addAttribute('quote_address', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
28 |
+
$installer->addAttribute('quote_address', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
29 |
+
|
30 |
+
$installer->addAttribute('quote_address', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
31 |
+
$installer->addAttribute('quote_address', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
32 |
+
|
33 |
+
$installer->addAttribute('quote_address', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
34 |
+
$installer->addAttribute('quote_address', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
35 |
+
|
36 |
+
$installer->addAttribute('quote_address', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
37 |
+
$installer->addAttribute('quote_address', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
38 |
+
|
39 |
+
$installer->addAttribute('quote_address', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
40 |
+
$installer->addAttribute('quote_address', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
41 |
+
|
42 |
+
$installer->addAttribute('quote_address', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
43 |
+
$installer->addAttribute('quote_address', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
44 |
+
|
45 |
+
$installer->addAttribute('quote_address', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
46 |
+
$installer->addAttribute('quote_address', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
47 |
+
|
48 |
+
// Table: sales_flat_quote_item
|
49 |
+
|
50 |
+
$installer->addAttribute('quote_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
51 |
+
$installer->addAttribute('quote_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
52 |
+
$installer->addAttribute('quote_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
53 |
+
$installer->addAttribute('quote_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
54 |
+
$installer->addAttribute('quote_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
55 |
+
$installer->addAttribute('quote_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
56 |
+
|
57 |
+
$installer->addAttribute('quote_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
58 |
+
$installer->addAttribute('quote_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
59 |
+
$installer->addAttribute('quote_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
60 |
+
$installer->addAttribute('quote_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
61 |
+
$installer->addAttribute('quote_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
62 |
+
$installer->addAttribute('quote_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
63 |
+
$installer->addAttribute('quote_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
64 |
+
|
65 |
+
$installer->addAttribute('quote_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
66 |
+
$installer->addAttribute('quote_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
67 |
+
$installer->addAttribute('quote_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
68 |
+
$installer->addAttribute('quote_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
69 |
+
$installer->addAttribute('quote_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
70 |
+
$installer->addAttribute('quote_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
71 |
+
$installer->addAttribute('quote_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
72 |
+
|
73 |
+
|
74 |
+
// Table: sales_flat_order_item
|
75 |
+
|
76 |
+
$installer->addAttribute('order_item', 'id_product_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
77 |
+
$installer->addAttribute('order_item', 'price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
78 |
+
$installer->addAttribute('order_item', 'customs_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
79 |
+
$installer->addAttribute('order_item', 'shipping_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
80 |
+
$installer->addAttribute('order_item', 'insurance_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
81 |
+
$installer->addAttribute('order_item', 'total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
82 |
+
|
83 |
+
$installer->addAttribute('order_item', 'price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
84 |
+
$installer->addAttribute('order_item', 'customs_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
85 |
+
$installer->addAttribute('order_item', 'shipping_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
86 |
+
$installer->addAttribute('order_item', 'insurance_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
87 |
+
$installer->addAttribute('order_item', 'total_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
88 |
+
$installer->addAttribute('order_item', 'guid_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
89 |
+
$installer->addAttribute('order_item', 'row_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
90 |
+
|
91 |
+
$installer->addAttribute('order_item', 'base_price_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
92 |
+
$installer->addAttribute('order_item', 'base_price_usd_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
93 |
+
$installer->addAttribute('order_item', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
94 |
+
$installer->addAttribute('order_item', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
95 |
+
$installer->addAttribute('order_item', 'adjust_label_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
96 |
+
$installer->addAttribute('order_item', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
97 |
+
$installer->addAttribute('order_item', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
98 |
+
|
99 |
+
|
100 |
+
// Table: sales_flat_order
|
101 |
+
|
102 |
+
$installer->addAttribute('order', 'subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
103 |
+
$installer->addAttribute('order', 'base_subtotal_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
104 |
+
$installer->addAttribute('order', 'grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
105 |
+
$installer->addAttribute('order', 'base_grand_total_skybox', array('type' => 'varchar', 'visible' => false, 'required' => false));
|
106 |
+
|
107 |
+
$installer->addAttribute('order', 'customs_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
108 |
+
$installer->addAttribute('order', 'customs_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
109 |
+
|
110 |
+
$installer->addAttribute('order', 'taxes_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
111 |
+
$installer->addAttribute('order', 'taxes_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
112 |
+
|
113 |
+
$installer->addAttribute('order', 'handling_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
114 |
+
$installer->addAttribute('order', 'handling_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
115 |
+
|
116 |
+
$installer->addAttribute('order', 'shipping_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
117 |
+
$installer->addAttribute('order', 'shipping_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
118 |
+
|
119 |
+
$installer->addAttribute('order', 'insurance_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
120 |
+
$installer->addAttribute('order', 'insurance_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
121 |
+
|
122 |
+
$installer->addAttribute('order', 'clearence_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
123 |
+
$installer->addAttribute('order', 'clearence_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
124 |
+
|
125 |
+
$installer->addAttribute('order', 'duties_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
126 |
+
$installer->addAttribute('order', 'duties_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
127 |
+
|
128 |
+
$installer->addAttribute('order', 'others_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
129 |
+
$installer->addAttribute('order', 'others_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
130 |
+
|
131 |
+
$installer->addAttribute('order', 'adjust_total_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
132 |
+
$installer->addAttribute('order', 'adjust_total_usd_skybox', array('type' => 'varchar', 'visible' => true, 'required' => false));
|
133 |
+
|
134 |
+
$installer->addAttribute('order', 'concepts_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
135 |
+
$installer->addAttribute('order', 'rmt_skybox', array('type' => 'text', 'visible' => true, 'required' => false));
|
136 |
+
|
137 |
+
|
138 |
+
$installer->endSetup();
|
app/code/community/Skybox/Core/Exception.php
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Core
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Core
|
8 |
-
* @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
*
|
13 |
-
* Exception
|
14 |
-
*
|
15 |
-
* @author César Tapia M. <ctapia@skyworldint.com>
|
16 |
-
*/
|
17 |
-
class Skybox_Core_Exception extends Mage_Core_Exception{
|
18 |
-
|
19 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Core
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Core
|
8 |
+
* @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
*
|
13 |
+
* Exception
|
14 |
+
*
|
15 |
+
* @author César Tapia M. <ctapia@skyworldint.com>
|
16 |
+
*/
|
17 |
+
class Skybox_Core_Exception extends Mage_Core_Exception{
|
18 |
+
|
19 |
+
}
|
app/code/community/Skybox/Core/Helper/Allow.php
CHANGED
@@ -1,236 +1,236 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Core
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Core
|
8 |
-
* @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Core_Helper_Allow extends Mage_Core_Helper_Abstract
|
11 |
-
{
|
12 |
-
const TYPE_LOCATION_ALLOW_STORE = 1;
|
13 |
-
const TYPE_LOCATION_ALLOW_CART_DISABLE = 0;
|
14 |
-
const TYPE_LOCATION_ALLOW_CART_SHOW = 1;
|
15 |
-
const TYPE_LOCATION_ALLOW_CART_HIDE = 3;
|
16 |
-
const FULL_ACTION_NAME_IFRAME = 'skbcheckout_international_index';
|
17 |
-
|
18 |
-
protected $_integrationType;
|
19 |
-
protected $_locationAllow;
|
20 |
-
protected $_actionName;
|
21 |
-
|
22 |
-
public function isPriceEnabled()
|
23 |
-
{
|
24 |
-
if ($this->getTypeLocationAllow()
|
25 |
-
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
26 |
-
) {
|
27 |
-
return true;
|
28 |
-
} elseif ($this->getTypeLocationAllow()
|
29 |
-
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
30 |
-
) {
|
31 |
-
return false;
|
32 |
-
} elseif ($this->getTypeLocationAllow()
|
33 |
-
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
34 |
-
) {
|
35 |
-
return false;
|
36 |
-
} elseif ($this->getTypeLocationAllow()
|
37 |
-
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
38 |
-
) {
|
39 |
-
return false;
|
40 |
-
}
|
41 |
-
|
42 |
-
return false;
|
43 |
-
}
|
44 |
-
|
45 |
-
public function isCartBarEnabled()
|
46 |
-
{
|
47 |
-
$fullActionName = $this->getFullActionName();
|
48 |
-
|
49 |
-
if ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_SHOW
|
50 |
-
&& $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE && $fullActionName != self::FULL_ACTION_NAME_IFRAME
|
51 |
-
) {
|
52 |
-
return true;
|
53 |
-
} elseif ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_SHOW
|
54 |
-
&& $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE && $fullActionName == self::FULL_ACTION_NAME_IFRAME
|
55 |
-
) {
|
56 |
-
return false;
|
57 |
-
} elseif ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_SHOW
|
58 |
-
&& $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
59 |
-
) {
|
60 |
-
return false;
|
61 |
-
} elseif ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_HIDE
|
62 |
-
&& $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE && $fullActionName != self::FULL_ACTION_NAME_IFRAME
|
63 |
-
) {
|
64 |
-
return false;
|
65 |
-
} elseif ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_HIDE
|
66 |
-
&& $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE && $fullActionName == self::FULL_ACTION_NAME_IFRAME
|
67 |
-
) {
|
68 |
-
return true;
|
69 |
-
} elseif ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_HIDE
|
70 |
-
&& $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
71 |
-
) {
|
72 |
-
return false;
|
73 |
-
}
|
74 |
-
|
75 |
-
return false;
|
76 |
-
}
|
77 |
-
|
78 |
-
public function isCartButtonEnabled()
|
79 |
-
{
|
80 |
-
if ($this->getTypeLocationAllow()
|
81 |
-
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
82 |
-
) {
|
83 |
-
return true;
|
84 |
-
} elseif ($this->getTypeLocationAllow()
|
85 |
-
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
86 |
-
) {
|
87 |
-
return false;
|
88 |
-
} elseif ($this->getTypeLocationAllow()
|
89 |
-
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
90 |
-
) {
|
91 |
-
return false;
|
92 |
-
} elseif ($this->getTypeLocationAllow()
|
93 |
-
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
94 |
-
) {
|
95 |
-
return false;
|
96 |
-
}
|
97 |
-
|
98 |
-
return false;
|
99 |
-
}
|
100 |
-
|
101 |
-
public function isCartButtonSkyboxEnabled()
|
102 |
-
{
|
103 |
-
if ($this->getTypeLocationAllow()
|
104 |
-
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
105 |
-
) {
|
106 |
-
return false;
|
107 |
-
} elseif ($this->getTypeLocationAllow()
|
108 |
-
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
109 |
-
) {
|
110 |
-
return false;
|
111 |
-
} elseif ($this->getTypeLocationAllow()
|
112 |
-
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
113 |
-
) {
|
114 |
-
return true;
|
115 |
-
} elseif ($this->getTypeLocationAllow()
|
116 |
-
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
117 |
-
) {
|
118 |
-
return false;
|
119 |
-
}
|
120 |
-
|
121 |
-
return false;
|
122 |
-
}
|
123 |
-
|
124 |
-
public function isChangeCountryEnabled()
|
125 |
-
{
|
126 |
-
if ($this->getTypeLocationAllow()
|
127 |
-
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
128 |
-
) {
|
129 |
-
return true;
|
130 |
-
} elseif ($this->getTypeLocationAllow()
|
131 |
-
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
132 |
-
) {
|
133 |
-
return false;
|
134 |
-
} elseif ($this->getTypeLocationAllow()
|
135 |
-
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
136 |
-
) {
|
137 |
-
return false;
|
138 |
-
} elseif ($this->getTypeLocationAllow()
|
139 |
-
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
140 |
-
) {
|
141 |
-
return false;
|
142 |
-
}
|
143 |
-
|
144 |
-
return false;
|
145 |
-
}
|
146 |
-
|
147 |
-
public function isVisible()
|
148 |
-
{
|
149 |
-
return $this->getLocationAllow() != 0 ? true : false;
|
150 |
-
}
|
151 |
-
|
152 |
-
public function isOperationCartEnabled()
|
153 |
-
{
|
154 |
-
if ($this->getTypeLocationAllow()
|
155 |
-
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
156 |
-
) {
|
157 |
-
return false;
|
158 |
-
} elseif ($this->getTypeLocationAllow()
|
159 |
-
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
160 |
-
) {
|
161 |
-
return true;
|
162 |
-
} elseif ($this->getTypeLocationAllow()
|
163 |
-
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
164 |
-
) {
|
165 |
-
return false;
|
166 |
-
} elseif ($this->getTypeLocationAllow()
|
167 |
-
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
168 |
-
) {
|
169 |
-
return false;
|
170 |
-
}
|
171 |
-
|
172 |
-
return false;
|
173 |
-
}
|
174 |
-
|
175 |
-
public function showSubtotal()
|
176 |
-
{
|
177 |
-
if ($this->getTypeLocationAllow()
|
178 |
-
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
179 |
-
) {
|
180 |
-
return false;
|
181 |
-
} elseif ($this->getTypeLocationAllow()
|
182 |
-
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
183 |
-
) {
|
184 |
-
return true;
|
185 |
-
} elseif ($this->getTypeLocationAllow()
|
186 |
-
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
187 |
-
) {
|
188 |
-
return true;
|
189 |
-
} elseif ($this->getTypeLocationAllow()
|
190 |
-
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
191 |
-
) {
|
192 |
-
return true;
|
193 |
-
}
|
194 |
-
|
195 |
-
return true;
|
196 |
-
}
|
197 |
-
|
198 |
-
/*
|
199 |
-
* Get Store Type Location
|
200 |
-
*/
|
201 |
-
private function getTypeLocationAllow()
|
202 |
-
{
|
203 |
-
if ($this->_integrationType == null) {
|
204 |
-
$integrationType = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
|
205 |
-
$this->_integrationType = $integrationType;
|
206 |
-
}
|
207 |
-
return $this->_integrationType;
|
208 |
-
}
|
209 |
-
|
210 |
-
/*
|
211 |
-
* Get LocationAllow
|
212 |
-
*/
|
213 |
-
public function getLocationAllow()
|
214 |
-
{
|
215 |
-
if ($this->_locationAllow == null) {
|
216 |
-
$_checkout = Mage::getModel('skyboxcheckout/api_checkout');
|
217 |
-
$value = $_checkout->getLocationAllow();
|
218 |
-
$value = isset($value) ? $value : 0;
|
219 |
-
$this->_locationAllow = $value;
|
220 |
-
}
|
221 |
-
return $this->_locationAllow;
|
222 |
-
}
|
223 |
-
|
224 |
-
/*
|
225 |
-
* Get FullActionName router name
|
226 |
-
*/
|
227 |
-
private function getFullActionName()
|
228 |
-
{
|
229 |
-
$moduleName = Mage::app()->getRequest()->getModuleName();
|
230 |
-
$controllerName = Mage::app()->getRequest()->getControllerName();
|
231 |
-
$actionName = Mage::app()->getRequest()->getActionName();
|
232 |
-
|
233 |
-
$result = $moduleName . "_" . $controllerName . "_" . $actionName;
|
234 |
-
return $result;
|
235 |
-
}
|
236 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Core
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Core
|
8 |
+
* @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Core_Helper_Allow extends Mage_Core_Helper_Abstract
|
11 |
+
{
|
12 |
+
const TYPE_LOCATION_ALLOW_STORE = 1;
|
13 |
+
const TYPE_LOCATION_ALLOW_CART_DISABLE = 0;
|
14 |
+
const TYPE_LOCATION_ALLOW_CART_SHOW = 1;
|
15 |
+
const TYPE_LOCATION_ALLOW_CART_HIDE = 3;
|
16 |
+
const FULL_ACTION_NAME_IFRAME = 'skbcheckout_international_index';
|
17 |
+
|
18 |
+
protected $_integrationType;
|
19 |
+
protected $_locationAllow;
|
20 |
+
protected $_actionName;
|
21 |
+
|
22 |
+
public function isPriceEnabled()
|
23 |
+
{
|
24 |
+
if ($this->getTypeLocationAllow()
|
25 |
+
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
26 |
+
) {
|
27 |
+
return true;
|
28 |
+
} elseif ($this->getTypeLocationAllow()
|
29 |
+
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
30 |
+
) {
|
31 |
+
return false;
|
32 |
+
} elseif ($this->getTypeLocationAllow()
|
33 |
+
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
34 |
+
) {
|
35 |
+
return false;
|
36 |
+
} elseif ($this->getTypeLocationAllow()
|
37 |
+
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
38 |
+
) {
|
39 |
+
return false;
|
40 |
+
}
|
41 |
+
|
42 |
+
return false;
|
43 |
+
}
|
44 |
+
|
45 |
+
public function isCartBarEnabled()
|
46 |
+
{
|
47 |
+
$fullActionName = $this->getFullActionName();
|
48 |
+
|
49 |
+
if ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_SHOW
|
50 |
+
&& $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE && $fullActionName != self::FULL_ACTION_NAME_IFRAME
|
51 |
+
) {
|
52 |
+
return true;
|
53 |
+
} elseif ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_SHOW
|
54 |
+
&& $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE && $fullActionName == self::FULL_ACTION_NAME_IFRAME
|
55 |
+
) {
|
56 |
+
return false;
|
57 |
+
} elseif ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_SHOW
|
58 |
+
&& $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
59 |
+
) {
|
60 |
+
return false;
|
61 |
+
} elseif ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_HIDE
|
62 |
+
&& $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE && $fullActionName != self::FULL_ACTION_NAME_IFRAME
|
63 |
+
) {
|
64 |
+
return false;
|
65 |
+
} elseif ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_HIDE
|
66 |
+
&& $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE && $fullActionName == self::FULL_ACTION_NAME_IFRAME
|
67 |
+
) {
|
68 |
+
return true;
|
69 |
+
} elseif ($this->getTypeLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_HIDE
|
70 |
+
&& $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
71 |
+
) {
|
72 |
+
return false;
|
73 |
+
}
|
74 |
+
|
75 |
+
return false;
|
76 |
+
}
|
77 |
+
|
78 |
+
public function isCartButtonEnabled()
|
79 |
+
{
|
80 |
+
if ($this->getTypeLocationAllow()
|
81 |
+
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
82 |
+
) {
|
83 |
+
return true;
|
84 |
+
} elseif ($this->getTypeLocationAllow()
|
85 |
+
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
86 |
+
) {
|
87 |
+
return false;
|
88 |
+
} elseif ($this->getTypeLocationAllow()
|
89 |
+
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
90 |
+
) {
|
91 |
+
return false;
|
92 |
+
} elseif ($this->getTypeLocationAllow()
|
93 |
+
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
94 |
+
) {
|
95 |
+
return false;
|
96 |
+
}
|
97 |
+
|
98 |
+
return false;
|
99 |
+
}
|
100 |
+
|
101 |
+
public function isCartButtonSkyboxEnabled()
|
102 |
+
{
|
103 |
+
if ($this->getTypeLocationAllow()
|
104 |
+
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
105 |
+
) {
|
106 |
+
return false;
|
107 |
+
} elseif ($this->getTypeLocationAllow()
|
108 |
+
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
109 |
+
) {
|
110 |
+
return false;
|
111 |
+
} elseif ($this->getTypeLocationAllow()
|
112 |
+
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
113 |
+
) {
|
114 |
+
return true;
|
115 |
+
} elseif ($this->getTypeLocationAllow()
|
116 |
+
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
117 |
+
) {
|
118 |
+
return false;
|
119 |
+
}
|
120 |
+
|
121 |
+
return false;
|
122 |
+
}
|
123 |
+
|
124 |
+
public function isChangeCountryEnabled()
|
125 |
+
{
|
126 |
+
if ($this->getTypeLocationAllow()
|
127 |
+
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
128 |
+
) {
|
129 |
+
return true;
|
130 |
+
} elseif ($this->getTypeLocationAllow()
|
131 |
+
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
132 |
+
) {
|
133 |
+
return false;
|
134 |
+
} elseif ($this->getTypeLocationAllow()
|
135 |
+
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
136 |
+
) {
|
137 |
+
return false;
|
138 |
+
} elseif ($this->getTypeLocationAllow()
|
139 |
+
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
140 |
+
) {
|
141 |
+
return false;
|
142 |
+
}
|
143 |
+
|
144 |
+
return false;
|
145 |
+
}
|
146 |
+
|
147 |
+
public function isVisible()
|
148 |
+
{
|
149 |
+
return $this->getLocationAllow() != 0 ? true : false;
|
150 |
+
}
|
151 |
+
|
152 |
+
public function isOperationCartEnabled()
|
153 |
+
{
|
154 |
+
if ($this->getTypeLocationAllow()
|
155 |
+
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
156 |
+
) {
|
157 |
+
return false;
|
158 |
+
} elseif ($this->getTypeLocationAllow()
|
159 |
+
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
160 |
+
) {
|
161 |
+
return true;
|
162 |
+
} elseif ($this->getTypeLocationAllow()
|
163 |
+
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
164 |
+
) {
|
165 |
+
return false;
|
166 |
+
} elseif ($this->getTypeLocationAllow()
|
167 |
+
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
168 |
+
) {
|
169 |
+
return false;
|
170 |
+
}
|
171 |
+
|
172 |
+
return false;
|
173 |
+
}
|
174 |
+
|
175 |
+
public function showSubtotal()
|
176 |
+
{
|
177 |
+
if ($this->getTypeLocationAllow()
|
178 |
+
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
179 |
+
) {
|
180 |
+
return false;
|
181 |
+
} elseif ($this->getTypeLocationAllow()
|
182 |
+
== self::TYPE_LOCATION_ALLOW_CART_SHOW && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
183 |
+
) {
|
184 |
+
return true;
|
185 |
+
} elseif ($this->getTypeLocationAllow()
|
186 |
+
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() != self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
187 |
+
) {
|
188 |
+
return true;
|
189 |
+
} elseif ($this->getTypeLocationAllow()
|
190 |
+
== self::TYPE_LOCATION_ALLOW_CART_HIDE && $this->getLocationAllow() == self::TYPE_LOCATION_ALLOW_CART_DISABLE
|
191 |
+
) {
|
192 |
+
return true;
|
193 |
+
}
|
194 |
+
|
195 |
+
return true;
|
196 |
+
}
|
197 |
+
|
198 |
+
/*
|
199 |
+
* Get Store Type Location
|
200 |
+
*/
|
201 |
+
private function getTypeLocationAllow()
|
202 |
+
{
|
203 |
+
if ($this->_integrationType == null) {
|
204 |
+
$integrationType = Mage::helper('skyboxinternational/data')->getSkyboxIntegration();
|
205 |
+
$this->_integrationType = $integrationType;
|
206 |
+
}
|
207 |
+
return $this->_integrationType;
|
208 |
+
}
|
209 |
+
|
210 |
+
/*
|
211 |
+
* Get LocationAllow
|
212 |
+
*/
|
213 |
+
public function getLocationAllow()
|
214 |
+
{
|
215 |
+
if ($this->_locationAllow == null) {
|
216 |
+
$_checkout = Mage::getModel('skyboxcheckout/api_checkout');
|
217 |
+
$value = $_checkout->getLocationAllow();
|
218 |
+
$value = isset($value) ? $value : 0;
|
219 |
+
$this->_locationAllow = $value;
|
220 |
+
}
|
221 |
+
return $this->_locationAllow;
|
222 |
+
}
|
223 |
+
|
224 |
+
/*
|
225 |
+
* Get FullActionName router name
|
226 |
+
*/
|
227 |
+
private function getFullActionName()
|
228 |
+
{
|
229 |
+
$moduleName = Mage::app()->getRequest()->getModuleName();
|
230 |
+
$controllerName = Mage::app()->getRequest()->getControllerName();
|
231 |
+
$actionName = Mage::app()->getRequest()->getActionName();
|
232 |
+
|
233 |
+
$result = $moduleName . "_" . $controllerName . "_" . $actionName;
|
234 |
+
return $result;
|
235 |
+
}
|
236 |
+
}
|
app/code/community/Skybox/Core/Helper/Data.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Core
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Core
|
8 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Core_Helper_Data extends Mage_Core_Helper_Abstract
|
11 |
-
{
|
12 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Core
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Core
|
8 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Core_Helper_Data extends Mage_Core_Helper_Abstract
|
11 |
+
{
|
12 |
}
|
app/code/community/Skybox/Core/Helper/Email.php
CHANGED
@@ -1,53 +1,53 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Core
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Core
|
8 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
|
11 |
-
class Skybox_Core_Helper_Email extends Mage_Core_Helper_Abstract
|
12 |
-
{
|
13 |
-
public function sendException($message)
|
14 |
-
{
|
15 |
-
$storeName = "[" . Mage::app()->getStore()->getName() . "]";
|
16 |
-
$subject = $storeName . " - Exception generated at " . strftime("%H:%M:%S", time());
|
17 |
-
return $this->email($subject, $message);
|
18 |
-
}
|
19 |
-
|
20 |
-
public function sendAPIError($message)
|
21 |
-
{
|
22 |
-
$storeName = "[" . Mage::app()->getStore()->getName() . "]";
|
23 |
-
$subject = $storeName . " - Error trying to connect to API at " . strftime("%H:%M:%S", time());
|
24 |
-
return $this->email($subject, $message);
|
25 |
-
}
|
26 |
-
|
27 |
-
public function email($subject, $body)
|
28 |
-
{
|
29 |
-
$skybox_email = Mage::helper('skyboxinternational/data')->getSkyboxEmail();
|
30 |
-
|
31 |
-
if (!$skybox_email) {
|
32 |
-
return false;
|
33 |
-
}
|
34 |
-
|
35 |
-
/* @var $mail Mage_Core_Model_Email */
|
36 |
-
$mail = Mage::getModel('core/email');
|
37 |
-
$mail->setToName('Magento Store');
|
38 |
-
$mail->setToEmail($skybox_email);
|
39 |
-
$mail->setBody($body);
|
40 |
-
$mail->setSubject($subject);
|
41 |
-
$mail->setFromEmail($skybox_email);
|
42 |
-
$mail->setFromName('Magento Store');
|
43 |
-
$mail->setType('text');
|
44 |
-
|
45 |
-
try {
|
46 |
-
$myEmail = $mail->send();
|
47 |
-
Mage::log($myEmail);
|
48 |
-
Mage::log('SkyboxCheckout: Your request email has been sent');
|
49 |
-
} catch (Exception $e) {
|
50 |
-
Mage::log('SkyboxCheckout: Unable to send');
|
51 |
-
}
|
52 |
-
}
|
53 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Core
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Core
|
8 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Skybox_Core_Helper_Email extends Mage_Core_Helper_Abstract
|
12 |
+
{
|
13 |
+
public function sendException($message)
|
14 |
+
{
|
15 |
+
$storeName = "[" . Mage::app()->getStore()->getName() . "]";
|
16 |
+
$subject = $storeName . " - Exception generated at " . strftime("%H:%M:%S", time());
|
17 |
+
return $this->email($subject, $message);
|
18 |
+
}
|
19 |
+
|
20 |
+
public function sendAPIError($message)
|
21 |
+
{
|
22 |
+
$storeName = "[" . Mage::app()->getStore()->getName() . "]";
|
23 |
+
$subject = $storeName . " - Error trying to connect to API at " . strftime("%H:%M:%S", time());
|
24 |
+
return $this->email($subject, $message);
|
25 |
+
}
|
26 |
+
|
27 |
+
public function email($subject, $body)
|
28 |
+
{
|
29 |
+
$skybox_email = Mage::helper('skyboxinternational/data')->getSkyboxEmail();
|
30 |
+
|
31 |
+
if (!$skybox_email) {
|
32 |
+
return false;
|
33 |
+
}
|
34 |
+
|
35 |
+
/* @var $mail Mage_Core_Model_Email */
|
36 |
+
$mail = Mage::getModel('core/email');
|
37 |
+
$mail->setToName('Magento Store');
|
38 |
+
$mail->setToEmail($skybox_email);
|
39 |
+
$mail->setBody($body);
|
40 |
+
$mail->setSubject($subject);
|
41 |
+
$mail->setFromEmail($skybox_email);
|
42 |
+
$mail->setFromName('Magento Store');
|
43 |
+
$mail->setType('text');
|
44 |
+
|
45 |
+
try {
|
46 |
+
$myEmail = $mail->send();
|
47 |
+
Mage::log($myEmail);
|
48 |
+
Mage::log('SkyboxCheckout: Your request email has been sent');
|
49 |
+
} catch (Exception $e) {
|
50 |
+
Mage::log('SkyboxCheckout: Unable to send');
|
51 |
+
}
|
52 |
+
}
|
53 |
}
|
app/code/community/Skybox/Core/Model/Api/Abstract.php
CHANGED
@@ -1,440 +1,440 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Skybox Checkout
|
4 |
-
*
|
5 |
-
* @category Mage
|
6 |
-
* @package Skybox_Core
|
7 |
-
* @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* SkyBox API - Abstract Class
|
12 |
-
*/
|
13 |
-
class Skybox_Core_Model_Api_Abstract extends Varien_Object
|
14 |
-
{
|
15 |
-
/**
|
16 |
-
* Config instance
|
17 |
-
* @var Skybox_Core_Model_Config
|
18 |
-
*/
|
19 |
-
protected $_config = null;
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Respuesta de api
|
23 |
-
* @var string
|
24 |
-
*/
|
25 |
-
protected $_response = null;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Solicitud de api
|
29 |
-
* @var string
|
30 |
-
*/
|
31 |
-
protected $_request = null;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Código de metodo actual
|
35 |
-
* @var string
|
36 |
-
*/
|
37 |
-
protected $_methodCode = null;
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Código de metodo actual
|
41 |
-
* @var array()
|
42 |
-
*/
|
43 |
-
protected $_params = null;
|
44 |
-
|
45 |
-
/*
|
46 |
-
* @var string
|
47 |
-
*/
|
48 |
-
protected $_status_code = null;
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Seteamos la instancia Config
|
52 |
-
* @param Skybox_Core_Model_Config $config
|
53 |
-
* @return Skybox_Core_Model_Api_Abstract
|
54 |
-
*/
|
55 |
-
public function setConfigObject(Skybox_Core_Model_Config $config)
|
56 |
-
{
|
57 |
-
$this->_config = $config;
|
58 |
-
return $this;
|
59 |
-
}
|
60 |
-
|
61 |
-
public function setStatusCode($value)
|
62 |
-
{
|
63 |
-
$this->_status_code = $value;
|
64 |
-
}
|
65 |
-
|
66 |
-
public function getStatusCode()
|
67 |
-
{
|
68 |
-
//Mage::log("Error:" . $this->gerResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_STATUS});
|
69 |
-
//return $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_STATUS};
|
70 |
-
return $this->_status_code;
|
71 |
-
}
|
72 |
-
|
73 |
-
public function getStatusMessage()
|
74 |
-
{
|
75 |
-
return $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_MESSAGE};
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Seteamos la respuesta del api
|
80 |
-
* @param string $response
|
81 |
-
* @return Skybox_Core_Model_Api_Abstract
|
82 |
-
*/
|
83 |
-
public function setResponse($response)
|
84 |
-
{
|
85 |
-
//Mage::log('setResponse->' . $response);
|
86 |
-
if (!empty($response)) {
|
87 |
-
$this->_response = $response;
|
88 |
-
}
|
89 |
-
return $this;
|
90 |
-
}
|
91 |
-
|
92 |
-
public function getResponse()
|
93 |
-
{
|
94 |
-
return $this->_response;
|
95 |
-
}
|
96 |
-
|
97 |
-
public function getResponseJson()
|
98 |
-
{
|
99 |
-
//Mage::log('gerResponseJson->' . $this->_response);
|
100 |
-
return json_decode($this->_response);
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Setea url de llamda al ApiRest con sus parametros
|
105 |
-
* @param String $action
|
106 |
-
* @param Array $params
|
107 |
-
* @return Skybox_Core_Model_Api_Abstract
|
108 |
-
*/
|
109 |
-
protected function setUrlService($method, $params)
|
110 |
-
{
|
111 |
-
$this->_methodCode = $method;
|
112 |
-
$paramsRequest = '';
|
113 |
-
if (!empty($params)) {
|
114 |
-
$paramsRequest = '?' . http_build_query($params);
|
115 |
-
}
|
116 |
-
//$this->_request = $this->_config->skyboxDefaultApiUrl . $method . $paramsRequest;
|
117 |
-
$this->_request = $this->_config->getSkyBoxUrlAPI() . $method . $paramsRequest;
|
118 |
-
return $this;
|
119 |
-
}
|
120 |
-
|
121 |
-
/**
|
122 |
-
* Retorna la url de llamada al servicio
|
123 |
-
* @return String
|
124 |
-
*/
|
125 |
-
public function getUrlService()
|
126 |
-
{
|
127 |
-
Mage::log(" | getUrlService | " . $this->_request);
|
128 |
-
return $this->_request;
|
129 |
-
}
|
130 |
-
|
131 |
-
/**
|
132 |
-
* Obtenemos el objeto Session
|
133 |
-
* @return Skybox_Core_Model_Session
|
134 |
-
*/
|
135 |
-
public function getSession()
|
136 |
-
{
|
137 |
-
return Mage::getSingleton('skybox/session');
|
138 |
-
}
|
139 |
-
|
140 |
-
/**
|
141 |
-
* Obtenemos el objeto Cookie
|
142 |
-
* @return Mage_Core_Model_Cookie
|
143 |
-
*/
|
144 |
-
public function getCookie()
|
145 |
-
{
|
146 |
-
return Mage::getModel('core/cookie');
|
147 |
-
}
|
148 |
-
|
149 |
-
/**
|
150 |
-
* Obtenemos el objeto Http
|
151 |
-
* @return Mage_Core_Helper_Http
|
152 |
-
*/
|
153 |
-
public function getHttp()
|
154 |
-
{
|
155 |
-
return Mage::helper('core/http');
|
156 |
-
}
|
157 |
-
|
158 |
-
/**
|
159 |
-
* Current locale code getter
|
160 |
-
*
|
161 |
-
* @return string
|
162 |
-
*/
|
163 |
-
public function getLocaleCode()
|
164 |
-
{
|
165 |
-
return Mage::app()->getLocale()->getLocaleCode();
|
166 |
-
}
|
167 |
-
|
168 |
-
/**
|
169 |
-
* Obtenemos inforamción del navegador del cliente
|
170 |
-
* @return HTTP_USER_AGENT
|
171 |
-
*/
|
172 |
-
public function getUserAgent()
|
173 |
-
{
|
174 |
-
return $this->getHttp()->getHttpUserAgent();
|
175 |
-
}
|
176 |
-
|
177 |
-
/**
|
178 |
-
* Obtenemos la Ip Local Remota del Cliente
|
179 |
-
* @return REMOTE_ADDR
|
180 |
-
*/
|
181 |
-
public function getRemoteAddr()
|
182 |
-
{
|
183 |
-
return $_SERVER['REMOTE_ADDR'];
|
184 |
-
//return $this->getHttp()->getRemoteAddr();
|
185 |
-
}
|
186 |
-
|
187 |
-
/**
|
188 |
-
* Obtenemos la Ip Proxy del Client
|
189 |
-
* @return HTTP_VIA or HTTP_X_FORWARDED_FOR
|
190 |
-
*/
|
191 |
-
public function getProxy()
|
192 |
-
{
|
193 |
-
return $_SERVER['HTTP_X_FORWARDED_FOR'];
|
194 |
-
}
|
195 |
-
|
196 |
-
/**
|
197 |
-
* Obtenemos la Ip Local del Cliente
|
198 |
-
* @return String
|
199 |
-
*/
|
200 |
-
public function getHost()
|
201 |
-
{
|
202 |
-
return $this->getHttp()->getHttpHost();
|
203 |
-
}
|
204 |
-
|
205 |
-
/**
|
206 |
-
* Obtenemos el lenguaje del Navegador del Cliente
|
207 |
-
*/
|
208 |
-
public function getLanguage()
|
209 |
-
{
|
210 |
-
return $this->getHttp()->getHttpAcceptLanguage();
|
211 |
-
}
|
212 |
-
|
213 |
-
/**
|
214 |
-
* Sección de Validaciones
|
215 |
-
*/
|
216 |
-
|
217 |
-
/**
|
218 |
-
* Valida que no exista ningun error
|
219 |
-
* @return bool
|
220 |
-
*/
|
221 |
-
public function HasError()
|
222 |
-
{
|
223 |
-
/*if($this->ErrorService()) return true;
|
224 |
-
if($this->ErrorKeyInvalid()) return true;
|
225 |
-
if($this->ErrorIpNoAllow()) return true;
|
226 |
-
if($this->ErrorMerchantInvalid()) return true;
|
227 |
-
if($this->ErrorGuidInvalid()) return true;
|
228 |
-
if($this->ErrorTokenInvalid()) return true;
|
229 |
-
if($this->ErrorToAddProductToCart()) return true;*/
|
230 |
-
|
231 |
-
if ($this->ErrorRatesNotFound()) {
|
232 |
-
return true;
|
233 |
-
}
|
234 |
-
|
235 |
-
if ($this->ErrorServiceNotController()) {
|
236 |
-
return true;
|
237 |
-
}
|
238 |
-
|
239 |
-
if ($this->ErrorIpNoAllow()) {
|
240 |
-
return true;
|
241 |
-
}
|
242 |
-
if ($this->ErrorIdMerchantInvalid()) {
|
243 |
-
return true;
|
244 |
-
}
|
245 |
-
if ($this->ErrorGuidInvalid()) {
|
246 |
-
return true;
|
247 |
-
}
|
248 |
-
if ($this->ErrorTokenExpired()) {
|
249 |
-
return true;
|
250 |
-
}
|
251 |
-
if ($this->ErrorToAddProductToCart()) {
|
252 |
-
return true;
|
253 |
-
}
|
254 |
-
if ($this->ErrorMerchantNotConfigured()) {
|
255 |
-
return true;
|
256 |
-
}
|
257 |
-
if ($this->ErrorProductCategoryRequired()) {
|
258 |
-
return true;
|
259 |
-
}
|
260 |
-
if ($this->ErrorProductUnitWeigthRequired()) {
|
261 |
-
return true;
|
262 |
-
}
|
263 |
-
if ($this->ErrorProductWeigthInvalid()) {
|
264 |
-
return true;
|
265 |
-
}
|
266 |
-
if ($this->ErrorProductWeigthIsnull()) {
|
267 |
-
return true;
|
268 |
-
}
|
269 |
-
if ($this->ErrorProductUnitWeightInvalid()) {
|
270 |
-
return true;
|
271 |
-
}
|
272 |
-
if ($this->ErrorStoreCityNotConfigured()) {
|
273 |
-
return true;
|
274 |
-
}
|
275 |
-
|
276 |
-
if ($this->ErrorTokenIsnull()) {
|
277 |
-
return true;
|
278 |
-
}
|
279 |
-
if ($this->ErrorGuidIsnull()) {
|
280 |
-
return true;
|
281 |
-
}
|
282 |
-
if ($this->ErrorRegionNotConfigured()) {
|
283 |
-
return true;
|
284 |
-
}
|
285 |
-
if ($this->ErrorProductNameRequiered()) {
|
286 |
-
return true;
|
287 |
-
}
|
288 |
-
if ($this->ErrorProductCodeRequiered()) {
|
289 |
-
return true;
|
290 |
-
}
|
291 |
-
|
292 |
-
if ($this->ErrorMerchantKeyIsnull()) {
|
293 |
-
return true;
|
294 |
-
}
|
295 |
-
if ($this->ErrorMerchantKeyInvalid()) {
|
296 |
-
return true;
|
297 |
-
}
|
298 |
-
|
299 |
-
return false;
|
300 |
-
|
301 |
-
}
|
302 |
-
|
303 |
-
/**
|
304 |
-
* Valida si se devolvio un error por Merchant invalido
|
305 |
-
* @return bool
|
306 |
-
*/
|
307 |
-
public function ErrorIdMerchantInvalid()
|
308 |
-
{
|
309 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_IDMERCHANT_INVALID;
|
310 |
-
}
|
311 |
-
|
312 |
-
public function ErrorMerchantNotConfigured()
|
313 |
-
{
|
314 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_COUNTRY_NOT_CONFIGURED_TO_STORE;
|
315 |
-
}
|
316 |
-
|
317 |
-
/**
|
318 |
-
* Valida si se devolvio un error por Guid invalido
|
319 |
-
* @return bool
|
320 |
-
*/
|
321 |
-
public function ErrorGuidInvalid()
|
322 |
-
{
|
323 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_DEVICE_GUID_INVALID;
|
324 |
-
}
|
325 |
-
|
326 |
-
/**
|
327 |
-
* Valida si se devolvio un error por Token invalido
|
328 |
-
* @return bool
|
329 |
-
*/
|
330 |
-
public function ErrorTokenExpired()
|
331 |
-
{
|
332 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_TOKEN_EXPIRED;
|
333 |
-
}
|
334 |
-
|
335 |
-
/**
|
336 |
-
* Valida si se devolvio un error de agregación de producto al carrito de compras
|
337 |
-
* @return bool
|
338 |
-
*/
|
339 |
-
public function ErrorToAddProductToCart()
|
340 |
-
{
|
341 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_NOT_IN_SHOPPING_CART;
|
342 |
-
}
|
343 |
-
|
344 |
-
/**
|
345 |
-
* Valida si se devolvio un error no controlado la respuesta del servicio
|
346 |
-
* @return bool
|
347 |
-
*/
|
348 |
-
public function ErrorServiceNotController()
|
349 |
-
{
|
350 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_SERVICE_NOT_CONTROLLER;
|
351 |
-
}
|
352 |
-
|
353 |
-
|
354 |
-
public function ErrorIpNoAllow()
|
355 |
-
{
|
356 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_IP_NOT_ALLOWED;
|
357 |
-
}
|
358 |
-
|
359 |
-
public function ErrorProductCategoryRequired()
|
360 |
-
{
|
361 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_CATEGORY_INVALID;
|
362 |
-
}
|
363 |
-
|
364 |
-
public function ErrorProductUnitWeigthRequired()
|
365 |
-
{
|
366 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_UNITWEIGHT_IS_NULL;
|
367 |
-
}
|
368 |
-
|
369 |
-
public function ErrorProductWeigthInvalid()
|
370 |
-
{
|
371 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_WEIGHT_INVALID;
|
372 |
-
}
|
373 |
-
|
374 |
-
public function ErrorProductWeigthIsnull()
|
375 |
-
{
|
376 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_WEIGHT_IS_NULL;
|
377 |
-
}
|
378 |
-
|
379 |
-
public function ErrorProductUnitWeightInvalid()
|
380 |
-
{
|
381 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_UNITWEIGHT_INVALID;
|
382 |
-
}
|
383 |
-
|
384 |
-
public function ErrorStoreCityNotConfigured()
|
385 |
-
{
|
386 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_STORE_CITY_NOT_CONFIGURED;
|
387 |
-
}
|
388 |
-
|
389 |
-
public function ErrorTokenIsnull()
|
390 |
-
{
|
391 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_TOKEN_IS_NULL;
|
392 |
-
}
|
393 |
-
|
394 |
-
public function ErrorGuidIsnull()
|
395 |
-
{
|
396 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_GUID_IS_NULL;
|
397 |
-
}
|
398 |
-
|
399 |
-
public function ErrorRegionNotConfigured()
|
400 |
-
{
|
401 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_REGION_NOT_CONFIGURED_TO_STORE;
|
402 |
-
}
|
403 |
-
|
404 |
-
public function ErrorProductNameRequiered()
|
405 |
-
{
|
406 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_NAME_IS_NULL;
|
407 |
-
}
|
408 |
-
|
409 |
-
public function ErrorProductCodeRequiered()
|
410 |
-
{
|
411 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_CODE_IS_NULL;
|
412 |
-
}
|
413 |
-
|
414 |
-
public function ErrorMerchantKeyInvalid()
|
415 |
-
{
|
416 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_MERCHANT_KEY_INVALID;
|
417 |
-
}
|
418 |
-
|
419 |
-
public function ErrorMerchantKeyIsnull()
|
420 |
-
{
|
421 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_MERCHANT_KEY_IS_NULL;
|
422 |
-
}
|
423 |
-
|
424 |
-
public function ErrorRatesNotFound()
|
425 |
-
{
|
426 |
-
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_RATES_NOT_FOUND;
|
427 |
-
}
|
428 |
-
|
429 |
-
// @todo: Improved message exceptions
|
430 |
-
public function getErrorRatesNotFoundMessage($id = 0)
|
431 |
-
{
|
432 |
-
$languages = array(
|
433 |
-
0 => "U.S. Orders Only",
|
434 |
-
1 => "U.S. Orders Only",
|
435 |
-
2 => "Restringido fuera de USA",
|
436 |
-
3 => "Restringido fuera de USA",
|
437 |
-
);
|
438 |
-
return $languages[$id];
|
439 |
-
}
|
440 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Skybox Checkout
|
4 |
+
*
|
5 |
+
* @category Mage
|
6 |
+
* @package Skybox_Core
|
7 |
+
* @copyright Copyright (c) 2014 - 2017 Skybox Checkout. (http://www.skyboxcheckout.com)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* SkyBox API - Abstract Class
|
12 |
+
*/
|
13 |
+
class Skybox_Core_Model_Api_Abstract extends Varien_Object
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Config instance
|
17 |
+
* @var Skybox_Core_Model_Config
|
18 |
+
*/
|
19 |
+
protected $_config = null;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Respuesta de api
|
23 |
+
* @var string
|
24 |
+
*/
|
25 |
+
protected $_response = null;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Solicitud de api
|
29 |
+
* @var string
|
30 |
+
*/
|
31 |
+
protected $_request = null;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Código de metodo actual
|
35 |
+
* @var string
|
36 |
+
*/
|
37 |
+
protected $_methodCode = null;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Código de metodo actual
|
41 |
+
* @var array()
|
42 |
+
*/
|
43 |
+
protected $_params = null;
|
44 |
+
|
45 |
+
/*
|
46 |
+
* @var string
|
47 |
+
*/
|
48 |
+
protected $_status_code = null;
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Seteamos la instancia Config
|
52 |
+
* @param Skybox_Core_Model_Config $config
|
53 |
+
* @return Skybox_Core_Model_Api_Abstract
|
54 |
+
*/
|
55 |
+
public function setConfigObject(Skybox_Core_Model_Config $config)
|
56 |
+
{
|
57 |
+
$this->_config = $config;
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
|
61 |
+
public function setStatusCode($value)
|
62 |
+
{
|
63 |
+
$this->_status_code = $value;
|
64 |
+
}
|
65 |
+
|
66 |
+
public function getStatusCode()
|
67 |
+
{
|
68 |
+
//Mage::log("Error:" . $this->gerResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_STATUS});
|
69 |
+
//return $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_STATUS};
|
70 |
+
return $this->_status_code;
|
71 |
+
}
|
72 |
+
|
73 |
+
public function getStatusMessage()
|
74 |
+
{
|
75 |
+
return $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_MESSAGE};
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Seteamos la respuesta del api
|
80 |
+
* @param string $response
|
81 |
+
* @return Skybox_Core_Model_Api_Abstract
|
82 |
+
*/
|
83 |
+
public function setResponse($response)
|
84 |
+
{
|
85 |
+
//Mage::log('setResponse->' . $response);
|
86 |
+
if (!empty($response)) {
|
87 |
+
$this->_response = $response;
|
88 |
+
}
|
89 |
+
return $this;
|
90 |
+
}
|
91 |
+
|
92 |
+
public function getResponse()
|
93 |
+
{
|
94 |
+
return $this->_response;
|
95 |
+
}
|
96 |
+
|
97 |
+
public function getResponseJson()
|
98 |
+
{
|
99 |
+
//Mage::log('gerResponseJson->' . $this->_response);
|
100 |
+
return json_decode($this->_response);
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Setea url de llamda al ApiRest con sus parametros
|
105 |
+
* @param String $action
|
106 |
+
* @param Array $params
|
107 |
+
* @return Skybox_Core_Model_Api_Abstract
|
108 |
+
*/
|
109 |
+
protected function setUrlService($method, $params)
|
110 |
+
{
|
111 |
+
$this->_methodCode = $method;
|
112 |
+
$paramsRequest = '';
|
113 |
+
if (!empty($params)) {
|
114 |
+
$paramsRequest = '?' . http_build_query($params);
|
115 |
+
}
|
116 |
+
//$this->_request = $this->_config->skyboxDefaultApiUrl . $method . $paramsRequest;
|
117 |
+
$this->_request = $this->_config->getSkyBoxUrlAPI() . $method . $paramsRequest;
|
118 |
+
return $this;
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Retorna la url de llamada al servicio
|
123 |
+
* @return String
|
124 |
+
*/
|
125 |
+
public function getUrlService()
|
126 |
+
{
|
127 |
+
Mage::log(" | getUrlService | " . $this->_request);
|
128 |
+
return $this->_request;
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Obtenemos el objeto Session
|
133 |
+
* @return Skybox_Core_Model_Session
|
134 |
+
*/
|
135 |
+
public function getSession()
|
136 |
+
{
|
137 |
+
return Mage::getSingleton('skybox/session');
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Obtenemos el objeto Cookie
|
142 |
+
* @return Mage_Core_Model_Cookie
|
143 |
+
*/
|
144 |
+
public function getCookie()
|
145 |
+
{
|
146 |
+
return Mage::getModel('core/cookie');
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Obtenemos el objeto Http
|
151 |
+
* @return Mage_Core_Helper_Http
|
152 |
+
*/
|
153 |
+
public function getHttp()
|
154 |
+
{
|
155 |
+
return Mage::helper('core/http');
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Current locale code getter
|
160 |
+
*
|
161 |
+
* @return string
|
162 |
+
*/
|
163 |
+
public function getLocaleCode()
|
164 |
+
{
|
165 |
+
return Mage::app()->getLocale()->getLocaleCode();
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Obtenemos inforamción del navegador del cliente
|
170 |
+
* @return HTTP_USER_AGENT
|
171 |
+
*/
|
172 |
+
public function getUserAgent()
|
173 |
+
{
|
174 |
+
return $this->getHttp()->getHttpUserAgent();
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Obtenemos la Ip Local Remota del Cliente
|
179 |
+
* @return REMOTE_ADDR
|
180 |
+
*/
|
181 |
+
public function getRemoteAddr()
|
182 |
+
{
|
183 |
+
return $_SERVER['REMOTE_ADDR'];
|
184 |
+
//return $this->getHttp()->getRemoteAddr();
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Obtenemos la Ip Proxy del Client
|
189 |
+
* @return HTTP_VIA or HTTP_X_FORWARDED_FOR
|
190 |
+
*/
|
191 |
+
public function getProxy()
|
192 |
+
{
|
193 |
+
return $_SERVER['HTTP_X_FORWARDED_FOR'];
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Obtenemos la Ip Local del Cliente
|
198 |
+
* @return String
|
199 |
+
*/
|
200 |
+
public function getHost()
|
201 |
+
{
|
202 |
+
return $this->getHttp()->getHttpHost();
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Obtenemos el lenguaje del Navegador del Cliente
|
207 |
+
*/
|
208 |
+
public function getLanguage()
|
209 |
+
{
|
210 |
+
return $this->getHttp()->getHttpAcceptLanguage();
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Sección de Validaciones
|
215 |
+
*/
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Valida que no exista ningun error
|
219 |
+
* @return bool
|
220 |
+
*/
|
221 |
+
public function HasError()
|
222 |
+
{
|
223 |
+
/*if($this->ErrorService()) return true;
|
224 |
+
if($this->ErrorKeyInvalid()) return true;
|
225 |
+
if($this->ErrorIpNoAllow()) return true;
|
226 |
+
if($this->ErrorMerchantInvalid()) return true;
|
227 |
+
if($this->ErrorGuidInvalid()) return true;
|
228 |
+
if($this->ErrorTokenInvalid()) return true;
|
229 |
+
if($this->ErrorToAddProductToCart()) return true;*/
|
230 |
+
|
231 |
+
if ($this->ErrorRatesNotFound()) {
|
232 |
+
return true;
|
233 |
+
}
|
234 |
+
|
235 |
+
if ($this->ErrorServiceNotController()) {
|
236 |
+
return true;
|
237 |
+
}
|
238 |
+
|
239 |
+
if ($this->ErrorIpNoAllow()) {
|
240 |
+
return true;
|
241 |
+
}
|
242 |
+
if ($this->ErrorIdMerchantInvalid()) {
|
243 |
+
return true;
|
244 |
+
}
|
245 |
+
if ($this->ErrorGuidInvalid()) {
|
246 |
+
return true;
|
247 |
+
}
|
248 |
+
if ($this->ErrorTokenExpired()) {
|
249 |
+
return true;
|
250 |
+
}
|
251 |
+
if ($this->ErrorToAddProductToCart()) {
|
252 |
+
return true;
|
253 |
+
}
|
254 |
+
if ($this->ErrorMerchantNotConfigured()) {
|
255 |
+
return true;
|
256 |
+
}
|
257 |
+
if ($this->ErrorProductCategoryRequired()) {
|
258 |
+
return true;
|
259 |
+
}
|
260 |
+
if ($this->ErrorProductUnitWeigthRequired()) {
|
261 |
+
return true;
|
262 |
+
}
|
263 |
+
if ($this->ErrorProductWeigthInvalid()) {
|
264 |
+
return true;
|
265 |
+
}
|
266 |
+
if ($this->ErrorProductWeigthIsnull()) {
|
267 |
+
return true;
|
268 |
+
}
|
269 |
+
if ($this->ErrorProductUnitWeightInvalid()) {
|
270 |
+
return true;
|
271 |
+
}
|
272 |
+
if ($this->ErrorStoreCityNotConfigured()) {
|
273 |
+
return true;
|
274 |
+
}
|
275 |
+
|
276 |
+
if ($this->ErrorTokenIsnull()) {
|
277 |
+
return true;
|
278 |
+
}
|
279 |
+
if ($this->ErrorGuidIsnull()) {
|
280 |
+
return true;
|
281 |
+
}
|
282 |
+
if ($this->ErrorRegionNotConfigured()) {
|
283 |
+
return true;
|
284 |
+
}
|
285 |
+
if ($this->ErrorProductNameRequiered()) {
|
286 |
+
return true;
|
287 |
+
}
|
288 |
+
if ($this->ErrorProductCodeRequiered()) {
|
289 |
+
return true;
|
290 |
+
}
|
291 |
+
|
292 |
+
if ($this->ErrorMerchantKeyIsnull()) {
|
293 |
+
return true;
|
294 |
+
}
|
295 |
+
if ($this->ErrorMerchantKeyInvalid()) {
|
296 |
+
return true;
|
297 |
+
}
|
298 |
+
|
299 |
+
return false;
|
300 |
+
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Valida si se devolvio un error por Merchant invalido
|
305 |
+
* @return bool
|
306 |
+
*/
|
307 |
+
public function ErrorIdMerchantInvalid()
|
308 |
+
{
|
309 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_IDMERCHANT_INVALID;
|
310 |
+
}
|
311 |
+
|
312 |
+
public function ErrorMerchantNotConfigured()
|
313 |
+
{
|
314 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_COUNTRY_NOT_CONFIGURED_TO_STORE;
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
* Valida si se devolvio un error por Guid invalido
|
319 |
+
* @return bool
|
320 |
+
*/
|
321 |
+
public function ErrorGuidInvalid()
|
322 |
+
{
|
323 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_DEVICE_GUID_INVALID;
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Valida si se devolvio un error por Token invalido
|
328 |
+
* @return bool
|
329 |
+
*/
|
330 |
+
public function ErrorTokenExpired()
|
331 |
+
{
|
332 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_TOKEN_EXPIRED;
|
333 |
+
}
|
334 |
+
|
335 |
+
/**
|
336 |
+
* Valida si se devolvio un error de agregación de producto al carrito de compras
|
337 |
+
* @return bool
|
338 |
+
*/
|
339 |
+
public function ErrorToAddProductToCart()
|
340 |
+
{
|
341 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_NOT_IN_SHOPPING_CART;
|
342 |
+
}
|
343 |
+
|
344 |
+
/**
|
345 |
+
* Valida si se devolvio un error no controlado la respuesta del servicio
|
346 |
+
* @return bool
|
347 |
+
*/
|
348 |
+
public function ErrorServiceNotController()
|
349 |
+
{
|
350 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_SERVICE_NOT_CONTROLLER;
|
351 |
+
}
|
352 |
+
|
353 |
+
|
354 |
+
public function ErrorIpNoAllow()
|
355 |
+
{
|
356 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_IP_NOT_ALLOWED;
|
357 |
+
}
|
358 |
+
|
359 |
+
public function ErrorProductCategoryRequired()
|
360 |
+
{
|
361 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_CATEGORY_INVALID;
|
362 |
+
}
|
363 |
+
|
364 |
+
public function ErrorProductUnitWeigthRequired()
|
365 |
+
{
|
366 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_UNITWEIGHT_IS_NULL;
|
367 |
+
}
|
368 |
+
|
369 |
+
public function ErrorProductWeigthInvalid()
|
370 |
+
{
|
371 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_WEIGHT_INVALID;
|
372 |
+
}
|
373 |
+
|
374 |
+
public function ErrorProductWeigthIsnull()
|
375 |
+
{
|
376 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_WEIGHT_IS_NULL;
|
377 |
+
}
|
378 |
+
|
379 |
+
public function ErrorProductUnitWeightInvalid()
|
380 |
+
{
|
381 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_UNITWEIGHT_INVALID;
|
382 |
+
}
|
383 |
+
|
384 |
+
public function ErrorStoreCityNotConfigured()
|
385 |
+
{
|
386 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_STORE_CITY_NOT_CONFIGURED;
|
387 |
+
}
|
388 |
+
|
389 |
+
public function ErrorTokenIsnull()
|
390 |
+
{
|
391 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_TOKEN_IS_NULL;
|
392 |
+
}
|
393 |
+
|
394 |
+
public function ErrorGuidIsnull()
|
395 |
+
{
|
396 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_GUID_IS_NULL;
|
397 |
+
}
|
398 |
+
|
399 |
+
public function ErrorRegionNotConfigured()
|
400 |
+
{
|
401 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_REGION_NOT_CONFIGURED_TO_STORE;
|
402 |
+
}
|
403 |
+
|
404 |
+
public function ErrorProductNameRequiered()
|
405 |
+
{
|
406 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_NAME_IS_NULL;
|
407 |
+
}
|
408 |
+
|
409 |
+
public function ErrorProductCodeRequiered()
|
410 |
+
{
|
411 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_PRODUCT_CODE_IS_NULL;
|
412 |
+
}
|
413 |
+
|
414 |
+
public function ErrorMerchantKeyInvalid()
|
415 |
+
{
|
416 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_MERCHANT_KEY_INVALID;
|
417 |
+
}
|
418 |
+
|
419 |
+
public function ErrorMerchantKeyIsnull()
|
420 |
+
{
|
421 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_MERCHANT_KEY_IS_NULL;
|
422 |
+
}
|
423 |
+
|
424 |
+
public function ErrorRatesNotFound()
|
425 |
+
{
|
426 |
+
return $this->getStatusCode() == Skybox_Core_Model_Config::SKYBOX_ERROR_GCODE_RATES_NOT_FOUND;
|
427 |
+
}
|
428 |
+
|
429 |
+
// @todo: Improved message exceptions
|
430 |
+
public function getErrorRatesNotFoundMessage($id = 0)
|
431 |
+
{
|
432 |
+
$languages = array(
|
433 |
+
0 => "U.S. Orders Only",
|
434 |
+
1 => "U.S. Orders Only",
|
435 |
+
2 => "Restringido fuera de USA",
|
436 |
+
3 => "Restringido fuera de USA",
|
437 |
+
);
|
438 |
+
return $languages[$id];
|
439 |
+
}
|
440 |
+
}
|
app/code/community/Skybox/Core/Model/Api/Restful.php
CHANGED
@@ -1,365 +1,365 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Core
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Core
|
8 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Core_Model_Api_Restful extends Skybox_Core_Model_Api_Abstract
|
11 |
-
{
|
12 |
-
public $_skybox_guid = "";
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Guardamos en sesión el Html Template del Botón
|
16 |
-
* @param string $value
|
17 |
-
* @return Skybox_Core_Model_Api_Restful
|
18 |
-
*/
|
19 |
-
public function setHtmlTemplateButton($value = null)
|
20 |
-
{
|
21 |
-
$html = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_BUTTONHTML};
|
22 |
-
$htmlError = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_BUTTONERRORHTML};
|
23 |
-
$this->_config->getSession()->setHtmlTemplateButton($html);
|
24 |
-
$this->_config->getSession()->setHtmlTemplateButtonError($htmlError);
|
25 |
-
return $this;
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Se recupera el Html Template del Botón almacenado en la sesión
|
30 |
-
* @return String
|
31 |
-
*/
|
32 |
-
public function getHtmlTemplateButton()
|
33 |
-
{
|
34 |
-
return $this->_config->getSession()->getHtmlTemplateButton();
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Guardamos en sesión el Html Template de la barra
|
39 |
-
* @param string $value
|
40 |
-
* @return Skybox_Core_Model_Api_Restful
|
41 |
-
*/
|
42 |
-
public function setHtmlTemplateBar($value = null)
|
43 |
-
{
|
44 |
-
$html = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_BARHTML};
|
45 |
-
$this->_config->getSession()->setHtmlTemplateBar($html);
|
46 |
-
return $this;
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Se recupera el Html Template del Botón almacenado en la sesión
|
51 |
-
* @return String
|
52 |
-
*/
|
53 |
-
public function getHtmlTemplateBar()
|
54 |
-
{
|
55 |
-
return $this->_config->getSession()->getHtmlTemplateBar();
|
56 |
-
}
|
57 |
-
|
58 |
-
public function setGuidApi($value = null)
|
59 |
-
{
|
60 |
-
$guidId = null;
|
61 |
-
|
62 |
-
if (!$guidId) {
|
63 |
-
$guidId = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_GUID};
|
64 |
-
Mage::log("GuidID Not cart: " . $guidId);
|
65 |
-
}
|
66 |
-
|
67 |
-
$this->_config->getSession()->setCookieGuid($guidId);
|
68 |
-
$this->_skybox_guid = $guidId;
|
69 |
-
Mage::log("GuidID found: " . $guidId);
|
70 |
-
return $this;
|
71 |
-
}
|
72 |
-
|
73 |
-
// @todo Rewrite the way to get GUID
|
74 |
-
public function getGuidApi()
|
75 |
-
{
|
76 |
-
$guidId = null;
|
77 |
-
|
78 |
-
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
79 |
-
foreach ($quote->getAllItems() as $item) {
|
80 |
-
$guidId = $item->getGuidSkybox();
|
81 |
-
Mage::log(' | CallApiRest->Error1 | ', null, 'guid.log', true);
|
82 |
-
Mage::log("getGuidApi(): GuidID found (quote): " . $guidId, null, 'guid.log', true);
|
83 |
-
break;
|
84 |
-
}
|
85 |
-
|
86 |
-
if (!$guidId) {
|
87 |
-
$skyboxSession = $this->_config->getSession()->getCookieGuid();
|
88 |
-
if ($skyboxSession) {
|
89 |
-
// Mage::log(' | CallApiRest->Error2 | ', null, 'guid.log', true);
|
90 |
-
Mage::log("Call getGuidApi() from getSession(): " . $this->_config->getSession()->getCookieGuid(), null,
|
91 |
-
'guid.log', true);
|
92 |
-
$guidId = $this->_config->getSession()->getCookieGuid();
|
93 |
-
}
|
94 |
-
}
|
95 |
-
return $guidId;
|
96 |
-
}
|
97 |
-
|
98 |
-
public function compareGuid()
|
99 |
-
{
|
100 |
-
$already_guid = $this->getGuidApi();
|
101 |
-
$called_guid = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_GUID};
|
102 |
-
|
103 |
-
if ($already_guid == $called_guid) {
|
104 |
-
return true;
|
105 |
-
}
|
106 |
-
return false;
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Seteamos si la localización del usuario esta permitida
|
111 |
-
* @param string $value
|
112 |
-
* @return Skybox_Core_Model_Api_Restful
|
113 |
-
*/
|
114 |
-
public function setLocationAllow($value = null)
|
115 |
-
{
|
116 |
-
$allow = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_LOCATION_ALLOW};
|
117 |
-
//$allow = 0; // Rogged
|
118 |
-
$this->_config->getSession()->setLocationAllow($allow);
|
119 |
-
return $this;
|
120 |
-
}
|
121 |
-
|
122 |
-
|
123 |
-
public function getLocationAllow()
|
124 |
-
{
|
125 |
-
return $this->_config->getSession()->getLocationAllow();
|
126 |
-
}
|
127 |
-
|
128 |
-
public function setStoreCode($value = null)
|
129 |
-
{
|
130 |
-
$storeCode = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_STORE_CODE};
|
131 |
-
$storeCode = trim($storeCode);
|
132 |
-
$this->_config->getSession()->setStoreCode($storeCode);
|
133 |
-
return $storeCode;
|
134 |
-
}
|
135 |
-
|
136 |
-
public function getStoreCode()
|
137 |
-
{
|
138 |
-
return $this->_config->getSession()->getStoreCode();
|
139 |
-
}
|
140 |
-
|
141 |
-
public function setCssVersion($value = null)
|
142 |
-
{
|
143 |
-
$cssVersion = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_CSS_VERSION};
|
144 |
-
$cssVersion = (isset($cssVersion)) ? trim($cssVersion) : 1;
|
145 |
-
$this->_config->getSession()->setCssVersion($cssVersion);
|
146 |
-
return $cssVersion;
|
147 |
-
}
|
148 |
-
|
149 |
-
public function getCssVersion()
|
150 |
-
{
|
151 |
-
return $this->_config->getSession()->getCssVersion();
|
152 |
-
}
|
153 |
-
|
154 |
-
/**
|
155 |
-
* Seteamos error del servicio
|
156 |
-
* @param string $value
|
157 |
-
* @return Skybox_Core_Model_Api_Restful
|
158 |
-
*/
|
159 |
-
public function setErrorAuthenticate()
|
160 |
-
{
|
161 |
-
$this->_config->getSession()->setErrorAuthenticate($this->HasError());
|
162 |
-
return $this;
|
163 |
-
}
|
164 |
-
|
165 |
-
public function getErrorAuthenticate()
|
166 |
-
{
|
167 |
-
return $this->_config->getSession()->getErrorAuthenticate();
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* Guardamos en sesión el token de autorización
|
172 |
-
* @param string $value
|
173 |
-
* @return Skybox_Core_Model_Api_Restful
|
174 |
-
*/
|
175 |
-
public function setAuthorizedToken($value = null)
|
176 |
-
{
|
177 |
-
$token = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_TOKEN};
|
178 |
-
Mage::log('setAuthorizedToken token skybox: ' . $token);
|
179 |
-
// $token = urlencode($token);
|
180 |
-
$this->_config->getSession()->setTokenApiRest($token);
|
181 |
-
return $this;
|
182 |
-
}
|
183 |
-
|
184 |
-
/**
|
185 |
-
* Obtenemos el token de autorización almacenado en sesión
|
186 |
-
* @return string
|
187 |
-
*/
|
188 |
-
public function getAuthorizedToken()
|
189 |
-
{
|
190 |
-
//return $this->_config->getSession()->getTokenApiRest() ?: "";
|
191 |
-
$algo = $this->_config->getSession()->getTokenApiRest();
|
192 |
-
if (!empty($algo)) {
|
193 |
-
return $this->_config->getSession()->getTokenApiRest();
|
194 |
-
}
|
195 |
-
return "";
|
196 |
-
}
|
197 |
-
|
198 |
-
/**
|
199 |
-
* Sección de llamadas a los metodos del ApiRest
|
200 |
-
*/
|
201 |
-
|
202 |
-
/**
|
203 |
-
* Se realiza llamado al metodo del Servicio y se guarda resultado
|
204 |
-
* @return Skybox_Core_Model_Api_Restful
|
205 |
-
*/
|
206 |
-
protected function SetResponseService()
|
207 |
-
{
|
208 |
-
//$this->_response = file_get_contents($this->getUrlService());
|
209 |
-
$this->_response = $this->file_get_contents_curl($this->getUrlService());
|
210 |
-
return $this;
|
211 |
-
}
|
212 |
-
|
213 |
-
/**
|
214 |
-
* Invocamos al servicio
|
215 |
-
* @return Skybox_Core_Model_Api_Standard
|
216 |
-
*/
|
217 |
-
public function CallService($method, $params)
|
218 |
-
{
|
219 |
-
$params['platform'] = "magento-".Mage::getVersion();
|
220 |
-
$params['version'] = "v.".Skybox_Core_Model_Config::SKYBOX_VERSION;
|
221 |
-
$start_time = time();
|
222 |
-
try {
|
223 |
-
/**
|
224 |
-
* Pasos
|
225 |
-
* 1: Generamos la Url del Servicio
|
226 |
-
* 2: Guardamos la solicitud que se realiza al servicio
|
227 |
-
* 3: Invocamos al response del Servicio
|
228 |
-
* 4: Asignamos valores a los parametros
|
229 |
-
* 5: Guardamos la respuesta del servicio
|
230 |
-
*/
|
231 |
-
$this->setUrlService($method, $params)
|
232 |
-
->SaveRequestService()
|
233 |
-
->SetResponseService()
|
234 |
-
->SetValuesResponse()
|
235 |
-
->SaveResponseService($method, $start_time);
|
236 |
-
} catch (Exception $e) {
|
237 |
-
//throw new Exception($e->getMessage(), 1);
|
238 |
-
Mage::log($e->getMessage());
|
239 |
-
Mage::helper('skyboxcore/email')->sendException($e->getMessage());
|
240 |
-
return $this;
|
241 |
-
}
|
242 |
-
|
243 |
-
return $this;
|
244 |
-
}
|
245 |
-
|
246 |
-
/**
|
247 |
-
* Seteamos valores a los parametros correspondientes a partir del methodo invocado
|
248 |
-
* @return Skybox_Core_Model_Api_Restful
|
249 |
-
*/
|
250 |
-
protected function SetValuesResponse()
|
251 |
-
{
|
252 |
-
$status = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_STATUS};
|
253 |
-
$this->setStatusCode($status);
|
254 |
-
|
255 |
-
switch ($this->_methodCode) {
|
256 |
-
case Skybox_Core_Model_Config::SKYBOX_ACTION_AUTHENTICATE:
|
257 |
-
$this->setAuthorizedToken();
|
258 |
-
$this->setErrorAuthenticate();
|
259 |
-
break;
|
260 |
-
|
261 |
-
case Skybox_Core_Model_Config::SKYBOX_ACTION_INITIALICE:
|
262 |
-
//$this->setGuidApi();
|
263 |
-
|
264 |
-
if ($this->compareGuid() && $this->getGuidApi()) {
|
265 |
-
$this->getGuidApi();
|
266 |
-
} else {
|
267 |
-
$this->setGuidApi();
|
268 |
-
}
|
269 |
-
$this->setLocationAllow();
|
270 |
-
$this->setStoreCode();
|
271 |
-
$this->setCssVersion();
|
272 |
-
$this->setHtmlTemplateBar();
|
273 |
-
break;
|
274 |
-
case Skybox_Core_Model_Config::SKYBOX_ACTION_GET_TEMPLATE_BUTTON:
|
275 |
-
$this->setHtmlTemplateButton();
|
276 |
-
break;
|
277 |
-
}
|
278 |
-
|
279 |
-
return $this;
|
280 |
-
}
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
/**
|
285 |
-
* Sesión de registro de log
|
286 |
-
*/
|
287 |
-
|
288 |
-
/**
|
289 |
-
* Se registra la llamada al servicio
|
290 |
-
*/
|
291 |
-
public function SaveRequestService()
|
292 |
-
{
|
293 |
-
//Acciones
|
294 |
-
return $this;
|
295 |
-
}
|
296 |
-
|
297 |
-
/**
|
298 |
-
* SaveResponseService
|
299 |
-
* Save Service Response
|
300 |
-
*
|
301 |
-
* @param string $action
|
302 |
-
* @param string $start_time
|
303 |
-
* @return Skybox_Core_Model_Api_Restful
|
304 |
-
*/
|
305 |
-
public function SaveResponseService($action, $start_time)
|
306 |
-
{
|
307 |
-
$skybox_log = Mage::helper('skyboxinternational/data')->getSkyboxLog();
|
308 |
-
|
309 |
-
if ($skybox_log) {
|
310 |
-
$data = array(
|
311 |
-
'action' => $action,
|
312 |
-
'request' => $this->getUrlService(),
|
313 |
-
'response' => $this->getResponse(),
|
314 |
-
'timestamp_request' => $start_time,
|
315 |
-
'timestamp_response' => time(),
|
316 |
-
);
|
317 |
-
|
318 |
-
try {
|
319 |
-
/* @var $log_service Skybox_Core_Model_Logservice */
|
320 |
-
$log_service = Mage::getModel('skyboxcore/logservice');
|
321 |
-
$log_service->setData($data);
|
322 |
-
$log_service->save();
|
323 |
-
|
324 |
-
} catch (Exception $e) {
|
325 |
-
Mage::log($e->getMessage());
|
326 |
-
}
|
327 |
-
}
|
328 |
-
return $this;
|
329 |
-
}
|
330 |
-
|
331 |
-
/*
|
332 |
-
* file_get_contents_curl
|
333 |
-
*/
|
334 |
-
|
335 |
-
function file_get_contents_curl($url)
|
336 |
-
{
|
337 |
-
if (!function_exists("curl_init")) {
|
338 |
-
die("cURL extension is not installed");
|
339 |
-
}
|
340 |
-
$ch = curl_init();
|
341 |
-
// Disable SSL verification
|
342 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
343 |
-
// Will return the response, if false it print the response
|
344 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
345 |
-
// To force the use of a new connection instead of a cached one
|
346 |
-
//curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
|
347 |
-
// Set the url
|
348 |
-
curl_setopt($ch, CURLOPT_URL, $url);
|
349 |
-
// Execute
|
350 |
-
$result = curl_exec($ch);
|
351 |
-
|
352 |
-
// Will dump a beauty json :3
|
353 |
-
//var_dump(json_decode($result, true));
|
354 |
-
return $result;
|
355 |
-
}
|
356 |
-
|
357 |
-
/**
|
358 |
-
* Validad que el módulo de skybox este habilitado para la tienda
|
359 |
-
* @return bool
|
360 |
-
*/
|
361 |
-
public function isModuleEnable()
|
362 |
-
{
|
363 |
-
return (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
|
364 |
-
}
|
365 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Core
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Core
|
8 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Core_Model_Api_Restful extends Skybox_Core_Model_Api_Abstract
|
11 |
+
{
|
12 |
+
public $_skybox_guid = "";
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Guardamos en sesión el Html Template del Botón
|
16 |
+
* @param string $value
|
17 |
+
* @return Skybox_Core_Model_Api_Restful
|
18 |
+
*/
|
19 |
+
public function setHtmlTemplateButton($value = null)
|
20 |
+
{
|
21 |
+
$html = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_BUTTONHTML};
|
22 |
+
$htmlError = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_BUTTONERRORHTML};
|
23 |
+
$this->_config->getSession()->setHtmlTemplateButton($html);
|
24 |
+
$this->_config->getSession()->setHtmlTemplateButtonError($htmlError);
|
25 |
+
return $this;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Se recupera el Html Template del Botón almacenado en la sesión
|
30 |
+
* @return String
|
31 |
+
*/
|
32 |
+
public function getHtmlTemplateButton()
|
33 |
+
{
|
34 |
+
return $this->_config->getSession()->getHtmlTemplateButton();
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Guardamos en sesión el Html Template de la barra
|
39 |
+
* @param string $value
|
40 |
+
* @return Skybox_Core_Model_Api_Restful
|
41 |
+
*/
|
42 |
+
public function setHtmlTemplateBar($value = null)
|
43 |
+
{
|
44 |
+
$html = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_BARHTML};
|
45 |
+
$this->_config->getSession()->setHtmlTemplateBar($html);
|
46 |
+
return $this;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Se recupera el Html Template del Botón almacenado en la sesión
|
51 |
+
* @return String
|
52 |
+
*/
|
53 |
+
public function getHtmlTemplateBar()
|
54 |
+
{
|
55 |
+
return $this->_config->getSession()->getHtmlTemplateBar();
|
56 |
+
}
|
57 |
+
|
58 |
+
public function setGuidApi($value = null)
|
59 |
+
{
|
60 |
+
$guidId = null;
|
61 |
+
|
62 |
+
if (!$guidId) {
|
63 |
+
$guidId = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_GUID};
|
64 |
+
Mage::log("GuidID Not cart: " . $guidId);
|
65 |
+
}
|
66 |
+
|
67 |
+
$this->_config->getSession()->setCookieGuid($guidId);
|
68 |
+
$this->_skybox_guid = $guidId;
|
69 |
+
Mage::log("GuidID found: " . $guidId);
|
70 |
+
return $this;
|
71 |
+
}
|
72 |
+
|
73 |
+
// @todo Rewrite the way to get GUID
|
74 |
+
public function getGuidApi()
|
75 |
+
{
|
76 |
+
$guidId = null;
|
77 |
+
|
78 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
79 |
+
foreach ($quote->getAllItems() as $item) {
|
80 |
+
$guidId = $item->getGuidSkybox();
|
81 |
+
Mage::log(' | CallApiRest->Error1 | ', null, 'guid.log', true);
|
82 |
+
Mage::log("getGuidApi(): GuidID found (quote): " . $guidId, null, 'guid.log', true);
|
83 |
+
break;
|
84 |
+
}
|
85 |
+
|
86 |
+
if (!$guidId) {
|
87 |
+
$skyboxSession = $this->_config->getSession()->getCookieGuid();
|
88 |
+
if ($skyboxSession) {
|
89 |
+
// Mage::log(' | CallApiRest->Error2 | ', null, 'guid.log', true);
|
90 |
+
Mage::log("Call getGuidApi() from getSession(): " . $this->_config->getSession()->getCookieGuid(), null,
|
91 |
+
'guid.log', true);
|
92 |
+
$guidId = $this->_config->getSession()->getCookieGuid();
|
93 |
+
}
|
94 |
+
}
|
95 |
+
return $guidId;
|
96 |
+
}
|
97 |
+
|
98 |
+
public function compareGuid()
|
99 |
+
{
|
100 |
+
$already_guid = $this->getGuidApi();
|
101 |
+
$called_guid = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_GUID};
|
102 |
+
|
103 |
+
if ($already_guid == $called_guid) {
|
104 |
+
return true;
|
105 |
+
}
|
106 |
+
return false;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Seteamos si la localización del usuario esta permitida
|
111 |
+
* @param string $value
|
112 |
+
* @return Skybox_Core_Model_Api_Restful
|
113 |
+
*/
|
114 |
+
public function setLocationAllow($value = null)
|
115 |
+
{
|
116 |
+
$allow = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_LOCATION_ALLOW};
|
117 |
+
//$allow = 0; // Rogged
|
118 |
+
$this->_config->getSession()->setLocationAllow($allow);
|
119 |
+
return $this;
|
120 |
+
}
|
121 |
+
|
122 |
+
|
123 |
+
public function getLocationAllow()
|
124 |
+
{
|
125 |
+
return $this->_config->getSession()->getLocationAllow();
|
126 |
+
}
|
127 |
+
|
128 |
+
public function setStoreCode($value = null)
|
129 |
+
{
|
130 |
+
$storeCode = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_STORE_CODE};
|
131 |
+
$storeCode = trim($storeCode);
|
132 |
+
$this->_config->getSession()->setStoreCode($storeCode);
|
133 |
+
return $storeCode;
|
134 |
+
}
|
135 |
+
|
136 |
+
public function getStoreCode()
|
137 |
+
{
|
138 |
+
return $this->_config->getSession()->getStoreCode();
|
139 |
+
}
|
140 |
+
|
141 |
+
public function setCssVersion($value = null)
|
142 |
+
{
|
143 |
+
$cssVersion = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_CSS_VERSION};
|
144 |
+
$cssVersion = (isset($cssVersion)) ? trim($cssVersion) : 1;
|
145 |
+
$this->_config->getSession()->setCssVersion($cssVersion);
|
146 |
+
return $cssVersion;
|
147 |
+
}
|
148 |
+
|
149 |
+
public function getCssVersion()
|
150 |
+
{
|
151 |
+
return $this->_config->getSession()->getCssVersion();
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Seteamos error del servicio
|
156 |
+
* @param string $value
|
157 |
+
* @return Skybox_Core_Model_Api_Restful
|
158 |
+
*/
|
159 |
+
public function setErrorAuthenticate()
|
160 |
+
{
|
161 |
+
$this->_config->getSession()->setErrorAuthenticate($this->HasError());
|
162 |
+
return $this;
|
163 |
+
}
|
164 |
+
|
165 |
+
public function getErrorAuthenticate()
|
166 |
+
{
|
167 |
+
return $this->_config->getSession()->getErrorAuthenticate();
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Guardamos en sesión el token de autorización
|
172 |
+
* @param string $value
|
173 |
+
* @return Skybox_Core_Model_Api_Restful
|
174 |
+
*/
|
175 |
+
public function setAuthorizedToken($value = null)
|
176 |
+
{
|
177 |
+
$token = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_TOKEN};
|
178 |
+
Mage::log('setAuthorizedToken token skybox: ' . $token);
|
179 |
+
// $token = urlencode($token);
|
180 |
+
$this->_config->getSession()->setTokenApiRest($token);
|
181 |
+
return $this;
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Obtenemos el token de autorización almacenado en sesión
|
186 |
+
* @return string
|
187 |
+
*/
|
188 |
+
public function getAuthorizedToken()
|
189 |
+
{
|
190 |
+
//return $this->_config->getSession()->getTokenApiRest() ?: "";
|
191 |
+
$algo = $this->_config->getSession()->getTokenApiRest();
|
192 |
+
if (!empty($algo)) {
|
193 |
+
return $this->_config->getSession()->getTokenApiRest();
|
194 |
+
}
|
195 |
+
return "";
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Sección de llamadas a los metodos del ApiRest
|
200 |
+
*/
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Se realiza llamado al metodo del Servicio y se guarda resultado
|
204 |
+
* @return Skybox_Core_Model_Api_Restful
|
205 |
+
*/
|
206 |
+
protected function SetResponseService()
|
207 |
+
{
|
208 |
+
//$this->_response = file_get_contents($this->getUrlService());
|
209 |
+
$this->_response = $this->file_get_contents_curl($this->getUrlService());
|
210 |
+
return $this;
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Invocamos al servicio
|
215 |
+
* @return Skybox_Core_Model_Api_Standard
|
216 |
+
*/
|
217 |
+
public function CallService($method, $params)
|
218 |
+
{
|
219 |
+
$params['platform'] = "magento-".Mage::getVersion();
|
220 |
+
$params['version'] = "v.".Skybox_Core_Model_Config::SKYBOX_VERSION;
|
221 |
+
$start_time = time();
|
222 |
+
try {
|
223 |
+
/**
|
224 |
+
* Pasos
|
225 |
+
* 1: Generamos la Url del Servicio
|
226 |
+
* 2: Guardamos la solicitud que se realiza al servicio
|
227 |
+
* 3: Invocamos al response del Servicio
|
228 |
+
* 4: Asignamos valores a los parametros
|
229 |
+
* 5: Guardamos la respuesta del servicio
|
230 |
+
*/
|
231 |
+
$this->setUrlService($method, $params)
|
232 |
+
->SaveRequestService()
|
233 |
+
->SetResponseService()
|
234 |
+
->SetValuesResponse()
|
235 |
+
->SaveResponseService($method, $start_time);
|
236 |
+
} catch (Exception $e) {
|
237 |
+
//throw new Exception($e->getMessage(), 1);
|
238 |
+
Mage::log($e->getMessage());
|
239 |
+
Mage::helper('skyboxcore/email')->sendException($e->getMessage());
|
240 |
+
return $this;
|
241 |
+
}
|
242 |
+
|
243 |
+
return $this;
|
244 |
+
}
|
245 |
+
|
246 |
+
/**
|
247 |
+
* Seteamos valores a los parametros correspondientes a partir del methodo invocado
|
248 |
+
* @return Skybox_Core_Model_Api_Restful
|
249 |
+
*/
|
250 |
+
protected function SetValuesResponse()
|
251 |
+
{
|
252 |
+
$status = $this->getResponseJson()->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_STATUS};
|
253 |
+
$this->setStatusCode($status);
|
254 |
+
|
255 |
+
switch ($this->_methodCode) {
|
256 |
+
case Skybox_Core_Model_Config::SKYBOX_ACTION_AUTHENTICATE:
|
257 |
+
$this->setAuthorizedToken();
|
258 |
+
$this->setErrorAuthenticate();
|
259 |
+
break;
|
260 |
+
|
261 |
+
case Skybox_Core_Model_Config::SKYBOX_ACTION_INITIALICE:
|
262 |
+
//$this->setGuidApi();
|
263 |
+
|
264 |
+
if ($this->compareGuid() && $this->getGuidApi()) {
|
265 |
+
$this->getGuidApi();
|
266 |
+
} else {
|
267 |
+
$this->setGuidApi();
|
268 |
+
}
|
269 |
+
$this->setLocationAllow();
|
270 |
+
$this->setStoreCode();
|
271 |
+
$this->setCssVersion();
|
272 |
+
$this->setHtmlTemplateBar();
|
273 |
+
break;
|
274 |
+
case Skybox_Core_Model_Config::SKYBOX_ACTION_GET_TEMPLATE_BUTTON:
|
275 |
+
$this->setHtmlTemplateButton();
|
276 |
+
break;
|
277 |
+
}
|
278 |
+
|
279 |
+
return $this;
|
280 |
+
}
|
281 |
+
|
282 |
+
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Sesión de registro de log
|
286 |
+
*/
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Se registra la llamada al servicio
|
290 |
+
*/
|
291 |
+
public function SaveRequestService()
|
292 |
+
{
|
293 |
+
//Acciones
|
294 |
+
return $this;
|
295 |
+
}
|
296 |
+
|
297 |
+
/**
|
298 |
+
* SaveResponseService
|
299 |
+
* Save Service Response
|
300 |
+
*
|
301 |
+
* @param string $action
|
302 |
+
* @param string $start_time
|
303 |
+
* @return Skybox_Core_Model_Api_Restful
|
304 |
+
*/
|
305 |
+
public function SaveResponseService($action, $start_time)
|
306 |
+
{
|
307 |
+
$skybox_log = Mage::helper('skyboxinternational/data')->getSkyboxLog();
|
308 |
+
|
309 |
+
if ($skybox_log) {
|
310 |
+
$data = array(
|
311 |
+
'action' => $action,
|
312 |
+
'request' => $this->getUrlService(),
|
313 |
+
'response' => $this->getResponse(),
|
314 |
+
'timestamp_request' => $start_time,
|
315 |
+
'timestamp_response' => time(),
|
316 |
+
);
|
317 |
+
|
318 |
+
try {
|
319 |
+
/* @var $log_service Skybox_Core_Model_Logservice */
|
320 |
+
$log_service = Mage::getModel('skyboxcore/logservice');
|
321 |
+
$log_service->setData($data);
|
322 |
+
$log_service->save();
|
323 |
+
|
324 |
+
} catch (Exception $e) {
|
325 |
+
Mage::log($e->getMessage());
|
326 |
+
}
|
327 |
+
}
|
328 |
+
return $this;
|
329 |
+
}
|
330 |
+
|
331 |
+
/*
|
332 |
+
* file_get_contents_curl
|
333 |
+
*/
|
334 |
+
|
335 |
+
function file_get_contents_curl($url)
|
336 |
+
{
|
337 |
+
if (!function_exists("curl_init")) {
|
338 |
+
die("cURL extension is not installed");
|
339 |
+
}
|
340 |
+
$ch = curl_init();
|
341 |
+
// Disable SSL verification
|
342 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
343 |
+
// Will return the response, if false it print the response
|
344 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
345 |
+
// To force the use of a new connection instead of a cached one
|
346 |
+
//curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
|
347 |
+
// Set the url
|
348 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
349 |
+
// Execute
|
350 |
+
$result = curl_exec($ch);
|
351 |
+
|
352 |
+
// Will dump a beauty json :3
|
353 |
+
//var_dump(json_decode($result, true));
|
354 |
+
return $result;
|
355 |
+
}
|
356 |
+
|
357 |
+
/**
|
358 |
+
* Validad que el módulo de skybox este habilitado para la tienda
|
359 |
+
* @return bool
|
360 |
+
*/
|
361 |
+
public function isModuleEnable()
|
362 |
+
{
|
363 |
+
return (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
|
364 |
+
}
|
365 |
+
}
|
app/code/community/Skybox/Core/Model/Config.php
CHANGED
@@ -1,252 +1,252 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Core
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Core
|
8 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Configuración del modelo
|
13 |
-
* @author César Tapia M. <ctapia@skyworldint.com>
|
14 |
-
*/
|
15 |
-
class Skybox_Core_Model_Config
|
16 |
-
{
|
17 |
-
|
18 |
-
const SKYBOX_VERSION = "1.2.8";
|
19 |
-
/**
|
20 |
-
* Skybox cookie
|
21 |
-
* @var string
|
22 |
-
*/
|
23 |
-
const SKYBOX_COOKIE_API_GUID = "int_guid_api";
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Skybox actions
|
27 |
-
* @var string
|
28 |
-
*/
|
29 |
-
const SKYBOX_ACTION_AUTHENTICATE = "AuthenticateService";
|
30 |
-
const SKYBOX_ACTION_INITIALICE = "InitializeSessionUser";
|
31 |
-
const SKYBOX_ACTION_CALCULATE = "Calculate";
|
32 |
-
const SKYBOX_ACTION_CATEGORIES = "Categories";
|
33 |
-
const SKYBOX_ACTION_ADD_PRODUCT_CART = "AddProductToCart";
|
34 |
-
const SKYBOX_ACTION_DELETE_PRODUCT_CART = "DelProductOfCart";
|
35 |
-
const SKYBOX_ACTION_UPDATE_PRODUCT_CART = "UpdateProductOfCart";
|
36 |
-
const SKYBOX_ACTION_GET_TEMPLATE_BUTTON = "GetButtonTemplate";
|
37 |
-
const SKYBOX_ACTION_GET_TOTAL_SHOPINGCART = "GetTotalShoppingCart";
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Skybox errors
|
41 |
-
* @var string
|
42 |
-
*/
|
43 |
-
const SKYBOX_ERROR_SERVICE_NOT_CONTROLLER = "50000";
|
44 |
-
const SKYBOX_ERROR_GCODE_IDMERCHANT_INVALID = "50001";
|
45 |
-
const SKYBOX_ERROR_GCODE_TOKEN_EXPIRED = "50002";
|
46 |
-
const SKYBOX_ERROR_GCODE_DEVICE_GUID_INVALID = "50003";
|
47 |
-
const SKYBOX_ERROR_GCODE_PRODUCT_NOT_IN_SHOPPING_CART = "50004";
|
48 |
-
const SKYBOX_ERROR_GCODE_COUNTRY_NOT_CONFIGURED_TO_STORE = "50005";
|
49 |
-
const SKYBOX_ERROR_MERCHANT_KEY_INVALID = "50006";
|
50 |
-
const SKYBOX_ERROR_GCODE_IP_NOT_ALLOWED = "50007";
|
51 |
-
const SKYBOX_ERROR_GCODE_PRODUCT_CATEGORY_INVALID = "50008";
|
52 |
-
const SKYBOX_ERROR_GCODE_PRODUCT_UNITWEIGHT_IS_NULL = "50009";
|
53 |
-
const SKYBOX_ERROR_GCODE_PRODUCT_WEIGHT_INVALID = "50010";
|
54 |
-
const SKYBOX_ERROR_GCODE_PRODUCT_WEIGHT_IS_NULL = "50011";
|
55 |
-
const SKYBOX_ERROR_GCODE_MERCHANT_KEY_IS_NULL = "50013";
|
56 |
-
const SKYBOX_ERROR_GCODE_PRODUCT_UNITWEIGHT_INVALID = "50014";
|
57 |
-
const SKYBOX_ERROR_GCODE_STORE_CITY_NOT_CONFIGURED = "50015";
|
58 |
-
const SKYBOX_ERROR_GCODE_TOKEN_IS_NULL = "50016";
|
59 |
-
const SKYBOX_ERROR_GCODE_GUID_IS_NULL = "50017";
|
60 |
-
const SKYBOX_ERROR_GCODE_REGION_NOT_CONFIGURED_TO_STORE = "50018";
|
61 |
-
const SKYBOX_ERROR_GCODE_PRODUCT_NAME_IS_NULL = "50019";
|
62 |
-
const SKYBOX_ERROR_GCODE_PRODUCT_CODE_IS_NULL = "50020";
|
63 |
-
const SKYBOX_ERROR_GCODE_RATES_NOT_FOUND = "50021";
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Skybox PARAMETERS REQUEST
|
67 |
-
* @var string
|
68 |
-
*/
|
69 |
-
const SKYBOX_PARAMETER_MERCHANT = "merchant";
|
70 |
-
const SKYBOX_PARAMETER_MERCHANTKEY = "merchantKey";
|
71 |
-
const SKYBOX_PARAMETER_GUID = "guid";
|
72 |
-
const SKYBOX_PARAMETER_TOKEN = "token";
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Skybox PARAMETERS RESPONSE
|
76 |
-
* @var string
|
77 |
-
*/
|
78 |
-
const SKYBOX_PARAMETER_RESPONSE_TOKEN = "TokenCode";
|
79 |
-
const SKYBOX_PARAMETER_RESPONSE_GUID = "Guid";
|
80 |
-
const SKYBOX_PARAMETER_RESPONSE_MESSAGE = "StatusMessage";
|
81 |
-
const SKYBOX_PARAMETER_RESPONSE_STATUS = "StatusCode";
|
82 |
-
const SKYBOX_PARAMETER_RESPONSE_BARHTML = "BarHtmlTemplate";
|
83 |
-
const SKYBOX_PARAMETER_RESPONSE_LOCATION_ALLOW = "LocationAllow";
|
84 |
-
const SKYBOX_PARAMETER_RESPONSE_STORE_CODE = "StoreCode";
|
85 |
-
const SKYBOX_PARAMETER_RESPONSE_BUTTONHTML = "HtmlTemplate";
|
86 |
-
const SKYBOX_PARAMETER_RESPONSE_BUTTONERRORHTML = "HtmlTemplateError";
|
87 |
-
const SKYBOX_PARAMETER_RESPONSE_BUTTONERROR = "CalcErrorCode";
|
88 |
-
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID = "ProductId";
|
89 |
-
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_CUSTOMS = "ProductCustoms";
|
90 |
-
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_SHIPPING = "ProductShipping";
|
91 |
-
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_INSURANCE = "ProductInsurance";
|
92 |
-
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_TOTAL = "TotalProduct";
|
93 |
-
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_PRICE = "StoreProductPrice";
|
94 |
-
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_CUSTOMS_USD = "ProductCustomsUSD";
|
95 |
-
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_SHIPPING_USD = "ProductShippingUSD";
|
96 |
-
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_INSURANCE_USD = "ProductInsuranceUSD";
|
97 |
-
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_TOTAL_USD = "TotalProductUSD";
|
98 |
-
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_PRICE_USD = "StoreProductPriceUSD";
|
99 |
-
const SKYBOX_PARAMETER_RESPONSE_CART_CURRENCY_ISO = "CartCurrencyIso";
|
100 |
-
|
101 |
-
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_BASE_PRICE = "BaseProductPrice";
|
102 |
-
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_BASE_PRICE_USD = "BaseProductPriceUSD";
|
103 |
-
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_ADJUST_PRICE = "ProductAdjustment";
|
104 |
-
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_ADJUST_PRICE_USD = "ProductAdjustmentUSD";
|
105 |
-
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_LABEL_ADJUST = "WidgetLabelAdjustment";
|
106 |
-
|
107 |
-
const SKYBOX_PARAMETER_RESPONSE_CSS_VERSION = "CssVersion";
|
108 |
-
|
109 |
-
const SKYBOX_CURRENCY_USD = "USD";
|
110 |
-
|
111 |
-
/**
|
112 |
-
* Default URL para Api Skybox Checkout
|
113 |
-
*
|
114 |
-
* @var string
|
115 |
-
*/
|
116 |
-
//public $skyboxDefaultApiUrl = 'http://www.skyboxcheckout.com/Service/ApiRest/';
|
117 |
-
//public $skyboxDefaultApiUrl = 'http://localhost:65065/ApiRest/';
|
118 |
-
public $skyboxDefaultApiUrl = 'http://127.0.0.1:65065/ApiRest/';
|
119 |
-
//public $skyboxDefaultApiUrl = 'http://checkout.skynet.com/Service/ApiRest/';
|
120 |
-
//public $skyboxDefaultApiUrl = 'http://beta.skyboxcheckout.com/ServiceTest/ApiRest/';
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Default URL para Skybox Checkout
|
124 |
-
*
|
125 |
-
* @var string
|
126 |
-
*/
|
127 |
-
//public $skyboxDefaultUrl = 'http://www.skyboxcheckout.com/';
|
128 |
-
//public $skyboxDefaultUrl = 'http://localhost:6761/';
|
129 |
-
//public $skyboxDefaultUrl = 'http://127.0.0.1:6761/';
|
130 |
-
public $skyboxDefaultUrl = 'http://127.0.0.1:6761/';
|
131 |
-
//public $skyboxDefaultUrl = 'http://checkout.skynet.com/';
|
132 |
-
|
133 |
-
/**
|
134 |
-
* Código de Tienda
|
135 |
-
*
|
136 |
-
* @var string
|
137 |
-
*/
|
138 |
-
protected $_merchantId = null;
|
139 |
-
|
140 |
-
|
141 |
-
/**
|
142 |
-
* Llave de Tienda
|
143 |
-
*
|
144 |
-
* @var string
|
145 |
-
*/
|
146 |
-
protected $_merchantkey = null;
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Código de Guid
|
150 |
-
* @var string
|
151 |
-
*/
|
152 |
-
protected $_guidapi = null;
|
153 |
-
|
154 |
-
/**
|
155 |
-
* Obtenemos el objeto Session
|
156 |
-
* @return Skybox_Core_Model_Session
|
157 |
-
*/
|
158 |
-
public function getSession()
|
159 |
-
{
|
160 |
-
return Mage::getSingleton('skyboxcore/session');
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* Obtenemos el objeto Cookie
|
165 |
-
* @return Mage_Core_Model_Cookie
|
166 |
-
*/
|
167 |
-
public function getCookie()
|
168 |
-
{
|
169 |
-
return Mage::getModel('core/cookie');
|
170 |
-
}
|
171 |
-
|
172 |
-
/**
|
173 |
-
* Obtenemos el objeto Http
|
174 |
-
*
|
175 |
-
* @return Mage_Core_Helper_Http
|
176 |
-
*/
|
177 |
-
public function getHttp()
|
178 |
-
{
|
179 |
-
return Mage::helper('core/http');
|
180 |
-
}
|
181 |
-
|
182 |
-
/**
|
183 |
-
* Current locale code getter
|
184 |
-
*
|
185 |
-
* @return string
|
186 |
-
*/
|
187 |
-
public function getLocaleCode()
|
188 |
-
{
|
189 |
-
return Mage::app()->getLocale()->getLocaleCode();
|
190 |
-
}
|
191 |
-
|
192 |
-
/**
|
193 |
-
* Obtenemos inforamción del navegador del cliente
|
194 |
-
*
|
195 |
-
* @return HTTP_USER_AGENT
|
196 |
-
*/
|
197 |
-
public function getUserAgent()
|
198 |
-
{
|
199 |
-
return $this->getHttp()->getHttpUserAgent();
|
200 |
-
}
|
201 |
-
|
202 |
-
/**
|
203 |
-
* Obtenemos la Ip Local Remota del Cliente
|
204 |
-
*
|
205 |
-
* @return REMOTE_ADDR
|
206 |
-
*/
|
207 |
-
public function getRemoteAddr()
|
208 |
-
{
|
209 |
-
return $this->getHttp()->getRemoteAddr();
|
210 |
-
}
|
211 |
-
|
212 |
-
/**
|
213 |
-
* Obtenemos la Ip Proxy del Client
|
214 |
-
*
|
215 |
-
* @return HTTP_VIA or HTTP_X_FORWARDED_FOR
|
216 |
-
*/
|
217 |
-
public function getProxy()
|
218 |
-
{
|
219 |
-
$proxy = getenv('HTTP_X_FORWARDED_FOR');
|
220 |
-
return isset($proxy) ? $proxy : "";
|
221 |
-
}
|
222 |
-
|
223 |
-
/**
|
224 |
-
* Obtenemos la Ip Local del Cliente
|
225 |
-
*
|
226 |
-
* @return String
|
227 |
-
*/
|
228 |
-
public function getHost()
|
229 |
-
{
|
230 |
-
return $this->getHttp()->getHttpHost();
|
231 |
-
}
|
232 |
-
|
233 |
-
/**
|
234 |
-
* Obtenemos el lenguaje del Navegador del Cliente
|
235 |
-
*
|
236 |
-
* @return string
|
237 |
-
*/
|
238 |
-
public function getLanguage()
|
239 |
-
{
|
240 |
-
return $this->getHttp()->getHttpAcceptLanguage();
|
241 |
-
}
|
242 |
-
|
243 |
-
public function getSkyBoxUrlAPI()
|
244 |
-
{
|
245 |
-
return Mage::helper('skyboxinternational/data')->getSkyboxUrlAPI();
|
246 |
-
}
|
247 |
-
|
248 |
-
public function getSkyBoxUrlMain()
|
249 |
-
{
|
250 |
-
return Mage::helper('skyboxinternational/data')->getSkyboxUrlMain();
|
251 |
-
}
|
252 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Core
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Core
|
8 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Configuración del modelo
|
13 |
+
* @author César Tapia M. <ctapia@skyworldint.com>
|
14 |
+
*/
|
15 |
+
class Skybox_Core_Model_Config
|
16 |
+
{
|
17 |
+
|
18 |
+
const SKYBOX_VERSION = "1.2.8";
|
19 |
+
/**
|
20 |
+
* Skybox cookie
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
+
const SKYBOX_COOKIE_API_GUID = "int_guid_api";
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Skybox actions
|
27 |
+
* @var string
|
28 |
+
*/
|
29 |
+
const SKYBOX_ACTION_AUTHENTICATE = "AuthenticateService";
|
30 |
+
const SKYBOX_ACTION_INITIALICE = "InitializeSessionUser";
|
31 |
+
const SKYBOX_ACTION_CALCULATE = "Calculate";
|
32 |
+
const SKYBOX_ACTION_CATEGORIES = "Categories";
|
33 |
+
const SKYBOX_ACTION_ADD_PRODUCT_CART = "AddProductToCart";
|
34 |
+
const SKYBOX_ACTION_DELETE_PRODUCT_CART = "DelProductOfCart";
|
35 |
+
const SKYBOX_ACTION_UPDATE_PRODUCT_CART = "UpdateProductOfCart";
|
36 |
+
const SKYBOX_ACTION_GET_TEMPLATE_BUTTON = "GetButtonTemplate";
|
37 |
+
const SKYBOX_ACTION_GET_TOTAL_SHOPINGCART = "GetTotalShoppingCart";
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Skybox errors
|
41 |
+
* @var string
|
42 |
+
*/
|
43 |
+
const SKYBOX_ERROR_SERVICE_NOT_CONTROLLER = "50000";
|
44 |
+
const SKYBOX_ERROR_GCODE_IDMERCHANT_INVALID = "50001";
|
45 |
+
const SKYBOX_ERROR_GCODE_TOKEN_EXPIRED = "50002";
|
46 |
+
const SKYBOX_ERROR_GCODE_DEVICE_GUID_INVALID = "50003";
|
47 |
+
const SKYBOX_ERROR_GCODE_PRODUCT_NOT_IN_SHOPPING_CART = "50004";
|
48 |
+
const SKYBOX_ERROR_GCODE_COUNTRY_NOT_CONFIGURED_TO_STORE = "50005";
|
49 |
+
const SKYBOX_ERROR_MERCHANT_KEY_INVALID = "50006";
|
50 |
+
const SKYBOX_ERROR_GCODE_IP_NOT_ALLOWED = "50007";
|
51 |
+
const SKYBOX_ERROR_GCODE_PRODUCT_CATEGORY_INVALID = "50008";
|
52 |
+
const SKYBOX_ERROR_GCODE_PRODUCT_UNITWEIGHT_IS_NULL = "50009";
|
53 |
+
const SKYBOX_ERROR_GCODE_PRODUCT_WEIGHT_INVALID = "50010";
|
54 |
+
const SKYBOX_ERROR_GCODE_PRODUCT_WEIGHT_IS_NULL = "50011";
|
55 |
+
const SKYBOX_ERROR_GCODE_MERCHANT_KEY_IS_NULL = "50013";
|
56 |
+
const SKYBOX_ERROR_GCODE_PRODUCT_UNITWEIGHT_INVALID = "50014";
|
57 |
+
const SKYBOX_ERROR_GCODE_STORE_CITY_NOT_CONFIGURED = "50015";
|
58 |
+
const SKYBOX_ERROR_GCODE_TOKEN_IS_NULL = "50016";
|
59 |
+
const SKYBOX_ERROR_GCODE_GUID_IS_NULL = "50017";
|
60 |
+
const SKYBOX_ERROR_GCODE_REGION_NOT_CONFIGURED_TO_STORE = "50018";
|
61 |
+
const SKYBOX_ERROR_GCODE_PRODUCT_NAME_IS_NULL = "50019";
|
62 |
+
const SKYBOX_ERROR_GCODE_PRODUCT_CODE_IS_NULL = "50020";
|
63 |
+
const SKYBOX_ERROR_GCODE_RATES_NOT_FOUND = "50021";
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Skybox PARAMETERS REQUEST
|
67 |
+
* @var string
|
68 |
+
*/
|
69 |
+
const SKYBOX_PARAMETER_MERCHANT = "merchant";
|
70 |
+
const SKYBOX_PARAMETER_MERCHANTKEY = "merchantKey";
|
71 |
+
const SKYBOX_PARAMETER_GUID = "guid";
|
72 |
+
const SKYBOX_PARAMETER_TOKEN = "token";
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Skybox PARAMETERS RESPONSE
|
76 |
+
* @var string
|
77 |
+
*/
|
78 |
+
const SKYBOX_PARAMETER_RESPONSE_TOKEN = "TokenCode";
|
79 |
+
const SKYBOX_PARAMETER_RESPONSE_GUID = "Guid";
|
80 |
+
const SKYBOX_PARAMETER_RESPONSE_MESSAGE = "StatusMessage";
|
81 |
+
const SKYBOX_PARAMETER_RESPONSE_STATUS = "StatusCode";
|
82 |
+
const SKYBOX_PARAMETER_RESPONSE_BARHTML = "BarHtmlTemplate";
|
83 |
+
const SKYBOX_PARAMETER_RESPONSE_LOCATION_ALLOW = "LocationAllow";
|
84 |
+
const SKYBOX_PARAMETER_RESPONSE_STORE_CODE = "StoreCode";
|
85 |
+
const SKYBOX_PARAMETER_RESPONSE_BUTTONHTML = "HtmlTemplate";
|
86 |
+
const SKYBOX_PARAMETER_RESPONSE_BUTTONERRORHTML = "HtmlTemplateError";
|
87 |
+
const SKYBOX_PARAMETER_RESPONSE_BUTTONERROR = "CalcErrorCode";
|
88 |
+
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_ID = "ProductId";
|
89 |
+
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_CUSTOMS = "ProductCustoms";
|
90 |
+
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_SHIPPING = "ProductShipping";
|
91 |
+
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_INSURANCE = "ProductInsurance";
|
92 |
+
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_TOTAL = "TotalProduct";
|
93 |
+
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_PRICE = "StoreProductPrice";
|
94 |
+
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_CUSTOMS_USD = "ProductCustomsUSD";
|
95 |
+
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_SHIPPING_USD = "ProductShippingUSD";
|
96 |
+
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_INSURANCE_USD = "ProductInsuranceUSD";
|
97 |
+
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_TOTAL_USD = "TotalProductUSD";
|
98 |
+
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_PRICE_USD = "StoreProductPriceUSD";
|
99 |
+
const SKYBOX_PARAMETER_RESPONSE_CART_CURRENCY_ISO = "CartCurrencyIso";
|
100 |
+
|
101 |
+
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_BASE_PRICE = "BaseProductPrice";
|
102 |
+
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_BASE_PRICE_USD = "BaseProductPriceUSD";
|
103 |
+
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_ADJUST_PRICE = "ProductAdjustment";
|
104 |
+
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_ADJUST_PRICE_USD = "ProductAdjustmentUSD";
|
105 |
+
const SKYBOX_PARAMETER_RESPONSE_PRODUCT_LABEL_ADJUST = "WidgetLabelAdjustment";
|
106 |
+
|
107 |
+
const SKYBOX_PARAMETER_RESPONSE_CSS_VERSION = "CssVersion";
|
108 |
+
|
109 |
+
const SKYBOX_CURRENCY_USD = "USD";
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Default URL para Api Skybox Checkout
|
113 |
+
*
|
114 |
+
* @var string
|
115 |
+
*/
|
116 |
+
//public $skyboxDefaultApiUrl = 'http://www.skyboxcheckout.com/Service/ApiRest/';
|
117 |
+
//public $skyboxDefaultApiUrl = 'http://localhost:65065/ApiRest/';
|
118 |
+
public $skyboxDefaultApiUrl = 'http://127.0.0.1:65065/ApiRest/';
|
119 |
+
//public $skyboxDefaultApiUrl = 'http://checkout.skynet.com/Service/ApiRest/';
|
120 |
+
//public $skyboxDefaultApiUrl = 'http://beta.skyboxcheckout.com/ServiceTest/ApiRest/';
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Default URL para Skybox Checkout
|
124 |
+
*
|
125 |
+
* @var string
|
126 |
+
*/
|
127 |
+
//public $skyboxDefaultUrl = 'http://www.skyboxcheckout.com/';
|
128 |
+
//public $skyboxDefaultUrl = 'http://localhost:6761/';
|
129 |
+
//public $skyboxDefaultUrl = 'http://127.0.0.1:6761/';
|
130 |
+
public $skyboxDefaultUrl = 'http://127.0.0.1:6761/';
|
131 |
+
//public $skyboxDefaultUrl = 'http://checkout.skynet.com/';
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Código de Tienda
|
135 |
+
*
|
136 |
+
* @var string
|
137 |
+
*/
|
138 |
+
protected $_merchantId = null;
|
139 |
+
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Llave de Tienda
|
143 |
+
*
|
144 |
+
* @var string
|
145 |
+
*/
|
146 |
+
protected $_merchantkey = null;
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Código de Guid
|
150 |
+
* @var string
|
151 |
+
*/
|
152 |
+
protected $_guidapi = null;
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Obtenemos el objeto Session
|
156 |
+
* @return Skybox_Core_Model_Session
|
157 |
+
*/
|
158 |
+
public function getSession()
|
159 |
+
{
|
160 |
+
return Mage::getSingleton('skyboxcore/session');
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Obtenemos el objeto Cookie
|
165 |
+
* @return Mage_Core_Model_Cookie
|
166 |
+
*/
|
167 |
+
public function getCookie()
|
168 |
+
{
|
169 |
+
return Mage::getModel('core/cookie');
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Obtenemos el objeto Http
|
174 |
+
*
|
175 |
+
* @return Mage_Core_Helper_Http
|
176 |
+
*/
|
177 |
+
public function getHttp()
|
178 |
+
{
|
179 |
+
return Mage::helper('core/http');
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Current locale code getter
|
184 |
+
*
|
185 |
+
* @return string
|
186 |
+
*/
|
187 |
+
public function getLocaleCode()
|
188 |
+
{
|
189 |
+
return Mage::app()->getLocale()->getLocaleCode();
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Obtenemos inforamción del navegador del cliente
|
194 |
+
*
|
195 |
+
* @return HTTP_USER_AGENT
|
196 |
+
*/
|
197 |
+
public function getUserAgent()
|
198 |
+
{
|
199 |
+
return $this->getHttp()->getHttpUserAgent();
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Obtenemos la Ip Local Remota del Cliente
|
204 |
+
*
|
205 |
+
* @return REMOTE_ADDR
|
206 |
+
*/
|
207 |
+
public function getRemoteAddr()
|
208 |
+
{
|
209 |
+
return $this->getHttp()->getRemoteAddr();
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Obtenemos la Ip Proxy del Client
|
214 |
+
*
|
215 |
+
* @return HTTP_VIA or HTTP_X_FORWARDED_FOR
|
216 |
+
*/
|
217 |
+
public function getProxy()
|
218 |
+
{
|
219 |
+
$proxy = getenv('HTTP_X_FORWARDED_FOR');
|
220 |
+
return isset($proxy) ? $proxy : "";
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Obtenemos la Ip Local del Cliente
|
225 |
+
*
|
226 |
+
* @return String
|
227 |
+
*/
|
228 |
+
public function getHost()
|
229 |
+
{
|
230 |
+
return $this->getHttp()->getHttpHost();
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Obtenemos el lenguaje del Navegador del Cliente
|
235 |
+
*
|
236 |
+
* @return string
|
237 |
+
*/
|
238 |
+
public function getLanguage()
|
239 |
+
{
|
240 |
+
return $this->getHttp()->getHttpAcceptLanguage();
|
241 |
+
}
|
242 |
+
|
243 |
+
public function getSkyBoxUrlAPI()
|
244 |
+
{
|
245 |
+
return Mage::helper('skyboxinternational/data')->getSkyboxUrlAPI();
|
246 |
+
}
|
247 |
+
|
248 |
+
public function getSkyBoxUrlMain()
|
249 |
+
{
|
250 |
+
return Mage::helper('skyboxinternational/data')->getSkyboxUrlMain();
|
251 |
+
}
|
252 |
}
|
app/code/community/Skybox/Core/Model/Logservice.php
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Core
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Core
|
8 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Core_Model_Logservice extends Mage_Core_Model_Abstract
|
11 |
-
{
|
12 |
-
protected function _construct()
|
13 |
-
{
|
14 |
-
parent::_construct();
|
15 |
-
$this->_init('skyboxcore/logservice', 'service_id');
|
16 |
-
}
|
17 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Core
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Core
|
8 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Core_Model_Logservice extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
protected function _construct()
|
13 |
+
{
|
14 |
+
parent::_construct();
|
15 |
+
$this->_init('skyboxcore/logservice', 'service_id');
|
16 |
+
}
|
17 |
}
|
app/code/community/Skybox/Core/Model/Mysql4.php
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Core
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Core
|
8 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Core_Model_Mysql4 extends Mage_Core_Model_Abstract
|
11 |
-
{
|
12 |
-
public function _construct()
|
13 |
-
{
|
14 |
-
parent::_construct();
|
15 |
-
$this->_init('skybox/mysql4');
|
16 |
-
}
|
17 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Core
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Core
|
8 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Core_Model_Mysql4 extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
public function _construct()
|
13 |
+
{
|
14 |
+
parent::_construct();
|
15 |
+
$this->_init('skybox/mysql4');
|
16 |
+
}
|
17 |
}
|
app/code/community/Skybox/Core/Model/Mysql4/Logservice.php
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Core
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Core
|
8 |
-
* @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
*
|
13 |
-
* Skybox Log Service Model
|
14 |
-
*
|
15 |
-
*/
|
16 |
-
class Skybox_Core_Model_Mysql4_Logservice extends Mage_Core_Model_Mysql4_Abstract
|
17 |
-
{
|
18 |
-
protected function _construct()
|
19 |
-
{
|
20 |
-
//parent::_construct();
|
21 |
-
$this->_init('skyboxcore/logservice', 'service_id');
|
22 |
-
}
|
23 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Core
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Core
|
8 |
+
* @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
*
|
13 |
+
* Skybox Log Service Model
|
14 |
+
*
|
15 |
+
*/
|
16 |
+
class Skybox_Core_Model_Mysql4_Logservice extends Mage_Core_Model_Mysql4_Abstract
|
17 |
+
{
|
18 |
+
protected function _construct()
|
19 |
+
{
|
20 |
+
//parent::_construct();
|
21 |
+
$this->_init('skyboxcore/logservice', 'service_id');
|
22 |
+
}
|
23 |
}
|
app/code/community/Skybox/Core/Model/Mysql4/Logservice/Collection.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Core
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Core
|
8 |
-
* @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Core_Model_Mysql4_Logservice_Collection
|
11 |
-
extends Mage_Core_Model_Mysql4_Collection_Abstract
|
12 |
-
{
|
13 |
-
|
14 |
-
protected function _construct()
|
15 |
-
{
|
16 |
-
$this->_init('skyboxcore/logservice', 'service_id');
|
17 |
-
}
|
18 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Core
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Core
|
8 |
+
* @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Core_Model_Mysql4_Logservice_Collection
|
11 |
+
extends Mage_Core_Model_Mysql4_Collection_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
protected function _construct()
|
15 |
+
{
|
16 |
+
$this->_init('skyboxcore/logservice', 'service_id');
|
17 |
+
}
|
18 |
}
|
app/code/community/Skybox/Core/Model/Session.php
CHANGED
@@ -1,30 +1,30 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Core
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Core
|
8 |
-
* @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
*
|
13 |
-
* Skybox transaction session namespace
|
14 |
-
*
|
15 |
-
* @author César Tapia M. <ctapia@skyworldint.com>
|
16 |
-
*/
|
17 |
-
class Skybox_Core_Model_Session extends Mage_Core_Model_Session_Abstract
|
18 |
-
{
|
19 |
-
public function __construct()
|
20 |
-
{
|
21 |
-
//$this->init('skybox');
|
22 |
-
//Mage::dispatchEvent('myapp_session_init', array('myapp_session' => $this));
|
23 |
-
|
24 |
-
$namespace = 'skyboxcore';
|
25 |
-
$namespace .= '_' . (Mage::app()->getStore()->getWebsite()->getCode());
|
26 |
-
|
27 |
-
$this->init($namespace);
|
28 |
-
Mage::dispatchEvent('skyboxcore_session_init', array('skyboxcore_session' => $this));
|
29 |
-
}
|
30 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Core
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Core
|
8 |
+
* @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
*
|
13 |
+
* Skybox transaction session namespace
|
14 |
+
*
|
15 |
+
* @author César Tapia M. <ctapia@skyworldint.com>
|
16 |
+
*/
|
17 |
+
class Skybox_Core_Model_Session extends Mage_Core_Model_Session_Abstract
|
18 |
+
{
|
19 |
+
public function __construct()
|
20 |
+
{
|
21 |
+
//$this->init('skybox');
|
22 |
+
//Mage::dispatchEvent('myapp_session_init', array('myapp_session' => $this));
|
23 |
+
|
24 |
+
$namespace = 'skyboxcore';
|
25 |
+
$namespace .= '_' . (Mage::app()->getStore()->getWebsite()->getCode());
|
26 |
+
|
27 |
+
$this->init($namespace);
|
28 |
+
Mage::dispatchEvent('skyboxcore_session_init', array('skyboxcore_session' => $this));
|
29 |
+
}
|
30 |
}
|
app/code/community/Skybox/Core/Model/Standard.php
CHANGED
@@ -1,292 +1,292 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Core
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Core
|
8 |
-
* @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Core_Model_Standard
|
11 |
-
{
|
12 |
-
/**
|
13 |
-
* Config instance
|
14 |
-
* @var Skybox_Core_Model_Config
|
15 |
-
*/
|
16 |
-
protected $_config = null;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Config Model Type
|
20 |
-
*
|
21 |
-
* @var string
|
22 |
-
*/
|
23 |
-
protected $_typeConfig = "skyboxcore/config";
|
24 |
-
|
25 |
-
/**
|
26 |
-
* API instance
|
27 |
-
* @var Skybox_Core_Model_Api_Restful
|
28 |
-
*/
|
29 |
-
protected $_api = null;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Api Model Type
|
33 |
-
*
|
34 |
-
* @var string
|
35 |
-
*/
|
36 |
-
protected $_apiType = 'skyboxcore/api_restful';
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Helper instance
|
40 |
-
* @var Skybox_International_Helper_Data
|
41 |
-
*/
|
42 |
-
protected $_help = null;
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Api Model Type
|
46 |
-
*
|
47 |
-
* @var string
|
48 |
-
*/
|
49 |
-
protected $_helpType = 'skyboxinternational/data';
|
50 |
-
|
51 |
-
/* @return Skybox_Core_Model_Config */
|
52 |
-
protected function _getConfig()
|
53 |
-
{
|
54 |
-
if (null === $this->_config)
|
55 |
-
$this->_config = Mage::getModel($this->_typeConfig);
|
56 |
-
return $this->_config;
|
57 |
-
}
|
58 |
-
|
59 |
-
/* @return Skybox_Core_Model_Api_Restful */
|
60 |
-
public function _getApi()
|
61 |
-
{
|
62 |
-
if (null === $this->_api) {
|
63 |
-
$this->_api = Mage::getModel($this->_apiType)->setConfigObject($this->_config);
|
64 |
-
}
|
65 |
-
return $this->_api;
|
66 |
-
}
|
67 |
-
|
68 |
-
/* @return Skybox_International_Helper_Data */
|
69 |
-
protected function _getHelper()
|
70 |
-
{
|
71 |
-
if (null === $this->_help) {
|
72 |
-
$this->_help = Mage::helper($this->_helpType);
|
73 |
-
}
|
74 |
-
return $this->_help;
|
75 |
-
}
|
76 |
-
|
77 |
-
public function __construct($params = array())
|
78 |
-
{
|
79 |
-
$this->_getConfig();
|
80 |
-
$this->_getApi();
|
81 |
-
}
|
82 |
-
|
83 |
-
public function getMerchant()
|
84 |
-
{
|
85 |
-
return $this->_getHelper()->getMerchantCode();
|
86 |
-
}
|
87 |
-
|
88 |
-
public function getMerchantKey()
|
89 |
-
{
|
90 |
-
return $this->_getHelper()->getMerchantKey();
|
91 |
-
}
|
92 |
-
|
93 |
-
public function getEnabledAddSumTaxToPrice()
|
94 |
-
{
|
95 |
-
return $this->_getHelper()->getEnabledAddSumTaxToPrice();
|
96 |
-
}
|
97 |
-
|
98 |
-
public function getWeightUnit()
|
99 |
-
{
|
100 |
-
return $this->_getHelper()->getWeightUnit();
|
101 |
-
}
|
102 |
-
|
103 |
-
public function getAuthorizedToken()
|
104 |
-
{
|
105 |
-
return $this->_api->getAuthorizedToken();
|
106 |
-
}
|
107 |
-
|
108 |
-
public function getGuidApi()
|
109 |
-
{
|
110 |
-
return $this->_api->getGuidApi();
|
111 |
-
}
|
112 |
-
|
113 |
-
public function getResponse()
|
114 |
-
{
|
115 |
-
return $this->_api->getResponseJson();
|
116 |
-
}
|
117 |
-
|
118 |
-
public function getParameter($paramName, $valueDefault = null)
|
119 |
-
{
|
120 |
-
try {
|
121 |
-
return $this->getResponse()->{$paramName};
|
122 |
-
} catch (Exception $e) {
|
123 |
-
return $valueDefault;
|
124 |
-
}
|
125 |
-
}
|
126 |
-
|
127 |
-
public function getLocationAllow()
|
128 |
-
{
|
129 |
-
//return $this->_api->getLocationAllow() == "1";
|
130 |
-
return $this->_api->getLocationAllow();
|
131 |
-
}
|
132 |
-
|
133 |
-
public function getStoreCode()
|
134 |
-
{
|
135 |
-
return $this->_api->getStoreCode();
|
136 |
-
}
|
137 |
-
|
138 |
-
public function getErrorAuthenticate()
|
139 |
-
{
|
140 |
-
return $this->_api->getErrorAuthenticate();
|
141 |
-
}
|
142 |
-
|
143 |
-
public function getHtmlTemplateBar()
|
144 |
-
{
|
145 |
-
return $this->_api->getHtmlTemplateBar();
|
146 |
-
}
|
147 |
-
|
148 |
-
public function getHtmlTemplateButton()
|
149 |
-
{
|
150 |
-
return $this->_api->getHtmlTemplateButton();
|
151 |
-
}
|
152 |
-
|
153 |
-
public function getHtmlTemplateButtonError()
|
154 |
-
{
|
155 |
-
return $this->_api->getHtmlTemplateButtonError();
|
156 |
-
}
|
157 |
-
|
158 |
-
public function HasError()
|
159 |
-
{
|
160 |
-
return $this->_api->HasError();
|
161 |
-
}
|
162 |
-
|
163 |
-
public function getStatusCode()
|
164 |
-
{
|
165 |
-
return $this->_api->getStatusCode();
|
166 |
-
}
|
167 |
-
|
168 |
-
public function getStatusMessage()
|
169 |
-
{
|
170 |
-
return $this->_api->getStatusMessage();
|
171 |
-
}
|
172 |
-
|
173 |
-
public function getCssVersion()
|
174 |
-
{
|
175 |
-
return$this->_api->getCssVersion();
|
176 |
-
}
|
177 |
-
|
178 |
-
/**
|
179 |
-
* Se invoca al servicio para generar Token de Seguridad
|
180 |
-
* @return Skybox_Core_Model_Standard
|
181 |
-
*/
|
182 |
-
public function AuthenticateService()
|
183 |
-
{
|
184 |
-
//$this->_getApi(); // Why? http://goo.gl/xYs9zM
|
185 |
-
Mage::log("AuthenticateService ", null, 'autenticate.log', true);
|
186 |
-
|
187 |
-
$successService = false;
|
188 |
-
$errorService = 1;
|
189 |
-
|
190 |
-
while (!$successService) {
|
191 |
-
$params = array(
|
192 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
193 |
-
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANTKEY => $this->getMerchantKey()
|
194 |
-
);
|
195 |
-
|
196 |
-
Mage::log('|AuthenticateService|' . json_encode($params));
|
197 |
-
|
198 |
-
$this->_api->CallService(Skybox_Core_Model_Config::SKYBOX_ACTION_AUTHENTICATE, $params);
|
199 |
-
|
200 |
-
//if ($this->_api->ErrorKeyInvalid() || $this->_api->ErrorIpNoAllow()) break;
|
201 |
-
//if (!($this->_api->ErrorService())) $successService = true;
|
202 |
-
if ($this->_api->ErrorMerchantKeyInvalid() || $this->_api->ErrorIpNoAllow()) break;
|
203 |
-
if (!($this->_api->ErrorServiceNotController())) $successService = true;
|
204 |
-
$errorService++;
|
205 |
-
if ($errorService > 3) break;
|
206 |
-
}
|
207 |
-
|
208 |
-
if (!$successService) {
|
209 |
-
//throw new Exception("Error Processing Request", 1);
|
210 |
-
//Mage::throwException('Error: al comunicarse con el servidor, si el error persiste comunicarse con su administrador');
|
211 |
-
}
|
212 |
-
|
213 |
-
return $this;
|
214 |
-
}
|
215 |
-
|
216 |
-
public function CallApiRest($action, $params)
|
217 |
-
{
|
218 |
-
|
219 |
-
$start = microtime(true);
|
220 |
-
|
221 |
-
Mage::log("CallApiRest ", null, 'standart.log', true);
|
222 |
-
|
223 |
-
$successService = false;
|
224 |
-
$errorService = 1;
|
225 |
-
$successAuthenticate = true;
|
226 |
-
try {
|
227 |
-
//$this->_getApi(); // Why? http://goo.gl/xYs9zM
|
228 |
-
$variable = $this->getAuthorizedToken();
|
229 |
-
if (empty($variable)) {
|
230 |
-
Mage::log("empty ", null, 'standart.log', true);
|
231 |
-
|
232 |
-
$this->AuthenticateService();
|
233 |
-
$params = $this->resetValueDefault($params);
|
234 |
-
$successAuthenticate = !$this->getErrorAuthenticate();
|
235 |
-
}
|
236 |
-
|
237 |
-
if ($successAuthenticate) {
|
238 |
-
Mage::log("successAuthenticate ", null, 'standart.log', true);
|
239 |
-
|
240 |
-
while (!$successService) {
|
241 |
-
Mage::log(" ---------------------------------------------");
|
242 |
-
Mage::log(" | Call | " . $action);
|
243 |
-
$this->_api->CallService($action, $params);
|
244 |
-
|
245 |
-
if ($this->_api->HasError()) {
|
246 |
-
Mage::log("HasError ", null, 'standart.log', true);
|
247 |
-
Mage::log(' | CallApiRest->Error | ');
|
248 |
-
$errorService++;
|
249 |
-
//if ($this->_api->ErrorTokenInvalid()) $this->AuthenticateService();
|
250 |
-
if ($this->_api->ErrorTokenExpired()) $this->AuthenticateService();
|
251 |
-
if ($errorService > 3) break;
|
252 |
-
$params = $this->resetValueDefault($params);
|
253 |
-
} else {
|
254 |
-
Mage::log(' | CallApiRest->Success | ');
|
255 |
-
$successService = true;
|
256 |
-
}
|
257 |
-
}
|
258 |
-
}
|
259 |
-
} catch (Exception $e) {
|
260 |
-
Mage::log(' | CallApiRest->Error | ' . $e->getMessage());
|
261 |
-
Mage::helper('skyboxcore/email')->sendException($e->getMessage());
|
262 |
-
$successService = false;
|
263 |
-
}
|
264 |
-
|
265 |
-
if (!$successService) {
|
266 |
-
Mage::log(' | Error Processing Request / CallApiRest | ' . $action);
|
267 |
-
//throw new Exception("Error Processing Request", 1);
|
268 |
-
//Mage::throwException('Error: al comunicarse con el servidor, si el error persiste comunicarse con su administrador');
|
269 |
-
//Mage::helper('skyboxcore/email')->sendAPIError($e->getMessage());
|
270 |
-
}
|
271 |
-
|
272 |
-
|
273 |
-
// $total_time = round(microtime(true)-$start, 4);
|
274 |
-
// Mage::log('Servicio generado ['.$action.']: '.$total_time.' segundos.', null, 'timer.log',true);
|
275 |
-
|
276 |
-
return $this;
|
277 |
-
}
|
278 |
-
|
279 |
-
/**
|
280 |
-
* Setea los valores por defecto
|
281 |
-
* @return array()
|
282 |
-
*/
|
283 |
-
protected function resetValueDefault($params)
|
284 |
-
{
|
285 |
-
foreach ($params as $key => $val) {
|
286 |
-
if ($key == Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN) $params[$key] = $this->_api->getAuthorizedToken();
|
287 |
-
if ($key == Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID) $params[$key] = $this->_api->getGuidApi();
|
288 |
-
}
|
289 |
-
|
290 |
-
return $params;
|
291 |
-
}
|
292 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Core
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Core
|
8 |
+
* @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Core_Model_Standard
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Config instance
|
14 |
+
* @var Skybox_Core_Model_Config
|
15 |
+
*/
|
16 |
+
protected $_config = null;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Config Model Type
|
20 |
+
*
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
+
protected $_typeConfig = "skyboxcore/config";
|
24 |
+
|
25 |
+
/**
|
26 |
+
* API instance
|
27 |
+
* @var Skybox_Core_Model_Api_Restful
|
28 |
+
*/
|
29 |
+
protected $_api = null;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Api Model Type
|
33 |
+
*
|
34 |
+
* @var string
|
35 |
+
*/
|
36 |
+
protected $_apiType = 'skyboxcore/api_restful';
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Helper instance
|
40 |
+
* @var Skybox_International_Helper_Data
|
41 |
+
*/
|
42 |
+
protected $_help = null;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Api Model Type
|
46 |
+
*
|
47 |
+
* @var string
|
48 |
+
*/
|
49 |
+
protected $_helpType = 'skyboxinternational/data';
|
50 |
+
|
51 |
+
/* @return Skybox_Core_Model_Config */
|
52 |
+
protected function _getConfig()
|
53 |
+
{
|
54 |
+
if (null === $this->_config)
|
55 |
+
$this->_config = Mage::getModel($this->_typeConfig);
|
56 |
+
return $this->_config;
|
57 |
+
}
|
58 |
+
|
59 |
+
/* @return Skybox_Core_Model_Api_Restful */
|
60 |
+
public function _getApi()
|
61 |
+
{
|
62 |
+
if (null === $this->_api) {
|
63 |
+
$this->_api = Mage::getModel($this->_apiType)->setConfigObject($this->_config);
|
64 |
+
}
|
65 |
+
return $this->_api;
|
66 |
+
}
|
67 |
+
|
68 |
+
/* @return Skybox_International_Helper_Data */
|
69 |
+
protected function _getHelper()
|
70 |
+
{
|
71 |
+
if (null === $this->_help) {
|
72 |
+
$this->_help = Mage::helper($this->_helpType);
|
73 |
+
}
|
74 |
+
return $this->_help;
|
75 |
+
}
|
76 |
+
|
77 |
+
public function __construct($params = array())
|
78 |
+
{
|
79 |
+
$this->_getConfig();
|
80 |
+
$this->_getApi();
|
81 |
+
}
|
82 |
+
|
83 |
+
public function getMerchant()
|
84 |
+
{
|
85 |
+
return $this->_getHelper()->getMerchantCode();
|
86 |
+
}
|
87 |
+
|
88 |
+
public function getMerchantKey()
|
89 |
+
{
|
90 |
+
return $this->_getHelper()->getMerchantKey();
|
91 |
+
}
|
92 |
+
|
93 |
+
public function getEnabledAddSumTaxToPrice()
|
94 |
+
{
|
95 |
+
return $this->_getHelper()->getEnabledAddSumTaxToPrice();
|
96 |
+
}
|
97 |
+
|
98 |
+
public function getWeightUnit()
|
99 |
+
{
|
100 |
+
return $this->_getHelper()->getWeightUnit();
|
101 |
+
}
|
102 |
+
|
103 |
+
public function getAuthorizedToken()
|
104 |
+
{
|
105 |
+
return $this->_api->getAuthorizedToken();
|
106 |
+
}
|
107 |
+
|
108 |
+
public function getGuidApi()
|
109 |
+
{
|
110 |
+
return $this->_api->getGuidApi();
|
111 |
+
}
|
112 |
+
|
113 |
+
public function getResponse()
|
114 |
+
{
|
115 |
+
return $this->_api->getResponseJson();
|
116 |
+
}
|
117 |
+
|
118 |
+
public function getParameter($paramName, $valueDefault = null)
|
119 |
+
{
|
120 |
+
try {
|
121 |
+
return $this->getResponse()->{$paramName};
|
122 |
+
} catch (Exception $e) {
|
123 |
+
return $valueDefault;
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
public function getLocationAllow()
|
128 |
+
{
|
129 |
+
//return $this->_api->getLocationAllow() == "1";
|
130 |
+
return $this->_api->getLocationAllow();
|
131 |
+
}
|
132 |
+
|
133 |
+
public function getStoreCode()
|
134 |
+
{
|
135 |
+
return $this->_api->getStoreCode();
|
136 |
+
}
|
137 |
+
|
138 |
+
public function getErrorAuthenticate()
|
139 |
+
{
|
140 |
+
return $this->_api->getErrorAuthenticate();
|
141 |
+
}
|
142 |
+
|
143 |
+
public function getHtmlTemplateBar()
|
144 |
+
{
|
145 |
+
return $this->_api->getHtmlTemplateBar();
|
146 |
+
}
|
147 |
+
|
148 |
+
public function getHtmlTemplateButton()
|
149 |
+
{
|
150 |
+
return $this->_api->getHtmlTemplateButton();
|
151 |
+
}
|
152 |
+
|
153 |
+
public function getHtmlTemplateButtonError()
|
154 |
+
{
|
155 |
+
return $this->_api->getHtmlTemplateButtonError();
|
156 |
+
}
|
157 |
+
|
158 |
+
public function HasError()
|
159 |
+
{
|
160 |
+
return $this->_api->HasError();
|
161 |
+
}
|
162 |
+
|
163 |
+
public function getStatusCode()
|
164 |
+
{
|
165 |
+
return $this->_api->getStatusCode();
|
166 |
+
}
|
167 |
+
|
168 |
+
public function getStatusMessage()
|
169 |
+
{
|
170 |
+
return $this->_api->getStatusMessage();
|
171 |
+
}
|
172 |
+
|
173 |
+
public function getCssVersion()
|
174 |
+
{
|
175 |
+
return$this->_api->getCssVersion();
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Se invoca al servicio para generar Token de Seguridad
|
180 |
+
* @return Skybox_Core_Model_Standard
|
181 |
+
*/
|
182 |
+
public function AuthenticateService()
|
183 |
+
{
|
184 |
+
//$this->_getApi(); // Why? http://goo.gl/xYs9zM
|
185 |
+
Mage::log("AuthenticateService ", null, 'autenticate.log', true);
|
186 |
+
|
187 |
+
$successService = false;
|
188 |
+
$errorService = 1;
|
189 |
+
|
190 |
+
while (!$successService) {
|
191 |
+
$params = array(
|
192 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
193 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANTKEY => $this->getMerchantKey()
|
194 |
+
);
|
195 |
+
|
196 |
+
Mage::log('|AuthenticateService|' . json_encode($params));
|
197 |
+
|
198 |
+
$this->_api->CallService(Skybox_Core_Model_Config::SKYBOX_ACTION_AUTHENTICATE, $params);
|
199 |
+
|
200 |
+
//if ($this->_api->ErrorKeyInvalid() || $this->_api->ErrorIpNoAllow()) break;
|
201 |
+
//if (!($this->_api->ErrorService())) $successService = true;
|
202 |
+
if ($this->_api->ErrorMerchantKeyInvalid() || $this->_api->ErrorIpNoAllow()) break;
|
203 |
+
if (!($this->_api->ErrorServiceNotController())) $successService = true;
|
204 |
+
$errorService++;
|
205 |
+
if ($errorService > 3) break;
|
206 |
+
}
|
207 |
+
|
208 |
+
if (!$successService) {
|
209 |
+
//throw new Exception("Error Processing Request", 1);
|
210 |
+
//Mage::throwException('Error: al comunicarse con el servidor, si el error persiste comunicarse con su administrador');
|
211 |
+
}
|
212 |
+
|
213 |
+
return $this;
|
214 |
+
}
|
215 |
+
|
216 |
+
public function CallApiRest($action, $params)
|
217 |
+
{
|
218 |
+
|
219 |
+
$start = microtime(true);
|
220 |
+
|
221 |
+
Mage::log("CallApiRest ", null, 'standart.log', true);
|
222 |
+
|
223 |
+
$successService = false;
|
224 |
+
$errorService = 1;
|
225 |
+
$successAuthenticate = true;
|
226 |
+
try {
|
227 |
+
//$this->_getApi(); // Why? http://goo.gl/xYs9zM
|
228 |
+
$variable = $this->getAuthorizedToken();
|
229 |
+
if (empty($variable)) {
|
230 |
+
Mage::log("empty ", null, 'standart.log', true);
|
231 |
+
|
232 |
+
$this->AuthenticateService();
|
233 |
+
$params = $this->resetValueDefault($params);
|
234 |
+
$successAuthenticate = !$this->getErrorAuthenticate();
|
235 |
+
}
|
236 |
+
|
237 |
+
if ($successAuthenticate) {
|
238 |
+
Mage::log("successAuthenticate ", null, 'standart.log', true);
|
239 |
+
|
240 |
+
while (!$successService) {
|
241 |
+
Mage::log(" ---------------------------------------------");
|
242 |
+
Mage::log(" | Call | " . $action);
|
243 |
+
$this->_api->CallService($action, $params);
|
244 |
+
|
245 |
+
if ($this->_api->HasError()) {
|
246 |
+
Mage::log("HasError ", null, 'standart.log', true);
|
247 |
+
Mage::log(' | CallApiRest->Error | ');
|
248 |
+
$errorService++;
|
249 |
+
//if ($this->_api->ErrorTokenInvalid()) $this->AuthenticateService();
|
250 |
+
if ($this->_api->ErrorTokenExpired()) $this->AuthenticateService();
|
251 |
+
if ($errorService > 3) break;
|
252 |
+
$params = $this->resetValueDefault($params);
|
253 |
+
} else {
|
254 |
+
Mage::log(' | CallApiRest->Success | ');
|
255 |
+
$successService = true;
|
256 |
+
}
|
257 |
+
}
|
258 |
+
}
|
259 |
+
} catch (Exception $e) {
|
260 |
+
Mage::log(' | CallApiRest->Error | ' . $e->getMessage());
|
261 |
+
Mage::helper('skyboxcore/email')->sendException($e->getMessage());
|
262 |
+
$successService = false;
|
263 |
+
}
|
264 |
+
|
265 |
+
if (!$successService) {
|
266 |
+
Mage::log(' | Error Processing Request / CallApiRest | ' . $action);
|
267 |
+
//throw new Exception("Error Processing Request", 1);
|
268 |
+
//Mage::throwException('Error: al comunicarse con el servidor, si el error persiste comunicarse con su administrador');
|
269 |
+
//Mage::helper('skyboxcore/email')->sendAPIError($e->getMessage());
|
270 |
+
}
|
271 |
+
|
272 |
+
|
273 |
+
// $total_time = round(microtime(true)-$start, 4);
|
274 |
+
// Mage::log('Servicio generado ['.$action.']: '.$total_time.' segundos.', null, 'timer.log',true);
|
275 |
+
|
276 |
+
return $this;
|
277 |
+
}
|
278 |
+
|
279 |
+
/**
|
280 |
+
* Setea los valores por defecto
|
281 |
+
* @return array()
|
282 |
+
*/
|
283 |
+
protected function resetValueDefault($params)
|
284 |
+
{
|
285 |
+
foreach ($params as $key => $val) {
|
286 |
+
if ($key == Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN) $params[$key] = $this->_api->getAuthorizedToken();
|
287 |
+
if ($key == Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID) $params[$key] = $this->_api->getGuidApi();
|
288 |
+
}
|
289 |
+
|
290 |
+
return $params;
|
291 |
+
}
|
292 |
+
}
|
app/code/community/Skybox/Core/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Skybox_Core>
|
5 |
-
<version>1.2.
|
6 |
<codePool>community</codePool>
|
7 |
</Skybox_Core>
|
8 |
</modules>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Skybox_Core>
|
5 |
+
<version>1.2.9</version>
|
6 |
<codePool>community</codePool>
|
7 |
</Skybox_Core>
|
8 |
</modules>
|
app/code/community/Skybox/Core/sql/skyboxcore_setup/mysql4-install-0.1.0.php
CHANGED
@@ -1,67 +1,67 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
$installer = $this;
|
4 |
-
$installer->startSetup();
|
5 |
-
|
6 |
-
$installer->run("
|
7 |
-
--DROP TABLE IF EXISTS {$this->getTable('skybox_log_service')};
|
8 |
-
|
9 |
-
CREATE TABLE {$this->getTable('skybox_log_service')} (
|
10 |
-
`service_id` int(11) NOT NULL auto_increment,
|
11 |
-
`action` text NOT NULl,
|
12 |
-
`request` text NOT NULl,
|
13 |
-
`response` text NULL,
|
14 |
-
`timestamp_request` timestamp NOT NULL default CURRENT_TIMESTAMP,
|
15 |
-
`timestamp_response` timestamp NULL
|
16 |
-
PRIMARY KEY (`service_id`)
|
17 |
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
18 |
-
");
|
19 |
-
|
20 |
-
$installer->endSetup();
|
21 |
-
|
22 |
-
echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";
|
23 |
-
*/
|
24 |
-
|
25 |
-
$installer = $this;
|
26 |
-
$installer->startSetup();
|
27 |
-
|
28 |
-
//$table = $installer->getConnection()
|
29 |
-
// //->newTable($installer->getTable('skyboxcore/skybox_log_service'))
|
30 |
-
// ->newTable($installer->getTable('skybox_log_service'))
|
31 |
-
// ->addColumn('service_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
32 |
-
// 'identity' => true,
|
33 |
-
// 'unsigned' => true,
|
34 |
-
// 'nullable' => false,
|
35 |
-
// 'primary' => true,
|
36 |
-
// ), 'Service Id')
|
37 |
-
// ->addColumn('action', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
38 |
-
// 'nullable' => false,
|
39 |
-
// ), 'Action')
|
40 |
-
// ->addColumn('request', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
41 |
-
// 'request' => false,
|
42 |
-
// ), 'Request')
|
43 |
-
// ->addColumn('response', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
44 |
-
// 'request' => false,
|
45 |
-
// ), 'Response')
|
46 |
-
// ->addColumn('timestamp_request', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
47 |
-
// 'request' => false,
|
48 |
-
// ), 'Timestamp Request')
|
49 |
-
// ->addColumn('timestamp_response', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
50 |
-
// 'request' => false,
|
51 |
-
// ), 'Timestamp Response');
|
52 |
-
//$installer->getConnection()->createTable($table);
|
53 |
-
|
54 |
-
$installer->run("
|
55 |
-
DROP TABLE IF EXISTS `{$this->getTable('skybox_log_service')}`;
|
56 |
-
CREATE TABLE `skybox_log_service` (
|
57 |
-
`service_id` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Service Id' ,
|
58 |
-
`action` TEXT NOT NULL COMMENT 'Action' ,
|
59 |
-
`request` TEXT NULL COMMENT 'Request' ,
|
60 |
-
`response` TEXT NULL COMMENT 'Response' ,
|
61 |
-
`timestamp_request` TIMESTAMP NULL DEFAULT NULL COMMENT 'Timestamp Request' ,
|
62 |
-
`timestamp_response` TIMESTAMP NULL DEFAULT NULL COMMENT 'Timestamp Response' ,
|
63 |
-
PRIMARY KEY (`service_id`)
|
64 |
-
)
|
65 |
-
COMMENT='skybox_log_service' ENGINE=INNODB CHARSET=utf8 COLLATE=utf8_general_ci;
|
66 |
-
");
|
67 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
$installer = $this;
|
4 |
+
$installer->startSetup();
|
5 |
+
|
6 |
+
$installer->run("
|
7 |
+
--DROP TABLE IF EXISTS {$this->getTable('skybox_log_service')};
|
8 |
+
|
9 |
+
CREATE TABLE {$this->getTable('skybox_log_service')} (
|
10 |
+
`service_id` int(11) NOT NULL auto_increment,
|
11 |
+
`action` text NOT NULl,
|
12 |
+
`request` text NOT NULl,
|
13 |
+
`response` text NULL,
|
14 |
+
`timestamp_request` timestamp NOT NULL default CURRENT_TIMESTAMP,
|
15 |
+
`timestamp_response` timestamp NULL
|
16 |
+
PRIMARY KEY (`service_id`)
|
17 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
18 |
+
");
|
19 |
+
|
20 |
+
$installer->endSetup();
|
21 |
+
|
22 |
+
echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";
|
23 |
+
*/
|
24 |
+
|
25 |
+
$installer = $this;
|
26 |
+
$installer->startSetup();
|
27 |
+
|
28 |
+
//$table = $installer->getConnection()
|
29 |
+
// //->newTable($installer->getTable('skyboxcore/skybox_log_service'))
|
30 |
+
// ->newTable($installer->getTable('skybox_log_service'))
|
31 |
+
// ->addColumn('service_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
32 |
+
// 'identity' => true,
|
33 |
+
// 'unsigned' => true,
|
34 |
+
// 'nullable' => false,
|
35 |
+
// 'primary' => true,
|
36 |
+
// ), 'Service Id')
|
37 |
+
// ->addColumn('action', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
38 |
+
// 'nullable' => false,
|
39 |
+
// ), 'Action')
|
40 |
+
// ->addColumn('request', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
41 |
+
// 'request' => false,
|
42 |
+
// ), 'Request')
|
43 |
+
// ->addColumn('response', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
44 |
+
// 'request' => false,
|
45 |
+
// ), 'Response')
|
46 |
+
// ->addColumn('timestamp_request', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
47 |
+
// 'request' => false,
|
48 |
+
// ), 'Timestamp Request')
|
49 |
+
// ->addColumn('timestamp_response', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
50 |
+
// 'request' => false,
|
51 |
+
// ), 'Timestamp Response');
|
52 |
+
//$installer->getConnection()->createTable($table);
|
53 |
+
|
54 |
+
$installer->run("
|
55 |
+
DROP TABLE IF EXISTS `{$this->getTable('skybox_log_service')}`;
|
56 |
+
CREATE TABLE `skybox_log_service` (
|
57 |
+
`service_id` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Service Id' ,
|
58 |
+
`action` TEXT NOT NULL COMMENT 'Action' ,
|
59 |
+
`request` TEXT NULL COMMENT 'Request' ,
|
60 |
+
`response` TEXT NULL COMMENT 'Response' ,
|
61 |
+
`timestamp_request` TIMESTAMP NULL DEFAULT NULL COMMENT 'Timestamp Request' ,
|
62 |
+
`timestamp_response` TIMESTAMP NULL DEFAULT NULL COMMENT 'Timestamp Response' ,
|
63 |
+
PRIMARY KEY (`service_id`)
|
64 |
+
)
|
65 |
+
COMMENT='skybox_log_service' ENGINE=INNODB CHARSET=utf8 COLLATE=utf8_general_ci;
|
66 |
+
");
|
67 |
+
$installer->endSetup();
|
app/code/community/Skybox/International/Helper/Data.php
CHANGED
@@ -1,78 +1,78 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox International
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_International
|
8 |
-
* @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_International_Helper_Data extends Mage_Core_Helper_Abstract
|
11 |
-
{
|
12 |
-
public function getMerchantCode()
|
13 |
-
{
|
14 |
-
return Mage::getStoreConfig('skyboxinternational/skyboxsettings/merchantcode', Mage::app()->getStore());
|
15 |
-
}
|
16 |
-
|
17 |
-
public function getMerchantKey()
|
18 |
-
{
|
19 |
-
return Mage::getStoreConfig('skyboxinternational/skyboxsettings/merchantkey', Mage::app()->getStore());
|
20 |
-
}
|
21 |
-
|
22 |
-
public function getWeightUnit()
|
23 |
-
{
|
24 |
-
return Mage::getStoreConfig('skyboxinternational/skyboxsettings/weigthunitproduct', Mage::app()->getStore());
|
25 |
-
}
|
26 |
-
|
27 |
-
public function getActive()
|
28 |
-
{
|
29 |
-
// return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
|
30 |
-
return Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
31 |
-
}
|
32 |
-
|
33 |
-
public function getSkyboxLog()
|
34 |
-
{
|
35 |
-
return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxlog', Mage::app()->getStore());
|
36 |
-
}
|
37 |
-
|
38 |
-
public function getSkyboxEmail()
|
39 |
-
{
|
40 |
-
return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxemail', Mage::app()->getStore());
|
41 |
-
}
|
42 |
-
|
43 |
-
public function getSkyboxIntegration()
|
44 |
-
{
|
45 |
-
return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxintegration', Mage::app()->getStore());
|
46 |
-
}
|
47 |
-
|
48 |
-
public function getSkyboxUrlAPI()
|
49 |
-
{
|
50 |
-
return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxurlapi', Mage::app()->getStore());
|
51 |
-
}
|
52 |
-
|
53 |
-
public function getSkyboxUrlMain()
|
54 |
-
{
|
55 |
-
return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxurlmain', Mage::app()->getStore());
|
56 |
-
}
|
57 |
-
|
58 |
-
public function getEnabledAddSumTaxToPrice()
|
59 |
-
{
|
60 |
-
return Mage::getStoreConfig('skyboxinternational/skyboxproduct/skyboxaddtaxtopriceenable', Mage::app()->getStore());
|
61 |
-
}
|
62 |
-
|
63 |
-
public function getStoreId()
|
64 |
-
{
|
65 |
-
//return $this->helper('core')->getStoreId();
|
66 |
-
return Mage::app()->getStore()->getId();
|
67 |
-
}
|
68 |
-
|
69 |
-
public function getCartId()
|
70 |
-
{
|
71 |
-
return Mage::getSingleton('checkout/session')->getQuoteId();
|
72 |
-
}
|
73 |
-
|
74 |
-
public function getCssVersion()
|
75 |
-
{
|
76 |
-
return Mage::getModel('skyboxcatalog/api_product')->getCssVersion();
|
77 |
-
}
|
78 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox International
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_International
|
8 |
+
* @copyright Copyright (c) 2014 SkyBOX Checkout, Inc. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_International_Helper_Data extends Mage_Core_Helper_Abstract
|
11 |
+
{
|
12 |
+
public function getMerchantCode()
|
13 |
+
{
|
14 |
+
return Mage::getStoreConfig('skyboxinternational/skyboxsettings/merchantcode', Mage::app()->getStore());
|
15 |
+
}
|
16 |
+
|
17 |
+
public function getMerchantKey()
|
18 |
+
{
|
19 |
+
return Mage::getStoreConfig('skyboxinternational/skyboxsettings/merchantkey', Mage::app()->getStore());
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getWeightUnit()
|
23 |
+
{
|
24 |
+
return Mage::getStoreConfig('skyboxinternational/skyboxsettings/weigthunitproduct', Mage::app()->getStore());
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getActive()
|
28 |
+
{
|
29 |
+
// return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
|
30 |
+
return Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
31 |
+
}
|
32 |
+
|
33 |
+
public function getSkyboxLog()
|
34 |
+
{
|
35 |
+
return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxlog', Mage::app()->getStore());
|
36 |
+
}
|
37 |
+
|
38 |
+
public function getSkyboxEmail()
|
39 |
+
{
|
40 |
+
return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxemail', Mage::app()->getStore());
|
41 |
+
}
|
42 |
+
|
43 |
+
public function getSkyboxIntegration()
|
44 |
+
{
|
45 |
+
return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxintegration', Mage::app()->getStore());
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getSkyboxUrlAPI()
|
49 |
+
{
|
50 |
+
return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxurlapi', Mage::app()->getStore());
|
51 |
+
}
|
52 |
+
|
53 |
+
public function getSkyboxUrlMain()
|
54 |
+
{
|
55 |
+
return Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxurlmain', Mage::app()->getStore());
|
56 |
+
}
|
57 |
+
|
58 |
+
public function getEnabledAddSumTaxToPrice()
|
59 |
+
{
|
60 |
+
return Mage::getStoreConfig('skyboxinternational/skyboxproduct/skyboxaddtaxtopriceenable', Mage::app()->getStore());
|
61 |
+
}
|
62 |
+
|
63 |
+
public function getStoreId()
|
64 |
+
{
|
65 |
+
//return $this->helper('core')->getStoreId();
|
66 |
+
return Mage::app()->getStore()->getId();
|
67 |
+
}
|
68 |
+
|
69 |
+
public function getCartId()
|
70 |
+
{
|
71 |
+
return Mage::getSingleton('checkout/session')->getQuoteId();
|
72 |
+
}
|
73 |
+
|
74 |
+
public function getCssVersion()
|
75 |
+
{
|
76 |
+
return Mage::getModel('skyboxcatalog/api_product')->getCssVersion();
|
77 |
+
}
|
78 |
}
|
app/code/community/Skybox/International/Model/Config.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Skybox International
|
4 |
-
*
|
5 |
-
* @category Skybox
|
6 |
-
* @package Skybox_International
|
7 |
-
* @subpackage Skybox_International_Model
|
8 |
-
* @copyright Copyright (c) 2014 SkyBOX Checkout Inc. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
|
11 |
-
class Skybox_International_Model_Config extends Mage_Core_Model_Abstract
|
12 |
-
{
|
13 |
-
public function __construct($params = array())
|
14 |
-
{
|
15 |
-
}
|
16 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Skybox International
|
4 |
+
*
|
5 |
+
* @category Skybox
|
6 |
+
* @package Skybox_International
|
7 |
+
* @subpackage Skybox_International_Model
|
8 |
+
* @copyright Copyright (c) 2014 SkyBOX Checkout Inc. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Skybox_International_Model_Config extends Mage_Core_Model_Abstract
|
12 |
+
{
|
13 |
+
public function __construct($params = array())
|
14 |
+
{
|
15 |
+
}
|
16 |
}
|
app/code/community/Skybox/International/Model/StoreType.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Skybox_International_Model_StoreType
|
4 |
-
{
|
5 |
-
public function toOptionArray()
|
6 |
-
{
|
7 |
-
return array(
|
8 |
-
array('value' => '1', 'label' => "Store Type 1"),
|
9 |
-
array('value' => '3', 'label' => "Store Type 3"),
|
10 |
-
);
|
11 |
-
}
|
12 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Skybox_International_Model_StoreType
|
4 |
+
{
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
return array(
|
8 |
+
array('value' => '1', 'label' => "Store Type 1"),
|
9 |
+
array('value' => '3', 'label' => "Store Type 3"),
|
10 |
+
);
|
11 |
+
}
|
12 |
+
}
|
app/code/community/Skybox/International/etc/adminhtml.xml
CHANGED
@@ -1,39 +1,39 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<config>
|
3 |
-
<menu>
|
4 |
-
<skyboxinternational translate="title" module="skyboxinternational">
|
5 |
-
<title>Skybox Checkout</title>
|
6 |
-
<sort_order>300</sort_order>
|
7 |
-
<children>
|
8 |
-
<skyboxinternational translate="title" module="skyboxinternational">
|
9 |
-
<title>Skybox Settings</title>
|
10 |
-
<sort_order>1</sort_order>
|
11 |
-
<action>adminhtml/system_config/edit/section/skyboxinternational</action>
|
12 |
-
</skyboxinternational>
|
13 |
-
</children>
|
14 |
-
</skyboxinternational>
|
15 |
-
</menu>
|
16 |
-
<acl>
|
17 |
-
<resources>
|
18 |
-
<all>
|
19 |
-
<title>Allow Everything</title>
|
20 |
-
</all>
|
21 |
-
<admin>
|
22 |
-
<children>
|
23 |
-
<system>
|
24 |
-
<children>
|
25 |
-
<config>
|
26 |
-
<children>
|
27 |
-
<skyboxinternational translate="title" module="skyboxinternational">
|
28 |
-
<title>Skybox Checkout</title>
|
29 |
-
<sort_order>300</sort_order>
|
30 |
-
</skyboxinternational>
|
31 |
-
</children>
|
32 |
-
</config>
|
33 |
-
</children>
|
34 |
-
</system>
|
35 |
-
</children>
|
36 |
-
</admin>
|
37 |
-
</resources>
|
38 |
-
</acl>
|
39 |
-
</config>
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<menu>
|
4 |
+
<skyboxinternational translate="title" module="skyboxinternational">
|
5 |
+
<title>Skybox Checkout</title>
|
6 |
+
<sort_order>300</sort_order>
|
7 |
+
<children>
|
8 |
+
<skyboxinternational translate="title" module="skyboxinternational">
|
9 |
+
<title>Skybox Settings</title>
|
10 |
+
<sort_order>1</sort_order>
|
11 |
+
<action>adminhtml/system_config/edit/section/skyboxinternational</action>
|
12 |
+
</skyboxinternational>
|
13 |
+
</children>
|
14 |
+
</skyboxinternational>
|
15 |
+
</menu>
|
16 |
+
<acl>
|
17 |
+
<resources>
|
18 |
+
<all>
|
19 |
+
<title>Allow Everything</title>
|
20 |
+
</all>
|
21 |
+
<admin>
|
22 |
+
<children>
|
23 |
+
<system>
|
24 |
+
<children>
|
25 |
+
<config>
|
26 |
+
<children>
|
27 |
+
<skyboxinternational translate="title" module="skyboxinternational">
|
28 |
+
<title>Skybox Checkout</title>
|
29 |
+
<sort_order>300</sort_order>
|
30 |
+
</skyboxinternational>
|
31 |
+
</children>
|
32 |
+
</config>
|
33 |
+
</children>
|
34 |
+
</system>
|
35 |
+
</children>
|
36 |
+
</admin>
|
37 |
+
</resources>
|
38 |
+
</acl>
|
39 |
+
</config>
|
app/code/community/Skybox/International/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Skybox_International>
|
5 |
-
<version>1.2.
|
6 |
<codePool>community</codePool>
|
7 |
</Skybox_International>
|
8 |
</modules>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Skybox_International>
|
5 |
+
<version>1.2.9</version>
|
6 |
<codePool>community</codePool>
|
7 |
</Skybox_International>
|
8 |
</modules>
|
app/code/community/Skybox/International/etc/system.xml
CHANGED
@@ -1,136 +1,136 @@
|
|
1 |
-
<config>
|
2 |
-
<tabs>
|
3 |
-
<skyboxinternational translate="label" module="skyboxinternational">
|
4 |
-
<label>Skybox Checkout</label>
|
5 |
-
<sort_order>100</sort_order>
|
6 |
-
</skyboxinternational>
|
7 |
-
</tabs>
|
8 |
-
<sections>
|
9 |
-
<skyboxinternational translate="label" module="skyboxinternational">
|
10 |
-
<label>Skybox Checkout Settings</label>
|
11 |
-
<tab>skyboxinternational</tab>
|
12 |
-
<sort_order>1000</sort_order>
|
13 |
-
<show_in_default>1</show_in_default>
|
14 |
-
<show_in_website>1</show_in_website>
|
15 |
-
<show_in_store>1</show_in_store>
|
16 |
-
<groups>
|
17 |
-
<skyboxsettings translate="label" module="skyboxinternational">
|
18 |
-
<label>Merchant Settings</label>
|
19 |
-
<frontend_type>text</frontend_type>
|
20 |
-
<sort_order>10</sort_order>
|
21 |
-
<show_in_default>1</show_in_default>
|
22 |
-
<show_in_website>1</show_in_website>
|
23 |
-
<show_in_store>1</show_in_store>
|
24 |
-
<fields>
|
25 |
-
<skyboxactive translate="label">
|
26 |
-
<label>Enabled</label>
|
27 |
-
<frontend_type>select</frontend_type>
|
28 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
29 |
-
<sort_order>1</sort_order>
|
30 |
-
<show_in_default>1</show_in_default>
|
31 |
-
<show_in_website>1</show_in_website>
|
32 |
-
<show_in_store>1</show_in_store>
|
33 |
-
</skyboxactive>
|
34 |
-
<merchantcode translate="label">
|
35 |
-
<label>Merchant Id:</label>
|
36 |
-
<comment>Code Merchant by Skybox Checkout International</comment>
|
37 |
-
<frontend_type>text</frontend_type>
|
38 |
-
<sort_order>2</sort_order>
|
39 |
-
<show_in_default>1</show_in_default>
|
40 |
-
<show_in_website>1</show_in_website>
|
41 |
-
<show_in_store>1</show_in_store>
|
42 |
-
</merchantcode>
|
43 |
-
<merchantkey translate="label">
|
44 |
-
<label>Merchant Key:</label>
|
45 |
-
<comment>Key Merchant by Skybox Checkout International</comment>
|
46 |
-
<frontend_type>text</frontend_type>
|
47 |
-
<sort_order>3</sort_order>
|
48 |
-
<show_in_default>1</show_in_default>
|
49 |
-
<show_in_website>1</show_in_website>
|
50 |
-
<show_in_store>1</show_in_store>
|
51 |
-
</merchantkey>
|
52 |
-
<weigthunitproduct translate="label">
|
53 |
-
<label>Weight Unit:</label>
|
54 |
-
<comment>Source model provider Magento's unit of measure values</comment>
|
55 |
-
<frontend_type>select</frontend_type>
|
56 |
-
<sort_order>4</sort_order>
|
57 |
-
<show_in_default>1</show_in_default>
|
58 |
-
<show_in_website>1</show_in_website>
|
59 |
-
<show_in_store>1</show_in_store>
|
60 |
-
<source_model>usa/shipping_carrier_ups_source_unitofmeasure</source_model>
|
61 |
-
</weigthunitproduct>
|
62 |
-
<skyboxlog translate="label">
|
63 |
-
<label>Save API Responses</label>
|
64 |
-
<frontend_type>select</frontend_type>
|
65 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
66 |
-
<sort_order>5</sort_order>
|
67 |
-
<show_in_default>1</show_in_default>
|
68 |
-
<show_in_website>1</show_in_website>
|
69 |
-
<show_in_store>1</show_in_store>
|
70 |
-
</skyboxlog>
|
71 |
-
<skyboxemail translate="label">
|
72 |
-
<label>SkyBox Email:</label>
|
73 |
-
<comment>SkyBox Email</comment>
|
74 |
-
<frontend_type>text</frontend_type>
|
75 |
-
<validate>validate-email</validate>
|
76 |
-
<sort_order>6</sort_order>
|
77 |
-
<show_in_default>1</show_in_default>
|
78 |
-
<show_in_website>1</show_in_website>
|
79 |
-
<show_in_store>1</show_in_store>
|
80 |
-
</skyboxemail>
|
81 |
-
<skyboxintegration translate="label">
|
82 |
-
<label>SkyBox Itegration:</label>
|
83 |
-
<comment>SkyBox Integration</comment>
|
84 |
-
<frontend_type>select</frontend_type>
|
85 |
-
<!--<source_model>adminhtml/system_config_source_yesno</source_model>-->
|
86 |
-
<source_model>Skybox_International_Model_StoreType</source_model>
|
87 |
-
<!--<frontend_type>text</frontend_type>-->
|
88 |
-
<sort_order>7</sort_order>
|
89 |
-
<show_in_default>1</show_in_default>
|
90 |
-
<show_in_website>1</show_in_website>
|
91 |
-
<show_in_store>1</show_in_store>
|
92 |
-
</skyboxintegration>
|
93 |
-
<skyboxurlapi translate="label">
|
94 |
-
<label>SkyBox Url API:</label>
|
95 |
-
<comment>Url API By Skybox Checkout International</comment>
|
96 |
-
<frontend_type>text</frontend_type>
|
97 |
-
<sort_order>8</sort_order>
|
98 |
-
<show_in_default>1</show_in_default>
|
99 |
-
<show_in_website>1</show_in_website>
|
100 |
-
<show_in_store>1</show_in_store>
|
101 |
-
</skyboxurlapi>
|
102 |
-
<skyboxurlmain translate="label">
|
103 |
-
<label>SkyBox Url Client:</label>
|
104 |
-
<comment>Url Client By Skybox Checkout International</comment>
|
105 |
-
<frontend_type>text</frontend_type>
|
106 |
-
<sort_order>9</sort_order>
|
107 |
-
<show_in_default>1</show_in_default>
|
108 |
-
<show_in_website>1</show_in_website>
|
109 |
-
<show_in_store>1</show_in_store>
|
110 |
-
</skyboxurlmain>
|
111 |
-
</fields>
|
112 |
-
</skyboxsettings>
|
113 |
-
<skyboxproduct translate="label" module="skyboxinternational">
|
114 |
-
<label>Tax Product</label>
|
115 |
-
<frontend_type>text</frontend_type>
|
116 |
-
<!--<comment>Tax + Price product</comment>-->
|
117 |
-
<sort_order>20</sort_order>
|
118 |
-
<show_in_default>1</show_in_default>
|
119 |
-
<show_in_website>1</show_in_website>
|
120 |
-
<show_in_store>1</show_in_store>
|
121 |
-
<fields>
|
122 |
-
<skyboxaddtaxtopriceenable translate="label">
|
123 |
-
<label>Add Tax to Price</label>
|
124 |
-
<frontend_type>select</frontend_type>
|
125 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
126 |
-
<sort_order>1</sort_order>
|
127 |
-
<show_in_default>1</show_in_default>
|
128 |
-
<show_in_website>1</show_in_website>
|
129 |
-
<show_in_store>1</show_in_store>
|
130 |
-
</skyboxaddtaxtopriceenable>
|
131 |
-
</fields>
|
132 |
-
</skyboxproduct>
|
133 |
-
</groups>
|
134 |
-
</skyboxinternational>
|
135 |
-
</sections>
|
136 |
</config>
|
1 |
+
<config>
|
2 |
+
<tabs>
|
3 |
+
<skyboxinternational translate="label" module="skyboxinternational">
|
4 |
+
<label>Skybox Checkout</label>
|
5 |
+
<sort_order>100</sort_order>
|
6 |
+
</skyboxinternational>
|
7 |
+
</tabs>
|
8 |
+
<sections>
|
9 |
+
<skyboxinternational translate="label" module="skyboxinternational">
|
10 |
+
<label>Skybox Checkout Settings</label>
|
11 |
+
<tab>skyboxinternational</tab>
|
12 |
+
<sort_order>1000</sort_order>
|
13 |
+
<show_in_default>1</show_in_default>
|
14 |
+
<show_in_website>1</show_in_website>
|
15 |
+
<show_in_store>1</show_in_store>
|
16 |
+
<groups>
|
17 |
+
<skyboxsettings translate="label" module="skyboxinternational">
|
18 |
+
<label>Merchant Settings</label>
|
19 |
+
<frontend_type>text</frontend_type>
|
20 |
+
<sort_order>10</sort_order>
|
21 |
+
<show_in_default>1</show_in_default>
|
22 |
+
<show_in_website>1</show_in_website>
|
23 |
+
<show_in_store>1</show_in_store>
|
24 |
+
<fields>
|
25 |
+
<skyboxactive translate="label">
|
26 |
+
<label>Enabled</label>
|
27 |
+
<frontend_type>select</frontend_type>
|
28 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
29 |
+
<sort_order>1</sort_order>
|
30 |
+
<show_in_default>1</show_in_default>
|
31 |
+
<show_in_website>1</show_in_website>
|
32 |
+
<show_in_store>1</show_in_store>
|
33 |
+
</skyboxactive>
|
34 |
+
<merchantcode translate="label">
|
35 |
+
<label>Merchant Id:</label>
|
36 |
+
<comment>Code Merchant by Skybox Checkout International</comment>
|
37 |
+
<frontend_type>text</frontend_type>
|
38 |
+
<sort_order>2</sort_order>
|
39 |
+
<show_in_default>1</show_in_default>
|
40 |
+
<show_in_website>1</show_in_website>
|
41 |
+
<show_in_store>1</show_in_store>
|
42 |
+
</merchantcode>
|
43 |
+
<merchantkey translate="label">
|
44 |
+
<label>Merchant Key:</label>
|
45 |
+
<comment>Key Merchant by Skybox Checkout International</comment>
|
46 |
+
<frontend_type>text</frontend_type>
|
47 |
+
<sort_order>3</sort_order>
|
48 |
+
<show_in_default>1</show_in_default>
|
49 |
+
<show_in_website>1</show_in_website>
|
50 |
+
<show_in_store>1</show_in_store>
|
51 |
+
</merchantkey>
|
52 |
+
<weigthunitproduct translate="label">
|
53 |
+
<label>Weight Unit:</label>
|
54 |
+
<comment>Source model provider Magento's unit of measure values</comment>
|
55 |
+
<frontend_type>select</frontend_type>
|
56 |
+
<sort_order>4</sort_order>
|
57 |
+
<show_in_default>1</show_in_default>
|
58 |
+
<show_in_website>1</show_in_website>
|
59 |
+
<show_in_store>1</show_in_store>
|
60 |
+
<source_model>usa/shipping_carrier_ups_source_unitofmeasure</source_model>
|
61 |
+
</weigthunitproduct>
|
62 |
+
<skyboxlog translate="label">
|
63 |
+
<label>Save API Responses</label>
|
64 |
+
<frontend_type>select</frontend_type>
|
65 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
66 |
+
<sort_order>5</sort_order>
|
67 |
+
<show_in_default>1</show_in_default>
|
68 |
+
<show_in_website>1</show_in_website>
|
69 |
+
<show_in_store>1</show_in_store>
|
70 |
+
</skyboxlog>
|
71 |
+
<skyboxemail translate="label">
|
72 |
+
<label>SkyBox Email:</label>
|
73 |
+
<comment>SkyBox Email</comment>
|
74 |
+
<frontend_type>text</frontend_type>
|
75 |
+
<validate>validate-email</validate>
|
76 |
+
<sort_order>6</sort_order>
|
77 |
+
<show_in_default>1</show_in_default>
|
78 |
+
<show_in_website>1</show_in_website>
|
79 |
+
<show_in_store>1</show_in_store>
|
80 |
+
</skyboxemail>
|
81 |
+
<skyboxintegration translate="label">
|
82 |
+
<label>SkyBox Itegration:</label>
|
83 |
+
<comment>SkyBox Integration</comment>
|
84 |
+
<frontend_type>select</frontend_type>
|
85 |
+
<!--<source_model>adminhtml/system_config_source_yesno</source_model>-->
|
86 |
+
<source_model>Skybox_International_Model_StoreType</source_model>
|
87 |
+
<!--<frontend_type>text</frontend_type>-->
|
88 |
+
<sort_order>7</sort_order>
|
89 |
+
<show_in_default>1</show_in_default>
|
90 |
+
<show_in_website>1</show_in_website>
|
91 |
+
<show_in_store>1</show_in_store>
|
92 |
+
</skyboxintegration>
|
93 |
+
<skyboxurlapi translate="label">
|
94 |
+
<label>SkyBox Url API:</label>
|
95 |
+
<comment>Url API By Skybox Checkout International</comment>
|
96 |
+
<frontend_type>text</frontend_type>
|
97 |
+
<sort_order>8</sort_order>
|
98 |
+
<show_in_default>1</show_in_default>
|
99 |
+
<show_in_website>1</show_in_website>
|
100 |
+
<show_in_store>1</show_in_store>
|
101 |
+
</skyboxurlapi>
|
102 |
+
<skyboxurlmain translate="label">
|
103 |
+
<label>SkyBox Url Client:</label>
|
104 |
+
<comment>Url Client By Skybox Checkout International</comment>
|
105 |
+
<frontend_type>text</frontend_type>
|
106 |
+
<sort_order>9</sort_order>
|
107 |
+
<show_in_default>1</show_in_default>
|
108 |
+
<show_in_website>1</show_in_website>
|
109 |
+
<show_in_store>1</show_in_store>
|
110 |
+
</skyboxurlmain>
|
111 |
+
</fields>
|
112 |
+
</skyboxsettings>
|
113 |
+
<skyboxproduct translate="label" module="skyboxinternational">
|
114 |
+
<label>Tax Product</label>
|
115 |
+
<frontend_type>text</frontend_type>
|
116 |
+
<!--<comment>Tax + Price product</comment>-->
|
117 |
+
<sort_order>20</sort_order>
|
118 |
+
<show_in_default>1</show_in_default>
|
119 |
+
<show_in_website>1</show_in_website>
|
120 |
+
<show_in_store>1</show_in_store>
|
121 |
+
<fields>
|
122 |
+
<skyboxaddtaxtopriceenable translate="label">
|
123 |
+
<label>Add Tax to Price</label>
|
124 |
+
<frontend_type>select</frontend_type>
|
125 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
126 |
+
<sort_order>1</sort_order>
|
127 |
+
<show_in_default>1</show_in_default>
|
128 |
+
<show_in_website>1</show_in_website>
|
129 |
+
<show_in_store>1</show_in_store>
|
130 |
+
</skyboxaddtaxtopriceenable>
|
131 |
+
</fields>
|
132 |
+
</skyboxproduct>
|
133 |
+
</groups>
|
134 |
+
</skyboxinternational>
|
135 |
+
</sections>
|
136 |
</config>
|
app/code/community/Skybox/Services/Model/Api.php
CHANGED
@@ -1,310 +1,310 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Services
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Services
|
8 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
*
|
13 |
-
* Skybox Services API
|
14 |
-
*
|
15 |
-
* @author Luis Alex Cordova Leon <lcordova@skyworldint.com>
|
16 |
-
*/
|
17 |
-
|
18 |
-
class Skybox_Services_Model_Api extends Mage_Api_Model_Resource_Abstract
|
19 |
-
{
|
20 |
-
const SKYBOX_SHIPPING = 'skyboxcheckout_shipping_skyboxcheckout';
|
21 |
-
const SKYBOX_PAYMENT = 'skyboxcheckout_pay';
|
22 |
-
|
23 |
-
public function __construct()
|
24 |
-
{
|
25 |
-
Mage::log("API Construct started " . date('m/d/Y h:i:s a', time()));
|
26 |
-
}
|
27 |
-
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Field name in session for saving store id
|
31 |
-
* @var int $orderIncrementId
|
32 |
-
* @var string $status
|
33 |
-
* @return boolean
|
34 |
-
*/
|
35 |
-
public function setStatusOrder($orderIncrementId, $status)
|
36 |
-
{
|
37 |
-
try {
|
38 |
-
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
39 |
-
$order->setData('state', $status); //complete
|
40 |
-
$order->setStatus($status);
|
41 |
-
if(Mage_Sales_Model_Order::STATE_PROCESSING == $status){
|
42 |
-
$order->setTotalPaid($order->getGrandTotal());
|
43 |
-
}elseif(Mage_Sales_Model_Order::STATE_COMPLETE == $status){
|
44 |
-
$history = $order->addStatusHistoryComment('La orden se estableció como completa', false);
|
45 |
-
$history->setIsCustomerNotified(false);
|
46 |
-
}
|
47 |
-
$order->save();
|
48 |
-
return true;
|
49 |
-
} catch (Exception $e) {
|
50 |
-
return false;
|
51 |
-
}
|
52 |
-
}
|
53 |
-
|
54 |
-
|
55 |
-
public function setQuoteDesactive($quoteId)
|
56 |
-
{
|
57 |
-
try {
|
58 |
-
Mage::log("API setQuoteDesactive started " . date('m/d/Y h:i:s a', time()));
|
59 |
-
$quote = Mage::getModel("sales/quote");
|
60 |
-
$quote->loadByIdWithoutStore($quoteId);
|
61 |
-
$quote->setIsActive(false);
|
62 |
-
$quote->save();
|
63 |
-
Mage::log("API setQuoteDesactive finished " . date('m/d/Y h:i:s a', time()));
|
64 |
-
return true;
|
65 |
-
} catch (Exception $e) {
|
66 |
-
return false;
|
67 |
-
}
|
68 |
-
}
|
69 |
-
|
70 |
-
/*
|
71 |
-
* Return a order generated
|
72 |
-
*
|
73 |
-
* @params many
|
74 |
-
* @return integer Quote ID
|
75 |
-
*/
|
76 |
-
public function generateOrder($IdCart, $IdStore, $CustomerName, $CustomerLasName, $CustomerEmail, $CustomerAdresss, $CustomerPhone, $CustomerZipCode, $CityName, $CountryId, $RegionId, $regionName = '')
|
77 |
-
{
|
78 |
-
|
79 |
-
Mage::log("API generateOrder started " . date('m/d/Y h:i:s a', time()));
|
80 |
-
|
81 |
-
$quoteId = $IdCart; // should be!
|
82 |
-
|
83 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
84 |
-
$quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
|
85 |
-
|
86 |
-
$address = $quote->getShippingAddress();
|
87 |
-
|
88 |
-
foreach ($quote->getAllItems() as $item) {
|
89 |
-
Mage::log(print_r($item->debug(), true), null, 'tracer.log', true);
|
90 |
-
$item->setCustomPrice($item->getPriceUsdSkybox());
|
91 |
-
$item->setOriginalCustomPrice($item->getPriceUsdSkybox());
|
92 |
-
// getOrderCurrencyCode
|
93 |
-
// $item->getProduct()->setIsSuperMode(true);
|
94 |
-
// $item->save();
|
95 |
-
}
|
96 |
-
|
97 |
-
/*
|
98 |
-
// Bug: When a customer is already registered as guest,
|
99 |
-
// it doesn't work with Customer validation
|
100 |
-
|
101 |
-
/* @var $customer Mage_Customer_Model_Customer
|
102 |
-
$customer = Mage::getModel('customer/customer');
|
103 |
-
$customer
|
104 |
-
->setWebsiteId(Mage::app()->getStore()->getWebsiteId())// or 1
|
105 |
-
->loadByEmail($CustomerEmail);
|
106 |
-
|
107 |
-
if ($customer->getId()) {
|
108 |
-
$quote->assignCustomer($customer); // for customer orders
|
109 |
-
} else {
|
110 |
-
// ...
|
111 |
-
}
|
112 |
-
*/
|
113 |
-
|
114 |
-
// for guest orders only
|
115 |
-
$quote->setIsMultiShipping(false);
|
116 |
-
$quote->setCheckoutMethod('guest');
|
117 |
-
$quote->setCustomerId(null);
|
118 |
-
$quote->setCustomerEmail($CustomerEmail);
|
119 |
-
$quote->setCustomerIsGuest(true);
|
120 |
-
$quote->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
|
121 |
-
|
122 |
-
$grandTotal = $address->getBaseGrandTotalSkybox();
|
123 |
-
// $quote->setBaseGrandTotal($grandTotal);
|
124 |
-
// $quote->setGrandTotal($grandTotal);
|
125 |
-
// setBaseCurrencyCode(string $value)
|
126 |
-
// setGlobalCurrencyCode(string $value)
|
127 |
-
// setQuoteCurrencyCode(string $value)
|
128 |
-
// setStoreCurrencyCode(string $value)
|
129 |
-
|
130 |
-
// Just for Guest User
|
131 |
-
$CustomerLasName = ($CustomerLasName != null) ? $CustomerLasName : $CustomerName;
|
132 |
-
|
133 |
-
$addressData = array(
|
134 |
-
'firstname' => $CustomerName,
|
135 |
-
'lastname' => $CustomerLasName,
|
136 |
-
'street' => $CustomerAdresss,
|
137 |
-
'city' => $CityName,
|
138 |
-
'postcode' => $CustomerZipCode,
|
139 |
-
'telephone' => $CustomerPhone,
|
140 |
-
'country_id' => $CountryId,
|
141 |
-
'region_id' => $RegionId,
|
142 |
-
'region' => $regionName,
|
143 |
-
'is_default_billing' => '1',
|
144 |
-
);
|
145 |
-
|
146 |
-
$billingAddress = $quote->getBillingAddress()->addData($addressData);
|
147 |
-
$shippingAddress = $quote->getShippingAddress()->addData($addressData);
|
148 |
-
|
149 |
-
// if(!Mage::getStoreConfig('payment/checkmo/active')){
|
150 |
-
// Mage::log('Desactivado checkmo', null, 'tracer.log', true);
|
151 |
-
// Mage::app()->getStore()->setConfig('payment/checkmo/active', true);
|
152 |
-
// }
|
153 |
-
|
154 |
-
$shippingAddress->setCollectShippingRates(true)
|
155 |
-
->collectShippingRates()
|
156 |
-
->setShippingMethod(self::SKYBOX_SHIPPING)//flatrate_flatrate
|
157 |
-
->setPaymentMethod(self::SKYBOX_PAYMENT);
|
158 |
-
|
159 |
-
$quote->getPayment()->importData(array('method' => self::SKYBOX_PAYMENT));
|
160 |
-
// $quote->getPayment()->importData(array('method' => 'checkmo'));
|
161 |
-
|
162 |
-
$quote->collectTotals()->save();
|
163 |
-
|
164 |
-
$address->setGrandTotal($grandTotal);
|
165 |
-
$address->setBaseGrandTotal($grandTotal);
|
166 |
-
|
167 |
-
$service = Mage::getModel('sales/service_quote', $quote);
|
168 |
-
$service->submitAll();
|
169 |
-
|
170 |
-
try {
|
171 |
-
$order = $service->getOrder();
|
172 |
-
|
173 |
-
// Comment
|
174 |
-
$comment = "This order was generated by Skybox Checkout";
|
175 |
-
$order->addStatusHistoryComment($comment);
|
176 |
-
$order->save();
|
177 |
-
|
178 |
-
// setQuoteDesactive
|
179 |
-
$this->setQuoteDesactive($quoteId);
|
180 |
-
//$quote->setIsActive(false);
|
181 |
-
|
182 |
-
/*Mage::log("Order " . $order->getIncrementId() . " was created");
|
183 |
-
Mage::log("API generateOrder finished " . date('m/d/Y h:i:s a', time()));
|
184 |
-
Mage::log("API Construct finished " . date('m/d/Y h:i:s a', time()));
|
185 |
-
Mage::log("getShippingMethod: " . $order->getShippingMethod());*/
|
186 |
-
return $order->getIncrementId();
|
187 |
-
} catch (Exception $e) {
|
188 |
-
Mage::log("exception", null, 'servicios.log', true);
|
189 |
-
Mage::log($e->getMessage());
|
190 |
-
}
|
191 |
-
}
|
192 |
-
|
193 |
-
public function generateOrderFull($DataProducts, $IdStore, $CustomerName, $CustomerLasName, $CustomerEmail, $CustomerAdresss, $CustomerPhone, $CustomerZipCode, $CityName, $CountryId, $RegionId, $regionName = '')
|
194 |
-
{
|
195 |
-
Mage::log("API generateOrderFull started " . date('m/d/Y h:i:s a', time()));
|
196 |
-
|
197 |
-
$IdStore = !empty($IdStore)?$IdStore:Mage::app()->getStore('default')->getId();
|
198 |
-
$quote = Mage::getModel('sales/quote')->setStoreId($IdStore);
|
199 |
-
$productList = array();
|
200 |
-
$objData = json_decode($DataProducts);
|
201 |
-
Mage::log('########### $objData ###########', null, 'tracer.log', true);
|
202 |
-
Mage::log(print_r($objData, true), null, 'tracer.log', true);
|
203 |
-
if(count($objData->Products)>0){
|
204 |
-
foreach ($objData->Products as $prod){
|
205 |
-
$product = Mage::getModel('catalog/product')->load($prod->ProductId);
|
206 |
-
$buyInfo = array(
|
207 |
-
'qty' => $prod->Quantity,
|
208 |
-
// custom option id => value id
|
209 |
-
// or
|
210 |
-
// configurable attribute id => value id
|
211 |
-
);
|
212 |
-
$productList[$prod->ProductId] = $prod;
|
213 |
-
$quote->addProduct($product, new Varien_Object($buyInfo));
|
214 |
-
}
|
215 |
-
}
|
216 |
-
Mage::log('########### $productList ###########', null, 'tracer.log', true);
|
217 |
-
Mage::log(print_r($productList, true), null, 'tracer.log', true);
|
218 |
-
|
219 |
-
$quoteId = $quote->getId();
|
220 |
-
|
221 |
-
$address = $quote->getShippingAddress();
|
222 |
-
|
223 |
-
foreach ($quote->getAllItems() as $item) {
|
224 |
-
Mage::log('########### $item ###########', null, 'tracer.log', true);
|
225 |
-
// Mage::log(print_r($item->debug(), true), null, 'tracer.log', true);
|
226 |
-
Mage::log(print_r($item->getProductId(), true), null, 'tracer.log', true);
|
227 |
-
$prod = $productList[$item->getProductId()];
|
228 |
-
Mage::log('########### PROD ###########', null, 'tracer.log', true);
|
229 |
-
Mage::log(print_r($prod, true), null, 'tracer.log', true);
|
230 |
-
$item->setCustomPrice($prod->ProductPriceUSD);
|
231 |
-
$item->setOriginalCustomPrice($prod->ProductPriceUSD);
|
232 |
-
// getOrderCurrencyCode
|
233 |
-
// $item->getProduct()->setIsSuperMode(true);
|
234 |
-
// $item->save();
|
235 |
-
}
|
236 |
-
|
237 |
-
// for guest orders only
|
238 |
-
$quote->setIsMultiShipping(false);
|
239 |
-
$quote->setCheckoutMethod('guest');
|
240 |
-
$quote->setCustomerId(null);
|
241 |
-
$quote->setCustomerEmail($CustomerEmail);
|
242 |
-
$quote->setCustomerIsGuest(true);
|
243 |
-
$quote->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
|
244 |
-
|
245 |
-
// $grandTotal = $address->getBaseGrandTotalSkybox();
|
246 |
-
$grandTotal = $objData->TotalShoppingCart->TotalPriceUSD;
|
247 |
-
Mage::log('########### $grandTotal ###########', null, 'tracer.log', true);
|
248 |
-
Mage::log(print_r($grandTotal, true), null, 'tracer.log', true);
|
249 |
-
// $quote->setBaseGrandTotal($grandTotal);
|
250 |
-
// $quote->setGrandTotal($grandTotal);
|
251 |
-
// setBaseCurrencyCode(string $value)
|
252 |
-
// setGlobalCurrencyCode(string $value)
|
253 |
-
// setQuoteCurrencyCode(string $value)
|
254 |
-
// setStoreCurrencyCode(string $value)
|
255 |
-
|
256 |
-
// Just for Guest User
|
257 |
-
$CustomerLasName = ($CustomerLasName != null) ? $CustomerLasName : $CustomerName;
|
258 |
-
|
259 |
-
$addressData = array(
|
260 |
-
'firstname' => $CustomerName,
|
261 |
-
'lastname' => $CustomerLasName,
|
262 |
-
'street' => $CustomerAdresss,
|
263 |
-
'city' => $CityName,
|
264 |
-
'postcode' => $CustomerZipCode,
|
265 |
-
'telephone' => $CustomerPhone,
|
266 |
-
'country_id' => $CountryId,
|
267 |
-
'region_id' => $RegionId,
|
268 |
-
'region' => $regionName,
|
269 |
-
'is_default_billing' => '1',
|
270 |
-
);
|
271 |
-
|
272 |
-
$billingAddress = $quote->getBillingAddress()->addData($addressData);
|
273 |
-
$shippingAddress = $quote->getShippingAddress()->addData($addressData);
|
274 |
-
|
275 |
-
$shippingAddress->setCollectShippingRates(true)
|
276 |
-
->collectShippingRates()
|
277 |
-
->setShippingMethod(self::SKYBOX_SHIPPING)//flatrate_flatrate
|
278 |
-
->setPaymentMethod(self::SKYBOX_PAYMENT);
|
279 |
-
|
280 |
-
$quote->getPayment()->importData(array('method' => self::SKYBOX_PAYMENT));
|
281 |
-
|
282 |
-
$quote->collectTotals()->save();
|
283 |
-
|
284 |
-
$address->setConceptsSkybox(json_encode($objData->TotalShoppingCart->ListDetailConcepts));
|
285 |
-
$address->setGrandTotal($grandTotal);
|
286 |
-
$address->setBaseGrandTotal($grandTotal);
|
287 |
-
|
288 |
-
$service = Mage::getModel('sales/service_quote', $quote);
|
289 |
-
$service->submitAll();
|
290 |
-
|
291 |
-
try {
|
292 |
-
$order = $service->getOrder();
|
293 |
-
|
294 |
-
// Comment
|
295 |
-
$comment = "This order was generated by Skybox Checkout";
|
296 |
-
$order->addStatusHistoryComment($comment);
|
297 |
-
$order->setTotalPaid($order->getGrandTotal());
|
298 |
-
$order->save();
|
299 |
-
|
300 |
-
// setQuoteDesactive
|
301 |
-
$this->setQuoteDesactive($quoteId);
|
302 |
-
//$quote->setIsActive(false);
|
303 |
-
|
304 |
-
return $order->getIncrementId();
|
305 |
-
} catch (Exception $e) {
|
306 |
-
Mage::log("exception", null, 'servicios.log', true);
|
307 |
-
Mage::log($e->getMessage());
|
308 |
-
}
|
309 |
-
}
|
310 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Services
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Services
|
8 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
*
|
13 |
+
* Skybox Services API
|
14 |
+
*
|
15 |
+
* @author Luis Alex Cordova Leon <lcordova@skyworldint.com>
|
16 |
+
*/
|
17 |
+
|
18 |
+
class Skybox_Services_Model_Api extends Mage_Api_Model_Resource_Abstract
|
19 |
+
{
|
20 |
+
const SKYBOX_SHIPPING = 'skyboxcheckout_shipping_skyboxcheckout';
|
21 |
+
const SKYBOX_PAYMENT = 'skyboxcheckout_pay';
|
22 |
+
|
23 |
+
public function __construct()
|
24 |
+
{
|
25 |
+
Mage::log("API Construct started " . date('m/d/Y h:i:s a', time()));
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Field name in session for saving store id
|
31 |
+
* @var int $orderIncrementId
|
32 |
+
* @var string $status
|
33 |
+
* @return boolean
|
34 |
+
*/
|
35 |
+
public function setStatusOrder($orderIncrementId, $status)
|
36 |
+
{
|
37 |
+
try {
|
38 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
39 |
+
$order->setData('state', $status); //complete
|
40 |
+
$order->setStatus($status);
|
41 |
+
if(Mage_Sales_Model_Order::STATE_PROCESSING == $status){
|
42 |
+
$order->setTotalPaid($order->getGrandTotal());
|
43 |
+
}elseif(Mage_Sales_Model_Order::STATE_COMPLETE == $status){
|
44 |
+
$history = $order->addStatusHistoryComment('La orden se estableció como completa', false);
|
45 |
+
$history->setIsCustomerNotified(false);
|
46 |
+
}
|
47 |
+
$order->save();
|
48 |
+
return true;
|
49 |
+
} catch (Exception $e) {
|
50 |
+
return false;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
|
55 |
+
public function setQuoteDesactive($quoteId)
|
56 |
+
{
|
57 |
+
try {
|
58 |
+
Mage::log("API setQuoteDesactive started " . date('m/d/Y h:i:s a', time()));
|
59 |
+
$quote = Mage::getModel("sales/quote");
|
60 |
+
$quote->loadByIdWithoutStore($quoteId);
|
61 |
+
$quote->setIsActive(false);
|
62 |
+
$quote->save();
|
63 |
+
Mage::log("API setQuoteDesactive finished " . date('m/d/Y h:i:s a', time()));
|
64 |
+
return true;
|
65 |
+
} catch (Exception $e) {
|
66 |
+
return false;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
/*
|
71 |
+
* Return a order generated
|
72 |
+
*
|
73 |
+
* @params many
|
74 |
+
* @return integer Quote ID
|
75 |
+
*/
|
76 |
+
public function generateOrder($IdCart, $IdStore, $CustomerName, $CustomerLasName, $CustomerEmail, $CustomerAdresss, $CustomerPhone, $CustomerZipCode, $CityName, $CountryId, $RegionId, $regionName = '')
|
77 |
+
{
|
78 |
+
|
79 |
+
Mage::log("API generateOrder started " . date('m/d/Y h:i:s a', time()));
|
80 |
+
|
81 |
+
$quoteId = $IdCart; // should be!
|
82 |
+
|
83 |
+
/* @var $quote Mage_Sales_Model_Quote */
|
84 |
+
$quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
|
85 |
+
|
86 |
+
$address = $quote->getShippingAddress();
|
87 |
+
|
88 |
+
foreach ($quote->getAllItems() as $item) {
|
89 |
+
Mage::log(print_r($item->debug(), true), null, 'tracer.log', true);
|
90 |
+
$item->setCustomPrice($item->getPriceUsdSkybox());
|
91 |
+
$item->setOriginalCustomPrice($item->getPriceUsdSkybox());
|
92 |
+
// getOrderCurrencyCode
|
93 |
+
// $item->getProduct()->setIsSuperMode(true);
|
94 |
+
// $item->save();
|
95 |
+
}
|
96 |
+
|
97 |
+
/*
|
98 |
+
// Bug: When a customer is already registered as guest,
|
99 |
+
// it doesn't work with Customer validation
|
100 |
+
|
101 |
+
/* @var $customer Mage_Customer_Model_Customer
|
102 |
+
$customer = Mage::getModel('customer/customer');
|
103 |
+
$customer
|
104 |
+
->setWebsiteId(Mage::app()->getStore()->getWebsiteId())// or 1
|
105 |
+
->loadByEmail($CustomerEmail);
|
106 |
+
|
107 |
+
if ($customer->getId()) {
|
108 |
+
$quote->assignCustomer($customer); // for customer orders
|
109 |
+
} else {
|
110 |
+
// ...
|
111 |
+
}
|
112 |
+
*/
|
113 |
+
|
114 |
+
// for guest orders only
|
115 |
+
$quote->setIsMultiShipping(false);
|
116 |
+
$quote->setCheckoutMethod('guest');
|
117 |
+
$quote->setCustomerId(null);
|
118 |
+
$quote->setCustomerEmail($CustomerEmail);
|
119 |
+
$quote->setCustomerIsGuest(true);
|
120 |
+
$quote->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
|
121 |
+
|
122 |
+
$grandTotal = $address->getBaseGrandTotalSkybox();
|
123 |
+
// $quote->setBaseGrandTotal($grandTotal);
|
124 |
+
// $quote->setGrandTotal($grandTotal);
|
125 |
+
// setBaseCurrencyCode(string $value)
|
126 |
+
// setGlobalCurrencyCode(string $value)
|
127 |
+
// setQuoteCurrencyCode(string $value)
|
128 |
+
// setStoreCurrencyCode(string $value)
|
129 |
+
|
130 |
+
// Just for Guest User
|
131 |
+
$CustomerLasName = ($CustomerLasName != null) ? $CustomerLasName : $CustomerName;
|
132 |
+
|
133 |
+
$addressData = array(
|
134 |
+
'firstname' => $CustomerName,
|
135 |
+
'lastname' => $CustomerLasName,
|
136 |
+
'street' => $CustomerAdresss,
|
137 |
+
'city' => $CityName,
|
138 |
+
'postcode' => $CustomerZipCode,
|
139 |
+
'telephone' => $CustomerPhone,
|
140 |
+
'country_id' => $CountryId,
|
141 |
+
'region_id' => $RegionId,
|
142 |
+
'region' => $regionName,
|
143 |
+
'is_default_billing' => '1',
|
144 |
+
);
|
145 |
+
|
146 |
+
$billingAddress = $quote->getBillingAddress()->addData($addressData);
|
147 |
+
$shippingAddress = $quote->getShippingAddress()->addData($addressData);
|
148 |
+
|
149 |
+
// if(!Mage::getStoreConfig('payment/checkmo/active')){
|
150 |
+
// Mage::log('Desactivado checkmo', null, 'tracer.log', true);
|
151 |
+
// Mage::app()->getStore()->setConfig('payment/checkmo/active', true);
|
152 |
+
// }
|
153 |
+
|
154 |
+
$shippingAddress->setCollectShippingRates(true)
|
155 |
+
->collectShippingRates()
|
156 |
+
->setShippingMethod(self::SKYBOX_SHIPPING)//flatrate_flatrate
|
157 |
+
->setPaymentMethod(self::SKYBOX_PAYMENT);
|
158 |
+
|
159 |
+
$quote->getPayment()->importData(array('method' => self::SKYBOX_PAYMENT));
|
160 |
+
// $quote->getPayment()->importData(array('method' => 'checkmo'));
|
161 |
+
|
162 |
+
$quote->collectTotals()->save();
|
163 |
+
|
164 |
+
$address->setGrandTotal($grandTotal);
|
165 |
+
$address->setBaseGrandTotal($grandTotal);
|
166 |
+
|
167 |
+
$service = Mage::getModel('sales/service_quote', $quote);
|
168 |
+
$service->submitAll();
|
169 |
+
|
170 |
+
try {
|
171 |
+
$order = $service->getOrder();
|
172 |
+
|
173 |
+
// Comment
|
174 |
+
$comment = "This order was generated by Skybox Checkout";
|
175 |
+
$order->addStatusHistoryComment($comment);
|
176 |
+
$order->save();
|
177 |
+
|
178 |
+
// setQuoteDesactive
|
179 |
+
$this->setQuoteDesactive($quoteId);
|
180 |
+
//$quote->setIsActive(false);
|
181 |
+
|
182 |
+
/*Mage::log("Order " . $order->getIncrementId() . " was created");
|
183 |
+
Mage::log("API generateOrder finished " . date('m/d/Y h:i:s a', time()));
|
184 |
+
Mage::log("API Construct finished " . date('m/d/Y h:i:s a', time()));
|
185 |
+
Mage::log("getShippingMethod: " . $order->getShippingMethod());*/
|
186 |
+
return $order->getIncrementId();
|
187 |
+
} catch (Exception $e) {
|
188 |
+
Mage::log("exception", null, 'servicios.log', true);
|
189 |
+
Mage::log($e->getMessage());
|
190 |
+
}
|
191 |
+
}
|
192 |
+
|
193 |
+
public function generateOrderFull($DataProducts, $IdStore, $CustomerName, $CustomerLasName, $CustomerEmail, $CustomerAdresss, $CustomerPhone, $CustomerZipCode, $CityName, $CountryId, $RegionId, $regionName = '')
|
194 |
+
{
|
195 |
+
Mage::log("API generateOrderFull started " . date('m/d/Y h:i:s a', time()));
|
196 |
+
|
197 |
+
$IdStore = !empty($IdStore)?$IdStore:Mage::app()->getStore('default')->getId();
|
198 |
+
$quote = Mage::getModel('sales/quote')->setStoreId($IdStore);
|
199 |
+
$productList = array();
|
200 |
+
$objData = json_decode($DataProducts);
|
201 |
+
Mage::log('########### $objData ###########', null, 'tracer.log', true);
|
202 |
+
Mage::log(print_r($objData, true), null, 'tracer.log', true);
|
203 |
+
if(count($objData->Products)>0){
|
204 |
+
foreach ($objData->Products as $prod){
|
205 |
+
$product = Mage::getModel('catalog/product')->load($prod->ProductId);
|
206 |
+
$buyInfo = array(
|
207 |
+
'qty' => $prod->Quantity,
|
208 |
+
// custom option id => value id
|
209 |
+
// or
|
210 |
+
// configurable attribute id => value id
|
211 |
+
);
|
212 |
+
$productList[$prod->ProductId] = $prod;
|
213 |
+
$quote->addProduct($product, new Varien_Object($buyInfo));
|
214 |
+
}
|
215 |
+
}
|
216 |
+
Mage::log('########### $productList ###########', null, 'tracer.log', true);
|
217 |
+
Mage::log(print_r($productList, true), null, 'tracer.log', true);
|
218 |
+
|
219 |
+
$quoteId = $quote->getId();
|
220 |
+
|
221 |
+
$address = $quote->getShippingAddress();
|
222 |
+
|
223 |
+
foreach ($quote->getAllItems() as $item) {
|
224 |
+
Mage::log('########### $item ###########', null, 'tracer.log', true);
|
225 |
+
// Mage::log(print_r($item->debug(), true), null, 'tracer.log', true);
|
226 |
+
Mage::log(print_r($item->getProductId(), true), null, 'tracer.log', true);
|
227 |
+
$prod = $productList[$item->getProductId()];
|
228 |
+
Mage::log('########### PROD ###########', null, 'tracer.log', true);
|
229 |
+
Mage::log(print_r($prod, true), null, 'tracer.log', true);
|
230 |
+
$item->setCustomPrice($prod->ProductPriceUSD);
|
231 |
+
$item->setOriginalCustomPrice($prod->ProductPriceUSD);
|
232 |
+
// getOrderCurrencyCode
|
233 |
+
// $item->getProduct()->setIsSuperMode(true);
|
234 |
+
// $item->save();
|
235 |
+
}
|
236 |
+
|
237 |
+
// for guest orders only
|
238 |
+
$quote->setIsMultiShipping(false);
|
239 |
+
$quote->setCheckoutMethod('guest');
|
240 |
+
$quote->setCustomerId(null);
|
241 |
+
$quote->setCustomerEmail($CustomerEmail);
|
242 |
+
$quote->setCustomerIsGuest(true);
|
243 |
+
$quote->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
|
244 |
+
|
245 |
+
// $grandTotal = $address->getBaseGrandTotalSkybox();
|
246 |
+
$grandTotal = $objData->TotalShoppingCart->TotalPriceUSD;
|
247 |
+
Mage::log('########### $grandTotal ###########', null, 'tracer.log', true);
|
248 |
+
Mage::log(print_r($grandTotal, true), null, 'tracer.log', true);
|
249 |
+
// $quote->setBaseGrandTotal($grandTotal);
|
250 |
+
// $quote->setGrandTotal($grandTotal);
|
251 |
+
// setBaseCurrencyCode(string $value)
|
252 |
+
// setGlobalCurrencyCode(string $value)
|
253 |
+
// setQuoteCurrencyCode(string $value)
|
254 |
+
// setStoreCurrencyCode(string $value)
|
255 |
+
|
256 |
+
// Just for Guest User
|
257 |
+
$CustomerLasName = ($CustomerLasName != null) ? $CustomerLasName : $CustomerName;
|
258 |
+
|
259 |
+
$addressData = array(
|
260 |
+
'firstname' => $CustomerName,
|
261 |
+
'lastname' => $CustomerLasName,
|
262 |
+
'street' => $CustomerAdresss,
|
263 |
+
'city' => $CityName,
|
264 |
+
'postcode' => $CustomerZipCode,
|
265 |
+
'telephone' => $CustomerPhone,
|
266 |
+
'country_id' => $CountryId,
|
267 |
+
'region_id' => $RegionId,
|
268 |
+
'region' => $regionName,
|
269 |
+
'is_default_billing' => '1',
|
270 |
+
);
|
271 |
+
|
272 |
+
$billingAddress = $quote->getBillingAddress()->addData($addressData);
|
273 |
+
$shippingAddress = $quote->getShippingAddress()->addData($addressData);
|
274 |
+
|
275 |
+
$shippingAddress->setCollectShippingRates(true)
|
276 |
+
->collectShippingRates()
|
277 |
+
->setShippingMethod(self::SKYBOX_SHIPPING)//flatrate_flatrate
|
278 |
+
->setPaymentMethod(self::SKYBOX_PAYMENT);
|
279 |
+
|
280 |
+
$quote->getPayment()->importData(array('method' => self::SKYBOX_PAYMENT));
|
281 |
+
|
282 |
+
$quote->collectTotals()->save();
|
283 |
+
|
284 |
+
$address->setConceptsSkybox(json_encode($objData->TotalShoppingCart->ListDetailConcepts));
|
285 |
+
$address->setGrandTotal($grandTotal);
|
286 |
+
$address->setBaseGrandTotal($grandTotal);
|
287 |
+
|
288 |
+
$service = Mage::getModel('sales/service_quote', $quote);
|
289 |
+
$service->submitAll();
|
290 |
+
|
291 |
+
try {
|
292 |
+
$order = $service->getOrder();
|
293 |
+
|
294 |
+
// Comment
|
295 |
+
$comment = "This order was generated by Skybox Checkout";
|
296 |
+
$order->addStatusHistoryComment($comment);
|
297 |
+
$order->setTotalPaid($order->getGrandTotal());
|
298 |
+
$order->save();
|
299 |
+
|
300 |
+
// setQuoteDesactive
|
301 |
+
$this->setQuoteDesactive($quoteId);
|
302 |
+
//$quote->setIsActive(false);
|
303 |
+
|
304 |
+
return $order->getIncrementId();
|
305 |
+
} catch (Exception $e) {
|
306 |
+
Mage::log("exception", null, 'servicios.log', true);
|
307 |
+
Mage::log($e->getMessage());
|
308 |
+
}
|
309 |
+
}
|
310 |
}
|
app/code/community/Skybox/Services/Model/Api/V2.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Skybox Services
|
5 |
-
*
|
6 |
-
* @category Skybox
|
7 |
-
* @package Skybox_Services
|
8 |
-
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
-
*/
|
10 |
-
class Skybox_Services_Model_Api_V2 extends Skybox_Services_Model_Api
|
11 |
-
{
|
12 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Skybox Services
|
5 |
+
*
|
6 |
+
* @category Skybox
|
7 |
+
* @package Skybox_Services
|
8 |
+
* @copyright Copyright (c) 2014 Skybox Checkout. (http://www.skyboxcheckout.com)
|
9 |
+
*/
|
10 |
+
class Skybox_Services_Model_Api_V2 extends Skybox_Services_Model_Api
|
11 |
+
{
|
12 |
}
|
app/code/community/Skybox/Services/etc/api.xml
CHANGED
@@ -1,38 +1,38 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<api>
|
4 |
-
<resources>
|
5 |
-
<services>
|
6 |
-
<model>services/api</model>
|
7 |
-
<title>Skybox Web Services</title>
|
8 |
-
<methods>
|
9 |
-
<setStatusOrder translate="title" module="services">
|
10 |
-
<title>Change status order to complete</title>
|
11 |
-
<method>setStatusOrder</method>
|
12 |
-
<acl>services/setStatusOrder</acl>
|
13 |
-
</setStatusOrder>
|
14 |
-
<setQuoteDesactive translate="title" module="services">
|
15 |
-
<title>Change Quote to Desactive</title>
|
16 |
-
<method>setQuoteDesactive</method>
|
17 |
-
<acl>services/setQuoteDesactive</acl>
|
18 |
-
</setQuoteDesactive>
|
19 |
-
<generateOrder translate="title" module="services">
|
20 |
-
<title>Generate Order Magento</title>
|
21 |
-
<method>generateOrder</method>
|
22 |
-
<acl>services/generateOrder</acl>
|
23 |
-
</generateOrder>
|
24 |
-
<generateOrderFull translate="title" module="services">
|
25 |
-
<title>Generate Order Full Magento</title>
|
26 |
-
<method>generateOrderFull</method>
|
27 |
-
<acl>services/generateOrderFull</acl>
|
28 |
-
</generateOrderFull>
|
29 |
-
</methods>
|
30 |
-
</services>
|
31 |
-
</resources>
|
32 |
-
<v2>
|
33 |
-
<resources_function_prefix>
|
34 |
-
<services>services</services>
|
35 |
-
</resources_function_prefix>
|
36 |
-
</v2>
|
37 |
-
</api>
|
38 |
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api>
|
4 |
+
<resources>
|
5 |
+
<services>
|
6 |
+
<model>services/api</model>
|
7 |
+
<title>Skybox Web Services</title>
|
8 |
+
<methods>
|
9 |
+
<setStatusOrder translate="title" module="services">
|
10 |
+
<title>Change status order to complete</title>
|
11 |
+
<method>setStatusOrder</method>
|
12 |
+
<acl>services/setStatusOrder</acl>
|
13 |
+
</setStatusOrder>
|
14 |
+
<setQuoteDesactive translate="title" module="services">
|
15 |
+
<title>Change Quote to Desactive</title>
|
16 |
+
<method>setQuoteDesactive</method>
|
17 |
+
<acl>services/setQuoteDesactive</acl>
|
18 |
+
</setQuoteDesactive>
|
19 |
+
<generateOrder translate="title" module="services">
|
20 |
+
<title>Generate Order Magento</title>
|
21 |
+
<method>generateOrder</method>
|
22 |
+
<acl>services/generateOrder</acl>
|
23 |
+
</generateOrder>
|
24 |
+
<generateOrderFull translate="title" module="services">
|
25 |
+
<title>Generate Order Full Magento</title>
|
26 |
+
<method>generateOrderFull</method>
|
27 |
+
<acl>services/generateOrderFull</acl>
|
28 |
+
</generateOrderFull>
|
29 |
+
</methods>
|
30 |
+
</services>
|
31 |
+
</resources>
|
32 |
+
<v2>
|
33 |
+
<resources_function_prefix>
|
34 |
+
<services>services</services>
|
35 |
+
</resources_function_prefix>
|
36 |
+
</v2>
|
37 |
+
</api>
|
38 |
</config>
|
app/code/community/Skybox/Services/etc/config.xml
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
<modules>
|
4 |
<Skybox_Services>
|
5 |
<active>true</active>
|
6 |
-
<version>1.2.
|
7 |
<codePool>community</codePool>
|
8 |
</Skybox_Services>
|
9 |
</modules>
|
3 |
<modules>
|
4 |
<Skybox_Services>
|
5 |
<active>true</active>
|
6 |
+
<version>1.2.9</version>
|
7 |
<codePool>community</codePool>
|
8 |
</Skybox_Services>
|
9 |
</modules>
|
app/code/community/Skybox/Services/etc/wsdl.xml
CHANGED
@@ -1,142 +1,142 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<definitions xmlns:typens="urn:{{var wsdl.name}}" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
3 |
-
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"
|
4 |
-
name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}">
|
5 |
-
<types>
|
6 |
-
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
|
7 |
-
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />
|
8 |
-
</schema>
|
9 |
-
</types>
|
10 |
-
|
11 |
-
<message name="servicesSetStatusOrderRequest">
|
12 |
-
<part name="sessionId" type="xsd:string" />
|
13 |
-
<part name="orderIncrementId" type="xsd:string" />
|
14 |
-
<part name="status" type="xsd:string" />
|
15 |
-
</message>
|
16 |
-
<message name="servicesSetStatusOrderResponse">
|
17 |
-
<part name="result" type="xsd:boolean" />
|
18 |
-
</message>
|
19 |
-
|
20 |
-
<message name="servicesSetQuoteDesactiveRequest">
|
21 |
-
<part name="sessionId" type="xsd:string" />
|
22 |
-
<part name="quoteId" type="xsd:int" />
|
23 |
-
</message>
|
24 |
-
<message name="servicesSetQuoteDesactiveResponse">
|
25 |
-
<part name="result" type="xsd:boolean" />
|
26 |
-
</message>
|
27 |
-
|
28 |
-
|
29 |
-
<message name="servicesGenerateOrderRequest">
|
30 |
-
<part name="sessionId" type="xsd:string" />
|
31 |
-
<part name="IdCart" type="xsd:int" />
|
32 |
-
<part name="IdStore" type="xsd:string" />
|
33 |
-
<part name="CustomerName" type="xsd:string" />
|
34 |
-
<part name="CustomerLasName" type="xsd:string" />
|
35 |
-
<part name="CustomerEmail" type="xsd:string" />
|
36 |
-
<part name="CustomerAdresss" type="xsd:string" />
|
37 |
-
<part name="CustomerPhone" type="xsd:string" />
|
38 |
-
<part name="CustomerZipCode" type="xsd:string" />
|
39 |
-
<part name="CityName" type="xsd:string" />
|
40 |
-
<part name="CountryId" type="xsd:string" />
|
41 |
-
<part name="RegionId" type="xsd:string" />
|
42 |
-
<part name="RegionName" type="xsd:string" />
|
43 |
-
</message>
|
44 |
-
|
45 |
-
<message name="servicesGenerateOrderResponse">
|
46 |
-
<part name="result" type="xsd:string" />
|
47 |
-
</message>
|
48 |
-
|
49 |
-
<message name="servicesGenerateOrderFullRequest">
|
50 |
-
<part name="sessionId" type="xsd:string" />
|
51 |
-
<part name="DataProducts" type="xsd:string" />
|
52 |
-
<part name="IdStore" type="xsd:string" />
|
53 |
-
<part name="CustomerName" type="xsd:string" />
|
54 |
-
<part name="CustomerLasName" type="xsd:string" />
|
55 |
-
<part name="CustomerEmail" type="xsd:string" />
|
56 |
-
<part name="CustomerAdresss" type="xsd:string" />
|
57 |
-
<part name="CustomerPhone" type="xsd:string" />
|
58 |
-
<part name="CustomerZipCode" type="xsd:string" />
|
59 |
-
<part name="CityName" type="xsd:string" />
|
60 |
-
<part name="CountryId" type="xsd:string" />
|
61 |
-
<part name="RegionId" type="xsd:string" />
|
62 |
-
<part name="RegionName" type="xsd:string" />
|
63 |
-
</message>
|
64 |
-
|
65 |
-
<message name="servicesGenerateOrderFullResponse">
|
66 |
-
<part name="result" type="xsd:string" />
|
67 |
-
</message>
|
68 |
-
|
69 |
-
|
70 |
-
<portType name="{{var wsdl.handler}}PortType">
|
71 |
-
|
72 |
-
<operation name="servicesSetStatusOrder">
|
73 |
-
<documentation>Change status order to complete</documentation>
|
74 |
-
<input message="typens:servicesSetStatusOrderRequest" />
|
75 |
-
<output message="typens:servicesSetStatusOrderResponse" />
|
76 |
-
</operation>
|
77 |
-
|
78 |
-
<operation name="servicesSetQuoteDesactive">
|
79 |
-
<documentation>Change Quote to Desactive</documentation>
|
80 |
-
<input message="typens:servicesSetQuoteDesactiveRequest" />
|
81 |
-
<output message="typens:servicesSetQuoteDesactiveResponse" />
|
82 |
-
</operation>
|
83 |
-
|
84 |
-
<operation name="servicesGenerateOrder">
|
85 |
-
<documentation>Generate Order Magento</documentation>
|
86 |
-
<input message="typens:servicesGenerateOrderRequest" />
|
87 |
-
<output message="typens:servicesGenerateOrderResponse" />
|
88 |
-
</operation>
|
89 |
-
|
90 |
-
<operation name="servicesGenerateOrderFull">
|
91 |
-
<documentation>Generate Order Full Magento</documentation>
|
92 |
-
<input message="typens:servicesGenerateOrderFullRequest" />
|
93 |
-
<output message="typens:servicesGenerateOrderFullResponse" />
|
94 |
-
</operation>
|
95 |
-
|
96 |
-
|
97 |
-
</portType>
|
98 |
-
<binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
|
99 |
-
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
|
100 |
-
|
101 |
-
<operation name="servicesSetStatusOrder">
|
102 |
-
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
|
103 |
-
<input>
|
104 |
-
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
105 |
-
</input>
|
106 |
-
<output>
|
107 |
-
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
108 |
-
</output>
|
109 |
-
</operation>
|
110 |
-
|
111 |
-
<operation name="servicesSetQuoteDesactive">
|
112 |
-
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
|
113 |
-
<input>
|
114 |
-
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
115 |
-
</input>
|
116 |
-
<output>
|
117 |
-
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
118 |
-
</output>
|
119 |
-
</operation>
|
120 |
-
|
121 |
-
<operation name="servicesGenerateOrder">
|
122 |
-
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
|
123 |
-
<input>
|
124 |
-
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
125 |
-
</input>
|
126 |
-
<output>
|
127 |
-
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
128 |
-
</output>
|
129 |
-
</operation>
|
130 |
-
|
131 |
-
<operation name="servicesGenerateOrderFull">
|
132 |
-
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
|
133 |
-
<input>
|
134 |
-
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
135 |
-
</input>
|
136 |
-
<output>
|
137 |
-
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
138 |
-
</output>
|
139 |
-
</operation>
|
140 |
-
|
141 |
-
</binding>
|
142 |
</definitions>
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<definitions xmlns:typens="urn:{{var wsdl.name}}" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
3 |
+
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"
|
4 |
+
name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}">
|
5 |
+
<types>
|
6 |
+
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
|
7 |
+
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />
|
8 |
+
</schema>
|
9 |
+
</types>
|
10 |
+
|
11 |
+
<message name="servicesSetStatusOrderRequest">
|
12 |
+
<part name="sessionId" type="xsd:string" />
|
13 |
+
<part name="orderIncrementId" type="xsd:string" />
|
14 |
+
<part name="status" type="xsd:string" />
|
15 |
+
</message>
|
16 |
+
<message name="servicesSetStatusOrderResponse">
|
17 |
+
<part name="result" type="xsd:boolean" />
|
18 |
+
</message>
|
19 |
+
|
20 |
+
<message name="servicesSetQuoteDesactiveRequest">
|
21 |
+
<part name="sessionId" type="xsd:string" />
|
22 |
+
<part name="quoteId" type="xsd:int" />
|
23 |
+
</message>
|
24 |
+
<message name="servicesSetQuoteDesactiveResponse">
|
25 |
+
<part name="result" type="xsd:boolean" />
|
26 |
+
</message>
|
27 |
+
|
28 |
+
|
29 |
+
<message name="servicesGenerateOrderRequest">
|
30 |
+
<part name="sessionId" type="xsd:string" />
|
31 |
+
<part name="IdCart" type="xsd:int" />
|
32 |
+
<part name="IdStore" type="xsd:string" />
|
33 |
+
<part name="CustomerName" type="xsd:string" />
|
34 |
+
<part name="CustomerLasName" type="xsd:string" />
|
35 |
+
<part name="CustomerEmail" type="xsd:string" />
|
36 |
+
<part name="CustomerAdresss" type="xsd:string" />
|
37 |
+
<part name="CustomerPhone" type="xsd:string" />
|
38 |
+
<part name="CustomerZipCode" type="xsd:string" />
|
39 |
+
<part name="CityName" type="xsd:string" />
|
40 |
+
<part name="CountryId" type="xsd:string" />
|
41 |
+
<part name="RegionId" type="xsd:string" />
|
42 |
+
<part name="RegionName" type="xsd:string" />
|
43 |
+
</message>
|
44 |
+
|
45 |
+
<message name="servicesGenerateOrderResponse">
|
46 |
+
<part name="result" type="xsd:string" />
|
47 |
+
</message>
|
48 |
+
|
49 |
+
<message name="servicesGenerateOrderFullRequest">
|
50 |
+
<part name="sessionId" type="xsd:string" />
|
51 |
+
<part name="DataProducts" type="xsd:string" />
|
52 |
+
<part name="IdStore" type="xsd:string" />
|
53 |
+
<part name="CustomerName" type="xsd:string" />
|
54 |
+
<part name="CustomerLasName" type="xsd:string" />
|
55 |
+
<part name="CustomerEmail" type="xsd:string" />
|
56 |
+
<part name="CustomerAdresss" type="xsd:string" />
|
57 |
+
<part name="CustomerPhone" type="xsd:string" />
|
58 |
+
<part name="CustomerZipCode" type="xsd:string" />
|
59 |
+
<part name="CityName" type="xsd:string" />
|
60 |
+
<part name="CountryId" type="xsd:string" />
|
61 |
+
<part name="RegionId" type="xsd:string" />
|
62 |
+
<part name="RegionName" type="xsd:string" />
|
63 |
+
</message>
|
64 |
+
|
65 |
+
<message name="servicesGenerateOrderFullResponse">
|
66 |
+
<part name="result" type="xsd:string" />
|
67 |
+
</message>
|
68 |
+
|
69 |
+
|
70 |
+
<portType name="{{var wsdl.handler}}PortType">
|
71 |
+
|
72 |
+
<operation name="servicesSetStatusOrder">
|
73 |
+
<documentation>Change status order to complete</documentation>
|
74 |
+
<input message="typens:servicesSetStatusOrderRequest" />
|
75 |
+
<output message="typens:servicesSetStatusOrderResponse" />
|
76 |
+
</operation>
|
77 |
+
|
78 |
+
<operation name="servicesSetQuoteDesactive">
|
79 |
+
<documentation>Change Quote to Desactive</documentation>
|
80 |
+
<input message="typens:servicesSetQuoteDesactiveRequest" />
|
81 |
+
<output message="typens:servicesSetQuoteDesactiveResponse" />
|
82 |
+
</operation>
|
83 |
+
|
84 |
+
<operation name="servicesGenerateOrder">
|
85 |
+
<documentation>Generate Order Magento</documentation>
|
86 |
+
<input message="typens:servicesGenerateOrderRequest" />
|
87 |
+
<output message="typens:servicesGenerateOrderResponse" />
|
88 |
+
</operation>
|
89 |
+
|
90 |
+
<operation name="servicesGenerateOrderFull">
|
91 |
+
<documentation>Generate Order Full Magento</documentation>
|
92 |
+
<input message="typens:servicesGenerateOrderFullRequest" />
|
93 |
+
<output message="typens:servicesGenerateOrderFullResponse" />
|
94 |
+
</operation>
|
95 |
+
|
96 |
+
|
97 |
+
</portType>
|
98 |
+
<binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
|
99 |
+
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
|
100 |
+
|
101 |
+
<operation name="servicesSetStatusOrder">
|
102 |
+
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
|
103 |
+
<input>
|
104 |
+
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
105 |
+
</input>
|
106 |
+
<output>
|
107 |
+
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
108 |
+
</output>
|
109 |
+
</operation>
|
110 |
+
|
111 |
+
<operation name="servicesSetQuoteDesactive">
|
112 |
+
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
|
113 |
+
<input>
|
114 |
+
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
115 |
+
</input>
|
116 |
+
<output>
|
117 |
+
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
118 |
+
</output>
|
119 |
+
</operation>
|
120 |
+
|
121 |
+
<operation name="servicesGenerateOrder">
|
122 |
+
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
|
123 |
+
<input>
|
124 |
+
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
125 |
+
</input>
|
126 |
+
<output>
|
127 |
+
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
128 |
+
</output>
|
129 |
+
</operation>
|
130 |
+
|
131 |
+
<operation name="servicesGenerateOrderFull">
|
132 |
+
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
|
133 |
+
<input>
|
134 |
+
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
135 |
+
</input>
|
136 |
+
<output>
|
137 |
+
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
138 |
+
</output>
|
139 |
+
</operation>
|
140 |
+
|
141 |
+
</binding>
|
142 |
</definitions>
|
app/code/community/Skybox/Services/etc/wsi.xml
CHANGED
@@ -1,159 +1,159 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<wsdl:definitions xmlns:typens="urn:{{var wsdl.name}}"
|
3 |
-
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
4 |
-
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
5 |
-
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
6 |
-
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
7 |
-
name="{{var wsdl.name}}"
|
8 |
-
targetNamespace="urn:{{var wsdl.name}}">
|
9 |
-
<wsdl:types>
|
10 |
-
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:{{var wsdl.name}}">
|
11 |
-
|
12 |
-
|
13 |
-
<xsd:element name="servicesSetStatusOrderRequestParam">
|
14 |
-
<xsd:complexType>
|
15 |
-
<xsd:sequence>
|
16 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
|
17 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="orderIncrementId" type="xsd:string" />
|
18 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="status" type="xsd:string" />
|
19 |
-
</xsd:sequence>
|
20 |
-
</xsd:complexType>
|
21 |
-
</xsd:element>
|
22 |
-
<xsd:element name="servicesSetStatusOrderResponseParam">
|
23 |
-
<xsd:complexType>
|
24 |
-
<xsd:sequence>
|
25 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:boolean" />
|
26 |
-
</xsd:sequence>
|
27 |
-
</xsd:complexType>
|
28 |
-
</xsd:element>
|
29 |
-
|
30 |
-
|
31 |
-
<xsd:element name="servicesSetQuoteDesactiveRequestParam">
|
32 |
-
<xsd:complexType>
|
33 |
-
<xsd:sequence>
|
34 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
|
35 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="quoteId" type="xsd:int" />
|
36 |
-
</xsd:sequence>
|
37 |
-
</xsd:complexType>
|
38 |
-
</xsd:element>
|
39 |
-
<xsd:element name="servicesSetQuoteDesactiveResponseParam">
|
40 |
-
<xsd:complexType>
|
41 |
-
<xsd:sequence>
|
42 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:boolean" />
|
43 |
-
</xsd:sequence>
|
44 |
-
</xsd:complexType>
|
45 |
-
</xsd:element>
|
46 |
-
|
47 |
-
|
48 |
-
<xsd:element name="servicesGenerateOrderRequestParam">
|
49 |
-
<xsd:complexType>
|
50 |
-
<xsd:sequence>
|
51 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
|
52 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="IdCart" type="xsd:int" />
|
53 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="IdStore" type="xsd:string" />
|
54 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="CustomerName" type="xsd:string" />
|
55 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="CustomerLasName" type="xsd:string" />
|
56 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="CustomerEmail" type="xsd:string" />
|
57 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="CustomerAdresss" type="xsd:string" />
|
58 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="CustomerPhone" type="xsd:string" />
|
59 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="CustomerZipCode" type="xsd:string" />
|
60 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="CityName" type="xsd:string" />
|
61 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="CountryId" type="xsd:string" />
|
62 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="RegionId" type="xsd:string" />
|
63 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="RegionName" type="xsd:string" />
|
64 |
-
</xsd:sequence>
|
65 |
-
</xsd:complexType>
|
66 |
-
</xsd:element>
|
67 |
-
<xsd:element name="servicesGenerateOrderResponseParam">
|
68 |
-
<xsd:complexType>
|
69 |
-
<xsd:sequence>
|
70 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:string" />
|
71 |
-
</xsd:sequence>
|
72 |
-
</xsd:complexType>
|
73 |
-
</xsd:element>
|
74 |
-
|
75 |
-
|
76 |
-
</xsd:schema>
|
77 |
-
</wsdl:types>
|
78 |
-
|
79 |
-
|
80 |
-
<wsdl:message name="ServicesSetStatusOrderRequest">
|
81 |
-
<wsdl:part name="parameters" element="typens:servicesSetStatusOrderRequestParam" />
|
82 |
-
</wsdl:message>
|
83 |
-
<wsdl:message name="ServicesSetStatusOrderResponse">
|
84 |
-
<wsdl:part name="parameters" element="typens:servicesSetStatusOrderResponseParam" />
|
85 |
-
</wsdl:message>
|
86 |
-
|
87 |
-
<wsdl:message name="ServicesSetQuoteDesactiveRequest">
|
88 |
-
<wsdl:part name="parameters" element="typens:servicesSetQuoteDesactiveRequestParam" />
|
89 |
-
</wsdl:message>
|
90 |
-
<wsdl:message name="ServicesSetQuoteDesactiveResponse">
|
91 |
-
<wsdl:part name="parameters" element="typens:servicesSetQuoteDesactiveResponseParam" />
|
92 |
-
</wsdl:message>
|
93 |
-
|
94 |
-
<wsdl:message name="ServicesGenerateOrderRequest">
|
95 |
-
<wsdl:part name="parameters" element="typens:servicesGenerateOrderRequestParam" />
|
96 |
-
</wsdl:message>
|
97 |
-
<wsdl:message name="ServicesGenerateOrderResponse">
|
98 |
-
<wsdl:part name="parameters" element="typens:servicesGenerateOrderResponseParam" />
|
99 |
-
</wsdl:message>
|
100 |
-
|
101 |
-
|
102 |
-
<wsdl:portType name="{{var wsdl.handler}}PortType">
|
103 |
-
|
104 |
-
<wsdl:operation name="ServicesSetStatusOrder">
|
105 |
-
<wsdl:documentation>Service set status</wsdl:documentation>
|
106 |
-
<wsdl:input message="typens:ServicesSetStatusOrderRequest" />
|
107 |
-
<wsdl:output message="typens:ServicesSetStatusOrderResponse" />
|
108 |
-
</wsdl:operation>
|
109 |
-
|
110 |
-
|
111 |
-
<wsdl:operation name="ServicesSetQuoteDesactive">
|
112 |
-
<wsdl:documentation>Service desactive quote</wsdl:documentation>
|
113 |
-
<wsdl:input message="typens:ServicesSetQuoteDesactiveRequest" />
|
114 |
-
<wsdl:output message="typens:ServicesSetQuoteDesactiveResponse" />
|
115 |
-
</wsdl:operation>
|
116 |
-
|
117 |
-
<wsdl:operation name="ServicesGenerateOrder">
|
118 |
-
<wsdl:documentation>Generate Order Magento</wsdl:documentation>
|
119 |
-
<wsdl:input message="typens:ServicesGenerateOrderRequest" />
|
120 |
-
<wsdl:output message="typens:ServicesGenerateOrderResponse" />
|
121 |
-
</wsdl:operation>
|
122 |
-
|
123 |
-
</wsdl:portType>
|
124 |
-
|
125 |
-
<wsdl:binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
|
126 |
-
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
|
127 |
-
|
128 |
-
<wsdl:operation name="ServicesSetStatusOrder">
|
129 |
-
<soap:operation soapAction="" />
|
130 |
-
<wsdl:input>
|
131 |
-
<soap:body use="literal" />
|
132 |
-
</wsdl:input>
|
133 |
-
<wsdl:output>
|
134 |
-
<soap:body use="literal" />
|
135 |
-
</wsdl:output>
|
136 |
-
</wsdl:operation>
|
137 |
-
|
138 |
-
<wsdl:operation name="ServicesSetQuoteDesactive">
|
139 |
-
<soap:operation soapAction="" />
|
140 |
-
<wsdl:input>
|
141 |
-
<soap:body use="literal" />
|
142 |
-
</wsdl:input>
|
143 |
-
<wsdl:output>
|
144 |
-
<soap:body use="literal" />
|
145 |
-
</wsdl:output>
|
146 |
-
</wsdl:operation>
|
147 |
-
|
148 |
-
<wsdl:operation name="ServicesGenerateOrder">
|
149 |
-
<soap:operation soapAction="" />
|
150 |
-
<wsdl:input>
|
151 |
-
<soap:body use="literal" />
|
152 |
-
</wsdl:input>
|
153 |
-
<wsdl:output>
|
154 |
-
<soap:body use="literal" />
|
155 |
-
</wsdl:output>
|
156 |
-
</wsdl:operation>
|
157 |
-
|
158 |
-
</wsdl:binding>
|
159 |
-
</wsdl:definitions>
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<wsdl:definitions xmlns:typens="urn:{{var wsdl.name}}"
|
3 |
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
4 |
+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
5 |
+
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
6 |
+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
7 |
+
name="{{var wsdl.name}}"
|
8 |
+
targetNamespace="urn:{{var wsdl.name}}">
|
9 |
+
<wsdl:types>
|
10 |
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:{{var wsdl.name}}">
|
11 |
+
|
12 |
+
|
13 |
+
<xsd:element name="servicesSetStatusOrderRequestParam">
|
14 |
+
<xsd:complexType>
|
15 |
+
<xsd:sequence>
|
16 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
|
17 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="orderIncrementId" type="xsd:string" />
|
18 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="status" type="xsd:string" />
|
19 |
+
</xsd:sequence>
|
20 |
+
</xsd:complexType>
|
21 |
+
</xsd:element>
|
22 |
+
<xsd:element name="servicesSetStatusOrderResponseParam">
|
23 |
+
<xsd:complexType>
|
24 |
+
<xsd:sequence>
|
25 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:boolean" />
|
26 |
+
</xsd:sequence>
|
27 |
+
</xsd:complexType>
|
28 |
+
</xsd:element>
|
29 |
+
|
30 |
+
|
31 |
+
<xsd:element name="servicesSetQuoteDesactiveRequestParam">
|
32 |
+
<xsd:complexType>
|
33 |
+
<xsd:sequence>
|
34 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
|
35 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="quoteId" type="xsd:int" />
|
36 |
+
</xsd:sequence>
|
37 |
+
</xsd:complexType>
|
38 |
+
</xsd:element>
|
39 |
+
<xsd:element name="servicesSetQuoteDesactiveResponseParam">
|
40 |
+
<xsd:complexType>
|
41 |
+
<xsd:sequence>
|
42 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:boolean" />
|
43 |
+
</xsd:sequence>
|
44 |
+
</xsd:complexType>
|
45 |
+
</xsd:element>
|
46 |
+
|
47 |
+
|
48 |
+
<xsd:element name="servicesGenerateOrderRequestParam">
|
49 |
+
<xsd:complexType>
|
50 |
+
<xsd:sequence>
|
51 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
|
52 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="IdCart" type="xsd:int" />
|
53 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="IdStore" type="xsd:string" />
|
54 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="CustomerName" type="xsd:string" />
|
55 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="CustomerLasName" type="xsd:string" />
|
56 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="CustomerEmail" type="xsd:string" />
|
57 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="CustomerAdresss" type="xsd:string" />
|
58 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="CustomerPhone" type="xsd:string" />
|
59 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="CustomerZipCode" type="xsd:string" />
|
60 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="CityName" type="xsd:string" />
|
61 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="CountryId" type="xsd:string" />
|
62 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="RegionId" type="xsd:string" />
|
63 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="RegionName" type="xsd:string" />
|
64 |
+
</xsd:sequence>
|
65 |
+
</xsd:complexType>
|
66 |
+
</xsd:element>
|
67 |
+
<xsd:element name="servicesGenerateOrderResponseParam">
|
68 |
+
<xsd:complexType>
|
69 |
+
<xsd:sequence>
|
70 |
+
<xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:string" />
|
71 |
+
</xsd:sequence>
|
72 |
+
</xsd:complexType>
|
73 |
+
</xsd:element>
|
74 |
+
|
75 |
+
|
76 |
+
</xsd:schema>
|
77 |
+
</wsdl:types>
|
78 |
+
|
79 |
+
|
80 |
+
<wsdl:message name="ServicesSetStatusOrderRequest">
|
81 |
+
<wsdl:part name="parameters" element="typens:servicesSetStatusOrderRequestParam" />
|
82 |
+
</wsdl:message>
|
83 |
+
<wsdl:message name="ServicesSetStatusOrderResponse">
|
84 |
+
<wsdl:part name="parameters" element="typens:servicesSetStatusOrderResponseParam" />
|
85 |
+
</wsdl:message>
|
86 |
+
|
87 |
+
<wsdl:message name="ServicesSetQuoteDesactiveRequest">
|
88 |
+
<wsdl:part name="parameters" element="typens:servicesSetQuoteDesactiveRequestParam" />
|
89 |
+
</wsdl:message>
|
90 |
+
<wsdl:message name="ServicesSetQuoteDesactiveResponse">
|
91 |
+
<wsdl:part name="parameters" element="typens:servicesSetQuoteDesactiveResponseParam" />
|
92 |
+
</wsdl:message>
|
93 |
+
|
94 |
+
<wsdl:message name="ServicesGenerateOrderRequest">
|
95 |
+
<wsdl:part name="parameters" element="typens:servicesGenerateOrderRequestParam" />
|
96 |
+
</wsdl:message>
|
97 |
+
<wsdl:message name="ServicesGenerateOrderResponse">
|
98 |
+
<wsdl:part name="parameters" element="typens:servicesGenerateOrderResponseParam" />
|
99 |
+
</wsdl:message>
|
100 |
+
|
101 |
+
|
102 |
+
<wsdl:portType name="{{var wsdl.handler}}PortType">
|
103 |
+
|
104 |
+
<wsdl:operation name="ServicesSetStatusOrder">
|
105 |
+
<wsdl:documentation>Service set status</wsdl:documentation>
|
106 |
+
<wsdl:input message="typens:ServicesSetStatusOrderRequest" />
|
107 |
+
<wsdl:output message="typens:ServicesSetStatusOrderResponse" />
|
108 |
+
</wsdl:operation>
|
109 |
+
|
110 |
+
|
111 |
+
<wsdl:operation name="ServicesSetQuoteDesactive">
|
112 |
+
<wsdl:documentation>Service desactive quote</wsdl:documentation>
|
113 |
+
<wsdl:input message="typens:ServicesSetQuoteDesactiveRequest" />
|
114 |
+
<wsdl:output message="typens:ServicesSetQuoteDesactiveResponse" />
|
115 |
+
</wsdl:operation>
|
116 |
+
|
117 |
+
<wsdl:operation name="ServicesGenerateOrder">
|
118 |
+
<wsdl:documentation>Generate Order Magento</wsdl:documentation>
|
119 |
+
<wsdl:input message="typens:ServicesGenerateOrderRequest" />
|
120 |
+
<wsdl:output message="typens:ServicesGenerateOrderResponse" />
|
121 |
+
</wsdl:operation>
|
122 |
+
|
123 |
+
</wsdl:portType>
|
124 |
+
|
125 |
+
<wsdl:binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
|
126 |
+
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
|
127 |
+
|
128 |
+
<wsdl:operation name="ServicesSetStatusOrder">
|
129 |
+
<soap:operation soapAction="" />
|
130 |
+
<wsdl:input>
|
131 |
+
<soap:body use="literal" />
|
132 |
+
</wsdl:input>
|
133 |
+
<wsdl:output>
|
134 |
+
<soap:body use="literal" />
|
135 |
+
</wsdl:output>
|
136 |
+
</wsdl:operation>
|
137 |
+
|
138 |
+
<wsdl:operation name="ServicesSetQuoteDesactive">
|
139 |
+
<soap:operation soapAction="" />
|
140 |
+
<wsdl:input>
|
141 |
+
<soap:body use="literal" />
|
142 |
+
</wsdl:input>
|
143 |
+
<wsdl:output>
|
144 |
+
<soap:body use="literal" />
|
145 |
+
</wsdl:output>
|
146 |
+
</wsdl:operation>
|
147 |
+
|
148 |
+
<wsdl:operation name="ServicesGenerateOrder">
|
149 |
+
<soap:operation soapAction="" />
|
150 |
+
<wsdl:input>
|
151 |
+
<soap:body use="literal" />
|
152 |
+
</wsdl:input>
|
153 |
+
<wsdl:output>
|
154 |
+
<soap:body use="literal" />
|
155 |
+
</wsdl:output>
|
156 |
+
</wsdl:operation>
|
157 |
+
|
158 |
+
</wsdl:binding>
|
159 |
+
</wsdl:definitions>
|
app/design/adminhtml/default/default/layout/skyboxcatalog.xml
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<layout version="0.1.0">
|
3 |
-
<default>
|
4 |
-
<reference name="head">
|
5 |
-
<action method="addJs"><script>skybox/adminhtml.category.js</script></action>
|
6 |
-
</reference>
|
7 |
-
</default>
|
8 |
</layout>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addJs"><script>skybox/adminhtml.category.js</script></action>
|
6 |
+
</reference>
|
7 |
+
</default>
|
8 |
</layout>
|
app/design/adminhtml/default/default/layout/skyboxinternational.xml
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<layout version="0.1.0">
|
3 |
-
<skyboxinternational_adminhtml_debug_index>
|
4 |
-
<reference name="content">
|
5 |
-
<block type="skyboxinternational/adminhtml_debug" name="skyboxinternational_debug_info" />
|
6 |
-
</reference>
|
7 |
-
</skyboxinternational_adminhtml_debug_index>
|
8 |
-
|
9 |
-
<adminhtml_sales_order_view>
|
10 |
-
<reference name="order_totals">
|
11 |
-
<block type="skyboxcheckout/sales_order_total" before="tax" />
|
12 |
-
</reference>
|
13 |
-
</adminhtml_sales_order_view>
|
14 |
-
|
15 |
</layout>
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<skyboxinternational_adminhtml_debug_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="skyboxinternational/adminhtml_debug" name="skyboxinternational_debug_info" />
|
6 |
+
</reference>
|
7 |
+
</skyboxinternational_adminhtml_debug_index>
|
8 |
+
|
9 |
+
<adminhtml_sales_order_view>
|
10 |
+
<reference name="order_totals">
|
11 |
+
<block type="skyboxcheckout/sales_order_total" before="tax" />
|
12 |
+
</reference>
|
13 |
+
</adminhtml_sales_order_view>
|
14 |
+
|
15 |
</layout>
|
app/design/frontend/base/default/layout/skyboxcheckout.xml
CHANGED
@@ -1,204 +1,204 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<layout version="0.1.0">
|
3 |
-
<skyboxcheckout_international_index>
|
4 |
-
<remove name="top.container"/>
|
5 |
-
<reference name="content">
|
6 |
-
<block type="core/template" name="skyboxcheckout.international.index"
|
7 |
-
template="skybox/checkout/skyboxcheckout.phtml"/>
|
8 |
-
</reference>
|
9 |
-
</skyboxcheckout_international_index>
|
10 |
-
<skyboxcheckout_international_success>
|
11 |
-
<reference name="content">
|
12 |
-
<block type="core/template" name="skyboxcheckout.international.index"
|
13 |
-
template="skybox/checkout/skyboxsuccess.phtml"/>
|
14 |
-
</reference>
|
15 |
-
</skyboxcheckout_international_success>
|
16 |
-
<checkout_onepage_index>
|
17 |
-
<reference name="checkout.onepage">
|
18 |
-
<!--
|
19 |
-
<action method="setTemplate"><template>skybox/checkout/onepage.phtml</template></action>
|
20 |
-
-->
|
21 |
-
<action method="setTemplate">
|
22 |
-
<template helper="checkout/data/getLayoutCheckoutSkybox"/>
|
23 |
-
</action>
|
24 |
-
<!-- Rogged -->
|
25 |
-
</reference>
|
26 |
-
</checkout_onepage_index>
|
27 |
-
<!--
|
28 |
-
Shopping cart item renderer
|
29 |
-
-->
|
30 |
-
<checkout_cart_index>
|
31 |
-
<remove name="top.container"/>
|
32 |
-
<reference name="checkout.cart.methods">
|
33 |
-
<block type="core/template" before="content" name="skybox.checkout.cart.methods.onepage.bottom"
|
34 |
-
template="skybox/checkout/onepage/link.phtml"/>
|
35 |
-
</reference>
|
36 |
-
|
37 |
-
<reference name="checkout.cart.shipping">
|
38 |
-
<action method="setTemplate">
|
39 |
-
<block type="checkout/cart_shipping" name="shippping" as="shippping" template="checkout/cart/shipping.phtml"/>
|
40 |
-
<template>skybox/checkout/cart/shipping.phtml</template>
|
41 |
-
</action>
|
42 |
-
</reference>
|
43 |
-
|
44 |
-
<reference name="checkout.cart.methods.multishipping">
|
45 |
-
<block type="checkout/multishipping_link" name="multishipping2" as="multishipping2" template="checkout/multishipping/link.phtml"/>
|
46 |
-
<action method="setTemplate">
|
47 |
-
<template>skybox/checkout/multishipping/link.phtml</template>
|
48 |
-
</action>
|
49 |
-
</reference>
|
50 |
-
|
51 |
-
<reference name="checkout.cart.sidebar">
|
52 |
-
<action method="setTemplate">
|
53 |
-
<template>skybox/checkout/cart/shipping.phtml</template>
|
54 |
-
</action>
|
55 |
-
</reference>
|
56 |
-
<!--
|
57 |
-
|
58 |
-
<reference name="checkout.cart">
|
59 |
-
|
60 |
-
<action method="setTemplate">
|
61 |
-
<template>skybox/checkout/cart_list.phtml</template>
|
62 |
-
</action>
|
63 |
-
|
64 |
-
<action method="setCartTemplate"><value>skybox/checkout/cart_list.phtml</value></action>
|
65 |
-
<action method="setEmptyTemplate"><value>checkout/cart/noItems.phtml</value></action>
|
66 |
-
<action method="chooseTemplate"/>
|
67 |
-
|
68 |
-
<action method="addItemRender">
|
69 |
-
<type>simple</type>
|
70 |
-
<block>checkout/cart_item_renderer</block>
|
71 |
-
<template>skybox/checkout/cart/item/default.phtml</template>
|
72 |
-
</action>
|
73 |
-
|
74 |
-
<action method="addItemRender">
|
75 |
-
<type>grouped</type>
|
76 |
-
<block>checkout/cart_item_renderer_grouped</block>
|
77 |
-
<template>skybox/checkout/cart/item/default.phtml</template>
|
78 |
-
</action>
|
79 |
-
|
80 |
-
<action method="addItemRender">
|
81 |
-
<type>configurable</type>
|
82 |
-
<block>checkout/cart_item_renderer_configurable</block>
|
83 |
-
<template>skybox/checkout/cart/item/default.phtml</template>
|
84 |
-
</action>
|
85 |
-
|
86 |
-
<action method="addItemRender">
|
87 |
-
<type>bundle</type>
|
88 |
-
<block>bundle/checkout_cart_item_renderer</block>
|
89 |
-
<template>skybox/checkout/cart/item/default.phtml</template>
|
90 |
-
</action>
|
91 |
-
|
92 |
-
</reference>
|
93 |
-
|
94 |
-
<reference name="checkout.cart.shipping">
|
95 |
-
<action method="setTemplate"><template>skybox/checkout/cart/shipping.phtml</template></action>
|
96 |
-
</reference>
|
97 |
-
|
98 |
-
<reference name="checkout.cart.sidebar">
|
99 |
-
<action method="setTemplate"><template>skybox/checkout/cart/shipping.phtml</template></action>
|
100 |
-
</reference>
|
101 |
-
-->
|
102 |
-
</checkout_cart_index>
|
103 |
-
<default>
|
104 |
-
<reference name="head">
|
105 |
-
<!--
|
106 |
-
<block type="directory/currency" name="custom_currency_selector" template="currency/currency.phtml"/>
|
107 |
-
-->
|
108 |
-
<action method="addJs" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
|
109 |
-
<script>prototype/window.js</script>
|
110 |
-
</action>
|
111 |
-
<action method="addJs" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
|
112 |
-
<script>prototype/debug.js</script>
|
113 |
-
</action>
|
114 |
-
<action method="addJs" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
|
115 |
-
<script>prototype/effects.js</script>
|
116 |
-
</action>
|
117 |
-
<action method="addItem" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
|
118 |
-
<type>js_css</type>
|
119 |
-
<name>prototype/windows/themes/default.css</name>
|
120 |
-
</action>
|
121 |
-
<action method="addItem" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
|
122 |
-
<type>js_css</type>
|
123 |
-
<name>prototype/windows/themes/alphacube.css</name>
|
124 |
-
</action>
|
125 |
-
<action method="addJs" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
|
126 |
-
<script>skybox/load-jquery.js</script>
|
127 |
-
</action>
|
128 |
-
<!-- jQuery ver. 1.7.2 -->
|
129 |
-
<!--
|
130 |
-
|
131 |
-
<action method="addJs"><script>skybox/jquery.min.js</script></action>
|
132 |
-
<action method="addJs"><script>skybox/jquery.ba-resize.min.js</script></action>
|
133 |
-
|
134 |
-
<block type="core/text" name="google.cdn.jquery">
|
135 |
-
<action method="setText">
|
136 |
-
<text><![CDATA[<script type="text/javascript">jQuery.noConflict();</script>]]></text>
|
137 |
-
</action>
|
138 |
-
</block>
|
139 |
-
|
140 |
-
-->
|
141 |
-
<!--
|
142 |
-
|
143 |
-
<block type="core/text" name="google.cdn.jquery">
|
144 |
-
<action method="setText">
|
145 |
-
<text><![CDATA[<script type="text/javascript">
|
146 |
-
if ( (typeof jQuery === 'undefined') && !window.jQuery ) {
|
147 |
-
document.write(unescape("%3Cscript type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'%3E%3C/script%3E"));
|
148 |
-
document.write(unescape("%3Cscript type='text/javascript'%3E%3C/script%3E jQuery.noConflict(); %3Cscript%3E%3C/script%3E"));
|
149 |
-
}</script>]]></text>
|
150 |
-
</action>
|
151 |
-
</block>
|
152 |
-
|
153 |
-
-->
|
154 |
-
<!--
|
155 |
-
<action method="addItem" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
|
156 |
-
-->
|
157 |
-
<!--
|
158 |
-
<type>skin_js</type><name>js/skybox/catalog.product.configurable.js</name>
|
159 |
-
-->
|
160 |
-
<!-- </action> -->
|
161 |
-
</reference>
|
162 |
-
<!--
|
163 |
-
|
164 |
-
<reference name="content">
|
165 |
-
<block type="core/template" name="skyboxcheckout.top.container.cart" before="-" template="skybox/checkout/cart.phtml"/>
|
166 |
-
</reference>
|
167 |
-
|
168 |
-
-->
|
169 |
-
<reference name="top.container">
|
170 |
-
<!-- <reference name="content"> -->
|
171 |
-
<block type="core/template" name="skyboxcheckout.top.container.cart">
|
172 |
-
<action method="setTemplate" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
|
173 |
-
<template>skybox/checkout/cart.phtml</template>
|
174 |
-
</action>
|
175 |
-
<action method="unsetData">
|
176 |
-
<key>cache_lifetime</key>
|
177 |
-
</action>
|
178 |
-
<action method="unsetData">
|
179 |
-
<key>cache_tags</key>
|
180 |
-
</action>
|
181 |
-
</block>
|
182 |
-
</reference>
|
183 |
-
<reference name="right">
|
184 |
-
<remove name="checkout/cart_sidebar"/>
|
185 |
-
<block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" before="-">
|
186 |
-
<action method="addItemRender">
|
187 |
-
<type>simple</type>
|
188 |
-
<block>checkout/cart_item_renderer</block>
|
189 |
-
<template>skybox/checkout/cart/sidebar/default.phtml</template>
|
190 |
-
</action>
|
191 |
-
<action method="addItemRender">
|
192 |
-
<type>grouped</type>
|
193 |
-
<block>checkout/cart_item_renderer_grouped</block>
|
194 |
-
<template>skybox/checkout/cart/sidebar/default.phtml</template>
|
195 |
-
</action>
|
196 |
-
<action method="addItemRender">
|
197 |
-
<type>configurable</type>
|
198 |
-
<block>checkout/cart_item_renderer_configurable</block>
|
199 |
-
<template>skybox/checkout/cart/sidebar/default.phtml</template>
|
200 |
-
</action>
|
201 |
-
</block>
|
202 |
-
</reference>
|
203 |
-
</default>
|
204 |
-
</layout>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<skyboxcheckout_international_index>
|
4 |
+
<remove name="top.container"/>
|
5 |
+
<reference name="content">
|
6 |
+
<block type="core/template" name="skyboxcheckout.international.index"
|
7 |
+
template="skybox/checkout/skyboxcheckout.phtml"/>
|
8 |
+
</reference>
|
9 |
+
</skyboxcheckout_international_index>
|
10 |
+
<skyboxcheckout_international_success>
|
11 |
+
<reference name="content">
|
12 |
+
<block type="core/template" name="skyboxcheckout.international.index"
|
13 |
+
template="skybox/checkout/skyboxsuccess.phtml"/>
|
14 |
+
</reference>
|
15 |
+
</skyboxcheckout_international_success>
|
16 |
+
<checkout_onepage_index>
|
17 |
+
<reference name="checkout.onepage">
|
18 |
+
<!--
|
19 |
+
<action method="setTemplate"><template>skybox/checkout/onepage.phtml</template></action>
|
20 |
+
-->
|
21 |
+
<action method="setTemplate">
|
22 |
+
<template helper="checkout/data/getLayoutCheckoutSkybox"/>
|
23 |
+
</action>
|
24 |
+
<!-- Rogged -->
|
25 |
+
</reference>
|
26 |
+
</checkout_onepage_index>
|
27 |
+
<!--
|
28 |
+
Shopping cart item renderer
|
29 |
+
-->
|
30 |
+
<checkout_cart_index>
|
31 |
+
<remove name="top.container"/>
|
32 |
+
<reference name="checkout.cart.methods">
|
33 |
+
<block type="core/template" before="content" name="skybox.checkout.cart.methods.onepage.bottom"
|
34 |
+
template="skybox/checkout/onepage/link.phtml"/>
|
35 |
+
</reference>
|
36 |
+
|
37 |
+
<reference name="checkout.cart.shipping">
|
38 |
+
<action method="setTemplate">
|
39 |
+
<block type="checkout/cart_shipping" name="shippping" as="shippping" template="checkout/cart/shipping.phtml"/>
|
40 |
+
<template>skybox/checkout/cart/shipping.phtml</template>
|
41 |
+
</action>
|
42 |
+
</reference>
|
43 |
+
|
44 |
+
<reference name="checkout.cart.methods.multishipping">
|
45 |
+
<block type="checkout/multishipping_link" name="multishipping2" as="multishipping2" template="checkout/multishipping/link.phtml"/>
|
46 |
+
<action method="setTemplate">
|
47 |
+
<template>skybox/checkout/multishipping/link.phtml</template>
|
48 |
+
</action>
|
49 |
+
</reference>
|
50 |
+
|
51 |
+
<reference name="checkout.cart.sidebar">
|
52 |
+
<action method="setTemplate">
|
53 |
+
<template>skybox/checkout/cart/shipping.phtml</template>
|
54 |
+
</action>
|
55 |
+
</reference>
|
56 |
+
<!--
|
57 |
+
|
58 |
+
<reference name="checkout.cart">
|
59 |
+
|
60 |
+
<action method="setTemplate">
|
61 |
+
<template>skybox/checkout/cart_list.phtml</template>
|
62 |
+
</action>
|
63 |
+
|
64 |
+
<action method="setCartTemplate"><value>skybox/checkout/cart_list.phtml</value></action>
|
65 |
+
<action method="setEmptyTemplate"><value>checkout/cart/noItems.phtml</value></action>
|
66 |
+
<action method="chooseTemplate"/>
|
67 |
+
|
68 |
+
<action method="addItemRender">
|
69 |
+
<type>simple</type>
|
70 |
+
<block>checkout/cart_item_renderer</block>
|
71 |
+
<template>skybox/checkout/cart/item/default.phtml</template>
|
72 |
+
</action>
|
73 |
+
|
74 |
+
<action method="addItemRender">
|
75 |
+
<type>grouped</type>
|
76 |
+
<block>checkout/cart_item_renderer_grouped</block>
|
77 |
+
<template>skybox/checkout/cart/item/default.phtml</template>
|
78 |
+
</action>
|
79 |
+
|
80 |
+
<action method="addItemRender">
|
81 |
+
<type>configurable</type>
|
82 |
+
<block>checkout/cart_item_renderer_configurable</block>
|
83 |
+
<template>skybox/checkout/cart/item/default.phtml</template>
|
84 |
+
</action>
|
85 |
+
|
86 |
+
<action method="addItemRender">
|
87 |
+
<type>bundle</type>
|
88 |
+
<block>bundle/checkout_cart_item_renderer</block>
|
89 |
+
<template>skybox/checkout/cart/item/default.phtml</template>
|
90 |
+
</action>
|
91 |
+
|
92 |
+
</reference>
|
93 |
+
|
94 |
+
<reference name="checkout.cart.shipping">
|
95 |
+
<action method="setTemplate"><template>skybox/checkout/cart/shipping.phtml</template></action>
|
96 |
+
</reference>
|
97 |
+
|
98 |
+
<reference name="checkout.cart.sidebar">
|
99 |
+
<action method="setTemplate"><template>skybox/checkout/cart/shipping.phtml</template></action>
|
100 |
+
</reference>
|
101 |
+
-->
|
102 |
+
</checkout_cart_index>
|
103 |
+
<default>
|
104 |
+
<reference name="head">
|
105 |
+
<!--
|
106 |
+
<block type="directory/currency" name="custom_currency_selector" template="currency/currency.phtml"/>
|
107 |
+
-->
|
108 |
+
<action method="addJs" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
|
109 |
+
<script>prototype/window.js</script>
|
110 |
+
</action>
|
111 |
+
<action method="addJs" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
|
112 |
+
<script>prototype/debug.js</script>
|
113 |
+
</action>
|
114 |
+
<action method="addJs" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
|
115 |
+
<script>prototype/effects.js</script>
|
116 |
+
</action>
|
117 |
+
<action method="addItem" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
|
118 |
+
<type>js_css</type>
|
119 |
+
<name>prototype/windows/themes/default.css</name>
|
120 |
+
</action>
|
121 |
+
<action method="addItem" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
|
122 |
+
<type>js_css</type>
|
123 |
+
<name>prototype/windows/themes/alphacube.css</name>
|
124 |
+
</action>
|
125 |
+
<action method="addJs" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
|
126 |
+
<script>skybox/load-jquery.js</script>
|
127 |
+
</action>
|
128 |
+
<!-- jQuery ver. 1.7.2 -->
|
129 |
+
<!--
|
130 |
+
|
131 |
+
<action method="addJs"><script>skybox/jquery.min.js</script></action>
|
132 |
+
<action method="addJs"><script>skybox/jquery.ba-resize.min.js</script></action>
|
133 |
+
|
134 |
+
<block type="core/text" name="google.cdn.jquery">
|
135 |
+
<action method="setText">
|
136 |
+
<text><![CDATA[<script type="text/javascript">jQuery.noConflict();</script>]]></text>
|
137 |
+
</action>
|
138 |
+
</block>
|
139 |
+
|
140 |
+
-->
|
141 |
+
<!--
|
142 |
+
|
143 |
+
<block type="core/text" name="google.cdn.jquery">
|
144 |
+
<action method="setText">
|
145 |
+
<text><![CDATA[<script type="text/javascript">
|
146 |
+
if ( (typeof jQuery === 'undefined') && !window.jQuery ) {
|
147 |
+
document.write(unescape("%3Cscript type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'%3E%3C/script%3E"));
|
148 |
+
document.write(unescape("%3Cscript type='text/javascript'%3E%3C/script%3E jQuery.noConflict(); %3Cscript%3E%3C/script%3E"));
|
149 |
+
}</script>]]></text>
|
150 |
+
</action>
|
151 |
+
</block>
|
152 |
+
|
153 |
+
-->
|
154 |
+
<!--
|
155 |
+
<action method="addItem" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
|
156 |
+
-->
|
157 |
+
<!--
|
158 |
+
<type>skin_js</type><name>js/skybox/catalog.product.configurable.js</name>
|
159 |
+
-->
|
160 |
+
<!-- </action> -->
|
161 |
+
</reference>
|
162 |
+
<!--
|
163 |
+
|
164 |
+
<reference name="content">
|
165 |
+
<block type="core/template" name="skyboxcheckout.top.container.cart" before="-" template="skybox/checkout/cart.phtml"/>
|
166 |
+
</reference>
|
167 |
+
|
168 |
+
-->
|
169 |
+
<reference name="top.container">
|
170 |
+
<!-- <reference name="content"> -->
|
171 |
+
<block type="core/template" name="skyboxcheckout.top.container.cart">
|
172 |
+
<action method="setTemplate" ifconfig="skyboxinternational/skyboxsettings/skyboxactive">
|
173 |
+
<template>skybox/checkout/cart.phtml</template>
|
174 |
+
</action>
|
175 |
+
<action method="unsetData">
|
176 |
+
<key>cache_lifetime</key>
|
177 |
+
</action>
|
178 |
+
<action method="unsetData">
|
179 |
+
<key>cache_tags</key>
|
180 |
+
</action>
|
181 |
+
</block>
|
182 |
+
</reference>
|
183 |
+
<reference name="right">
|
184 |
+
<remove name="checkout/cart_sidebar"/>
|
185 |
+
<block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" before="-">
|
186 |
+
<action method="addItemRender">
|
187 |
+
<type>simple</type>
|
188 |
+
<block>checkout/cart_item_renderer</block>
|
189 |
+
<template>skybox/checkout/cart/sidebar/default.phtml</template>
|
190 |
+
</action>
|
191 |
+
<action method="addItemRender">
|
192 |
+
<type>grouped</type>
|
193 |
+
<block>checkout/cart_item_renderer_grouped</block>
|
194 |
+
<template>skybox/checkout/cart/sidebar/default.phtml</template>
|
195 |
+
</action>
|
196 |
+
<action method="addItemRender">
|
197 |
+
<type>configurable</type>
|
198 |
+
<block>checkout/cart_item_renderer_configurable</block>
|
199 |
+
<template>skybox/checkout/cart/sidebar/default.phtml</template>
|
200 |
+
</action>
|
201 |
+
</block>
|
202 |
+
</reference>
|
203 |
+
</default>
|
204 |
+
</layout>
|
app/design/frontend/base/default/template/skybox/checkout/cart.phtml
CHANGED
@@ -1,177 +1,177 @@
|
|
1 |
-
<?php
|
2 |
-
/** @var Skybox_International_Helper_Data $_helper */
|
3 |
-
$_helper = Mage::helper('skyboxinternational/data');
|
4 |
-
|
5 |
-
if ($_helper->getActive()) {
|
6 |
-
|
7 |
-
/** @var Skybox_Core_Model_Config $_config */
|
8 |
-
$_config = Mage::getModel('skyboxcore/config');
|
9 |
-
|
10 |
-
/** @var Skybox_Checkout_Model_Api_Checkout $_checkout */
|
11 |
-
$_checkout = Mage::getModel('skyboxcheckout/api_checkout');
|
12 |
-
|
13 |
-
/** @var Skybox_Core_Helper_Allow $allowHelper */
|
14 |
-
$allowHelper = Mage::helper('skyboxcore/allow');
|
15 |
-
|
16 |
-
$_cartDataURL = "";
|
17 |
-
$_merchant = $_helper->getMerchantCode();
|
18 |
-
$template = "";
|
19 |
-
$cartId = $_helper->getCartId();
|
20 |
-
$cssVersion= $_helper->getCssVersion();
|
21 |
-
|
22 |
-
$_checkout->InitializeBarSkybox();
|
23 |
-
|
24 |
-
$change_country = false;
|
25 |
-
|
26 |
-
// $request = $this->getRequest();
|
27 |
-
// $module = $request->getModuleName();
|
28 |
-
// $controller = $request->getControllerName();
|
29 |
-
// $action = $request->getActionName();
|
30 |
-
$getHomeUrl = Mage::helper('core/url')->getHomeUrl();
|
31 |
-
$urlCheckCart = Mage::getUrl("checkout/cart");
|
32 |
-
|
33 |
-
$cart = $_config->getSession()->getCartSkybox();
|
34 |
-
|
35 |
-
// Load CSS & JS
|
36 |
-
$skybox_url = $_helper->getSkyboxUrlMain();// $_config->skyboxDefaultUrl;
|
37 |
-
$api_css_button_international = $skybox_url . 'widgets/api-button/css/api-button-international-css.ashx';
|
38 |
-
$api_css_button_international .= '?s=' . $_merchant;
|
39 |
-
$api_css_button_international .= '&CssVersion=' . $cssVersion;
|
40 |
-
$api_js_button_international = $skybox_url . 'Content/debug/API/js/api-button-tooltip.js';
|
41 |
-
$countryChange = 0;
|
42 |
-
|
43 |
-
if ($allowHelper->isCartBarEnabled()) :
|
44 |
-
$countryChange = 1;
|
45 |
-
$template = '';
|
46 |
-
// $cart = $_config->getSession()->getCartSkybox();
|
47 |
-
if (!empty($cart)) :
|
48 |
-
$template = $cart->BarHtmlTemplate;
|
49 |
-
foreach ($cart as $key => $value) :
|
50 |
-
$template = str_replace('{' . $key . '}', $value, $template);
|
51 |
-
endforeach;
|
52 |
-
endif;
|
53 |
-
$_cartDataURL = $cart->CartDataURL;
|
54 |
-
echo $template;
|
55 |
-
endif;
|
56 |
-
|
57 |
-
if ($allowHelper->isChangeCountryEnabled()):
|
58 |
-
// $cart = $_config->getSession()->getCartSkybox();
|
59 |
-
$template = "<div class='main-container' style='padding: 10px 0 0;text-align: right;'>";
|
60 |
-
$template .= "<div class='change_country'>";
|
61 |
-
$template .= "<a class='skx_position_option_country' href='javascript:;'>Change country</a>";
|
62 |
-
$template .= "</div>";
|
63 |
-
$template .= "</div>";
|
64 |
-
$change_country = true;
|
65 |
-
$countryChange = 0;
|
66 |
-
$_cartDataURL = $cart->CartDataURL;
|
67 |
-
echo $template;
|
68 |
-
endif;
|
69 |
-
|
70 |
-
if ($allowHelper->isPriceEnabled()) {
|
71 |
-
$productConfigurable = $this->getSkinUrl('js/skybox/catalog.product.configurable.js');
|
72 |
-
echo '<script type="text/javascript" src="' . $productConfigurable . '"></script>';
|
73 |
-
}
|
74 |
-
|
75 |
-
$skyBoxUrlClientBase = $_helper->getSkyBoxUrlAPI();
|
76 |
-
$storeCode = Mage::getModel('skyboxcatalog/api_product')->getStoreCode();
|
77 |
-
$skyBoxUrlClientGet = str_replace("apirest/", "", $skyBoxUrlClientBase);
|
78 |
-
$skyBoxUrlClient = $skyBoxUrlClientGet . "multiplecalculate/" . $storeCode . "/calc-";
|
79 |
-
$skyboxForceReload = intval(Mage::getBlockSingleton('page/html_header')->getIsHomePage());
|
80 |
-
?>
|
81 |
-
|
82 |
-
<link rel="stylesheet" type="text/css" href="<?php echo $api_css_button_international; ?>"/>
|
83 |
-
<link rel="stylesheet" type="text/css"
|
84 |
-
href="<?php echo $this->getSkinUrl('css/skybox/style.css?v=' . $cssVersion); ?>"/>
|
85 |
-
<script type="text/javascript">
|
86 |
-
var URL_CHECK_CART = "<?php echo $urlCheckCart ?>";
|
87 |
-
var CART_ID = "<?php echo $cartId ?>";
|
88 |
-
var CART_DATA_URL_SKYBOX = "<?php echo $_cartDataURL ?>";
|
89 |
-
var MERCHANT_ID_SKYBOX = "<?php echo $_merchant ?>";
|
90 |
-
var SKYBOX_URL = "<?php echo $skybox_url ?>";
|
91 |
-
var CHANGE_COUNTRY = "<?php echo $change_country ?>";
|
92 |
-
var ACTUAL_URI = "<?php echo 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'] ?>";
|
93 |
-
var GET_HOME_URL = "<?php echo $getHomeUrl ?>";
|
94 |
-
var COUNTRY_CHANGE = "<?php echo $countryChange?>";
|
95 |
-
var IS_SKYBOX_VISIBLE = "<?php echo $_checkout->getLocationAllow(); ?>";
|
96 |
-
var URL_BASE_MAGENTO = "<?php echo Mage::getBaseUrl() ?>";
|
97 |
-
var IS_REGISTRATION_DISABLED_SKYBOX = 1;
|
98 |
-
var SKYBOX_FORCE_RELOAD = "<?php echo $skyboxForceReload; ?>";
|
99 |
-
var LOADING_IMAGE = "<?php echo $this->getSkinUrl('images/skybox/ajax-loading.gif')?>";
|
100 |
-
|
101 |
-
(function ($) {
|
102 |
-
$(document).ready(function () {
|
103 |
-
if (typeof $.fancybox !== "function") {
|
104 |
-
var fileref = document.createElement("link");
|
105 |
-
fileref.rel = "stylesheet";
|
106 |
-
fileref.type = "text/css";
|
107 |
-
fileref.href = "<?php echo $this->getSkinUrl('css/skybox/jquery.fancybox.css');?>";
|
108 |
-
document.getElementsByTagName("head")[0].appendChild(fileref);
|
109 |
-
$('head').append($('<script />').attr('src', '<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'js/skybox/jquery.fancybox.js'; ?>'));
|
110 |
-
}
|
111 |
-
$(".skybox-price-set").each(function (index) {
|
112 |
-
var SkyBoxUrlClient = "<?php echo $skyBoxUrlClient;?>";
|
113 |
-
var dataId = $(this).attr("id");
|
114 |
-
var id = $(this).attr("product-id");
|
115 |
-
var url = SkyBoxUrlClient + id + ".html";
|
116 |
-
var content = $.get(url, function (data) {
|
117 |
-
$("#" + dataId).html(data);
|
118 |
-
});
|
119 |
-
});
|
120 |
-
});
|
121 |
-
})(jQuery);
|
122 |
-
</script>
|
123 |
-
<script src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'js/skybox/main.js'; ?>"></script>
|
124 |
-
<script type="text/javascript">
|
125 |
-
//<![CDATA[
|
126 |
-
var SKYBOX_OPTIONS_PRICE_URL = '<?php echo Mage::getUrl("skbcheckout/calculate"); ?>';
|
127 |
-
//]]>
|
128 |
-
</script>
|
129 |
-
<script type="text/javascript" src="<?php echo $api_js_button_international; ?>"></script>
|
130 |
-
<?php
|
131 |
-
// note: Just to force reload page on Home Page.
|
132 |
-
$forceReload = $_config->getSession()->getChangeCountryHomePage();
|
133 |
-
$forceReload = isset($forceReload) ? $forceReload : 0;
|
134 |
-
|
135 |
-
// if (Mage::getBlockSingleton('page/html_header')->getIsHomePage()) :
|
136 |
-
if ($skyboxForceReload):
|
137 |
-
if ($forceReload == 1):
|
138 |
-
$forceReload = 0;
|
139 |
-
$_config->getSession()->setChangeCountryHomePage($forceReload);
|
140 |
-
?>
|
141 |
-
<script type="text/javascript">
|
142 |
-
console.log("[Skybox] Reloading page...");
|
143 |
-
// window.location.reload(true);
|
144 |
-
</script>
|
145 |
-
<?php
|
146 |
-
endif;
|
147 |
-
endif;
|
148 |
-
?>
|
149 |
-
<script>
|
150 |
-
setTimeout(function () {
|
151 |
-
jQuery("a[href='#'].skx-bar-other").attr('href', 'javascript:;');
|
152 |
-
var country_change = "<?php echo $countryChange?>";
|
153 |
-
if (parseInt(country_change) === 1) {
|
154 |
-
var currencyISO_ = document.getElementsByClassName('skx_banner_label_currencyISO');
|
155 |
-
if (currencyISO_.length > 1) {
|
156 |
-
var nextSiblingOne = currencyISO_[0].nextElementSibling;
|
157 |
-
var getAttrNextSiblingOne = nextSiblingOne.getAttribute('class');
|
158 |
-
var nextSiblingLast = currencyISO_[1].nextElementSibling;
|
159 |
-
nextSiblingLast.setAttribute('class', getAttrNextSiblingOne);
|
160 |
-
currencyISO_[1].innerHTML = currencyISO_[0].innerHTML;
|
161 |
-
}
|
162 |
-
} else {
|
163 |
-
var optCountry = document.getElementsByClassName('skx_position_option_country');
|
164 |
-
if (optCountry.length > 1) {
|
165 |
-
optCountry[1].innerHTML = optCountry[0].innerText;
|
166 |
-
try {
|
167 |
-
document.getElementById('l_checkout_view_account').style.display = 'none';
|
168 |
-
} catch (e) {
|
169 |
-
|
170 |
-
}
|
171 |
-
}
|
172 |
-
}
|
173 |
-
}, 500);
|
174 |
-
</script>
|
175 |
-
<?php
|
176 |
-
}
|
177 |
-
?>
|
1 |
+
<?php
|
2 |
+
/** @var Skybox_International_Helper_Data $_helper */
|
3 |
+
$_helper = Mage::helper('skyboxinternational/data');
|
4 |
+
|
5 |
+
if ($_helper->getActive()) {
|
6 |
+
|
7 |
+
/** @var Skybox_Core_Model_Config $_config */
|
8 |
+
$_config = Mage::getModel('skyboxcore/config');
|
9 |
+
|
10 |
+
/** @var Skybox_Checkout_Model_Api_Checkout $_checkout */
|
11 |
+
$_checkout = Mage::getModel('skyboxcheckout/api_checkout');
|
12 |
+
|
13 |
+
/** @var Skybox_Core_Helper_Allow $allowHelper */
|
14 |
+
$allowHelper = Mage::helper('skyboxcore/allow');
|
15 |
+
|
16 |
+
$_cartDataURL = "";
|
17 |
+
$_merchant = $_helper->getMerchantCode();
|
18 |
+
$template = "";
|
19 |
+
$cartId = $_helper->getCartId();
|
20 |
+
$cssVersion= $_helper->getCssVersion();
|
21 |
+
|
22 |
+
$_checkout->InitializeBarSkybox();
|
23 |
+
|
24 |
+
$change_country = false;
|
25 |
+
|
26 |
+
// $request = $this->getRequest();
|
27 |
+
// $module = $request->getModuleName();
|
28 |
+
// $controller = $request->getControllerName();
|
29 |
+
// $action = $request->getActionName();
|
30 |
+
$getHomeUrl = Mage::helper('core/url')->getHomeUrl();
|
31 |
+
$urlCheckCart = Mage::getUrl("checkout/cart");
|
32 |
+
|
33 |
+
$cart = $_config->getSession()->getCartSkybox();
|
34 |
+
|
35 |
+
// Load CSS & JS
|
36 |
+
$skybox_url = $_helper->getSkyboxUrlMain();// $_config->skyboxDefaultUrl;
|
37 |
+
$api_css_button_international = $skybox_url . 'widgets/api-button/css/api-button-international-css.ashx';
|
38 |
+
$api_css_button_international .= '?s=' . $_merchant;
|
39 |
+
$api_css_button_international .= '&CssVersion=' . $cssVersion;
|
40 |
+
$api_js_button_international = $skybox_url . 'Content/debug/API/js/api-button-tooltip.js';
|
41 |
+
$countryChange = 0;
|
42 |
+
|
43 |
+
if ($allowHelper->isCartBarEnabled()) :
|
44 |
+
$countryChange = 1;
|
45 |
+
$template = '';
|
46 |
+
// $cart = $_config->getSession()->getCartSkybox();
|
47 |
+
if (!empty($cart)) :
|
48 |
+
$template = $cart->BarHtmlTemplate;
|
49 |
+
foreach ($cart as $key => $value) :
|
50 |
+
$template = str_replace('{' . $key . '}', $value, $template);
|
51 |
+
endforeach;
|
52 |
+
endif;
|
53 |
+
$_cartDataURL = $cart->CartDataURL;
|
54 |
+
echo $template;
|
55 |
+
endif;
|
56 |
+
|
57 |
+
if ($allowHelper->isChangeCountryEnabled()):
|
58 |
+
// $cart = $_config->getSession()->getCartSkybox();
|
59 |
+
$template = "<div class='main-container' style='padding: 10px 0 0;text-align: right;'>";
|
60 |
+
$template .= "<div class='change_country'>";
|
61 |
+
$template .= "<a class='skx_position_option_country' href='javascript:;'>Change country</a>";
|
62 |
+
$template .= "</div>";
|
63 |
+
$template .= "</div>";
|
64 |
+
$change_country = true;
|
65 |
+
$countryChange = 0;
|
66 |
+
$_cartDataURL = $cart->CartDataURL;
|
67 |
+
echo $template;
|
68 |
+
endif;
|
69 |
+
|
70 |
+
if ($allowHelper->isPriceEnabled()) {
|
71 |
+
$productConfigurable = $this->getSkinUrl('js/skybox/catalog.product.configurable.js');
|
72 |
+
echo '<script type="text/javascript" src="' . $productConfigurable . '"></script>';
|
73 |
+
}
|
74 |
+
|
75 |
+
$skyBoxUrlClientBase = $_helper->getSkyBoxUrlAPI();
|
76 |
+
$storeCode = Mage::getModel('skyboxcatalog/api_product')->getStoreCode();
|
77 |
+
$skyBoxUrlClientGet = str_replace("apirest/", "", $skyBoxUrlClientBase);
|
78 |
+
$skyBoxUrlClient = $skyBoxUrlClientGet . "multiplecalculate/" . $storeCode . "/calc-";
|
79 |
+
$skyboxForceReload = intval(Mage::getBlockSingleton('page/html_header')->getIsHomePage());
|
80 |
+
?>
|
81 |
+
|
82 |
+
<link rel="stylesheet" type="text/css" href="<?php echo $api_css_button_international; ?>"/>
|
83 |
+
<link rel="stylesheet" type="text/css"
|
84 |
+
href="<?php echo $this->getSkinUrl('css/skybox/style.css?v=' . $cssVersion); ?>"/>
|
85 |
+
<script type="text/javascript">
|
86 |
+
var URL_CHECK_CART = "<?php echo $urlCheckCart ?>";
|
87 |
+
var CART_ID = "<?php echo $cartId ?>";
|
88 |
+
var CART_DATA_URL_SKYBOX = "<?php echo $_cartDataURL ?>";
|
89 |
+
var MERCHANT_ID_SKYBOX = "<?php echo $_merchant ?>";
|
90 |
+
var SKYBOX_URL = "<?php echo $skybox_url ?>";
|
91 |
+
var CHANGE_COUNTRY = "<?php echo $change_country ?>";
|
92 |
+
var ACTUAL_URI = "<?php echo 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'] ?>";
|
93 |
+
var GET_HOME_URL = "<?php echo $getHomeUrl ?>";
|
94 |
+
var COUNTRY_CHANGE = "<?php echo $countryChange?>";
|
95 |
+
var IS_SKYBOX_VISIBLE = "<?php echo $_checkout->getLocationAllow(); ?>";
|
96 |
+
var URL_BASE_MAGENTO = "<?php echo Mage::getBaseUrl() ?>";
|
97 |
+
var IS_REGISTRATION_DISABLED_SKYBOX = 1;
|
98 |
+
var SKYBOX_FORCE_RELOAD = "<?php echo $skyboxForceReload; ?>";
|
99 |
+
var LOADING_IMAGE = "<?php echo $this->getSkinUrl('images/skybox/ajax-loading.gif')?>";
|
100 |
+
|
101 |
+
(function ($) {
|
102 |
+
$(document).ready(function () {
|
103 |
+
if (typeof $.fancybox !== "function") {
|
104 |
+
var fileref = document.createElement("link");
|
105 |
+
fileref.rel = "stylesheet";
|
106 |
+
fileref.type = "text/css";
|
107 |
+
fileref.href = "<?php echo $this->getSkinUrl('css/skybox/jquery.fancybox.css');?>";
|
108 |
+
document.getElementsByTagName("head")[0].appendChild(fileref);
|
109 |
+
$('head').append($('<script />').attr('src', '<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'js/skybox/jquery.fancybox.js'; ?>'));
|
110 |
+
}
|
111 |
+
$(".skybox-price-set").each(function (index) {
|
112 |
+
var SkyBoxUrlClient = "<?php echo $skyBoxUrlClient;?>";
|
113 |
+
var dataId = $(this).attr("id");
|
114 |
+
var id = $(this).attr("product-id");
|
115 |
+
var url = SkyBoxUrlClient + id + ".html";
|
116 |
+
var content = $.get(url, function (data) {
|
117 |
+
$("#" + dataId).html(data);
|
118 |
+
});
|
119 |
+
});
|
120 |
+
});
|
121 |
+
})(jQuery);
|
122 |
+
</script>
|
123 |
+
<script src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'js/skybox/main.js'; ?>"></script>
|
124 |
+
<script type="text/javascript">
|
125 |
+
//<![CDATA[
|
126 |
+
var SKYBOX_OPTIONS_PRICE_URL = '<?php echo Mage::getUrl("skbcheckout/calculate"); ?>';
|
127 |
+
//]]>
|
128 |
+
</script>
|
129 |
+
<script type="text/javascript" src="<?php echo $api_js_button_international; ?>"></script>
|
130 |
+
<?php
|
131 |
+
// note: Just to force reload page on Home Page.
|
132 |
+
$forceReload = $_config->getSession()->getChangeCountryHomePage();
|
133 |
+
$forceReload = isset($forceReload) ? $forceReload : 0;
|
134 |
+
|
135 |
+
// if (Mage::getBlockSingleton('page/html_header')->getIsHomePage()) :
|
136 |
+
if ($skyboxForceReload):
|
137 |
+
if ($forceReload == 1):
|
138 |
+
$forceReload = 0;
|
139 |
+
$_config->getSession()->setChangeCountryHomePage($forceReload);
|
140 |
+
?>
|
141 |
+
<script type="text/javascript">
|
142 |
+
console.log("[Skybox] Reloading page...");
|
143 |
+
// window.location.reload(true);
|
144 |
+
</script>
|
145 |
+
<?php
|
146 |
+
endif;
|
147 |
+
endif;
|
148 |
+
?>
|
149 |
+
<script>
|
150 |
+
setTimeout(function () {
|
151 |
+
jQuery("a[href='#'].skx-bar-other").attr('href', 'javascript:;');
|
152 |
+
var country_change = "<?php echo $countryChange?>";
|
153 |
+
if (parseInt(country_change) === 1) {
|
154 |
+
var currencyISO_ = document.getElementsByClassName('skx_banner_label_currencyISO');
|
155 |
+
if (currencyISO_.length > 1) {
|
156 |
+
var nextSiblingOne = currencyISO_[0].nextElementSibling;
|
157 |
+
var getAttrNextSiblingOne = nextSiblingOne.getAttribute('class');
|
158 |
+
var nextSiblingLast = currencyISO_[1].nextElementSibling;
|
159 |
+
nextSiblingLast.setAttribute('class', getAttrNextSiblingOne);
|
160 |
+
currencyISO_[1].innerHTML = currencyISO_[0].innerHTML;
|
161 |
+
}
|
162 |
+
} else {
|
163 |
+
var optCountry = document.getElementsByClassName('skx_position_option_country');
|
164 |
+
if (optCountry.length > 1) {
|
165 |
+
optCountry[1].innerHTML = optCountry[0].innerText;
|
166 |
+
try {
|
167 |
+
document.getElementById('l_checkout_view_account').style.display = 'none';
|
168 |
+
} catch (e) {
|
169 |
+
|
170 |
+
}
|
171 |
+
}
|
172 |
+
}
|
173 |
+
}, 500);
|
174 |
+
</script>
|
175 |
+
<?php
|
176 |
+
}
|
177 |
+
?>
|
app/design/frontend/base/default/template/skybox/checkout/cart/item/default.phtml
CHANGED
@@ -1,294 +1,294 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/afl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category design
|
22 |
-
* @package base_default
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
-
*/
|
26 |
-
?>
|
27 |
-
<?php
|
28 |
-
$_item = $this->getItem();
|
29 |
-
$isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility();
|
30 |
-
$canApplyMsrp = Mage::helper('catalog')->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM);
|
31 |
-
?>
|
32 |
-
<tr>
|
33 |
-
<td><?php if ($this->hasProductUrl()):?><a href="<?php echo $this->getProductUrl() ?>" title="<?php echo $this->escapeHtml($this->getProductName()) ?>" class="product-image"><?php endif;?><img src="<?php echo $this->getProductThumbnail()->resize(75); ?>" width="75" height="75" alt="<?php echo $this->escapeHtml($this->getProductName()) ?>" /><?php if ($this->hasProductUrl()):?></a><?php endif;?></td>
|
34 |
-
<td>
|
35 |
-
<h2 class="product-name">
|
36 |
-
<?php if ($this->hasProductUrl()):?>
|
37 |
-
<a href="<?php echo $this->getProductUrl() ?>"><?php echo $this->escapeHtml($this->getProductName()) ?></a>
|
38 |
-
<?php else: ?>
|
39 |
-
<?php echo $this->escapeHtml($this->getProductName()) ?>
|
40 |
-
<?php endif; ?>
|
41 |
-
</h2>
|
42 |
-
<?php if ($_options = $this->getOptionList()):?>
|
43 |
-
<dl class="item-options">
|
44 |
-
<?php foreach ($_options as $_option) : ?>
|
45 |
-
<?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
|
46 |
-
<dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
|
47 |
-
<dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
|
48 |
-
<?php if (isset($_formatedOptionValue['full_view'])): ?>
|
49 |
-
<div class="truncated_full_value">
|
50 |
-
<dl class="item-options">
|
51 |
-
<dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
|
52 |
-
<dd><?php echo $_formatedOptionValue['full_view'] ?></dd>
|
53 |
-
</dl>
|
54 |
-
</div>
|
55 |
-
<?php endif; ?>
|
56 |
-
</dd>
|
57 |
-
<?php endforeach; ?>
|
58 |
-
</dl>
|
59 |
-
<?php endif;?>
|
60 |
-
<?php if ($messages = $this->getMessages()): ?>
|
61 |
-
<?php foreach ($messages as $message): ?>
|
62 |
-
<p class="item-msg <?php echo $message['type'] ?>">* <?php echo $this->escapeHtml($message['text']) ?></p>
|
63 |
-
<?php endforeach; ?>
|
64 |
-
<?php endif; ?>
|
65 |
-
<?php $addInfoBlock = $this->getProductAdditionalInformationBlock(); ?>
|
66 |
-
<?php if ($addInfoBlock): ?>
|
67 |
-
<?php echo $addInfoBlock->setItem($_item)->toHtml() ?>
|
68 |
-
<?php endif;?>
|
69 |
-
</td>
|
70 |
-
<td class="a-center">
|
71 |
-
<?php if ($isVisibleProduct): ?>
|
72 |
-
<a href="<?php echo $this->getConfigureUrl() ?>" title="<?php echo $this->__('Edit item parameters') ?>"><?php echo $this->__('Edit') ?></a>
|
73 |
-
<?php endif ?>
|
74 |
-
</td>
|
75 |
-
<?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
|
76 |
-
<td class="a-center">
|
77 |
-
<?php if ($isVisibleProduct): ?>
|
78 |
-
<a href="<?php echo $this->helper('wishlist')->getMoveFromCartUrl($_item->getId()); ?>" class="link-wishlist use-ajax"><?php echo $this->__('Move'); ?></a>
|
79 |
-
<?php endif ?>
|
80 |
-
</td>
|
81 |
-
<?php endif ?>
|
82 |
-
|
83 |
-
<?php if ($canApplyMsrp): ?>
|
84 |
-
<td class="a-right"<?php if ($this->helper('tax')->displayCartBothPrices()): ?> colspan="2"<?php endif; ?>>
|
85 |
-
<span class="cart-price">
|
86 |
-
<span class="cart-msrp-unit"><?php echo $this->__('See price before order confirmation.'); ?></span>
|
87 |
-
<?php $helpLinkId = 'cart-msrp-help-' . $_item->getId(); ?>
|
88 |
-
<a id="<?php echo $helpLinkId ?>" href="#" class="map-help-link"><?php echo $this->__("What's this?"); ?></a>
|
89 |
-
<script type="text/javascript">
|
90 |
-
Catalog.Map.addHelpLink($('<?php echo $helpLinkId ?>'), "<?php echo $this->__("Whats this?") ?>");
|
91 |
-
</script>
|
92 |
-
</span>
|
93 |
-
</td>
|
94 |
-
<?php else: ?>
|
95 |
-
|
96 |
-
<!-- Skybox Checkout -->
|
97 |
-
<!--<td class="a-center"><?php echo $this->helper('checkout')->formatPrice($_item->getPriceSkybox()); ?></td>
|
98 |
-
<td class="a-center"><?php echo $this->helper('checkout')->formatPrice($_item->getCustomsSkybox()); ?></td>
|
99 |
-
<td class="a-center"><?php echo $this->helper('checkout')->formatPrice($_item->getInsuranceSkybox()); ?></td>
|
100 |
-
<td class="a-center"><?php echo $this->helper('checkout')->formatPrice($_item->getShippingSkybox()); ?></td>-->
|
101 |
-
<!-- /Skybox Checkout -->
|
102 |
-
|
103 |
-
<?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
|
104 |
-
<td class="a-right">
|
105 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
106 |
-
<span class="cart-tax-total" onclick="taxToggle('eunit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
|
107 |
-
<?php else: ?>
|
108 |
-
<span class="cart-price" style="white-space: nowrap;">
|
109 |
-
<?php endif; ?>
|
110 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
111 |
-
<?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
|
112 |
-
<?php else: ?>
|
113 |
-
<?php echo $this->helper('checkout')->formatPrice($_item->getPriceSkybox()); ?>
|
114 |
-
|
115 |
-
<!--<?php echo $this->helper('checkout')->formatPrice($_item->getTotalSkybox()); ?>-->
|
116 |
-
<?php endif; ?>
|
117 |
-
<?php if ($_item->getBasePriceSkybox() > $_item->getPriceSkybox()):?>
|
118 |
-
<span class="price price-discount" style="text-decoration: line-through;">
|
119 |
-
(<?php echo $this->helper('checkout')->formatPrice($_item->getBasePriceSkybox()); ?>)
|
120 |
-
</span>
|
121 |
-
<span class="text-discount"><?php echo $_item->getAdjustLabelSkybox(); ?></span>
|
122 |
-
<?php endif; ?>
|
123 |
-
</span>
|
124 |
-
|
125 |
-
<?php if (Mage::helper('weee')->getApplied($_item)): ?>
|
126 |
-
|
127 |
-
<div class="cart-tax-info" id="eunit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
|
128 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
129 |
-
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
130 |
-
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
|
131 |
-
<?php endforeach; ?>
|
132 |
-
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
133 |
-
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
134 |
-
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
|
135 |
-
<?php endforeach; ?>
|
136 |
-
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
137 |
-
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
138 |
-
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
|
139 |
-
<?php endforeach; ?>
|
140 |
-
<?php endif; ?>
|
141 |
-
</div>
|
142 |
-
|
143 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
144 |
-
<div class="cart-tax-total" onclick="taxToggle('eunit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
|
145 |
-
<span class="weee"><?php echo Mage::helper('weee')->__('Total'); ?>: <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?></span>
|
146 |
-
</div>
|
147 |
-
<?php endif; ?>
|
148 |
-
<?php endif; ?>
|
149 |
-
</td>
|
150 |
-
<?php endif; ?><!-- inclusive price starts here -->
|
151 |
-
<?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
|
152 |
-
<td>
|
153 |
-
<?php $_incl = $this->helper('checkout')->getPriceInclTax($_item); ?>
|
154 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
155 |
-
<span class="cart-tax-total" onclick="taxToggle('unit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
|
156 |
-
<?php else: ?>
|
157 |
-
<span class="cart-price">
|
158 |
-
<?php endif; ?>
|
159 |
-
|
160 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
161 |
-
<?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?>
|
162 |
-
<?php else: ?>
|
163 |
-
<?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?>
|
164 |
-
<?php endif; ?>
|
165 |
-
|
166 |
-
</span>
|
167 |
-
<?php if (Mage::helper('weee')->getApplied($_item)): ?>
|
168 |
-
|
169 |
-
<div class="cart-tax-info" id="unit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
|
170 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
171 |
-
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
172 |
-
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
|
173 |
-
<?php endforeach; ?>
|
174 |
-
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
175 |
-
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
176 |
-
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
|
177 |
-
<?php endforeach; ?>
|
178 |
-
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
179 |
-
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
180 |
-
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
|
181 |
-
<?php endforeach; ?>
|
182 |
-
<?php endif; ?>
|
183 |
-
</div>
|
184 |
-
|
185 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
186 |
-
<div class="cart-tax-total" onclick="taxToggle('unit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
|
187 |
-
<span class="weee"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>: <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?></span>
|
188 |
-
</div>
|
189 |
-
<?php endif; ?>
|
190 |
-
<?php endif; ?>
|
191 |
-
</td>
|
192 |
-
<?php endif; ?>
|
193 |
-
<?php endif; ?>
|
194 |
-
<td class="a-center">
|
195 |
-
<input name="cart[<?php echo $_item->getId() ?>][qty]" value="<?php echo $this->getQty() ?>" size="4" title="<?php echo $this->__('Qty') ?>" class="input-text qty" maxlength="12" />
|
196 |
-
</td>
|
197 |
-
|
198 |
-
<!--Sub total starts here -->
|
199 |
-
<?php if (($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) && !$_item->getNoSubtotal()): ?>
|
200 |
-
<td class="a-right" style="white-space: nowrap;">
|
201 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
202 |
-
<span class="cart-tax-total" onclick="taxToggle('esubtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
|
203 |
-
<?php else: ?>
|
204 |
-
<span class="cart-price">
|
205 |
-
<?php endif; ?>
|
206 |
-
|
207 |
-
<?php if ($canApplyMsrp): ?>
|
208 |
-
<span class="cart-msrp-subtotal">--</span>
|
209 |
-
<?php else: ?>
|
210 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
211 |
-
<?php echo $this->helper('checkout')->formatPrice($_item->getTotalSkybox()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?>
|
212 |
-
<?php else: ?>
|
213 |
-
<?php //echo $this->helper('checkout')->formatPrice($_item->getRowTotalSkybox()) ?>
|
214 |
-
<?php echo $this->helper('checkout')->formatPrice($_item->getRowTotalSkybox()) ?><!--total-->
|
215 |
-
<?php endif; ?>
|
216 |
-
<?php endif; ?>
|
217 |
-
|
218 |
-
</span>
|
219 |
-
<?php if (Mage::helper('weee')->getApplied($_item)): ?>
|
220 |
-
|
221 |
-
<div class="cart-tax-info" id="esubtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
|
222 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
223 |
-
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
224 |
-
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
|
225 |
-
<?php endforeach; ?>
|
226 |
-
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
227 |
-
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
228 |
-
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
|
229 |
-
<?php endforeach; ?>
|
230 |
-
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
231 |
-
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
232 |
-
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
|
233 |
-
<?php endforeach; ?>
|
234 |
-
<?php endif; ?>
|
235 |
-
</div>
|
236 |
-
|
237 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
238 |
-
<div class="cart-tax-total" onclick="taxToggle('esubtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
|
239 |
-
<span class="weee"><?php echo Mage::helper('weee')->__('Total'); ?>: <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span>
|
240 |
-
</div>
|
241 |
-
<?php endif; ?>
|
242 |
-
<?php endif; ?>
|
243 |
-
</td>
|
244 |
-
<?php endif; ?>
|
245 |
-
<?php if (($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) && !$_item->getNoSubtotal()): ?>
|
246 |
-
<td>
|
247 |
-
<?php $_incl = $this->helper('checkout')->getSubtotalInclTax($_item); ?>
|
248 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
249 |
-
<span class="cart-tax-total" onclick="taxToggle('subtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
|
250 |
-
<?php else: ?>
|
251 |
-
<span class="cart-price">
|
252 |
-
<?php endif; ?>
|
253 |
-
|
254 |
-
<?php if ($canApplyMsrp): ?>
|
255 |
-
<span class="cart-msrp-subtotal">--</span>
|
256 |
-
<?php else: ?>
|
257 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
258 |
-
<?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getRowWeeeTaxInclTax($_item)); ?>
|
259 |
-
<?php else: ?>
|
260 |
-
<?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?>
|
261 |
-
<?php endif; ?>
|
262 |
-
<?php endif; ?>
|
263 |
-
|
264 |
-
</span>
|
265 |
-
|
266 |
-
|
267 |
-
<?php if (Mage::helper('weee')->getApplied($_item)): ?>
|
268 |
-
|
269 |
-
<div class="cart-tax-info" id="subtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
|
270 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
271 |
-
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
272 |
-
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
|
273 |
-
<?php endforeach; ?>
|
274 |
-
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
275 |
-
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
276 |
-
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
|
277 |
-
<?php endforeach; ?>
|
278 |
-
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
279 |
-
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
280 |
-
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
|
281 |
-
<?php endforeach; ?>
|
282 |
-
<?php endif; ?>
|
283 |
-
</div>
|
284 |
-
|
285 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
286 |
-
<div class="cart-tax-total" onclick="taxToggle('subtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
|
287 |
-
<span class="weee"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>: <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getRowWeeeTaxInclTax($_item)); ?></span>
|
288 |
-
</div>
|
289 |
-
<?php endif; ?>
|
290 |
-
<?php endif; ?>
|
291 |
-
</td>
|
292 |
-
<?php endif; ?>
|
293 |
-
<td class="a-center"><a href="<?php echo $this->getDeleteUrl()?>" title="<?php echo $this->__('Remove item')?>" class="btn-remove btn-remove2"><?php echo $this->__('Remove item')?></a></td>
|
294 |
-
</tr>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php
|
28 |
+
$_item = $this->getItem();
|
29 |
+
$isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility();
|
30 |
+
$canApplyMsrp = Mage::helper('catalog')->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM);
|
31 |
+
?>
|
32 |
+
<tr>
|
33 |
+
<td><?php if ($this->hasProductUrl()):?><a href="<?php echo $this->getProductUrl() ?>" title="<?php echo $this->escapeHtml($this->getProductName()) ?>" class="product-image"><?php endif;?><img src="<?php echo $this->getProductThumbnail()->resize(75); ?>" width="75" height="75" alt="<?php echo $this->escapeHtml($this->getProductName()) ?>" /><?php if ($this->hasProductUrl()):?></a><?php endif;?></td>
|
34 |
+
<td>
|
35 |
+
<h2 class="product-name">
|
36 |
+
<?php if ($this->hasProductUrl()):?>
|
37 |
+
<a href="<?php echo $this->getProductUrl() ?>"><?php echo $this->escapeHtml($this->getProductName()) ?></a>
|
38 |
+
<?php else: ?>
|
39 |
+
<?php echo $this->escapeHtml($this->getProductName()) ?>
|
40 |
+
<?php endif; ?>
|
41 |
+
</h2>
|
42 |
+
<?php if ($_options = $this->getOptionList()):?>
|
43 |
+
<dl class="item-options">
|
44 |
+
<?php foreach ($_options as $_option) : ?>
|
45 |
+
<?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
|
46 |
+
<dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
|
47 |
+
<dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
|
48 |
+
<?php if (isset($_formatedOptionValue['full_view'])): ?>
|
49 |
+
<div class="truncated_full_value">
|
50 |
+
<dl class="item-options">
|
51 |
+
<dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
|
52 |
+
<dd><?php echo $_formatedOptionValue['full_view'] ?></dd>
|
53 |
+
</dl>
|
54 |
+
</div>
|
55 |
+
<?php endif; ?>
|
56 |
+
</dd>
|
57 |
+
<?php endforeach; ?>
|
58 |
+
</dl>
|
59 |
+
<?php endif;?>
|
60 |
+
<?php if ($messages = $this->getMessages()): ?>
|
61 |
+
<?php foreach ($messages as $message): ?>
|
62 |
+
<p class="item-msg <?php echo $message['type'] ?>">* <?php echo $this->escapeHtml($message['text']) ?></p>
|
63 |
+
<?php endforeach; ?>
|
64 |
+
<?php endif; ?>
|
65 |
+
<?php $addInfoBlock = $this->getProductAdditionalInformationBlock(); ?>
|
66 |
+
<?php if ($addInfoBlock): ?>
|
67 |
+
<?php echo $addInfoBlock->setItem($_item)->toHtml() ?>
|
68 |
+
<?php endif;?>
|
69 |
+
</td>
|
70 |
+
<td class="a-center">
|
71 |
+
<?php if ($isVisibleProduct): ?>
|
72 |
+
<a href="<?php echo $this->getConfigureUrl() ?>" title="<?php echo $this->__('Edit item parameters') ?>"><?php echo $this->__('Edit') ?></a>
|
73 |
+
<?php endif ?>
|
74 |
+
</td>
|
75 |
+
<?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
|
76 |
+
<td class="a-center">
|
77 |
+
<?php if ($isVisibleProduct): ?>
|
78 |
+
<a href="<?php echo $this->helper('wishlist')->getMoveFromCartUrl($_item->getId()); ?>" class="link-wishlist use-ajax"><?php echo $this->__('Move'); ?></a>
|
79 |
+
<?php endif ?>
|
80 |
+
</td>
|
81 |
+
<?php endif ?>
|
82 |
+
|
83 |
+
<?php if ($canApplyMsrp): ?>
|
84 |
+
<td class="a-right"<?php if ($this->helper('tax')->displayCartBothPrices()): ?> colspan="2"<?php endif; ?>>
|
85 |
+
<span class="cart-price">
|
86 |
+
<span class="cart-msrp-unit"><?php echo $this->__('See price before order confirmation.'); ?></span>
|
87 |
+
<?php $helpLinkId = 'cart-msrp-help-' . $_item->getId(); ?>
|
88 |
+
<a id="<?php echo $helpLinkId ?>" href="#" class="map-help-link"><?php echo $this->__("What's this?"); ?></a>
|
89 |
+
<script type="text/javascript">
|
90 |
+
Catalog.Map.addHelpLink($('<?php echo $helpLinkId ?>'), "<?php echo $this->__("Whats this?") ?>");
|
91 |
+
</script>
|
92 |
+
</span>
|
93 |
+
</td>
|
94 |
+
<?php else: ?>
|
95 |
+
|
96 |
+
<!-- Skybox Checkout -->
|
97 |
+
<!--<td class="a-center"><?php echo $this->helper('checkout')->formatPrice($_item->getPriceSkybox()); ?></td>
|
98 |
+
<td class="a-center"><?php echo $this->helper('checkout')->formatPrice($_item->getCustomsSkybox()); ?></td>
|
99 |
+
<td class="a-center"><?php echo $this->helper('checkout')->formatPrice($_item->getInsuranceSkybox()); ?></td>
|
100 |
+
<td class="a-center"><?php echo $this->helper('checkout')->formatPrice($_item->getShippingSkybox()); ?></td>-->
|
101 |
+
<!-- /Skybox Checkout -->
|
102 |
+
|
103 |
+
<?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
|
104 |
+
<td class="a-right">
|
105 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
106 |
+
<span class="cart-tax-total" onclick="taxToggle('eunit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
|
107 |
+
<?php else: ?>
|
108 |
+
<span class="cart-price" style="white-space: nowrap;">
|
109 |
+
<?php endif; ?>
|
110 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
111 |
+
<?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
|
112 |
+
<?php else: ?>
|
113 |
+
<?php echo $this->helper('checkout')->formatPrice($_item->getPriceSkybox()); ?>
|
114 |
+
|
115 |
+
<!--<?php echo $this->helper('checkout')->formatPrice($_item->getTotalSkybox()); ?>-->
|
116 |
+
<?php endif; ?>
|
117 |
+
<?php if ($_item->getBasePriceSkybox() > $_item->getPriceSkybox()):?>
|
118 |
+
<span class="price price-discount" style="text-decoration: line-through;">
|
119 |
+
(<?php echo $this->helper('checkout')->formatPrice($_item->getBasePriceSkybox()); ?>)
|
120 |
+
</span>
|
121 |
+
<span class="text-discount"><?php echo $_item->getAdjustLabelSkybox(); ?></span>
|
122 |
+
<?php endif; ?>
|
123 |
+
</span>
|
124 |
+
|
125 |
+
<?php if (Mage::helper('weee')->getApplied($_item)): ?>
|
126 |
+
|
127 |
+
<div class="cart-tax-info" id="eunit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
|
128 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
129 |
+
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
130 |
+
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
|
131 |
+
<?php endforeach; ?>
|
132 |
+
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
133 |
+
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
134 |
+
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
|
135 |
+
<?php endforeach; ?>
|
136 |
+
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
137 |
+
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
138 |
+
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
|
139 |
+
<?php endforeach; ?>
|
140 |
+
<?php endif; ?>
|
141 |
+
</div>
|
142 |
+
|
143 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
144 |
+
<div class="cart-tax-total" onclick="taxToggle('eunit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
|
145 |
+
<span class="weee"><?php echo Mage::helper('weee')->__('Total'); ?>: <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?></span>
|
146 |
+
</div>
|
147 |
+
<?php endif; ?>
|
148 |
+
<?php endif; ?>
|
149 |
+
</td>
|
150 |
+
<?php endif; ?><!-- inclusive price starts here -->
|
151 |
+
<?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
|
152 |
+
<td>
|
153 |
+
<?php $_incl = $this->helper('checkout')->getPriceInclTax($_item); ?>
|
154 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
155 |
+
<span class="cart-tax-total" onclick="taxToggle('unit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
|
156 |
+
<?php else: ?>
|
157 |
+
<span class="cart-price">
|
158 |
+
<?php endif; ?>
|
159 |
+
|
160 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
161 |
+
<?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?>
|
162 |
+
<?php else: ?>
|
163 |
+
<?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?>
|
164 |
+
<?php endif; ?>
|
165 |
+
|
166 |
+
</span>
|
167 |
+
<?php if (Mage::helper('weee')->getApplied($_item)): ?>
|
168 |
+
|
169 |
+
<div class="cart-tax-info" id="unit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
|
170 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
171 |
+
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
172 |
+
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
|
173 |
+
<?php endforeach; ?>
|
174 |
+
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
175 |
+
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
176 |
+
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
|
177 |
+
<?php endforeach; ?>
|
178 |
+
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
179 |
+
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
180 |
+
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
|
181 |
+
<?php endforeach; ?>
|
182 |
+
<?php endif; ?>
|
183 |
+
</div>
|
184 |
+
|
185 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
186 |
+
<div class="cart-tax-total" onclick="taxToggle('unit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
|
187 |
+
<span class="weee"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>: <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?></span>
|
188 |
+
</div>
|
189 |
+
<?php endif; ?>
|
190 |
+
<?php endif; ?>
|
191 |
+
</td>
|
192 |
+
<?php endif; ?>
|
193 |
+
<?php endif; ?>
|
194 |
+
<td class="a-center">
|
195 |
+
<input name="cart[<?php echo $_item->getId() ?>][qty]" value="<?php echo $this->getQty() ?>" size="4" title="<?php echo $this->__('Qty') ?>" class="input-text qty" maxlength="12" />
|
196 |
+
</td>
|
197 |
+
|
198 |
+
<!--Sub total starts here -->
|
199 |
+
<?php if (($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) && !$_item->getNoSubtotal()): ?>
|
200 |
+
<td class="a-right" style="white-space: nowrap;">
|
201 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
202 |
+
<span class="cart-tax-total" onclick="taxToggle('esubtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
|
203 |
+
<?php else: ?>
|
204 |
+
<span class="cart-price">
|
205 |
+
<?php endif; ?>
|
206 |
+
|
207 |
+
<?php if ($canApplyMsrp): ?>
|
208 |
+
<span class="cart-msrp-subtotal">--</span>
|
209 |
+
<?php else: ?>
|
210 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
211 |
+
<?php echo $this->helper('checkout')->formatPrice($_item->getTotalSkybox()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?>
|
212 |
+
<?php else: ?>
|
213 |
+
<?php //echo $this->helper('checkout')->formatPrice($_item->getRowTotalSkybox()) ?>
|
214 |
+
<?php echo $this->helper('checkout')->formatPrice($_item->getRowTotalSkybox()) ?><!--total-->
|
215 |
+
<?php endif; ?>
|
216 |
+
<?php endif; ?>
|
217 |
+
|
218 |
+
</span>
|
219 |
+
<?php if (Mage::helper('weee')->getApplied($_item)): ?>
|
220 |
+
|
221 |
+
<div class="cart-tax-info" id="esubtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
|
222 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
223 |
+
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
224 |
+
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
|
225 |
+
<?php endforeach; ?>
|
226 |
+
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
227 |
+
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
228 |
+
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
|
229 |
+
<?php endforeach; ?>
|
230 |
+
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
231 |
+
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
232 |
+
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
|
233 |
+
<?php endforeach; ?>
|
234 |
+
<?php endif; ?>
|
235 |
+
</div>
|
236 |
+
|
237 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
238 |
+
<div class="cart-tax-total" onclick="taxToggle('esubtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
|
239 |
+
<span class="weee"><?php echo Mage::helper('weee')->__('Total'); ?>: <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span>
|
240 |
+
</div>
|
241 |
+
<?php endif; ?>
|
242 |
+
<?php endif; ?>
|
243 |
+
</td>
|
244 |
+
<?php endif; ?>
|
245 |
+
<?php if (($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) && !$_item->getNoSubtotal()): ?>
|
246 |
+
<td>
|
247 |
+
<?php $_incl = $this->helper('checkout')->getSubtotalInclTax($_item); ?>
|
248 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
249 |
+
<span class="cart-tax-total" onclick="taxToggle('subtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
|
250 |
+
<?php else: ?>
|
251 |
+
<span class="cart-price">
|
252 |
+
<?php endif; ?>
|
253 |
+
|
254 |
+
<?php if ($canApplyMsrp): ?>
|
255 |
+
<span class="cart-msrp-subtotal">--</span>
|
256 |
+
<?php else: ?>
|
257 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
258 |
+
<?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getRowWeeeTaxInclTax($_item)); ?>
|
259 |
+
<?php else: ?>
|
260 |
+
<?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?>
|
261 |
+
<?php endif; ?>
|
262 |
+
<?php endif; ?>
|
263 |
+
|
264 |
+
</span>
|
265 |
+
|
266 |
+
|
267 |
+
<?php if (Mage::helper('weee')->getApplied($_item)): ?>
|
268 |
+
|
269 |
+
<div class="cart-tax-info" id="subtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
|
270 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
271 |
+
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
272 |
+
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
|
273 |
+
<?php endforeach; ?>
|
274 |
+
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
275 |
+
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
276 |
+
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
|
277 |
+
<?php endforeach; ?>
|
278 |
+
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
279 |
+
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
280 |
+
<span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
|
281 |
+
<?php endforeach; ?>
|
282 |
+
<?php endif; ?>
|
283 |
+
</div>
|
284 |
+
|
285 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
|
286 |
+
<div class="cart-tax-total" onclick="taxToggle('subtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
|
287 |
+
<span class="weee"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>: <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getRowWeeeTaxInclTax($_item)); ?></span>
|
288 |
+
</div>
|
289 |
+
<?php endif; ?>
|
290 |
+
<?php endif; ?>
|
291 |
+
</td>
|
292 |
+
<?php endif; ?>
|
293 |
+
<td class="a-center"><a href="<?php echo $this->getDeleteUrl()?>" title="<?php echo $this->__('Remove item')?>" class="btn-remove btn-remove2"><?php echo $this->__('Remove item')?></a></td>
|
294 |
+
</tr>
|
app/design/frontend/base/default/template/skybox/checkout/cart/shipping.phtml
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @see Mage_Checkout_Block_Cart_Shipping
|
4 |
-
*/
|
5 |
-
$allowHelper = Mage::helper('skyboxcore/allow');
|
6 |
-
if (!$allowHelper->isPriceEnabled()) :
|
7 |
-
?>
|
8 |
-
<?php echo $this->getChildHtml('shippping') ?>
|
9 |
-
<?php
|
10 |
-
endif;
|
11 |
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @see Mage_Checkout_Block_Cart_Shipping
|
4 |
+
*/
|
5 |
+
$allowHelper = Mage::helper('skyboxcore/allow');
|
6 |
+
if (!$allowHelper->isPriceEnabled()) :
|
7 |
+
?>
|
8 |
+
<?php echo $this->getChildHtml('shippping') ?>
|
9 |
+
<?php
|
10 |
+
endif;
|
11 |
?>
|
app/design/frontend/base/default/template/skybox/checkout/cart/sidebar.phtml
CHANGED
@@ -1,80 +1,80 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/afl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category design
|
22 |
-
* @package base_default
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Shoping cart sidebar
|
29 |
-
*
|
30 |
-
* @see Mage_Checkout_Block_Cart_Sidebar
|
31 |
-
*/
|
32 |
-
|
33 |
-
?>
|
34 |
-
<?php if ($this->getIsNeedToDisplaySideBar()):?>
|
35 |
-
<div class="block block-cart">
|
36 |
-
<?php $_cartQty = $this->getSummaryCount() ?>
|
37 |
-
<div class="block-title">
|
38 |
-
<strong><span><?php echo $this->__('My Cart') ?></span></strong>
|
39 |
-
</div>
|
40 |
-
<div class="block-content">
|
41 |
-
<?php if ($_cartQty>0): ?>
|
42 |
-
<div class="summary">
|
43 |
-
<?php if ($_cartQty==1): ?>
|
44 |
-
<p class="amount"><?php echo $this->__('There is <a href="%s">1 item</a> in your cart.', $this->getUrl('checkout/cart')) ?></p>
|
45 |
-
<?php else: ?>
|
46 |
-
<p class="amount"><?php echo $this->__('There are <a href="%s">%s items</a> in your cart.', $this->getUrl('checkout/cart'), $_cartQty) ?></p>
|
47 |
-
<?php endif ?>
|
48 |
-
<p class="subtotal">
|
49 |
-
<?php if ($this->canApplyMsrp()): ?>
|
50 |
-
<span class="map-cart-sidebar-total"><?php echo $this->__('ORDER TOTAL WILL BE DISPLAYED BEFORE YOU SUBMIT THE ORDER'); ?></span>
|
51 |
-
<?php else: ?>
|
52 |
-
<span class="label"><?php echo $this->__('Cart Subtotal:') ?></span> <?php echo Mage::helper('checkout')->formatPrice($this->getSubtotal()) ?>
|
53 |
-
<?php if ($_subtotalInclTax = $this->getSubtotalInclTax()): ?>
|
54 |
-
<br />(<?php echo Mage::helper('checkout')->formatPrice($_subtotalInclTax) ?> <?php echo Mage::helper('tax')->getIncExcText(true) ?>)
|
55 |
-
<?php endif; ?>
|
56 |
-
<?php endif; ?>
|
57 |
-
</p>
|
58 |
-
</div>
|
59 |
-
<?php endif ?>
|
60 |
-
<?php if($_cartQty && $this->isPossibleOnepageCheckout()): ?>
|
61 |
-
<div class="actions">
|
62 |
-
<?php echo $this->getChildHtml('extra_actions') ?>
|
63 |
-
<button type="button" title="<?php echo $this->__('Checkout') ?>" class="button" onclick="setLocation('<?php echo $this->getCheckoutUrl() ?>')"><span><span><?php echo $this->__('Checkout') ?></span></span></button>
|
64 |
-
</div>
|
65 |
-
<?php endif ?>
|
66 |
-
<?php $_items = $this->getRecentItems() ?>
|
67 |
-
<?php if(count($_items)): ?>
|
68 |
-
<p class="block-subtitle"><?php echo $this->__('Recently added item(s)') ?></p>
|
69 |
-
<ol id="cart-sidebar" class="mini-products-list">
|
70 |
-
<?php foreach($_items as $_item): ?>
|
71 |
-
<?php echo $this->getItemHtml($_item) ?>
|
72 |
-
<?php endforeach; ?>
|
73 |
-
</ol>
|
74 |
-
<script type="text/javascript">decorateList('cart-sidebar', 'none-recursive')</script>
|
75 |
-
<?php else: ?>
|
76 |
-
<p class="empty"><?php echo $this->__('You have no items in your shopping cart.') ?></p>
|
77 |
-
<?php endif ?>
|
78 |
-
</div>
|
79 |
-
</div>
|
80 |
-
<?php endif;?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Shoping cart sidebar
|
29 |
+
*
|
30 |
+
* @see Mage_Checkout_Block_Cart_Sidebar
|
31 |
+
*/
|
32 |
+
|
33 |
+
?>
|
34 |
+
<?php if ($this->getIsNeedToDisplaySideBar()):?>
|
35 |
+
<div class="block block-cart">
|
36 |
+
<?php $_cartQty = $this->getSummaryCount() ?>
|
37 |
+
<div class="block-title">
|
38 |
+
<strong><span><?php echo $this->__('My Cart') ?></span></strong>
|
39 |
+
</div>
|
40 |
+
<div class="block-content">
|
41 |
+
<?php if ($_cartQty>0): ?>
|
42 |
+
<div class="summary">
|
43 |
+
<?php if ($_cartQty==1): ?>
|
44 |
+
<p class="amount"><?php echo $this->__('There is <a href="%s">1 item</a> in your cart.', $this->getUrl('checkout/cart')) ?></p>
|
45 |
+
<?php else: ?>
|
46 |
+
<p class="amount"><?php echo $this->__('There are <a href="%s">%s items</a> in your cart.', $this->getUrl('checkout/cart'), $_cartQty) ?></p>
|
47 |
+
<?php endif ?>
|
48 |
+
<p class="subtotal">
|
49 |
+
<?php if ($this->canApplyMsrp()): ?>
|
50 |
+
<span class="map-cart-sidebar-total"><?php echo $this->__('ORDER TOTAL WILL BE DISPLAYED BEFORE YOU SUBMIT THE ORDER'); ?></span>
|
51 |
+
<?php else: ?>
|
52 |
+
<span class="label"><?php echo $this->__('Cart Subtotal:') ?></span> <?php echo Mage::helper('checkout')->formatPrice($this->getSubtotal()) ?>
|
53 |
+
<?php if ($_subtotalInclTax = $this->getSubtotalInclTax()): ?>
|
54 |
+
<br />(<?php echo Mage::helper('checkout')->formatPrice($_subtotalInclTax) ?> <?php echo Mage::helper('tax')->getIncExcText(true) ?>)
|
55 |
+
<?php endif; ?>
|
56 |
+
<?php endif; ?>
|
57 |
+
</p>
|
58 |
+
</div>
|
59 |
+
<?php endif ?>
|
60 |
+
<?php if($_cartQty && $this->isPossibleOnepageCheckout()): ?>
|
61 |
+
<div class="actions">
|
62 |
+
<?php echo $this->getChildHtml('extra_actions') ?>
|
63 |
+
<button type="button" title="<?php echo $this->__('Checkout') ?>" class="button" onclick="setLocation('<?php echo $this->getCheckoutUrl() ?>')"><span><span><?php echo $this->__('Checkout') ?></span></span></button>
|
64 |
+
</div>
|
65 |
+
<?php endif ?>
|
66 |
+
<?php $_items = $this->getRecentItems() ?>
|
67 |
+
<?php if(count($_items)): ?>
|
68 |
+
<p class="block-subtitle"><?php echo $this->__('Recently added item(s)') ?></p>
|
69 |
+
<ol id="cart-sidebar" class="mini-products-list">
|
70 |
+
<?php foreach($_items as $_item): ?>
|
71 |
+
<?php echo $this->getItemHtml($_item) ?>
|
72 |
+
<?php endforeach; ?>
|
73 |
+
</ol>
|
74 |
+
<script type="text/javascript">decorateList('cart-sidebar', 'none-recursive')</script>
|
75 |
+
<?php else: ?>
|
76 |
+
<p class="empty"><?php echo $this->__('You have no items in your shopping cart.') ?></p>
|
77 |
+
<?php endif ?>
|
78 |
+
</div>
|
79 |
+
</div>
|
80 |
+
<?php endif;?>
|
app/design/frontend/base/default/template/skybox/checkout/cart/sidebar/default.phtml
CHANGED
@@ -1,146 +1,146 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/afl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category design
|
22 |
-
* @package base_default
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
-
*/
|
26 |
-
?>
|
27 |
-
<?php
|
28 |
-
$_item = $this->getItem();
|
29 |
-
$isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility();
|
30 |
-
$canApplyMsrp = Mage::helper('catalog')->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM);
|
31 |
-
?>
|
32 |
-
<li class="item">
|
33 |
-
<?php if ($this->hasProductUrl()): ?>
|
34 |
-
<a href="<?php echo $this->getProductUrl()?>" title="<?php echo $this->escapeHtml($this->getProductName()) ?>" class="product-image"><img src="<?php echo $this->getProductThumbnail()->resize(50, 50)->setWatermarkSize('30x10'); ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($this->getProductName()) ?>" /></a>
|
35 |
-
<?php else: ?>
|
36 |
-
<span class="product-image"><img src="<?php echo $this->getProductThumbnail()->resize(50, 50)->setWatermarkSize('30x10'); ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($this->getProductName()) ?>" /></span>
|
37 |
-
<?php endif; ?>
|
38 |
-
<div class="product-details">
|
39 |
-
<a href="<?php echo $this->getDeleteUrl() ?>" title="<?php echo $this->__('Remove This Item') ?>" onclick="return confirm('<?php echo $this->__('Are you sure you would like to remove this item from the shopping cart?') ?>');" class="btn-remove"><?php echo $this->__('Remove This Item') ?></a>
|
40 |
-
<?php if ($isVisibleProduct): ?>
|
41 |
-
<a href="<?php echo $this->getConfigureUrl() ?>" title="<?php echo $this->__('Edit item') ?>" class="btn-edit"><?php echo $this->__('Edit item')?></a>
|
42 |
-
<?php endif ?>
|
43 |
-
<p class="product-name"><?php if ($this->hasProductUrl()): ?><a href="<?php echo $this->getProductUrl() ?>"><?php endif; ?><?php echo $this->escapeHtml($this->getProductName()) ?><?php if ($this->hasProductUrl()): ?></a><?php endif; ?></p>
|
44 |
-
<strong><?php echo $this->getQty() ?></strong> x
|
45 |
-
|
46 |
-
<?php if ($canApplyMsrp): ?>
|
47 |
-
|
48 |
-
<span class="map-cart-sidebar-item"><?php echo $this->__('See price before order confirmation.'); ?></span>
|
49 |
-
|
50 |
-
<?php else: ?>
|
51 |
-
|
52 |
-
<?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
|
53 |
-
<?php if ($this->helper('tax')->displayCartBothPrices()): ?>
|
54 |
-
<?php echo $this->__('Excl. Tax'); ?>:
|
55 |
-
<?php endif; ?>
|
56 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?>
|
57 |
-
<?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
|
58 |
-
<?php else: ?>
|
59 |
-
<?php //echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()) ?>
|
60 |
-
<?php echo $this->helper('checkout')->formatPrice($_item->getRowTotalSkybox()) ?>
|
61 |
-
<?php endif; ?>
|
62 |
-
<?php if (Mage::helper('weee')->getApplied($_item)): ?>
|
63 |
-
<br />
|
64 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales')): ?>
|
65 |
-
<small>
|
66 |
-
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
67 |
-
<span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span><br />
|
68 |
-
<?php endforeach; ?>
|
69 |
-
</small>
|
70 |
-
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
|
71 |
-
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
72 |
-
<span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></small></span><br />
|
73 |
-
<?php endforeach; ?>
|
74 |
-
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales')): ?>
|
75 |
-
<small>
|
76 |
-
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
77 |
-
<span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span><br />
|
78 |
-
<?php endforeach; ?>
|
79 |
-
</small>
|
80 |
-
<?php endif; ?>
|
81 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
|
82 |
-
<span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br /> <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?></span>
|
83 |
-
<?php endif; ?>
|
84 |
-
<?php endif; ?>
|
85 |
-
<?php endif; ?>
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
<?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
|
90 |
-
<?php $_incl = $this->helper('checkout')->getPriceInclTax($_item); ?>
|
91 |
-
<?php if ($this->helper('tax')->displayCartBothPrices()): ?>
|
92 |
-
<br /><?php echo $this->__('Incl. Tax'); ?>:
|
93 |
-
<?php endif; ?>
|
94 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?>
|
95 |
-
<?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?>
|
96 |
-
<?php else: ?>
|
97 |
-
<?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?>
|
98 |
-
<?php endif; ?>
|
99 |
-
<?php if (Mage::helper('weee')->getApplied($_item)): ?>
|
100 |
-
<br />
|
101 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales')): ?>
|
102 |
-
<small>
|
103 |
-
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
104 |
-
<span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span><br />
|
105 |
-
<?php endforeach; ?>
|
106 |
-
</small>
|
107 |
-
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
|
108 |
-
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
109 |
-
<span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></small></span><br />
|
110 |
-
<?php endforeach; ?>
|
111 |
-
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales')): ?>
|
112 |
-
<small>
|
113 |
-
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
114 |
-
<span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span><br />
|
115 |
-
<?php endforeach; ?>
|
116 |
-
</small>
|
117 |
-
<?php endif; ?>
|
118 |
-
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
|
119 |
-
<span class="nobr"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>:<br /> <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?></span>
|
120 |
-
<?php endif; ?>
|
121 |
-
<?php endif; ?>
|
122 |
-
<?php endif; ?>
|
123 |
-
|
124 |
-
<?php endif; //Can apply MSRP ?>
|
125 |
-
|
126 |
-
<?php if ($_options = $this->getOptionList()):?>
|
127 |
-
<div class="truncated">
|
128 |
-
<div class="truncated_full_value">
|
129 |
-
<dl class="item-options">
|
130 |
-
<?php foreach ($_options as $_option) : ?>
|
131 |
-
<dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
|
132 |
-
<dd>
|
133 |
-
<?php if (is_array($_option['value'])): ?>
|
134 |
-
<?php echo nl2br(implode("\n", $_option['value'])) ?>
|
135 |
-
<?php else: ?>
|
136 |
-
<?php echo $_option['value'] ?>
|
137 |
-
<?php endif; ?>
|
138 |
-
</dd>
|
139 |
-
<?php endforeach; ?>
|
140 |
-
</dl>
|
141 |
-
</div>
|
142 |
-
<a href="#" onclick="return false;" class="details"><?php echo $this->__('Details') ?></a>
|
143 |
-
</div>
|
144 |
-
<?php endif; ?>
|
145 |
-
</div>
|
146 |
-
</li>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php
|
28 |
+
$_item = $this->getItem();
|
29 |
+
$isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility();
|
30 |
+
$canApplyMsrp = Mage::helper('catalog')->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM);
|
31 |
+
?>
|
32 |
+
<li class="item">
|
33 |
+
<?php if ($this->hasProductUrl()): ?>
|
34 |
+
<a href="<?php echo $this->getProductUrl()?>" title="<?php echo $this->escapeHtml($this->getProductName()) ?>" class="product-image"><img src="<?php echo $this->getProductThumbnail()->resize(50, 50)->setWatermarkSize('30x10'); ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($this->getProductName()) ?>" /></a>
|
35 |
+
<?php else: ?>
|
36 |
+
<span class="product-image"><img src="<?php echo $this->getProductThumbnail()->resize(50, 50)->setWatermarkSize('30x10'); ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($this->getProductName()) ?>" /></span>
|
37 |
+
<?php endif; ?>
|
38 |
+
<div class="product-details">
|
39 |
+
<a href="<?php echo $this->getDeleteUrl() ?>" title="<?php echo $this->__('Remove This Item') ?>" onclick="return confirm('<?php echo $this->__('Are you sure you would like to remove this item from the shopping cart?') ?>');" class="btn-remove"><?php echo $this->__('Remove This Item') ?></a>
|
40 |
+
<?php if ($isVisibleProduct): ?>
|
41 |
+
<a href="<?php echo $this->getConfigureUrl() ?>" title="<?php echo $this->__('Edit item') ?>" class="btn-edit"><?php echo $this->__('Edit item')?></a>
|
42 |
+
<?php endif ?>
|
43 |
+
<p class="product-name"><?php if ($this->hasProductUrl()): ?><a href="<?php echo $this->getProductUrl() ?>"><?php endif; ?><?php echo $this->escapeHtml($this->getProductName()) ?><?php if ($this->hasProductUrl()): ?></a><?php endif; ?></p>
|
44 |
+
<strong><?php echo $this->getQty() ?></strong> x
|
45 |
+
|
46 |
+
<?php if ($canApplyMsrp): ?>
|
47 |
+
|
48 |
+
<span class="map-cart-sidebar-item"><?php echo $this->__('See price before order confirmation.'); ?></span>
|
49 |
+
|
50 |
+
<?php else: ?>
|
51 |
+
|
52 |
+
<?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
|
53 |
+
<?php if ($this->helper('tax')->displayCartBothPrices()): ?>
|
54 |
+
<?php echo $this->__('Excl. Tax'); ?>:
|
55 |
+
<?php endif; ?>
|
56 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?>
|
57 |
+
<?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
|
58 |
+
<?php else: ?>
|
59 |
+
<?php //echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()) ?>
|
60 |
+
<?php echo $this->helper('checkout')->formatPrice($_item->getRowTotalSkybox()) ?>
|
61 |
+
<?php endif; ?>
|
62 |
+
<?php if (Mage::helper('weee')->getApplied($_item)): ?>
|
63 |
+
<br />
|
64 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales')): ?>
|
65 |
+
<small>
|
66 |
+
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
67 |
+
<span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span><br />
|
68 |
+
<?php endforeach; ?>
|
69 |
+
</small>
|
70 |
+
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
|
71 |
+
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
72 |
+
<span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></small></span><br />
|
73 |
+
<?php endforeach; ?>
|
74 |
+
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales')): ?>
|
75 |
+
<small>
|
76 |
+
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
77 |
+
<span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span><br />
|
78 |
+
<?php endforeach; ?>
|
79 |
+
</small>
|
80 |
+
<?php endif; ?>
|
81 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
|
82 |
+
<span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br /> <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?></span>
|
83 |
+
<?php endif; ?>
|
84 |
+
<?php endif; ?>
|
85 |
+
<?php endif; ?>
|
86 |
+
|
87 |
+
|
88 |
+
|
89 |
+
<?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
|
90 |
+
<?php $_incl = $this->helper('checkout')->getPriceInclTax($_item); ?>
|
91 |
+
<?php if ($this->helper('tax')->displayCartBothPrices()): ?>
|
92 |
+
<br /><?php echo $this->__('Incl. Tax'); ?>:
|
93 |
+
<?php endif; ?>
|
94 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?>
|
95 |
+
<?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?>
|
96 |
+
<?php else: ?>
|
97 |
+
<?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?>
|
98 |
+
<?php endif; ?>
|
99 |
+
<?php if (Mage::helper('weee')->getApplied($_item)): ?>
|
100 |
+
<br />
|
101 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales')): ?>
|
102 |
+
<small>
|
103 |
+
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
104 |
+
<span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span><br />
|
105 |
+
<?php endforeach; ?>
|
106 |
+
</small>
|
107 |
+
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
|
108 |
+
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
109 |
+
<span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></small></span><br />
|
110 |
+
<?php endforeach; ?>
|
111 |
+
<?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales')): ?>
|
112 |
+
<small>
|
113 |
+
<?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
|
114 |
+
<span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span><br />
|
115 |
+
<?php endforeach; ?>
|
116 |
+
</small>
|
117 |
+
<?php endif; ?>
|
118 |
+
<?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
|
119 |
+
<span class="nobr"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>:<br /> <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?></span>
|
120 |
+
<?php endif; ?>
|
121 |
+
<?php endif; ?>
|
122 |
+
<?php endif; ?>
|
123 |
+
|
124 |
+
<?php endif; //Can apply MSRP ?>
|
125 |
+
|
126 |
+
<?php if ($_options = $this->getOptionList()):?>
|
127 |
+
<div class="truncated">
|
128 |
+
<div class="truncated_full_value">
|
129 |
+
<dl class="item-options">
|
130 |
+
<?php foreach ($_options as $_option) : ?>
|
131 |
+
<dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
|
132 |
+
<dd>
|
133 |
+
<?php if (is_array($_option['value'])): ?>
|
134 |
+
<?php echo nl2br(implode("\n", $_option['value'])) ?>
|
135 |
+
<?php else: ?>
|
136 |
+
<?php echo $_option['value'] ?>
|
137 |
+
<?php endif; ?>
|
138 |
+
</dd>
|
139 |
+
<?php endforeach; ?>
|
140 |
+
</dl>
|
141 |
+
</div>
|
142 |
+
<a href="#" onclick="return false;" class="details"><?php echo $this->__('Details') ?></a>
|
143 |
+
</div>
|
144 |
+
<?php endif; ?>
|
145 |
+
</div>
|
146 |
+
</li>
|
app/design/frontend/base/default/template/skybox/checkout/cart_list.phtml
CHANGED
@@ -1,196 +1,196 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/afl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category design
|
22 |
-
* @package base_default
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
-
*/
|
26 |
-
?>
|
27 |
-
<?php
|
28 |
-
/**
|
29 |
-
* Shopping cart template
|
30 |
-
*
|
31 |
-
* @see Mage_Checkout_Block_Cart
|
32 |
-
*/
|
33 |
-
?>
|
34 |
-
<div class="cart">
|
35 |
-
<div class="page-title title-buttons">
|
36 |
-
<h1><?php echo $this->__('Shopping Cart') ?></h1>
|
37 |
-
<?php if(!$this->hasError()): ?>
|
38 |
-
<ul class="checkout-types">
|
39 |
-
<?php foreach ($this->getMethods('top_methods') as $method): ?>
|
40 |
-
<?php if ($methodHtml = $this->getMethodHtml($method)): ?>
|
41 |
-
<li><?php echo $methodHtml; ?></li>
|
42 |
-
<?php endif; ?>
|
43 |
-
<?php endforeach; ?>
|
44 |
-
</ul>
|
45 |
-
<?php endif; ?>
|
46 |
-
</div>
|
47 |
-
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
48 |
-
<?php echo $this->getChildHtml('form_before') ?>
|
49 |
-
<div class="skx-cart-list-product">
|
50 |
-
<form action="<?php echo $this->getUrl('checkout/cart/updatePost') ?>" method="post">
|
51 |
-
<?php echo $this->getBlockHtml('formkey'); ?>
|
52 |
-
<table id="shopping-cart-table" class="data-table cart-table">
|
53 |
-
<col width="1" />
|
54 |
-
<col />
|
55 |
-
<col width="1" />
|
56 |
-
<?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
|
57 |
-
<col width="1" />
|
58 |
-
<?php endif ?>
|
59 |
-
<?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
|
60 |
-
<col width="1" />
|
61 |
-
<?php endif; ?>
|
62 |
-
<?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
|
63 |
-
<col width="1" />
|
64 |
-
<?php endif; ?>
|
65 |
-
<col width="1" />
|
66 |
-
<?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
|
67 |
-
<col width="1" />
|
68 |
-
<?php endif; ?>
|
69 |
-
<?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
|
70 |
-
<col width="1" />
|
71 |
-
<?php endif; ?>
|
72 |
-
<col width="1" />
|
73 |
-
|
74 |
-
<?php $mergedCells = ($this->helper('tax')->displayCartBothPrices() ? 2 : 1); ?>
|
75 |
-
<thead>
|
76 |
-
<tr>
|
77 |
-
<th rowspan="<?php echo $mergedCells; ?>"> </th>
|
78 |
-
<th rowspan="<?php echo $mergedCells; ?>"><span class="nobr"><?php echo $this->__('Product Name') ?></span></th>
|
79 |
-
<th rowspan="<?php echo $mergedCells; ?>"></th>
|
80 |
-
<?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
|
81 |
-
<th rowspan="<?php echo $mergedCells; ?>" class="a-center"><span class="nobr"><?php echo $this->__('Move to Wishlist') ?></span></th>
|
82 |
-
<?php endif ?>
|
83 |
-
<th class="a-center" colspan="<?php echo $mergedCells; ?>"><span class="nobr"><?php echo $this->__('Unit Price') ?></span></th>
|
84 |
-
<!--<th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Customs') ?></th>
|
85 |
-
<th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Insurance') ?></th>
|
86 |
-
<th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Shipping') ?></th>
|
87 |
-
<th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Price') ?></th>-->
|
88 |
-
<th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Qty') ?></th>
|
89 |
-
<th class="a-center" colspan="<?php echo $mergedCells; ?>"><?php echo $this->__('Subtotal') ?></th>
|
90 |
-
<th rowspan="<?php echo $mergedCells; ?>" class="a-center"> </th>
|
91 |
-
</tr>
|
92 |
-
<?php if ($this->helper('tax')->displayCartBothPrices()): ?>
|
93 |
-
<tr>
|
94 |
-
<th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
|
95 |
-
<th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
|
96 |
-
<th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
|
97 |
-
<th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
|
98 |
-
</tr>
|
99 |
-
<?php endif; ?>
|
100 |
-
</thead>
|
101 |
-
<tfoot>
|
102 |
-
<tr>
|
103 |
-
<td colspan="50" class="a-right">
|
104 |
-
<?php if($this->getContinueShoppingUrl()): ?>
|
105 |
-
<button type="button" title="<?php echo $this->__('Continue Shopping') ?>" class="button btn-continue" onclick="setLocation('<?php echo $this->getContinueShoppingUrl() ?>')"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
|
106 |
-
<?php endif; ?>
|
107 |
-
<button type="submit" name="update_cart_action" value="update_qty" title="<?php echo $this->__('Update Shopping Cart'); ?>" class="button btn-update"><span><span><?php echo $this->__('Update Shopping Cart'); ?></span></span></button>
|
108 |
-
<button type="submit" name="update_cart_action" value="empty_cart" title="<?php echo $this->__('Clear Shopping Cart'); ?>" class="button btn-empty" id="empty_cart_button"><span><span><?php echo $this->__('Clear Shopping Cart'); ?></span></span></button>
|
109 |
-
<!--[if lt IE 8]>
|
110 |
-
<input type="hidden" id="update_cart_action_container" />
|
111 |
-
<script type="text/javascript">
|
112 |
-
//<![CDATA[
|
113 |
-
Event.observe(window, 'load', function()
|
114 |
-
{
|
115 |
-
// Internet Explorer (lt 8) does not support value attribute in button elements
|
116 |
-
$emptyCartButton = $('empty_cart_button');
|
117 |
-
$cartActionContainer = $('update_cart_action_container');
|
118 |
-
if ($emptyCartButton && $cartActionContainer) {
|
119 |
-
Event.observe($emptyCartButton, 'click', function()
|
120 |
-
{
|
121 |
-
$emptyCartButton.setAttribute('name', 'update_cart_action_temp');
|
122 |
-
$cartActionContainer.setAttribute('name', 'update_cart_action');
|
123 |
-
$cartActionContainer.setValue('empty_cart');
|
124 |
-
});
|
125 |
-
}
|
126 |
-
|
127 |
-
});
|
128 |
-
//]]>
|
129 |
-
</script>
|
130 |
-
<![endif]-->
|
131 |
-
</td>
|
132 |
-
</tr>
|
133 |
-
</tfoot>
|
134 |
-
<tbody>
|
135 |
-
<?php foreach($this->getItems() as $_item): ?>
|
136 |
-
<?php echo $this->getItemHtml($_item) ?>
|
137 |
-
<?php endforeach ?>
|
138 |
-
</tbody>
|
139 |
-
</table>
|
140 |
-
<script type="text/javascript">decorateTable('shopping-cart-table')</script>
|
141 |
-
</form>
|
142 |
-
</div>
|
143 |
-
<div class="skx-cart-total-product">
|
144 |
-
<div class="cart-forms">
|
145 |
-
<?php echo $this->getChildHtml('crosssell') ?>
|
146 |
-
<?php echo $this->getChildHtml('checkout.cart.extra') ?>
|
147 |
-
<?php echo $this->getChildHtml('coupon') ?>
|
148 |
-
<?php if (!$this->getIsVirtual()): echo $this->getChildHtml('shipping'); endif; ?>
|
149 |
-
</div>
|
150 |
-
<div class="cart-totals-wrapper">
|
151 |
-
<div class="cart-totals">
|
152 |
-
<?php echo $this->getChildHtml('totals'); ?>
|
153 |
-
<?php if(!$this->hasError()): ?>
|
154 |
-
<ul class="checkout-types">
|
155 |
-
<?php foreach ($this->getMethods('methods') as $method): ?>
|
156 |
-
<?php if ($methodHtml = $this->getMethodHtml($method)): ?>
|
157 |
-
<li><?php echo $methodHtml; ?></li>
|
158 |
-
<?php endif; ?>
|
159 |
-
<?php endforeach; ?>
|
160 |
-
</ul>
|
161 |
-
<?php endif; ?>
|
162 |
-
</div>
|
163 |
-
</div>
|
164 |
-
</div>
|
165 |
-
</div>
|
166 |
-
<style type="text/css">
|
167 |
-
/*@media (min-width:320px) */
|
168 |
-
.cart .cart-totals table tfoot strong span, .cart .cart-totals table tfoot span.price {
|
169 |
-
white-space: nowrap;
|
170 |
-
}
|
171 |
-
@media screen and (max-width: 320px) , screen and (max-height: 480px) {
|
172 |
-
.cart-table {
|
173 |
-
float: none;
|
174 |
-
width: 100%;
|
175 |
-
}
|
176 |
-
.cart-forms, .cart-totals-wrapper, .crosssell {
|
177 |
-
float: none;
|
178 |
-
width: 100%;
|
179 |
-
padding-left: 0;
|
180 |
-
}
|
181 |
-
|
182 |
-
.cart .button
|
183 |
-
{
|
184 |
-
display: block;
|
185 |
-
width: 100%;
|
186 |
-
margin: 5px;
|
187 |
-
float: none !important;
|
188 |
-
}
|
189 |
-
|
190 |
-
.cart-table tbody td.a-center {
|
191 |
-
display: block;
|
192 |
-
text-align: right;
|
193 |
-
}
|
194 |
-
|
195 |
-
}
|
196 |
</style>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php
|
28 |
+
/**
|
29 |
+
* Shopping cart template
|
30 |
+
*
|
31 |
+
* @see Mage_Checkout_Block_Cart
|
32 |
+
*/
|
33 |
+
?>
|
34 |
+
<div class="cart">
|
35 |
+
<div class="page-title title-buttons">
|
36 |
+
<h1><?php echo $this->__('Shopping Cart') ?></h1>
|
37 |
+
<?php if(!$this->hasError()): ?>
|
38 |
+
<ul class="checkout-types">
|
39 |
+
<?php foreach ($this->getMethods('top_methods') as $method): ?>
|
40 |
+
<?php if ($methodHtml = $this->getMethodHtml($method)): ?>
|
41 |
+
<li><?php echo $methodHtml; ?></li>
|
42 |
+
<?php endif; ?>
|
43 |
+
<?php endforeach; ?>
|
44 |
+
</ul>
|
45 |
+
<?php endif; ?>
|
46 |
+
</div>
|
47 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
48 |
+
<?php echo $this->getChildHtml('form_before') ?>
|
49 |
+
<div class="skx-cart-list-product">
|
50 |
+
<form action="<?php echo $this->getUrl('checkout/cart/updatePost') ?>" method="post">
|
51 |
+
<?php echo $this->getBlockHtml('formkey'); ?>
|
52 |
+
<table id="shopping-cart-table" class="data-table cart-table">
|
53 |
+
<col width="1" />
|
54 |
+
<col />
|
55 |
+
<col width="1" />
|
56 |
+
<?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
|
57 |
+
<col width="1" />
|
58 |
+
<?php endif ?>
|
59 |
+
<?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
|
60 |
+
<col width="1" />
|
61 |
+
<?php endif; ?>
|
62 |
+
<?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
|
63 |
+
<col width="1" />
|
64 |
+
<?php endif; ?>
|
65 |
+
<col width="1" />
|
66 |
+
<?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
|
67 |
+
<col width="1" />
|
68 |
+
<?php endif; ?>
|
69 |
+
<?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
|
70 |
+
<col width="1" />
|
71 |
+
<?php endif; ?>
|
72 |
+
<col width="1" />
|
73 |
+
|
74 |
+
<?php $mergedCells = ($this->helper('tax')->displayCartBothPrices() ? 2 : 1); ?>
|
75 |
+
<thead>
|
76 |
+
<tr>
|
77 |
+
<th rowspan="<?php echo $mergedCells; ?>"> </th>
|
78 |
+
<th rowspan="<?php echo $mergedCells; ?>"><span class="nobr"><?php echo $this->__('Product Name') ?></span></th>
|
79 |
+
<th rowspan="<?php echo $mergedCells; ?>"></th>
|
80 |
+
<?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
|
81 |
+
<th rowspan="<?php echo $mergedCells; ?>" class="a-center"><span class="nobr"><?php echo $this->__('Move to Wishlist') ?></span></th>
|
82 |
+
<?php endif ?>
|
83 |
+
<th class="a-center" colspan="<?php echo $mergedCells; ?>"><span class="nobr"><?php echo $this->__('Unit Price') ?></span></th>
|
84 |
+
<!--<th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Customs') ?></th>
|
85 |
+
<th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Insurance') ?></th>
|
86 |
+
<th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Shipping') ?></th>
|
87 |
+
<th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Price') ?></th>-->
|
88 |
+
<th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Qty') ?></th>
|
89 |
+
<th class="a-center" colspan="<?php echo $mergedCells; ?>"><?php echo $this->__('Subtotal') ?></th>
|
90 |
+
<th rowspan="<?php echo $mergedCells; ?>" class="a-center"> </th>
|
91 |
+
</tr>
|
92 |
+
<?php if ($this->helper('tax')->displayCartBothPrices()): ?>
|
93 |
+
<tr>
|
94 |
+
<th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
|
95 |
+
<th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
|
96 |
+
<th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
|
97 |
+
<th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
|
98 |
+
</tr>
|
99 |
+
<?php endif; ?>
|
100 |
+
</thead>
|
101 |
+
<tfoot>
|
102 |
+
<tr>
|
103 |
+
<td colspan="50" class="a-right">
|
104 |
+
<?php if($this->getContinueShoppingUrl()): ?>
|
105 |
+
<button type="button" title="<?php echo $this->__('Continue Shopping') ?>" class="button btn-continue" onclick="setLocation('<?php echo $this->getContinueShoppingUrl() ?>')"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
|
106 |
+
<?php endif; ?>
|
107 |
+
<button type="submit" name="update_cart_action" value="update_qty" title="<?php echo $this->__('Update Shopping Cart'); ?>" class="button btn-update"><span><span><?php echo $this->__('Update Shopping Cart'); ?></span></span></button>
|
108 |
+
<button type="submit" name="update_cart_action" value="empty_cart" title="<?php echo $this->__('Clear Shopping Cart'); ?>" class="button btn-empty" id="empty_cart_button"><span><span><?php echo $this->__('Clear Shopping Cart'); ?></span></span></button>
|
109 |
+
<!--[if lt IE 8]>
|
110 |
+
<input type="hidden" id="update_cart_action_container" />
|
111 |
+
<script type="text/javascript">
|
112 |
+
//<![CDATA[
|
113 |
+
Event.observe(window, 'load', function()
|
114 |
+
{
|
115 |
+
// Internet Explorer (lt 8) does not support value attribute in button elements
|
116 |
+
$emptyCartButton = $('empty_cart_button');
|
117 |
+
$cartActionContainer = $('update_cart_action_container');
|
118 |
+
if ($emptyCartButton && $cartActionContainer) {
|
119 |
+
Event.observe($emptyCartButton, 'click', function()
|
120 |
+
{
|
121 |
+
$emptyCartButton.setAttribute('name', 'update_cart_action_temp');
|
122 |
+
$cartActionContainer.setAttribute('name', 'update_cart_action');
|
123 |
+
$cartActionContainer.setValue('empty_cart');
|
124 |
+
});
|
125 |
+
}
|
126 |
+
|
127 |
+
});
|
128 |
+
//]]>
|
129 |
+
</script>
|
130 |
+
<![endif]-->
|
131 |
+
</td>
|
132 |
+
</tr>
|
133 |
+
</tfoot>
|
134 |
+
<tbody>
|
135 |
+
<?php foreach($this->getItems() as $_item): ?>
|
136 |
+
<?php echo $this->getItemHtml($_item) ?>
|
137 |
+
<?php endforeach ?>
|
138 |
+
</tbody>
|
139 |
+
</table>
|
140 |
+
<script type="text/javascript">decorateTable('shopping-cart-table')</script>
|
141 |
+
</form>
|
142 |
+
</div>
|
143 |
+
<div class="skx-cart-total-product">
|
144 |
+
<div class="cart-forms">
|
145 |
+
<?php echo $this->getChildHtml('crosssell') ?>
|
146 |
+
<?php echo $this->getChildHtml('checkout.cart.extra') ?>
|
147 |
+
<?php echo $this->getChildHtml('coupon') ?>
|
148 |
+
<?php if (!$this->getIsVirtual()): echo $this->getChildHtml('shipping'); endif; ?>
|
149 |
+
</div>
|
150 |
+
<div class="cart-totals-wrapper">
|
151 |
+
<div class="cart-totals">
|
152 |
+
<?php echo $this->getChildHtml('totals'); ?>
|
153 |
+
<?php if(!$this->hasError()): ?>
|
154 |
+
<ul class="checkout-types">
|
155 |
+
<?php foreach ($this->getMethods('methods') as $method): ?>
|
156 |
+
<?php if ($methodHtml = $this->getMethodHtml($method)): ?>
|
157 |
+
<li><?php echo $methodHtml; ?></li>
|
158 |
+
<?php endif; ?>
|
159 |
+
<?php endforeach; ?>
|
160 |
+
</ul>
|
161 |
+
<?php endif; ?>
|
162 |
+
</div>
|
163 |
+
</div>
|
164 |
+
</div>
|
165 |
+
</div>
|
166 |
+
<style type="text/css">
|
167 |
+
/*@media (min-width:320px) */
|
168 |
+
.cart .cart-totals table tfoot strong span, .cart .cart-totals table tfoot span.price {
|
169 |
+
white-space: nowrap;
|
170 |
+
}
|
171 |
+
@media screen and (max-width: 320px) , screen and (max-height: 480px) {
|
172 |
+
.cart-table {
|
173 |
+
float: none;
|
174 |
+
width: 100%;
|
175 |
+
}
|
176 |
+
.cart-forms, .cart-totals-wrapper, .crosssell {
|
177 |
+
float: none;
|
178 |
+
width: 100%;
|
179 |
+
padding-left: 0;
|
180 |
+
}
|
181 |
+
|
182 |
+
.cart .button
|
183 |
+
{
|
184 |
+
display: block;
|
185 |
+
width: 100%;
|
186 |
+
margin: 5px;
|
187 |
+
float: none !important;
|
188 |
+
}
|
189 |
+
|
190 |
+
.cart-table tbody td.a-center {
|
191 |
+
display: block;
|
192 |
+
text-align: right;
|
193 |
+
}
|
194 |
+
|
195 |
+
}
|
196 |
</style>
|
app/design/frontend/base/default/template/skybox/checkout/multishipping/link.phtml
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @see Mage_Checkout_Block_Multishipping_Link
|
4 |
-
*/
|
5 |
-
$allowHelper = Mage::helper('skyboxcore/allow');
|
6 |
-
if (!$allowHelper->isPriceEnabled()) :
|
7 |
-
?>
|
8 |
-
<?php echo $this->getChildHtml('multishipping2') ?>
|
9 |
-
<?php
|
10 |
-
endif;
|
11 |
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @see Mage_Checkout_Block_Multishipping_Link
|
4 |
+
*/
|
5 |
+
$allowHelper = Mage::helper('skyboxcore/allow');
|
6 |
+
if (!$allowHelper->isPriceEnabled()) :
|
7 |
+
?>
|
8 |
+
<?php echo $this->getChildHtml('multishipping2') ?>
|
9 |
+
<?php
|
10 |
+
endif;
|
11 |
?>
|
app/design/frontend/base/default/template/skybox/checkout/onepage.phtml
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl("skbcheckout/international"));
|
1 |
+
<?php
|
2 |
+
|
3 |
+
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl("skbcheckout/international"));
|
app/design/frontend/base/default/template/skybox/checkout/onepage/link.phtml
CHANGED
@@ -1,38 +1,38 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/afl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magento.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magento.com for more information.
|
20 |
-
*
|
21 |
-
* @category design
|
22 |
-
* @package base_default
|
23 |
-
* @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
|
24 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
$allowHelper = Mage::helper('skyboxcore/allow');
|
28 |
-
if ($allowHelper->isCartButtonSkyboxEnabled()) :
|
29 |
-
?>
|
30 |
-
<button type="button"
|
31 |
-
class="button btn-proceed-checkout btn-checkout"
|
32 |
-
onclick="window.location='<?php echo $this->getUrl('skbcheckout/international',
|
33 |
-
array('_secure' => true)) ?>';">
|
34 |
-
<span>
|
35 |
-
<span><?php echo $this->__('Checkout with SkyBOX Checkout') ?></span>
|
36 |
-
</span>
|
37 |
-
</button>
|
38 |
<?php endif; ?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
$allowHelper = Mage::helper('skyboxcore/allow');
|
28 |
+
if ($allowHelper->isCartButtonSkyboxEnabled()) :
|
29 |
+
?>
|
30 |
+
<button type="button"
|
31 |
+
class="button btn-proceed-checkout btn-checkout"
|
32 |
+
onclick="window.location='<?php echo $this->getUrl('skbcheckout/international',
|
33 |
+
array('_secure' => true)) ?>';">
|
34 |
+
<span>
|
35 |
+
<span><?php echo $this->__('Checkout with SkyBOX Checkout') ?></span>
|
36 |
+
</span>
|
37 |
+
</button>
|
38 |
<?php endif; ?>
|
app/design/frontend/base/default/template/skybox/checkout/pagecheckout.phtml
CHANGED
@@ -1,32 +1,32 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Template for Mage_Page_Block_Html
|
4 |
-
*/
|
5 |
-
?>
|
6 |
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
7 |
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">
|
8 |
-
<head>
|
9 |
-
<?php echo $this->getChildHtml('head') ?>
|
10 |
-
</head>
|
11 |
-
<body<?php echo $this->getBodyClass()?' class="'.$this->getBodyClass().'"':'' ?>>
|
12 |
-
<?php echo $this->getChildHtml('after_body_start') ?>
|
13 |
-
<div class="wrapper">
|
14 |
-
<?php echo $this->getChildHtml('global_notices') ?>
|
15 |
-
<div class="page">
|
16 |
-
<?php echo $this->getChildHtml('headerskybox') ?>
|
17 |
-
<div class="main-container col1-layout">
|
18 |
-
<div class="main">
|
19 |
-
<div class="col-main">
|
20 |
-
<?php echo $this->getChildHtml('global_messages') ?>
|
21 |
-
<?php echo $this->getChildHtml('content') ?>
|
22 |
-
</div>
|
23 |
-
</div>
|
24 |
-
</div>
|
25 |
-
<?php echo $this->getChildHtml('footer') ?>
|
26 |
-
<?php echo $this->getChildHtml('global_cookie_notice') ?>
|
27 |
-
<?php echo $this->getChildHtml('before_body_end') ?>
|
28 |
-
</div>
|
29 |
-
</div>
|
30 |
-
<?php echo $this->getAbsoluteFooter() ?>
|
31 |
-
</body>
|
32 |
</html>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Template for Mage_Page_Block_Html
|
4 |
+
*/
|
5 |
+
?>
|
6 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
7 |
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">
|
8 |
+
<head>
|
9 |
+
<?php echo $this->getChildHtml('head') ?>
|
10 |
+
</head>
|
11 |
+
<body<?php echo $this->getBodyClass()?' class="'.$this->getBodyClass().'"':'' ?>>
|
12 |
+
<?php echo $this->getChildHtml('after_body_start') ?>
|
13 |
+
<div class="wrapper">
|
14 |
+
<?php echo $this->getChildHtml('global_notices') ?>
|
15 |
+
<div class="page">
|
16 |
+
<?php echo $this->getChildHtml('headerskybox') ?>
|
17 |
+
<div class="main-container col1-layout">
|
18 |
+
<div class="main">
|
19 |
+
<div class="col-main">
|
20 |
+
<?php echo $this->getChildHtml('global_messages') ?>
|
21 |
+
<?php echo $this->getChildHtml('content') ?>
|
22 |
+
</div>
|
23 |
+
</div>
|
24 |
+
</div>
|
25 |
+
<?php echo $this->getChildHtml('footer') ?>
|
26 |
+
<?php echo $this->getChildHtml('global_cookie_notice') ?>
|
27 |
+
<?php echo $this->getChildHtml('before_body_end') ?>
|
28 |
+
</div>
|
29 |
+
</div>
|
30 |
+
<?php echo $this->getAbsoluteFooter() ?>
|
31 |
+
</body>
|
32 |
</html>
|
app/design/frontend/base/default/template/skybox/checkout/skyboxcheckout.phtml
CHANGED
@@ -1,358 +1,358 @@
|
|
1 |
-
<?php
|
2 |
-
$_helper = Mage::helper('skyboxinternational/data');
|
3 |
-
|
4 |
-
$_model = Mage::getModel('skyboxcore/standard');
|
5 |
-
|
6 |
-
/** @var Skybox_Core_Model_Config $_config */
|
7 |
-
$_config = Mage::getModel('skyboxcore/config');
|
8 |
-
|
9 |
-
/** @var Skybox_Checkout_Model_Api_Checkout $_checkout */
|
10 |
-
$_checkout = Mage::getModel('skyboxcheckout/api_checkout');
|
11 |
-
|
12 |
-
/** @var Skybox_Core_Helper_Allow $allowHelper */
|
13 |
-
$allowHelper = Mage::helper('skyboxcore/allow');
|
14 |
-
|
15 |
-
$isCartEnabled = $allowHelper->isCartBarEnabled();
|
16 |
-
|
17 |
-
$_cartDataURL = "";
|
18 |
-
$_merchant = $_helper->getMerchantCode();
|
19 |
-
$template = "";
|
20 |
-
$cartId = $_helper->getCartId();
|
21 |
-
|
22 |
-
Mage::log("InitializeBarSkybox ", null, 'skyboxcheckout.log', true);
|
23 |
-
$_checkout->InitializeBarSkybox();
|
24 |
-
|
25 |
-
$change_country = false;
|
26 |
-
$request = $this->getRequest();
|
27 |
-
$module = $request->getModuleName();
|
28 |
-
$controller = $request->getControllerName();
|
29 |
-
$action = $request->getActionName();
|
30 |
-
$getHomeUrl = Mage::helper('core/url')->getHomeUrl();
|
31 |
-
$_url_check_cart = Mage::getUrl("checkout/cart");
|
32 |
-
|
33 |
-
$cart = $_config->getSession()->getCartSkybox();
|
34 |
-
/**
|
35 |
-
* Start Aditional we add a line debug with integration information
|
36 |
-
*/
|
37 |
-
echo '<script>
|
38 |
-
console.log("LocationAllowService: ' . $_checkout->getLocationAllow() . ' ");
|
39 |
-
</script>';
|
40 |
-
/**
|
41 |
-
* End Aditional we add a line debug with integration information
|
42 |
-
*/
|
43 |
-
//$template = "<a href='#' id='link_choise_country'> </a>";
|
44 |
-
// Load CSS & JS
|
45 |
-
$skybox_url = $_helper->getSkyboxUrlMain();// $_config->skyboxDefaultUrl;
|
46 |
-
$api_css_button_international = $skybox_url . 'widgets/api-button/css/api-button-international-css.ashx';
|
47 |
-
$api_css_button_international .= '?s=' . $_helper->getMerchantCode();
|
48 |
-
$api_css_button_international .= '&CssVersion=' . $_helper->getCssVersion();
|
49 |
-
$api_js_button_international = $skybox_url . 'Content/debug/API/js/api-button-tooltip.js';
|
50 |
-
|
51 |
-
if ($allowHelper->isCartBarEnabled()) :
|
52 |
-
$template = '';
|
53 |
-
$cart = $_config->getSession()->getCartSkybox();
|
54 |
-
if (!empty($cart)) :
|
55 |
-
$template = $cart->BarHtmlTemplate;
|
56 |
-
foreach ($cart as $key => $value) :
|
57 |
-
$template = str_replace('{' . $key . '}', $value, $template);
|
58 |
-
endforeach;
|
59 |
-
endif;
|
60 |
-
$_cartDataURL = $cart->CartDataURL;
|
61 |
-
echo $template;
|
62 |
-
endif;
|
63 |
-
?>
|
64 |
-
<link rel="stylesheet" type="text/css" href="<?php echo $api_css_button_international; ?>"/>
|
65 |
-
<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('css/skybox/style.css?v=' . $_helper->getCssVersion()); ?>"/>
|
66 |
-
<!-- <link rel="stylesheet" type="text/css" href="--><?php #echo $this->getSkinUrl('css/skybox/style.css?v=230120171122');?><!--"/>-->
|
67 |
-
<script type="text/javascript">
|
68 |
-
var URL_CHECK_CART = "<?php echo $_url_check_cart ?>";
|
69 |
-
var CART_ID = "<?php echo $cartId ?>";
|
70 |
-
var CART_DATA_URL = "<?php echo $_cartDataURL ?>";
|
71 |
-
var MERCHANT = "<?php echo $_merchant ?>";
|
72 |
-
var SKYBOX_URL = "<?php echo $skybox_url ?>";
|
73 |
-
var CHANGE_COUNTRY = "<?php echo $change_country ?>";
|
74 |
-
var ACTUAL_URI = "<?php echo 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'] ?>";
|
75 |
-
var GET_HOME_URL = "<?php echo $getHomeUrl ?>";
|
76 |
-
jQuery(document).ready(function() {
|
77 |
-
jQuery(".skybox-price-set").each(function( index ) {
|
78 |
-
<?php
|
79 |
-
$skyBoxUrlClientBase= $_helper->getSkyBoxUrlAPI();
|
80 |
-
$codeShop = Mage::getModel('skyboxcatalog/api_product')->getStoreCode();
|
81 |
-
$skyBoxUrlClientGet = str_replace("apirest/", "", $skyBoxUrlClientBase);
|
82 |
-
$skyBoxUrlClient = $skyBoxUrlClientGet . "multiplecalculate/" . $codeShop . "/calc-";
|
83 |
-
?>
|
84 |
-
var SkyBoxUrlClient = "<?php echo $skyBoxUrlClient;?>";
|
85 |
-
var dataId = jQuery(this).attr("id");
|
86 |
-
var id = jQuery(this).attr("product-id");
|
87 |
-
var url = SkyBoxUrlClient + id + ".html";
|
88 |
-
var content = jQuery.get(url, function (data) {
|
89 |
-
jQuery("#" + dataId).html(data);
|
90 |
-
});
|
91 |
-
});
|
92 |
-
});
|
93 |
-
|
94 |
-
(function ($) {
|
95 |
-
|
96 |
-
var widthPage = 0;
|
97 |
-
var heightPage = 0;
|
98 |
-
var popup = {};
|
99 |
-
var popupWidth = 540;
|
100 |
-
var popupHeight = 545;
|
101 |
-
var win = '';
|
102 |
-
|
103 |
-
function showPopup(name, t, url, w, h) {
|
104 |
-
//winCompare = new Window('popup', {className: 'alphacube', title: t, url: url, width: w, height: h, minimizable: false, maximizable: false, showEffectOptions: {duration: 0.4}, hideEffectOptions: {duration: 0.4} });
|
105 |
-
winCompare = new Window(name, {
|
106 |
-
className: 'alphacube',
|
107 |
-
title: t,
|
108 |
-
url: url,
|
109 |
-
width: w,
|
110 |
-
height: h,
|
111 |
-
minimizable: false,
|
112 |
-
maximizable: false,
|
113 |
-
showEffectOptions: {duration: 0.4},
|
114 |
-
hideEffectOptions: {duration: 0.4},
|
115 |
-
destroyOnClose: true,
|
116 |
-
draggable: false,
|
117 |
-
resizable: false
|
118 |
-
});
|
119 |
-
|
120 |
-
winCompare.setDestroyOnClose();
|
121 |
-
winCompare.setZIndex(9999);
|
122 |
-
winCompare.showCenter(true);
|
123 |
-
return winCompare;
|
124 |
-
}
|
125 |
-
|
126 |
-
function goToCart() {
|
127 |
-
document.location = URL_CHECK_CART;
|
128 |
-
}
|
129 |
-
|
130 |
-
function goToInitializeSession() {
|
131 |
-
var idCart = CART_ID;
|
132 |
-
var datos = CART_DATA_URL;
|
133 |
-
var merchant = MERCHANT;
|
134 |
-
var actualUri = ACTUAL_URI + "?LoadFrame=1";
|
135 |
-
var url = SKYBOX_URL + "WebForms/PublicSite/Tracking.aspx?" + datos + "&merchant=" + merchant + "&idCart=" + idCart + "&ReLoad=1&uri=" + actualUri;
|
136 |
-
var name = 'initSession' + Date.now();
|
137 |
-
callAlphacube();
|
138 |
-
showPopup(name, '', url, (widthPage - 50 ), ((heightPage < 800) ? heightPage - 50 : 800));
|
139 |
-
}
|
140 |
-
|
141 |
-
function callAlphacube(){
|
142 |
-
var alphacube_ = document.querySelectorAll('.alphacube_close');
|
143 |
-
if(alphacube_.length > 0){
|
144 |
-
var overlay_ = document.getElementById("overlay_modal");
|
145 |
-
|
146 |
-
if(overlay_ !== null) overlay_.style.display = '';
|
147 |
-
var id_modal = (alphacube_[1]) ? alphacube_[1].parentNode.getAttribute('id') : '';
|
148 |
-
try{
|
149 |
-
document.getElementById(id_modal).remove();
|
150 |
-
}
|
151 |
-
catch(e) {
|
152 |
-
|
153 |
-
}
|
154 |
-
}
|
155 |
-
}
|
156 |
-
|
157 |
-
function goToLocation() {
|
158 |
-
win = 'resync';
|
159 |
-
var datos = CART_DATA_URL;
|
160 |
-
var process_url = GET_HOME_URL + "skbcheckout/process";
|
161 |
-
var return_url = getReturnUrl();
|
162 |
-
// var return_url = document.URL;
|
163 |
-
var change_country_status = CHANGE_COUNTRY;
|
164 |
-
var url = SKYBOX_URL + "Webforms/PublicSite/ReSync.aspx?" + datos;
|
165 |
-
url += "&process_url=" + process_url;
|
166 |
-
url += "&return_url=" + return_url;
|
167 |
-
url += "&change_country=" + change_country_status;
|
168 |
-
|
169 |
-
var _size = getSizeForPopup();
|
170 |
-
var name = 'selectLocation' + Date.now();
|
171 |
-
callAlphacube();
|
172 |
-
popup = showPopup(name, '', url, _size.width, _size.height);
|
173 |
-
}
|
174 |
-
|
175 |
-
function goToTrackingLocation() {
|
176 |
-
var url = SKYBOX_URL + "Webforms/PublicSite/Tracking.aspx?" + CART_DATA_URL + "&idCart=" + CART_ID;
|
177 |
-
var name = 'tracking' + Date.now();
|
178 |
-
showPopup(name, '', url, (widthPage - 50 ), ((heightPage < 800) ? heightPage - 50 : 800));
|
179 |
-
}
|
180 |
-
|
181 |
-
function loadIframe() {
|
182 |
-
var actualUri = ACTUAL_URI;
|
183 |
-
var flgLoadIframe = "<?php echo (isset($_GET['LoadFrame'])) ? $_GET['LoadFrame'] : 0; ?>";
|
184 |
-
if (flgLoadIframe === "1") {
|
185 |
-
if (actualUri.indexOf("skbcheckout/international") === -1) goToInitializeSession();
|
186 |
-
}
|
187 |
-
}
|
188 |
-
|
189 |
-
function postMessageIframe() {
|
190 |
-
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
|
191 |
-
var eventer = window[eventMethod];
|
192 |
-
var messageEvent = eventMethod === "attachEvent" ? "onmessage" : "message";
|
193 |
-
eventer(messageEvent,function(e) {
|
194 |
-
// if(e.origin == 'https://www.skyboxcheckout.com'){
|
195 |
-
recalculateHeightIframe(e.data);
|
196 |
-
// }
|
197 |
-
},false);
|
198 |
-
}
|
199 |
-
|
200 |
-
function recalculateHeightIframe(data) {
|
201 |
-
if (data.win === 'resync') {
|
202 |
-
popupHeight = data.height;
|
203 |
-
var _size = getSizeForPopup();
|
204 |
-
try{
|
205 |
-
popup.setSize(_size.width, _size.height);
|
206 |
-
}
|
207 |
-
catch (e) {
|
208 |
-
// console.log("not calculate popup:::: ", e);
|
209 |
-
}
|
210 |
-
// popup.showCenter(true);
|
211 |
-
}
|
212 |
-
}
|
213 |
-
|
214 |
-
function browserResize() {
|
215 |
-
jQuery(window).resize(function() {
|
216 |
-
if(!jQuery.isEmptyObject(popup)){
|
217 |
-
var _size = getSizeForPopup();
|
218 |
-
popup.setSize(_size.width, _size.height)
|
219 |
-
}
|
220 |
-
});
|
221 |
-
}
|
222 |
-
|
223 |
-
function getSizeForPopup() {
|
224 |
-
var _width = jQuery(window).width();
|
225 |
-
var _height = jQuery(window).height();
|
226 |
-
_width = (_width < popupWidth) ? _width - 30 : popupWidth ;
|
227 |
-
return {width: _width, height: popupHeight};
|
228 |
-
}
|
229 |
-
|
230 |
-
$(".skx_position_option_country").unbind().click(function () {
|
231 |
-
goToLocation();
|
232 |
-
});
|
233 |
-
|
234 |
-
$(".skx_banner_image_account").unbind().click(function () {
|
235 |
-
goToInitializeSession();
|
236 |
-
});
|
237 |
-
|
238 |
-
$(".skx_banner_image_car").unbind().click(function () {
|
239 |
-
goToCart();
|
240 |
-
});
|
241 |
-
|
242 |
-
$(".skx_banner_image_tracking").unbind().click(function () {
|
243 |
-
goToTrackingLocation();
|
244 |
-
});
|
245 |
-
|
246 |
-
$("#link_choise_country").unbind().click(function () {
|
247 |
-
goToCart();
|
248 |
-
});
|
249 |
-
|
250 |
-
$(document).ready(function () {
|
251 |
-
widthPage = $(window).width();
|
252 |
-
heightPage = $(window).height();
|
253 |
-
postMessageIframe();
|
254 |
-
loadIframe();
|
255 |
-
browserResize();
|
256 |
-
});
|
257 |
-
})(jQuery);
|
258 |
-
</script>
|
259 |
-
|
260 |
-
<script type="text/javascript">
|
261 |
-
//<![CDATA[
|
262 |
-
var SKYBOX_OPTIONS_PRICE_URL = '<?php echo Mage::getUrl(); ?>skbcheckout/calculate';
|
263 |
-
//]]>
|
264 |
-
</script>
|
265 |
-
|
266 |
-
<script type="text/javascript" src="<?php echo $api_js_button_international; ?>"></script>
|
267 |
-
|
268 |
-
<?php
|
269 |
-
|
270 |
-
/**
|
271 |
-
* Integration 3 start, show bar*
|
272 |
-
*/
|
273 |
-
if (!$_checkout->getErrorAuthenticate() && $_checkout->getLocationAllow()) : // Rogged
|
274 |
-
// Calculate height
|
275 |
-
$size = 0;
|
276 |
-
|
277 |
-
$UserTemporal = "1";
|
278 |
-
$CartItemCount = 0;
|
279 |
-
|
280 |
-
if (!$_checkout->getErrorAuthenticate() && $_checkout->getLocationAllow()) :
|
281 |
-
$cart = $_config->getSession()->getCartSkybox();
|
282 |
-
if (!empty($cart)) :
|
283 |
-
$UserTemporal = $cart->{'UserTemporal'};
|
284 |
-
$CartItemCount = intval($cart->{'CartItemCount'});
|
285 |
-
for ($i = 1; $i <= $CartItemCount; $i++) :
|
286 |
-
$size = $size + 50;
|
287 |
-
endfor;
|
288 |
-
endif;
|
289 |
-
endif;
|
290 |
-
|
291 |
-
|
292 |
-
$merchant = $_helper->getMerchantCode();
|
293 |
-
$storeId = $_helper->getStoreId();
|
294 |
-
$cartId = $_helper->getCartId();
|
295 |
-
$guid = $_model->getGuidApi();
|
296 |
-
$urlSuccess = Mage::getUrl("skbcheckout/international/success");
|
297 |
-
$urlConfirm = Mage::getUrl("skbcheckout/international");
|
298 |
-
$token = $_model->AuthenticateService()->getAuthorizedToken();
|
299 |
-
|
300 |
-
$url = $_helper->getSkyboxUrlMain() . "WebForms/Checkout/APICheckout.aspx"; //$_config->skyboxDefaultUrl . "WebForms/Checkout/APICheckout.aspx";
|
301 |
-
$url .= "?token=" . $token;
|
302 |
-
$url .= "&GuiId=" . $guid;
|
303 |
-
$url .= "&merchant=" . $merchant;
|
304 |
-
$url .= "&idCart=" . $cartId;
|
305 |
-
$url .= "&idStore=" . $storeId;
|
306 |
-
$url .= "&UrlC=" . $urlConfirm;// "http://magento.skynet.com/magento192/skbcheckout/international";
|
307 |
-
$url .= "&paypal=" . $_GET["paypal"];
|
308 |
-
$url .= '&checkout=' . strip_tags(Mage::app()->getRequest()->getParam('checkout',''));
|
309 |
-
$url .= "&UrlR=" . $urlSuccess;
|
310 |
-
|
311 |
-
if($size == 0):
|
312 |
-
$cart = Mage::getSingleton('checkout/session')->getQuote();
|
313 |
-
foreach ($cart->getAllItems() as $item) :
|
314 |
-
$size = $size + 50;
|
315 |
-
endforeach;
|
316 |
-
endif;
|
317 |
-
|
318 |
-
if($size == 0) $size = 100;
|
319 |
-
|
320 |
-
$height = (($UserTemporal == "1") ? 1400 : 900) + $size;
|
321 |
-
$height = 2500;
|
322 |
-
?>
|
323 |
-
<div class="div_iframe_skybox_checkout">
|
324 |
-
<iframe id="iframe_skybox_checkout" src="<?php echo $url; ?>" frameborder="0" scrolling="no"></iframe>
|
325 |
-
</div>
|
326 |
-
<script type="text/javascript">
|
327 |
-
jQuery(document).ready(function() {
|
328 |
-
var height = <?php echo $height; ?>;
|
329 |
-
var isMobile = /Mobi/.test(navigator.userAgent);
|
330 |
-
console.log("isMobile ::: " + isMobile);
|
331 |
-
if (isMobile) {
|
332 |
-
height = jQuery(window).height();
|
333 |
-
height = height * 5;
|
334 |
-
}
|
335 |
-
console.log("height ::: " + height);
|
336 |
-
jQuery('#iframe_skybox_checkout').attr('height', height);
|
337 |
-
});
|
338 |
-
</script>
|
339 |
-
<?php
|
340 |
-
// ----- Rogged -----
|
341 |
-
else:
|
342 |
-
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl("checkout/onepage"));
|
343 |
-
endif;
|
344 |
-
// ----- ----- -----
|
345 |
-
?>
|
346 |
-
<script>
|
347 |
-
setTimeout(function(){
|
348 |
-
var location_pathname = window.location.pathname.split('/');
|
349 |
-
var skx_bar = document.getElementsByClassName('skx-bar-text');
|
350 |
-
try{
|
351 |
-
if(location_pathname[2] === "international") skx_bar[0].style.display = "none";
|
352 |
-
}
|
353 |
-
catch(e) {
|
354 |
-
|
355 |
-
}
|
356 |
-
}, 300);
|
357 |
-
|
358 |
</script>
|
1 |
+
<?php
|
2 |
+
$_helper = Mage::helper('skyboxinternational/data');
|
3 |
+
|
4 |
+
$_model = Mage::getModel('skyboxcore/standard');
|
5 |
+
|
6 |
+
/** @var Skybox_Core_Model_Config $_config */
|
7 |
+
$_config = Mage::getModel('skyboxcore/config');
|
8 |
+
|
9 |
+
/** @var Skybox_Checkout_Model_Api_Checkout $_checkout */
|
10 |
+
$_checkout = Mage::getModel('skyboxcheckout/api_checkout');
|
11 |
+
|
12 |
+
/** @var Skybox_Core_Helper_Allow $allowHelper */
|
13 |
+
$allowHelper = Mage::helper('skyboxcore/allow');
|
14 |
+
|
15 |
+
$isCartEnabled = $allowHelper->isCartBarEnabled();
|
16 |
+
|
17 |
+
$_cartDataURL = "";
|
18 |
+
$_merchant = $_helper->getMerchantCode();
|
19 |
+
$template = "";
|
20 |
+
$cartId = $_helper->getCartId();
|
21 |
+
|
22 |
+
Mage::log("InitializeBarSkybox ", null, 'skyboxcheckout.log', true);
|
23 |
+
$_checkout->InitializeBarSkybox();
|
24 |
+
|
25 |
+
$change_country = false;
|
26 |
+
$request = $this->getRequest();
|
27 |
+
$module = $request->getModuleName();
|
28 |
+
$controller = $request->getControllerName();
|
29 |
+
$action = $request->getActionName();
|
30 |
+
$getHomeUrl = Mage::helper('core/url')->getHomeUrl();
|
31 |
+
$_url_check_cart = Mage::getUrl("checkout/cart");
|
32 |
+
|
33 |
+
$cart = $_config->getSession()->getCartSkybox();
|
34 |
+
/**
|
35 |
+
* Start Aditional we add a line debug with integration information
|
36 |
+
*/
|
37 |
+
echo '<script>
|
38 |
+
console.log("LocationAllowService: ' . $_checkout->getLocationAllow() . ' ");
|
39 |
+
</script>';
|
40 |
+
/**
|
41 |
+
* End Aditional we add a line debug with integration information
|
42 |
+
*/
|
43 |
+
//$template = "<a href='#' id='link_choise_country'> </a>";
|
44 |
+
// Load CSS & JS
|
45 |
+
$skybox_url = $_helper->getSkyboxUrlMain();// $_config->skyboxDefaultUrl;
|
46 |
+
$api_css_button_international = $skybox_url . 'widgets/api-button/css/api-button-international-css.ashx';
|
47 |
+
$api_css_button_international .= '?s=' . $_helper->getMerchantCode();
|
48 |
+
$api_css_button_international .= '&CssVersion=' . $_helper->getCssVersion();
|
49 |
+
$api_js_button_international = $skybox_url . 'Content/debug/API/js/api-button-tooltip.js';
|
50 |
+
|
51 |
+
if ($allowHelper->isCartBarEnabled()) :
|
52 |
+
$template = '';
|
53 |
+
$cart = $_config->getSession()->getCartSkybox();
|
54 |
+
if (!empty($cart)) :
|
55 |
+
$template = $cart->BarHtmlTemplate;
|
56 |
+
foreach ($cart as $key => $value) :
|
57 |
+
$template = str_replace('{' . $key . '}', $value, $template);
|
58 |
+
endforeach;
|
59 |
+
endif;
|
60 |
+
$_cartDataURL = $cart->CartDataURL;
|
61 |
+
echo $template;
|
62 |
+
endif;
|
63 |
+
?>
|
64 |
+
<link rel="stylesheet" type="text/css" href="<?php echo $api_css_button_international; ?>"/>
|
65 |
+
<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('css/skybox/style.css?v=' . $_helper->getCssVersion()); ?>"/>
|
66 |
+
<!-- <link rel="stylesheet" type="text/css" href="--><?php #echo $this->getSkinUrl('css/skybox/style.css?v=230120171122');?><!--"/>-->
|
67 |
+
<script type="text/javascript">
|
68 |
+
var URL_CHECK_CART = "<?php echo $_url_check_cart ?>";
|
69 |
+
var CART_ID = "<?php echo $cartId ?>";
|
70 |
+
var CART_DATA_URL = "<?php echo $_cartDataURL ?>";
|
71 |
+
var MERCHANT = "<?php echo $_merchant ?>";
|
72 |
+
var SKYBOX_URL = "<?php echo $skybox_url ?>";
|
73 |
+
var CHANGE_COUNTRY = "<?php echo $change_country ?>";
|
74 |
+
var ACTUAL_URI = "<?php echo 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'] ?>";
|
75 |
+
var GET_HOME_URL = "<?php echo $getHomeUrl ?>";
|
76 |
+
jQuery(document).ready(function() {
|
77 |
+
jQuery(".skybox-price-set").each(function( index ) {
|
78 |
+
<?php
|
79 |
+
$skyBoxUrlClientBase= $_helper->getSkyBoxUrlAPI();
|
80 |
+
$codeShop = Mage::getModel('skyboxcatalog/api_product')->getStoreCode();
|
81 |
+
$skyBoxUrlClientGet = str_replace("apirest/", "", $skyBoxUrlClientBase);
|
82 |
+
$skyBoxUrlClient = $skyBoxUrlClientGet . "multiplecalculate/" . $codeShop . "/calc-";
|
83 |
+
?>
|
84 |
+
var SkyBoxUrlClient = "<?php echo $skyBoxUrlClient;?>";
|
85 |
+
var dataId = jQuery(this).attr("id");
|
86 |
+
var id = jQuery(this).attr("product-id");
|
87 |
+
var url = SkyBoxUrlClient + id + ".html";
|
88 |
+
var content = jQuery.get(url, function (data) {
|
89 |
+
jQuery("#" + dataId).html(data);
|
90 |
+
});
|
91 |
+
});
|
92 |
+
});
|
93 |
+
|
94 |
+
(function ($) {
|
95 |
+
|
96 |
+
var widthPage = 0;
|
97 |
+
var heightPage = 0;
|
98 |
+
var popup = {};
|
99 |
+
var popupWidth = 540;
|
100 |
+
var popupHeight = 545;
|
101 |
+
var win = '';
|
102 |
+
|
103 |
+
function showPopup(name, t, url, w, h) {
|
104 |
+
//winCompare = new Window('popup', {className: 'alphacube', title: t, url: url, width: w, height: h, minimizable: false, maximizable: false, showEffectOptions: {duration: 0.4}, hideEffectOptions: {duration: 0.4} });
|
105 |
+
winCompare = new Window(name, {
|
106 |
+
className: 'alphacube',
|
107 |
+
title: t,
|
108 |
+
url: url,
|
109 |
+
width: w,
|
110 |
+
height: h,
|
111 |
+
minimizable: false,
|
112 |
+
maximizable: false,
|
113 |
+
showEffectOptions: {duration: 0.4},
|
114 |
+
hideEffectOptions: {duration: 0.4},
|
115 |
+
destroyOnClose: true,
|
116 |
+
draggable: false,
|
117 |
+
resizable: false
|
118 |
+
});
|
119 |
+
|
120 |
+
winCompare.setDestroyOnClose();
|
121 |
+
winCompare.setZIndex(9999);
|
122 |
+
winCompare.showCenter(true);
|
123 |
+
return winCompare;
|
124 |
+
}
|
125 |
+
|
126 |
+
function goToCart() {
|
127 |
+
document.location = URL_CHECK_CART;
|
128 |
+
}
|
129 |
+
|
130 |
+
function goToInitializeSession() {
|
131 |
+
var idCart = CART_ID;
|
132 |
+
var datos = CART_DATA_URL;
|
133 |
+
var merchant = MERCHANT;
|
134 |
+
var actualUri = ACTUAL_URI + "?LoadFrame=1";
|
135 |
+
var url = SKYBOX_URL + "WebForms/PublicSite/Tracking.aspx?" + datos + "&merchant=" + merchant + "&idCart=" + idCart + "&ReLoad=1&uri=" + actualUri;
|
136 |
+
var name = 'initSession' + Date.now();
|
137 |
+
callAlphacube();
|
138 |
+
showPopup(name, '', url, (widthPage - 50 ), ((heightPage < 800) ? heightPage - 50 : 800));
|
139 |
+
}
|
140 |
+
|
141 |
+
function callAlphacube(){
|
142 |
+
var alphacube_ = document.querySelectorAll('.alphacube_close');
|
143 |
+
if(alphacube_.length > 0){
|
144 |
+
var overlay_ = document.getElementById("overlay_modal");
|
145 |
+
|
146 |
+
if(overlay_ !== null) overlay_.style.display = '';
|
147 |
+
var id_modal = (alphacube_[1]) ? alphacube_[1].parentNode.getAttribute('id') : '';
|
148 |
+
try{
|
149 |
+
document.getElementById(id_modal).remove();
|
150 |
+
}
|
151 |
+
catch(e) {
|
152 |
+
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
function goToLocation() {
|
158 |
+
win = 'resync';
|
159 |
+
var datos = CART_DATA_URL;
|
160 |
+
var process_url = GET_HOME_URL + "skbcheckout/process";
|
161 |
+
var return_url = getReturnUrl();
|
162 |
+
// var return_url = document.URL;
|
163 |
+
var change_country_status = CHANGE_COUNTRY;
|
164 |
+
var url = SKYBOX_URL + "Webforms/PublicSite/ReSync.aspx?" + datos;
|
165 |
+
url += "&process_url=" + process_url;
|
166 |
+
url += "&return_url=" + return_url;
|
167 |
+
url += "&change_country=" + change_country_status;
|
168 |
+
|
169 |
+
var _size = getSizeForPopup();
|
170 |
+
var name = 'selectLocation' + Date.now();
|
171 |
+
callAlphacube();
|
172 |
+
popup = showPopup(name, '', url, _size.width, _size.height);
|
173 |
+
}
|
174 |
+
|
175 |
+
function goToTrackingLocation() {
|
176 |
+
var url = SKYBOX_URL + "Webforms/PublicSite/Tracking.aspx?" + CART_DATA_URL + "&idCart=" + CART_ID;
|
177 |
+
var name = 'tracking' + Date.now();
|
178 |
+
showPopup(name, '', url, (widthPage - 50 ), ((heightPage < 800) ? heightPage - 50 : 800));
|
179 |
+
}
|
180 |
+
|
181 |
+
function loadIframe() {
|
182 |
+
var actualUri = ACTUAL_URI;
|
183 |
+
var flgLoadIframe = "<?php echo (isset($_GET['LoadFrame'])) ? $_GET['LoadFrame'] : 0; ?>";
|
184 |
+
if (flgLoadIframe === "1") {
|
185 |
+
if (actualUri.indexOf("skbcheckout/international") === -1) goToInitializeSession();
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
function postMessageIframe() {
|
190 |
+
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
|
191 |
+
var eventer = window[eventMethod];
|
192 |
+
var messageEvent = eventMethod === "attachEvent" ? "onmessage" : "message";
|
193 |
+
eventer(messageEvent,function(e) {
|
194 |
+
// if(e.origin == 'https://www.skyboxcheckout.com'){
|
195 |
+
recalculateHeightIframe(e.data);
|
196 |
+
// }
|
197 |
+
},false);
|
198 |
+
}
|
199 |
+
|
200 |
+
function recalculateHeightIframe(data) {
|
201 |
+
if (data.win === 'resync') {
|
202 |
+
popupHeight = data.height;
|
203 |
+
var _size = getSizeForPopup();
|
204 |
+
try{
|
205 |
+
popup.setSize(_size.width, _size.height);
|
206 |
+
}
|
207 |
+
catch (e) {
|
208 |
+
// console.log("not calculate popup:::: ", e);
|
209 |
+
}
|
210 |
+
// popup.showCenter(true);
|
211 |
+
}
|
212 |
+
}
|
213 |
+
|
214 |
+
function browserResize() {
|
215 |
+
jQuery(window).resize(function() {
|
216 |
+
if(!jQuery.isEmptyObject(popup)){
|
217 |
+
var _size = getSizeForPopup();
|
218 |
+
popup.setSize(_size.width, _size.height)
|
219 |
+
}
|
220 |
+
});
|
221 |
+
}
|
222 |
+
|
223 |
+
function getSizeForPopup() {
|
224 |
+
var _width = jQuery(window).width();
|
225 |
+
var _height = jQuery(window).height();
|
226 |
+
_width = (_width < popupWidth) ? _width - 30 : popupWidth ;
|
227 |
+
return {width: _width, height: popupHeight};
|
228 |
+
}
|
229 |
+
|
230 |
+
$(".skx_position_option_country").unbind().click(function () {
|
231 |
+
goToLocation();
|
232 |
+
});
|
233 |
+
|
234 |
+
$(".skx_banner_image_account").unbind().click(function () {
|
235 |
+
goToInitializeSession();
|
236 |
+
});
|
237 |
+
|
238 |
+
$(".skx_banner_image_car").unbind().click(function () {
|
239 |
+
goToCart();
|
240 |
+
});
|
241 |
+
|
242 |
+
$(".skx_banner_image_tracking").unbind().click(function () {
|
243 |
+
goToTrackingLocation();
|
244 |
+
});
|
245 |
+
|
246 |
+
$("#link_choise_country").unbind().click(function () {
|
247 |
+
goToCart();
|
248 |
+
});
|
249 |
+
|
250 |
+
$(document).ready(function () {
|
251 |
+
widthPage = $(window).width();
|
252 |
+
heightPage = $(window).height();
|
253 |
+
postMessageIframe();
|
254 |
+
loadIframe();
|
255 |
+
browserResize();
|
256 |
+
});
|
257 |
+
})(jQuery);
|
258 |
+
</script>
|
259 |
+
|
260 |
+
<script type="text/javascript">
|
261 |
+
//<![CDATA[
|
262 |
+
var SKYBOX_OPTIONS_PRICE_URL = '<?php echo Mage::getUrl(); ?>skbcheckout/calculate';
|
263 |
+
//]]>
|
264 |
+
</script>
|
265 |
+
|
266 |
+
<script type="text/javascript" src="<?php echo $api_js_button_international; ?>"></script>
|
267 |
+
|
268 |
+
<?php
|
269 |
+
|
270 |
+
/**
|
271 |
+
* Integration 3 start, show bar*
|
272 |
+
*/
|
273 |
+
if (!$_checkout->getErrorAuthenticate() && $_checkout->getLocationAllow()) : // Rogged
|
274 |
+
// Calculate height
|
275 |
+
$size = 0;
|
276 |
+
|
277 |
+
$UserTemporal = "1";
|
278 |
+
$CartItemCount = 0;
|
279 |
+
|
280 |
+
if (!$_checkout->getErrorAuthenticate() && $_checkout->getLocationAllow()) :
|
281 |
+
$cart = $_config->getSession()->getCartSkybox();
|
282 |
+
if (!empty($cart)) :
|
283 |
+
$UserTemporal = $cart->{'UserTemporal'};
|
284 |
+
$CartItemCount = intval($cart->{'CartItemCount'});
|
285 |
+
for ($i = 1; $i <= $CartItemCount; $i++) :
|
286 |
+
$size = $size + 50;
|
287 |
+
endfor;
|
288 |
+
endif;
|
289 |
+
endif;
|
290 |
+
|
291 |
+
|
292 |
+
$merchant = $_helper->getMerchantCode();
|
293 |
+
$storeId = $_helper->getStoreId();
|
294 |
+
$cartId = $_helper->getCartId();
|
295 |
+
$guid = $_model->getGuidApi();
|
296 |
+
$urlSuccess = Mage::getUrl("skbcheckout/international/success");
|
297 |
+
$urlConfirm = Mage::getUrl("skbcheckout/international");
|
298 |
+
$token = $_model->AuthenticateService()->getAuthorizedToken();
|
299 |
+
|
300 |
+
$url = $_helper->getSkyboxUrlMain() . "WebForms/Checkout/APICheckout.aspx"; //$_config->skyboxDefaultUrl . "WebForms/Checkout/APICheckout.aspx";
|
301 |
+
$url .= "?token=" . $token;
|
302 |
+
$url .= "&GuiId=" . $guid;
|
303 |
+
$url .= "&merchant=" . $merchant;
|
304 |
+
$url .= "&idCart=" . $cartId;
|
305 |
+
$url .= "&idStore=" . $storeId;
|
306 |
+
$url .= "&UrlC=" . $urlConfirm;// "http://magento.skynet.com/magento192/skbcheckout/international";
|
307 |
+
$url .= "&paypal=" . $_GET["paypal"];
|
308 |
+
$url .= '&checkout=' . strip_tags(Mage::app()->getRequest()->getParam('checkout',''));
|
309 |
+
$url .= "&UrlR=" . $urlSuccess;
|
310 |
+
|
311 |
+
if($size == 0):
|
312 |
+
$cart = Mage::getSingleton('checkout/session')->getQuote();
|
313 |
+
foreach ($cart->getAllItems() as $item) :
|
314 |
+
$size = $size + 50;
|
315 |
+
endforeach;
|
316 |
+
endif;
|
317 |
+
|
318 |
+
if($size == 0) $size = 100;
|
319 |
+
|
320 |
+
$height = (($UserTemporal == "1") ? 1400 : 900) + $size;
|
321 |
+
$height = 2500;
|
322 |
+
?>
|
323 |
+
<div class="div_iframe_skybox_checkout">
|
324 |
+
<iframe id="iframe_skybox_checkout" src="<?php echo $url; ?>" frameborder="0" scrolling="no"></iframe>
|
325 |
+
</div>
|
326 |
+
<script type="text/javascript">
|
327 |
+
jQuery(document).ready(function() {
|
328 |
+
var height = <?php echo $height; ?>;
|
329 |
+
var isMobile = /Mobi/.test(navigator.userAgent);
|
330 |
+
console.log("isMobile ::: " + isMobile);
|
331 |
+
if (isMobile) {
|
332 |
+
height = jQuery(window).height();
|
333 |
+
height = height * 5;
|
334 |
+
}
|
335 |
+
console.log("height ::: " + height);
|
336 |
+
jQuery('#iframe_skybox_checkout').attr('height', height);
|
337 |
+
});
|
338 |
+
</script>
|
339 |
+
<?php
|
340 |
+
// ----- Rogged -----
|
341 |
+
else:
|
342 |
+
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl("checkout/onepage"));
|
343 |
+
endif;
|
344 |
+
// ----- ----- -----
|
345 |
+
?>
|
346 |
+
<script>
|
347 |
+
setTimeout(function(){
|
348 |
+
var location_pathname = window.location.pathname.split('/');
|
349 |
+
var skx_bar = document.getElementsByClassName('skx-bar-text');
|
350 |
+
try{
|
351 |
+
if(location_pathname[2] === "international") skx_bar[0].style.display = "none";
|
352 |
+
}
|
353 |
+
catch(e) {
|
354 |
+
|
355 |
+
}
|
356 |
+
}, 300);
|
357 |
+
|
358 |
</script>
|
app/design/frontend/base/default/template/skybox/checkout/skyboxsuccess.phtml
CHANGED
@@ -1,29 +1,29 @@
|
|
1 |
-
<div>
|
2 |
-
<?php
|
3 |
-
$message = Mage::getSingleton('core/session')->getSkyboxSuccessMsg();
|
4 |
-
if (isset($message)) {
|
5 |
-
echo $message;
|
6 |
-
}
|
7 |
-
echo "<br/><br/>";
|
8 |
-
/*echo $_POST["STATUS"] . "<br/>";
|
9 |
-
echo $_POST["STATUS_DESCRIPTION"] . "<br/>";
|
10 |
-
echo $_POST["ORDER_NUMBER"] . "<br/>";
|
11 |
-
echo $_POST["CUSTOMER_EMAIL"] . "<br/>";
|
12 |
-
echo $_POST["CUSTOMER_NAME"] . "<br/>";
|
13 |
-
echo $_POST["CUSTOMER_ID"] . "<br/>";
|
14 |
-
echo $_POST["CUSTOMER_ADDRESS"] . "<br/>";
|
15 |
-
echo $_POST["CUSTOMER_COUNTRY"] . "<br/>";
|
16 |
-
echo $_POST["CUSTOMER_REGION"] . "<br/>";
|
17 |
-
echo $_POST["CUSTOMER_CITY"] . "<br/>";
|
18 |
-
echo $_POST["CUSTOMER_ZIPCODE"] . "<br/>";
|
19 |
-
echo $_POST["ORDER_CURRENCY"] . "<br/>";
|
20 |
-
echo $_POST["ORDER_AMOUNT"] . "<br/>";
|
21 |
-
echo $_POST["ORDER_PAYMENT_METHOD"] . "<br/>";
|
22 |
-
echo $_POST["ORDER_CONCEPTS"] . "<br/><br/>";*/
|
23 |
-
|
24 |
-
echo $_POST["INVOICE_HTML"] . "<br/>";
|
25 |
-
/*if (isset($_POST['ORDER_CONCEPTS'])
|
26 |
-
foreach ($_POST['ORDER_CONCEPTS'] as $value)
|
27 |
-
echo $value . "<br/>";*/
|
28 |
-
?>
|
29 |
</div>
|
1 |
+
<div>
|
2 |
+
<?php
|
3 |
+
$message = Mage::getSingleton('core/session')->getSkyboxSuccessMsg();
|
4 |
+
if (isset($message)) {
|
5 |
+
echo $message;
|
6 |
+
}
|
7 |
+
echo "<br/><br/>";
|
8 |
+
/*echo $_POST["STATUS"] . "<br/>";
|
9 |
+
echo $_POST["STATUS_DESCRIPTION"] . "<br/>";
|
10 |
+
echo $_POST["ORDER_NUMBER"] . "<br/>";
|
11 |
+
echo $_POST["CUSTOMER_EMAIL"] . "<br/>";
|
12 |
+
echo $_POST["CUSTOMER_NAME"] . "<br/>";
|
13 |
+
echo $_POST["CUSTOMER_ID"] . "<br/>";
|
14 |
+
echo $_POST["CUSTOMER_ADDRESS"] . "<br/>";
|
15 |
+
echo $_POST["CUSTOMER_COUNTRY"] . "<br/>";
|
16 |
+
echo $_POST["CUSTOMER_REGION"] . "<br/>";
|
17 |
+
echo $_POST["CUSTOMER_CITY"] . "<br/>";
|
18 |
+
echo $_POST["CUSTOMER_ZIPCODE"] . "<br/>";
|
19 |
+
echo $_POST["ORDER_CURRENCY"] . "<br/>";
|
20 |
+
echo $_POST["ORDER_AMOUNT"] . "<br/>";
|
21 |
+
echo $_POST["ORDER_PAYMENT_METHOD"] . "<br/>";
|
22 |
+
echo $_POST["ORDER_CONCEPTS"] . "<br/><br/>";*/
|
23 |
+
|
24 |
+
echo $_POST["INVOICE_HTML"] . "<br/>";
|
25 |
+
/*if (isset($_POST['ORDER_CONCEPTS'])
|
26 |
+
foreach ($_POST['ORDER_CONCEPTS'] as $value)
|
27 |
+
echo $value . "<br/>";*/
|
28 |
+
?>
|
29 |
</div>
|
app/etc/modules/Skybox_All.xml
CHANGED
@@ -1,37 +1,37 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<modules>
|
4 |
-
<Skybox_Core>
|
5 |
-
<active>true</active>
|
6 |
-
<codePool>community</codePool>
|
7 |
-
</Skybox_Core>
|
8 |
-
<Skybox_International>
|
9 |
-
<active>true</active>
|
10 |
-
<codePool>community</codePool>
|
11 |
-
</Skybox_International>
|
12 |
-
<Skybox_Services>
|
13 |
-
<active>true</active>
|
14 |
-
<codePool>community</codePool>
|
15 |
-
</Skybox_Services>
|
16 |
-
<Skybox_Checkout>
|
17 |
-
<active>true</active>
|
18 |
-
<codePool>community</codePool>
|
19 |
-
<depends>
|
20 |
-
<Mage_Core/>
|
21 |
-
<Mage_Checkout/>
|
22 |
-
<Mage_Sales />
|
23 |
-
<Mage_Shipping />
|
24 |
-
<!--Skybox_Core /-->
|
25 |
-
</depends>
|
26 |
-
</Skybox_Checkout>
|
27 |
-
<Skybox_Catalog>
|
28 |
-
<active>true</active>
|
29 |
-
<codePool>community</codePool>
|
30 |
-
<depends>
|
31 |
-
<Mage_Core/>
|
32 |
-
<Mage_Catalog/>
|
33 |
-
<!--Skybox_Core /-->
|
34 |
-
</depends>
|
35 |
-
</Skybox_Catalog>
|
36 |
-
</modules>
|
37 |
-
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Skybox_Core>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Skybox_Core>
|
8 |
+
<Skybox_International>
|
9 |
+
<active>true</active>
|
10 |
+
<codePool>community</codePool>
|
11 |
+
</Skybox_International>
|
12 |
+
<Skybox_Services>
|
13 |
+
<active>true</active>
|
14 |
+
<codePool>community</codePool>
|
15 |
+
</Skybox_Services>
|
16 |
+
<Skybox_Checkout>
|
17 |
+
<active>true</active>
|
18 |
+
<codePool>community</codePool>
|
19 |
+
<depends>
|
20 |
+
<Mage_Core/>
|
21 |
+
<Mage_Checkout/>
|
22 |
+
<Mage_Sales />
|
23 |
+
<Mage_Shipping />
|
24 |
+
<!--Skybox_Core /-->
|
25 |
+
</depends>
|
26 |
+
</Skybox_Checkout>
|
27 |
+
<Skybox_Catalog>
|
28 |
+
<active>true</active>
|
29 |
+
<codePool>community</codePool>
|
30 |
+
<depends>
|
31 |
+
<Mage_Core/>
|
32 |
+
<Mage_Catalog/>
|
33 |
+
<!--Skybox_Core /-->
|
34 |
+
</depends>
|
35 |
+
</Skybox_Catalog>
|
36 |
+
</modules>
|
37 |
+
</config>
|
js/skybox/adminhtml.category.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
// Adminhtml Category
|
2 |
-
|
3 |
-
function categorySubmit2(url, useAjax) {
|
4 |
-
document.getElementById('apply_button').value = 'all_products';
|
5 |
-
categorySubmit(url, useAjax);
|
6 |
-
}
|
7 |
-
|
8 |
-
function categorySubmit3(url, useAjax) {
|
9 |
-
document.getElementById('apply_button').value = 'all_products_without_commoditites';
|
10 |
-
categorySubmit(url, useAjax);
|
11 |
}
|
1 |
+
// Adminhtml Category
|
2 |
+
|
3 |
+
function categorySubmit2(url, useAjax) {
|
4 |
+
document.getElementById('apply_button').value = 'all_products';
|
5 |
+
categorySubmit(url, useAjax);
|
6 |
+
}
|
7 |
+
|
8 |
+
function categorySubmit3(url, useAjax) {
|
9 |
+
document.getElementById('apply_button').value = 'all_products_without_commoditites';
|
10 |
+
categorySubmit(url, useAjax);
|
11 |
}
|
js/skybox/jquery.ba-resize.min.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
/*
|
2 |
-
* jQuery resize event - v1.1 - 3/14/2010
|
3 |
-
* http://benalman.com/projects/jquery-resize-plugin/
|
4 |
-
*
|
5 |
-
* Copyright (c) 2010 "Cowboy" Ben Alman
|
6 |
-
* Dual licensed under the MIT and GPL licenses.
|
7 |
-
* http://benalman.com/about/license/
|
8 |
-
*/
|
9 |
(function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this);
|
1 |
+
/*
|
2 |
+
* jQuery resize event - v1.1 - 3/14/2010
|
3 |
+
* http://benalman.com/projects/jquery-resize-plugin/
|
4 |
+
*
|
5 |
+
* Copyright (c) 2010 "Cowboy" Ben Alman
|
6 |
+
* Dual licensed under the MIT and GPL licenses.
|
7 |
+
* http://benalman.com/about/license/
|
8 |
+
*/
|
9 |
(function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this);
|
js/skybox/jquery.fancybox.js
CHANGED
@@ -1,2020 +1,2020 @@
|
|
1 |
-
/*!
|
2 |
-
* fancyBox - jQuery Plugin
|
3 |
-
* version: 2.1.5 (Fri, 14 Jun 2013)
|
4 |
-
* @requires jQuery v1.6 or later
|
5 |
-
*
|
6 |
-
* Examples at http://fancyapps.com/fancybox/
|
7 |
-
* License: www.fancyapps.com/fancybox/#license
|
8 |
-
*
|
9 |
-
* Copyright 2012 Janis Skarnelis - janis@fancyapps.com
|
10 |
-
*
|
11 |
-
*/
|
12 |
-
|
13 |
-
(function (window, document, $, undefined) {
|
14 |
-
"use strict";
|
15 |
-
|
16 |
-
var H = $("html"),
|
17 |
-
W = $(window),
|
18 |
-
D = $(document),
|
19 |
-
F = $.fancybox = function () {
|
20 |
-
F.open.apply( this, arguments );
|
21 |
-
},
|
22 |
-
IE = navigator.userAgent.match(/msie/i),
|
23 |
-
didUpdate = null,
|
24 |
-
isTouch = document.createTouch !== undefined,
|
25 |
-
|
26 |
-
isQuery = function(obj) {
|
27 |
-
return obj && obj.hasOwnProperty && obj instanceof $;
|
28 |
-
},
|
29 |
-
isString = function(str) {
|
30 |
-
return str && $.type(str) === "string";
|
31 |
-
},
|
32 |
-
isPercentage = function(str) {
|
33 |
-
return isString(str) && str.indexOf('%') > 0;
|
34 |
-
},
|
35 |
-
isScrollable = function(el) {
|
36 |
-
return (el && !(el.style.overflow && el.style.overflow === 'hidden') && ((el.clientWidth && el.scrollWidth > el.clientWidth) || (el.clientHeight && el.scrollHeight > el.clientHeight)));
|
37 |
-
},
|
38 |
-
getScalar = function(orig, dim) {
|
39 |
-
var value = parseInt(orig, 10) || 0;
|
40 |
-
|
41 |
-
if (dim && isPercentage(orig)) {
|
42 |
-
value = F.getViewport()[ dim ] / 100 * value;
|
43 |
-
}
|
44 |
-
|
45 |
-
return Math.ceil(value);
|
46 |
-
},
|
47 |
-
getValue = function(value, dim) {
|
48 |
-
return getScalar(value, dim) + 'px';
|
49 |
-
};
|
50 |
-
|
51 |
-
$.extend(F, {
|
52 |
-
// The current version of fancyBox
|
53 |
-
version: '2.1.5',
|
54 |
-
|
55 |
-
defaults: {
|
56 |
-
padding : 15,
|
57 |
-
margin : 20,
|
58 |
-
|
59 |
-
width : 800,
|
60 |
-
height : 600,
|
61 |
-
minWidth : 100,
|
62 |
-
minHeight : 100,
|
63 |
-
maxWidth : 9999,
|
64 |
-
maxHeight : 9999,
|
65 |
-
pixelRatio: 1, // Set to 2 for retina display support
|
66 |
-
|
67 |
-
autoSize : true,
|
68 |
-
autoHeight : false,
|
69 |
-
autoWidth : false,
|
70 |
-
|
71 |
-
autoResize : true,
|
72 |
-
autoCenter : !isTouch,
|
73 |
-
fitToView : true,
|
74 |
-
aspectRatio : false,
|
75 |
-
topRatio : 0.5,
|
76 |
-
leftRatio : 0.5,
|
77 |
-
|
78 |
-
scrolling : 'auto', // 'auto', 'yes' or 'no'
|
79 |
-
wrapCSS : '',
|
80 |
-
|
81 |
-
arrows : true,
|
82 |
-
closeBtn : true,
|
83 |
-
closeClick : false,
|
84 |
-
nextClick : false,
|
85 |
-
mouseWheel : true,
|
86 |
-
autoPlay : false,
|
87 |
-
playSpeed : 3000,
|
88 |
-
preload : 3,
|
89 |
-
modal : false,
|
90 |
-
loop : true,
|
91 |
-
|
92 |
-
ajax : {
|
93 |
-
dataType : 'html',
|
94 |
-
headers : { 'X-fancyBox': true }
|
95 |
-
},
|
96 |
-
iframe : {
|
97 |
-
scrolling : 'auto',
|
98 |
-
preload : true
|
99 |
-
},
|
100 |
-
swf : {
|
101 |
-
wmode: 'transparent',
|
102 |
-
allowfullscreen : 'true',
|
103 |
-
allowscriptaccess : 'always'
|
104 |
-
},
|
105 |
-
|
106 |
-
keys : {
|
107 |
-
next : {
|
108 |
-
13 : 'left', // enter
|
109 |
-
34 : 'up', // page down
|
110 |
-
39 : 'left', // right arrow
|
111 |
-
40 : 'up' // down arrow
|
112 |
-
},
|
113 |
-
prev : {
|
114 |
-
8 : 'right', // backspace
|
115 |
-
33 : 'down', // page up
|
116 |
-
37 : 'right', // left arrow
|
117 |
-
38 : 'down' // up arrow
|
118 |
-
},
|
119 |
-
close : [27], // escape key
|
120 |
-
play : [32], // space - start/stop slideshow
|
121 |
-
toggle : [70] // letter "f" - toggle fullscreen
|
122 |
-
},
|
123 |
-
|
124 |
-
direction : {
|
125 |
-
next : 'left',
|
126 |
-
prev : 'right'
|
127 |
-
},
|
128 |
-
|
129 |
-
scrollOutside : true,
|
130 |
-
|
131 |
-
// Override some properties
|
132 |
-
index : 0,
|
133 |
-
type : null,
|
134 |
-
href : null,
|
135 |
-
content : null,
|
136 |
-
title : null,
|
137 |
-
|
138 |
-
// HTML templates
|
139 |
-
tpl: {
|
140 |
-
wrap : '<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>',
|
141 |
-
image : '<img class="fancybox-image" src="{href}" alt="" />',
|
142 |
-
iframe : '<iframe id="fancybox-frame{rnd}" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen' + (IE ? ' allowtransparency="true"' : '') + '></iframe>',
|
143 |
-
error : '<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',
|
144 |
-
closeBtn : '<a title="Close" class="fancybox-item fancybox-close" href="javascript:;"></a>',
|
145 |
-
next : '<a title="Next" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',
|
146 |
-
prev : '<a title="Previous" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'
|
147 |
-
},
|
148 |
-
|
149 |
-
// Properties for each animation type
|
150 |
-
// Opening fancyBox
|
151 |
-
openEffect : 'fade', // 'elastic', 'fade' or 'none'
|
152 |
-
openSpeed : 250,
|
153 |
-
openEasing : 'swing',
|
154 |
-
openOpacity : true,
|
155 |
-
openMethod : 'zoomIn',
|
156 |
-
|
157 |
-
// Closing fancyBox
|
158 |
-
closeEffect : 'fade', // 'elastic', 'fade' or 'none'
|
159 |
-
closeSpeed : 250,
|
160 |
-
closeEasing : 'swing',
|
161 |
-
closeOpacity : true,
|
162 |
-
closeMethod : 'zoomOut',
|
163 |
-
|
164 |
-
// Changing next gallery item
|
165 |
-
nextEffect : 'elastic', // 'elastic', 'fade' or 'none'
|
166 |
-
nextSpeed : 250,
|
167 |
-
nextEasing : 'swing',
|
168 |
-
nextMethod : 'changeIn',
|
169 |
-
|
170 |
-
// Changing previous gallery item
|
171 |
-
prevEffect : 'elastic', // 'elastic', 'fade' or 'none'
|
172 |
-
prevSpeed : 250,
|
173 |
-
prevEasing : 'swing',
|
174 |
-
prevMethod : 'changeOut',
|
175 |
-
|
176 |
-
// Enable default helpers
|
177 |
-
helpers : {
|
178 |
-
overlay : true,
|
179 |
-
title : true
|
180 |
-
},
|
181 |
-
|
182 |
-
// Callbacks
|
183 |
-
onCancel : $.noop, // If canceling
|
184 |
-
beforeLoad : $.noop, // Before loading
|
185 |
-
afterLoad : $.noop, // After loading
|
186 |
-
beforeShow : $.noop, // Before changing in current item
|
187 |
-
afterShow : $.noop, // After opening
|
188 |
-
beforeChange : $.noop, // Before changing gallery item
|
189 |
-
beforeClose : $.noop, // Before closing
|
190 |
-
afterClose : $.noop // After closing
|
191 |
-
},
|
192 |
-
|
193 |
-
//Current state
|
194 |
-
group : {}, // Selected group
|
195 |
-
opts : {}, // Group options
|
196 |
-
previous : null, // Previous element
|
197 |
-
coming : null, // Element being loaded
|
198 |
-
current : null, // Currently loaded element
|
199 |
-
isActive : false, // Is activated
|
200 |
-
isOpen : false, // Is currently open
|
201 |
-
isOpened : false, // Have been fully opened at least once
|
202 |
-
|
203 |
-
wrap : null,
|
204 |
-
skin : null,
|
205 |
-
outer : null,
|
206 |
-
inner : null,
|
207 |
-
|
208 |
-
player : {
|
209 |
-
timer : null,
|
210 |
-
isActive : false
|
211 |
-
},
|
212 |
-
|
213 |
-
// Loaders
|
214 |
-
ajaxLoad : null,
|
215 |
-
imgPreload : null,
|
216 |
-
|
217 |
-
// Some collections
|
218 |
-
transitions : {},
|
219 |
-
helpers : {},
|
220 |
-
|
221 |
-
/*
|
222 |
-
* Static methods
|
223 |
-
*/
|
224 |
-
|
225 |
-
open: function (group, opts) {
|
226 |
-
if (!group) {
|
227 |
-
return;
|
228 |
-
}
|
229 |
-
|
230 |
-
if (!$.isPlainObject(opts)) {
|
231 |
-
opts = {};
|
232 |
-
}
|
233 |
-
|
234 |
-
// Close if already active
|
235 |
-
if (false === F.close(true)) {
|
236 |
-
return;
|
237 |
-
}
|
238 |
-
|
239 |
-
// Normalize group
|
240 |
-
if (!$.isArray(group)) {
|
241 |
-
group = isQuery(group) ? $(group).get() : [group];
|
242 |
-
}
|
243 |
-
|
244 |
-
// Recheck if the type of each element is `object` and set content type (image, ajax, etc)
|
245 |
-
$.each(group, function(i, element) {
|
246 |
-
var obj = {},
|
247 |
-
href,
|
248 |
-
title,
|
249 |
-
content,
|
250 |
-
type,
|
251 |
-
rez,
|
252 |
-
hrefParts,
|
253 |
-
selector;
|
254 |
-
|
255 |
-
if ($.type(element) === "object") {
|
256 |
-
// Check if is DOM element
|
257 |
-
if (element.nodeType) {
|
258 |
-
element = $(element);
|
259 |
-
}
|
260 |
-
|
261 |
-
if (isQuery(element)) {
|
262 |
-
obj = {
|
263 |
-
href : element.data('fancybox-href') || element.attr('href'),
|
264 |
-
title : element.data('fancybox-title') || element.attr('title'),
|
265 |
-
isDom : true,
|
266 |
-
element : element
|
267 |
-
};
|
268 |
-
|
269 |
-
if ($.metadata) {
|
270 |
-
$.extend(true, obj, element.metadata());
|
271 |
-
}
|
272 |
-
|
273 |
-
} else {
|
274 |
-
obj = element;
|
275 |
-
}
|
276 |
-
}
|
277 |
-
|
278 |
-
href = opts.href || obj.href || (isString(element) ? element : null);
|
279 |
-
title = opts.title !== undefined ? opts.title : obj.title || '';
|
280 |
-
|
281 |
-
content = opts.content || obj.content;
|
282 |
-
type = content ? 'html' : (opts.type || obj.type);
|
283 |
-
|
284 |
-
if (!type && obj.isDom) {
|
285 |
-
type = element.data('fancybox-type');
|
286 |
-
|
287 |
-
if (!type) {
|
288 |
-
rez = element.prop('class').match(/fancybox\.(\w+)/);
|
289 |
-
type = rez ? rez[1] : null;
|
290 |
-
}
|
291 |
-
}
|
292 |
-
|
293 |
-
if (isString(href)) {
|
294 |
-
// Try to guess the content type
|
295 |
-
if (!type) {
|
296 |
-
if (F.isImage(href)) {
|
297 |
-
type = 'image';
|
298 |
-
|
299 |
-
} else if (F.isSWF(href)) {
|
300 |
-
type = 'swf';
|
301 |
-
|
302 |
-
} else if (href.charAt(0) === '#') {
|
303 |
-
type = 'inline';
|
304 |
-
|
305 |
-
} else if (isString(element)) {
|
306 |
-
type = 'html';
|
307 |
-
content = element;
|
308 |
-
}
|
309 |
-
}
|
310 |
-
|
311 |
-
// Split url into two pieces with source url and content selector, e.g,
|
312 |
-
// "/mypage.html #my_id" will load "/mypage.html" and display element having id "my_id"
|
313 |
-
if (type === 'ajax') {
|
314 |
-
hrefParts = href.split(/\s+/, 2);
|
315 |
-
href = hrefParts.shift();
|
316 |
-
selector = hrefParts.shift();
|
317 |
-
}
|
318 |
-
}
|
319 |
-
|
320 |
-
if (!content) {
|
321 |
-
if (type === 'inline') {
|
322 |
-
if (href) {
|
323 |
-
content = $( isString(href) ? href.replace(/.*(?=#[^\s]+$)/, '') : href ); //strip for ie7
|
324 |
-
|
325 |
-
} else if (obj.isDom) {
|
326 |
-
content = element;
|
327 |
-
}
|
328 |
-
|
329 |
-
} else if (type === 'html') {
|
330 |
-
content = href;
|
331 |
-
|
332 |
-
} else if (!type && !href && obj.isDom) {
|
333 |
-
type = 'inline';
|
334 |
-
content = element;
|
335 |
-
}
|
336 |
-
}
|
337 |
-
|
338 |
-
$.extend(obj, {
|
339 |
-
href : href,
|
340 |
-
type : type,
|
341 |
-
content : content,
|
342 |
-
title : title,
|
343 |
-
selector : selector
|
344 |
-
});
|
345 |
-
|
346 |
-
group[ i ] = obj;
|
347 |
-
});
|
348 |
-
|
349 |
-
// Extend the defaults
|
350 |
-
F.opts = $.extend(true, {}, F.defaults, opts);
|
351 |
-
|
352 |
-
// All options are merged recursive except keys
|
353 |
-
if (opts.keys !== undefined) {
|
354 |
-
F.opts.keys = opts.keys ? $.extend({}, F.defaults.keys, opts.keys) : false;
|
355 |
-
}
|
356 |
-
|
357 |
-
F.group = group;
|
358 |
-
|
359 |
-
return F._start(F.opts.index);
|
360 |
-
},
|
361 |
-
|
362 |
-
// Cancel image loading or abort ajax request
|
363 |
-
cancel: function () {
|
364 |
-
var coming = F.coming;
|
365 |
-
|
366 |
-
if (!coming || false === F.trigger('onCancel')) {
|
367 |
-
return;
|
368 |
-
}
|
369 |
-
|
370 |
-
F.hideLoading();
|
371 |
-
|
372 |
-
if (F.ajaxLoad) {
|
373 |
-
F.ajaxLoad.abort();
|
374 |
-
}
|
375 |
-
|
376 |
-
F.ajaxLoad = null;
|
377 |
-
|
378 |
-
if (F.imgPreload) {
|
379 |
-
F.imgPreload.onload = F.imgPreload.onerror = null;
|
380 |
-
}
|
381 |
-
|
382 |
-
if (coming.wrap) {
|
383 |
-
coming.wrap.stop(true, true).trigger('onReset').remove();
|
384 |
-
}
|
385 |
-
|
386 |
-
F.coming = null;
|
387 |
-
|
388 |
-
// If the first item has been canceled, then clear everything
|
389 |
-
if (!F.current) {
|
390 |
-
F._afterZoomOut( coming );
|
391 |
-
}
|
392 |
-
},
|
393 |
-
|
394 |
-
// Start closing animation if is open; remove immediately if opening/closing
|
395 |
-
close: function (event) {
|
396 |
-
F.cancel();
|
397 |
-
|
398 |
-
if (false === F.trigger('beforeClose')) {
|
399 |
-
return;
|
400 |
-
}
|
401 |
-
|
402 |
-
F.unbindEvents();
|
403 |
-
|
404 |
-
if (!F.isActive) {
|
405 |
-
return;
|
406 |
-
}
|
407 |
-
|
408 |
-
if (!F.isOpen || event === true) {
|
409 |
-
$('.fancybox-wrap').stop(true).trigger('onReset').remove();
|
410 |
-
|
411 |
-
F._afterZoomOut();
|
412 |
-
|
413 |
-
} else {
|
414 |
-
F.isOpen = F.isOpened = false;
|
415 |
-
F.isClosing = true;
|
416 |
-
|
417 |
-
$('.fancybox-item, .fancybox-nav').remove();
|
418 |
-
|
419 |
-
F.wrap.stop(true, true).removeClass('fancybox-opened');
|
420 |
-
|
421 |
-
F.transitions[ F.current.closeMethod ]();
|
422 |
-
}
|
423 |
-
},
|
424 |
-
|
425 |
-
// Manage slideshow:
|
426 |
-
// $.fancybox.play(); - toggle slideshow
|
427 |
-
// $.fancybox.play( true ); - start
|
428 |
-
// $.fancybox.play( false ); - stop
|
429 |
-
play: function ( action ) {
|
430 |
-
var clear = function () {
|
431 |
-
clearTimeout(F.player.timer);
|
432 |
-
},
|
433 |
-
set = function () {
|
434 |
-
clear();
|
435 |
-
|
436 |
-
if (F.current && F.player.isActive) {
|
437 |
-
F.player.timer = setTimeout(F.next, F.current.playSpeed);
|
438 |
-
}
|
439 |
-
},
|
440 |
-
stop = function () {
|
441 |
-
clear();
|
442 |
-
|
443 |
-
D.unbind('.player');
|
444 |
-
|
445 |
-
F.player.isActive = false;
|
446 |
-
|
447 |
-
F.trigger('onPlayEnd');
|
448 |
-
},
|
449 |
-
start = function () {
|
450 |
-
if (F.current && (F.current.loop || F.current.index < F.group.length - 1)) {
|
451 |
-
F.player.isActive = true;
|
452 |
-
|
453 |
-
D.bind({
|
454 |
-
'onCancel.player beforeClose.player' : stop,
|
455 |
-
'onUpdate.player' : set,
|
456 |
-
'beforeLoad.player' : clear
|
457 |
-
});
|
458 |
-
|
459 |
-
set();
|
460 |
-
|
461 |
-
F.trigger('onPlayStart');
|
462 |
-
}
|
463 |
-
};
|
464 |
-
|
465 |
-
if (action === true || (!F.player.isActive && action !== false)) {
|
466 |
-
start();
|
467 |
-
} else {
|
468 |
-
stop();
|
469 |
-
}
|
470 |
-
},
|
471 |
-
|
472 |
-
// Navigate to next gallery item
|
473 |
-
next: function ( direction ) {
|
474 |
-
var current = F.current;
|
475 |
-
|
476 |
-
if (current) {
|
477 |
-
if (!isString(direction)) {
|
478 |
-
direction = current.direction.next;
|
479 |
-
}
|
480 |
-
|
481 |
-
F.jumpto(current.index + 1, direction, 'next');
|
482 |
-
}
|
483 |
-
},
|
484 |
-
|
485 |
-
// Navigate to previous gallery item
|
486 |
-
prev: function ( direction ) {
|
487 |
-
var current = F.current;
|
488 |
-
|
489 |
-
if (current) {
|
490 |
-
if (!isString(direction)) {
|
491 |
-
direction = current.direction.prev;
|
492 |
-
}
|
493 |
-
|
494 |
-
F.jumpto(current.index - 1, direction, 'prev');
|
495 |
-
}
|
496 |
-
},
|
497 |
-
|
498 |
-
// Navigate to gallery item by index
|
499 |
-
jumpto: function ( index, direction, router ) {
|
500 |
-
var current = F.current;
|
501 |
-
|
502 |
-
if (!current) {
|
503 |
-
return;
|
504 |
-
}
|
505 |
-
|
506 |
-
index = getScalar(index);
|
507 |
-
|
508 |
-
F.direction = direction || current.direction[ (index >= current.index ? 'next' : 'prev') ];
|
509 |
-
F.router = router || 'jumpto';
|
510 |
-
|
511 |
-
if (current.loop) {
|
512 |
-
if (index < 0) {
|
513 |
-
index = current.group.length + (index % current.group.length);
|
514 |
-
}
|
515 |
-
|
516 |
-
index = index % current.group.length;
|
517 |
-
}
|
518 |
-
|
519 |
-
if (current.group[ index ] !== undefined) {
|
520 |
-
F.cancel();
|
521 |
-
|
522 |
-
F._start(index);
|
523 |
-
}
|
524 |
-
},
|
525 |
-
|
526 |
-
// Center inside viewport and toggle position type to fixed or absolute if needed
|
527 |
-
reposition: function (e, onlyAbsolute) {
|
528 |
-
var current = F.current,
|
529 |
-
wrap = current ? current.wrap : null,
|
530 |
-
pos;
|
531 |
-
|
532 |
-
if (wrap) {
|
533 |
-
pos = F._getPosition(onlyAbsolute);
|
534 |
-
|
535 |
-
if (e && e.type === 'scroll') {
|
536 |
-
delete pos.position;
|
537 |
-
|
538 |
-
wrap.stop(true, true).animate(pos, 200);
|
539 |
-
|
540 |
-
} else {
|
541 |
-
wrap.css(pos);
|
542 |
-
|
543 |
-
current.pos = $.extend({}, current.dim, pos);
|
544 |
-
}
|
545 |
-
}
|
546 |
-
},
|
547 |
-
|
548 |
-
update: function (e) {
|
549 |
-
var type = (e && e.type),
|
550 |
-
anyway = !type || type === 'orientationchange';
|
551 |
-
|
552 |
-
if (anyway) {
|
553 |
-
clearTimeout(didUpdate);
|
554 |
-
|
555 |
-
didUpdate = null;
|
556 |
-
}
|
557 |
-
|
558 |
-
if (!F.isOpen || didUpdate) {
|
559 |
-
return;
|
560 |
-
}
|
561 |
-
|
562 |
-
didUpdate = setTimeout(function() {
|
563 |
-
var current = F.current;
|
564 |
-
|
565 |
-
if (!current || F.isClosing) {
|
566 |
-
return;
|
567 |
-
}
|
568 |
-
|
569 |
-
F.wrap.removeClass('fancybox-tmp');
|
570 |
-
|
571 |
-
if (anyway || type === 'load' || (type === 'resize' && current.autoResize)) {
|
572 |
-
F._setDimension();
|
573 |
-
}
|
574 |
-
|
575 |
-
if (!(type === 'scroll' && current.canShrink)) {
|
576 |
-
F.reposition(e);
|
577 |
-
}
|
578 |
-
|
579 |
-
F.trigger('onUpdate');
|
580 |
-
|
581 |
-
didUpdate = null;
|
582 |
-
|
583 |
-
}, (anyway && !isTouch ? 0 : 300));
|
584 |
-
},
|
585 |
-
|
586 |
-
// Shrink content to fit inside viewport or restore if resized
|
587 |
-
toggle: function ( action ) {
|
588 |
-
if (F.isOpen) {
|
589 |
-
F.current.fitToView = $.type(action) === "boolean" ? action : !F.current.fitToView;
|
590 |
-
|
591 |
-
// Help browser to restore document dimensions
|
592 |
-
if (isTouch) {
|
593 |
-
F.wrap.removeAttr('style').addClass('fancybox-tmp');
|
594 |
-
|
595 |
-
F.trigger('onUpdate');
|
596 |
-
}
|
597 |
-
|
598 |
-
F.update();
|
599 |
-
}
|
600 |
-
},
|
601 |
-
|
602 |
-
hideLoading: function () {
|
603 |
-
D.unbind('.loading');
|
604 |
-
|
605 |
-
$('#fancybox-loading').remove();
|
606 |
-
},
|
607 |
-
|
608 |
-
showLoading: function () {
|
609 |
-
var el, viewport;
|
610 |
-
|
611 |
-
F.hideLoading();
|
612 |
-
|
613 |
-
el = $('<div id="fancybox-loading"><div></div></div>').click(F.cancel).appendTo('body');
|
614 |
-
|
615 |
-
// If user will press the escape-button, the request will be canceled
|
616 |
-
D.bind('keydown.loading', function(e) {
|
617 |
-
if ((e.which || e.keyCode) === 27) {
|
618 |
-
e.preventDefault();
|
619 |
-
|
620 |
-
F.cancel();
|
621 |
-
}
|
622 |
-
});
|
623 |
-
|
624 |
-
if (!F.defaults.fixed) {
|
625 |
-
viewport = F.getViewport();
|
626 |
-
|
627 |
-
el.css({
|
628 |
-
position : 'absolute',
|
629 |
-
top : (viewport.h * 0.5) + viewport.y,
|
630 |
-
left : (viewport.w * 0.5) + viewport.x
|
631 |
-
});
|
632 |
-
}
|
633 |
-
},
|
634 |
-
|
635 |
-
getViewport: function () {
|
636 |
-
var locked = (F.current && F.current.locked) || false,
|
637 |
-
rez = {
|
638 |
-
x: W.scrollLeft(),
|
639 |
-
y: W.scrollTop()
|
640 |
-
};
|
641 |
-
|
642 |
-
if (locked) {
|
643 |
-
rez.w = locked[0].clientWidth;
|
644 |
-
rez.h = locked[0].clientHeight;
|
645 |
-
|
646 |
-
} else {
|
647 |
-
// See http://bugs.jquery.com/ticket/6724
|
648 |
-
rez.w = isTouch && window.innerWidth ? window.innerWidth : W.width();
|
649 |
-
rez.h = isTouch && window.innerHeight ? window.innerHeight : W.height();
|
650 |
-
}
|
651 |
-
|
652 |
-
return rez;
|
653 |
-
},
|
654 |
-
|
655 |
-
// Unbind the keyboard / clicking actions
|
656 |
-
unbindEvents: function () {
|
657 |
-
if (F.wrap && isQuery(F.wrap)) {
|
658 |
-
F.wrap.unbind('.fb');
|
659 |
-
}
|
660 |
-
|
661 |
-
D.unbind('.fb');
|
662 |
-
W.unbind('.fb');
|
663 |
-
},
|
664 |
-
|
665 |
-
bindEvents: function () {
|
666 |
-
var current = F.current,
|
667 |
-
keys;
|
668 |
-
|
669 |
-
if (!current) {
|
670 |
-
return;
|
671 |
-
}
|
672 |
-
|
673 |
-
// Changing document height on iOS devices triggers a 'resize' event,
|
674 |
-
// that can change document height... repeating infinitely
|
675 |
-
W.bind('orientationchange.fb' + (isTouch ? '' : ' resize.fb') + (current.autoCenter && !current.locked ? ' scroll.fb' : ''), F.update);
|
676 |
-
|
677 |
-
keys = current.keys;
|
678 |
-
|
679 |
-
if (keys) {
|
680 |
-
D.bind('keydown.fb', function (e) {
|
681 |
-
var code = e.which || e.keyCode,
|
682 |
-
target = e.target || e.srcElement;
|
683 |
-
|
684 |
-
// Skip esc key if loading, because showLoading will cancel preloading
|
685 |
-
if (code === 27 && F.coming) {
|
686 |
-
return false;
|
687 |
-
}
|
688 |
-
|
689 |
-
// Ignore key combinations and key events within form elements
|
690 |
-
if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey && !(target && (target.type || $(target).is('[contenteditable]')))) {
|
691 |
-
$.each(keys, function(i, val) {
|
692 |
-
if (current.group.length > 1 && val[ code ] !== undefined) {
|
693 |
-
F[ i ]( val[ code ] );
|
694 |
-
|
695 |
-
e.preventDefault();
|
696 |
-
return false;
|
697 |
-
}
|
698 |
-
|
699 |
-
if ($.inArray(code, val) > -1) {
|
700 |
-
F[ i ] ();
|
701 |
-
|
702 |
-
e.preventDefault();
|
703 |
-
return false;
|
704 |
-
}
|
705 |
-
});
|
706 |
-
}
|
707 |
-
});
|
708 |
-
}
|
709 |
-
|
710 |
-
if ($.fn.mousewheel && current.mouseWheel) {
|
711 |
-
F.wrap.bind('mousewheel.fb', function (e, delta, deltaX, deltaY) {
|
712 |
-
var target = e.target || null,
|
713 |
-
parent = $(target),
|
714 |
-
canScroll = false;
|
715 |
-
|
716 |
-
while (parent.length) {
|
717 |
-
if (canScroll || parent.is('.fancybox-skin') || parent.is('.fancybox-wrap')) {
|
718 |
-
break;
|
719 |
-
}
|
720 |
-
|
721 |
-
canScroll = isScrollable( parent[0] );
|
722 |
-
parent = $(parent).parent();
|
723 |
-
}
|
724 |
-
|
725 |
-
if (delta !== 0 && !canScroll) {
|
726 |
-
if (F.group.length > 1 && !current.canShrink) {
|
727 |
-
if (deltaY > 0 || deltaX > 0) {
|
728 |
-
F.prev( deltaY > 0 ? 'down' : 'left' );
|
729 |
-
|
730 |
-
} else if (deltaY < 0 || deltaX < 0) {
|
731 |
-
F.next( deltaY < 0 ? 'up' : 'right' );
|
732 |
-
}
|
733 |
-
|
734 |
-
e.preventDefault();
|
735 |
-
}
|
736 |
-
}
|
737 |
-
});
|
738 |
-
}
|
739 |
-
},
|
740 |
-
|
741 |
-
trigger: function (event, o) {
|
742 |
-
var ret, obj = o || F.coming || F.current;
|
743 |
-
|
744 |
-
if (!obj) {
|
745 |
-
return;
|
746 |
-
}
|
747 |
-
|
748 |
-
if ($.isFunction( obj[event] )) {
|
749 |
-
ret = obj[event].apply(obj, Array.prototype.slice.call(arguments, 1));
|
750 |
-
}
|
751 |
-
|
752 |
-
if (ret === false) {
|
753 |
-
return false;
|
754 |
-
}
|
755 |
-
|
756 |
-
if (obj.helpers) {
|
757 |
-
$.each(obj.helpers, function (helper, opts) {
|
758 |
-
if (opts && F.helpers[helper] && $.isFunction(F.helpers[helper][event])) {
|
759 |
-
F.helpers[helper][event]($.extend(true, {}, F.helpers[helper].defaults, opts), obj);
|
760 |
-
}
|
761 |
-
});
|
762 |
-
}
|
763 |
-
|
764 |
-
D.trigger(event);
|
765 |
-
},
|
766 |
-
|
767 |
-
isImage: function (str) {
|
768 |
-
return isString(str) && str.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i);
|
769 |
-
},
|
770 |
-
|
771 |
-
isSWF: function (str) {
|
772 |
-
return isString(str) && str.match(/\.(swf)((\?|#).*)?$/i);
|
773 |
-
},
|
774 |
-
|
775 |
-
_start: function (index) {
|
776 |
-
var coming = {},
|
777 |
-
obj,
|
778 |
-
href,
|
779 |
-
type,
|
780 |
-
margin,
|
781 |
-
padding;
|
782 |
-
|
783 |
-
index = getScalar( index );
|
784 |
-
obj = F.group[ index ] || null;
|
785 |
-
|
786 |
-
if (!obj) {
|
787 |
-
return false;
|
788 |
-
}
|
789 |
-
|
790 |
-
coming = $.extend(true, {}, F.opts, obj);
|
791 |
-
|
792 |
-
// Convert margin and padding properties to array - top, right, bottom, left
|
793 |
-
margin = coming.margin;
|
794 |
-
padding = coming.padding;
|
795 |
-
|
796 |
-
if ($.type(margin) === 'number') {
|
797 |
-
coming.margin = [margin, margin, margin, margin];
|
798 |
-
}
|
799 |
-
|
800 |
-
if ($.type(padding) === 'number') {
|
801 |
-
coming.padding = [padding, padding, padding, padding];
|
802 |
-
}
|
803 |
-
|
804 |
-
// 'modal' propery is just a shortcut
|
805 |
-
if (coming.modal) {
|
806 |
-
$.extend(true, coming, {
|
807 |
-
closeBtn : false,
|
808 |
-
closeClick : false,
|
809 |
-
nextClick : false,
|
810 |
-
arrows : false,
|
811 |
-
mouseWheel : false,
|
812 |
-
keys : null,
|
813 |
-
helpers: {
|
814 |
-
overlay : {
|
815 |
-
closeClick : false
|
816 |
-
}
|
817 |
-
}
|
818 |
-
});
|
819 |
-
}
|
820 |
-
|
821 |
-
// 'autoSize' property is a shortcut, too
|
822 |
-
if (coming.autoSize) {
|
823 |
-
coming.autoWidth = coming.autoHeight = true;
|
824 |
-
}
|
825 |
-
|
826 |
-
if (coming.width === 'auto') {
|
827 |
-
coming.autoWidth = true;
|
828 |
-
}
|
829 |
-
|
830 |
-
if (coming.height === 'auto') {
|
831 |
-
coming.autoHeight = true;
|
832 |
-
}
|
833 |
-
|
834 |
-
/*
|
835 |
-
* Add reference to the group, so it`s possible to access from callbacks, example:
|
836 |
-
* afterLoad : function() {
|
837 |
-
* this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');
|
838 |
-
* }
|
839 |
-
*/
|
840 |
-
|
841 |
-
coming.group = F.group;
|
842 |
-
coming.index = index;
|
843 |
-
|
844 |
-
// Give a chance for callback or helpers to update coming item (type, title, etc)
|
845 |
-
F.coming = coming;
|
846 |
-
|
847 |
-
if (false === F.trigger('beforeLoad')) {
|
848 |
-
F.coming = null;
|
849 |
-
|
850 |
-
return;
|
851 |
-
}
|
852 |
-
|
853 |
-
type = coming.type;
|
854 |
-
href = coming.href;
|
855 |
-
|
856 |
-
if (!type) {
|
857 |
-
F.coming = null;
|
858 |
-
|
859 |
-
//If we can not determine content type then drop silently or display next/prev item if looping through gallery
|
860 |
-
if (F.current && F.router && F.router !== 'jumpto') {
|
861 |
-
F.current.index = index;
|
862 |
-
|
863 |
-
return F[ F.router ]( F.direction );
|
864 |
-
}
|
865 |
-
|
866 |
-
return false;
|
867 |
-
}
|
868 |
-
|
869 |
-
F.isActive = true;
|
870 |
-
|
871 |
-
if (type === 'image' || type === 'swf') {
|
872 |
-
coming.autoHeight = coming.autoWidth = false;
|
873 |
-
coming.scrolling = 'visible';
|
874 |
-
}
|
875 |
-
|
876 |
-
if (type === 'image') {
|
877 |
-
coming.aspectRatio = true;
|
878 |
-
}
|
879 |
-
|
880 |
-
if (type === 'iframe' && isTouch) {
|
881 |
-
coming.scrolling = 'scroll';
|
882 |
-
}
|
883 |
-
|
884 |
-
// Build the neccessary markup
|
885 |
-
coming.wrap = $(coming.tpl.wrap).addClass('fancybox-' + (isTouch ? 'mobile' : 'desktop') + ' fancybox-type-' + type + ' fancybox-tmp ' + coming.wrapCSS).appendTo( coming.parent || 'body' );
|
886 |
-
|
887 |
-
$.extend(coming, {
|
888 |
-
skin : $('.fancybox-skin', coming.wrap),
|
889 |
-
outer : $('.fancybox-outer', coming.wrap),
|
890 |
-
inner : $('.fancybox-inner', coming.wrap)
|
891 |
-
});
|
892 |
-
|
893 |
-
$.each(["Top", "Right", "Bottom", "Left"], function(i, v) {
|
894 |
-
coming.skin.css('padding' + v, getValue(coming.padding[ i ]));
|
895 |
-
});
|
896 |
-
|
897 |
-
F.trigger('onReady');
|
898 |
-
|
899 |
-
// Check before try to load; 'inline' and 'html' types need content, others - href
|
900 |
-
if (type === 'inline' || type === 'html') {
|
901 |
-
if (!coming.content || !coming.content.length) {
|
902 |
-
return F._error( 'content' );
|
903 |
-
}
|
904 |
-
|
905 |
-
} else if (!href) {
|
906 |
-
return F._error( 'href' );
|
907 |
-
}
|
908 |
-
|
909 |
-
if (type === 'image') {
|
910 |
-
F._loadImage();
|
911 |
-
|
912 |
-
} else if (type === 'ajax') {
|
913 |
-
F._loadAjax();
|
914 |
-
|
915 |
-
} else if (type === 'iframe') {
|
916 |
-
F._loadIframe();
|
917 |
-
|
918 |
-
} else {
|
919 |
-
F._afterLoad();
|
920 |
-
}
|
921 |
-
},
|
922 |
-
|
923 |
-
_error: function ( type ) {
|
924 |
-
$.extend(F.coming, {
|
925 |
-
type : 'html',
|
926 |
-
autoWidth : true,
|
927 |
-
autoHeight : true,
|
928 |
-
minWidth : 0,
|
929 |
-
minHeight : 0,
|
930 |
-
scrolling : 'no',
|
931 |
-
hasError : type,
|
932 |
-
content : F.coming.tpl.error
|
933 |
-
});
|
934 |
-
|
935 |
-
F._afterLoad();
|
936 |
-
},
|
937 |
-
|
938 |
-
_loadImage: function () {
|
939 |
-
// Reset preload image so it is later possible to check "complete" property
|
940 |
-
var img = F.imgPreload = new Image();
|
941 |
-
|
942 |
-
img.onload = function () {
|
943 |
-
this.onload = this.onerror = null;
|
944 |
-
|
945 |
-
F.coming.width = this.width / F.opts.pixelRatio;
|
946 |
-
F.coming.height = this.height / F.opts.pixelRatio;
|
947 |
-
|
948 |
-
F._afterLoad();
|
949 |
-
};
|
950 |
-
|
951 |
-
img.onerror = function () {
|
952 |
-
this.onload = this.onerror = null;
|
953 |
-
|
954 |
-
F._error( 'image' );
|
955 |
-
};
|
956 |
-
|
957 |
-
img.src = F.coming.href;
|
958 |
-
|
959 |
-
if (img.complete !== true) {
|
960 |
-
F.showLoading();
|
961 |
-
}
|
962 |
-
},
|
963 |
-
|
964 |
-
_loadAjax: function () {
|
965 |
-
var coming = F.coming;
|
966 |
-
|
967 |
-
F.showLoading();
|
968 |
-
|
969 |
-
F.ajaxLoad = $.ajax($.extend({}, coming.ajax, {
|
970 |
-
url: coming.href,
|
971 |
-
error: function (jqXHR, textStatus) {
|
972 |
-
if (F.coming && textStatus !== 'abort') {
|
973 |
-
F._error( 'ajax', jqXHR );
|
974 |
-
|
975 |
-
} else {
|
976 |
-
F.hideLoading();
|
977 |
-
}
|
978 |
-
},
|
979 |
-
success: function (data, textStatus) {
|
980 |
-
if (textStatus === 'success') {
|
981 |
-
coming.content = data;
|
982 |
-
|
983 |
-
F._afterLoad();
|
984 |
-
}
|
985 |
-
}
|
986 |
-
}));
|
987 |
-
},
|
988 |
-
|
989 |
-
_loadIframe: function() {
|
990 |
-
var coming = F.coming,
|
991 |
-
iframe = $(coming.tpl.iframe.replace(/\{rnd\}/g, new Date().getTime()))
|
992 |
-
.attr('scrolling', isTouch ? 'auto' : coming.iframe.scrolling)
|
993 |
-
.attr('src', coming.href);
|
994 |
-
|
995 |
-
// This helps IE
|
996 |
-
$(coming.wrap).bind('onReset', function () {
|
997 |
-
try {
|
998 |
-
$(this).find('iframe').hide().attr('src', '//about:blank').end().empty();
|
999 |
-
} catch (e) {}
|
1000 |
-
});
|
1001 |
-
|
1002 |
-
if (coming.iframe.preload) {
|
1003 |
-
F.showLoading();
|
1004 |
-
|
1005 |
-
iframe.one('load', function() {
|
1006 |
-
$(this).data('ready', 1);
|
1007 |
-
|
1008 |
-
// iOS will lose scrolling if we resize
|
1009 |
-
if (!isTouch) {
|
1010 |
-
$(this).bind('load.fb', F.update);
|
1011 |
-
}
|
1012 |
-
|
1013 |
-
// Without this trick:
|
1014 |
-
// - iframe won't scroll on iOS devices
|
1015 |
-
// - IE7 sometimes displays empty iframe
|
1016 |
-
$(this).parents('.fancybox-wrap').width('100%').removeClass('fancybox-tmp').show();
|
1017 |
-
|
1018 |
-
F._afterLoad();
|
1019 |
-
});
|
1020 |
-
}
|
1021 |
-
|
1022 |
-
coming.content = iframe.appendTo( coming.inner );
|
1023 |
-
|
1024 |
-
if (!coming.iframe.preload) {
|
1025 |
-
F._afterLoad();
|
1026 |
-
}
|
1027 |
-
},
|
1028 |
-
|
1029 |
-
_preloadImages: function() {
|
1030 |
-
var group = F.group,
|
1031 |
-
current = F.current,
|
1032 |
-
len = group.length,
|
1033 |
-
cnt = current.preload ? Math.min(current.preload, len - 1) : 0,
|
1034 |
-
item,
|
1035 |
-
i;
|
1036 |
-
|
1037 |
-
for (i = 1; i <= cnt; i += 1) {
|
1038 |
-
item = group[ (current.index + i ) % len ];
|
1039 |
-
|
1040 |
-
if (item.type === 'image' && item.href) {
|
1041 |
-
new Image().src = item.href;
|
1042 |
-
}
|
1043 |
-
}
|
1044 |
-
},
|
1045 |
-
|
1046 |
-
_afterLoad: function () {
|
1047 |
-
var coming = F.coming,
|
1048 |
-
previous = F.current,
|
1049 |
-
placeholder = 'fancybox-placeholder',
|
1050 |
-
current,
|
1051 |
-
content,
|
1052 |
-
type,
|
1053 |
-
scrolling,
|
1054 |
-
href,
|
1055 |
-
embed;
|
1056 |
-
|
1057 |
-
F.hideLoading();
|
1058 |
-
|
1059 |
-
if (!coming || F.isActive === false) {
|
1060 |
-
return;
|
1061 |
-
}
|
1062 |
-
|
1063 |
-
if (false === F.trigger('afterLoad', coming, previous)) {
|
1064 |
-
coming.wrap.stop(true).trigger('onReset').remove();
|
1065 |
-
|
1066 |
-
F.coming = null;
|
1067 |
-
|
1068 |
-
return;
|
1069 |
-
}
|
1070 |
-
|
1071 |
-
if (previous) {
|
1072 |
-
F.trigger('beforeChange', previous);
|
1073 |
-
|
1074 |
-
previous.wrap.stop(true).removeClass('fancybox-opened')
|
1075 |
-
.find('.fancybox-item, .fancybox-nav')
|
1076 |
-
.remove();
|
1077 |
-
}
|
1078 |
-
|
1079 |
-
F.unbindEvents();
|
1080 |
-
|
1081 |
-
current = coming;
|
1082 |
-
content = coming.content;
|
1083 |
-
type = coming.type;
|
1084 |
-
scrolling = coming.scrolling;
|
1085 |
-
|
1086 |
-
$.extend(F, {
|
1087 |
-
wrap : current.wrap,
|
1088 |
-
skin : current.skin,
|
1089 |
-
outer : current.outer,
|
1090 |
-
inner : current.inner,
|
1091 |
-
current : current,
|
1092 |
-
previous : previous
|
1093 |
-
});
|
1094 |
-
|
1095 |
-
href = current.href;
|
1096 |
-
|
1097 |
-
switch (type) {
|
1098 |
-
case 'inline':
|
1099 |
-
case 'ajax':
|
1100 |
-
case 'html':
|
1101 |
-
if (current.selector) {
|
1102 |
-
content = $('<div>').html(content).find(current.selector);
|
1103 |
-
|
1104 |
-
} else if (isQuery(content)) {
|
1105 |
-
if (!content.data(placeholder)) {
|
1106 |
-
content.data(placeholder, $('<div class="' + placeholder + '"></div>').insertAfter( content ).hide() );
|
1107 |
-
}
|
1108 |
-
|
1109 |
-
content = content.show().detach();
|
1110 |
-
|
1111 |
-
current.wrap.bind('onReset', function () {
|
1112 |
-
if ($(this).find(content).length) {
|
1113 |
-
content.hide().replaceAll( content.data(placeholder) ).data(placeholder, false);
|
1114 |
-
}
|
1115 |
-
});
|
1116 |
-
}
|
1117 |
-
break;
|
1118 |
-
|
1119 |
-
case 'image':
|
1120 |
-
content = current.tpl.image.replace('{href}', href);
|
1121 |
-
break;
|
1122 |
-
|
1123 |
-
case 'swf':
|
1124 |
-
content = '<object id="fancybox-swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="movie" value="' + href + '"></param>';
|
1125 |
-
embed = '';
|
1126 |
-
|
1127 |
-
$.each(current.swf, function(name, val) {
|
1128 |
-
content += '<param name="' + name + '" value="' + val + '"></param>';
|
1129 |
-
embed += ' ' + name + '="' + val + '"';
|
1130 |
-
});
|
1131 |
-
|
1132 |
-
content += '<embed src="' + href + '" type="application/x-shockwave-flash" width="100%" height="100%"' + embed + '></embed></object>';
|
1133 |
-
break;
|
1134 |
-
}
|
1135 |
-
|
1136 |
-
if (!(isQuery(content) && content.parent().is(current.inner))) {
|
1137 |
-
current.inner.append( content );
|
1138 |
-
}
|
1139 |
-
|
1140 |
-
// Give a chance for helpers or callbacks to update elements
|
1141 |
-
F.trigger('beforeShow');
|
1142 |
-
|
1143 |
-
// Set scrolling before calculating dimensions
|
1144 |
-
current.inner.css('overflow', scrolling === 'yes' ? 'scroll' : (scrolling === 'no' ? 'hidden' : scrolling));
|
1145 |
-
|
1146 |
-
// Set initial dimensions and start position
|
1147 |
-
F._setDimension();
|
1148 |
-
|
1149 |
-
F.reposition();
|
1150 |
-
|
1151 |
-
F.isOpen = false;
|
1152 |
-
F.coming = null;
|
1153 |
-
|
1154 |
-
F.bindEvents();
|
1155 |
-
|
1156 |
-
if (!F.isOpened) {
|
1157 |
-
$('.fancybox-wrap').not( current.wrap ).stop(true).trigger('onReset').remove();
|
1158 |
-
|
1159 |
-
} else if (previous.prevMethod) {
|
1160 |
-
F.transitions[ previous.prevMethod ]();
|
1161 |
-
}
|
1162 |
-
|
1163 |
-
F.transitions[ F.isOpened ? current.nextMethod : current.openMethod ]();
|
1164 |
-
|
1165 |
-
F._preloadImages();
|
1166 |
-
},
|
1167 |
-
|
1168 |
-
_setDimension: function () {
|
1169 |
-
var viewport = F.getViewport(),
|
1170 |
-
steps = 0,
|
1171 |
-
canShrink = false,
|
1172 |
-
canExpand = false,
|
1173 |
-
wrap = F.wrap,
|
1174 |
-
skin = F.skin,
|
1175 |
-
inner = F.inner,
|
1176 |
-
current = F.current,
|
1177 |
-
width = current.width,
|
1178 |
-
height = current.height,
|
1179 |
-
minWidth = current.minWidth,
|
1180 |
-
minHeight = current.minHeight,
|
1181 |
-
maxWidth = current.maxWidth,
|
1182 |
-
maxHeight = current.maxHeight,
|
1183 |
-
scrolling = current.scrolling,
|
1184 |
-
scrollOut = current.scrollOutside ? current.scrollbarWidth : 0,
|
1185 |
-
margin = current.margin,
|
1186 |
-
wMargin = getScalar(margin[1] + margin[3]),
|
1187 |
-
hMargin = getScalar(margin[0] + margin[2]),
|
1188 |
-
wPadding,
|
1189 |
-
hPadding,
|
1190 |
-
wSpace,
|
1191 |
-
hSpace,
|
1192 |
-
origWidth,
|
1193 |
-
origHeight,
|
1194 |
-
origMaxWidth,
|
1195 |
-
origMaxHeight,
|
1196 |
-
ratio,
|
1197 |
-
width_,
|
1198 |
-
height_,
|
1199 |
-
maxWidth_,
|
1200 |
-
maxHeight_,
|
1201 |
-
iframe,
|
1202 |
-
body;
|
1203 |
-
|
1204 |
-
// Reset dimensions so we could re-check actual size
|
1205 |
-
wrap.add(skin).add(inner).width('auto').height('auto').removeClass('fancybox-tmp');
|
1206 |
-
|
1207 |
-
wPadding = getScalar(skin.outerWidth(true) - skin.width());
|
1208 |
-
hPadding = getScalar(skin.outerHeight(true) - skin.height());
|
1209 |
-
|
1210 |
-
// Any space between content and viewport (margin, padding, border, title)
|
1211 |
-
wSpace = wMargin + wPadding;
|
1212 |
-
hSpace = hMargin + hPadding;
|
1213 |
-
|
1214 |
-
origWidth = isPercentage(width) ? (viewport.w - wSpace) * getScalar(width) / 100 : width;
|
1215 |
-
origHeight = isPercentage(height) ? (viewport.h - hSpace) * getScalar(height) / 100 : height;
|
1216 |
-
|
1217 |
-
if (current.type === 'iframe') {
|
1218 |
-
iframe = current.content;
|
1219 |
-
|
1220 |
-
if (current.autoHeight && iframe.data('ready') === 1) {
|
1221 |
-
try {
|
1222 |
-
if (iframe[0].contentWindow.document.location) {
|
1223 |
-
inner.width( origWidth ).height(9999);
|
1224 |
-
|
1225 |
-
body = iframe.contents().find('body');
|
1226 |
-
|
1227 |
-
if (scrollOut) {
|
1228 |
-
body.css('overflow-x', 'hidden');
|
1229 |
-
}
|
1230 |
-
|
1231 |
-
origHeight = body.outerHeight(true);
|
1232 |
-
}
|
1233 |
-
|
1234 |
-
} catch (e) {}
|
1235 |
-
}
|
1236 |
-
|
1237 |
-
} else if (current.autoWidth || current.autoHeight) {
|
1238 |
-
inner.addClass( 'fancybox-tmp' );
|
1239 |
-
|
1240 |
-
// Set width or height in case we need to calculate only one dimension
|
1241 |
-
if (!current.autoWidth) {
|
1242 |
-
inner.width( origWidth );
|
1243 |
-
}
|
1244 |
-
|
1245 |
-
if (!current.autoHeight) {
|
1246 |
-
inner.height( origHeight );
|
1247 |
-
}
|
1248 |
-
|
1249 |
-
if (current.autoWidth) {
|
1250 |
-
origWidth = inner.width();
|
1251 |
-
}
|
1252 |
-
|
1253 |
-
if (current.autoHeight) {
|
1254 |
-
origHeight = inner.height();
|
1255 |
-
}
|
1256 |
-
|
1257 |
-
inner.removeClass( 'fancybox-tmp' );
|
1258 |
-
}
|
1259 |
-
|
1260 |
-
width = getScalar( origWidth );
|
1261 |
-
height = getScalar( origHeight );
|
1262 |
-
|
1263 |
-
ratio = origWidth / origHeight;
|
1264 |
-
|
1265 |
-
// Calculations for the content
|
1266 |
-
minWidth = getScalar(isPercentage(minWidth) ? getScalar(minWidth, 'w') - wSpace : minWidth);
|
1267 |
-
maxWidth = getScalar(isPercentage(maxWidth) ? getScalar(maxWidth, 'w') - wSpace : maxWidth);
|
1268 |
-
|
1269 |
-
minHeight = getScalar(isPercentage(minHeight) ? getScalar(minHeight, 'h') - hSpace : minHeight);
|
1270 |
-
maxHeight = getScalar(isPercentage(maxHeight) ? getScalar(maxHeight, 'h') - hSpace : maxHeight);
|
1271 |
-
|
1272 |
-
// These will be used to determine if wrap can fit in the viewport
|
1273 |
-
origMaxWidth = maxWidth;
|
1274 |
-
origMaxHeight = maxHeight;
|
1275 |
-
|
1276 |
-
if (current.fitToView) {
|
1277 |
-
maxWidth = Math.min(viewport.w - wSpace, maxWidth);
|
1278 |
-
maxHeight = Math.min(viewport.h - hSpace, maxHeight);
|
1279 |
-
}
|
1280 |
-
|
1281 |
-
maxWidth_ = viewport.w - wMargin;
|
1282 |
-
maxHeight_ = viewport.h - hMargin;
|
1283 |
-
|
1284 |
-
if (current.aspectRatio) {
|
1285 |
-
if (width > maxWidth) {
|
1286 |
-
width = maxWidth;
|
1287 |
-
height = getScalar(width / ratio);
|
1288 |
-
}
|
1289 |
-
|
1290 |
-
if (height > maxHeight) {
|
1291 |
-
height = maxHeight;
|
1292 |
-
width = getScalar(height * ratio);
|
1293 |
-
}
|
1294 |
-
|
1295 |
-
if (width < minWidth) {
|
1296 |
-
width = minWidth;
|
1297 |
-
height = getScalar(width / ratio);
|
1298 |
-
}
|
1299 |
-
|
1300 |
-
if (height < minHeight) {
|
1301 |
-
height = minHeight;
|
1302 |
-
width = getScalar(height * ratio);
|
1303 |
-
}
|
1304 |
-
|
1305 |
-
} else {
|
1306 |
-
width = Math.max(minWidth, Math.min(width, maxWidth));
|
1307 |
-
|
1308 |
-
if (current.autoHeight && current.type !== 'iframe') {
|
1309 |
-
inner.width( width );
|
1310 |
-
|
1311 |
-
height = inner.height();
|
1312 |
-
}
|
1313 |
-
|
1314 |
-
height = Math.max(minHeight, Math.min(height, maxHeight));
|
1315 |
-
}
|
1316 |
-
|
1317 |
-
// Try to fit inside viewport (including the title)
|
1318 |
-
if (current.fitToView) {
|
1319 |
-
inner.width( width ).height( height );
|
1320 |
-
|
1321 |
-
wrap.width( width + wPadding );
|
1322 |
-
|
1323 |
-
// Real wrap dimensions
|
1324 |
-
width_ = wrap.width();
|
1325 |
-
height_ = wrap.height();
|
1326 |
-
|
1327 |
-
if (current.aspectRatio) {
|
1328 |
-
while ((width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight) {
|
1329 |
-
if (steps++ > 19) {
|
1330 |
-
break;
|
1331 |
-
}
|
1332 |
-
|
1333 |
-
height = Math.max(minHeight, Math.min(maxHeight, height - 10));
|
1334 |
-
width = getScalar(height * ratio);
|
1335 |
-
|
1336 |
-
if (width < minWidth) {
|
1337 |
-
width = minWidth;
|
1338 |
-
height = getScalar(width / ratio);
|
1339 |
-
}
|
1340 |
-
|
1341 |
-
if (width > maxWidth) {
|
1342 |
-
width = maxWidth;
|
1343 |
-
height = getScalar(width / ratio);
|
1344 |
-
}
|
1345 |
-
|
1346 |
-
inner.width( width ).height( height );
|
1347 |
-
|
1348 |
-
wrap.width( width + wPadding );
|
1349 |
-
|
1350 |
-
width_ = wrap.width();
|
1351 |
-
height_ = wrap.height();
|
1352 |
-
}
|
1353 |
-
|
1354 |
-
} else {
|
1355 |
-
width = Math.max(minWidth, Math.min(width, width - (width_ - maxWidth_)));
|
1356 |
-
height = Math.max(minHeight, Math.min(height, height - (height_ - maxHeight_)));
|
1357 |
-
}
|
1358 |
-
}
|
1359 |
-
|
1360 |
-
if (scrollOut && scrolling === 'auto' && height < origHeight && (width + wPadding + scrollOut) < maxWidth_) {
|
1361 |
-
width += scrollOut;
|
1362 |
-
}
|
1363 |
-
|
1364 |
-
inner.width( width ).height( height );
|
1365 |
-
|
1366 |
-
wrap.width( width + wPadding );
|
1367 |
-
|
1368 |
-
width_ = wrap.width();
|
1369 |
-
height_ = wrap.height();
|
1370 |
-
|
1371 |
-
canShrink = (width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight;
|
1372 |
-
canExpand = current.aspectRatio ? (width < origMaxWidth && height < origMaxHeight && width < origWidth && height < origHeight) : ((width < origMaxWidth || height < origMaxHeight) && (width < origWidth || height < origHeight));
|
1373 |
-
|
1374 |
-
$.extend(current, {
|
1375 |
-
dim : {
|
1376 |
-
width : getValue( width_ ),
|
1377 |
-
height : getValue( height_ )
|
1378 |
-
},
|
1379 |
-
origWidth : origWidth,
|
1380 |
-
origHeight : origHeight,
|
1381 |
-
canShrink : canShrink,
|
1382 |
-
canExpand : canExpand,
|
1383 |
-
wPadding : wPadding,
|
1384 |
-
hPadding : hPadding,
|
1385 |
-
wrapSpace : height_ - skin.outerHeight(true),
|
1386 |
-
skinSpace : skin.height() - height
|
1387 |
-
});
|
1388 |
-
|
1389 |
-
if (!iframe && current.autoHeight && height > minHeight && height < maxHeight && !canExpand) {
|
1390 |
-
inner.height('auto');
|
1391 |
-
}
|
1392 |
-
},
|
1393 |
-
|
1394 |
-
_getPosition: function (onlyAbsolute) {
|
1395 |
-
var current = F.current,
|
1396 |
-
viewport = F.getViewport(),
|
1397 |
-
margin = current.margin,
|
1398 |
-
width = F.wrap.width() + margin[1] + margin[3],
|
1399 |
-
height = F.wrap.height() + margin[0] + margin[2],
|
1400 |
-
rez = {
|
1401 |
-
position: 'absolute',
|
1402 |
-
top : margin[0],
|
1403 |
-
left : margin[3]
|
1404 |
-
};
|
1405 |
-
|
1406 |
-
if (current.autoCenter && current.fixed && !onlyAbsolute && height <= viewport.h && width <= viewport.w) {
|
1407 |
-
rez.position = 'fixed';
|
1408 |
-
|
1409 |
-
} else if (!current.locked) {
|
1410 |
-
rez.top += viewport.y;
|
1411 |
-
rez.left += viewport.x;
|
1412 |
-
}
|
1413 |
-
|
1414 |
-
rez.top = getValue(Math.max(rez.top, rez.top + ((viewport.h - height) * current.topRatio)));
|
1415 |
-
rez.left = getValue(Math.max(rez.left, rez.left + ((viewport.w - width) * current.leftRatio)));
|
1416 |
-
|
1417 |
-
return rez;
|
1418 |
-
},
|
1419 |
-
|
1420 |
-
_afterZoomIn: function () {
|
1421 |
-
var current = F.current;
|
1422 |
-
|
1423 |
-
if (!current) {
|
1424 |
-
return;
|
1425 |
-
}
|
1426 |
-
|
1427 |
-
F.isOpen = F.isOpened = true;
|
1428 |
-
|
1429 |
-
F.wrap.css('overflow', 'visible').addClass('fancybox-opened');
|
1430 |
-
|
1431 |
-
F.update();
|
1432 |
-
|
1433 |
-
// Assign a click event
|
1434 |
-
if ( current.closeClick || (current.nextClick && F.group.length > 1) ) {
|
1435 |
-
F.inner.css('cursor', 'pointer').bind('click.fb', function(e) {
|
1436 |
-
if (!$(e.target).is('a') && !$(e.target).parent().is('a')) {
|
1437 |
-
e.preventDefault();
|
1438 |
-
|
1439 |
-
F[ current.closeClick ? 'close' : 'next' ]();
|
1440 |
-
}
|
1441 |
-
});
|
1442 |
-
}
|
1443 |
-
|
1444 |
-
// Create a close button
|
1445 |
-
if (current.closeBtn) {
|
1446 |
-
$(current.tpl.closeBtn).appendTo(F.skin).bind('click.fb', function(e) {
|
1447 |
-
e.preventDefault();
|
1448 |
-
|
1449 |
-
F.close();
|
1450 |
-
});
|
1451 |
-
}
|
1452 |
-
|
1453 |
-
// Create navigation arrows
|
1454 |
-
if (current.arrows && F.group.length > 1) {
|
1455 |
-
if (current.loop || current.index > 0) {
|
1456 |
-
$(current.tpl.prev).appendTo(F.outer).bind('click.fb', F.prev);
|
1457 |
-
}
|
1458 |
-
|
1459 |
-
if (current.loop || current.index < F.group.length - 1) {
|
1460 |
-
$(current.tpl.next).appendTo(F.outer).bind('click.fb', F.next);
|
1461 |
-
}
|
1462 |
-
}
|
1463 |
-
|
1464 |
-
F.trigger('afterShow');
|
1465 |
-
|
1466 |
-
// Stop the slideshow if this is the last item
|
1467 |
-
if (!current.loop && current.index === current.group.length - 1) {
|
1468 |
-
F.play( false );
|
1469 |
-
|
1470 |
-
} else if (F.opts.autoPlay && !F.player.isActive) {
|
1471 |
-
F.opts.autoPlay = false;
|
1472 |
-
|
1473 |
-
F.play();
|
1474 |
-
}
|
1475 |
-
},
|
1476 |
-
|
1477 |
-
_afterZoomOut: function ( obj ) {
|
1478 |
-
obj = obj || F.current;
|
1479 |
-
|
1480 |
-
$('.fancybox-wrap').trigger('onReset').remove();
|
1481 |
-
|
1482 |
-
$.extend(F, {
|
1483 |
-
group : {},
|
1484 |
-
opts : {},
|
1485 |
-
router : false,
|
1486 |
-
current : null,
|
1487 |
-
isActive : false,
|
1488 |
-
isOpened : false,
|
1489 |
-
isOpen : false,
|
1490 |
-
isClosing : false,
|
1491 |
-
wrap : null,
|
1492 |
-
skin : null,
|
1493 |
-
outer : null,
|
1494 |
-
inner : null
|
1495 |
-
});
|
1496 |
-
|
1497 |
-
F.trigger('afterClose', obj);
|
1498 |
-
}
|
1499 |
-
});
|
1500 |
-
|
1501 |
-
/*
|
1502 |
-
* Default transitions
|
1503 |
-
*/
|
1504 |
-
|
1505 |
-
F.transitions = {
|
1506 |
-
getOrigPosition: function () {
|
1507 |
-
var current = F.current,
|
1508 |
-
element = current.element,
|
1509 |
-
orig = current.orig,
|
1510 |
-
pos = {},
|
1511 |
-
width = 50,
|
1512 |
-
height = 50,
|
1513 |
-
hPadding = current.hPadding,
|
1514 |
-
wPadding = current.wPadding,
|
1515 |
-
viewport = F.getViewport();
|
1516 |
-
|
1517 |
-
if (!orig && current.isDom && element.is(':visible')) {
|
1518 |
-
orig = element.find('img:first');
|
1519 |
-
|
1520 |
-
if (!orig.length) {
|
1521 |
-
orig = element;
|
1522 |
-
}
|
1523 |
-
}
|
1524 |
-
|
1525 |
-
if (isQuery(orig)) {
|
1526 |
-
pos = orig.offset();
|
1527 |
-
|
1528 |
-
if (orig.is('img')) {
|
1529 |
-
width = orig.outerWidth();
|
1530 |
-
height = orig.outerHeight();
|
1531 |
-
}
|
1532 |
-
|
1533 |
-
} else {
|
1534 |
-
pos.top = viewport.y + (viewport.h - height) * current.topRatio;
|
1535 |
-
pos.left = viewport.x + (viewport.w - width) * current.leftRatio;
|
1536 |
-
}
|
1537 |
-
|
1538 |
-
if (F.wrap.css('position') === 'fixed' || current.locked) {
|
1539 |
-
pos.top -= viewport.y;
|
1540 |
-
pos.left -= viewport.x;
|
1541 |
-
}
|
1542 |
-
|
1543 |
-
pos = {
|
1544 |
-
top : getValue(pos.top - hPadding * current.topRatio),
|
1545 |
-
left : getValue(pos.left - wPadding * current.leftRatio),
|
1546 |
-
width : getValue(width + wPadding),
|
1547 |
-
height : getValue(height + hPadding)
|
1548 |
-
};
|
1549 |
-
|
1550 |
-
return pos;
|
1551 |
-
},
|
1552 |
-
|
1553 |
-
step: function (now, fx) {
|
1554 |
-
var ratio,
|
1555 |
-
padding,
|
1556 |
-
value,
|
1557 |
-
prop = fx.prop,
|
1558 |
-
current = F.current,
|
1559 |
-
wrapSpace = current.wrapSpace,
|
1560 |
-
skinSpace = current.skinSpace;
|
1561 |
-
|
1562 |
-
if (prop === 'width' || prop === 'height') {
|
1563 |
-
ratio = fx.end === fx.start ? 1 : (now - fx.start) / (fx.end - fx.start);
|
1564 |
-
|
1565 |
-
if (F.isClosing) {
|
1566 |
-
ratio = 1 - ratio;
|
1567 |
-
}
|
1568 |
-
|
1569 |
-
padding = prop === 'width' ? current.wPadding : current.hPadding;
|
1570 |
-
value = now - padding;
|
1571 |
-
|
1572 |
-
F.skin[ prop ]( getScalar( prop === 'width' ? value : value - (wrapSpace * ratio) ) );
|
1573 |
-
F.inner[ prop ]( getScalar( prop === 'width' ? value : value - (wrapSpace * ratio) - (skinSpace * ratio) ) );
|
1574 |
-
}
|
1575 |
-
},
|
1576 |
-
|
1577 |
-
zoomIn: function () {
|
1578 |
-
var current = F.current,
|
1579 |
-
startPos = current.pos,
|
1580 |
-
effect = current.openEffect,
|
1581 |
-
elastic = effect === 'elastic',
|
1582 |
-
endPos = $.extend({opacity : 1}, startPos);
|
1583 |
-
|
1584 |
-
// Remove "position" property that breaks older IE
|
1585 |
-
delete endPos.position;
|
1586 |
-
|
1587 |
-
if (elastic) {
|
1588 |
-
startPos = this.getOrigPosition();
|
1589 |
-
|
1590 |
-
if (current.openOpacity) {
|
1591 |
-
startPos.opacity = 0.1;
|
1592 |
-
}
|
1593 |
-
|
1594 |
-
} else if (effect === 'fade') {
|
1595 |
-
startPos.opacity = 0.1;
|
1596 |
-
}
|
1597 |
-
|
1598 |
-
F.wrap.css(startPos).animate(endPos, {
|
1599 |
-
duration : effect === 'none' ? 0 : current.openSpeed,
|
1600 |
-
easing : current.openEasing,
|
1601 |
-
step : elastic ? this.step : null,
|
1602 |
-
complete : F._afterZoomIn
|
1603 |
-
});
|
1604 |
-
},
|
1605 |
-
|
1606 |
-
zoomOut: function () {
|
1607 |
-
var current = F.current,
|
1608 |
-
effect = current.closeEffect,
|
1609 |
-
elastic = effect === 'elastic',
|
1610 |
-
endPos = {opacity : 0.1};
|
1611 |
-
|
1612 |
-
if (elastic) {
|
1613 |
-
endPos = this.getOrigPosition();
|
1614 |
-
|
1615 |
-
if (current.closeOpacity) {
|
1616 |
-
endPos.opacity = 0.1;
|
1617 |
-
}
|
1618 |
-
}
|
1619 |
-
|
1620 |
-
F.wrap.animate(endPos, {
|
1621 |
-
duration : effect === 'none' ? 0 : current.closeSpeed,
|
1622 |
-
easing : current.closeEasing,
|
1623 |
-
step : elastic ? this.step : null,
|
1624 |
-
complete : F._afterZoomOut
|
1625 |
-
});
|
1626 |
-
},
|
1627 |
-
|
1628 |
-
changeIn: function () {
|
1629 |
-
var current = F.current,
|
1630 |
-
effect = current.nextEffect,
|
1631 |
-
startPos = current.pos,
|
1632 |
-
endPos = { opacity : 1 },
|
1633 |
-
direction = F.direction,
|
1634 |
-
distance = 200,
|
1635 |
-
field;
|
1636 |
-
|
1637 |
-
startPos.opacity = 0.1;
|
1638 |
-
|
1639 |
-
if (effect === 'elastic') {
|
1640 |
-
field = direction === 'down' || direction === 'up' ? 'top' : 'left';
|
1641 |
-
|
1642 |
-
if (direction === 'down' || direction === 'right') {
|
1643 |
-
startPos[ field ] = getValue(getScalar(startPos[ field ]) - distance);
|
1644 |
-
endPos[ field ] = '+=' + distance + 'px';
|
1645 |
-
|
1646 |
-
} else {
|
1647 |
-
startPos[ field ] = getValue(getScalar(startPos[ field ]) + distance);
|
1648 |
-
endPos[ field ] = '-=' + distance + 'px';
|
1649 |
-
}
|
1650 |
-
}
|
1651 |
-
|
1652 |
-
// Workaround for http://bugs.jquery.com/ticket/12273
|
1653 |
-
if (effect === 'none') {
|
1654 |
-
F._afterZoomIn();
|
1655 |
-
|
1656 |
-
} else {
|
1657 |
-
F.wrap.css(startPos).animate(endPos, {
|
1658 |
-
duration : current.nextSpeed,
|
1659 |
-
easing : current.nextEasing,
|
1660 |
-
complete : F._afterZoomIn
|
1661 |
-
});
|
1662 |
-
}
|
1663 |
-
},
|
1664 |
-
|
1665 |
-
changeOut: function () {
|
1666 |
-
var previous = F.previous,
|
1667 |
-
effect = previous.prevEffect,
|
1668 |
-
endPos = { opacity : 0.1 },
|
1669 |
-
direction = F.direction,
|
1670 |
-
distance = 200;
|
1671 |
-
|
1672 |
-
if (effect === 'elastic') {
|
1673 |
-
endPos[ direction === 'down' || direction === 'up' ? 'top' : 'left' ] = ( direction === 'up' || direction === 'left' ? '-' : '+' ) + '=' + distance + 'px';
|
1674 |
-
}
|
1675 |
-
|
1676 |
-
previous.wrap.animate(endPos, {
|
1677 |
-
duration : effect === 'none' ? 0 : previous.prevSpeed,
|
1678 |
-
easing : previous.prevEasing,
|
1679 |
-
complete : function () {
|
1680 |
-
$(this).trigger('onReset').remove();
|
1681 |
-
}
|
1682 |
-
});
|
1683 |
-
}
|
1684 |
-
};
|
1685 |
-
|
1686 |
-
/*
|
1687 |
-
* Overlay helper
|
1688 |
-
*/
|
1689 |
-
|
1690 |
-
F.helpers.overlay = {
|
1691 |
-
defaults : {
|
1692 |
-
closeClick : true, // if true, fancyBox will be closed when user clicks on the overlay
|
1693 |
-
speedOut : 200, // duration of fadeOut animation
|
1694 |
-
showEarly : true, // indicates if should be opened immediately or wait until the content is ready
|
1695 |
-
css : {}, // custom CSS properties
|
1696 |
-
locked : !isTouch, // if true, the content will be locked into overlay
|
1697 |
-
fixed : true // if false, the overlay CSS position property will not be set to "fixed"
|
1698 |
-
},
|
1699 |
-
|
1700 |
-
overlay : null, // current handle
|
1701 |
-
fixed : false, // indicates if the overlay has position "fixed"
|
1702 |
-
el : $('html'), // element that contains "the lock"
|
1703 |
-
|
1704 |
-
// Public methods
|
1705 |
-
create : function(opts) {
|
1706 |
-
opts = $.extend({}, this.defaults, opts);
|
1707 |
-
|
1708 |
-
if (this.overlay) {
|
1709 |
-
this.close();
|
1710 |
-
}
|
1711 |
-
|
1712 |
-
this.overlay = $('<div class="fancybox-overlay"></div>').appendTo( F.coming ? F.coming.parent : opts.parent );
|
1713 |
-
this.fixed = false;
|
1714 |
-
|
1715 |
-
if (opts.fixed && F.defaults.fixed) {
|
1716 |
-
this.overlay.addClass('fancybox-overlay-fixed');
|
1717 |
-
|
1718 |
-
this.fixed = true;
|
1719 |
-
}
|
1720 |
-
},
|
1721 |
-
|
1722 |
-
open : function(opts) {
|
1723 |
-
var that = this;
|
1724 |
-
|
1725 |
-
opts = $.extend({}, this.defaults, opts);
|
1726 |
-
|
1727 |
-
if (this.overlay) {
|
1728 |
-
this.overlay.unbind('.overlay').width('auto').height('auto');
|
1729 |
-
|
1730 |
-
} else {
|
1731 |
-
this.create(opts);
|
1732 |
-
}
|
1733 |
-
|
1734 |
-
if (!this.fixed) {
|
1735 |
-
W.bind('resize.overlay', $.proxy( this.update, this) );
|
1736 |
-
|
1737 |
-
this.update();
|
1738 |
-
}
|
1739 |
-
|
1740 |
-
if (opts.closeClick) {
|
1741 |
-
this.overlay.bind('click.overlay', function(e) {
|
1742 |
-
if ($(e.target).hasClass('fancybox-overlay')) {
|
1743 |
-
if (F.isActive) {
|
1744 |
-
F.close();
|
1745 |
-
} else {
|
1746 |
-
that.close();
|
1747 |
-
}
|
1748 |
-
|
1749 |
-
return false;
|
1750 |
-
}
|
1751 |
-
});
|
1752 |
-
}
|
1753 |
-
|
1754 |
-
this.overlay.css( opts.css ).show();
|
1755 |
-
},
|
1756 |
-
|
1757 |
-
close : function() {
|
1758 |
-
var scrollV, scrollH;
|
1759 |
-
|
1760 |
-
W.unbind('resize.overlay');
|
1761 |
-
|
1762 |
-
if (this.el.hasClass('fancybox-lock')) {
|
1763 |
-
$('.fancybox-margin').removeClass('fancybox-margin');
|
1764 |
-
|
1765 |
-
scrollV = W.scrollTop();
|
1766 |
-
scrollH = W.scrollLeft();
|
1767 |
-
|
1768 |
-
this.el.removeClass('fancybox-lock');
|
1769 |
-
|
1770 |
-
W.scrollTop( scrollV ).scrollLeft( scrollH );
|
1771 |
-
}
|
1772 |
-
|
1773 |
-
$('.fancybox-overlay').remove().hide();
|
1774 |
-
|
1775 |
-
$.extend(this, {
|
1776 |
-
overlay : null,
|
1777 |
-
fixed : false
|
1778 |
-
});
|
1779 |
-
},
|
1780 |
-
|
1781 |
-
// Private, callbacks
|
1782 |
-
|
1783 |
-
update : function () {
|
1784 |
-
var width = '100%', offsetWidth;
|
1785 |
-
|
1786 |
-
// Reset width/height so it will not mess
|
1787 |
-
this.overlay.width(width).height('100%');
|
1788 |
-
|
1789 |
-
// jQuery does not return reliable result for IE
|
1790 |
-
if (IE) {
|
1791 |
-
offsetWidth = Math.max(document.documentElement.offsetWidth, document.body.offsetWidth);
|
1792 |
-
|
1793 |
-
if (D.width() > offsetWidth) {
|
1794 |
-
width = D.width();
|
1795 |
-
}
|
1796 |
-
|
1797 |
-
} else if (D.width() > W.width()) {
|
1798 |
-
width = D.width();
|
1799 |
-
}
|
1800 |
-
|
1801 |
-
this.overlay.width(width).height(D.height());
|
1802 |
-
},
|
1803 |
-
|
1804 |
-
// This is where we can manipulate DOM, because later it would cause iframes to reload
|
1805 |
-
onReady : function (opts, obj) {
|
1806 |
-
var overlay = this.overlay;
|
1807 |
-
|
1808 |
-
$('.fancybox-overlay').stop(true, true);
|
1809 |
-
|
1810 |
-
if (!overlay) {
|
1811 |
-
this.create(opts);
|
1812 |
-
}
|
1813 |
-
|
1814 |
-
if (opts.locked && this.fixed && obj.fixed) {
|
1815 |
-
if (!overlay) {
|
1816 |
-
this.margin = D.height() > W.height() ? $('html').css('margin-right').replace("px", "") : false;
|
1817 |
-
}
|
1818 |
-
|
1819 |
-
obj.locked = this.overlay.append( obj.wrap );
|
1820 |
-
obj.fixed = false;
|
1821 |
-
}
|
1822 |
-
|
1823 |
-
if (opts.showEarly === true) {
|
1824 |
-
this.beforeShow.apply(this, arguments);
|
1825 |
-
}
|
1826 |
-
},
|
1827 |
-
|
1828 |
-
beforeShow : function(opts, obj) {
|
1829 |
-
var scrollV, scrollH;
|
1830 |
-
|
1831 |
-
if (obj.locked) {
|
1832 |
-
if (this.margin !== false) {
|
1833 |
-
$('*').filter(function(){
|
1834 |
-
return ($(this).css('position') === 'fixed' && !$(this).hasClass("fancybox-overlay") && !$(this).hasClass("fancybox-wrap") );
|
1835 |
-
}).addClass('fancybox-margin');
|
1836 |
-
|
1837 |
-
this.el.addClass('fancybox-margin');
|
1838 |
-
}
|
1839 |
-
|
1840 |
-
scrollV = W.scrollTop();
|
1841 |
-
scrollH = W.scrollLeft();
|
1842 |
-
|
1843 |
-
this.el.addClass('fancybox-lock');
|
1844 |
-
|
1845 |
-
W.scrollTop( scrollV ).scrollLeft( scrollH );
|
1846 |
-
}
|
1847 |
-
|
1848 |
-
this.open(opts);
|
1849 |
-
},
|
1850 |
-
|
1851 |
-
onUpdate : function() {
|
1852 |
-
if (!this.fixed) {
|
1853 |
-
this.update();
|
1854 |
-
}
|
1855 |
-
},
|
1856 |
-
|
1857 |
-
afterClose: function (opts) {
|
1858 |
-
// Remove overlay if exists and fancyBox is not opening
|
1859 |
-
// (e.g., it is not being open using afterClose callback)
|
1860 |
-
//if (this.overlay && !F.isActive) {
|
1861 |
-
if (this.overlay && !F.coming) {
|
1862 |
-
this.overlay.fadeOut(opts.speedOut, $.proxy( this.close, this ));
|
1863 |
-
}
|
1864 |
-
}
|
1865 |
-
};
|
1866 |
-
|
1867 |
-
/*
|
1868 |
-
* Title helper
|
1869 |
-
*/
|
1870 |
-
|
1871 |
-
F.helpers.title = {
|
1872 |
-
defaults : {
|
1873 |
-
type : 'float', // 'float', 'inside', 'outside' or 'over',
|
1874 |
-
position : 'bottom' // 'top' or 'bottom'
|
1875 |
-
},
|
1876 |
-
|
1877 |
-
beforeShow: function (opts) {
|
1878 |
-
var current = F.current,
|
1879 |
-
text = current.title,
|
1880 |
-
type = opts.type,
|
1881 |
-
title,
|
1882 |
-
target;
|
1883 |
-
|
1884 |
-
if ($.isFunction(text)) {
|
1885 |
-
text = text.call(current.element, current);
|
1886 |
-
}
|
1887 |
-
|
1888 |
-
if (!isString(text) || $.trim(text) === '') {
|
1889 |
-
return;
|
1890 |
-
}
|
1891 |
-
|
1892 |
-
title = $('<div class="fancybox-title fancybox-title-' + type + '-wrap">' + text + '</div>');
|
1893 |
-
|
1894 |
-
switch (type) {
|
1895 |
-
case 'inside':
|
1896 |
-
target = F.skin;
|
1897 |
-
break;
|
1898 |
-
|
1899 |
-
case 'outside':
|
1900 |
-
target = F.wrap;
|
1901 |
-
break;
|
1902 |
-
|
1903 |
-
case 'over':
|
1904 |
-
target = F.inner;
|
1905 |
-
break;
|
1906 |
-
|
1907 |
-
default: // 'float'
|
1908 |
-
target = F.skin;
|
1909 |
-
|
1910 |
-
title.appendTo('body');
|
1911 |
-
|
1912 |
-
if (IE) {
|
1913 |
-
title.width( title.width() );
|
1914 |
-
}
|
1915 |
-
|
1916 |
-
title.wrapInner('<span class="child"></span>');
|
1917 |
-
|
1918 |
-
//Increase bottom margin so this title will also fit into viewport
|
1919 |
-
F.current.margin[2] += Math.abs( getScalar(title.css('margin-bottom')) );
|
1920 |
-
break;
|
1921 |
-
}
|
1922 |
-
|
1923 |
-
title[ (opts.position === 'top' ? 'prependTo' : 'appendTo') ](target);
|
1924 |
-
}
|
1925 |
-
};
|
1926 |
-
|
1927 |
-
// jQuery plugin initialization
|
1928 |
-
$.fn.fancybox = function (options) {
|
1929 |
-
var index,
|
1930 |
-
that = $(this),
|
1931 |
-
selector = this.selector || '',
|
1932 |
-
run = function(e) {
|
1933 |
-
var what = $(this).blur(), idx = index, relType, relVal;
|
1934 |
-
|
1935 |
-
if (!(e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) && !what.is('.fancybox-wrap')) {
|
1936 |
-
relType = options.groupAttr || 'data-fancybox-group';
|
1937 |
-
relVal = what.attr(relType);
|
1938 |
-
|
1939 |
-
if (!relVal) {
|
1940 |
-
relType = 'rel';
|
1941 |
-
relVal = what.get(0)[ relType ];
|
1942 |
-
}
|
1943 |
-
|
1944 |
-
if (relVal && relVal !== '' && relVal !== 'nofollow') {
|
1945 |
-
what = selector.length ? $(selector) : that;
|
1946 |
-
what = what.filter('[' + relType + '="' + relVal + '"]');
|
1947 |
-
idx = what.index(this);
|
1948 |
-
}
|
1949 |
-
|
1950 |
-
options.index = idx;
|
1951 |
-
|
1952 |
-
// Stop an event from bubbling if everything is fine
|
1953 |
-
if (F.open(what, options) !== false) {
|
1954 |
-
e.preventDefault();
|
1955 |
-
}
|
1956 |
-
}
|
1957 |
-
};
|
1958 |
-
|
1959 |
-
options = options || {};
|
1960 |
-
index = options.index || 0;
|
1961 |
-
|
1962 |
-
if (!selector || options.live === false) {
|
1963 |
-
that.unbind('click.fb-start').bind('click.fb-start', run);
|
1964 |
-
|
1965 |
-
} else {
|
1966 |
-
D.undelegate(selector, 'click.fb-start').delegate(selector + ":not('.fancybox-item, .fancybox-nav')", 'click.fb-start', run);
|
1967 |
-
}
|
1968 |
-
|
1969 |
-
this.filter('[data-fancybox-start=1]').trigger('click');
|
1970 |
-
|
1971 |
-
return this;
|
1972 |
-
};
|
1973 |
-
|
1974 |
-
// Tests that need a body at doc ready
|
1975 |
-
D.ready(function() {
|
1976 |
-
var w1, w2;
|
1977 |
-
|
1978 |
-
if ( $.scrollbarWidth === undefined ) {
|
1979 |
-
// http://benalman.com/projects/jquery-misc-plugins/#scrollbarwidth
|
1980 |
-
$.scrollbarWidth = function() {
|
1981 |
-
var parent = $('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo('body'),
|
1982 |
-
child = parent.children(),
|
1983 |
-
width = child.innerWidth() - child.height( 99 ).innerWidth();
|
1984 |
-
|
1985 |
-
parent.remove();
|
1986 |
-
|
1987 |
-
return width;
|
1988 |
-
};
|
1989 |
-
}
|
1990 |
-
|
1991 |
-
if ( $.support.fixedPosition === undefined ) {
|
1992 |
-
$.support.fixedPosition = (function() {
|
1993 |
-
var elem = $('<div style="position:fixed;top:20px;"></div>').appendTo('body'),
|
1994 |
-
fixed = ( elem[0].offsetTop === 20 || elem[0].offsetTop === 15 );
|
1995 |
-
|
1996 |
-
elem.remove();
|
1997 |
-
|
1998 |
-
return fixed;
|
1999 |
-
}());
|
2000 |
-
}
|
2001 |
-
|
2002 |
-
$.extend(F.defaults, {
|
2003 |
-
scrollbarWidth : $.scrollbarWidth(),
|
2004 |
-
fixed : $.support.fixedPosition,
|
2005 |
-
parent : $('body')
|
2006 |
-
});
|
2007 |
-
|
2008 |
-
//Get real width of page scroll-bar
|
2009 |
-
w1 = $(window).width();
|
2010 |
-
|
2011 |
-
H.addClass('fancybox-lock-test');
|
2012 |
-
|
2013 |
-
w2 = $(window).width();
|
2014 |
-
|
2015 |
-
H.removeClass('fancybox-lock-test');
|
2016 |
-
|
2017 |
-
$("<style type='text/css'>.fancybox-margin{margin-right:" + (w2 - w1) + "px;}</style>").appendTo("head");
|
2018 |
-
});
|
2019 |
-
|
2020 |
}(window, document, jQuery));
|
1 |
+
/*!
|
2 |
+
* fancyBox - jQuery Plugin
|
3 |
+
* version: 2.1.5 (Fri, 14 Jun 2013)
|
4 |
+
* @requires jQuery v1.6 or later
|
5 |
+
*
|
6 |
+
* Examples at http://fancyapps.com/fancybox/
|
7 |
+
* License: www.fancyapps.com/fancybox/#license
|
8 |
+
*
|
9 |
+
* Copyright 2012 Janis Skarnelis - janis@fancyapps.com
|
10 |
+
*
|
11 |
+
*/
|
12 |
+
|
13 |
+
(function (window, document, $, undefined) {
|
14 |
+
"use strict";
|
15 |
+
|
16 |
+
var H = $("html"),
|
17 |
+
W = $(window),
|
18 |
+
D = $(document),
|
19 |
+
F = $.fancybox = function () {
|
20 |
+
F.open.apply( this, arguments );
|
21 |
+
},
|
22 |
+
IE = navigator.userAgent.match(/msie/i),
|
23 |
+
didUpdate = null,
|
24 |
+
isTouch = document.createTouch !== undefined,
|
25 |
+
|
26 |
+
isQuery = function(obj) {
|
27 |
+
return obj && obj.hasOwnProperty && obj instanceof $;
|
28 |
+
},
|
29 |
+
isString = function(str) {
|
30 |
+
return str && $.type(str) === "string";
|
31 |
+
},
|
32 |
+
isPercentage = function(str) {
|
33 |
+
return isString(str) && str.indexOf('%') > 0;
|
34 |
+
},
|
35 |
+
isScrollable = function(el) {
|
36 |
+
return (el && !(el.style.overflow && el.style.overflow === 'hidden') && ((el.clientWidth && el.scrollWidth > el.clientWidth) || (el.clientHeight && el.scrollHeight > el.clientHeight)));
|
37 |
+
},
|
38 |
+
getScalar = function(orig, dim) {
|
39 |
+
var value = parseInt(orig, 10) || 0;
|
40 |
+
|
41 |
+
if (dim && isPercentage(orig)) {
|
42 |
+
value = F.getViewport()[ dim ] / 100 * value;
|
43 |
+
}
|
44 |
+
|
45 |
+
return Math.ceil(value);
|
46 |
+
},
|
47 |
+
getValue = function(value, dim) {
|
48 |
+
return getScalar(value, dim) + 'px';
|
49 |
+
};
|
50 |
+
|
51 |
+
$.extend(F, {
|
52 |
+
// The current version of fancyBox
|
53 |
+
version: '2.1.5',
|
54 |
+
|
55 |
+
defaults: {
|
56 |
+
padding : 15,
|
57 |
+
margin : 20,
|
58 |
+
|
59 |
+
width : 800,
|
60 |
+
height : 600,
|
61 |
+
minWidth : 100,
|
62 |
+
minHeight : 100,
|
63 |
+
maxWidth : 9999,
|
64 |
+
maxHeight : 9999,
|
65 |
+
pixelRatio: 1, // Set to 2 for retina display support
|
66 |
+
|
67 |
+
autoSize : true,
|
68 |
+
autoHeight : false,
|
69 |
+
autoWidth : false,
|
70 |
+
|
71 |
+
autoResize : true,
|
72 |
+
autoCenter : !isTouch,
|
73 |
+
fitToView : true,
|
74 |
+
aspectRatio : false,
|
75 |
+
topRatio : 0.5,
|
76 |
+
leftRatio : 0.5,
|
77 |
+
|
78 |
+
scrolling : 'auto', // 'auto', 'yes' or 'no'
|
79 |
+
wrapCSS : '',
|
80 |
+
|
81 |
+
arrows : true,
|
82 |
+
closeBtn : true,
|
83 |
+
closeClick : false,
|
84 |
+
nextClick : false,
|
85 |
+
mouseWheel : true,
|
86 |
+
autoPlay : false,
|
87 |
+
playSpeed : 3000,
|
88 |
+
preload : 3,
|
89 |
+
modal : false,
|
90 |
+
loop : true,
|
91 |
+
|
92 |
+
ajax : {
|
93 |
+
dataType : 'html',
|
94 |
+
headers : { 'X-fancyBox': true }
|
95 |
+
},
|
96 |
+
iframe : {
|
97 |
+
scrolling : 'auto',
|
98 |
+
preload : true
|
99 |
+
},
|
100 |
+
swf : {
|
101 |
+
wmode: 'transparent',
|
102 |
+
allowfullscreen : 'true',
|
103 |
+
allowscriptaccess : 'always'
|
104 |
+
},
|
105 |
+
|
106 |
+
keys : {
|
107 |
+
next : {
|
108 |
+
13 : 'left', // enter
|
109 |
+
34 : 'up', // page down
|
110 |
+
39 : 'left', // right arrow
|
111 |
+
40 : 'up' // down arrow
|
112 |
+
},
|
113 |
+
prev : {
|
114 |
+
8 : 'right', // backspace
|
115 |
+
33 : 'down', // page up
|
116 |
+
37 : 'right', // left arrow
|
117 |
+
38 : 'down' // up arrow
|
118 |
+
},
|
119 |
+
close : [27], // escape key
|
120 |
+
play : [32], // space - start/stop slideshow
|
121 |
+
toggle : [70] // letter "f" - toggle fullscreen
|
122 |
+
},
|
123 |
+
|
124 |
+
direction : {
|
125 |
+
next : 'left',
|
126 |
+
prev : 'right'
|
127 |
+
},
|
128 |
+
|
129 |
+
scrollOutside : true,
|
130 |
+
|
131 |
+
// Override some properties
|
132 |
+
index : 0,
|
133 |
+
type : null,
|
134 |
+
href : null,
|
135 |
+
content : null,
|
136 |
+
title : null,
|
137 |
+
|
138 |
+
// HTML templates
|
139 |
+
tpl: {
|
140 |
+
wrap : '<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>',
|
141 |
+
image : '<img class="fancybox-image" src="{href}" alt="" />',
|
142 |
+
iframe : '<iframe id="fancybox-frame{rnd}" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen' + (IE ? ' allowtransparency="true"' : '') + '></iframe>',
|
143 |
+
error : '<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',
|
144 |
+
closeBtn : '<a title="Close" class="fancybox-item fancybox-close" href="javascript:;"></a>',
|
145 |
+
next : '<a title="Next" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',
|
146 |
+
prev : '<a title="Previous" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'
|
147 |
+
},
|
148 |
+
|
149 |
+
// Properties for each animation type
|
150 |
+
// Opening fancyBox
|
151 |
+
openEffect : 'fade', // 'elastic', 'fade' or 'none'
|
152 |
+
openSpeed : 250,
|
153 |
+
openEasing : 'swing',
|
154 |
+
openOpacity : true,
|
155 |
+
openMethod : 'zoomIn',
|
156 |
+
|
157 |
+
// Closing fancyBox
|
158 |
+
closeEffect : 'fade', // 'elastic', 'fade' or 'none'
|
159 |
+
closeSpeed : 250,
|
160 |
+
closeEasing : 'swing',
|
161 |
+
closeOpacity : true,
|
162 |
+
closeMethod : 'zoomOut',
|
163 |
+
|
164 |
+
// Changing next gallery item
|
165 |
+
nextEffect : 'elastic', // 'elastic', 'fade' or 'none'
|
166 |
+
nextSpeed : 250,
|
167 |
+
nextEasing : 'swing',
|
168 |
+
nextMethod : 'changeIn',
|
169 |
+
|
170 |
+
// Changing previous gallery item
|
171 |
+
prevEffect : 'elastic', // 'elastic', 'fade' or 'none'
|
172 |
+
prevSpeed : 250,
|
173 |
+
prevEasing : 'swing',
|
174 |
+
prevMethod : 'changeOut',
|
175 |
+
|
176 |
+
// Enable default helpers
|
177 |
+
helpers : {
|
178 |
+
overlay : true,
|
179 |
+
title : true
|
180 |
+
},
|
181 |
+
|
182 |
+
// Callbacks
|
183 |
+
onCancel : $.noop, // If canceling
|
184 |
+
beforeLoad : $.noop, // Before loading
|
185 |
+
afterLoad : $.noop, // After loading
|
186 |
+
beforeShow : $.noop, // Before changing in current item
|
187 |
+
afterShow : $.noop, // After opening
|
188 |
+
beforeChange : $.noop, // Before changing gallery item
|
189 |
+
beforeClose : $.noop, // Before closing
|
190 |
+
afterClose : $.noop // After closing
|
191 |
+
},
|
192 |
+
|
193 |
+
//Current state
|
194 |
+
group : {}, // Selected group
|
195 |
+
opts : {}, // Group options
|
196 |
+
previous : null, // Previous element
|
197 |
+
coming : null, // Element being loaded
|
198 |
+
current : null, // Currently loaded element
|
199 |
+
isActive : false, // Is activated
|
200 |
+
isOpen : false, // Is currently open
|
201 |
+
isOpened : false, // Have been fully opened at least once
|
202 |
+
|
203 |
+
wrap : null,
|
204 |
+
skin : null,
|
205 |
+
outer : null,
|
206 |
+
inner : null,
|
207 |
+
|
208 |
+
player : {
|
209 |
+
timer : null,
|
210 |
+
isActive : false
|
211 |
+
},
|
212 |
+
|
213 |
+
// Loaders
|
214 |
+
ajaxLoad : null,
|
215 |
+
imgPreload : null,
|
216 |
+
|
217 |
+
// Some collections
|
218 |
+
transitions : {},
|
219 |
+
helpers : {},
|
220 |
+
|
221 |
+
/*
|
222 |
+
* Static methods
|
223 |
+
*/
|
224 |
+
|
225 |
+
open: function (group, opts) {
|
226 |
+
if (!group) {
|
227 |
+
return;
|
228 |
+
}
|
229 |
+
|
230 |
+
if (!$.isPlainObject(opts)) {
|
231 |
+
opts = {};
|
232 |
+
}
|
233 |
+
|
234 |
+
// Close if already active
|
235 |
+
if (false === F.close(true)) {
|
236 |
+
return;
|
237 |
+
}
|
238 |
+
|
239 |
+
// Normalize group
|
240 |
+
if (!$.isArray(group)) {
|
241 |
+
group = isQuery(group) ? $(group).get() : [group];
|
242 |
+
}
|
243 |
+
|
244 |
+
// Recheck if the type of each element is `object` and set content type (image, ajax, etc)
|
245 |
+
$.each(group, function(i, element) {
|
246 |
+
var obj = {},
|
247 |
+
href,
|
248 |
+
title,
|
249 |
+
content,
|
250 |
+
type,
|
251 |
+
rez,
|
252 |
+
hrefParts,
|
253 |
+
selector;
|
254 |
+
|
255 |
+
if ($.type(element) === "object") {
|
256 |
+
// Check if is DOM element
|
257 |
+
if (element.nodeType) {
|
258 |
+
element = $(element);
|
259 |
+
}
|
260 |
+
|
261 |
+
if (isQuery(element)) {
|
262 |
+
obj = {
|
263 |
+
href : element.data('fancybox-href') || element.attr('href'),
|
264 |
+
title : element.data('fancybox-title') || element.attr('title'),
|
265 |
+
isDom : true,
|
266 |
+
element : element
|
267 |
+
};
|
268 |
+
|
269 |
+
if ($.metadata) {
|
270 |
+
$.extend(true, obj, element.metadata());
|
271 |
+
}
|
272 |
+
|
273 |
+
} else {
|
274 |
+
obj = element;
|
275 |
+
}
|
276 |
+
}
|
277 |
+
|
278 |
+
href = opts.href || obj.href || (isString(element) ? element : null);
|
279 |
+
title = opts.title !== undefined ? opts.title : obj.title || '';
|
280 |
+
|
281 |
+
content = opts.content || obj.content;
|
282 |
+
type = content ? 'html' : (opts.type || obj.type);
|
283 |
+
|
284 |
+
if (!type && obj.isDom) {
|
285 |
+
type = element.data('fancybox-type');
|
286 |
+
|
287 |
+
if (!type) {
|
288 |
+
rez = element.prop('class').match(/fancybox\.(\w+)/);
|
289 |
+
type = rez ? rez[1] : null;
|
290 |
+
}
|
291 |
+
}
|
292 |
+
|
293 |
+
if (isString(href)) {
|
294 |
+
// Try to guess the content type
|
295 |
+
if (!type) {
|
296 |
+
if (F.isImage(href)) {
|
297 |
+
type = 'image';
|
298 |
+
|
299 |
+
} else if (F.isSWF(href)) {
|
300 |
+
type = 'swf';
|
301 |
+
|
302 |
+
} else if (href.charAt(0) === '#') {
|
303 |
+
type = 'inline';
|
304 |
+
|
305 |
+
} else if (isString(element)) {
|
306 |
+
type = 'html';
|
307 |
+
content = element;
|
308 |
+
}
|
309 |
+
}
|
310 |
+
|
311 |
+
// Split url into two pieces with source url and content selector, e.g,
|
312 |
+
// "/mypage.html #my_id" will load "/mypage.html" and display element having id "my_id"
|
313 |
+
if (type === 'ajax') {
|
314 |
+
hrefParts = href.split(/\s+/, 2);
|
315 |
+
href = hrefParts.shift();
|
316 |
+
selector = hrefParts.shift();
|
317 |
+
}
|
318 |
+
}
|
319 |
+
|
320 |
+
if (!content) {
|
321 |
+
if (type === 'inline') {
|
322 |
+
if (href) {
|
323 |
+
content = $( isString(href) ? href.replace(/.*(?=#[^\s]+$)/, '') : href ); //strip for ie7
|
324 |
+
|
325 |
+
} else if (obj.isDom) {
|
326 |
+
content = element;
|
327 |
+
}
|
328 |
+
|
329 |
+
} else if (type === 'html') {
|
330 |
+
content = href;
|
331 |
+
|
332 |
+
} else if (!type && !href && obj.isDom) {
|
333 |
+
type = 'inline';
|
334 |
+
content = element;
|
335 |
+
}
|
336 |
+
}
|
337 |
+
|
338 |
+
$.extend(obj, {
|
339 |
+
href : href,
|
340 |
+
type : type,
|
341 |
+
content : content,
|
342 |
+
title : title,
|
343 |
+
selector : selector
|
344 |
+
});
|
345 |
+
|
346 |
+
group[ i ] = obj;
|
347 |
+
});
|
348 |
+
|
349 |
+
// Extend the defaults
|
350 |
+
F.opts = $.extend(true, {}, F.defaults, opts);
|
351 |
+
|
352 |
+
// All options are merged recursive except keys
|
353 |
+
if (opts.keys !== undefined) {
|
354 |
+
F.opts.keys = opts.keys ? $.extend({}, F.defaults.keys, opts.keys) : false;
|
355 |
+
}
|
356 |
+
|
357 |
+
F.group = group;
|
358 |
+
|
359 |
+
return F._start(F.opts.index);
|
360 |
+
},
|
361 |
+
|
362 |
+
// Cancel image loading or abort ajax request
|
363 |
+
cancel: function () {
|
364 |
+
var coming = F.coming;
|
365 |
+
|
366 |
+
if (!coming || false === F.trigger('onCancel')) {
|
367 |
+
return;
|
368 |
+
}
|
369 |
+
|
370 |
+
F.hideLoading();
|
371 |
+
|
372 |
+
if (F.ajaxLoad) {
|
373 |
+
F.ajaxLoad.abort();
|
374 |
+
}
|
375 |
+
|
376 |
+
F.ajaxLoad = null;
|
377 |
+
|
378 |
+
if (F.imgPreload) {
|
379 |
+
F.imgPreload.onload = F.imgPreload.onerror = null;
|
380 |
+
}
|
381 |
+
|
382 |
+
if (coming.wrap) {
|
383 |
+
coming.wrap.stop(true, true).trigger('onReset').remove();
|
384 |
+
}
|
385 |
+
|
386 |
+
F.coming = null;
|
387 |
+
|
388 |
+
// If the first item has been canceled, then clear everything
|
389 |
+
if (!F.current) {
|
390 |
+
F._afterZoomOut( coming );
|
391 |
+
}
|
392 |
+
},
|
393 |
+
|
394 |
+
// Start closing animation if is open; remove immediately if opening/closing
|
395 |
+
close: function (event) {
|
396 |
+
F.cancel();
|
397 |
+
|
398 |
+
if (false === F.trigger('beforeClose')) {
|
399 |
+
return;
|
400 |
+
}
|
401 |
+
|
402 |
+
F.unbindEvents();
|
403 |
+
|
404 |
+
if (!F.isActive) {
|
405 |
+
return;
|
406 |
+
}
|
407 |
+
|
408 |
+
if (!F.isOpen || event === true) {
|
409 |
+
$('.fancybox-wrap').stop(true).trigger('onReset').remove();
|
410 |
+
|
411 |
+
F._afterZoomOut();
|
412 |
+
|
413 |
+
} else {
|
414 |
+
F.isOpen = F.isOpened = false;
|
415 |
+
F.isClosing = true;
|
416 |
+
|
417 |
+
$('.fancybox-item, .fancybox-nav').remove();
|
418 |
+
|
419 |
+
F.wrap.stop(true, true).removeClass('fancybox-opened');
|
420 |
+
|
421 |
+
F.transitions[ F.current.closeMethod ]();
|
422 |
+
}
|
423 |
+
},
|
424 |
+
|
425 |
+
// Manage slideshow:
|
426 |
+
// $.fancybox.play(); - toggle slideshow
|
427 |
+
// $.fancybox.play( true ); - start
|
428 |
+
// $.fancybox.play( false ); - stop
|
429 |
+
play: function ( action ) {
|
430 |
+
var clear = function () {
|
431 |
+
clearTimeout(F.player.timer);
|
432 |
+
},
|
433 |
+
set = function () {
|
434 |
+
clear();
|
435 |
+
|
436 |
+
if (F.current && F.player.isActive) {
|
437 |
+
F.player.timer = setTimeout(F.next, F.current.playSpeed);
|
438 |
+
}
|
439 |
+
},
|
440 |
+
stop = function () {
|
441 |
+
clear();
|
442 |
+
|
443 |
+
D.unbind('.player');
|
444 |
+
|
445 |
+
F.player.isActive = false;
|
446 |
+
|
447 |
+
F.trigger('onPlayEnd');
|
448 |
+
},
|
449 |
+
start = function () {
|
450 |
+
if (F.current && (F.current.loop || F.current.index < F.group.length - 1)) {
|
451 |
+
F.player.isActive = true;
|
452 |
+
|
453 |
+
D.bind({
|
454 |
+
'onCancel.player beforeClose.player' : stop,
|
455 |
+
'onUpdate.player' : set,
|
456 |
+
'beforeLoad.player' : clear
|
457 |
+
});
|
458 |
+
|
459 |
+
set();
|
460 |
+
|
461 |
+
F.trigger('onPlayStart');
|
462 |
+
}
|
463 |
+
};
|
464 |
+
|
465 |
+
if (action === true || (!F.player.isActive && action !== false)) {
|
466 |
+
start();
|
467 |
+
} else {
|
468 |
+
stop();
|
469 |
+
}
|
470 |
+
},
|
471 |
+
|
472 |
+
// Navigate to next gallery item
|
473 |
+
next: function ( direction ) {
|
474 |
+
var current = F.current;
|
475 |
+
|
476 |
+
if (current) {
|
477 |
+
if (!isString(direction)) {
|
478 |
+
direction = current.direction.next;
|
479 |
+
}
|
480 |
+
|
481 |
+
F.jumpto(current.index + 1, direction, 'next');
|
482 |
+
}
|
483 |
+
},
|
484 |
+
|
485 |
+
// Navigate to previous gallery item
|
486 |
+
prev: function ( direction ) {
|
487 |
+
var current = F.current;
|
488 |
+
|
489 |
+
if (current) {
|
490 |
+
if (!isString(direction)) {
|
491 |
+
direction = current.direction.prev;
|
492 |
+
}
|
493 |
+
|
494 |
+
F.jumpto(current.index - 1, direction, 'prev');
|
495 |
+
}
|
496 |
+
},
|
497 |
+
|
498 |
+
// Navigate to gallery item by index
|
499 |
+
jumpto: function ( index, direction, router ) {
|
500 |
+
var current = F.current;
|
501 |
+
|
502 |
+
if (!current) {
|
503 |
+
return;
|
504 |
+
}
|
505 |
+
|
506 |
+
index = getScalar(index);
|
507 |
+
|
508 |
+
F.direction = direction || current.direction[ (index >= current.index ? 'next' : 'prev') ];
|
509 |
+
F.router = router || 'jumpto';
|
510 |
+
|
511 |
+
if (current.loop) {
|
512 |
+
if (index < 0) {
|
513 |
+
index = current.group.length + (index % current.group.length);
|
514 |
+
}
|
515 |
+
|
516 |
+
index = index % current.group.length;
|
517 |
+
}
|
518 |
+
|
519 |
+
if (current.group[ index ] !== undefined) {
|
520 |
+
F.cancel();
|
521 |
+
|
522 |
+
F._start(index);
|
523 |
+
}
|
524 |
+
},
|
525 |
+
|
526 |
+
// Center inside viewport and toggle position type to fixed or absolute if needed
|
527 |
+
reposition: function (e, onlyAbsolute) {
|
528 |
+
var current = F.current,
|
529 |
+
wrap = current ? current.wrap : null,
|
530 |
+
pos;
|
531 |
+
|
532 |
+
if (wrap) {
|
533 |
+
pos = F._getPosition(onlyAbsolute);
|
534 |
+
|
535 |
+
if (e && e.type === 'scroll') {
|
536 |
+
delete pos.position;
|
537 |
+
|
538 |
+
wrap.stop(true, true).animate(pos, 200);
|
539 |
+
|
540 |
+
} else {
|
541 |
+
wrap.css(pos);
|
542 |
+
|
543 |
+
current.pos = $.extend({}, current.dim, pos);
|
544 |
+
}
|
545 |
+
}
|
546 |
+
},
|
547 |
+
|
548 |
+
update: function (e) {
|
549 |
+
var type = (e && e.type),
|
550 |
+
anyway = !type || type === 'orientationchange';
|
551 |
+
|
552 |
+
if (anyway) {
|
553 |
+
clearTimeout(didUpdate);
|
554 |
+
|
555 |
+
didUpdate = null;
|
556 |
+
}
|
557 |
+
|
558 |
+
if (!F.isOpen || didUpdate) {
|
559 |
+
return;
|
560 |
+
}
|
561 |
+
|
562 |
+
didUpdate = setTimeout(function() {
|
563 |
+
var current = F.current;
|
564 |
+
|
565 |
+
if (!current || F.isClosing) {
|
566 |
+
return;
|
567 |
+
}
|
568 |
+
|
569 |
+
F.wrap.removeClass('fancybox-tmp');
|
570 |
+
|
571 |
+
if (anyway || type === 'load' || (type === 'resize' && current.autoResize)) {
|
572 |
+
F._setDimension();
|
573 |
+
}
|
574 |
+
|
575 |
+
if (!(type === 'scroll' && current.canShrink)) {
|
576 |
+
F.reposition(e);
|
577 |
+
}
|
578 |
+
|
579 |
+
F.trigger('onUpdate');
|
580 |
+
|
581 |
+
didUpdate = null;
|
582 |
+
|
583 |
+
}, (anyway && !isTouch ? 0 : 300));
|
584 |
+
},
|
585 |
+
|
586 |
+
// Shrink content to fit inside viewport or restore if resized
|
587 |
+
toggle: function ( action ) {
|
588 |
+
if (F.isOpen) {
|
589 |
+
F.current.fitToView = $.type(action) === "boolean" ? action : !F.current.fitToView;
|
590 |
+
|
591 |
+
// Help browser to restore document dimensions
|
592 |
+
if (isTouch) {
|
593 |
+
F.wrap.removeAttr('style').addClass('fancybox-tmp');
|
594 |
+
|
595 |
+
F.trigger('onUpdate');
|
596 |
+
}
|
597 |
+
|
598 |
+
F.update();
|
599 |
+
}
|
600 |
+
},
|
601 |
+
|
602 |
+
hideLoading: function () {
|
603 |
+
D.unbind('.loading');
|
604 |
+
|
605 |
+
$('#fancybox-loading').remove();
|
606 |
+
},
|
607 |
+
|
608 |
+
showLoading: function () {
|
609 |
+
var el, viewport;
|
610 |
+
|
611 |
+
F.hideLoading();
|
612 |
+
|
613 |
+
el = $('<div id="fancybox-loading"><div></div></div>').click(F.cancel).appendTo('body');
|
614 |
+
|
615 |
+
// If user will press the escape-button, the request will be canceled
|
616 |
+
D.bind('keydown.loading', function(e) {
|
617 |
+
if ((e.which || e.keyCode) === 27) {
|
618 |
+
e.preventDefault();
|
619 |
+
|
620 |
+
F.cancel();
|
621 |
+
}
|
622 |
+
});
|
623 |
+
|
624 |
+
if (!F.defaults.fixed) {
|
625 |
+
viewport = F.getViewport();
|
626 |
+
|
627 |
+
el.css({
|
628 |
+
position : 'absolute',
|
629 |
+
top : (viewport.h * 0.5) + viewport.y,
|
630 |
+
left : (viewport.w * 0.5) + viewport.x
|
631 |
+
});
|
632 |
+
}
|
633 |
+
},
|
634 |
+
|
635 |
+
getViewport: function () {
|
636 |
+
var locked = (F.current && F.current.locked) || false,
|
637 |
+
rez = {
|
638 |
+
x: W.scrollLeft(),
|
639 |
+
y: W.scrollTop()
|
640 |
+
};
|
641 |
+
|
642 |
+
if (locked) {
|
643 |
+
rez.w = locked[0].clientWidth;
|
644 |
+
rez.h = locked[0].clientHeight;
|
645 |
+
|
646 |
+
} else {
|
647 |
+
// See http://bugs.jquery.com/ticket/6724
|
648 |
+
rez.w = isTouch && window.innerWidth ? window.innerWidth : W.width();
|
649 |
+
rez.h = isTouch && window.innerHeight ? window.innerHeight : W.height();
|
650 |
+
}
|
651 |
+
|
652 |
+
return rez;
|
653 |
+
},
|
654 |
+
|
655 |
+
// Unbind the keyboard / clicking actions
|
656 |
+
unbindEvents: function () {
|
657 |
+
if (F.wrap && isQuery(F.wrap)) {
|
658 |
+
F.wrap.unbind('.fb');
|
659 |
+
}
|
660 |
+
|
661 |
+
D.unbind('.fb');
|
662 |
+
W.unbind('.fb');
|
663 |
+
},
|
664 |
+
|
665 |
+
bindEvents: function () {
|
666 |
+
var current = F.current,
|
667 |
+
keys;
|
668 |
+
|
669 |
+
if (!current) {
|
670 |
+
return;
|
671 |
+
}
|
672 |
+
|
673 |
+
// Changing document height on iOS devices triggers a 'resize' event,
|
674 |
+
// that can change document height... repeating infinitely
|
675 |
+
W.bind('orientationchange.fb' + (isTouch ? '' : ' resize.fb') + (current.autoCenter && !current.locked ? ' scroll.fb' : ''), F.update);
|
676 |
+
|
677 |
+
keys = current.keys;
|
678 |
+
|
679 |
+
if (keys) {
|
680 |
+
D.bind('keydown.fb', function (e) {
|
681 |
+
var code = e.which || e.keyCode,
|
682 |
+
target = e.target || e.srcElement;
|
683 |
+
|
684 |
+
// Skip esc key if loading, because showLoading will cancel preloading
|
685 |
+
if (code === 27 && F.coming) {
|
686 |
+
return false;
|
687 |
+
}
|
688 |
+
|
689 |
+
// Ignore key combinations and key events within form elements
|
690 |
+
if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey && !(target && (target.type || $(target).is('[contenteditable]')))) {
|
691 |
+
$.each(keys, function(i, val) {
|
692 |
+
if (current.group.length > 1 && val[ code ] !== undefined) {
|
693 |
+
F[ i ]( val[ code ] );
|
694 |
+
|
695 |
+
e.preventDefault();
|
696 |
+
return false;
|
697 |
+
}
|
698 |
+
|
699 |
+
if ($.inArray(code, val) > -1) {
|
700 |
+
F[ i ] ();
|
701 |
+
|
702 |
+
e.preventDefault();
|
703 |
+
return false;
|
704 |
+
}
|
705 |
+
});
|
706 |
+
}
|
707 |
+
});
|
708 |
+
}
|
709 |
+
|
710 |
+
if ($.fn.mousewheel && current.mouseWheel) {
|
711 |
+
F.wrap.bind('mousewheel.fb', function (e, delta, deltaX, deltaY) {
|
712 |
+
var target = e.target || null,
|
713 |
+
parent = $(target),
|
714 |
+
canScroll = false;
|
715 |
+
|
716 |
+
while (parent.length) {
|
717 |
+
if (canScroll || parent.is('.fancybox-skin') || parent.is('.fancybox-wrap')) {
|
718 |
+
break;
|
719 |
+
}
|
720 |
+
|
721 |
+
canScroll = isScrollable( parent[0] );
|
722 |
+
parent = $(parent).parent();
|
723 |
+
}
|
724 |
+
|
725 |
+
if (delta !== 0 && !canScroll) {
|
726 |
+
if (F.group.length > 1 && !current.canShrink) {
|
727 |
+
if (deltaY > 0 || deltaX > 0) {
|
728 |
+
F.prev( deltaY > 0 ? 'down' : 'left' );
|
729 |
+
|
730 |
+
} else if (deltaY < 0 || deltaX < 0) {
|
731 |
+
F.next( deltaY < 0 ? 'up' : 'right' );
|
732 |
+
}
|
733 |
+
|
734 |
+
e.preventDefault();
|
735 |
+
}
|
736 |
+
}
|
737 |
+
});
|
738 |
+
}
|
739 |
+
},
|
740 |
+
|
741 |
+
trigger: function (event, o) {
|
742 |
+
var ret, obj = o || F.coming || F.current;
|
743 |
+
|
744 |
+
if (!obj) {
|
745 |
+
return;
|
746 |
+
}
|
747 |
+
|
748 |
+
if ($.isFunction( obj[event] )) {
|
749 |
+
ret = obj[event].apply(obj, Array.prototype.slice.call(arguments, 1));
|
750 |
+
}
|
751 |
+
|
752 |
+
if (ret === false) {
|
753 |
+
return false;
|
754 |
+
}
|
755 |
+
|
756 |
+
if (obj.helpers) {
|
757 |
+
$.each(obj.helpers, function (helper, opts) {
|
758 |
+
if (opts && F.helpers[helper] && $.isFunction(F.helpers[helper][event])) {
|
759 |
+
F.helpers[helper][event]($.extend(true, {}, F.helpers[helper].defaults, opts), obj);
|
760 |
+
}
|
761 |
+
});
|
762 |
+
}
|
763 |
+
|
764 |
+
D.trigger(event);
|
765 |
+
},
|
766 |
+
|
767 |
+
isImage: function (str) {
|
768 |
+
return isString(str) && str.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i);
|
769 |
+
},
|
770 |
+
|
771 |
+
isSWF: function (str) {
|
772 |
+
return isString(str) && str.match(/\.(swf)((\?|#).*)?$/i);
|
773 |
+
},
|
774 |
+
|
775 |
+
_start: function (index) {
|
776 |
+
var coming = {},
|
777 |
+
obj,
|
778 |
+
href,
|
779 |
+
type,
|
780 |
+
margin,
|
781 |
+
padding;
|
782 |
+
|
783 |
+
index = getScalar( index );
|
784 |
+
obj = F.group[ index ] || null;
|
785 |
+
|
786 |
+
if (!obj) {
|
787 |
+
return false;
|
788 |
+
}
|
789 |
+
|
790 |
+
coming = $.extend(true, {}, F.opts, obj);
|
791 |
+
|
792 |
+
// Convert margin and padding properties to array - top, right, bottom, left
|
793 |
+
margin = coming.margin;
|
794 |
+
padding = coming.padding;
|
795 |
+
|
796 |
+
if ($.type(margin) === 'number') {
|
797 |
+
coming.margin = [margin, margin, margin, margin];
|
798 |
+
}
|
799 |
+
|
800 |
+
if ($.type(padding) === 'number') {
|
801 |
+
coming.padding = [padding, padding, padding, padding];
|
802 |
+
}
|
803 |
+
|
804 |
+
// 'modal' propery is just a shortcut
|
805 |
+
if (coming.modal) {
|
806 |
+
$.extend(true, coming, {
|
807 |
+
closeBtn : false,
|
808 |
+
closeClick : false,
|
809 |
+
nextClick : false,
|
810 |
+
arrows : false,
|
811 |
+
mouseWheel : false,
|
812 |
+
keys : null,
|
813 |
+
helpers: {
|
814 |
+
overlay : {
|
815 |
+
closeClick : false
|
816 |
+
}
|
817 |
+
}
|
818 |
+
});
|
819 |
+
}
|
820 |
+
|
821 |
+
// 'autoSize' property is a shortcut, too
|
822 |
+
if (coming.autoSize) {
|
823 |
+
coming.autoWidth = coming.autoHeight = true;
|
824 |
+
}
|
825 |
+
|
826 |
+
if (coming.width === 'auto') {
|
827 |
+
coming.autoWidth = true;
|
828 |
+
}
|
829 |
+
|
830 |
+
if (coming.height === 'auto') {
|
831 |
+
coming.autoHeight = true;
|
832 |
+
}
|
833 |
+
|
834 |
+
/*
|
835 |
+
* Add reference to the group, so it`s possible to access from callbacks, example:
|
836 |
+
* afterLoad : function() {
|
837 |
+
* this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');
|
838 |
+
* }
|
839 |
+
*/
|
840 |
+
|
841 |
+
coming.group = F.group;
|
842 |
+
coming.index = index;
|
843 |
+
|
844 |
+
// Give a chance for callback or helpers to update coming item (type, title, etc)
|
845 |
+
F.coming = coming;
|
846 |
+
|
847 |
+
if (false === F.trigger('beforeLoad')) {
|
848 |
+
F.coming = null;
|
849 |
+
|
850 |
+
return;
|
851 |
+
}
|
852 |
+
|
853 |
+
type = coming.type;
|
854 |
+
href = coming.href;
|
855 |
+
|
856 |
+
if (!type) {
|
857 |
+
F.coming = null;
|
858 |
+
|
859 |
+
//If we can not determine content type then drop silently or display next/prev item if looping through gallery
|
860 |
+
if (F.current && F.router && F.router !== 'jumpto') {
|
861 |
+
F.current.index = index;
|
862 |
+
|
863 |
+
return F[ F.router ]( F.direction );
|
864 |
+
}
|
865 |
+
|
866 |
+
return false;
|
867 |
+
}
|
868 |
+
|
869 |
+
F.isActive = true;
|
870 |
+
|
871 |
+
if (type === 'image' || type === 'swf') {
|
872 |
+
coming.autoHeight = coming.autoWidth = false;
|
873 |
+
coming.scrolling = 'visible';
|
874 |
+
}
|
875 |
+
|
876 |
+
if (type === 'image') {
|
877 |
+
coming.aspectRatio = true;
|
878 |
+
}
|
879 |
+
|
880 |
+
if (type === 'iframe' && isTouch) {
|
881 |
+
coming.scrolling = 'scroll';
|
882 |
+
}
|
883 |
+
|
884 |
+
// Build the neccessary markup
|
885 |
+
coming.wrap = $(coming.tpl.wrap).addClass('fancybox-' + (isTouch ? 'mobile' : 'desktop') + ' fancybox-type-' + type + ' fancybox-tmp ' + coming.wrapCSS).appendTo( coming.parent || 'body' );
|
886 |
+
|
887 |
+
$.extend(coming, {
|
888 |
+
skin : $('.fancybox-skin', coming.wrap),
|
889 |
+
outer : $('.fancybox-outer', coming.wrap),
|
890 |
+
inner : $('.fancybox-inner', coming.wrap)
|
891 |
+
});
|
892 |
+
|
893 |
+
$.each(["Top", "Right", "Bottom", "Left"], function(i, v) {
|
894 |
+
coming.skin.css('padding' + v, getValue(coming.padding[ i ]));
|
895 |
+
});
|
896 |
+
|
897 |
+
F.trigger('onReady');
|
898 |
+
|
899 |
+
// Check before try to load; 'inline' and 'html' types need content, others - href
|
900 |
+
if (type === 'inline' || type === 'html') {
|
901 |
+
if (!coming.content || !coming.content.length) {
|
902 |
+
return F._error( 'content' );
|
903 |
+
}
|
904 |
+
|
905 |
+
} else if (!href) {
|
906 |
+
return F._error( 'href' );
|
907 |
+
}
|
908 |
+
|
909 |
+
if (type === 'image') {
|
910 |
+
F._loadImage();
|
911 |
+
|
912 |
+
} else if (type === 'ajax') {
|
913 |
+
F._loadAjax();
|
914 |
+
|
915 |
+
} else if (type === 'iframe') {
|
916 |
+
F._loadIframe();
|
917 |
+
|
918 |
+
} else {
|
919 |
+
F._afterLoad();
|
920 |
+
}
|
921 |
+
},
|
922 |
+
|
923 |
+
_error: function ( type ) {
|
924 |
+
$.extend(F.coming, {
|
925 |
+
type : 'html',
|
926 |
+
autoWidth : true,
|
927 |
+
autoHeight : true,
|
928 |
+
minWidth : 0,
|
929 |
+
minHeight : 0,
|
930 |
+
scrolling : 'no',
|
931 |
+
hasError : type,
|
932 |
+
content : F.coming.tpl.error
|
933 |
+
});
|
934 |
+
|
935 |
+
F._afterLoad();
|
936 |
+
},
|
937 |
+
|
938 |
+
_loadImage: function () {
|
939 |
+
// Reset preload image so it is later possible to check "complete" property
|
940 |
+
var img = F.imgPreload = new Image();
|
941 |
+
|
942 |
+
img.onload = function () {
|
943 |
+
this.onload = this.onerror = null;
|
944 |
+
|
945 |
+
F.coming.width = this.width / F.opts.pixelRatio;
|
946 |
+
F.coming.height = this.height / F.opts.pixelRatio;
|
947 |
+
|
948 |
+
F._afterLoad();
|
949 |
+
};
|
950 |
+
|
951 |
+
img.onerror = function () {
|
952 |
+
this.onload = this.onerror = null;
|
953 |
+
|
954 |
+
F._error( 'image' );
|
955 |
+
};
|
956 |
+
|
957 |
+
img.src = F.coming.href;
|
958 |
+
|
959 |
+
if (img.complete !== true) {
|
960 |
+
F.showLoading();
|
961 |
+
}
|
962 |
+
},
|
963 |
+
|
964 |
+
_loadAjax: function () {
|
965 |
+
var coming = F.coming;
|
966 |
+
|
967 |
+
F.showLoading();
|
968 |
+
|
969 |
+
F.ajaxLoad = $.ajax($.extend({}, coming.ajax, {
|
970 |
+
url: coming.href,
|
971 |
+
error: function (jqXHR, textStatus) {
|
972 |
+
if (F.coming && textStatus !== 'abort') {
|
973 |
+
F._error( 'ajax', jqXHR );
|
974 |
+
|
975 |
+
} else {
|
976 |
+
F.hideLoading();
|
977 |
+
}
|
978 |
+
},
|
979 |
+
success: function (data, textStatus) {
|
980 |
+
if (textStatus === 'success') {
|
981 |
+
coming.content = data;
|
982 |
+
|
983 |
+
F._afterLoad();
|
984 |
+
}
|
985 |
+
}
|
986 |
+
}));
|
987 |
+
},
|
988 |
+
|
989 |
+
_loadIframe: function() {
|
990 |
+
var coming = F.coming,
|
991 |
+
iframe = $(coming.tpl.iframe.replace(/\{rnd\}/g, new Date().getTime()))
|
992 |
+
.attr('scrolling', isTouch ? 'auto' : coming.iframe.scrolling)
|
993 |
+
.attr('src', coming.href);
|
994 |
+
|
995 |
+
// This helps IE
|
996 |
+
$(coming.wrap).bind('onReset', function () {
|
997 |
+
try {
|
998 |
+
$(this).find('iframe').hide().attr('src', '//about:blank').end().empty();
|
999 |
+
} catch (e) {}
|
1000 |
+
});
|
1001 |
+
|
1002 |
+
if (coming.iframe.preload) {
|
1003 |
+
F.showLoading();
|
1004 |
+
|
1005 |
+
iframe.one('load', function() {
|
1006 |
+
$(this).data('ready', 1);
|
1007 |
+
|
1008 |
+
// iOS will lose scrolling if we resize
|
1009 |
+
if (!isTouch) {
|
1010 |
+
$(this).bind('load.fb', F.update);
|
1011 |
+
}
|
1012 |
+
|
1013 |
+
// Without this trick:
|
1014 |
+
// - iframe won't scroll on iOS devices
|
1015 |
+
// - IE7 sometimes displays empty iframe
|
1016 |
+
$(this).parents('.fancybox-wrap').width('100%').removeClass('fancybox-tmp').show();
|
1017 |
+
|
1018 |
+
F._afterLoad();
|
1019 |
+
});
|
1020 |
+
}
|
1021 |
+
|
1022 |
+
coming.content = iframe.appendTo( coming.inner );
|
1023 |
+
|
1024 |
+
if (!coming.iframe.preload) {
|
1025 |
+
F._afterLoad();
|
1026 |
+
}
|
1027 |
+
},
|
1028 |
+
|
1029 |
+
_preloadImages: function() {
|
1030 |
+
var group = F.group,
|
1031 |
+
current = F.current,
|
1032 |
+
len = group.length,
|
1033 |
+
cnt = current.preload ? Math.min(current.preload, len - 1) : 0,
|
1034 |
+
item,
|
1035 |
+
i;
|
1036 |
+
|
1037 |
+
for (i = 1; i <= cnt; i += 1) {
|
1038 |
+
item = group[ (current.index + i ) % len ];
|
1039 |
+
|
1040 |
+
if (item.type === 'image' && item.href) {
|
1041 |
+
new Image().src = item.href;
|
1042 |
+
}
|
1043 |
+
}
|
1044 |
+
},
|
1045 |
+
|
1046 |
+
_afterLoad: function () {
|
1047 |
+
var coming = F.coming,
|
1048 |
+
previous = F.current,
|
1049 |
+
placeholder = 'fancybox-placeholder',
|
1050 |
+
current,
|
1051 |
+
content,
|
1052 |
+
type,
|
1053 |
+
scrolling,
|
1054 |
+
href,
|
1055 |
+
embed;
|
1056 |
+
|
1057 |
+
F.hideLoading();
|
1058 |
+
|
1059 |
+
if (!coming || F.isActive === false) {
|
1060 |
+
return;
|
1061 |
+
}
|
1062 |
+
|
1063 |
+
if (false === F.trigger('afterLoad', coming, previous)) {
|
1064 |
+
coming.wrap.stop(true).trigger('onReset').remove();
|
1065 |
+
|
1066 |
+
F.coming = null;
|
1067 |
+
|
1068 |
+
return;
|
1069 |
+
}
|
1070 |
+
|
1071 |
+
if (previous) {
|
1072 |
+
F.trigger('beforeChange', previous);
|
1073 |
+
|
1074 |
+
previous.wrap.stop(true).removeClass('fancybox-opened')
|
1075 |
+
.find('.fancybox-item, .fancybox-nav')
|
1076 |
+
.remove();
|
1077 |
+
}
|
1078 |
+
|
1079 |
+
F.unbindEvents();
|
1080 |
+
|
1081 |
+
current = coming;
|
1082 |
+
content = coming.content;
|
1083 |
+
type = coming.type;
|
1084 |
+
scrolling = coming.scrolling;
|
1085 |
+
|
1086 |
+
$.extend(F, {
|
1087 |
+
wrap : current.wrap,
|
1088 |
+
skin : current.skin,
|
1089 |
+
outer : current.outer,
|
1090 |
+
inner : current.inner,
|
1091 |
+
current : current,
|
1092 |
+
previous : previous
|
1093 |
+
});
|
1094 |
+
|
1095 |
+
href = current.href;
|
1096 |
+
|
1097 |
+
switch (type) {
|
1098 |
+
case 'inline':
|
1099 |
+
case 'ajax':
|
1100 |
+
case 'html':
|
1101 |
+
if (current.selector) {
|
1102 |
+
content = $('<div>').html(content).find(current.selector);
|
1103 |
+
|
1104 |
+
} else if (isQuery(content)) {
|
1105 |
+
if (!content.data(placeholder)) {
|
1106 |
+
content.data(placeholder, $('<div class="' + placeholder + '"></div>').insertAfter( content ).hide() );
|
1107 |
+
}
|
1108 |
+
|
1109 |
+
content = content.show().detach();
|
1110 |
+
|
1111 |
+
current.wrap.bind('onReset', function () {
|
1112 |
+
if ($(this).find(content).length) {
|
1113 |
+
content.hide().replaceAll( content.data(placeholder) ).data(placeholder, false);
|
1114 |
+
}
|
1115 |
+
});
|
1116 |
+
}
|
1117 |
+
break;
|
1118 |
+
|
1119 |
+
case 'image':
|
1120 |
+
content = current.tpl.image.replace('{href}', href);
|
1121 |
+
break;
|
1122 |
+
|
1123 |
+
case 'swf':
|
1124 |
+
content = '<object id="fancybox-swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="movie" value="' + href + '"></param>';
|
1125 |
+
embed = '';
|
1126 |
+
|
1127 |
+
$.each(current.swf, function(name, val) {
|
1128 |
+
content += '<param name="' + name + '" value="' + val + '"></param>';
|
1129 |
+
embed += ' ' + name + '="' + val + '"';
|
1130 |
+
});
|
1131 |
+
|
1132 |
+
content += '<embed src="' + href + '" type="application/x-shockwave-flash" width="100%" height="100%"' + embed + '></embed></object>';
|
1133 |
+
break;
|
1134 |
+
}
|
1135 |
+
|
1136 |
+
if (!(isQuery(content) && content.parent().is(current.inner))) {
|
1137 |
+
current.inner.append( content );
|
1138 |
+
}
|
1139 |
+
|
1140 |
+
// Give a chance for helpers or callbacks to update elements
|
1141 |
+
F.trigger('beforeShow');
|
1142 |
+
|
1143 |
+
// Set scrolling before calculating dimensions
|
1144 |
+
current.inner.css('overflow', scrolling === 'yes' ? 'scroll' : (scrolling === 'no' ? 'hidden' : scrolling));
|
1145 |
+
|
1146 |
+
// Set initial dimensions and start position
|
1147 |
+
F._setDimension();
|
1148 |
+
|
1149 |
+
F.reposition();
|
1150 |
+
|
1151 |
+
F.isOpen = false;
|
1152 |
+
F.coming = null;
|
1153 |
+
|
1154 |
+
F.bindEvents();
|
1155 |
+
|
1156 |
+
if (!F.isOpened) {
|
1157 |
+
$('.fancybox-wrap').not( current.wrap ).stop(true).trigger('onReset').remove();
|
1158 |
+
|
1159 |
+
} else if (previous.prevMethod) {
|
1160 |
+
F.transitions[ previous.prevMethod ]();
|
1161 |
+
}
|
1162 |
+
|
1163 |
+
F.transitions[ F.isOpened ? current.nextMethod : current.openMethod ]();
|
1164 |
+
|
1165 |
+
F._preloadImages();
|
1166 |
+
},
|
1167 |
+
|
1168 |
+
_setDimension: function () {
|
1169 |
+
var viewport = F.getViewport(),
|
1170 |
+
steps = 0,
|
1171 |
+
canShrink = false,
|
1172 |
+
canExpand = false,
|
1173 |
+
wrap = F.wrap,
|
1174 |
+
skin = F.skin,
|
1175 |
+
inner = F.inner,
|
1176 |
+
current = F.current,
|
1177 |
+
width = current.width,
|
1178 |
+
height = current.height,
|
1179 |
+
minWidth = current.minWidth,
|
1180 |
+
minHeight = current.minHeight,
|
1181 |
+
maxWidth = current.maxWidth,
|
1182 |
+
maxHeight = current.maxHeight,
|
1183 |
+
scrolling = current.scrolling,
|
1184 |
+
scrollOut = current.scrollOutside ? current.scrollbarWidth : 0,
|
1185 |
+
margin = current.margin,
|
1186 |
+
wMargin = getScalar(margin[1] + margin[3]),
|
1187 |
+
hMargin = getScalar(margin[0] + margin[2]),
|
1188 |
+
wPadding,
|
1189 |
+
hPadding,
|
1190 |
+
wSpace,
|
1191 |
+
hSpace,
|
1192 |
+
origWidth,
|
1193 |
+
origHeight,
|
1194 |
+
origMaxWidth,
|
1195 |
+
origMaxHeight,
|
1196 |
+
ratio,
|
1197 |
+
width_,
|
1198 |
+
height_,
|
1199 |
+
maxWidth_,
|
1200 |
+
maxHeight_,
|
1201 |
+
iframe,
|
1202 |
+
body;
|
1203 |
+
|
1204 |
+
// Reset dimensions so we could re-check actual size
|
1205 |
+
wrap.add(skin).add(inner).width('auto').height('auto').removeClass('fancybox-tmp');
|
1206 |
+
|
1207 |
+
wPadding = getScalar(skin.outerWidth(true) - skin.width());
|
1208 |
+
hPadding = getScalar(skin.outerHeight(true) - skin.height());
|
1209 |
+
|
1210 |
+
// Any space between content and viewport (margin, padding, border, title)
|
1211 |
+
wSpace = wMargin + wPadding;
|
1212 |
+
hSpace = hMargin + hPadding;
|
1213 |
+
|
1214 |
+
origWidth = isPercentage(width) ? (viewport.w - wSpace) * getScalar(width) / 100 : width;
|
1215 |
+
origHeight = isPercentage(height) ? (viewport.h - hSpace) * getScalar(height) / 100 : height;
|
1216 |
+
|
1217 |
+
if (current.type === 'iframe') {
|
1218 |
+
iframe = current.content;
|
1219 |
+
|
1220 |
+
if (current.autoHeight && iframe.data('ready') === 1) {
|
1221 |
+
try {
|
1222 |
+
if (iframe[0].contentWindow.document.location) {
|
1223 |
+
inner.width( origWidth ).height(9999);
|
1224 |
+
|
1225 |
+
body = iframe.contents().find('body');
|
1226 |
+
|
1227 |
+
if (scrollOut) {
|
1228 |
+
body.css('overflow-x', 'hidden');
|
1229 |
+
}
|
1230 |
+
|
1231 |
+
origHeight = body.outerHeight(true);
|
1232 |
+
}
|
1233 |
+
|
1234 |
+
} catch (e) {}
|
1235 |
+
}
|
1236 |
+
|
1237 |
+
} else if (current.autoWidth || current.autoHeight) {
|
1238 |
+
inner.addClass( 'fancybox-tmp' );
|
1239 |
+
|
1240 |
+
// Set width or height in case we need to calculate only one dimension
|
1241 |
+
if (!current.autoWidth) {
|
1242 |
+
inner.width( origWidth );
|
1243 |
+
}
|
1244 |
+
|
1245 |
+
if (!current.autoHeight) {
|
1246 |
+
inner.height( origHeight );
|
1247 |
+
}
|
1248 |
+
|
1249 |
+
if (current.autoWidth) {
|
1250 |
+
origWidth = inner.width();
|
1251 |
+
}
|
1252 |
+
|
1253 |
+
if (current.autoHeight) {
|
1254 |
+
origHeight = inner.height();
|
1255 |
+
}
|
1256 |
+
|
1257 |
+
inner.removeClass( 'fancybox-tmp' );
|
1258 |
+
}
|
1259 |
+
|
1260 |
+
width = getScalar( origWidth );
|
1261 |
+
height = getScalar( origHeight );
|
1262 |
+
|
1263 |
+
ratio = origWidth / origHeight;
|
1264 |
+
|
1265 |
+
// Calculations for the content
|
1266 |
+
minWidth = getScalar(isPercentage(minWidth) ? getScalar(minWidth, 'w') - wSpace : minWidth);
|
1267 |
+
maxWidth = getScalar(isPercentage(maxWidth) ? getScalar(maxWidth, 'w') - wSpace : maxWidth);
|
1268 |
+
|
1269 |
+
minHeight = getScalar(isPercentage(minHeight) ? getScalar(minHeight, 'h') - hSpace : minHeight);
|
1270 |
+
maxHeight = getScalar(isPercentage(maxHeight) ? getScalar(maxHeight, 'h') - hSpace : maxHeight);
|
1271 |
+
|
1272 |
+
// These will be used to determine if wrap can fit in the viewport
|
1273 |
+
origMaxWidth = maxWidth;
|
1274 |
+
origMaxHeight = maxHeight;
|
1275 |
+
|
1276 |
+
if (current.fitToView) {
|
1277 |
+
maxWidth = Math.min(viewport.w - wSpace, maxWidth);
|
1278 |
+
maxHeight = Math.min(viewport.h - hSpace, maxHeight);
|
1279 |
+
}
|
1280 |
+
|
1281 |
+
maxWidth_ = viewport.w - wMargin;
|
1282 |
+
maxHeight_ = viewport.h - hMargin;
|
1283 |
+
|
1284 |
+
if (current.aspectRatio) {
|
1285 |
+
if (width > maxWidth) {
|
1286 |
+
width = maxWidth;
|
1287 |
+
height = getScalar(width / ratio);
|
1288 |
+
}
|
1289 |
+
|
1290 |
+
if (height > maxHeight) {
|
1291 |
+
height = maxHeight;
|
1292 |
+
width = getScalar(height * ratio);
|
1293 |
+
}
|
1294 |
+
|
1295 |
+
if (width < minWidth) {
|
1296 |
+
width = minWidth;
|
1297 |
+
height = getScalar(width / ratio);
|
1298 |
+
}
|
1299 |
+
|
1300 |
+
if (height < minHeight) {
|
1301 |
+
height = minHeight;
|
1302 |
+
width = getScalar(height * ratio);
|
1303 |
+
}
|
1304 |
+
|
1305 |
+
} else {
|
1306 |
+
width = Math.max(minWidth, Math.min(width, maxWidth));
|
1307 |
+
|
1308 |
+
if (current.autoHeight && current.type !== 'iframe') {
|
1309 |
+
inner.width( width );
|
1310 |
+
|
1311 |
+
height = inner.height();
|
1312 |
+
}
|
1313 |
+
|
1314 |
+
height = Math.max(minHeight, Math.min(height, maxHeight));
|
1315 |
+
}
|
1316 |
+
|
1317 |
+
// Try to fit inside viewport (including the title)
|
1318 |
+
if (current.fitToView) {
|
1319 |
+
inner.width( width ).height( height );
|
1320 |
+
|
1321 |
+
wrap.width( width + wPadding );
|
1322 |
+
|
1323 |
+
// Real wrap dimensions
|
1324 |
+
width_ = wrap.width();
|
1325 |
+
height_ = wrap.height();
|
1326 |
+
|
1327 |
+
if (current.aspectRatio) {
|
1328 |
+
while ((width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight) {
|
1329 |
+
if (steps++ > 19) {
|
1330 |
+
break;
|
1331 |
+
}
|
1332 |
+
|
1333 |
+
height = Math.max(minHeight, Math.min(maxHeight, height - 10));
|
1334 |
+
width = getScalar(height * ratio);
|
1335 |
+
|
1336 |
+
if (width < minWidth) {
|
1337 |
+
width = minWidth;
|
1338 |
+
height = getScalar(width / ratio);
|
1339 |
+
}
|
1340 |
+
|
1341 |
+
if (width > maxWidth) {
|
1342 |
+
width = maxWidth;
|
1343 |
+
height = getScalar(width / ratio);
|
1344 |
+
}
|
1345 |
+
|
1346 |
+
inner.width( width ).height( height );
|
1347 |
+
|
1348 |
+
wrap.width( width + wPadding );
|
1349 |
+
|
1350 |
+
width_ = wrap.width();
|
1351 |
+
height_ = wrap.height();
|
1352 |
+
}
|
1353 |
+
|
1354 |
+
} else {
|
1355 |
+
width = Math.max(minWidth, Math.min(width, width - (width_ - maxWidth_)));
|
1356 |
+
height = Math.max(minHeight, Math.min(height, height - (height_ - maxHeight_)));
|
1357 |
+
}
|
1358 |
+
}
|
1359 |
+
|
1360 |
+
if (scrollOut && scrolling === 'auto' && height < origHeight && (width + wPadding + scrollOut) < maxWidth_) {
|
1361 |
+
width += scrollOut;
|
1362 |
+
}
|
1363 |
+
|
1364 |
+
inner.width( width ).height( height );
|
1365 |
+
|
1366 |
+
wrap.width( width + wPadding );
|
1367 |
+
|
1368 |
+
width_ = wrap.width();
|
1369 |
+
height_ = wrap.height();
|
1370 |
+
|
1371 |
+
canShrink = (width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight;
|
1372 |
+
canExpand = current.aspectRatio ? (width < origMaxWidth && height < origMaxHeight && width < origWidth && height < origHeight) : ((width < origMaxWidth || height < origMaxHeight) && (width < origWidth || height < origHeight));
|
1373 |
+
|
1374 |
+
$.extend(current, {
|
1375 |
+
dim : {
|
1376 |
+
width : getValue( width_ ),
|
1377 |
+
height : getValue( height_ )
|
1378 |
+
},
|
1379 |
+
origWidth : origWidth,
|
1380 |
+
origHeight : origHeight,
|
1381 |
+
canShrink : canShrink,
|
1382 |
+
canExpand : canExpand,
|
1383 |
+
wPadding : wPadding,
|
1384 |
+
hPadding : hPadding,
|
1385 |
+
wrapSpace : height_ - skin.outerHeight(true),
|
1386 |
+
skinSpace : skin.height() - height
|
1387 |
+
});
|
1388 |
+
|
1389 |
+
if (!iframe && current.autoHeight && height > minHeight && height < maxHeight && !canExpand) {
|
1390 |
+
inner.height('auto');
|
1391 |
+
}
|
1392 |
+
},
|
1393 |
+
|
1394 |
+
_getPosition: function (onlyAbsolute) {
|
1395 |
+
var current = F.current,
|
1396 |
+
viewport = F.getViewport(),
|
1397 |
+
margin = current.margin,
|
1398 |
+
width = F.wrap.width() + margin[1] + margin[3],
|
1399 |
+
height = F.wrap.height() + margin[0] + margin[2],
|
1400 |
+
rez = {
|
1401 |
+
position: 'absolute',
|
1402 |
+
top : margin[0],
|
1403 |
+
left : margin[3]
|
1404 |
+
};
|
1405 |
+
|
1406 |
+
if (current.autoCenter && current.fixed && !onlyAbsolute && height <= viewport.h && width <= viewport.w) {
|
1407 |
+
rez.position = 'fixed';
|
1408 |
+
|
1409 |
+
} else if (!current.locked) {
|
1410 |
+
rez.top += viewport.y;
|
1411 |
+
rez.left += viewport.x;
|
1412 |
+
}
|
1413 |
+
|
1414 |
+
rez.top = getValue(Math.max(rez.top, rez.top + ((viewport.h - height) * current.topRatio)));
|
1415 |
+
rez.left = getValue(Math.max(rez.left, rez.left + ((viewport.w - width) * current.leftRatio)));
|
1416 |
+
|
1417 |
+
return rez;
|
1418 |
+
},
|
1419 |
+
|
1420 |
+
_afterZoomIn: function () {
|
1421 |
+
var current = F.current;
|
1422 |
+
|
1423 |
+
if (!current) {
|
1424 |
+
return;
|
1425 |
+
}
|
1426 |
+
|
1427 |
+
F.isOpen = F.isOpened = true;
|
1428 |
+
|
1429 |
+
F.wrap.css('overflow', 'visible').addClass('fancybox-opened');
|
1430 |
+
|
1431 |
+
F.update();
|
1432 |
+
|
1433 |
+
// Assign a click event
|
1434 |
+
if ( current.closeClick || (current.nextClick && F.group.length > 1) ) {
|
1435 |
+
F.inner.css('cursor', 'pointer').bind('click.fb', function(e) {
|
1436 |
+
if (!$(e.target).is('a') && !$(e.target).parent().is('a')) {
|
1437 |
+
e.preventDefault();
|
1438 |
+
|
1439 |
+
F[ current.closeClick ? 'close' : 'next' ]();
|
1440 |
+
}
|
1441 |
+
});
|
1442 |
+
}
|
1443 |
+
|
1444 |
+
// Create a close button
|
1445 |
+
if (current.closeBtn) {
|
1446 |
+
$(current.tpl.closeBtn).appendTo(F.skin).bind('click.fb', function(e) {
|
1447 |
+
e.preventDefault();
|
1448 |
+
|
1449 |
+
F.close();
|
1450 |
+
});
|
1451 |
+
}
|
1452 |
+
|
1453 |
+
// Create navigation arrows
|
1454 |
+
if (current.arrows && F.group.length > 1) {
|
1455 |
+
if (current.loop || current.index > 0) {
|
1456 |
+
$(current.tpl.prev).appendTo(F.outer).bind('click.fb', F.prev);
|
1457 |
+
}
|
1458 |
+
|
1459 |
+
if (current.loop || current.index < F.group.length - 1) {
|
1460 |
+
$(current.tpl.next).appendTo(F.outer).bind('click.fb', F.next);
|
1461 |
+
}
|
1462 |
+
}
|
1463 |
+
|
1464 |
+
F.trigger('afterShow');
|
1465 |
+
|
1466 |
+
// Stop the slideshow if this is the last item
|
1467 |
+
if (!current.loop && current.index === current.group.length - 1) {
|
1468 |
+
F.play( false );
|
1469 |
+
|
1470 |
+
} else if (F.opts.autoPlay && !F.player.isActive) {
|
1471 |
+
F.opts.autoPlay = false;
|
1472 |
+
|
1473 |
+
F.play();
|
1474 |
+
}
|
1475 |
+
},
|
1476 |
+
|
1477 |
+
_afterZoomOut: function ( obj ) {
|
1478 |
+
obj = obj || F.current;
|
1479 |
+
|
1480 |
+
$('.fancybox-wrap').trigger('onReset').remove();
|
1481 |
+
|
1482 |
+
$.extend(F, {
|
1483 |
+
group : {},
|
1484 |
+
opts : {},
|
1485 |
+
router : false,
|
1486 |
+
current : null,
|
1487 |
+
isActive : false,
|
1488 |
+
isOpened : false,
|
1489 |
+
isOpen : false,
|
1490 |
+
isClosing : false,
|
1491 |
+
wrap : null,
|
1492 |
+
skin : null,
|
1493 |
+
outer : null,
|
1494 |
+
inner : null
|
1495 |
+
});
|
1496 |
+
|
1497 |
+
F.trigger('afterClose', obj);
|
1498 |
+
}
|
1499 |
+
});
|
1500 |
+
|
1501 |
+
/*
|
1502 |
+
* Default transitions
|
1503 |
+
*/
|
1504 |
+
|
1505 |
+
F.transitions = {
|
1506 |
+
getOrigPosition: function () {
|
1507 |
+
var current = F.current,
|
1508 |
+
element = current.element,
|
1509 |
+
orig = current.orig,
|
1510 |
+
pos = {},
|
1511 |
+
width = 50,
|
1512 |
+
height = 50,
|
1513 |
+
hPadding = current.hPadding,
|
1514 |
+
wPadding = current.wPadding,
|
1515 |
+
viewport = F.getViewport();
|
1516 |
+
|
1517 |
+
if (!orig && current.isDom && element.is(':visible')) {
|
1518 |
+
orig = element.find('img:first');
|
1519 |
+
|
1520 |
+
if (!orig.length) {
|
1521 |
+
orig = element;
|
1522 |
+
}
|
1523 |
+
}
|
1524 |
+
|
1525 |
+
if (isQuery(orig)) {
|
1526 |
+
pos = orig.offset();
|
1527 |
+
|
1528 |
+
if (orig.is('img')) {
|
1529 |
+
width = orig.outerWidth();
|
1530 |
+
height = orig.outerHeight();
|
1531 |
+
}
|
1532 |
+
|
1533 |
+
} else {
|
1534 |
+
pos.top = viewport.y + (viewport.h - height) * current.topRatio;
|
1535 |
+
pos.left = viewport.x + (viewport.w - width) * current.leftRatio;
|
1536 |
+
}
|
1537 |
+
|
1538 |
+
if (F.wrap.css('position') === 'fixed' || current.locked) {
|
1539 |
+
pos.top -= viewport.y;
|
1540 |
+
pos.left -= viewport.x;
|
1541 |
+
}
|
1542 |
+
|
1543 |
+
pos = {
|
1544 |
+
top : getValue(pos.top - hPadding * current.topRatio),
|
1545 |
+
left : getValue(pos.left - wPadding * current.leftRatio),
|
1546 |
+
width : getValue(width + wPadding),
|
1547 |
+
height : getValue(height + hPadding)
|
1548 |
+
};
|
1549 |
+
|
1550 |
+
return pos;
|
1551 |
+
},
|
1552 |
+
|
1553 |
+
step: function (now, fx) {
|
1554 |
+
var ratio,
|
1555 |
+
padding,
|
1556 |
+
value,
|
1557 |
+
prop = fx.prop,
|
1558 |
+
current = F.current,
|
1559 |
+
wrapSpace = current.wrapSpace,
|
1560 |
+
skinSpace = current.skinSpace;
|
1561 |
+
|
1562 |
+
if (prop === 'width' || prop === 'height') {
|
1563 |
+
ratio = fx.end === fx.start ? 1 : (now - fx.start) / (fx.end - fx.start);
|
1564 |
+
|
1565 |
+
if (F.isClosing) {
|
1566 |
+
ratio = 1 - ratio;
|
1567 |
+
}
|
1568 |
+
|
1569 |
+
padding = prop === 'width' ? current.wPadding : current.hPadding;
|
1570 |
+
value = now - padding;
|
1571 |
+
|
1572 |
+
F.skin[ prop ]( getScalar( prop === 'width' ? value : value - (wrapSpace * ratio) ) );
|
1573 |
+
F.inner[ prop ]( getScalar( prop === 'width' ? value : value - (wrapSpace * ratio) - (skinSpace * ratio) ) );
|
1574 |
+
}
|
1575 |
+
},
|
1576 |
+
|
1577 |
+
zoomIn: function () {
|
1578 |
+
var current = F.current,
|
1579 |
+
startPos = current.pos,
|
1580 |
+
effect = current.openEffect,
|
1581 |
+
elastic = effect === 'elastic',
|
1582 |
+
endPos = $.extend({opacity : 1}, startPos);
|
1583 |
+
|
1584 |
+
// Remove "position" property that breaks older IE
|
1585 |
+
delete endPos.position;
|
1586 |
+
|
1587 |
+
if (elastic) {
|
1588 |
+
startPos = this.getOrigPosition();
|
1589 |
+
|
1590 |
+
if (current.openOpacity) {
|
1591 |
+
startPos.opacity = 0.1;
|
1592 |
+
}
|
1593 |
+
|
1594 |
+
} else if (effect === 'fade') {
|
1595 |
+
startPos.opacity = 0.1;
|
1596 |
+
}
|
1597 |
+
|
1598 |
+
F.wrap.css(startPos).animate(endPos, {
|
1599 |
+
duration : effect === 'none' ? 0 : current.openSpeed,
|
1600 |
+
easing : current.openEasing,
|
1601 |
+
step : elastic ? this.step : null,
|
1602 |
+
complete : F._afterZoomIn
|
1603 |
+
});
|
1604 |
+
},
|
1605 |
+
|
1606 |
+
zoomOut: function () {
|
1607 |
+
var current = F.current,
|
1608 |
+
effect = current.closeEffect,
|
1609 |
+
elastic = effect === 'elastic',
|
1610 |
+
endPos = {opacity : 0.1};
|
1611 |
+
|
1612 |
+
if (elastic) {
|
1613 |
+
endPos = this.getOrigPosition();
|
1614 |
+
|
1615 |
+
if (current.closeOpacity) {
|
1616 |
+
endPos.opacity = 0.1;
|
1617 |
+
}
|
1618 |
+
}
|
1619 |
+
|
1620 |
+
F.wrap.animate(endPos, {
|
1621 |
+
duration : effect === 'none' ? 0 : current.closeSpeed,
|
1622 |
+
easing : current.closeEasing,
|
1623 |
+
step : elastic ? this.step : null,
|
1624 |
+
complete : F._afterZoomOut
|
1625 |
+
});
|
1626 |
+
},
|
1627 |
+
|
1628 |
+
changeIn: function () {
|
1629 |
+
var current = F.current,
|
1630 |
+
effect = current.nextEffect,
|
1631 |
+
startPos = current.pos,
|
1632 |
+
endPos = { opacity : 1 },
|
1633 |
+
direction = F.direction,
|
1634 |
+
distance = 200,
|
1635 |
+
field;
|
1636 |
+
|
1637 |
+
startPos.opacity = 0.1;
|
1638 |
+
|
1639 |
+
if (effect === 'elastic') {
|
1640 |
+
field = direction === 'down' || direction === 'up' ? 'top' : 'left';
|
1641 |
+
|
1642 |
+
if (direction === 'down' || direction === 'right') {
|
1643 |
+
startPos[ field ] = getValue(getScalar(startPos[ field ]) - distance);
|
1644 |
+
endPos[ field ] = '+=' + distance + 'px';
|
1645 |
+
|
1646 |
+
} else {
|
1647 |
+
startPos[ field ] = getValue(getScalar(startPos[ field ]) + distance);
|
1648 |
+
endPos[ field ] = '-=' + distance + 'px';
|
1649 |
+
}
|
1650 |
+
}
|
1651 |
+
|
1652 |
+
// Workaround for http://bugs.jquery.com/ticket/12273
|
1653 |
+
if (effect === 'none') {
|
1654 |
+
F._afterZoomIn();
|
1655 |
+
|
1656 |
+
} else {
|
1657 |
+
F.wrap.css(startPos).animate(endPos, {
|
1658 |
+
duration : current.nextSpeed,
|
1659 |
+
easing : current.nextEasing,
|
1660 |
+
complete : F._afterZoomIn
|
1661 |
+
});
|
1662 |
+
}
|
1663 |
+
},
|
1664 |
+
|
1665 |
+
changeOut: function () {
|
1666 |
+
var previous = F.previous,
|
1667 |
+
effect = previous.prevEffect,
|
1668 |
+
endPos = { opacity : 0.1 },
|
1669 |
+
direction = F.direction,
|
1670 |
+
distance = 200;
|
1671 |
+
|
1672 |
+
if (effect === 'elastic') {
|
1673 |
+
endPos[ direction === 'down' || direction === 'up' ? 'top' : 'left' ] = ( direction === 'up' || direction === 'left' ? '-' : '+' ) + '=' + distance + 'px';
|
1674 |
+
}
|
1675 |
+
|
1676 |
+
previous.wrap.animate(endPos, {
|
1677 |
+
duration : effect === 'none' ? 0 : previous.prevSpeed,
|
1678 |
+
easing : previous.prevEasing,
|
1679 |
+
complete : function () {
|
1680 |
+
$(this).trigger('onReset').remove();
|
1681 |
+
}
|
1682 |
+
});
|
1683 |
+
}
|
1684 |
+
};
|
1685 |
+
|
1686 |
+
/*
|
1687 |
+
* Overlay helper
|
1688 |
+
*/
|
1689 |
+
|
1690 |
+
F.helpers.overlay = {
|
1691 |
+
defaults : {
|
1692 |
+
closeClick : true, // if true, fancyBox will be closed when user clicks on the overlay
|
1693 |
+
speedOut : 200, // duration of fadeOut animation
|
1694 |
+
showEarly : true, // indicates if should be opened immediately or wait until the content is ready
|
1695 |
+
css : {}, // custom CSS properties
|
1696 |
+
locked : !isTouch, // if true, the content will be locked into overlay
|
1697 |
+
fixed : true // if false, the overlay CSS position property will not be set to "fixed"
|
1698 |
+
},
|
1699 |
+
|
1700 |
+
overlay : null, // current handle
|
1701 |
+
fixed : false, // indicates if the overlay has position "fixed"
|
1702 |
+
el : $('html'), // element that contains "the lock"
|
1703 |
+
|
1704 |
+
// Public methods
|
1705 |
+
create : function(opts) {
|
1706 |
+
opts = $.extend({}, this.defaults, opts);
|
1707 |
+
|
1708 |
+
if (this.overlay) {
|
1709 |
+
this.close();
|
1710 |
+
}
|
1711 |
+
|
1712 |
+
this.overlay = $('<div class="fancybox-overlay"></div>').appendTo( F.coming ? F.coming.parent : opts.parent );
|
1713 |
+
this.fixed = false;
|
1714 |
+
|
1715 |
+
if (opts.fixed && F.defaults.fixed) {
|
1716 |
+
this.overlay.addClass('fancybox-overlay-fixed');
|
1717 |
+
|
1718 |
+
this.fixed = true;
|
1719 |
+
}
|
1720 |
+
},
|
1721 |
+
|
1722 |
+
open : function(opts) {
|
1723 |
+
var that = this;
|
1724 |
+
|
1725 |
+
opts = $.extend({}, this.defaults, opts);
|
1726 |
+
|
1727 |
+
if (this.overlay) {
|
1728 |
+
this.overlay.unbind('.overlay').width('auto').height('auto');
|
1729 |
+
|
1730 |
+
} else {
|
1731 |
+
this.create(opts);
|
1732 |
+
}
|
1733 |
+
|
1734 |
+
if (!this.fixed) {
|
1735 |
+
W.bind('resize.overlay', $.proxy( this.update, this) );
|
1736 |
+
|
1737 |
+
this.update();
|
1738 |
+
}
|
1739 |
+
|
1740 |
+
if (opts.closeClick) {
|
1741 |
+
this.overlay.bind('click.overlay', function(e) {
|
1742 |
+
if ($(e.target).hasClass('fancybox-overlay')) {
|
1743 |
+
if (F.isActive) {
|
1744 |
+
F.close();
|
1745 |
+
} else {
|
1746 |
+
that.close();
|
1747 |
+
}
|
1748 |
+
|
1749 |
+
return false;
|
1750 |
+
}
|
1751 |
+
});
|
1752 |
+
}
|
1753 |
+
|
1754 |
+
this.overlay.css( opts.css ).show();
|
1755 |
+
},
|
1756 |
+
|
1757 |
+
close : function() {
|
1758 |
+
var scrollV, scrollH;
|
1759 |
+
|
1760 |
+
W.unbind('resize.overlay');
|
1761 |
+
|
1762 |
+
if (this.el.hasClass('fancybox-lock')) {
|
1763 |
+
$('.fancybox-margin').removeClass('fancybox-margin');
|
1764 |
+
|
1765 |
+
scrollV = W.scrollTop();
|
1766 |
+
scrollH = W.scrollLeft();
|
1767 |
+
|
1768 |
+
this.el.removeClass('fancybox-lock');
|
1769 |
+
|
1770 |
+
W.scrollTop( scrollV ).scrollLeft( scrollH );
|
1771 |
+
}
|
1772 |
+
|
1773 |
+
$('.fancybox-overlay').remove().hide();
|
1774 |
+
|
1775 |
+
$.extend(this, {
|
1776 |
+
overlay : null,
|
1777 |
+
fixed : false
|
1778 |
+
});
|
1779 |
+
},
|
1780 |
+
|
1781 |
+
// Private, callbacks
|
1782 |
+
|
1783 |
+
update : function () {
|
1784 |
+
var width = '100%', offsetWidth;
|
1785 |
+
|
1786 |
+
// Reset width/height so it will not mess
|
1787 |
+
this.overlay.width(width).height('100%');
|
1788 |
+
|
1789 |
+
// jQuery does not return reliable result for IE
|
1790 |
+
if (IE) {
|
1791 |
+
offsetWidth = Math.max(document.documentElement.offsetWidth, document.body.offsetWidth);
|
1792 |
+
|
1793 |
+
if (D.width() > offsetWidth) {
|
1794 |
+
width = D.width();
|
1795 |
+
}
|
1796 |
+
|
1797 |
+
} else if (D.width() > W.width()) {
|
1798 |
+
width = D.width();
|
1799 |
+
}
|
1800 |
+
|
1801 |
+
this.overlay.width(width).height(D.height());
|
1802 |
+
},
|
1803 |
+
|
1804 |
+
// This is where we can manipulate DOM, because later it would cause iframes to reload
|
1805 |
+
onReady : function (opts, obj) {
|
1806 |
+
var overlay = this.overlay;
|
1807 |
+
|
1808 |
+
$('.fancybox-overlay').stop(true, true);
|
1809 |
+
|
1810 |
+
if (!overlay) {
|
1811 |
+
this.create(opts);
|
1812 |
+
}
|
1813 |
+
|
1814 |
+
if (opts.locked && this.fixed && obj.fixed) {
|
1815 |
+
if (!overlay) {
|
1816 |
+
this.margin = D.height() > W.height() ? $('html').css('margin-right').replace("px", "") : false;
|
1817 |
+
}
|
1818 |
+
|
1819 |
+
obj.locked = this.overlay.append( obj.wrap );
|
1820 |
+
obj.fixed = false;
|
1821 |
+
}
|
1822 |
+
|
1823 |
+
if (opts.showEarly === true) {
|
1824 |
+
this.beforeShow.apply(this, arguments);
|
1825 |
+
}
|
1826 |
+
},
|
1827 |
+
|
1828 |
+
beforeShow : function(opts, obj) {
|
1829 |
+
var scrollV, scrollH;
|
1830 |
+
|
1831 |
+
if (obj.locked) {
|
1832 |
+
if (this.margin !== false) {
|
1833 |
+
$('*').filter(function(){
|
1834 |
+
return ($(this).css('position') === 'fixed' && !$(this).hasClass("fancybox-overlay") && !$(this).hasClass("fancybox-wrap") );
|
1835 |
+
}).addClass('fancybox-margin');
|
1836 |
+
|
1837 |
+
this.el.addClass('fancybox-margin');
|
1838 |
+
}
|
1839 |
+
|
1840 |
+
scrollV = W.scrollTop();
|
1841 |
+
scrollH = W.scrollLeft();
|
1842 |
+
|
1843 |
+
this.el.addClass('fancybox-lock');
|
1844 |
+
|
1845 |
+
W.scrollTop( scrollV ).scrollLeft( scrollH );
|
1846 |
+
}
|
1847 |
+
|
1848 |
+
this.open(opts);
|
1849 |
+
},
|
1850 |
+
|
1851 |
+
onUpdate : function() {
|
1852 |
+
if (!this.fixed) {
|
1853 |
+
this.update();
|
1854 |
+
}
|
1855 |
+
},
|
1856 |
+
|
1857 |
+
afterClose: function (opts) {
|
1858 |
+
// Remove overlay if exists and fancyBox is not opening
|
1859 |
+
// (e.g., it is not being open using afterClose callback)
|
1860 |
+
//if (this.overlay && !F.isActive) {
|
1861 |
+
if (this.overlay && !F.coming) {
|
1862 |
+
this.overlay.fadeOut(opts.speedOut, $.proxy( this.close, this ));
|
1863 |
+
}
|
1864 |
+
}
|
1865 |
+
};
|
1866 |
+
|
1867 |
+
/*
|
1868 |
+
* Title helper
|
1869 |
+
*/
|
1870 |
+
|
1871 |
+
F.helpers.title = {
|
1872 |
+
defaults : {
|
1873 |
+
type : 'float', // 'float', 'inside', 'outside' or 'over',
|
1874 |
+
position : 'bottom' // 'top' or 'bottom'
|
1875 |
+
},
|
1876 |
+
|
1877 |
+
beforeShow: function (opts) {
|
1878 |
+
var current = F.current,
|
1879 |
+
text = current.title,
|
1880 |
+
type = opts.type,
|
1881 |
+
title,
|
1882 |
+
target;
|
1883 |
+
|
1884 |
+
if ($.isFunction(text)) {
|
1885 |
+
text = text.call(current.element, current);
|
1886 |
+
}
|
1887 |
+
|
1888 |
+
if (!isString(text) || $.trim(text) === '') {
|
1889 |
+
return;
|
1890 |
+
}
|
1891 |
+
|
1892 |
+
title = $('<div class="fancybox-title fancybox-title-' + type + '-wrap">' + text + '</div>');
|
1893 |
+
|
1894 |
+
switch (type) {
|
1895 |
+
case 'inside':
|
1896 |
+
target = F.skin;
|
1897 |
+
break;
|
1898 |
+
|
1899 |
+
case 'outside':
|
1900 |
+
target = F.wrap;
|
1901 |
+
break;
|
1902 |
+
|
1903 |
+
case 'over':
|
1904 |
+
target = F.inner;
|
1905 |
+
break;
|
1906 |
+
|
1907 |
+
default: // 'float'
|
1908 |
+
target = F.skin;
|
1909 |
+
|
1910 |
+
title.appendTo('body');
|
1911 |
+
|
1912 |
+
if (IE) {
|
1913 |
+
title.width( title.width() );
|
1914 |
+
}
|
1915 |
+
|
1916 |
+
title.wrapInner('<span class="child"></span>');
|
1917 |
+
|
1918 |
+
//Increase bottom margin so this title will also fit into viewport
|
1919 |
+
F.current.margin[2] += Math.abs( getScalar(title.css('margin-bottom')) );
|
1920 |
+
break;
|
1921 |
+
}
|
1922 |
+
|
1923 |
+
title[ (opts.position === 'top' ? 'prependTo' : 'appendTo') ](target);
|
1924 |
+
}
|
1925 |
+
};
|
1926 |
+
|
1927 |
+
// jQuery plugin initialization
|
1928 |
+
$.fn.fancybox = function (options) {
|
1929 |
+
var index,
|
1930 |
+
that = $(this),
|
1931 |
+
selector = this.selector || '',
|
1932 |
+
run = function(e) {
|
1933 |
+
var what = $(this).blur(), idx = index, relType, relVal;
|
1934 |
+
|
1935 |
+
if (!(e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) && !what.is('.fancybox-wrap')) {
|
1936 |
+
relType = options.groupAttr || 'data-fancybox-group';
|
1937 |
+
relVal = what.attr(relType);
|
1938 |
+
|
1939 |
+
if (!relVal) {
|
1940 |
+
relType = 'rel';
|
1941 |
+
relVal = what.get(0)[ relType ];
|
1942 |
+
}
|
1943 |
+
|
1944 |
+
if (relVal && relVal !== '' && relVal !== 'nofollow') {
|
1945 |
+
what = selector.length ? $(selector) : that;
|
1946 |
+
what = what.filter('[' + relType + '="' + relVal + '"]');
|
1947 |
+
idx = what.index(this);
|
1948 |
+
}
|
1949 |
+
|
1950 |
+
options.index = idx;
|
1951 |
+
|
1952 |
+
// Stop an event from bubbling if everything is fine
|
1953 |
+
if (F.open(what, options) !== false) {
|
1954 |
+
e.preventDefault();
|
1955 |
+
}
|
1956 |
+
}
|
1957 |
+
};
|
1958 |
+
|
1959 |
+
options = options || {};
|
1960 |
+
index = options.index || 0;
|
1961 |
+
|
1962 |
+
if (!selector || options.live === false) {
|
1963 |
+
that.unbind('click.fb-start').bind('click.fb-start', run);
|
1964 |
+
|
1965 |
+
} else {
|
1966 |
+
D.undelegate(selector, 'click.fb-start').delegate(selector + ":not('.fancybox-item, .fancybox-nav')", 'click.fb-start', run);
|
1967 |
+
}
|
1968 |
+
|
1969 |
+
this.filter('[data-fancybox-start=1]').trigger('click');
|
1970 |
+
|
1971 |
+
return this;
|
1972 |
+
};
|
1973 |
+
|
1974 |
+
// Tests that need a body at doc ready
|
1975 |
+
D.ready(function() {
|
1976 |
+
var w1, w2;
|
1977 |
+
|
1978 |
+
if ( $.scrollbarWidth === undefined ) {
|
1979 |
+
// http://benalman.com/projects/jquery-misc-plugins/#scrollbarwidth
|
1980 |
+
$.scrollbarWidth = function() {
|
1981 |
+
var parent = $('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo('body'),
|
1982 |
+
child = parent.children(),
|
1983 |
+
width = child.innerWidth() - child.height( 99 ).innerWidth();
|
1984 |
+
|
1985 |
+
parent.remove();
|
1986 |
+
|
1987 |
+
return width;
|
1988 |
+
};
|
1989 |
+
}
|
1990 |
+
|
1991 |
+
if ( $.support.fixedPosition === undefined ) {
|
1992 |
+
$.support.fixedPosition = (function() {
|
1993 |
+
var elem = $('<div style="position:fixed;top:20px;"></div>').appendTo('body'),
|
1994 |
+
fixed = ( elem[0].offsetTop === 20 || elem[0].offsetTop === 15 );
|
1995 |
+
|
1996 |
+
elem.remove();
|
1997 |
+
|
1998 |
+
return fixed;
|
1999 |
+
}());
|
2000 |
+
}
|
2001 |
+
|
2002 |
+
$.extend(F.defaults, {
|
2003 |
+
scrollbarWidth : $.scrollbarWidth(),
|
2004 |
+
fixed : $.support.fixedPosition,
|
2005 |
+
parent : $('body')
|
2006 |
+
});
|
2007 |
+
|
2008 |
+
//Get real width of page scroll-bar
|
2009 |
+
w1 = $(window).width();
|
2010 |
+
|
2011 |
+
H.addClass('fancybox-lock-test');
|
2012 |
+
|
2013 |
+
w2 = $(window).width();
|
2014 |
+
|
2015 |
+
H.removeClass('fancybox-lock-test');
|
2016 |
+
|
2017 |
+
$("<style type='text/css'>.fancybox-margin{margin-right:" + (w2 - w1) + "px;}</style>").appendTo("head");
|
2018 |
+
});
|
2019 |
+
|
2020 |
}(window, document, jQuery));
|
js/skybox/jquery.min.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
/*! jQuery v1.7.2 jquery.com | jquery.org/license */
|
2 |
-
(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cu(a){if(!cj[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ck||(ck=c.createElement("iframe"),ck.frameBorder=ck.width=ck.height=0),b.appendChild(ck);if(!cl||!ck.createElement)cl=(ck.contentWindow||ck.contentDocument).document,cl.write((f.support.boxModel?"<!doctype html>":"")+"<html><body>"),cl.close();d=cl.createElement(a),cl.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ck)}cj[a]=e}return cj[a]}function ct(a,b){var c={};f.each(cp.concat.apply([],cp.slice(0,b)),function(){c[this]=a});return c}function cs(){cq=b}function cr(){setTimeout(cs,0);return cq=f.now()}function ci(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ch(){try{return new a.XMLHttpRequest}catch(b){}}function cb(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g<i;g++){if(g===1)for(h in a.converters)typeof h=="string"&&(e[h.toLowerCase()]=a.converters[h]);l=k,k=d[g];if(k==="*")k=l;else if(l!=="*"&&l!==k){m=l+" "+k,n=e[m]||e["* "+k];if(!n){p=b;for(o in e){j=o.split(" ");if(j[0]===l||j[0]==="*"){p=e[j[1]+" "+k];if(p){o=e[o],o===!0?n=p:p===!0&&(n=o);break}}}}!n&&!p&&f.error("No conversion from "+m.replace(" "," to ")),n!==!0&&(c=n?n(c):p(o(c)))}}return c}function ca(a,c,d){var e=a.contents,f=a.dataTypes,g=a.responseFields,h,i,j,k;for(i in g)i in d&&(c[g[i]]=d[i]);while(f[0]==="*")f.shift(),h===b&&(h=a.mimeType||c.getResponseHeader("content-type"));if(h)for(i in e)if(e[i]&&e[i].test(h)){f.unshift(i);break}if(f[0]in d)j=f[0];else{for(i in d){if(!f[0]||a.converters[i+" "+f[0]]){j=i;break}k||(k=i)}j=j||k}if(j){j!==f[0]&&f.unshift(j);return d[j]}}function b_(a,b,c,d){if(f.isArray(b))f.each(b,function(b,e){c||bD.test(a)?d(a,e):b_(a+"["+(typeof e=="object"?b:"")+"]",e,c,d)});else if(!c&&f.type(b)==="object")for(var e in b)b_(a+"["+e+"]",b[e],c,d);else d(a,b)}function b$(a,c){var d,e,g=f.ajaxSettings.flatOptions||{};for(d in c)c[d]!==b&&((g[d]?a:e||(e={}))[d]=c[d]);e&&f.extend(!0,a,e)}function bZ(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h=a[f],i=0,j=h?h.length:0,k=a===bS,l;for(;i<j&&(k||!l);i++)l=h[i](c,d,e),typeof l=="string"&&(!k||g[l]?l=b:(c.dataTypes.unshift(l),l=bZ(a,c,d,e,l,g)));(k||!l)&&!g["*"]&&(l=bZ(a,c,d,e,"*",g));return l}function bY(a){return function(b,c){typeof b!="string"&&(c=b,b="*");if(f.isFunction(c)){var d=b.toLowerCase().split(bO),e=0,g=d.length,h,i,j;for(;e<g;e++)h=d[e],j=/^\+/.test(h),j&&(h=h.substr(1)||"*"),i=a[h]=a[h]||[],i[j?"unshift":"push"](c)}}}function bB(a,b,c){var d=b==="width"?a.offsetWidth:a.offsetHeight,e=b==="width"?1:0,g=4;if(d>0){if(c!=="border")for(;e<g;e+=2)c||(d-=parseFloat(f.css(a,"padding"+bx[e]))||0),c==="margin"?d+=parseFloat(f.css(a,c+bx[e]))||0:d-=parseFloat(f.css(a,"border"+bx[e]+"Width"))||0;return d+"px"}d=by(a,b);if(d<0||d==null)d=a.style[b];if(bt.test(d))return d;d=parseFloat(d)||0;if(c)for(;e<g;e+=2)d+=parseFloat(f.css(a,"padding"+bx[e]))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+bx[e]+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+bx[e]))||0);return d+"px"}function bo(a){var b=c.createElement("div");bh.appendChild(b),b.innerHTML=a.outerHTML;return b.firstChild}function bn(a){var b=(a.nodeName||"").toLowerCase();b==="input"?bm(a):b!=="script"&&typeof a.getElementsByTagName!="undefined"&&f.grep(a.getElementsByTagName("input"),bm)}function bm(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bl(a){return typeof a.getElementsByTagName!="undefined"?a.getElementsByTagName("*"):typeof a.querySelectorAll!="undefined"?a.querySelectorAll("*"):[]}function bk(a,b){var c;b.nodeType===1&&(b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase(),c==="object"?b.outerHTML=a.outerHTML:c!=="input"||a.type!=="checkbox"&&a.type!=="radio"?c==="option"?b.selected=a.defaultSelected:c==="input"||c==="textarea"?b.defaultValue=a.defaultValue:c==="script"&&b.text!==a.text&&(b.text=a.text):(a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value)),b.removeAttribute(f.expando),b.removeAttribute("_submit_attached"),b.removeAttribute("_change_attached"))}function bj(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c,d,e,g=f._data(a),h=f._data(b,g),i=g.events;if(i){delete h.handle,h.events={};for(c in i)for(d=0,e=i[c].length;d<e;d++)f.event.add(b,c,i[c][d])}h.data&&(h.data=f.extend({},h.data))}}function bi(a,b){return f.nodeName(a,"table")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function U(a){var b=V.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}function T(a,b,c){b=b||0;if(f.isFunction(b))return f.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return f.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=f.grep(a,function(a){return a.nodeType===1});if(O.test(b))return f.filter(b,d,!c);b=f.filter(b,d)}return f.grep(a,function(a,d){return f.inArray(a,b)>=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?+d:j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c<d;c++)b[a[c]]=!0;return b}var c=a.document,d=a.navigator,e=a.location,f=function(){function J(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(J,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.2",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j<k;j++)if((a=arguments[j])!=null)for(c in a){d=i[c],f=a[c];if(i===f)continue;l&&f&&(e.isPlainObject(f)||(g=e.isArray(f)))?(g?(g=!1,h=d&&e.isArray(d)?d:[]):h=d&&e.isPlainObject(d)?d:{},i[c]=e.extend(l,h,f)):f!==b&&(i[c]=f)}return i},e.extend({noConflict:function(b){a.$===e&&(a.$=g),b&&a.jQuery===e&&(a.jQuery=f);return e},isReady:!1,readyWait:1,holdReady:function(a){a?e.readyWait++:e.ready(!0)},ready:function(a){if(a===!0&&!--e.readyWait||a!==!0&&!e.isReady){if(!c.body)return setTimeout(e.ready,1);e.isReady=!0;if(a!==!0&&--e.readyWait>0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a!=null&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){if(typeof c!="string"||!c)return null;var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g<h;)if(c.apply(a[g++],d)===!1)break}else if(i){for(f in a)if(c.call(a[f],f,a[f])===!1)break}else for(;g<h;)if(c.call(a[g],g,a[g++])===!1)break;return a},trim:G?function(a){return a==null?"":G.call(a)}:function(a){return a==null?"":(a+"").replace(k,"").replace(l,"")},makeArray:function(a,b){var c=b||[];if(a!=null){var d=e.type(a);a.length==null||d==="string"||d==="function"||d==="regexp"||e.isWindow(a)?E.call(c,a):e.merge(c,a)}return c},inArray:function(a,b,c){var d;if(b){if(H)return H.call(b,a,c);d=b.length,c=c?c<0?Math.max(0,d+c):c:0;for(;c<d;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,c){var d=a.length,e=0;if(typeof c.length=="number")for(var f=c.length;e<f;e++)a[d++]=c[e];else while(c[e]!==b)a[d++]=c[e++];a.length=d;return a},grep:function(a,b,c){var d=[],e;c=!!c;for(var f=0,g=a.length;f<g;f++)e=!!b(a[f],f),c!==e&&d.push(a[f]);return d},map:function(a,c,d){var f,g,h=[],i=0,j=a.length,k=a instanceof e||j!==b&&typeof j=="number"&&(j>0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i<j;i++)f=c(a[i],i,d),f!=null&&(h[h.length]=f);else for(g in a)f=c(a[g],g,d),f!=null&&(h[h.length]=f);return h.concat.apply([],h)},guid:1,proxy:function(a,c){if(typeof c=="string"){var d=a[c];c=a,a=d}if(!e.isFunction(a))return b;var f=F.call(arguments,2),g=function(){return a.apply(c,f.concat(F.call(arguments)))};g.guid=a.guid=a.guid||g.guid||e.guid++;return g},access:function(a,c,d,f,g,h,i){var j,k=d==null,l=0,m=a.length;if(d&&typeof d=="object"){for(l in d)e.access(a,c,l,d[l],1,h,f);g=1}else if(f!==b){j=i===b&&e.isFunction(f),k&&(j?(j=c,c=function(a,b,c){return j.call(e(a),c)}):(c.call(a,f),c=null));if(c)for(;l<m;l++)c(a[l],d,j?f.call(a[l],l,c(a[l],d)):f,i);g=1}return g?a:k?c.call(a):m?c(a[0],d):h},now:function(){return(new Date).getTime()},uaMatch:function(a){a=a.toLowerCase();var b=r.exec(a)||s.exec(a)||t.exec(a)||a.indexOf("compatible")<0&&u.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},sub:function(){function a(b,c){return new a.fn.init(b,c)}e.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function(d,f){f&&f instanceof e&&!(f instanceof a)&&(f=a(f));return e.fn.init.call(this,d,f,b)},a.fn.init.prototype=a.fn;var b=a(c);return a},browser:{}}),e.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){I["[object "+b+"]"]=b.toLowerCase()}),z=e.uaMatch(y),z.browser&&(e.browser[z.browser]=!0,e.browser.version=z.version),e.browser.webkit&&(e.browser.safari=!0),j.test(" ")&&(k=/^[\s\xA0]+/,l=/[\s\xA0]+$/),h=e(c),c.addEventListener?B=function(){c.removeEventListener("DOMContentLoaded",B,!1),e.ready()}:c.attachEvent&&(B=function(){c.readyState==="complete"&&(c.detachEvent("onreadystatechange",B),e.ready())});return e}(),g={};f.Callbacks=function(a){a=a?g[a]||h(a):{};var c=[],d=[],e,i,j,k,l,m,n=function(b){var d,e,g,h,i;for(d=0,e=b.length;d<e;d++)g=b[d],h=f.type(g),h==="array"?n(g):h==="function"&&(!a.unique||!p.has(g))&&c.push(g)},o=function(b,f){f=f||[],e=!a.memory||[b,f],i=!0,j=!0,m=k||0,k=0,l=c.length;for(;c&&m<l;m++)if(c[m].apply(b,f)===!1&&a.stopOnFalse){e=!0;break}j=!1,c&&(a.once?e===!0?p.disable():c=[]:d&&d.length&&(e=d.shift(),p.fireWith(e[0],e[1])))},p={add:function(){if(c){var a=c.length;n(arguments),j?l=c.length:e&&e!==!0&&(k=a,o(e[0],e[1]))}return this},remove:function(){if(c){var b=arguments,d=0,e=b.length;for(;d<e;d++)for(var f=0;f<c.length;f++)if(b[d]===c[f]){j&&f<=l&&(l--,f<=m&&m--),c.splice(f--,1);if(a.unique)break}}return this},has:function(a){if(c){var b=0,d=c.length;for(;b<d;b++)if(a===c[b])return!0}return!1},empty:function(){c=[];return this},disable:function(){c=d=e=b;return this},disabled:function(){return!c},lock:function(){d=b,(!e||e===!0)&&p.disable();return this},locked:function(){return!d},fireWith:function(b,c){d&&(j?a.once||d.push([b,c]):(!a.once||!e)&&o(b,c));return this},fire:function(){p.fireWith(this,arguments);return this},fired:function(){return!!i}};return p};var i=[].slice;f.extend({Deferred:function(a){var b=f.Callbacks("once memory"),c=f.Callbacks("once memory"),d=f.Callbacks("memory"),e="pending",g={resolve:b,reject:c,notify:d},h={done:b.add,fail:c.add,progress:d.add,state:function(){return e},isResolved:b.fired,isRejected:c.fired,then:function(a,b,c){i.done(a).fail(b).progress(c);return this},always:function(){i.done.apply(i,arguments).fail.apply(i,arguments);return this},pipe:function(a,b,c){return f.Deferred(function(d){f.each({done:[a,"resolve"],fail:[b,"reject"],progress:[c,"notify"]},function(a,b){var c=b[0],e=b[1],g;f.isFunction(c)?i[a](function(){g=c.apply(this,arguments),g&&f.isFunction(g.promise)?g.promise().then(d.resolve,d.reject,d.notify):d[e+"With"](this===i?d:this,[g])}):i[a](d[e])})}).promise()},promise:function(a){if(a==null)a=h;else for(var b in h)a[b]=h[b];return a}},i=h.promise({}),j;for(j in g)i[j]=g[j].fire,i[j+"With"]=g[j].fireWith;i.done(function(){e="resolved"},c.disable,d.lock).fail(function(){e="rejected"},b.disable,d.lock),a&&a.call(i,i);return i},when:function(a){function m(a){return function(b){e[a]=arguments.length>1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c<d;c++)b[c]&&b[c].promise&&f.isFunction(b[c].promise)?b[c].promise().then(l(c),j.reject,m(c)):--g;g||j.resolveWith(j,b)}else j!==a&&j.resolveWith(j,d?[a]:[]);return k}}),f.support=function(){var b,d,e,g,h,i,j,k,l,m,n,o,p=c.createElement("div"),q=c.documentElement;p.setAttribute("className","t"),p.innerHTML=" <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>",d=p.getElementsByTagName("*"),e=p.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=p.getElementsByTagName("input")[0],b={leadingWhitespace:p.firstChild.nodeType===3,tbody:!p.getElementsByTagName("tbody").length,htmlSerialize:!!p.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:p.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav></:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,pixelMargin:!0},f.boxModel=b.boxModel=c.compatMode==="CSS1Compat",i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete p.test}catch(r){b.deleteExpando=!1}!p.addEventListener&&p.attachEvent&&p.fireEvent&&(p.attachEvent("onclick",function(){b.noCloneEvent=!1}),p.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),i.setAttribute("name","t"),p.appendChild(i),j=c.createDocumentFragment(),j.appendChild(p.lastChild),b.checkClone=j.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,j.removeChild(i),j.appendChild(p);if(p.attachEvent)for(n in{submit:1,change:1,focusin:1})m="on"+n,o=m in p,o||(p.setAttribute(m,"return;"),o=typeof p[m]=="function"),b[n+"Bubbles"]=o;j.removeChild(p),j=g=h=p=i=null,f(function(){var d,e,g,h,i,j,l,m,n,q,r,s,t,u=c.getElementsByTagName("body")[0];!u||(m=1,t="padding:0;margin:0;border:",r="position:absolute;top:0;left:0;width:1px;height:1px;",s=t+"0;visibility:hidden;",n="style='"+r+t+"5px solid #000;",q="<div "+n+"display:block;'><div style='"+t+"0;display:block;overflow:hidden;'></div></div>"+"<table "+n+"' cellpadding='0' cellspacing='0'>"+"<tr><td></td></tr></table>",d=c.createElement("div"),d.style.cssText=s+"width:0;height:0;position:static;top:0;margin-top:"+m+"px",u.insertBefore(d,u.firstChild),p=c.createElement("div"),d.appendChild(p),p.innerHTML="<table><tr><td style='"+t+"0;display:none'></td><td>t</td></tr></table>",k=p.getElementsByTagName("td"),o=k[0].offsetHeight===0,k[0].style.display="",k[1].style.display="none",b.reliableHiddenOffsets=o&&k[0].offsetHeight===0,a.getComputedStyle&&(p.innerHTML="",l=c.createElement("div"),l.style.width="0",l.style.marginRight="0",p.style.width="2px",p.appendChild(l),b.reliableMarginRight=(parseInt((a.getComputedStyle(l,null)||{marginRight:0}).marginRight,10)||0)===0),typeof p.style.zoom!="undefined"&&(p.innerHTML="",p.style.width=p.style.padding="1px",p.style.border=0,p.style.overflow="hidden",p.style.display="inline",p.style.zoom=1,b.inlineBlockNeedsLayout=p.offsetWidth===3,p.style.display="block",p.style.overflow="visible",p.innerHTML="<div style='width:5px;'></div>",b.shrinkWrapBlocks=p.offsetWidth!==3),p.style.cssText=r+s,p.innerHTML=q,e=p.firstChild,g=e.firstChild,i=e.nextSibling.firstChild.firstChild,j={doesNotAddBorder:g.offsetTop!==5,doesAddBorderForTableAndCells:i.offsetTop===5},g.style.position="fixed",g.style.top="20px",j.fixedPosition=g.offsetTop===20||g.offsetTop===15,g.style.position=g.style.top="",e.style.overflow="hidden",e.style.position="relative",j.subtractsBorderForOverflowNotVisible=g.offsetTop===-5,j.doesNotIncludeMarginInBodyOffset=u.offsetTop!==m,a.getComputedStyle&&(p.style.marginTop="1%",b.pixelMargin=(a.getComputedStyle(p,null)||{marginTop:0}).marginTop!=="1%"),typeof d.style.zoom!="undefined"&&(d.style.zoom=1),u.removeChild(d),l=p=d=null,f.extend(b,j))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e<g;e++)delete d[b[e]];if(!(c?m:f.isEmptyObject)(d))return}}if(!c){delete j[k].data;if(!m(j[k]))return}f.support.deleteExpando||!j.setInterval?delete j[k]:j[k]=null,i&&(f.support.deleteExpando?delete a[h]:a.removeAttribute?a.removeAttribute(h):a[h]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d,e,g,h,i,j=this[0],k=0,m=null;if(a===b){if(this.length){m=f.data(j);if(j.nodeType===1&&!f._data(j,"parsedAttrs")){g=j.attributes;for(i=g.length;k<i;k++)h=g[k].name,h.indexOf("data-")===0&&(h=f.camelCase(h.substring(5)),l(j,h,m[h]));f._data(j,"parsedAttrs",!0)}}return m}if(typeof a=="object")return this.each(function(){f.data(this,a)});d=a.split(".",2),d[1]=d[1]?"."+d[1]:"",e=d[1]+"!";return f.access(this,function(c){if(c===b){m=this.triggerHandler("getData"+e,[d[0]]),m===b&&j&&(m=f.data(j,a),m=l(j,a,m));return m===b&&d[1]?this.data(d[0]):m}d[1]=c,this.each(function(){var b=f(this);b.triggerHandler("setData"+e,d),f.data(this,a,c),b.triggerHandler("changeData"+e,d)})},null,c,arguments.length>1,null,!1)},removeData:function(a){return this.each(function(){f.removeData(this,a)})}}),f.extend({_mark:function(a,b){a&&(b=(b||"fx")+"mark",f._data(a,b,(f._data(a,b)||0)+1))},_unmark:function(a,b,c){a!==!0&&(c=b,b=a,a=!1);if(b){c=c||"fx";var d=c+"mark",e=a?0:(f._data(b,d)||1)-1;e?f._data(b,d,e):(f.removeData(b,d,!0),n(b,c,"mark"))}},queue:function(a,b,c){var d;if(a){b=(b||"fx")+"queue",d=f._data(a,b),c&&(!d||f.isArray(c)?d=f._data(a,b,f.makeArray(c)):d.push(c));return d||[]}},dequeue:function(a,b){b=b||"fx";var c=f.queue(a,b),d=c.shift(),e={};d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),f._data(a,b+".run",e),d.call(a,function(){f.dequeue(a,b)},e)),c.length||(f.removeData(a,b+"queue "+b+".run",!0),n(a,b,"queue"))}}),f.fn.extend({queue:function(a,c){var d=2;typeof a!="string"&&(c=a,a="fx",d--);if(arguments.length<d)return f.queue(this[0],a);return c===b?this:this.each(function(){var b=f.queue(this,a,c);a==="fx"&&b[0]!=="inprogress"&&f.dequeue(this,a)})},dequeue:function(a){return this.each(function(){f.dequeue(this,a)})},delay:function(a,b){a=f.fx?f.fx.speeds[a]||a:a,b=b||"fx";return this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,c){function m(){--h||d.resolveWith(e,[e])}typeof a!="string"&&(c=a,a=b),a=a||"fx";var d=f.Deferred(),e=this,g=e.length,h=1,i=a+"defer",j=a+"queue",k=a+"mark",l;while(g--)if(l=f.data(e[g],i,b,!0)||(f.data(e[g],j,b,!0)||f.data(e[g],k,b,!0))&&f.data(e[g],i,f.Callbacks("once memory"),!0))h++,l.add(m);m();return d.promise(c)}});var o=/[\n\t\r]/g,p=/\s+/,q=/\r/g,r=/^(?:button|input)$/i,s=/^(?:button|input|object|select|textarea)$/i,t=/^a(?:rea)?$/i,u=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,v=f.support.getSetAttribute,w,x,y;f.fn.extend({attr:function(a,b){return f.access(this,f.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,f.prop,a,b,arguments.length>1)},removeProp:function(a){a=f.propFix[a]||a;return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,g,h,i;if(f.isFunction(a))return this.each(function(b){f(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(p);for(c=0,d=this.length;c<d;c++){e=this[c];if(e.nodeType===1)if(!e.className&&b.length===1)e.className=a;else{g=" "+e.className+" ";for(h=0,i=b.length;h<i;h++)~g.indexOf(" "+b[h]+" ")||(g+=b[h]+" ");e.className=f.trim(g)}}}return this},removeClass:function(a){var c,d,e,g,h,i,j;if(f.isFunction(a))return this.each(function(b){f(this).removeClass(a.call(this,b,this.className))});if(a&&typeof a=="string"||a===b){c=(a||"").split(p);for(d=0,e=this.length;d<e;d++){g=this[d];if(g.nodeType===1&&g.className)if(a){h=(" "+g.className+" ").replace(o," ");for(i=0,j=c.length;i<j;i++)h=h.replace(" "+c[i]+" "," ");g.className=f.trim(h)}else g.className=""}}return this},toggleClass:function(a,b){var c=typeof a,d=typeof b=="boolean";if(f.isFunction(a))return this.each(function(c){f(this).toggleClass(a.call(this,c,this.className,b),b)});return this.each(function(){if(c==="string"){var e,g=0,h=f(this),i=b,j=a.split(p);while(e=j[g++])i=d?i:!h.hasClass(e),h[i?"addClass":"removeClass"](e)}else if(c==="undefined"||c==="boolean")this.className&&f._data(this,"__className__",this.className),this.className=this.className||a===!1?"":f._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ",c=0,d=this.length;for(;c<d;c++)if(this[c].nodeType===1&&(" "+this[c].className+" ").replace(o," ").indexOf(b)>-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.type]||f.valHooks[this.nodeName.toLowerCase()];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.type]||f.valHooks[g.nodeName.toLowerCase()];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c<d;c++){e=i[c];if(e.selected&&(f.support.optDisabled?!e.disabled:e.getAttribute("disabled")===null)&&(!e.parentNode.disabled||!f.nodeName(e.parentNode,"optgroup"))){b=f(e).val();if(j)return b;h.push(b)}}if(j&&!h.length&&i.length)return f(i[g]).val();return h},set:function(a,b){var c=f.makeArray(b);f(a).find("option").each(function(){this.selected=f.inArray(f(this).val(),c)>=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h,i=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;i<g;i++)e=d[i],e&&(c=f.propFix[e]||e,h=u.test(e),h||f.attr(a,e,""),a.removeAttribute(v?e:c),h&&c in a&&(a[c]=!1))}},attrHooks:{type:{set:function(a,b){if(r.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},value:{get:function(a,b){if(w&&f.nodeName(a,"button"))return w.get(a,b);return b in a?a.value:null},set:function(a,b,c){if(w&&f.nodeName(a,"button"))return w.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e,g,h,i=a.nodeType;if(!!a&&i!==3&&i!==8&&i!==2){h=i!==1||!f.isXMLDoc(a),h&&(c=f.propFix[c]||c,g=f.propHooks[c]);return d!==b?g&&"set"in g&&(e=g.set(a,d,c))!==b?e:a[c]=d:g&&"get"in g&&(e=g.get(a,c))!==null?e:a[c]}},propHooks:{tabIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):s.test(a.nodeName)||t.test(a.nodeName)&&a.href?0:b}}}}),f.attrHooks.tabindex=f.propHooks.tabIndex,x={get:function(a,c){var d,e=f.prop(a,c);return e===!0||typeof e!="boolean"&&(d=a.getAttributeNode(c))&&d.nodeValue!==!1?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase()));return c}},v||(y={name:!0,id:!0,coords:!0},w=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&(y[c]?d.nodeValue!=="":d.specified)?d.nodeValue:b},set:function(a,b,d){var e=a.getAttributeNode(d);e||(e=c.createAttribute(d),a.setAttributeNode(e));return e.nodeValue=b+""}},f.attrHooks.tabindex.set=w.set,f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})}),f.attrHooks.contenteditable={get:w.get,set:function(a,b,c){b===""&&(b="false"),w.set(a,b,c)}}),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex);return null}})),f.support.enctype||(f.propFix.enctype="encoding"),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/(?:^|\s)hover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function(
|
3 |
-
a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.ho
|
|
|
|
|
|