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.1 |
Comparing to | |
See all releases |
Code changes from version 1.2.0 to 1.2.1
- app/code/community/Skybox/Catalog/Block/Bundle/Price.php +1 -0
- app/code/community/Skybox/Catalog/Block/Product/List.php +456 -0
- app/code/community/Skybox/Catalog/Block/Product/Price.php +74 -19
- app/code/community/Skybox/Catalog/Model/Api/Product.php +436 -45
- app/code/community/Skybox/Catalog/Model/Observer.php +31 -3
- app/code/community/Skybox/Catalog/etc/config.xml +7 -0
- app/code/community/Skybox/Checkout/Block/Cart/Totals.php +147 -0
- app/code/community/Skybox/Checkout/Block/Checkout/Cart.php +45 -0
- app/code/community/Skybox/Checkout/Block/Checkout/Cart/Sidebar.php +16 -0
- app/code/community/Skybox/Checkout/Block/Checkout/Links.php +26 -0
- app/code/community/Skybox/Checkout/Block/Checkout/Onepage/Link.php +29 -0
- app/code/community/Skybox/Checkout/Block/Sales/Order/Total.php +24 -12
- app/code/community/Skybox/Checkout/Helper/Data.php +55 -10
- app/code/community/Skybox/Checkout/Helper/Url.php +59 -0
- app/code/community/Skybox/Checkout/Model/Api/Checkout.php +48 -4
- app/code/community/Skybox/Checkout/Model/Carrier.php +37 -0
- app/code/community/Skybox/Checkout/Model/Cart.php +71 -3
- app/code/community/Skybox/Checkout/Model/Observer.php +23 -3
- app/code/community/Skybox/Checkout/Model/Pay.php +12 -0
- app/code/community/Skybox/Checkout/Model/Quote/Address/Total/Rmt.php +6 -2
- app/code/community/Skybox/Checkout/Model/Quote/Total.php +20 -3
- app/code/community/Skybox/Checkout/controllers/CalculateController.php +1 -1
- app/code/community/Skybox/Checkout/controllers/InternationalController.php +4 -1
- app/code/community/Skybox/Checkout/controllers/ProcessController.php +37 -16
- app/code/community/Skybox/Checkout/etc/config.xml +56 -0
- app/code/community/Skybox/Checkout/etc/system.xml +127 -0
- app/code/community/Skybox/Core/Model/Api/Restful.php +26 -0
- app/code/community/Skybox/Core/Model/Config.php +1 -0
- app/code/community/Skybox/Core/Model/Standard.php +19 -1
- app/code/community/Skybox/Core/sql/skyboxcore_setup/mysql4-install-0.1.0.php +38 -25
- app/code/community/Skybox/International/Helper/Data.php +7 -1
- app/code/community/Skybox/International/etc/config.xml +6 -3
- app/code/community/Skybox/International/etc/system.xml +21 -1
- app/code/community/Skybox/Services/Model/Api.php +159 -8
- app/code/community/Skybox/Services/etc/api.xml +5 -0
- app/code/community/Skybox/Services/etc/wsdl.xml +37 -0
- app/code/community/Skybox/Services/etc/wsi.xml +1 -0
- app/design/frontend/base/default/layout/skyboxcheckout.xml +32 -10
- app/design/frontend/base/default/template/skybox/checkout/cart.phtml +206 -23
- app/design/frontend/base/default/template/skybox/checkout/onepage/link.phtml +41 -0
- app/design/frontend/base/default/template/skybox/checkout/skyboxcheckout.phtml +1 -0
- app/design/frontend/base/default/template/skybox/product/price.phtml +1 -0
- app/etc/modules/Skybox_All.xml +1 -0
- package.xml +4 -4
- skin/frontend/base/default/js/skybox/catalog.product.configurable.js +13 -5
app/code/community/Skybox/Catalog/Block/Bundle/Price.php
CHANGED
@@ -114,6 +114,7 @@ class Skybox_Catalog_Block_Bundle_Price extends Mage_Bundle_Block_Catalog_Produc
|
|
114 |
*/
|
115 |
protected function calculatePrice($product, $bundleType = 'bundle')
|
116 |
{
|
|
|
117 |
$stockItem = $product->getStockItem();
|
118 |
if (!$stockItem->getIsInStock()) {
|
119 |
return ''; // Out of Stock
|
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
|
app/code/community/Skybox/Catalog/Block/Product/List.php
ADDED
@@ -0,0 +1,456 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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@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 Mage
|
22 |
+
* @package Mage_Catalog
|
23 |
+
* @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Product list
|
30 |
+
*
|
31 |
+
* @category Mage
|
32 |
+
* @package Mage_Catalog
|
33 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
34 |
+
*/
|
35 |
+
class Skybox_Catalog_Block_Product_List extends Mage_Catalog_Block_Product_List
|
36 |
+
{
|
37 |
+
/**
|
38 |
+
* Default toolbar block name
|
39 |
+
*
|
40 |
+
* @var string
|
41 |
+
*/
|
42 |
+
protected $_defaultToolbarBlock = 'catalog/product_list_toolbar';
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Product Collection
|
46 |
+
*
|
47 |
+
* @var Mage_Eav_Model_Entity_Collection_Abstract
|
48 |
+
*/
|
49 |
+
protected $_productCollection;
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Retrieve loaded category collection
|
53 |
+
*
|
54 |
+
* @return Mage_Eav_Model_Entity_Collection_Abstract
|
55 |
+
*/
|
56 |
+
protected function _getProductCollection()
|
57 |
+
{
|
58 |
+
if (is_null($this->_productCollection)) {
|
59 |
+
$layer = $this->getLayer();
|
60 |
+
/* @var $layer Mage_Catalog_Model_Layer */
|
61 |
+
if ($this->getShowRootCategory()) {
|
62 |
+
$this->setCategoryId(Mage::app()->getStore()->getRootCategoryId());
|
63 |
+
}
|
64 |
+
|
65 |
+
// if this is a product view page
|
66 |
+
if (Mage::registry('product')) {
|
67 |
+
// get collection of categories this product is associated with
|
68 |
+
$categories = Mage::registry('product')->getCategoryCollection()
|
69 |
+
->setPage(1, 1)
|
70 |
+
->load();
|
71 |
+
// if the product is associated with any category
|
72 |
+
if ($categories->count()) {
|
73 |
+
// show products from this category
|
74 |
+
$this->setCategoryId(current($categories->getIterator()));
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
$origCategory = null;
|
79 |
+
if ($this->getCategoryId()) {
|
80 |
+
$category = Mage::getModel('catalog/category')->load($this->getCategoryId());
|
81 |
+
if ($category->getId()) {
|
82 |
+
$origCategory = $layer->getCurrentCategory();
|
83 |
+
$layer->setCurrentCategory($category);
|
84 |
+
$this->addModelTags($category);
|
85 |
+
}
|
86 |
+
}
|
87 |
+
$this->_productCollection = $layer->getProductCollection();
|
88 |
+
|
89 |
+
$this->prepareSortableFieldsByCategory($layer->getCurrentCategory());
|
90 |
+
|
91 |
+
if ($origCategory) {
|
92 |
+
$layer->setCurrentCategory($origCategory);
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
return $this->_productCollection;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Get catalog layer model
|
101 |
+
*
|
102 |
+
* @return Mage_Catalog_Model_Layer
|
103 |
+
*/
|
104 |
+
public function getLayer()
|
105 |
+
{
|
106 |
+
$layer = Mage::registry('current_layer');
|
107 |
+
if ($layer) {
|
108 |
+
return $layer;
|
109 |
+
}
|
110 |
+
return Mage::getSingleton('catalog/layer');
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Retrieve loaded category collection
|
115 |
+
*
|
116 |
+
* @return Mage_Eav_Model_Entity_Collection_Abstract
|
117 |
+
*/
|
118 |
+
public function getLoadedProductCollection()
|
119 |
+
{
|
120 |
+
return $this->_getProductCollection();
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Retrieve current view mode
|
125 |
+
*
|
126 |
+
* @return string
|
127 |
+
*/
|
128 |
+
public function getMode()
|
129 |
+
{
|
130 |
+
return $this->getChild('toolbar')->getCurrentMode();
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Retrieve API Product
|
135 |
+
*
|
136 |
+
* @return Skybox_Catalog_Model_Api_Product
|
137 |
+
*/
|
138 |
+
protected function _getApi()
|
139 |
+
{
|
140 |
+
if (null === $this->_api) {
|
141 |
+
$this->_api = Mage::getModel('skyboxcatalog/api_product');
|
142 |
+
}
|
143 |
+
return $this->_api;
|
144 |
+
}
|
145 |
+
|
146 |
+
public function getUrlService($product)
|
147 |
+
{
|
148 |
+
|
149 |
+
$type = $product->getTypeId();
|
150 |
+
switch ($type) {
|
151 |
+
case 'simple':
|
152 |
+
$template = $this->_getApi()->getUrl($product->getId(), null, $product->getFinalPrice(), $product->getTypeId());
|
153 |
+
break;
|
154 |
+
case 'configurable':
|
155 |
+
$template = $this->_getApi()->getUrl($product->getId(), null, $product->getFinalPrice(), $product->getTypeId());
|
156 |
+
break;
|
157 |
+
case 'bundle':
|
158 |
+
$template = $this->_getApi()->getUrl($product, null, $product->getFinalPrice(), 'simple');
|
159 |
+
break;
|
160 |
+
}
|
161 |
+
return $template;
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Need use as _prepareLayout - but problem in declaring collection from
|
166 |
+
* another block (was problem with search result)
|
167 |
+
*/
|
168 |
+
protected function _beforeToHtml()
|
169 |
+
{
|
170 |
+
|
171 |
+
/*ini Load all product of catalog*/
|
172 |
+
|
173 |
+
//var_dump($products); exit;
|
174 |
+
$session = Mage::getSingleton("core/session", array("name"=>"frontend"));
|
175 |
+
$sky = $session->getData("skyBox");
|
176 |
+
/*1 step conexion done*/
|
177 |
+
$_checkout = Mage::getModel('skyboxcheckout/api_checkout');
|
178 |
+
$_cartDataURL = "";
|
179 |
+
$_checkout->InitializeBarSkybox();
|
180 |
+
$data = $_checkout->getValueAccessService();
|
181 |
+
|
182 |
+
$skyBoxUrlClient = Mage::helper('skyboxinternational/data')->getSkyBoxUrlAPI();
|
183 |
+
$skyBoxUrlClient = $skyBoxUrlClient . ("multiplecalculate");
|
184 |
+
//var_dump($skyBoxUrlClient); "https://beta.skyboxcheckout.com/testapi/ApiRest/multiplecalculate"
|
185 |
+
$products = $this->_getProductCollection();
|
186 |
+
/*call*/
|
187 |
+
/*Objeto producto catalogo*/
|
188 |
+
foreach($products as $prod) {
|
189 |
+
$product = Mage::getModel('catalog/product')->load($prod->getId());
|
190 |
+
$data['listproducts'][] = $this->getUrlService($product);
|
191 |
+
$dataJson = json_encode($data);
|
192 |
+
}
|
193 |
+
$this->_getApi()->HtmlTemplateButton();
|
194 |
+
$template = $this->_getApi()->getHtmlTemplateButton();
|
195 |
+
|
196 |
+
$start = microtime(true);
|
197 |
+
$resultObjectMultiCurl = $this->file_multi_get_contents_curl($skyBoxUrlClient, $dataJson);
|
198 |
+
//var_export($resultObjectMultiCurl);
|
199 |
+
$time_elapsed_secs = microtime(true) - $start;
|
200 |
+
/*echo "<div style='position: absolute;
|
201 |
+
background: lightgreen;
|
202 |
+
font-weight: bolder;
|
203 |
+
z-index: 1111;'>Tiempo de respuesta (Multiple): {$time_elapsed_secs}</div>"."<br/>";*/
|
204 |
+
|
205 |
+
$dataMultiCurl = array();
|
206 |
+
$resultObjectMultiCurl = json_decode($resultObjectMultiCurl);
|
207 |
+
$resultObjectMultiCurlArray = json_decode(json_encode($resultObjectMultiCurl), true);
|
208 |
+
|
209 |
+
foreach($resultObjectMultiCurlArray['listCalculateResponse'] as $value) {
|
210 |
+
$dataMultiCurl[$value["HtmlObjectId"]] = $this->getTemplateServicio($value, $template);
|
211 |
+
}
|
212 |
+
|
213 |
+
/*$dataMultiCurlVal = array();
|
214 |
+
$cont = 0;
|
215 |
+
foreach($products as $key => $prod) {
|
216 |
+
$dataMultiCurlVal[$prod->getId()] = $dataMultiCurl[$cont];
|
217 |
+
$cont++;
|
218 |
+
}*/
|
219 |
+
$session->setData("skyBox", $dataMultiCurl);
|
220 |
+
/*end Load all product of catalog*/
|
221 |
+
|
222 |
+
|
223 |
+
$toolbar = $this->getToolbarBlock();
|
224 |
+
|
225 |
+
// called prepare sortable parameters
|
226 |
+
$collection = $this->_getProductCollection();
|
227 |
+
|
228 |
+
// use sortable parameters
|
229 |
+
if ($orders = $this->getAvailableOrders()) {
|
230 |
+
$toolbar->setAvailableOrders($orders);
|
231 |
+
}
|
232 |
+
if ($sort = $this->getSortBy()) {
|
233 |
+
$toolbar->setDefaultOrder($sort);
|
234 |
+
}
|
235 |
+
if ($dir = $this->getDefaultDirection()) {
|
236 |
+
$toolbar->setDefaultDirection($dir);
|
237 |
+
}
|
238 |
+
if ($modes = $this->getModes()) {
|
239 |
+
$toolbar->setModes($modes);
|
240 |
+
}
|
241 |
+
|
242 |
+
// set collection to toolbar and apply sort
|
243 |
+
$toolbar->setCollection($collection);
|
244 |
+
|
245 |
+
$this->setChild('toolbar', $toolbar);
|
246 |
+
Mage::dispatchEvent('catalog_block_product_list_collection', array(
|
247 |
+
'collection' => $this->_getProductCollection()
|
248 |
+
));
|
249 |
+
|
250 |
+
$this->_getProductCollection()->load();
|
251 |
+
|
252 |
+
return parent::_beforeToHtml();
|
253 |
+
}
|
254 |
+
|
255 |
+
public function getTemplateServicio($objectProduct,$template)
|
256 |
+
{
|
257 |
+
|
258 |
+
|
259 |
+
|
260 |
+
|
261 |
+
|
262 |
+
|
263 |
+
/*2step execute get button template*/
|
264 |
+
|
265 |
+
/*var_dump($a->getHtmlTemplateButton());exit;*/
|
266 |
+
|
267 |
+
/*3 step call calculate*/;
|
268 |
+
if (1) {
|
269 |
+
|
270 |
+
/*$objectProduct = json_decode($objectProduct);
|
271 |
+
$objectProduct = json_decode(json_encode($objectProduct), true);*/
|
272 |
+
//var_dump($objectProduct);exit;
|
273 |
+
foreach ($objectProduct as $key => $value) {
|
274 |
+
/*echo "==>".$key."<====";
|
275 |
+
echo "==>".$value."<====";exit;-*/
|
276 |
+
$template = str_replace('{' . $key . '}', $value, $template);
|
277 |
+
}
|
278 |
+
|
279 |
+
// Just for {Block} crap
|
280 |
+
$template = str_replace('{Block}', '', $template);
|
281 |
+
/*echo "<hit>";
|
282 |
+
echo($template); exit;
|
283 |
+
echo "</hit>";*/
|
284 |
+
/*echo $template; exit;*/
|
285 |
+
return $template;
|
286 |
+
}
|
287 |
+
//exit("debug si es que llega");
|
288 |
+
/*var_dump($a); exit;
|
289 |
+
var_dump(Mage::getSingleton('skyboxcore/session')); exit;--*/
|
290 |
+
|
291 |
+
|
292 |
+
}
|
293 |
+
|
294 |
+
function file_multi_get_contents_curl($url, $data)
|
295 |
+
{
|
296 |
+
|
297 |
+
/*var_export($data); exit;*/
|
298 |
+
if (!function_exists("curl_init")) die("cURL extension is not installed");
|
299 |
+
$ch = curl_init();
|
300 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
301 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
302 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
303 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
|
304 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
305 |
+
$response = curl_exec($ch);
|
306 |
+
|
307 |
+
/*var_export($response); exit;*/
|
308 |
+
// Will dump a beauty json :3
|
309 |
+
//var_dump(json_decode($result, true));
|
310 |
+
return $response;
|
311 |
+
/*
|
312 |
+
$node_count = count($nodes);
|
313 |
+
$curl_arr = array();
|
314 |
+
$master = curl_multi_init();
|
315 |
+
//curl_setopt($master, CURLOPT_SSL_VERIFYPEER, false);
|
316 |
+
// Will return the response, if false it print the response
|
317 |
+
//curl_setopt($master, CURLOPT_RETURNTRANSFER, true);
|
318 |
+
|
319 |
+
for($i = 0; $i < count($nodes); $i++)
|
320 |
+
{
|
321 |
+
$start = microtime(true);
|
322 |
+
$url =$nodes[$i];
|
323 |
+
$curl_arr[$i] = curl_init($url);
|
324 |
+
curl_setopt($curl_arr[$i], CURLOPT_RETURNTRANSFER, true);
|
325 |
+
curl_multi_add_handle($master, $curl_arr[$i]);
|
326 |
+
$total_time = round(microtime(true)-$start, 4);
|
327 |
+
echo "Request #".($i+1).": send {$start} ; delay: {$total_time}"."<br/>";
|
328 |
+
}
|
329 |
+
|
330 |
+
$start = microtime(true);
|
331 |
+
do
|
332 |
+
{
|
333 |
+
$startMultiExec = microtime(true);
|
334 |
+
$curl_multi_exec = curl_multi_exec($master,$running);
|
335 |
+
$totalMultiExec = round(microtime(true)-$startMultiExec, 4);
|
336 |
+
//echo "Request MultiExec: send {$startMultiExec} ; delay: {$totalMultiExec}"."<br/>";
|
337 |
+
}
|
338 |
+
while($running > 0);
|
339 |
+
$total_time = round(microtime(true)-$start, 4);
|
340 |
+
echo "Request All: send {$start} ; delay: {$total_time}"."<br/>";
|
341 |
+
|
342 |
+
echo 'results: '."<br/>";
|
343 |
+
$results = array();
|
344 |
+
for($i = 0; $i < $node_count; $i++)
|
345 |
+
{
|
346 |
+
$preresult = curl_multi_getcontent ( $curl_arr[$i] );
|
347 |
+
$results[] = $preresult;
|
348 |
+
echo "<pre>".var_export($results)."</pre>";
|
349 |
+
echo( $i . '\n' . $results . '\n');
|
350 |
+
}
|
351 |
+
echo "<pre>".var_dump($results)."</pre>";
|
352 |
+
|
353 |
+
echo 'done'."<br/>";*/
|
354 |
+
}
|
355 |
+
|
356 |
+
/**
|
357 |
+
* Retrieve Toolbar block
|
358 |
+
*
|
359 |
+
* @return Mage_Catalog_Block_Product_List_Toolbar
|
360 |
+
*/
|
361 |
+
public function getToolbarBlock()
|
362 |
+
{
|
363 |
+
if ($blockName = $this->getToolbarBlockName()) {
|
364 |
+
if ($block = $this->getLayout()->getBlock($blockName)) {
|
365 |
+
return $block;
|
366 |
+
}
|
367 |
+
}
|
368 |
+
$block = $this->getLayout()->createBlock($this->_defaultToolbarBlock, microtime());
|
369 |
+
return $block;
|
370 |
+
}
|
371 |
+
|
372 |
+
/**
|
373 |
+
* Retrieve additional blocks html
|
374 |
+
*
|
375 |
+
* @return string
|
376 |
+
*/
|
377 |
+
public function getAdditionalHtml()
|
378 |
+
{
|
379 |
+
return $this->getChildHtml('additional');
|
380 |
+
}
|
381 |
+
|
382 |
+
/**
|
383 |
+
* Retrieve list toolbar HTML
|
384 |
+
*
|
385 |
+
* @return string
|
386 |
+
*/
|
387 |
+
public function getToolbarHtml()
|
388 |
+
{
|
389 |
+
return $this->getChildHtml('toolbar');
|
390 |
+
}
|
391 |
+
|
392 |
+
public function setCollection($collection)
|
393 |
+
{
|
394 |
+
$this->_productCollection = $collection;
|
395 |
+
return $this;
|
396 |
+
}
|
397 |
+
|
398 |
+
public function addAttribute($code)
|
399 |
+
{
|
400 |
+
$this->_getProductCollection()->addAttributeToSelect($code);
|
401 |
+
return $this;
|
402 |
+
}
|
403 |
+
|
404 |
+
public function getPriceBlockTemplate()
|
405 |
+
{
|
406 |
+
return $this->_getData('price_block_template');
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* Retrieve Catalog Config object
|
411 |
+
*
|
412 |
+
* @return Mage_Catalog_Model_Config
|
413 |
+
*/
|
414 |
+
protected function _getConfig()
|
415 |
+
{
|
416 |
+
return Mage::getSingleton('catalog/config');
|
417 |
+
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
* Prepare Sort By fields from Category Data
|
421 |
+
*
|
422 |
+
* @param Mage_Catalog_Model_Category $category
|
423 |
+
* @return Mage_Catalog_Block_Product_List
|
424 |
+
*/
|
425 |
+
public function prepareSortableFieldsByCategory($category) {
|
426 |
+
if (!$this->getAvailableOrders()) {
|
427 |
+
$this->setAvailableOrders($category->getAvailableSortByOptions());
|
428 |
+
}
|
429 |
+
$availableOrders = $this->getAvailableOrders();
|
430 |
+
if (!$this->getSortBy()) {
|
431 |
+
if ($categorySortBy = $category->getDefaultSortBy()) {
|
432 |
+
if (!$availableOrders) {
|
433 |
+
$availableOrders = $this->_getConfig()->getAttributeUsedForSortByArray();
|
434 |
+
}
|
435 |
+
if (isset($availableOrders[$categorySortBy])) {
|
436 |
+
$this->setSortBy($categorySortBy);
|
437 |
+
}
|
438 |
+
}
|
439 |
+
}
|
440 |
+
|
441 |
+
return $this;
|
442 |
+
}
|
443 |
+
|
444 |
+
/**
|
445 |
+
* Retrieve block cache tags based on product collection
|
446 |
+
*
|
447 |
+
* @return array
|
448 |
+
*/
|
449 |
+
public function getCacheTags()
|
450 |
+
{
|
451 |
+
return array_merge(
|
452 |
+
parent::getCacheTags(),
|
453 |
+
$this->getItemsTags($this->_getProductCollection())
|
454 |
+
);
|
455 |
+
}
|
456 |
+
}
|
app/code/community/Skybox/Catalog/Block/Product/Price.php
CHANGED
@@ -76,13 +76,22 @@ class Skybox_Catalog_Block_Product_Price extends Mage_Catalog_Block_Product_Pric
|
|
76 |
*/
|
77 |
public function _toHtml()
|
78 |
{
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
86 |
}
|
87 |
|
88 |
/* @var $product Mage_Catalog_Model_Product */
|
@@ -90,20 +99,28 @@ class Skybox_Catalog_Block_Product_Price extends Mage_Catalog_Block_Product_Pric
|
|
90 |
$type = $product->getTypeId();
|
91 |
$route_name = Mage::app()->getRequest()->getRouteName();
|
92 |
|
|
|
|
|
93 |
// Simple Product
|
94 |
if ($type == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE && $this->getTemplate() == 'catalog/product/price.phtml') {
|
95 |
return $this->calculatePrice($product);
|
96 |
}
|
97 |
|
|
|
98 |
if ($type == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE && $this->getTemplate() == 'catalog/product/view/price_clone.phtml') {
|
99 |
return '';
|
100 |
}
|
101 |
|
102 |
// Configurable Product
|
103 |
if ($type == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE && $this->getTemplate() == 'catalog/product/price.phtml') {
|
104 |
-
if ($route_name == 'catalog') {
|
105 |
return '';
|
|
|
|
|
|
|
|
|
106 |
}
|
|
|
107 |
return $this->calculatePrice($product);
|
108 |
}
|
109 |
|
@@ -125,27 +142,65 @@ class Skybox_Catalog_Block_Product_Price extends Mage_Catalog_Block_Product_Pric
|
|
125 |
*/
|
126 |
protected function calculatePrice($product)
|
127 |
{
|
|
|
128 |
$stockItem = $product->getStockItem();
|
129 |
-
if (!$stockItem->getIsInStock()) {
|
130 |
-
|
131 |
-
|
|
|
132 |
|
133 |
$type = $product->getTypeId();
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
->
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
}
|
148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
$extraHtml = ''
|
150 |
. '<div class="price-box">'
|
151 |
. '<p class="label" id="skybox-configurable-price-from-'
|
76 |
*/
|
77 |
public function _toHtml()
|
78 |
{
|
79 |
+
// $activation = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
|
80 |
+
$activation = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
81 |
+
|
82 |
+
if (!$activation) {
|
83 |
+
return '';
|
84 |
+
}
|
85 |
+
$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
|
86 |
+
//Mage::log(print_r('product\Price::_toHtml', true), null, 'tracer.log', true);
|
87 |
+
if($this->_getApi()->getLocationAllow() && ($typeIntegration!=3)){ // Rogged
|
88 |
if ($this->_getApi()->getErrorAuthenticate() && !$this->_getApi()->getLocationAllow() && $this->_getApi()->HasError()) {
|
89 |
return '';
|
90 |
} elseif ($this->_getApi()->HasError()) {
|
91 |
//$error_code = $this->_getApi()->getStatusCode();
|
92 |
$message = $this->_getApi()->getStatusMessage();
|
93 |
+
return '';
|
94 |
+
// return '<div style="color:#FF0000;">' . $message . '</div>';
|
95 |
}
|
96 |
|
97 |
/* @var $product Mage_Catalog_Model_Product */
|
99 |
$type = $product->getTypeId();
|
100 |
$route_name = Mage::app()->getRequest()->getRouteName();
|
101 |
|
102 |
+
// Mage::log(print_r('$route_name: '. $route_name, true), null, 'tracer.log', true);
|
103 |
+
|
104 |
// Simple Product
|
105 |
if ($type == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE && $this->getTemplate() == 'catalog/product/price.phtml') {
|
106 |
return $this->calculatePrice($product);
|
107 |
}
|
108 |
|
109 |
+
|
110 |
if ($type == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE && $this->getTemplate() == 'catalog/product/view/price_clone.phtml') {
|
111 |
return '';
|
112 |
}
|
113 |
|
114 |
// Configurable Product
|
115 |
if ($type == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE && $this->getTemplate() == 'catalog/product/price.phtml') {
|
116 |
+
/*if ($route_name == 'catalog') {
|
117 |
return '';
|
118 |
+
}*/
|
119 |
+
|
120 |
+
if(Mage::registry('current_product')) {
|
121 |
+
return "";
|
122 |
}
|
123 |
+
|
124 |
return $this->calculatePrice($product);
|
125 |
}
|
126 |
|
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 |
+
if (Mage::registry('current_category')){
|
156 |
+
/*Async Ini*/
|
157 |
+
$session = Mage::getSingleton("core/session", array("name"=>"frontend"));
|
158 |
+
$skyboxPrecio = $session->getData("skyBox");
|
159 |
+
/*
|
160 |
+
if($product->getTypeId() == "simple"){
|
161 |
+
$parentIds = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($product->getId());
|
162 |
+
if(!$parentIds)
|
163 |
+
$parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
|
164 |
+
if(isset($parentIds[0])){
|
165 |
+
$parent = Mage::getModel('catalog/product')->load($parentIds[0]);
|
166 |
+
// do stuff here
|
167 |
+
}
|
168 |
+
}*/
|
169 |
+
$template = $skyboxPrecio[$product->getId()];
|
170 |
+
$template = '<div class="skybox-price-set" product-id="' . $product->getId() . '" id="product-' . $product->getId() . '"></div>';
|
171 |
+
/*Async End*/
|
172 |
+
} else {
|
173 |
+
switch ($type) {
|
174 |
+
case 'simple':
|
175 |
+
$template = $this->_getApi()->CalculatePrice($product->getId(), null, $product->getFinalPrice(), $product->getTypeId())
|
176 |
+
->GetTemplateProduct();
|
177 |
+
break;
|
178 |
+
case 'configurable':
|
179 |
+
$template = $this->_getApi()->CalculatePrice($product->getId(), null, $product->getFinalPrice(), $product->getTypeId())
|
180 |
+
->GetTemplateProduct();
|
181 |
+
break;
|
182 |
+
case 'bundle':
|
183 |
+
$template = $this->_getApi()->CalculatePrice($product, null, $product->getFinalPrice(), 'simple')
|
184 |
+
->GetTemplateProduct();
|
185 |
+
break;
|
186 |
+
}
|
187 |
}
|
188 |
|
189 |
+
// Mage::log(print_r('##Product template##', true), null, 'tracer.log', true);
|
190 |
+
// Mage::log(print_r($template, true), null, 'tracer.log', true);
|
191 |
+
/*
|
192 |
+
$extraHtml = ''
|
193 |
+
. '<div class="price-box">'
|
194 |
+
. '<p class="label" id="skybox-configurable-price-from-'
|
195 |
+
. $product->getId()
|
196 |
+
. $this->getIdSuffix()
|
197 |
+
. '">'
|
198 |
+
. $template
|
199 |
+
. '</p>'
|
200 |
+
. '</div>'
|
201 |
+
. '<div style="clear:both"></div>';
|
202 |
+
|
203 |
+
*/
|
204 |
$extraHtml = ''
|
205 |
. '<div class="price-box">'
|
206 |
. '<p class="label" id="skybox-configurable-price-from-'
|
app/code/community/Skybox/Catalog/Model/Api/Product.php
CHANGED
@@ -68,13 +68,16 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
|
|
68 |
{
|
69 |
Mage::log("ApiProductCatalog ", null, 'orden.log', true);
|
70 |
|
|
|
|
|
71 |
//if ($this->getErrorAuthenticate() && !$this->getLocationAllow()) {
|
72 |
if (!$this->getLocationAllow()) {
|
73 |
return $this;
|
74 |
}
|
75 |
|
76 |
if (!is_object($product)) {
|
77 |
-
$
|
|
|
78 |
}
|
79 |
|
80 |
$productId = $product->getId();
|
@@ -84,11 +87,13 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
|
|
84 |
$type = $product->getTypeId();
|
85 |
}
|
86 |
|
|
|
87 |
switch ($type) {
|
88 |
case 'simple':
|
89 |
$finalPrice = isset($finalPrice) ? $finalPrice : $product->getFinalPrice();
|
90 |
$category_id = $product->getSkyboxCategoryId();
|
91 |
$category_id = isset($category_id) ? $product->getSkyboxCategoryId() : 0;
|
|
|
92 |
|
93 |
$_data = array(
|
94 |
'object_id' => 1,
|
@@ -96,11 +101,13 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
|
|
96 |
'sku' => $product->getSku(),
|
97 |
'category_id' => $category_id,
|
98 |
'final_price' => $finalPrice,
|
99 |
-
'weight' =>
|
100 |
'image_url' => $product->getImageUrl(),
|
101 |
-
'typeProduct' => $type
|
|
|
|
|
102 |
);
|
103 |
-
$this->_calculatePrice($_data);
|
104 |
break;
|
105 |
|
106 |
case 'configurable':
|
@@ -146,6 +153,33 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
|
|
146 |
Mage::log("CalculatePrice candidate FIN", null, 'skyboxcheckout.log', false);
|
147 |
}
|
148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
$_data = array(
|
150 |
'object_id' => 1,
|
151 |
'name' => $product->getName(),
|
@@ -153,14 +187,14 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
|
|
153 |
'sku' => $sku,
|
154 |
'category_id' => $product->getSkyboxCategoryId(),
|
155 |
'final_price' => $finalPrice,
|
156 |
-
|
157 |
-
'weight' => $weight,
|
158 |
-
'weight' => 1,
|
159 |
'image_url' => $product->getImageUrl(),
|
160 |
-
'typeProduct' => $type
|
|
|
|
|
161 |
);
|
162 |
|
163 |
-
$this->_calculatePrice($_data);
|
164 |
break;
|
165 |
|
166 |
case 'bundle':
|
@@ -208,18 +242,20 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
|
|
208 |
//Mage::log("weight: " . $weight, null, 'cart.log', true);
|
209 |
//Mage::log("sku: " . $sku, null, 'cart.log', true);
|
210 |
|
|
|
211 |
$_data = array(
|
212 |
'object_id' => 1,
|
213 |
'name' => $product->getName(),
|
214 |
'sku' => $sku,
|
215 |
'category_id' => $product->getSkyboxCategoryId(),
|
216 |
'final_price' => $finalPrice,
|
217 |
-
|
218 |
-
'weight' => $weight,
|
219 |
'image_url' => $product->getImageUrl(),
|
220 |
-
'typeProduct' => $type
|
|
|
|
|
221 |
);
|
222 |
-
$this->_calculatePrice($_data);
|
223 |
break;
|
224 |
|
225 |
case 'bundle_fixed':
|
@@ -266,27 +302,64 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
|
|
266 |
Mage::log("weight: " . $weight, null, 'cart.log', true);
|
267 |
Mage::log("sku: " . $sku, null, 'cart.log', true);*/
|
268 |
|
|
|
269 |
$_data = array(
|
270 |
'object_id' => 1,
|
271 |
'name' => $product->getName(),
|
272 |
'sku' => $sku,
|
273 |
'category_id' => $skyboxCategoryId,
|
274 |
'final_price' => $finalPrice,
|
275 |
-
|
276 |
-
'weight' => $weight,
|
277 |
'image_url' => $product->getImageUrl(),
|
278 |
-
'typeProduct' => $type
|
|
|
|
|
279 |
);
|
280 |
|
281 |
-
$this->_calculatePrice($_data);
|
282 |
break;
|
283 |
|
284 |
default:
|
285 |
Mage::log("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice", null, 'skyboxcheckout.log', false);
|
286 |
trigger_error("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice");
|
|
|
287 |
break;
|
288 |
}
|
289 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
Mage::log("Product Class: " . get_class($product), null, 'skyboxcheckout.log', false);
|
291 |
Mage::log("Product Type: " . $type, null, 'skyboxcheckout.log', false);
|
292 |
Mage::log(print_r($_data, true), null, 'skyboxcheckout.log', false);
|
@@ -320,9 +393,10 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
|
|
320 |
'storeproductcategory' => $data['category_id'],
|
321 |
'storeproductprice' => $data['final_price'],
|
322 |
//'storeproductprice' => $product->getFinalPrice(),
|
323 |
-
'weight' =>
|
324 |
'weightunit' => $this->getWeightUnit(),
|
325 |
-
'storeproductimgurl' => $data['image_url
|
|
|
326 |
);
|
327 |
$this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_CALCULATE, $params);
|
328 |
}
|
@@ -348,32 +422,35 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
|
|
348 |
if (!$this->getErrorAuthenticate() && $this->_getApi()->getLocationAllow() && !$this->_getApi()->ErrorServiceNotController()) {
|
349 |
//if (!$this->getErrorAuthenticate() && $this->_getApi()->getLocationAllow() && !$this->_getApi()->ErrorService()) {
|
350 |
$_productResult = $this->getResponse();
|
351 |
-
$
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
|
|
|
|
|
|
377 |
} else {
|
378 |
$template = '<div class="skx_content_button"></div>';
|
379 |
return $template;
|
@@ -469,4 +546,318 @@ class Skybox_Catalog_Model_Api_Product extends Skybox_Core_Model_Standard
|
|
469 |
{
|
470 |
return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_LABEL_ADJUST, "");
|
471 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
472 |
}
|
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();
|
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) ? $product->getSkyboxCategoryId() : 0;
|
96 |
+
$volWeight = !empty(trim($product->getDimensionalWeight()))?$product->getDimensionalWeight():0;
|
97 |
|
98 |
$_data = array(
|
99 |
'object_id' => 1,
|
101 |
'sku' => $product->getSku(),
|
102 |
'category_id' => $category_id,
|
103 |
'final_price' => $finalPrice,
|
104 |
+
'weight' => ($product->getWeight())?$product->getWeight():1,
|
105 |
'image_url' => $product->getImageUrl(),
|
106 |
+
'typeProduct' => $type,
|
107 |
+
'VolWeight' => $volWeight,
|
108 |
+
'merchantproductid' => $productId
|
109 |
);
|
110 |
+
// $this->_calculatePrice($_data);
|
111 |
break;
|
112 |
|
113 |
case 'configurable':
|
153 |
Mage::log("CalculatePrice candidate FIN", null, 'skyboxcheckout.log', false);
|
154 |
}
|
155 |
|
156 |
+
/* Weight start*/
|
157 |
+
/*
|
158 |
+
$options = array();
|
159 |
+
// Get any super_attribute settings we need
|
160 |
+
$productAttributesOptions = $product->getTypeInstance(true)->getConfigurableOptions($product);
|
161 |
+
foreach ($productAttributesOptions as $productAttributeOption) {
|
162 |
+
$options[$product->getId()] = array();
|
163 |
+
foreach ($productAttributeOption as $optionValues) {
|
164 |
+
$val = ($optionValues['option_title']);
|
165 |
+
$options[$product->getId()][] = array (
|
166 |
+
$optionValues['sku'] => $optionValues['attribute_code']."=".$val
|
167 |
+
|
168 |
+
) ;
|
169 |
+
}
|
170 |
+
|
171 |
+
}
|
172 |
+
$prod_weight = 1;
|
173 |
+
if(!empty($optionValues)) {
|
174 |
+
$a = Mage::getModel('catalog/product')->loadByAttribute('sku',$optionValues['sku']);
|
175 |
+
//$product->load($product->getIdBySku($optionValues['sku']));
|
176 |
+
$prod_weight = $a->getWeight();
|
177 |
+
echo ":::".$prod_weight."::";
|
178 |
+
}
|
179 |
+
*/
|
180 |
+
/* Weight end*/
|
181 |
+
|
182 |
+
$volWeight = !empty(trim($product->getDimensionalWeight()))?$product->getDimensionalWeight():0;
|
183 |
$_data = array(
|
184 |
'object_id' => 1,
|
185 |
'name' => $product->getName(),
|
187 |
'sku' => $sku,
|
188 |
'category_id' => $product->getSkyboxCategoryId(),
|
189 |
'final_price' => $finalPrice,
|
190 |
+
'weight' => $weight?$weight:1,
|
|
|
|
|
191 |
'image_url' => $product->getImageUrl(),
|
192 |
+
'typeProduct' => $type,
|
193 |
+
'VolWeight' => $volWeight,
|
194 |
+
'merchantproductid' => $productId
|
195 |
);
|
196 |
|
197 |
+
// $this->_calculatePrice($_data);
|
198 |
break;
|
199 |
|
200 |
case 'bundle':
|
242 |
//Mage::log("weight: " . $weight, null, 'cart.log', true);
|
243 |
//Mage::log("sku: " . $sku, null, 'cart.log', true);
|
244 |
|
245 |
+
$volWeight = !empty(trim($product->getDimensionalWeight()))?$product->getDimensionalWeight():0;
|
246 |
$_data = array(
|
247 |
'object_id' => 1,
|
248 |
'name' => $product->getName(),
|
249 |
'sku' => $sku,
|
250 |
'category_id' => $product->getSkyboxCategoryId(),
|
251 |
'final_price' => $finalPrice,
|
252 |
+
'weight' => ($weight)?$weight:1,
|
|
|
253 |
'image_url' => $product->getImageUrl(),
|
254 |
+
'typeProduct' => $type,
|
255 |
+
'VolWeight' => $volWeight,
|
256 |
+
'merchantproductid' => $productId
|
257 |
);
|
258 |
+
// $this->_calculatePrice($_data);
|
259 |
break;
|
260 |
|
261 |
case 'bundle_fixed':
|
302 |
Mage::log("weight: " . $weight, null, 'cart.log', true);
|
303 |
Mage::log("sku: " . $sku, null, 'cart.log', true);*/
|
304 |
|
305 |
+
$volWeight = !empty(trim($product->getDimensionalWeight()))?$product->getDimensionalWeight():0;
|
306 |
$_data = array(
|
307 |
'object_id' => 1,
|
308 |
'name' => $product->getName(),
|
309 |
'sku' => $sku,
|
310 |
'category_id' => $skyboxCategoryId,
|
311 |
'final_price' => $finalPrice,
|
312 |
+
'weight' => ($weight)?$weight:1,
|
|
|
313 |
'image_url' => $product->getImageUrl(),
|
314 |
+
'typeProduct' => $type,
|
315 |
+
'VolWeight' => $volWeight,
|
316 |
+
'merchantproductid' => $productId
|
317 |
);
|
318 |
|
319 |
+
// $this->_calculatePrice($_data);
|
320 |
break;
|
321 |
|
322 |
default:
|
323 |
Mage::log("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice", null, 'skyboxcheckout.log', false);
|
324 |
trigger_error("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice");
|
325 |
+
$defaultSwitch = true;
|
326 |
break;
|
327 |
}
|
328 |
|
329 |
+
if(!$defaultSwitch){
|
330 |
+
//Mage::log(print_r('EnableTax: ', true), null, 'tracer.log', true);
|
331 |
+
//Mage::log(print_r($this->getEnabledAddSumTaxToPrice(), true), null, 'tracer.log', true);
|
332 |
+
if($this->getEnabledAddSumTaxToPrice()) {
|
333 |
+
$store = Mage::app()->getStore('default');
|
334 |
+
$taxCalculation = Mage::getModel('tax/calculation');
|
335 |
+
$request = $taxCalculation->getRateRequest(null, null, null, $store);
|
336 |
+
// $product = Mage::registry('current_product');
|
337 |
+
$taxClassId = $product->getTaxClassId();
|
338 |
+
$percentTax = $taxCalculation->getRate($request->setProductClassId($taxClassId));
|
339 |
+
|
340 |
+
$taxPrice = $_data['final_price'] * ($percentTax / 100);
|
341 |
+
|
342 |
+
//Mage::log(print_r('Id product: ' . $product->getId(), true), null, 'tracer.log', true);
|
343 |
+
//Mage::log(print_r('$taxPrice: ' . $taxPrice, true), null, 'tracer.log', true);
|
344 |
+
//Mage::log(print_r('price: ' . $_data['final_price'], true), null, 'tracer.log', true);
|
345 |
+
//Mage::log(print_r('$taxPrice+price: ' . ($taxPrice + $_data['final_price']), true), null, 'tracer.log', true);
|
346 |
+
$comissionSkybox = $_data['final_price'] * (10 / 100);
|
347 |
+
//Mage::log(print_r('comision skybox: ' . ($comissionSkybox), true), null, 'tracer.log', true);
|
348 |
+
//Mage::log(print_r('price+comision skybox: ' . ($_data['final_price'] + $comissionSkybox), true), null, 'tracer.log', true);
|
349 |
+
//Mage::log(print_r('$taxPrice+price+comision: ' . ($taxPrice + $_data['final_price'] + $comissionSkybox), true), null, 'tracer.log', true);
|
350 |
+
//Mage::log(print_r('comision true: ' . (($taxPrice + $_data['final_price']) * (10 / 100)), true), null, 'tracer.log', true);
|
351 |
+
$priceReally = ($taxPrice + $_data['final_price']) + ($taxPrice + $_data['final_price']) * (10 / 100);
|
352 |
+
//Mage::log(print_r('$taxPrice+price+comision true: ' . ($priceReally), true), null, 'tracer.log', true);
|
353 |
+
|
354 |
+
|
355 |
+
$_data['final_price'] = $_data['final_price'] + $taxPrice;
|
356 |
+
}
|
357 |
+
|
358 |
+
//Mage::log(print_r('####################### Data produc params #######################', true), null, 'tracer.log', true);
|
359 |
+
//Mage::log(print_r($_data, true), null, 'tracer.log', true);
|
360 |
+
$this->_calculatePrice($_data);
|
361 |
+
}
|
362 |
+
|
363 |
Mage::log("Product Class: " . get_class($product), null, 'skyboxcheckout.log', false);
|
364 |
Mage::log("Product Type: " . $type, null, 'skyboxcheckout.log', false);
|
365 |
Mage::log(print_r($_data, true), null, 'skyboxcheckout.log', false);
|
393 |
'storeproductcategory' => $data['category_id'],
|
394 |
'storeproductprice' => $data['final_price'],
|
395 |
//'storeproductprice' => $product->getFinalPrice(),
|
396 |
+
'weight' => ($data['weight'])?$data['weight']:1,
|
397 |
'weightunit' => $this->getWeightUnit(),
|
398 |
+
'storeproductimgurl' => $data['image_url'],
|
399 |
+
'merchantproductid' => $data['merchantproductid']
|
400 |
);
|
401 |
$this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_CALCULATE, $params);
|
402 |
}
|
422 |
if (!$this->getErrorAuthenticate() && $this->_getApi()->getLocationAllow() && !$this->_getApi()->ErrorServiceNotController()) {
|
423 |
//if (!$this->getErrorAuthenticate() && $this->_getApi()->getLocationAllow() && !$this->_getApi()->ErrorService()) {
|
424 |
$_productResult = $this->getResponse();
|
425 |
+
$template = $_productResult->TooltipButtonTemplate;
|
426 |
+
return $template;
|
427 |
+
// $templateButton = $this->getHtmlTemplateButton();
|
428 |
+
// if (empty($templateButton))
|
429 |
+
// $this->HtmlTemplateButton();
|
430 |
+
//
|
431 |
+
// /*if($_productResult->{Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_BUTTONERROR})
|
432 |
+
// {*/
|
433 |
+
// //Mage::log("_productResult--->" . json_decode($_productResult));
|
434 |
+
// $templateButton = $this->getHtmlTemplateButton();
|
435 |
+
// if (!empty($templateButton)) {
|
436 |
+
// $template = $this->getHtmlTemplateButton();
|
437 |
+
//// Mage::log(print_r('response template buttom', true), null, 'tracer.log', true);
|
438 |
+
//// Mage::log(print_r($_productResult, true), null, 'tracer.log', true);
|
439 |
+
// foreach ($_productResult as $key => $value) {
|
440 |
+
// $template = str_replace('{' . $key . '}', $value, $template);
|
441 |
+
// }
|
442 |
+
//
|
443 |
+
// // Just for {Block} crap
|
444 |
+
// $template = str_replace('{Block}', '', $template);
|
445 |
+
//
|
446 |
+
// return $template;
|
447 |
+
// }
|
448 |
+
//
|
449 |
+
// $displayUSD = "''"; //CartCountryIso
|
450 |
+
// /*}else{
|
451 |
+
// return "Plantilla de error";
|
452 |
+
// }*/
|
453 |
+
// //Mage::log(get_class($this) . " GetTemplateProduct() ", null, 'cart.log', true);
|
454 |
} else {
|
455 |
$template = '<div class="skx_content_button"></div>';
|
456 |
return $template;
|
546 |
{
|
547 |
return $this->getParameter(Skybox_Core_Model_Config::SKYBOX_PARAMETER_RESPONSE_PRODUCT_LABEL_ADJUST, "");
|
548 |
}
|
549 |
+
|
550 |
+
/*Async Ini*/
|
551 |
+
|
552 |
+
public function getUrl($product, $request, $finalPrice = null, $type = null, $objectId = 1)
|
553 |
+
{
|
554 |
+
Mage::log("ApiProductCatalog ", null, 'orden.log', true);
|
555 |
+
|
556 |
+
//Mage::log(print_r('Product', true), null, 'tracer.log', true);
|
557 |
+
|
558 |
+
//if ($this->getErrorAuthenticate() && !$this->getLocationAllow()) {
|
559 |
+
if (!$this->getLocationAllow()) {
|
560 |
+
return $this;
|
561 |
+
}
|
562 |
+
|
563 |
+
if (!is_object($product)) {
|
564 |
+
$storeId = Mage::app()->getStore()->getStoreId();
|
565 |
+
$product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($product);
|
566 |
+
}
|
567 |
+
|
568 |
+
$productId = $product->getId();
|
569 |
+
$_data = null;
|
570 |
+
|
571 |
+
if ($type == null) {
|
572 |
+
$type = $product->getTypeId();
|
573 |
+
}
|
574 |
+
|
575 |
+
$defaultSwitch = true;
|
576 |
+
switch ($type) {
|
577 |
+
case 'simple':
|
578 |
+
$finalPrice = isset($finalPrice) ? $finalPrice : $product->getFinalPrice();
|
579 |
+
$category_id = $product->getSkyboxCategoryId();
|
580 |
+
$category_id = isset($category_id) ? $product->getSkyboxCategoryId() : 0;
|
581 |
+
$volWeight = !empty(trim($product->getDimensionalWeight()))?$product->getDimensionalWeight():0;
|
582 |
+
|
583 |
+
$_data = array(
|
584 |
+
'object_id' => $product->getId(),
|
585 |
+
'name' => $product->getName(),
|
586 |
+
'sku' => $product->getSku(),
|
587 |
+
'category_id' => $category_id,
|
588 |
+
'final_price' => $finalPrice,
|
589 |
+
'weight' => ($product->getWeight())?$product->getWeight():1,
|
590 |
+
'image_url' => $product->getImageUrl(),
|
591 |
+
'typeProduct' => $type,
|
592 |
+
'VolWeight' => $volWeight,
|
593 |
+
'merchantproductid' => $productId
|
594 |
+
);
|
595 |
+
// $this->_calculatePrice($_data);
|
596 |
+
break;
|
597 |
+
|
598 |
+
case 'configurable':
|
599 |
+
|
600 |
+
$finalPrice = isset($finalPrice) ? $finalPrice : null;
|
601 |
+
$weight = $product->getTypeInstance(true)->getWeight($product);
|
602 |
+
$sku = $product->getSku();
|
603 |
+
|
604 |
+
Mage::log("CalculatePrice configurable : " . $finalPrice, null, 'skyboxcheckout.log', false);
|
605 |
+
|
606 |
+
if ($request) {
|
607 |
+
$childProduct = Mage::getModel('catalog/product_type_configurable')
|
608 |
+
->getProductByAttributes($request->getData('super_attribute'), $product);
|
609 |
+
|
610 |
+
$productId = $childProduct->getId();
|
611 |
+
$sku = $childProduct->getSku();
|
612 |
+
|
613 |
+
}
|
614 |
+
|
615 |
+
$parentItem = null;
|
616 |
+
|
617 |
+
if (isset($request) && !$finalPrice) {
|
618 |
+
Mage::log("CalculatePrice candidate INI", null, 'skyboxcheckout.log', false);
|
619 |
+
$_finalPrice = 0;
|
620 |
+
|
621 |
+
$cartCandidates = $product->getTypeInstance(true)
|
622 |
+
->prepareForCartAdvanced($request, $product, 'full');
|
623 |
+
|
624 |
+
foreach ($cartCandidates as $candidate) {
|
625 |
+
// Child items can be sticked together only within their parent
|
626 |
+
$stickWithinParent = $candidate->getParentProductId() ? $parentItem : null;
|
627 |
+
$candidate->setStickWithinParent($stickWithinParent);
|
628 |
+
|
629 |
+
$candidate_getFinalPrice = $candidate->getPriceModel()->getFinalPrice($request->getQty(), $product);
|
630 |
+
Mage::log("CalculatePrice candidate getFinalPrice: " . $candidate_getFinalPrice, null, 'skyboxcheckout.log', false);
|
631 |
+
|
632 |
+
$_finalPrice = $_finalPrice + $candidate_getFinalPrice;
|
633 |
+
if ($_finalPrice) {
|
634 |
+
break;
|
635 |
+
}
|
636 |
+
}
|
637 |
+
$finalPrice = $_finalPrice;
|
638 |
+
Mage::log("CalculatePrice candidate FIN", null, 'skyboxcheckout.log', false);
|
639 |
+
}
|
640 |
+
|
641 |
+
$volWeight = !empty(trim($product->getDimensionalWeight()))?$product->getDimensionalWeight():0;
|
642 |
+
$_data = array(
|
643 |
+
'object_id' => $product->getId(),
|
644 |
+
'name' => $product->getName(),
|
645 |
+
//'sku' => $product->getSku(),
|
646 |
+
'sku' => $sku,
|
647 |
+
'category_id' => $product->getSkyboxCategoryId(),
|
648 |
+
'final_price' => $finalPrice,
|
649 |
+
'weight' => $weight?$weight:1,
|
650 |
+
'image_url' => $product->getImageUrl(),
|
651 |
+
'typeProduct' => $type,
|
652 |
+
'VolWeight' => $volWeight,
|
653 |
+
'merchantproductid' => $productId
|
654 |
+
);
|
655 |
+
|
656 |
+
// $this->_calculatePrice($_data);
|
657 |
+
break;
|
658 |
+
|
659 |
+
case 'bundle':
|
660 |
+
//$_finalPrice = $product->getTotalBundleItemsPrice($product, $request->getQty());
|
661 |
+
//$finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
|
662 |
+
|
663 |
+
//Mage::log(print_r($product, true), null, 'cart.log', true);
|
664 |
+
//Mage::log("Product: [" . $product->getId() . "] - Class: " . get_class($product), null, 'skyboxcheckout.log', false);
|
665 |
+
|
666 |
+
//Mage::log(print_r($request, true), null, 'cart.log', true);
|
667 |
+
|
668 |
+
$finalPrice = isset($finalPrice) ? $finalPrice : null;
|
669 |
+
$weight = $product->getTypeInstance(true)->getWeight($product);
|
670 |
+
$sku = $product->getSku();
|
671 |
+
|
672 |
+
//if (isset($request) && !$finalPrice) {
|
673 |
+
if (isset($request)) {
|
674 |
+
|
675 |
+
$parentItem = null;
|
676 |
+
$_finalPrice = null;
|
677 |
+
$_weight = 0;
|
678 |
+
|
679 |
+
$cartCandidates = $product->getTypeInstance(true)
|
680 |
+
->prepareForCartAdvanced($request, $product, 'full');
|
681 |
+
|
682 |
+
foreach ($cartCandidates as $candidate) {
|
683 |
+
// Child items can be sticked together only within their parent
|
684 |
+
$stickWithinParent = $candidate->getParentProductId() ? $parentItem : null;
|
685 |
+
$candidate->setStickWithinParent($stickWithinParent);
|
686 |
+
|
687 |
+
if (!$_finalPrice) {
|
688 |
+
$_finalPrice = $candidate->getPriceModel()->getFinalPrice($request->getQty(), $product);
|
689 |
+
//break;
|
690 |
+
}
|
691 |
+
//$_weight = $_weight + $candidate->getPriceModel()->getWeight();
|
692 |
+
$_weight = $_weight + $candidate->getWeight();
|
693 |
+
}
|
694 |
+
|
695 |
+
$finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
|
696 |
+
if ($_weight > 0) {
|
697 |
+
$weight = $_weight;
|
698 |
+
}
|
699 |
+
}
|
700 |
+
|
701 |
+
//Mage::log("weight: " . $weight, null, 'cart.log', true);
|
702 |
+
//Mage::log("sku: " . $sku, null, 'cart.log', true);
|
703 |
+
|
704 |
+
$volWeight = !empty(trim($product->getDimensionalWeight()))?$product->getDimensionalWeight():0;
|
705 |
+
$_data = array(
|
706 |
+
'object_id' => $product->getId(),
|
707 |
+
'name' => $product->getName(),
|
708 |
+
'sku' => $sku,
|
709 |
+
'category_id' => $product->getSkyboxCategoryId(),
|
710 |
+
'final_price' => $finalPrice,
|
711 |
+
'weight' => ($weight)?$weight:1,
|
712 |
+
'image_url' => $product->getImageUrl(),
|
713 |
+
'typeProduct' => $type,
|
714 |
+
'VolWeight' => $volWeight,
|
715 |
+
'merchantproductid' => $productId
|
716 |
+
);
|
717 |
+
// $this->_calculatePrice($_data);
|
718 |
+
break;
|
719 |
+
|
720 |
+
case 'bundle_fixed':
|
721 |
+
$finalPrice = isset($finalPrice) ? $finalPrice : null;
|
722 |
+
$skyboxCategoryId = $product->getSkyboxCategoryId();
|
723 |
+
$weight = $product->getTypeInstance(true)->getWeight($product);
|
724 |
+
$sku = $product->getSku();
|
725 |
+
|
726 |
+
$selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection(
|
727 |
+
$product->getTypeInstance(true)->getOptionsIds($product), $product
|
728 |
+
);
|
729 |
+
|
730 |
+
$_finalPrice = null;
|
731 |
+
$_weight = 0;
|
732 |
+
$_skyboxCategoryId = null;
|
733 |
+
|
734 |
+
foreach ($selectionCollection as $option) {
|
735 |
+
//if ($option->getData('is_default') == 0) continue;
|
736 |
+
|
737 |
+
$product_simple = Mage::getModel('catalog/product')
|
738 |
+
->load($option->getId());
|
739 |
+
|
740 |
+
$_finalPrice = $_finalPrice + $product_simple->getFinalPrice();
|
741 |
+
$_weight = $_weight + $product_simple->getWeight();
|
742 |
+
|
743 |
+
if (!$_skyboxCategoryId) { // Set SkyboxCategory from the first Simple Product
|
744 |
+
$_skyboxCategoryId = $product_simple->getSkyboxCategoryId();
|
745 |
+
}
|
746 |
+
}
|
747 |
+
|
748 |
+
$finalPrice = isset($finalPrice) ? $finalPrice : $_finalPrice;
|
749 |
+
|
750 |
+
if (!$weight) {
|
751 |
+
$weight = $_weight;
|
752 |
+
}
|
753 |
+
|
754 |
+
if (!$skyboxCategoryId) {
|
755 |
+
$skyboxCategoryId = $_skyboxCategoryId;
|
756 |
+
}
|
757 |
+
|
758 |
+
/*Mage::log("-------------------------", null, 'cart.log', true);
|
759 |
+
Mage::log("Product: " . $product->getName(), null, 'cart.log', true);
|
760 |
+
Mage::log("Price: " . $finalPrice, null, 'cart.log', true);
|
761 |
+
Mage::log("weight: " . $weight, null, 'cart.log', true);
|
762 |
+
Mage::log("sku: " . $sku, null, 'cart.log', true);*/
|
763 |
+
|
764 |
+
$volWeight = !empty(trim($product->getDimensionalWeight()))?$product->getDimensionalWeight():0;
|
765 |
+
$_data = array(
|
766 |
+
'object_id' => $product->getId(),
|
767 |
+
'name' => $product->getName(),
|
768 |
+
'sku' => $sku,
|
769 |
+
'category_id' => $skyboxCategoryId,
|
770 |
+
'final_price' => $finalPrice,
|
771 |
+
'weight' => ($weight)?$weight:1,
|
772 |
+
'image_url' => $product->getImageUrl(),
|
773 |
+
'typeProduct' => $type,
|
774 |
+
'VolWeight' => $volWeight,
|
775 |
+
'merchantproductid' => $productId
|
776 |
+
);
|
777 |
+
|
778 |
+
// $this->_calculatePrice($_data);
|
779 |
+
break;
|
780 |
+
|
781 |
+
default:
|
782 |
+
Mage::log("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice", null, 'skyboxcheckout.log', false);
|
783 |
+
trigger_error("CalculatePrice:: Product Type (" . $type . ") is invalid or not supported at SkyboxCheckout CalculatePrice");
|
784 |
+
$defaultSwitch = true;
|
785 |
+
break;
|
786 |
+
}
|
787 |
+
|
788 |
+
if(!$defaultSwitch){
|
789 |
+
//Mage::log(print_r('EnableTax: ', true), null, 'tracer.log', true);
|
790 |
+
//Mage::log(print_r($this->getEnabledAddSumTaxToPrice(), true), null, 'tracer.log', true);
|
791 |
+
if($this->getEnabledAddSumTaxToPrice()) {
|
792 |
+
$store = Mage::app()->getStore('default');
|
793 |
+
$taxCalculation = Mage::getModel('tax/calculation');
|
794 |
+
$request = $taxCalculation->getRateRequest(null, null, null, $store);
|
795 |
+
// $product = Mage::registry('current_product');
|
796 |
+
$taxClassId = $product->getTaxClassId();
|
797 |
+
$percentTax = $taxCalculation->getRate($request->setProductClassId($taxClassId));
|
798 |
+
|
799 |
+
$taxPrice = $_data['final_price'] * ($percentTax / 100);
|
800 |
+
|
801 |
+
//Mage::log(print_r('Id product: ' . $product->getId(), true), null, 'tracer.log', true);
|
802 |
+
//Mage::log(print_r('$taxPrice: ' . $taxPrice, true), null, 'tracer.log', true);
|
803 |
+
//Mage::log(print_r('price: ' . $_data['final_price'], true), null, 'tracer.log', true);
|
804 |
+
//Mage::log(print_r('$taxPrice+price: ' . ($taxPrice + $_data['final_price']), true), null, 'tracer.log', true);
|
805 |
+
$comissionSkybox = $_data['final_price'] * (10 / 100);
|
806 |
+
//Mage::log(print_r('comision skybox: ' . ($comissionSkybox), true), null, 'tracer.log', true);
|
807 |
+
//Mage::log(print_r('price+comision skybox: ' . ($_data['final_price'] + $comissionSkybox), true), null, 'tracer.log', true);
|
808 |
+
//Mage::log(print_r('$taxPrice+price+comision: ' . ($taxPrice + $_data['final_price'] + $comissionSkybox), true), null, 'tracer.log', true);
|
809 |
+
//Mage::log(print_r('comision true: ' . (($taxPrice + $_data['final_price']) * (10 / 100)), true), null, 'tracer.log', true);
|
810 |
+
$priceReally = ($taxPrice + $_data['final_price']) + ($taxPrice + $_data['final_price']) * (10 / 100);
|
811 |
+
//Mage::log(print_r('$taxPrice+price+comision true: ' . ($priceReally), true), null, 'tracer.log', true);
|
812 |
+
$_data['final_price'] = $_data['final_price'] + $taxPrice;
|
813 |
+
}
|
814 |
+
|
815 |
+
//Mage::log(print_r('####################### Data produc params #######################', true), null, 'tracer.log', true);
|
816 |
+
//Mage::log(print_r($_data, true), null, 'tracer.log', true);
|
817 |
+
$this->_calculatePrice($_data);
|
818 |
+
}
|
819 |
+
|
820 |
+
Mage::log("Product Class: " . get_class($product), null, 'skyboxcheckout.log', false);
|
821 |
+
Mage::log("Product Type: " . $type, null, 'skyboxcheckout.log', false);
|
822 |
+
Mage::log(print_r($_data, true), null, 'skyboxcheckout.log', false);
|
823 |
+
|
824 |
+
$data = $this->_callServiceSky($_data);
|
825 |
+
/*var_dump($this); exit;
|
826 |
+
$this->_product_data = $_data;
|
827 |
+
$this->_product_id = $productId;
|
828 |
+
$apiData = $this->_api;
|
829 |
+
var_dump($apiData); exit;*/
|
830 |
+
return $data;
|
831 |
+
}
|
832 |
+
|
833 |
+
private function _callServiceSky($data)
|
834 |
+
{
|
835 |
+
$msg = sprintf("CalculatePrice: [%s] - [%s] - [%s] - [Category_id: %s] - [Price: %s] - [weight: %s] - [typeProduct: %s]",
|
836 |
+
$data['object_id'],
|
837 |
+
$data['sku'],
|
838 |
+
$data['name'],
|
839 |
+
$data['category_id'],
|
840 |
+
$data['final_price'],
|
841 |
+
$data['weight'],
|
842 |
+
$data['typeProduct']
|
843 |
+
);
|
844 |
+
|
845 |
+
$params = array(
|
846 |
+
'htmlobjectid' => $data['object_id'],
|
847 |
+
'code' => $data['sku'],
|
848 |
+
'name' => $data['name'],
|
849 |
+
'category' => $data['category_id'],
|
850 |
+
'price' => $data['final_price'],
|
851 |
+
//'storeproductprice' => $product->getFinalPrice(),
|
852 |
+
'weight' => ($data['weight'])?$data['weight']:1,
|
853 |
+
'weightunit' => $this->getWeightUnit(),
|
854 |
+
'imgurl' => $data['image_url'],
|
855 |
+
/*'volweight' => $data['VolWeight'],
|
856 |
+
'merchantproductid' => $data['merchantproductid']*/
|
857 |
+
);
|
858 |
+
//var_dump($params); exit;
|
859 |
+
return $params;
|
860 |
+
}
|
861 |
+
|
862 |
+
/*Async End*/
|
863 |
}
|
app/code/community/Skybox/Catalog/Model/Observer.php
CHANGED
@@ -16,22 +16,44 @@
|
|
16 |
*/
|
17 |
class Skybox_Catalog_Model_Observer
|
18 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
public function hookToControllerActionPreDispatch($observer)
|
20 |
{
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
Mage::dispatchEvent("add_to_cart_before", array('request' => $observer->getControllerAction()->getRequest()));
|
23 |
}
|
24 |
}
|
25 |
|
26 |
public function hookToControllerActionPostDispatch($observer)
|
27 |
{
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
Mage::dispatchEvent("add_to_cart_after", array('request' => $observer->getControllerAction()->getRequest()));
|
30 |
}
|
31 |
}
|
32 |
|
33 |
public function hookToAddToCartBefore($observer)
|
34 |
{
|
|
|
|
|
|
|
|
|
35 |
$key = Mage::getSingleton('core/session')->getFormKey();
|
36 |
$observer->getEvent()->getRequest()->setParam('form_key', $key);
|
37 |
$request = $observer->getEvent()->getRequest()->getParams();
|
@@ -39,12 +61,18 @@ class Skybox_Catalog_Model_Observer
|
|
39 |
|
40 |
public function hookToAddToCartAfter($observer)
|
41 |
{
|
|
|
|
|
|
|
42 |
$request = $observer->getEvent()->getRequest()->getParams();
|
43 |
-
|
44 |
}
|
45 |
|
46 |
public function injectTab(Varien_Event_Observer $observer)
|
47 |
{
|
|
|
|
|
|
|
48 |
// core_block_abstract_prepare_layout_after
|
49 |
|
50 |
/* $block Mage_Adminhtml_Block_Catalog_Category_Tabs */
|
16 |
*/
|
17 |
class Skybox_Catalog_Model_Observer
|
18 |
{
|
19 |
+
private function getActive() {
|
20 |
+
// $value = (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
|
21 |
+
$value = Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
22 |
+
return $value;
|
23 |
+
}
|
24 |
+
|
25 |
public function hookToControllerActionPreDispatch($observer)
|
26 |
{
|
27 |
+
$active = $this->getActive();
|
28 |
+
if (!$active) { return; }
|
29 |
+
|
30 |
+
//Mage::log('router tivoli: '.$observer->getEvent()->getControllerAction()->getFullActionName(), null, 'tracer.log', true);
|
31 |
+
if (($observer->getEvent()->getControllerAction()->getFullActionName() == 'checkout_cart_add')) {
|
32 |
+
|
33 |
+
//Mage::log('hookToControllerActionPreDispatch '.$observer->getEvent()->getControllerAction()->getFullActionName(),null, 'tracer.log', true);
|
34 |
Mage::dispatchEvent("add_to_cart_before", array('request' => $observer->getControllerAction()->getRequest()));
|
35 |
}
|
36 |
}
|
37 |
|
38 |
public function hookToControllerActionPostDispatch($observer)
|
39 |
{
|
40 |
+
$active = $this->getActive();
|
41 |
+
if (!$active) { return; }
|
42 |
+
|
43 |
+
//Mage::log('router tivoli: '.$observer->getEvent()->getControllerAction()->getFullActionName(), null, 'tracer.log', true);
|
44 |
+
if (($observer->getEvent()->getControllerAction()->getFullActionName() == 'checkout_cart_add')) {
|
45 |
+
|
46 |
+
//Mage::log('hookToControllerActionPostDispatch: '.$observer->getEvent()->getControllerAction()->getFullActionName(),null, 'tracer.log', true);
|
47 |
Mage::dispatchEvent("add_to_cart_after", array('request' => $observer->getControllerAction()->getRequest()));
|
48 |
}
|
49 |
}
|
50 |
|
51 |
public function hookToAddToCartBefore($observer)
|
52 |
{
|
53 |
+
$active = $this->getActive();
|
54 |
+
if (!$active) { return; }
|
55 |
+
|
56 |
+
//Mage::log('function hookToAddToCartBefore: ',null, 'tracer.log', true);
|
57 |
$key = Mage::getSingleton('core/session')->getFormKey();
|
58 |
$observer->getEvent()->getRequest()->setParam('form_key', $key);
|
59 |
$request = $observer->getEvent()->getRequest()->getParams();
|
61 |
|
62 |
public function hookToAddToCartAfter($observer)
|
63 |
{
|
64 |
+
$active = $this->getActive();
|
65 |
+
if (!$active) { return; }
|
66 |
+
|
67 |
$request = $observer->getEvent()->getRequest()->getParams();
|
68 |
+
Mage::log("hookToAddToCartAfter ".print_r($request,true)." is added to cart.", null, 'cart.log', true);
|
69 |
}
|
70 |
|
71 |
public function injectTab(Varien_Event_Observer $observer)
|
72 |
{
|
73 |
+
// $active = $this->getActive();
|
74 |
+
// if (!$active) { return; }
|
75 |
+
|
76 |
// core_block_abstract_prepare_layout_after
|
77 |
|
78 |
/* $block Mage_Adminhtml_Block_Catalog_Category_Tabs */
|
app/code/community/Skybox/Catalog/etc/config.xml
CHANGED
@@ -1,5 +1,11 @@
|
|
1 |
<?xml version="1.0" encoding="utf-8"?>
|
2 |
<config>
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
<modules>
|
4 |
<Skybox_Catalog>
|
5 |
<version>0.1.0</version>
|
@@ -16,6 +22,7 @@
|
|
16 |
<rewrite>
|
17 |
<product_price>Skybox_Catalog_Block_Product_Price</product_price>
|
18 |
<product_widget_new>Skybox_Catalog_Block_Product_Widget_New</product_widget_new>
|
|
|
19 |
</rewrite>
|
20 |
</catalog>
|
21 |
<bundle>
|
1 |
<?xml version="1.0" encoding="utf-8"?>
|
2 |
<config>
|
3 |
+
<default>
|
4 |
+
<settings>
|
5 |
+
<typeIntegration>1</typeIntegration>
|
6 |
+
<codeShop>00248</codeShop>
|
7 |
+
</settings>
|
8 |
+
</default>
|
9 |
<modules>
|
10 |
<Skybox_Catalog>
|
11 |
<version>0.1.0</version>
|
22 |
<rewrite>
|
23 |
<product_price>Skybox_Catalog_Block_Product_Price</product_price>
|
24 |
<product_widget_new>Skybox_Catalog_Block_Product_Widget_New</product_widget_new>
|
25 |
+
<product_list>Skybox_Catalog_Block_Product_List</product_list>
|
26 |
</rewrite>
|
27 |
</catalog>
|
28 |
<bundle>
|
app/code/community/Skybox/Checkout/Block/Cart/Totals.php
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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@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 Mage
|
22 |
+
* @package Mage_Checkout
|
23 |
+
* @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Skybox_Checkout_Block_Cart_Totals extends Mage_Checkout_Block_Cart_Abstract
|
28 |
+
{
|
29 |
+
protected $_totalRenderers;
|
30 |
+
protected $_defaultRenderer = 'checkout/total_default';
|
31 |
+
protected $_totals = null;
|
32 |
+
|
33 |
+
public function getTotals()
|
34 |
+
{
|
35 |
+
if (is_null($this->_totals)) {
|
36 |
+
return parent::getTotals();
|
37 |
+
}
|
38 |
+
return $this->_totals;
|
39 |
+
}
|
40 |
+
|
41 |
+
public function setTotals($value)
|
42 |
+
{
|
43 |
+
$this->_totals = $value;
|
44 |
+
return $this;
|
45 |
+
}
|
46 |
+
|
47 |
+
protected function _getTotalRenderer($code)
|
48 |
+
{
|
49 |
+
$blockName = $code.'_total_renderer';
|
50 |
+
$block = $this->getLayout()->getBlock($blockName);
|
51 |
+
if (!$block) {
|
52 |
+
$block = $this->_defaultRenderer;
|
53 |
+
$config = Mage::getConfig()->getNode("global/sales/quote/totals/{$code}/renderer");
|
54 |
+
if ($config) {
|
55 |
+
$block = (string) $config;
|
56 |
+
}
|
57 |
+
|
58 |
+
$block = $this->getLayout()->createBlock($block, $blockName);
|
59 |
+
}
|
60 |
+
/**
|
61 |
+
* Transfer totals to renderer
|
62 |
+
*/
|
63 |
+
$block->setTotals($this->getTotals());
|
64 |
+
return $block;
|
65 |
+
}
|
66 |
+
|
67 |
+
public function renderTotal($total, $area = null, $colspan = 1)
|
68 |
+
{
|
69 |
+
$code = $total->getCode();
|
70 |
+
if($code!="subtotal") {
|
71 |
+
|
72 |
+
if ($total->getAs()) {
|
73 |
+
$code = $total->getAs();
|
74 |
+
}
|
75 |
+
return $this->_getTotalRenderer($code)
|
76 |
+
->setTotal($total)
|
77 |
+
->setColspan($colspan)
|
78 |
+
->setRenderingArea(is_null($area) ? -1 : $area)
|
79 |
+
->toHtml();
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Render totals html for specific totals area (footer, body)
|
85 |
+
*
|
86 |
+
* @param null|string $area
|
87 |
+
* @param int $colspan
|
88 |
+
* @return string
|
89 |
+
*/
|
90 |
+
public function renderTotals($area = null, $colspan = 1)
|
91 |
+
{
|
92 |
+
$html = '';
|
93 |
+
foreach($this->getTotals() as $total) {
|
94 |
+
if ($total->getArea() != $area && $area != -1) {
|
95 |
+
continue;
|
96 |
+
}
|
97 |
+
$html .= $this->renderTotal($total, $area, $colspan);
|
98 |
+
}
|
99 |
+
return $html;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Check if we have display grand total in base currency
|
104 |
+
*
|
105 |
+
* @return bool
|
106 |
+
*/
|
107 |
+
public function needDisplayBaseGrandtotal()
|
108 |
+
{
|
109 |
+
$quote = $this->getQuote();
|
110 |
+
if ($quote->getBaseCurrencyCode() != $quote->getQuoteCurrencyCode()) {
|
111 |
+
return true;
|
112 |
+
}
|
113 |
+
return false;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Get formated in base currency base grand total value
|
118 |
+
*
|
119 |
+
* @return string
|
120 |
+
*/
|
121 |
+
public function displayBaseGrandtotal()
|
122 |
+
{
|
123 |
+
$firstTotal = reset($this->_totals);
|
124 |
+
if ($firstTotal) {
|
125 |
+
$total = $firstTotal->getAddress()->getBaseGrandTotal();
|
126 |
+
return Mage::app()->getStore()->getBaseCurrency()->format($total, array(), true);
|
127 |
+
}
|
128 |
+
return '-';
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Get active or custom quote
|
133 |
+
*
|
134 |
+
* @return Mage_Sales_Model_Quote
|
135 |
+
*/
|
136 |
+
public function getQuote()
|
137 |
+
{
|
138 |
+
if ($this->getCustomQuote()) {
|
139 |
+
return $this->getCustomQuote();
|
140 |
+
}
|
141 |
+
|
142 |
+
if (null === $this->_quote) {
|
143 |
+
$this->_quote = $this->getCheckout()->getQuote();
|
144 |
+
}
|
145 |
+
return $this->_quote;
|
146 |
+
}
|
147 |
+
}
|
app/code/community/Skybox/Checkout/Block/Checkout/Cart.php
ADDED
@@ -0,0 +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 |
+
}
|
app/code/community/Skybox/Checkout/Block/Checkout/Cart/Sidebar.php
ADDED
@@ -0,0 +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 |
+
}
|
app/code/community/Skybox/Checkout/Block/Checkout/Links.php
ADDED
@@ -0,0 +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 |
+
}
|
app/code/community/Skybox/Checkout/Block/Checkout/Onepage/Link.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
if($isEnabled) {
|
12 |
+
return $this->getUrl('skbcheckout/international', array('_secure'=>true));
|
13 |
+
}
|
14 |
+
/*
|
15 |
+
if (Mage::helper('onestepcheckout')->isRewriteCheckoutLinksEnabled()){
|
16 |
+
return $this->getUrl('onestepcheckout', array('_secure'=>true));
|
17 |
+
}
|
18 |
+
*/
|
19 |
+
/*
|
20 |
+
Mage::log('get getCheckoutUrl skybox', null, 'tracer.log', true);
|
21 |
+
if (!$this->helper('checkout')->isRewriteCheckoutLinksEnabled()){
|
22 |
+
return parent::getCheckoutUrl();
|
23 |
+
}
|
24 |
+
*/
|
25 |
+
|
26 |
+
return parent::getCheckoutUrl();
|
27 |
+
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Skybox/Checkout/Block/Sales/Order/Total.php
CHANGED
@@ -14,20 +14,32 @@ class Skybox_Checkout_Block_Sales_Order_Total extends Mage_Sales_Block_Order_Tot
|
|
14 |
|
15 |
parent::_initTotals();
|
16 |
$order= $this->getOrder();
|
|
|
|
|
|
|
|
|
17 |
$ConceptsSkyboxjson=json_decode($order->getConceptsSkybox());
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
$
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
}
|
32 |
}
|
33 |
}
|
14 |
|
15 |
parent::_initTotals();
|
16 |
$order= $this->getOrder();
|
17 |
+
|
18 |
+
//Mage::log('$order', null, 'tracer.log', true);
|
19 |
+
//Mage::log(print_r($order->debug(), true), null, 'tracer.log', true);
|
20 |
+
|
21 |
$ConceptsSkyboxjson=json_decode($order->getConceptsSkybox());
|
22 |
|
23 |
+
//Mage::log('$ConceptsSkyboxjson', null, 'tracer.log', true);
|
24 |
+
// Mage::log(print_r($ConceptsSkyboxjson, true), null, 'tracer.log', true);
|
25 |
+
if(count($ConceptsSkyboxjson)>0){
|
26 |
+
|
27 |
+
$i = 0;
|
28 |
+
foreach ($ConceptsSkyboxjson as $item) {
|
29 |
+
if($item->Visible != 0)
|
30 |
+
{
|
31 |
+
$i+=1;
|
32 |
+
$this->getParentBlock()->addTotal(new Varien_Object(array(
|
33 |
+
'code'=> 'checkout_total'.$i,
|
34 |
+
'value'=> $item->ValueUSD,//$item->Value
|
35 |
+
'base_value'=> $item->ValueUSD,//$item->Value
|
36 |
+
'label'=> $item->Concept,
|
37 |
+
)), 'subtotal', 'tax');
|
38 |
+
}
|
39 |
+
}
|
40 |
+
if($order->getShippingAmount() == 0){
|
41 |
+
$this->getParentBlock()->removeTotal('shipping');
|
42 |
+
}
|
43 |
}
|
44 |
}
|
45 |
}
|
app/code/community/Skybox/Checkout/Helper/Data.php
CHANGED
@@ -9,6 +9,7 @@
|
|
9 |
*/
|
10 |
class Skybox_Checkout_Helper_Data extends Mage_Checkout_Helper_Data
|
11 |
{
|
|
|
12 |
protected function _getApi()
|
13 |
{
|
14 |
if (null === $this->_api) {
|
@@ -18,19 +19,23 @@ class Skybox_Checkout_Helper_Data extends Mage_Checkout_Helper_Data
|
|
18 |
}
|
19 |
public function formatPrice($price)
|
20 |
{
|
|
|
|
|
|
|
21 |
/* @var $config Skybox_Core_Model_Config */
|
22 |
/*$config = Mage::getModel("skyboxcore/config");
|
23 |
$skybox_user = $config->getSession()->getSkyboxUser();
|
24 |
$currency = $skybox_user->CartCurrencySymbol;
|
25 |
//return '<span class="price">' . $currency . ' ' . number_format($price, 2) . '</span>';
|
26 |
return '<span class="price">' . $currency . ' ' . $price . '</span>';*/
|
27 |
-
/* @var $config Skybox_Core_Model_Config */
|
28 |
-
|
29 |
|
30 |
|
31 |
$config = Mage::getModel("skyboxcore/config");
|
32 |
-
$skybox_user = $config->getSession()->getSkyboxUser();
|
33 |
-
|
|
|
|
|
34 |
$currency = $skybox_user->CartCurrencySymbol; // Rogged
|
35 |
}else{ // Rogged
|
36 |
$currency = Mage::app()->getLocale()->currency( $currency_code )->getSymbol(); // Rogged
|
@@ -40,26 +45,66 @@ class Skybox_Checkout_Helper_Data extends Mage_Checkout_Helper_Data
|
|
40 |
$price=str_replace(',', '', $price);
|
41 |
//Mage::log("precio".$price, null, 'cartlabels.log', true);
|
42 |
$price=Mage::getModel('directory/currency')->setData("currency_code",
|
43 |
-
|
44 |
-
|
45 |
|
46 |
if ($price < 0) return '<span class="price">('.$currency." ".-1*$price.')</span>';
|
47 |
return '<span class="price">'.$currency." ".$price.'</span>';
|
48 |
|
49 |
}
|
|
|
50 |
/**
|
51 |
-
*
|
52 |
-
*
|
53 |
-
* @return Skybox_Catalog_Model_Api_Product
|
54 |
*/
|
55 |
-
|
56 |
public function getLayoutCheckoutSkybox(){ // Rogged
|
57 |
$page_layout = Mage::getStoreConfig('customize_your_own');
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
if($this->_getApi()->getLocationAllow()){
|
59 |
$page_layout = 'skybox/checkout/onepage.phtml';
|
60 |
}else{
|
61 |
$page_layout = 'checkout/onepage.phtml';
|
62 |
}
|
|
|
|
|
|
|
63 |
return $page_layout;
|
64 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
}
|
9 |
*/
|
10 |
class Skybox_Checkout_Helper_Data extends Mage_Checkout_Helper_Data
|
11 |
{
|
12 |
+
protected $_api = null;
|
13 |
protected function _getApi()
|
14 |
{
|
15 |
if (null === $this->_api) {
|
19 |
}
|
20 |
public function formatPrice($price)
|
21 |
{
|
22 |
+
if(!$this->isRewriteCheckoutLinksEnabled()){
|
23 |
+
return parent::formatPrice($price);
|
24 |
+
}
|
25 |
/* @var $config Skybox_Core_Model_Config */
|
26 |
/*$config = Mage::getModel("skyboxcore/config");
|
27 |
$skybox_user = $config->getSession()->getSkyboxUser();
|
28 |
$currency = $skybox_user->CartCurrencySymbol;
|
29 |
//return '<span class="price">' . $currency . ' ' . number_format($price, 2) . '</span>';
|
30 |
return '<span class="price">' . $currency . ' ' . $price . '</span>';*/
|
31 |
+
/* @var $config Skybox_Core_Model_Config */
|
|
|
32 |
|
33 |
|
34 |
$config = Mage::getModel("skyboxcore/config");
|
35 |
+
$skybox_user = $config->getSession()->getSkyboxUser();
|
36 |
+
/*LocationAllow3*/
|
37 |
+
$typeIntegration = Mage::getStoreConfig('settings/typeIntegration');
|
38 |
+
if($this->_getApi()->getLocationAllow() && ($typeIntegration!=3)){ // Rogged
|
39 |
$currency = $skybox_user->CartCurrencySymbol; // Rogged
|
40 |
}else{ // Rogged
|
41 |
$currency = Mage::app()->getLocale()->currency( $currency_code )->getSymbol(); // Rogged
|
45 |
$price=str_replace(',', '', $price);
|
46 |
//Mage::log("precio".$price, null, 'cartlabels.log', true);
|
47 |
$price=Mage::getModel('directory/currency')->setData("currency_code",
|
48 |
+
Mage::app()->getStore(null)->getCurrentCurrency()->getCode())->format(
|
49 |
+
$price, array('display' =>Zend_Currency::NO_SYMBOL), false);
|
50 |
|
51 |
if ($price < 0) return '<span class="price">('.$currency." ".-1*$price.')</span>';
|
52 |
return '<span class="price">'.$currency." ".$price.'</span>';
|
53 |
|
54 |
}
|
55 |
+
|
56 |
/**
|
57 |
+
* @deprecated
|
|
|
|
|
58 |
*/
|
|
|
59 |
public function getLayoutCheckoutSkybox(){ // Rogged
|
60 |
$page_layout = Mage::getStoreConfig('customize_your_own');
|
61 |
+
|
62 |
+
/*LocationAllow3*/
|
63 |
+
$active = 0;
|
64 |
+
if(isset($_GET['v'])) {
|
65 |
+
$active = 1;
|
66 |
+
}
|
67 |
if($this->_getApi()->getLocationAllow()){
|
68 |
$page_layout = 'skybox/checkout/onepage.phtml';
|
69 |
}else{
|
70 |
$page_layout = 'checkout/onepage.phtml';
|
71 |
}
|
72 |
+
if($active) {
|
73 |
+
$page_layout = 'checkout/onepage.phtml';
|
74 |
+
}
|
75 |
return $page_layout;
|
76 |
}
|
77 |
+
|
78 |
+
public function isRewriteCheckoutLinksEnabled()
|
79 |
+
{
|
80 |
+
// return (bool)Mage::getStoreConfig('skyboxinternational/skyboxsettings/skyboxactive', Mage::app()->getStore());
|
81 |
+
return Mage::getModel('skyboxcore/api_restful')->isModuleEnable();
|
82 |
+
}
|
83 |
+
|
84 |
+
public function concatNameDetailProduct($product, $sku = null)
|
85 |
+
{
|
86 |
+
Mage::log('concatNameDetailProduct', null, 'tracer.log');
|
87 |
+
$attributesConcat = '';
|
88 |
+
if($product->getData('type_id') == 'configurable'){
|
89 |
+
$options = $this->getAllAttributesVariantConfigurableProducts($product);
|
90 |
+
$attributesData = $options[$product->getId()][$sku];
|
91 |
+
$attributesConcat = implode(', ', $attributesData);
|
92 |
+
}
|
93 |
+
return $attributesConcat;
|
94 |
+
}
|
95 |
+
|
96 |
+
public function getAllAttributesVariantConfigurableProducts($configurableProduct)
|
97 |
+
{
|
98 |
+
$attributes = array();
|
99 |
+
$productAttributesOptions = $configurableProduct->getTypeInstance(true)->getConfigurableOptions($configurableProduct);
|
100 |
+
foreach ($productAttributesOptions as $productAttributeOption) {
|
101 |
+
$attributes[$configurableProduct->getId()] = array();
|
102 |
+
foreach ($productAttributeOption as $optionValues) {
|
103 |
+
$val = ($optionValues['option_title']);
|
104 |
+
$attributes[$configurableProduct->getId()][$optionValues['sku']][] = $optionValues['attribute_code'].'-'.$val;
|
105 |
+
}
|
106 |
+
}
|
107 |
+
Mage::log(print_r($attributes, true), null, 'tracer.log');
|
108 |
+
return $attributes;
|
109 |
+
}
|
110 |
}
|
app/code/community/Skybox/Checkout/Helper/Url.php
ADDED
@@ -0,0 +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 |
+
}
|
app/code/community/Skybox/Checkout/Model/Api/Checkout.php
CHANGED
@@ -16,6 +16,8 @@ class Skybox_Checkout_Model_Api_Checkout extends Skybox_Core_Model_Standard
|
|
16 |
*/
|
17 |
protected $_product = null;
|
18 |
|
|
|
|
|
19 |
protected $_typeProduct = "catalog/product";
|
20 |
|
21 |
public function getProduct()
|
@@ -55,14 +57,28 @@ class Skybox_Checkout_Model_Api_Checkout extends Skybox_Core_Model_Standard
|
|
55 |
//}
|
56 |
}
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
public function AddProductOfCart($data, $quantity)
|
59 |
{
|
|
|
|
|
|
|
60 |
if ($this->getErrorAuthenticate() && !$this->getLocationAllow()) {
|
61 |
return $this;
|
62 |
}
|
63 |
|
64 |
Mage::log("AddProductOfCart: " . print_r($data, true), null, 'skyboxcheckout.log', true);
|
65 |
|
|
|
|
|
66 |
$params = array(
|
67 |
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
68 |
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
|
@@ -70,12 +86,14 @@ class Skybox_Checkout_Model_Api_Checkout extends Skybox_Core_Model_Standard
|
|
70 |
'productid' => "0",
|
71 |
'quantity' => $quantity,
|
72 |
'storeproductcode' => $data['sku'],
|
73 |
-
'storeproductname' => $
|
74 |
'storeproductcategory' => $data['category_id'],
|
75 |
'storeproductprice' => $data['final_price'],
|
76 |
-
'weight' =>
|
77 |
'weightunit' => $this->getWeightUnit(),
|
78 |
-
'storeproductimgurl' => $data['image_url
|
|
|
|
|
79 |
);
|
80 |
$this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_ADD_PRODUCT_CART, $params);
|
81 |
|
@@ -95,7 +113,7 @@ class Skybox_Checkout_Model_Api_Checkout extends Skybox_Core_Model_Standard
|
|
95 |
);
|
96 |
|
97 |
$this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_GET_TOTAL_SHOPINGCART, $params);
|
98 |
-
|
99 |
return $this;
|
100 |
}
|
101 |
|
@@ -144,6 +162,10 @@ class Skybox_Checkout_Model_Api_Checkout extends Skybox_Core_Model_Standard
|
|
144 |
return "";
|
145 |
}
|
146 |
|
|
|
|
|
|
|
|
|
147 |
/*
|
148 |
* Get Categories
|
149 |
*
|
@@ -162,4 +184,26 @@ class Skybox_Checkout_Model_Api_Checkout extends Skybox_Core_Model_Standard
|
|
162 |
$jsonData = $response->getResponse()->{'Categories'};
|
163 |
return $jsonData;
|
164 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
}
|
16 |
*/
|
17 |
protected $_product = null;
|
18 |
|
19 |
+
protected $_currentProduct = null;
|
20 |
+
|
21 |
protected $_typeProduct = "catalog/product";
|
22 |
|
23 |
public function getProduct()
|
57 |
//}
|
58 |
}
|
59 |
|
60 |
+
public function setCurrentProduct($product)
|
61 |
+
{
|
62 |
+
$this->_currentProduct = $product;
|
63 |
+
}
|
64 |
+
public function getCurrentProduct()
|
65 |
+
{
|
66 |
+
return $this->_currentProduct;
|
67 |
+
}
|
68 |
+
|
69 |
public function AddProductOfCart($data, $quantity)
|
70 |
{
|
71 |
+
$detailProduct = Mage::helper('checkout')->concatNameDetailProduct($this->getCurrentProduct(), $data['sku']);
|
72 |
+
|
73 |
+
//Mage::log("entro AddProductOfCart", null, 'tracer.log', true);
|
74 |
if ($this->getErrorAuthenticate() && !$this->getLocationAllow()) {
|
75 |
return $this;
|
76 |
}
|
77 |
|
78 |
Mage::log("AddProductOfCart: " . print_r($data, true), null, 'skyboxcheckout.log', true);
|
79 |
|
80 |
+
$storeProductName = $data['name'].' '.$detailProduct;
|
81 |
+
|
82 |
$params = array(
|
83 |
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
84 |
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
|
86 |
'productid' => "0",
|
87 |
'quantity' => $quantity,
|
88 |
'storeproductcode' => $data['sku'],
|
89 |
+
'storeproductname' => $storeProductName,
|
90 |
'storeproductcategory' => $data['category_id'],
|
91 |
'storeproductprice' => $data['final_price'],
|
92 |
+
'weight' => ($data['weight'])?($data['weight']):1,
|
93 |
'weightunit' => $this->getWeightUnit(),
|
94 |
+
'storeproductimgurl' => $data['image_url'],
|
95 |
+
'VolWeight' => $data['VolWeight'],
|
96 |
+
'merchantproductid' => $data['merchantproductid']
|
97 |
);
|
98 |
$this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_ADD_PRODUCT_CART, $params);
|
99 |
|
113 |
);
|
114 |
|
115 |
$this->CallApiRest(Skybox_Core_Model_Config::SKYBOX_ACTION_GET_TOTAL_SHOPINGCART, $params);
|
116 |
+
|
117 |
return $this;
|
118 |
}
|
119 |
|
162 |
return "";
|
163 |
}
|
164 |
|
165 |
+
public function getStoreCode() {
|
166 |
+
return 77;
|
167 |
+
}
|
168 |
+
|
169 |
/*
|
170 |
* Get Categories
|
171 |
*
|
184 |
$jsonData = $response->getResponse()->{'Categories'};
|
185 |
return $jsonData;
|
186 |
}
|
187 |
+
|
188 |
+
public function getValueAccessService()
|
189 |
+
{
|
190 |
+
$params = array(
|
191 |
+
"merchantCode" => $this->getMerchant(),
|
192 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_TOKEN => $this->getAuthorizedToken(),
|
193 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_GUID => $this->getGuidApi(),
|
194 |
+
|
195 |
+
Skybox_Core_Model_Config::SKYBOX_PARAMETER_MERCHANT => $this->getMerchant(),
|
196 |
+
'customeriplocal' => $this->_getConfig()->getHost(),
|
197 |
+
'customeripremote' => $this->_getConfig()->getRemoteAddr(),
|
198 |
+
'customeripproxy' => $this->_getConfig()->getProxy(),
|
199 |
+
'customerbrowser' => $this->_getConfig()->getUserAgent(),
|
200 |
+
'customerlanguages' => $this->_getConfig()->getLanguage()
|
201 |
+
|
202 |
+
|
203 |
+
);
|
204 |
+
|
205 |
+
|
206 |
+
return $params;
|
207 |
+
|
208 |
+
}
|
209 |
}
|
app/code/community/Skybox/Checkout/Model/Carrier.php
ADDED
@@ -0,0 +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(
|