Version Notes
[2.6.0 - October 24, 2016]
Refactor code to comply to Magento coding standards
Remove compress functionality
Only one carrier available for new installations
[2.5.24 - September 07, 2016]
Update documentation
[2.5.23 - August 18, 2016]
Fix special functions call issue: missing opening parenthesis
[2.5.22 - July 18, 2016]
Add composer.json and modman files
[2.5.21 - May 9, 2016]
Fix replacement of special functions, thanks to Sébastien L.
[2.5.20 - 25 avril 2016]
Fix code indentation
Fix version number
Add readme file in package
[2.5.19 - 09 novembre 2015]
Note: the extension is not affected by the patch SUPEE-6788 since it uses the new admin url routing syntax for 3 years (version 2.4.8.0)
Fix bug: deactivation of auto-escaping by default since it can cause some bugs (ex: impossible to use {address_filter.EU-27} in shipto)
Fix bug: fix auto-escaping of properties like {{shipto.country_name}}
Fix bug: variable replacements in labels (variables {cart.price-tax-discount}, {cart.price-tax+discount}, {cart.price+tax-discount} and {cart.price+tax+discount})
Fix bug: use items and not quote to retrieve values {cart.price-tax-discount}, {cart.price-tax+discount}, {cart.price+tax-discount} and {cart.price+tax+discount} (quote totals are not available at this time, calculating them causes duplications of addresses and a false grand_total value)
Fix bug: retrieve customer in backoffice order
Fix unicode accented chars in json_encode for PHP < 5.4
Fix bug: usage of regular expressions inside {count ...}, {sum ...}, {min ...} and {max ...}
Allow usage of php functions date and strtotime (ex: "label": "'Your package will be delivered between ' . date('d/m', strtotime('+5 days')) . ' and ' . date('d/m Y', strtotime('+7 days'))",
Release Info
Developer | owebia |
Extension | Owebia_Shipping_2 |
Version | 2.6.0 |
Comparing to | |
See all releases |
Code changes from version 2.5.24 to 2.6.0
- app/code/community/Owebia/Shipping2/Block/Adminhtml/Os2/Editor.php +138 -130
- app/code/community/Owebia/Shipping2/Block/Adminhtml/Os2/Editor/Property/Input.php +7 -19
- app/code/community/Owebia/Shipping2/Block/Adminhtml/Os2/Help.php +20 -72
- app/code/community/Owebia/Shipping2/Block/Adminhtml/System/Config/Form/Field/Config.php +35 -50
- app/code/community/Owebia/Shipping2/Block/Adminhtml/System/Config/Form/Field/Informations.php +8 -19
- app/code/community/Owebia/Shipping2/Controller/Abstract.php +72 -64
- app/code/community/Owebia/Shipping2/Helper/Data.php +101 -106
- app/code/community/Owebia/Shipping2/Model/AddressFilterParser.php +188 -0
- app/code/community/Owebia/Shipping2/Model/Carrier/Abstract.php +66 -93
- app/code/community/Owebia/Shipping2/Model/Carrier/OwebiaShipping1.php +3 -18
- app/code/community/Owebia/Shipping2/Model/Carrier/OwebiaShipping2.php +3 -18
- app/code/community/Owebia/Shipping2/Model/Carrier/OwebiaShipping3.php +0 -25
- app/code/community/Owebia/Shipping2/Model/ConfigParser.php +1940 -0
- app/code/community/Owebia/Shipping2/Model/Mysql4/Setup.php +0 -24
- app/code/community/Owebia/Shipping2/Model/Os2/Data.php +41 -0
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Abstract.php +14 -39
- app/code/community/Owebia/Shipping2/Model/Os2/Data/AbstractWithAttributes.php +16 -34
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Address.php +5 -20
- app/code/community/Owebia/Shipping2/Model/Os2/Data/AddressFilter.php +42 -30
- app/code/community/Owebia/Shipping2/Model/Os2/Data/AttributeSet.php +5 -20
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Billto.php +3 -18
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Cart.php +51 -64
- app/code/community/Owebia/Shipping2/Model/Os2/Data/CartItem.php +34 -73
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Category.php +5 -20
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Customer.php +12 -25
- app/code/community/Owebia/Shipping2/Model/Os2/Data/CustomerGroup.php +31 -40
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Customvar.php +3 -18
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Date.php +26 -27
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Info.php +4 -18
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Product.php +54 -63
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Quote.php +10 -23
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Selection.php +3 -18
- app/code/community/Owebia/Shipping2/Model/Os2/Data/StockItem.php +9 -22
- app/code/community/Owebia/Shipping2/Model/Os2/Data/Store.php +5 -20
- app/code/community/Owebia/Shipping2/Model/Os2/Message.php +35 -0
- app/code/community/Owebia/Shipping2/Model/Os2/Result.php +35 -0
- app/code/community/Owebia/Shipping2/Model/System/Config/Source/LoadOnParent.php +8 -19
- app/code/community/Owebia/Shipping2/Model/System/Config/Source/ProcessChildren.php +8 -19
- app/code/community/Owebia/Shipping2/changelog +5 -0
- app/code/community/Owebia/Shipping2/controllers/Adminhtml/Os2/AjaxController.php +232 -172
- app/code/community/Owebia/Shipping2/controllers/Checkout/CartController.php +8 -21
- app/code/community/Owebia/Shipping2/doc_en_US.html +7 -2
- app/code/community/Owebia/Shipping2/doc_fr_FR.html +7 -2
- app/code/community/Owebia/Shipping2/etc/adminhtml.xml +3 -17
- app/code/community/Owebia/Shipping2/etc/config.xml +14 -49
- app/code/community/Owebia/Shipping2/etc/system.xml +7 -150
- app/code/community/Owebia/Shipping2/includes/OS2_AddressFilterParser.php +0 -148
- app/code/community/Owebia/Shipping2/includes/OwebiaShippingHelper.php +0 -1467
- app/code/community/Owebia/Shipping2/sql/owebia_shipping2_setup/mysql4-install-2.5.13.php +15 -6
- app/etc/modules/Owebia_Shipping2.xml +2 -17
- app/locale/en_US/Owebia_Shipping2.csv +1 -727
- app/locale/fr_FR/Owebia_Shipping2.csv +1 -747
- package.xml +10 -5
@@ -1,28 +1,13 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Block_Adminhtml_Os2_Editor extends Mage_Adminhtml_Block_Abstract
|
23 |
{
|
24 |
protected $_config;
|
25 |
-
protected $
|
26 |
|
27 |
public function __construct($attributes)
|
28 |
{
|
@@ -31,7 +16,7 @@ class Owebia_Shipping2_Block_Adminhtml_Os2_Editor extends Mage_Adminhtml_Block_A
|
|
31 |
'opened_row_ids' => array(),
|
32 |
);
|
33 |
$this->_config = $attributes['config'];
|
34 |
-
$this->
|
35 |
}
|
36 |
|
37 |
public function __()
|
@@ -40,122 +25,134 @@ class Owebia_Shipping2_Block_Adminhtml_Os2_Editor extends Mage_Adminhtml_Block_A
|
|
40 |
return Mage::helper('owebia_shipping2')->__($args);
|
41 |
}
|
42 |
|
43 |
-
|
44 |
{
|
45 |
if (is_array($property)) { // Compatibility PHP 5.2
|
46 |
-
$value = isset($property['original_value'])
|
|
|
|
|
47 |
} else {
|
48 |
$value = $property;
|
49 |
}
|
50 |
|
51 |
-
$toolbar = "<span class=\"os2-field-btn os2-field-help\" data-property=\"{$
|
52 |
-
switch ($
|
53 |
case 'enabled':
|
54 |
-
$enabled = $value!==false;
|
55 |
-
$input = "<select class=field name=\"{$
|
56 |
-
."<option value=\"1\"".($enabled ? ' selected="selected"' : '').
|
57 |
-
|
58 |
-
|
|
|
|
|
59 |
break;
|
60 |
case 'type':
|
61 |
-
$input = "<select class=field name=\"{$
|
62 |
-
."<option value=method".($value=='method' || !$value ? '' : ' selected="selected"').
|
63 |
-
|
64 |
-
."<option value=
|
65 |
-
|
|
|
|
|
|
|
66 |
break;
|
67 |
case 'shipto':
|
68 |
case 'billto':
|
69 |
case 'origin':
|
70 |
-
$toolbar = "<span class=\"os2-field-btn os2-field-edit\"></span>"
|
71 |
default:
|
72 |
-
$input = "<input class=field name=\"{$
|
|
|
73 |
break;
|
74 |
}
|
75 |
return $input;
|
76 |
}
|
77 |
-
|
78 |
-
public function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
{
|
80 |
$after = '';
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
.
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
.
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
.
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
."
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
."</p><div id=os2-output></div>"
|
145 |
-
."</fieldset>"
|
146 |
-
;
|
147 |
-
break;
|
148 |
-
case 'about':
|
149 |
-
break;
|
150 |
}
|
151 |
return $after;
|
152 |
}
|
153 |
|
154 |
-
public function sortProperties($
|
155 |
{
|
156 |
-
$
|
157 |
-
$
|
158 |
-
return $
|
|
|
159 |
}
|
160 |
|
161 |
protected function _getRowUI(&$row)
|
@@ -164,20 +161,26 @@ class Owebia_Shipping2_Block_Adminhtml_Os2_Editor extends Mage_Adminhtml_Block_A
|
|
164 |
$type = isset($row['type']['value']) ? $row['type']['value'] : null;
|
165 |
switch ($type) {
|
166 |
case 'meta':
|
167 |
-
$
|
168 |
break;
|
169 |
case 'data':
|
170 |
-
$
|
171 |
break;
|
172 |
default:
|
173 |
if (!isset($row['label'])) {
|
174 |
$row['label']['value'] = $this->__('New shipping method');
|
175 |
}
|
176 |
-
$
|
177 |
-
$properties = array_merge(
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
}
|
179 |
|
180 |
-
$
|
181 |
'*id' => 'ID',
|
182 |
'type' => 'Type',
|
183 |
'about' => 'About',
|
@@ -192,26 +195,29 @@ class Owebia_Shipping2_Block_Adminhtml_Os2_Editor extends Mage_Adminhtml_Block_A
|
|
192 |
'customer_groups' => 'Customer groups',
|
193 |
'tracking_url' => 'Tracking url',
|
194 |
);
|
195 |
-
foreach ($properties as $
|
196 |
-
if (!isset($row[$
|
197 |
}
|
198 |
-
$this->
|
199 |
uksort($row, array($this, 'sortProperties'));
|
200 |
$list = '';
|
201 |
$content = '';
|
202 |
$j = 0;
|
203 |
-
foreach ($row as $
|
204 |
-
$
|
205 |
$error = array();
|
206 |
if (isset($property['messages'])) {
|
207 |
foreach ($property['messages'] as $message) {
|
208 |
$error[] = $this->__($message);
|
209 |
}
|
210 |
}
|
211 |
-
$content .= "<tr class=\"os2-p-container".($error ? ' os2-error' : '')."\""
|
|
|
|
|
|
|
|
|
212 |
$j++;
|
213 |
}
|
214 |
-
//$output = "<ul class=\"properties-list ui-layout-west\">{$list}</ul><div class=\"properties-container ui-layout-center\">{$content}</div>";
|
215 |
$output = "<table class=properties-container>{$content}</table>";
|
216 |
return $output;
|
217 |
}
|
@@ -235,13 +241,15 @@ class Owebia_Shipping2_Block_Adminhtml_Os2_Editor extends Mage_Adminhtml_Block_A
|
|
235 |
$content = $this->_getRowUI($row);
|
236 |
}
|
237 |
$error = false;
|
238 |
-
foreach ($row as $
|
239 |
if (is_array($property) /*Compatibility*/ && isset($property['messages'])) {
|
240 |
$error = true;
|
241 |
break;
|
242 |
}
|
243 |
}
|
244 |
-
return "<li data-id=\"{$row['*id']}\"".($error ? ' class=os2-error' : '')
|
|
|
|
|
245 |
}
|
246 |
|
247 |
protected function esc($input)
|
@@ -251,7 +259,7 @@ class Owebia_Shipping2_Block_Adminhtml_Os2_Editor extends Mage_Adminhtml_Block_A
|
|
251 |
|
252 |
protected function jsEscape($input)
|
253 |
{
|
254 |
-
return str_replace(array("\r\n","\r","\n","'"),array("\\n","\\n","\\n","\\'")
|
255 |
}
|
256 |
|
257 |
public function getRowUI(&$row)
|
@@ -262,15 +270,15 @@ class Owebia_Shipping2_Block_Adminhtml_Os2_Editor extends Mage_Adminhtml_Block_A
|
|
262 |
public function getHtml()
|
263 |
{
|
264 |
$config = $this->getData('config');
|
265 |
-
$
|
266 |
-
$output =
|
267 |
$i = 0;
|
268 |
if (!$config) {
|
269 |
$output .= "<p style=\"padding:10px;\">Configuration vide</p>";
|
270 |
} else {
|
271 |
$output .= "<ul id=os2-editor-elems-container>";
|
272 |
-
foreach ($config as $
|
273 |
-
$opened = in_array($
|
274 |
$output .= $this->_getRowItem($row, $opened);
|
275 |
$i++;
|
276 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Block_Adminhtml_Os2_Editor extends Mage_Adminhtml_Block_Abstract
|
8 |
{
|
9 |
protected $_config;
|
10 |
+
protected $_openedRowIds;
|
11 |
|
12 |
public function __construct($attributes)
|
13 |
{
|
16 |
'opened_row_ids' => array(),
|
17 |
);
|
18 |
$this->_config = $attributes['config'];
|
19 |
+
$this->_openedRowIds = $attributes['opened_row_ids'];
|
20 |
}
|
21 |
|
22 |
public function __()
|
25 |
return Mage::helper('owebia_shipping2')->__($args);
|
26 |
}
|
27 |
|
28 |
+
protected function _getPropertyInput($propertyName, $property)
|
29 |
{
|
30 |
if (is_array($property)) { // Compatibility PHP 5.2
|
31 |
+
$value = isset($property['original_value'])
|
32 |
+
? $property['original_value']
|
33 |
+
: (isset($property['value']) ? $property['value'] : (isset($property) ? $property : ''));
|
34 |
} else {
|
35 |
$value = $property;
|
36 |
}
|
37 |
|
38 |
+
$toolbar = "<span class=\"os2-field-btn os2-field-help\" data-property=\"{$propertyName}\"></span>";
|
39 |
+
switch ($propertyName) {
|
40 |
case 'enabled':
|
41 |
+
$enabled = $value !== false;
|
42 |
+
$input = "<select class=field name=\"{$propertyName}\">"
|
43 |
+
. "<option value=\"1\"" . ($enabled ? ' selected="selected"' : '') . ">"
|
44 |
+
. $this->__('Enabled (default)') . "</option>"
|
45 |
+
. "<option value=\"0\"" . ($enabled ? '' : ' selected="selected"') . ">"
|
46 |
+
. $this->__('Disabled') . "</option>"
|
47 |
+
. "</select>";
|
48 |
break;
|
49 |
case 'type':
|
50 |
+
$input = "<select class=field name=\"{$propertyName}\">"
|
51 |
+
. "<option value=method" . ($value=='method' || !$value ? '' : ' selected="selected"') . ">"
|
52 |
+
. $this->__('Shipping Method (default)') . "</option>"
|
53 |
+
. "<option value=data" . ($value=='data' ? ' selected="selected"' : '') . ">"
|
54 |
+
. $this->__('Data') . "</option>"
|
55 |
+
. "<option value=meta" . ($value=='meta' ? ' selected="selected"' : '') . ">"
|
56 |
+
. $this->__('Meta') . "</option>"
|
57 |
+
. "</select>";
|
58 |
break;
|
59 |
case 'shipto':
|
60 |
case 'billto':
|
61 |
case 'origin':
|
62 |
+
$toolbar = "<span class=\"os2-field-btn os2-field-edit\"></span>" . $toolbar;
|
63 |
default:
|
64 |
+
$input = "<input class=field name=\"{$propertyName}\""
|
65 |
+
. " value=\"" . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . "\"/>";
|
66 |
break;
|
67 |
}
|
68 |
return $input;
|
69 |
}
|
70 |
+
|
71 |
+
public function insertBtn($controller, $title, $variable)
|
72 |
+
{
|
73 |
+
return $controller->button__(
|
74 |
+
$title,
|
75 |
+
"os2editor.insertAtCaret(this,'$variable');",
|
76 |
+
'os2-insert'
|
77 |
+
);
|
78 |
+
}
|
79 |
+
|
80 |
+
public function getPropertyTools($controller, $propertyName)
|
81 |
{
|
82 |
$after = '';
|
83 |
+
if ($propertyName == 'label' || $propertyName == 'description') {
|
84 |
+
$after = "<fieldset class=buttons-set><legend>" . $this->__('Insert') . "</legend>"
|
85 |
+
. "<p>"
|
86 |
+
. $this->insertBtn($controller, 'Shipping country', '{shipto.country_name}')
|
87 |
+
. $this->insertBtn($controller, 'Cart weight', '{cart.weight}')
|
88 |
+
. $this->insertBtn($controller, 'Products quantity', '{cart.qty}')
|
89 |
+
. $this->insertBtn($controller, 'Price incl. tax', '{cart.price+tax+discount}')
|
90 |
+
. $this->insertBtn($controller, 'Price excl. tax', '{cart.price-tax+discount}')
|
91 |
+
. "</p>"
|
92 |
+
. "</fieldset>";
|
93 |
+
} elseif ($propertyName == 'fees') {
|
94 |
+
$after = "<fieldset class=buttons-set><legend>" . $this->__('Insert') . "</legend>"
|
95 |
+
. "<p>"
|
96 |
+
. $this->insertBtn($controller, 'Weight', '{cart.weight}')
|
97 |
+
. $this->insertBtn($controller, 'Products quantity', '{cart.qty}')
|
98 |
+
. $this->insertBtn($controller, 'Price incl. tax', '{cart.price+tax+discount}')
|
99 |
+
. $this->insertBtn($controller, 'Price excl. tax', '{cart.price-tax+discount}')
|
100 |
+
. "</p>"
|
101 |
+
. "</fieldset>";
|
102 |
+
} elseif ($propertyName == 'conditions') {
|
103 |
+
$after = "<fieldset class=buttons-set><legend>" . $this->__('Insert') . "</legend>"
|
104 |
+
. "<p>"
|
105 |
+
. $this->insertBtn($controller, 'Weight', '{cart.weight}')
|
106 |
+
. $this->insertBtn($controller, 'Products quantity', '{cart.qty}')
|
107 |
+
. $this->insertBtn($controller, 'Price incl. tax', '{cart.price+tax+discount}')
|
108 |
+
. $this->insertBtn($controller, 'Price excl. tax', '{cart.price-tax+discount}')
|
109 |
+
. "</p>"
|
110 |
+
. "</fieldset>";
|
111 |
+
} elseif ($propertyName == 'customer_groups') {
|
112 |
+
$model = Mage::getModel('owebia_shipping2/Os2_Data_CustomerGroup');
|
113 |
+
$groups = (array)$model->getCollection();
|
114 |
+
$output = '';
|
115 |
+
foreach ($groups as $id => $name) {
|
116 |
+
$output .= $this->insertBtn(
|
117 |
+
$controller,
|
118 |
+
$this->esc($name . ' (' . $id . ')'),
|
119 |
+
$this->jsEscape($id)
|
120 |
+
);
|
121 |
+
}
|
122 |
+
$after = "<fieldset class=buttons-set><legend>" . $this->__('Tools') . "</legend>"
|
123 |
+
. "<p>"
|
124 |
+
. $controller->button__('Human readable version', "os2editor.getReadableSelection(this);")
|
125 |
+
. "</p><div id=os2-output></div>"
|
126 |
+
. "</fieldset>"
|
127 |
+
. "<fieldset class=buttons-set><legend>" . $this->__('Insert') . "</legend>"
|
128 |
+
. "<p>{$output}</p>"
|
129 |
+
. "</fieldset>"
|
130 |
+
;
|
131 |
+
} elseif ($propertyName == 'tracking_url') {
|
132 |
+
$after = "<fieldset class=buttons-set><legend>" . $this->__('Insert') . "</legend>"
|
133 |
+
. "<p>"
|
134 |
+
. $this->insertBtn($controller, 'Tracking number', '{tracking_number}')
|
135 |
+
. "</p>"
|
136 |
+
. "</fieldset>";
|
137 |
+
} elseif ($propertyName == 'shipto' ||$propertyName == 'billto' || $propertyName == 'origin') {
|
138 |
+
$after = "<fieldset class=buttons-set><legend>" . $this->__('Tools') . "</legend>"
|
139 |
+
. "<p>"
|
140 |
+
. $controller->button__('Human readable version', "os2editor.getReadableSelection(this);")
|
141 |
+
. "</p><div id=os2-output></div>"
|
142 |
+
. "</fieldset>"
|
143 |
+
;
|
144 |
+
} elseif ($propertyName == 'about') {
|
145 |
+
$after = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
}
|
147 |
return $after;
|
148 |
}
|
149 |
|
150 |
+
public function sortProperties($firstKey, $secondKey)
|
151 |
{
|
152 |
+
$firstKeyPosition = isset($this->propertiesSort[$firstKey]) ? $this->propertiesSort[$firstKey] : 1000;
|
153 |
+
$secondKeyPosition = isset($this->propertiesSort[$secondKey]) ? $this->propertiesSort[$secondKey] : 1000;
|
154 |
+
return $firstKeyPosition == $secondKeyPosition
|
155 |
+
? strcmp($firstKey, $secondKey) : $firstKeyPosition - $secondKeyPosition;
|
156 |
}
|
157 |
|
158 |
protected function _getRowUI(&$row)
|
161 |
$type = isset($row['type']['value']) ? $row['type']['value'] : null;
|
162 |
switch ($type) {
|
163 |
case 'meta':
|
164 |
+
$rowLabel = $this->__('[meta] %s', $row['*id']);
|
165 |
break;
|
166 |
case 'data':
|
167 |
+
$rowLabel = $this->__('[data] %s', $row['*id']);
|
168 |
break;
|
169 |
default:
|
170 |
if (!isset($row['label'])) {
|
171 |
$row['label']['value'] = $this->__('New shipping method');
|
172 |
}
|
173 |
+
$rowLabel = $row['label']['value'];
|
174 |
+
$properties = array_merge(
|
175 |
+
$properties,
|
176 |
+
array(
|
177 |
+
'label', 'description', 'shipto', 'billto', 'origin',
|
178 |
+
'conditions', 'fees', 'customer_groups', 'tracking_url',
|
179 |
+
)
|
180 |
+
);
|
181 |
}
|
182 |
|
183 |
+
$propertiesLabel = array(
|
184 |
'*id' => 'ID',
|
185 |
'type' => 'Type',
|
186 |
'about' => 'About',
|
195 |
'customer_groups' => 'Customer groups',
|
196 |
'tracking_url' => 'Tracking url',
|
197 |
);
|
198 |
+
foreach ($properties as $propertyName) {
|
199 |
+
if (!isset($row[$propertyName])) $row[$propertyName] = null;
|
200 |
}
|
201 |
+
$this->propertiesSort = array_flip($properties);
|
202 |
uksort($row, array($this, 'sortProperties'));
|
203 |
$list = '';
|
204 |
$content = '';
|
205 |
$j = 0;
|
206 |
+
foreach ($row as $propertyName => $property) {
|
207 |
+
$propertyLabel = isset($propertiesLabel[$propertyName]) ? $propertiesLabel[$propertyName] : $propertyName;
|
208 |
$error = array();
|
209 |
if (isset($property['messages'])) {
|
210 |
foreach ($property['messages'] as $message) {
|
211 |
$error[] = $this->__($message);
|
212 |
}
|
213 |
}
|
214 |
+
$content .= "<tr class=\"os2-p-container" . ($error ? ' os2-error' : ''). "\""
|
215 |
+
. ($error ? ' title="' . $this->esc(implode(', ', $error)) . '"' : '')
|
216 |
+
. "><th>" . $this->__($propertyLabel) . "</th>"
|
217 |
+
. "<td>" . $this->_getPropertyInput($propertyName, $property, $big = false) . "</td>"
|
218 |
+
. "</tr>";
|
219 |
$j++;
|
220 |
}
|
|
|
221 |
$output = "<table class=properties-container>{$content}</table>";
|
222 |
return $output;
|
223 |
}
|
241 |
$content = $this->_getRowUI($row);
|
242 |
}
|
243 |
$error = false;
|
244 |
+
foreach ($row as $propertyName => $property) {
|
245 |
if (is_array($property) /*Compatibility*/ && isset($property['messages'])) {
|
246 |
$error = true;
|
247 |
break;
|
248 |
}
|
249 |
}
|
250 |
+
return "<li data-id=\"{$row['*id']}\"" . ($error ? ' class=os2-error' : '') . ">"
|
251 |
+
. "<h5><button class=\"os2-remove-row-btn\" title=\"{$this->__('Remove')}\"></button>" . $label . "</h5>"
|
252 |
+
. "<div class=\"row-ui" . ($opened ? ' opened' : '') . "\">{$content}</div></li>";
|
253 |
}
|
254 |
|
255 |
protected function esc($input)
|
259 |
|
260 |
protected function jsEscape($input)
|
261 |
{
|
262 |
+
return str_replace(array("\r\n", "\r", "\n", "'"), array("\\n", "\\n", "\\n", "\\'"), $input);
|
263 |
}
|
264 |
|
265 |
public function getRowUI(&$row)
|
270 |
public function getHtml()
|
271 |
{
|
272 |
$config = $this->getData('config');
|
273 |
+
$openedRowIds = $this->getData('opened_row_ids');
|
274 |
+
$output = '';
|
275 |
$i = 0;
|
276 |
if (!$config) {
|
277 |
$output .= "<p style=\"padding:10px;\">Configuration vide</p>";
|
278 |
} else {
|
279 |
$output .= "<ul id=os2-editor-elems-container>";
|
280 |
+
foreach ($config as $rowId => &$row) {
|
281 |
+
$opened = in_array($rowId, $openedRowIds) || !$openedRowIds && $i==0;
|
282 |
$output .= $this->_getRowItem($row, $opened);
|
283 |
$i++;
|
284 |
}
|
@@ -1,28 +1,16 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Block_Adminhtml_Os2_Editor_Property_Input extends Mage_Adminhtml_Block_Abstract
|
23 |
{
|
|
|
|
|
|
|
24 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
25 |
{
|
26 |
-
|
27 |
}
|
28 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Block_Adminhtml_Os2_Editor_Property_Input extends Mage_Adminhtml_Block_Abstract
|
8 |
{
|
9 |
+
/**
|
10 |
+
* {@inheritdoc}
|
11 |
+
*/
|
12 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
13 |
{
|
14 |
+
return '';
|
15 |
}
|
16 |
}
|
@@ -1,23 +1,8 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Block_Adminhtml_Os2_Help extends Mage_Adminhtml_Block_Abstract
|
23 |
{
|
@@ -30,26 +15,28 @@ class Owebia_Shipping2_Block_Adminhtml_Os2_Help extends Mage_Adminhtml_Block_Abs
|
|
30 |
public function getHtml()
|
31 |
{
|
32 |
$controller = $this->getData('controller');
|
33 |
-
$
|
34 |
$content = $this->getData('content');
|
35 |
$helper = $this->getData('helper');
|
36 |
|
37 |
-
$
|
38 |
-
$
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
41 |
}
|
42 |
-
$content =
|
43 |
-
$
|
44 |
-
$
|
45 |
-
$
|
46 |
-
$
|
47 |
-
$
|
48 |
-
$content = $
|
49 |
-
//. "<script>jQuery.fn.scrollspy = function(){};" . $doc_scripts . "</script>"
|
50 |
. "<script>
|
51 |
jQuery.fn.scrollspy = function(){};
|
52 |
-
{$
|
53 |
function bjson() {
|
54 |
var index = 0;
|
55 |
jQuery('div.json').each(function(){
|
@@ -69,49 +56,10 @@ setTimeout(function(){
|
|
69 |
}, 1000);
|
70 |
</script>"
|
71 |
;
|
72 |
-
//$nav = "<div id=os2-help-nav><a href=\"#\" onclick=\"os2editor.refreshHelp();\">".$this->__('Refresh')."</a> | <a href=\"#\" onclick=\"os2editor.previousHelp();\">".$this->__('Previous page')."</a>".($help_id!='summary' ? " | <a href=\"#summary\">".$this->__('Summary')."</a>" : '')."</div>";
|
73 |
$nav = '';
|
74 |
$title = '';
|
75 |
$header = "<div class=\"ui-layout-north os2-help-header\">{$nav}<h4>{$title}</h4></div>";
|
76 |
-
$content = ($header ? "{$header}" : '')."<div id=os2-help class=ui-layout-center>{$content}</div>";
|
77 |
-
return $content;
|
78 |
-
|
79 |
-
$controller = $this->getData('controller');
|
80 |
-
$help_id = $this->getData('help_id');
|
81 |
-
$content = $this->getData('content');
|
82 |
-
$helper = $this->getData('helper');
|
83 |
-
$content = str_replace(
|
84 |
-
array("\\t", "<c>", "<c class=new>", "</c>", "<string>", "</string>", "<property>", "</property>"),
|
85 |
-
array(' ', "<span class=code>", "<span class=\"code new\">", "</span>", "<span class=code><span class=string>", "</span></span>", "<span class=property>", "</span>"),
|
86 |
-
$content);
|
87 |
-
$header = null;
|
88 |
-
$footer = null;
|
89 |
-
$title = null;
|
90 |
-
if ($help_id=='changelog') {
|
91 |
-
$changelog = @file_get_contents($controller->getModulePath('changelog'));
|
92 |
-
if (!$changelog) $changelog = "Empty changelog";
|
93 |
-
$changelog = mb_convert_encoding($changelog, 'UTF-8', 'ISO-8859-1');
|
94 |
-
if (!$changelog) $changelog = "Encoding error";
|
95 |
-
$changelog = htmlspecialchars($changelog, ENT_QUOTES, 'UTF-8');
|
96 |
-
$changelog = str_replace("\n", "<br/>", $changelog);
|
97 |
-
$content = str_replace('{changelog}', $changelog, $content);
|
98 |
-
}
|
99 |
-
while (preg_match('#{code=json}(.*?){/code}#s', $content, $result)) {
|
100 |
-
$json = str_replace("\r\n", '', $result[1]);
|
101 |
-
try {
|
102 |
-
$json = Zend_Json::decode($json);
|
103 |
-
} catch (Exception $e) {}
|
104 |
-
$content = str_replace($result[0], "<div class=code>".$helper::jsonEncode($json, $beautify = true, $html = true)."</div>", $content);
|
105 |
-
}
|
106 |
-
if (preg_match('#<h4>(.*)</h4>#', $content, $result)) {
|
107 |
-
$title = $result[1];
|
108 |
-
$content = str_replace($result[0], '', $content);
|
109 |
-
}
|
110 |
-
$nav = "<div id=os2-help-nav><a href=\"#\" onclick=\"os2editor.refreshHelp();\">".$this->__('Refresh')."</a> | <a href=\"#\" onclick=\"os2editor.previousHelp();\">".$this->__('Previous page')."</a>".($help_id!='summary' ? " | <a href=\"#summary\">".$this->__('Summary')."</a>" : '')."</div>";
|
111 |
-
$header = "<div class=\"ui-layout-north os2-help-header\">{$nav}<h4>{$title}</h4></div>";
|
112 |
-
$content = ($header ? "{$header}" : '')."<div id=os2-help class=ui-layout-center>{$content}</div>";
|
113 |
-
$content = preg_replace('/ href="#([a-z0-9_\-\.]+)"/', ' href="#" onclick="os2editor.help(\'\1\');"', $content);
|
114 |
return $content;
|
115 |
-
|
116 |
}
|
117 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Block_Adminhtml_Os2_Help extends Mage_Adminhtml_Block_Abstract
|
8 |
{
|
15 |
public function getHtml()
|
16 |
{
|
17 |
$controller = $this->getData('controller');
|
18 |
+
$helpId = $this->getData('help_id');
|
19 |
$content = $this->getData('content');
|
20 |
$helper = $this->getData('helper');
|
21 |
|
22 |
+
$localeCode = Mage::app()->getLocale()->getLocaleCode();
|
23 |
+
$helpFileDir = Mage::getBaseDir('app') . '/code/community/Owebia/Shipping2';
|
24 |
+
$helpFileBasename = 'doc_' . $localeCode . '.html';
|
25 |
+
$ioFile = new Varien_Io_File();
|
26 |
+
$ioFile->cd($helpFileDir);
|
27 |
+
if ($ioFile->fileExists($helpFileBasename)) {
|
28 |
+
$helpFileBasename = 'doc_en_US.html';
|
29 |
}
|
30 |
+
$content = $ioFile->read($helpFileBasename);
|
31 |
+
$docSidebar = preg_replace('#^.*<!-- doc sidebar start -->(.*)<!-- doc sidebar end -->.*$#s', '\1', $content);
|
32 |
+
$docContent = preg_replace('#^.*<!-- doc content start -->(.*)<!-- doc content end -->.*$#s', '\1', $content);
|
33 |
+
$docScript = preg_replace('#^.*<!-- doc scripts start -->(.*)<!-- doc scripts end -->.*$#s', '\1', $content);
|
34 |
+
$docScript = str_replace('$(', "jQuery(", $docScript);
|
35 |
+
$docScript = str_replace('$.', "jQuery.", $docScript);
|
36 |
+
$content = $docSidebar . $docContent
|
|
|
37 |
. "<script>
|
38 |
jQuery.fn.scrollspy = function(){};
|
39 |
+
{$docScript}
|
40 |
function bjson() {
|
41 |
var index = 0;
|
42 |
jQuery('div.json').each(function(){
|
56 |
}, 1000);
|
57 |
</script>"
|
58 |
;
|
|
|
59 |
$nav = '';
|
60 |
$title = '';
|
61 |
$header = "<div class=\"ui-layout-north os2-help-header\">{$nav}<h4>{$title}</h4></div>";
|
62 |
+
$content = ($header ? "{$header}" : '') . "<div id=os2-help class=ui-layout-center>{$content}</div>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
return $content;
|
|
|
64 |
}
|
65 |
}
|
@@ -1,28 +1,14 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
-
class Owebia_Shipping2_Block_Adminhtml_System_Config_Form_Field_Config
|
|
|
23 |
{
|
24 |
-
|
25 |
-
|
26 |
public function __()
|
27 |
{
|
28 |
$args = func_get_args();
|
@@ -40,57 +26,56 @@ class Owebia_Shipping2_Block_Adminhtml_System_Config_Form_Field_Config extends M
|
|
40 |
$head->addJs('owebia/shipping2/colorbox/jquery.colorbox-min.js');
|
41 |
$head->addJs('owebia/shipping2/jquery.caret.1.02.min.js');
|
42 |
$head->addJs('owebia/shipping2/os2editor.js');
|
43 |
-
//$head->addItem('js_css', 'owebia/shipping2/jquery-ui-1.8.23.custom/css/ui-lightness/jquery-ui-1.8.23.custom.css');
|
44 |
$head->addItem('js_css', 'owebia/shipping2/colorbox/colorbox.css', 'media="all"');
|
45 |
$head->addItem('js_css', 'owebia/shipping2/os2editor.css', 'media="all"');
|
46 |
-
//$head->addItem('other', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js');
|
47 |
-
//$head->append($block);
|
48 |
-
|
49 |
parent::_prepareLayout();
|
50 |
}
|
51 |
|
52 |
-
|
53 |
{
|
54 |
-
return str_replace(array("\r\n","\r","\n","'"), array("\\n","\\n","\\n","\\'"), $this->__($input));
|
55 |
}
|
56 |
|
57 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
58 |
{
|
59 |
$output = '';
|
60 |
-
if (!self::$
|
61 |
$output = "<script type=\"text/javascript\">\n"
|
62 |
-
."//<![CDATA[\n"
|
63 |
-
."jQuery.noConflict();\n"
|
64 |
-
."var os2editor = new OS2Editor({\n"
|
65 |
-
."ajax_url: '"
|
66 |
-
."form_key: FORM_KEY,\n"
|
67 |
-
."apply_btn_label: '"
|
68 |
-
."cancel_btn_label: '"
|
69 |
-
."menu_item_dissociate_label: '"
|
70 |
-
."menu_item_remove_label: '"
|
71 |
-
."menu_item_edit_label: '"
|
72 |
-
."prompt_new_value_label: '"
|
73 |
-
."default_row_label: '"
|
74 |
-
."loading_label: '"
|
75 |
-
."});\n"
|
76 |
-
."
|
77 |
"
|
78 |
-
."//]]>\n"
|
79 |
-
."</script>\n"
|
80 |
;
|
81 |
-
self::$
|
82 |
}
|
83 |
|
84 |
-
$
|
85 |
return <<<EOD
|
86 |
{$output}
|
87 |
<div style="margin-bottom:1px;">
|
88 |
-
<button type="button" class="scalable" onclick="os2editor.init(this, '{$
|
89 |
-
|
|
|
|
|
90 |
<!--<a href="{$this->getUrl('adminhtml/os2_ajax/doc')}">doc</a>-->
|
91 |
</div>
|
92 |
{$element->getElementHtml()}<br/>
|
93 |
-
<a href="http://www.owebia.com/contributions/magento/owebia-shipping/fr/modeles-de-configuration" target="_blank"
|
|
|
94 |
EOD;
|
95 |
}
|
96 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
class Owebia_Shipping2_Block_Adminhtml_System_Config_Form_Field_Config
|
8 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
9 |
{
|
10 |
+
protected static $_isJsIncluded = false;
|
11 |
+
|
12 |
public function __()
|
13 |
{
|
14 |
$args = func_get_args();
|
26 |
$head->addJs('owebia/shipping2/colorbox/jquery.colorbox-min.js');
|
27 |
$head->addJs('owebia/shipping2/jquery.caret.1.02.min.js');
|
28 |
$head->addJs('owebia/shipping2/os2editor.js');
|
|
|
29 |
$head->addItem('js_css', 'owebia/shipping2/colorbox/colorbox.css', 'media="all"');
|
30 |
$head->addItem('js_css', 'owebia/shipping2/os2editor.css', 'media="all"');
|
|
|
|
|
|
|
31 |
parent::_prepareLayout();
|
32 |
}
|
33 |
|
34 |
+
protected function label__($input)
|
35 |
{
|
36 |
+
return str_replace(array("\r\n", "\r", "\n", "'"), array("\\n", "\\n", "\\n", "\\'"), $this->__($input));
|
37 |
}
|
38 |
|
39 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
40 |
{
|
41 |
$output = '';
|
42 |
+
if (!self::$_isJsIncluded) {
|
43 |
$output = "<script type=\"text/javascript\">\n"
|
44 |
+
. "//<![CDATA[\n"
|
45 |
+
. "jQuery.noConflict();\n"
|
46 |
+
. "var os2editor = new OS2Editor({\n"
|
47 |
+
. "ajax_url: '" . $this->getUrl('adminhtml/os2_ajax/index') . "?isAjax=true',\n"
|
48 |
+
. "form_key: FORM_KEY,\n"
|
49 |
+
. "apply_btn_label: '" . $this->label__('Apply') . "',\n"
|
50 |
+
. "cancel_btn_label: '" . $this->label__('Cancel') . "',\n"
|
51 |
+
. "menu_item_dissociate_label: '" . $this->label__('Dissociate') . "',\n"
|
52 |
+
. "menu_item_remove_label: '" . $this->label__('Remove') . "',\n"
|
53 |
+
. "menu_item_edit_label: '" . $this->label__('Edit') . "',\n"
|
54 |
+
. "prompt_new_value_label: '" . $this->label__('Enter the new value:') . "',\n"
|
55 |
+
. "default_row_label: '" . $this->label__('[No label]') . "',\n"
|
56 |
+
. "loading_label: '" . $this->label__('Loading...') . "'\n"
|
57 |
+
. "});\n"
|
58 |
+
. "
|
59 |
"
|
60 |
+
. "//]]>\n"
|
61 |
+
. "</script>\n"
|
62 |
;
|
63 |
+
self::$_isJsIncluded = true;
|
64 |
}
|
65 |
|
66 |
+
$shippingCode = preg_replace('/^groups\[([^\]]*)\].*$/', '\1', $element->getName());
|
67 |
return <<<EOD
|
68 |
{$output}
|
69 |
<div style="margin-bottom:1px;">
|
70 |
+
<button type="button" class="scalable" onclick="os2editor.init(this, '{$shippingCode}').page('source');"
|
71 |
+
><span>{$this->__('Source & Correction')}</span></button>
|
72 |
+
<button type="button" class="scalable" onclick="os2editor.init(this, '{$shippingCode}').help('summary');"
|
73 |
+
><span>{$this->__('Help')}</span></button>
|
74 |
<!--<a href="{$this->getUrl('adminhtml/os2_ajax/doc')}">doc</a>-->
|
75 |
</div>
|
76 |
{$element->getElementHtml()}<br/>
|
77 |
+
<a href="http://www.owebia.com/contributions/magento/owebia-shipping/fr/modeles-de-configuration" target="_blank"
|
78 |
+
>{$this->__('Download configuration templates')}</a>
|
79 |
EOD;
|
80 |
}
|
81 |
}
|
@@ -1,25 +1,11 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
-
class Owebia_Shipping2_Block_Adminhtml_System_Config_Form_Field_Informations
|
|
|
23 |
{
|
24 |
public function __()
|
25 |
{
|
@@ -27,6 +13,9 @@ class Owebia_Shipping2_Block_Adminhtml_System_Config_Form_Field_Informations ext
|
|
27 |
return Mage::helper('owebia_shipping2')->__($args);
|
28 |
}
|
29 |
|
|
|
|
|
|
|
30 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
31 |
{
|
32 |
$version = Mage::getConfig()->getNode('modules/Owebia_Shipping2/version');
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
class Owebia_Shipping2_Block_Adminhtml_System_Config_Form_Field_Informations
|
8 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
9 |
{
|
10 |
public function __()
|
11 |
{
|
13 |
return Mage::helper('owebia_shipping2')->__($args);
|
14 |
}
|
15 |
|
16 |
+
/**
|
17 |
+
* {@inheritDoc}
|
18 |
+
*/
|
19 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
20 |
{
|
21 |
$version = Mage::getConfig()->getNode('modules/Owebia_Shipping2/version');
|
@@ -1,44 +1,39 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Controller_Abstract extends Mage_Adminhtml_Controller_Action
|
23 |
{
|
|
|
|
|
|
|
|
|
|
|
24 |
public function __()
|
25 |
{
|
26 |
$args = func_get_args();
|
27 |
return Mage::helper('owebia_shipping2')->__($args);
|
28 |
}
|
29 |
|
30 |
-
|
31 |
{
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
37 |
}
|
38 |
|
39 |
protected function getMimeType($extension)
|
40 |
{
|
41 |
-
$
|
42 |
'.gz' => 'application/x-gzip',
|
43 |
'.tgz' => 'application/x-gzip',
|
44 |
'.zip' => 'application/zip',
|
@@ -53,54 +48,66 @@ class Owebia_Shipping2_Controller_Abstract extends Mage_Adminhtml_Controller_Act
|
|
53 |
'.mpg' => 'video/mpeg',
|
54 |
'.avi' => 'video/x-msvideo',
|
55 |
);
|
56 |
-
return isset($
|
57 |
}
|
58 |
-
|
59 |
protected function forceDownload($filename, $content)
|
60 |
{
|
61 |
if (headers_sent()) {
|
62 |
-
trigger_error('forceDownload($filename) - Headers have already been sent',E_USER_ERROR);
|
63 |
return false;
|
64 |
}
|
65 |
|
66 |
-
$extension = strrchr($filename,'.');
|
67 |
-
$
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
return
|
78 |
}
|
79 |
|
80 |
protected function cleanKey($key)
|
81 |
{
|
82 |
-
return preg_replace('/[^a-z0-9\-_]/i','_'
|
83 |
}
|
84 |
|
85 |
-
protected function page($page, $
|
86 |
{
|
87 |
-
if (!is_array($
|
88 |
-
return ($
|
89 |
-
. $this->pageHeader(
|
90 |
-
$this->
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
)
|
95 |
. "<div id=os2-page-container class=ui-layout-center>" : '')
|
96 |
. "<div id=os2-page-{$page} class=os2-page>"
|
97 |
-
. (!isset($
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
. "</div>"
|
103 |
-
. ($
|
104 |
. "</div>" : '')
|
105 |
;
|
106 |
}
|
@@ -108,22 +115,23 @@ class Owebia_Shipping2_Controller_Abstract extends Mage_Adminhtml_Controller_Act
|
|
108 |
protected function pageHeader($title, $buttons)
|
109 |
{
|
110 |
return "<div class=ui-layout-north><div id=os2-page-header>"
|
111 |
-
."<table cellspacing=0><tr>"
|
112 |
-
."<td><h3>{$title}</h3></td>"
|
113 |
-
."<td class=buttons>{$buttons}</td>"
|
114 |
-
."</tr></table>"
|
115 |
-
."</div></div>"
|
116 |
;
|
117 |
}
|
118 |
|
119 |
-
public function button($label, $onclick, $
|
120 |
{
|
121 |
-
$
|
122 |
-
return "<button type=\"button\" class=\""
|
|
|
123 |
}
|
124 |
|
125 |
-
public function button__($label, $onclick, $
|
126 |
{
|
127 |
-
return $this->button($this->__($label)
|
128 |
}
|
129 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Controller_Abstract extends Mage_Adminhtml_Controller_Action
|
8 |
{
|
9 |
+
protected function _isAllowed()
|
10 |
+
{
|
11 |
+
return Mage::getSingleton('admin/session')->isAllowed('admin');
|
12 |
+
}
|
13 |
+
|
14 |
public function __()
|
15 |
{
|
16 |
$args = func_get_args();
|
17 |
return Mage::helper('owebia_shipping2')->__($args);
|
18 |
}
|
19 |
|
20 |
+
protected function outputContent($content)
|
21 |
{
|
22 |
+
return $this->getResponse()
|
23 |
+
->setBody($content);
|
24 |
+
}
|
25 |
+
|
26 |
+
protected function json($data)
|
27 |
+
{
|
28 |
+
return $this->outputContent(
|
29 |
+
Mage::helper('core')
|
30 |
+
->jsonEncode($data)
|
31 |
+
);
|
32 |
}
|
33 |
|
34 |
protected function getMimeType($extension)
|
35 |
{
|
36 |
+
$mimeTypeArray = array(
|
37 |
'.gz' => 'application/x-gzip',
|
38 |
'.tgz' => 'application/x-gzip',
|
39 |
'.zip' => 'application/zip',
|
48 |
'.mpg' => 'video/mpeg',
|
49 |
'.avi' => 'video/x-msvideo',
|
50 |
);
|
51 |
+
return isset($mimeTypeArray[$extension]) ? $mimeTypeArray[$extension] : 'application/octet-stream';
|
52 |
}
|
53 |
+
|
54 |
protected function forceDownload($filename, $content)
|
55 |
{
|
56 |
if (headers_sent()) {
|
57 |
+
trigger_error('forceDownload($filename) - Headers have already been sent', E_USER_ERROR);
|
58 |
return false;
|
59 |
}
|
60 |
|
61 |
+
$extension = strrchr($filename, '.');
|
62 |
+
$mimeType = $this->getMimeType($extension);
|
63 |
|
64 |
+
$this->getResponse()
|
65 |
+
->clearHeaders()
|
66 |
+
->setHeader('Content-disposition', 'attachment; filename="' . $filename . '"')
|
67 |
+
->setHeader('Content-Type', 'application/force-download')
|
68 |
+
->setHeader('Content-Transfer-Encoding', $mimeType . "\n") // Surtout ne pas enlever le \n
|
69 |
+
->setHeader('Pragma', 'no-cache')
|
70 |
+
->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0')
|
71 |
+
->setHeader('Expires', '0');
|
72 |
+
return $this->outputContent($content);
|
73 |
}
|
74 |
|
75 |
protected function cleanKey($key)
|
76 |
{
|
77 |
+
return preg_replace('/[^a-z0-9\-_]/i', '_', $key);
|
78 |
}
|
79 |
|
80 |
+
protected function page($page, $layoutContent = array(), $withDialog = true)
|
81 |
{
|
82 |
+
if (!is_array($layoutContent)) $layoutContent = array('center' => $layoutContent);
|
83 |
+
return ($withDialog ? "<div id=os2-dialog>"
|
84 |
+
. $this->pageHeader(
|
85 |
+
$this->__('Owebia Shipping 2 Editor'),
|
86 |
+
$this->button__('Source & Correction', "os2editor.page('source');", 'source')
|
87 |
+
. $this->button__('Help', "os2editor.help('summary');", 'help')
|
88 |
+
. $this->button__('Close', "os2editor.close();", 'cancel')
|
89 |
)
|
90 |
. "<div id=os2-page-container class=ui-layout-center>" : '')
|
91 |
. "<div id=os2-page-{$page} class=os2-page>"
|
92 |
+
. (!isset($layoutContent['north'])
|
93 |
+
? ''
|
94 |
+
: "<div class=\"ui-layout-north inner-layout\">" . $layoutContent['north'] . "</div>"
|
95 |
+
)
|
96 |
+
. "<div class=\"ui-layout-center inner-layout\">" . $layoutContent['center'] . "</div>"
|
97 |
+
. (!isset($layoutContent['south'])
|
98 |
+
? ''
|
99 |
+
: "<div class=\"ui-layout-south inner-layout\">" . $layoutContent['south'] . "</div>"
|
100 |
+
)
|
101 |
+
. (!isset($layoutContent['west'])
|
102 |
+
? ''
|
103 |
+
: "<div class=\"ui-layout-west inner-layout\">" . $layoutContent['west'] . "</div>"
|
104 |
+
)
|
105 |
+
. (!isset($layoutContent['east'])
|
106 |
+
? ''
|
107 |
+
: "<div class=\"ui-layout-east inner-layout\">" . $layoutContent['east'] . "</div>"
|
108 |
+
)
|
109 |
. "</div>"
|
110 |
+
. ($withDialog ? "</div>"
|
111 |
. "</div>" : '')
|
112 |
;
|
113 |
}
|
115 |
protected function pageHeader($title, $buttons)
|
116 |
{
|
117 |
return "<div class=ui-layout-north><div id=os2-page-header>"
|
118 |
+
. "<table cellspacing=0><tr>"
|
119 |
+
. "<td><h3>{$title}</h3></td>"
|
120 |
+
. "<td class=buttons>{$buttons}</td>"
|
121 |
+
. "</tr></table>"
|
122 |
+
. "</div></div>"
|
123 |
;
|
124 |
}
|
125 |
|
126 |
+
public function button($label, $onclick, $className = '')
|
127 |
{
|
128 |
+
$className = 'scalable' . ($className != '' ? ' ' . $className : '');
|
129 |
+
return "<button type=\"button\" class=\"" . $className . "\" onclick=\"" . $onclick . "\">"
|
130 |
+
. "<span>" . $label . "</span></button>";
|
131 |
}
|
132 |
|
133 |
+
public function button__($label, $onclick, $className = '')
|
134 |
{
|
135 |
+
return $this->button($this->__($label), $onclick, $className);
|
136 |
}
|
137 |
}
|
@@ -1,76 +1,39 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Helper_Data extends Mage_Core_Helper_Data
|
23 |
{
|
24 |
-
protected $
|
25 |
|
26 |
public function __()
|
27 |
{
|
28 |
$args = func_get_args();
|
29 |
-
if (isset($args[0]) && is_array($args[0]) && count($args)==1) {
|
30 |
$args = $args[0];
|
31 |
}
|
32 |
$message = array_shift($args);
|
33 |
-
if ($message instanceof
|
34 |
$args = $message->args;
|
35 |
$message = $message->message;
|
36 |
}
|
37 |
-
|
38 |
-
$output = parent::__($message);
|
39 |
-
|
40 |
-
/*if (true) {
|
41 |
-
$translations = @file_get_contents('translations.os2');
|
42 |
-
$translations = eval('return '.$translations.';');
|
43 |
-
if (!is_array($translations)) $translations = array();
|
44 |
-
|
45 |
-
$file = 'NC';
|
46 |
-
$line = 'NC';
|
47 |
-
$backtrace = debug_backtrace();
|
48 |
-
foreach ($backtrace as $trace) {
|
49 |
-
if (!isset($trace['function'])) continue;
|
50 |
-
if (substr($trace['function'], strlen($trace['function'])-2, strlen($trace['function']))=='__') {
|
51 |
-
$file = ltrim(str_replace(Mage::getBaseDir(), '', $trace['file']), '/');
|
52 |
-
$line = $trace['line'];
|
53 |
-
continue;
|
54 |
-
}
|
55 |
-
//$file = ltrim(str_replace(Mage::getBaseDir(), '', $trace['file']), '/');
|
56 |
-
//echo $file.', '.$trace['function'].'(), '.$line.', '.$message.'<br/>';
|
57 |
-
break;
|
58 |
-
}
|
59 |
|
60 |
-
|
61 |
-
ksort($translations[Mage::app()->getLocale()->getLocaleCode()]);
|
62 |
-
file_put_contents('translations.os2', var_export($translations, true));
|
63 |
-
}*/
|
64 |
|
65 |
-
if (count($args)==0) {
|
66 |
$result = $output;
|
67 |
} else {
|
68 |
-
if (!isset($this->
|
69 |
-
|
|
|
|
|
|
|
70 |
$parts = explode('}}{{', $output);
|
71 |
$parts[0] = vsprintf($parts[0], $args);
|
72 |
$result = implode('}}{{', $parts);
|
73 |
-
} else
|
74 |
$result = vsprintf($output, $args);
|
75 |
}
|
76 |
}
|
@@ -83,50 +46,70 @@ class Owebia_Shipping2_Helper_Data extends Mage_Core_Helper_Data
|
|
83 |
|
84 |
$output = '';
|
85 |
$cart = $process['data']['cart'];
|
86 |
-
return $helper->evalInput(
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
|
|
|
|
|
|
|
|
|
|
103 |
}
|
104 |
-
|
105 |
-
|
106 |
{
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
return array(
|
109 |
-
'info' => Mage::getModel(
|
110 |
-
'
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
'
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
),
|
128 |
-
),
|
129 |
-
)),
|
130 |
'quote' => Mage::getModel('owebia_shipping2/Os2_Data_Quote'),
|
131 |
'selection' => Mage::getModel('owebia_shipping2/Os2_Data_Selection'),
|
132 |
'customer' => Mage::getModel('owebia_shipping2/Os2_Data_Customer'),
|
@@ -134,20 +117,32 @@ class Owebia_Shipping2_Helper_Data extends Mage_Core_Helper_Data
|
|
134 |
'customvar' => Mage::getModel('owebia_shipping2/Os2_Data_Customvar'),
|
135 |
'date' => Mage::getModel('owebia_shipping2/Os2_Data_Date'),
|
136 |
'address_filter' => Mage::getModel('owebia_shipping2/Os2_Data_AddressFilter'),
|
137 |
-
'origin' => Mage::getModel(
|
138 |
-
'
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
'billto' => Mage::getModel('owebia_shipping2/Os2_Data_Billto'),
|
152 |
'store' => Mage::getModel('owebia_shipping2/Os2_Data_Store', array('id' => $request->getData('store_id'))),
|
153 |
'request' => Mage::getModel('owebia_shipping2/Os2_Data_Abstract', $request->getData()),
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Helper_Data extends Mage_Core_Helper_Data
|
8 |
{
|
9 |
+
protected $_isTranslateInlineEnabled;
|
10 |
|
11 |
public function __()
|
12 |
{
|
13 |
$args = func_get_args();
|
14 |
+
if (isset($args[0]) && is_array($args[0]) && count($args) == 1) {
|
15 |
$args = $args[0];
|
16 |
}
|
17 |
$message = array_shift($args);
|
18 |
+
if ($message instanceof Owebia_Shipping2_Model_Os2_Message) {
|
19 |
$args = $message->args;
|
20 |
$message = $message->message;
|
21 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
+
$output = parent::__($message);
|
|
|
|
|
|
|
24 |
|
25 |
+
if (count($args) == 0) {
|
26 |
$result = $output;
|
27 |
} else {
|
28 |
+
if (!isset($this->_isTranslateInlineEnabled)) {
|
29 |
+
$this->_isTranslateInlineEnabled = Mage::getSingleton('core/translate')
|
30 |
+
->getTranslateInline();
|
31 |
+
}
|
32 |
+
if ($this->_isTranslateInlineEnabled) {
|
33 |
$parts = explode('}}{{', $output);
|
34 |
$parts[0] = vsprintf($parts[0], $args);
|
35 |
$result = implode('}}{{', $parts);
|
36 |
+
} else {
|
37 |
$result = vsprintf($output, $args);
|
38 |
}
|
39 |
}
|
46 |
|
47 |
$output = '';
|
48 |
$cart = $process['data']['cart'];
|
49 |
+
return $helper->evalInput(
|
50 |
+
$process,
|
51 |
+
$row,
|
52 |
+
$property,
|
53 |
+
str_replace(
|
54 |
+
array(
|
55 |
+
'{cart.weight}',
|
56 |
+
'{cart.price-tax+discount}',
|
57 |
+
'{cart.price-tax-discount}',
|
58 |
+
'{cart.price+tax+discount}',
|
59 |
+
'{cart.price+tax-discount}',
|
60 |
+
),
|
61 |
+
array(
|
62 |
+
$cart->getData('weight') . $cart->getData('weight_unit'),
|
63 |
+
$this->currency($cart->getData('price-tax+discount')),
|
64 |
+
$this->currency($cart->getData('price-tax-discount')),
|
65 |
+
$this->currency($cart->getData('price+tax+discount')),
|
66 |
+
$this->currency($cart->getData('price+tax-discount')),
|
67 |
+
),
|
68 |
+
$helper->getRowProperty($row, $property)
|
69 |
+
)
|
70 |
+
);
|
71 |
}
|
72 |
+
|
73 |
+
protected function getBoolean($path)
|
74 |
{
|
75 |
+
return (boolean) Mage::getStoreConfig('owebia_shipping2/' . $path);
|
76 |
+
}
|
77 |
+
|
78 |
+
public function getDataModelMap($helper, $carrierCode, $request)
|
79 |
+
{
|
80 |
+
$mageConfig = Mage::getConfig();
|
81 |
+
$cartOptions = array(
|
82 |
+
'bundle' => array(
|
83 |
+
'process_children' => $this->getBoolean('bundle_product/process_children'),
|
84 |
+
'load_item_options_on_parent' => $this->getBoolean('bundle_product/load_item_options_on_parent'),
|
85 |
+
'load_item_data_on_parent' => $this->getBoolean('bundle_product/load_item_data_on_parent'),
|
86 |
+
'load_product_data_on_parent' => $this->getBoolean('bundle_product/load_product_data_on_parent'),
|
87 |
+
),
|
88 |
+
'configurable' => array(
|
89 |
+
'load_item_options_on_parent' => $this->getBoolean('configurable_product/load_item_options_on_parent'),
|
90 |
+
'load_item_data_on_parent' => $this->getBoolean('configurable_product/load_item_data_on_parent'),
|
91 |
+
'load_product_data_on_parent' => $this->getBoolean('configurable_product/load_product_data_on_parent'),
|
92 |
+
),
|
93 |
+
);
|
94 |
return array(
|
95 |
+
'info' => Mage::getModel(
|
96 |
+
'owebia_shipping2/Os2_Data_Info',
|
97 |
+
array_merge(
|
98 |
+
$helper->getInfos(),
|
99 |
+
array(
|
100 |
+
'magento_version' => Mage::getVersion(),
|
101 |
+
'module_version' => (string)$mageConfig->getNode('modules/Owebia_Shipping2/version'),
|
102 |
+
'carrier_code' => $carrierCode,
|
103 |
+
)
|
104 |
+
)
|
105 |
+
),
|
106 |
+
'cart' => Mage::getModel(
|
107 |
+
'owebia_shipping2/Os2_Data_Cart',
|
108 |
+
array(
|
109 |
+
'request' => $request,
|
110 |
+
'options' => $cartOptions,
|
111 |
+
)
|
112 |
+
),
|
|
|
|
|
|
|
113 |
'quote' => Mage::getModel('owebia_shipping2/Os2_Data_Quote'),
|
114 |
'selection' => Mage::getModel('owebia_shipping2/Os2_Data_Selection'),
|
115 |
'customer' => Mage::getModel('owebia_shipping2/Os2_Data_Customer'),
|
117 |
'customvar' => Mage::getModel('owebia_shipping2/Os2_Data_Customvar'),
|
118 |
'date' => Mage::getModel('owebia_shipping2/Os2_Data_Date'),
|
119 |
'address_filter' => Mage::getModel('owebia_shipping2/Os2_Data_AddressFilter'),
|
120 |
+
'origin' => Mage::getModel(
|
121 |
+
'owebia_shipping2/Os2_Data_Address',
|
122 |
+
$this->_extract(
|
123 |
+
$request->getData(),
|
124 |
+
array(
|
125 |
+
'country_id' => 'country_id',
|
126 |
+
'region_id' => 'region_id',
|
127 |
+
'postcode' => 'postcode',
|
128 |
+
'city' => 'city',
|
129 |
+
)
|
130 |
+
)
|
131 |
+
),
|
132 |
+
'shipto' => Mage::getModel(
|
133 |
+
'owebia_shipping2/Os2_Data_Address',
|
134 |
+
$this->_extract(
|
135 |
+
$request->getData(),
|
136 |
+
array(
|
137 |
+
'country_id' => 'dest_country_id',
|
138 |
+
'region_id' => 'dest_region_id',
|
139 |
+
'region_code' => 'dest_region_code',
|
140 |
+
'street' => 'dest_street',
|
141 |
+
'city' => 'dest_city',
|
142 |
+
'postcode' => 'dest_postcode',
|
143 |
+
)
|
144 |
+
)
|
145 |
+
),
|
146 |
'billto' => Mage::getModel('owebia_shipping2/Os2_Data_Billto'),
|
147 |
'store' => Mage::getModel('owebia_shipping2/Os2_Data_Store', array('id' => $request->getData('store_id'))),
|
148 |
'request' => Mage::getModel('owebia_shipping2/Os2_Data_Abstract', $request->getData()),
|
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Owebia_Shipping2_Model_AddressFilterParser
|
8 |
+
{
|
9 |
+
protected $_configParser;
|
10 |
+
protected $_input = null;
|
11 |
+
protected $_position = null;
|
12 |
+
protected $_bufferStart = null;
|
13 |
+
protected $_char = null;
|
14 |
+
protected $_join = null;
|
15 |
+
|
16 |
+
protected $_output = '';
|
17 |
+
protected $_level = null;
|
18 |
+
protected $_parentLevel = null;
|
19 |
+
protected $_regexp = false;
|
20 |
+
protected $_litteral = false;
|
21 |
+
protected $_litteralQuote = null;
|
22 |
+
protected $_callbackMap = array(
|
23 |
+
'(' => 'openingParenthesisCallback',
|
24 |
+
')' => 'closingParenthesisCallback',
|
25 |
+
'"' => 'quoteCallback',
|
26 |
+
"'" => 'quoteCallback',
|
27 |
+
' ' => 'spaceCallback',
|
28 |
+
'-' => 'hyphenCallback',
|
29 |
+
',' => 'commaCallback',
|
30 |
+
'/' => 'slashCallback',
|
31 |
+
);
|
32 |
+
|
33 |
+
public function __construct($configParser)
|
34 |
+
{
|
35 |
+
$this->_configParser = $configParser;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function parse($input)
|
39 |
+
{
|
40 |
+
$this->current = array();
|
41 |
+
|
42 |
+
$this->_input = $input;
|
43 |
+
$this->length = strlen($this->_input);
|
44 |
+
// look at each character
|
45 |
+
$this->_join = ' && ';
|
46 |
+
for ($this->_position = 0; $this->_position < $this->length; $this->_position++) {
|
47 |
+
$this->_char = $this->_input[$this->_position];
|
48 |
+
if (isset($this->_callbackMap[$this->_char])) {
|
49 |
+
$this->{$this->_callbackMap[$this->_char]}();
|
50 |
+
} else {
|
51 |
+
$this->defaultCallback();
|
52 |
+
}
|
53 |
+
}
|
54 |
+
$this->push($this->buffer());
|
55 |
+
return $this->_output;
|
56 |
+
}
|
57 |
+
|
58 |
+
protected function closingParenthesisCallback()
|
59 |
+
{
|
60 |
+
if ($this->_regexp || $this->_litteral) {
|
61 |
+
return;
|
62 |
+
}
|
63 |
+
$this->push($this->buffer() . ')');
|
64 |
+
$this->_parentLevel = null;
|
65 |
+
}
|
66 |
+
|
67 |
+
protected function openingParenthesisCallback()
|
68 |
+
{
|
69 |
+
if ($this->_regexp || $this->_litteral) {
|
70 |
+
return;
|
71 |
+
}
|
72 |
+
$this->push($this->buffer());
|
73 |
+
$this->push($this->_join, $onlyIfNotEmpty = true);
|
74 |
+
$this->push('(');
|
75 |
+
$this->_parentLevel = $this->_level;
|
76 |
+
$this->_join = ' && ';
|
77 |
+
}
|
78 |
+
|
79 |
+
protected function quoteCallback()
|
80 |
+
{
|
81 |
+
if (!$this->_litteral || $this->_litteralQuote == $this->_char) {
|
82 |
+
$this->_litteral = !$this->_litteral;
|
83 |
+
$this->_litteralQuote = $this->_char;
|
84 |
+
}
|
85 |
+
if ($this->_bufferStart === null) {
|
86 |
+
$this->_bufferStart = $this->_position;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
protected function spaceCallback()
|
91 |
+
{
|
92 |
+
if ($this->_regexp || $this->_litteral) {
|
93 |
+
return;
|
94 |
+
}
|
95 |
+
$this->push($this->buffer());
|
96 |
+
}
|
97 |
+
|
98 |
+
protected function hyphenCallback()
|
99 |
+
{
|
100 |
+
if ($this->_regexp || $this->_litteral) {
|
101 |
+
return;
|
102 |
+
}
|
103 |
+
$this->push($this->buffer());
|
104 |
+
$this->_join = ' && !';
|
105 |
+
}
|
106 |
+
|
107 |
+
protected function commaCallback()
|
108 |
+
{
|
109 |
+
if ($this->_regexp || $this->_litteral) {
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
$this->push($this->buffer());
|
113 |
+
$this->push(' || ');
|
114 |
+
}
|
115 |
+
|
116 |
+
protected function slashCallback()
|
117 |
+
{
|
118 |
+
$this->_regexp = !$this->_regexp;
|
119 |
+
$this->defaultCallback();
|
120 |
+
}
|
121 |
+
|
122 |
+
protected function defaultCallback()
|
123 |
+
{
|
124 |
+
if ($this->_bufferStart === null) {
|
125 |
+
$this->_bufferStart = $this->_position;
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
protected function escapeString($input)
|
130 |
+
{
|
131 |
+
return $this->_configParser->escapeString($input);
|
132 |
+
}
|
133 |
+
|
134 |
+
protected function buffer()
|
135 |
+
{
|
136 |
+
if ($this->_bufferStart !== null) {
|
137 |
+
// extract string from buffer start to current position
|
138 |
+
$buffer = substr($this->_input, $this->_bufferStart, $this->_position - $this->_bufferStart);
|
139 |
+
// clean buffer
|
140 |
+
$this->_bufferStart = null;
|
141 |
+
// throw token into current scope
|
142 |
+
if ($buffer == '*') {
|
143 |
+
$buffer = 1;
|
144 |
+
} else if ($this->_parentLevel == 'country') {
|
145 |
+
if (preg_match('/^[A-Z]{2}$/', $buffer)) {
|
146 |
+
$buffer = "{{c}}==={$this->escapeString($buffer)}";
|
147 |
+
$this->_level = 'country';
|
148 |
+
} else if (substr($buffer, 0, 1) == '/'
|
149 |
+
&& (substr($buffer, strlen($buffer) - 1, 1) == '/'
|
150 |
+
|| substr($buffer, strlen($buffer) - 2, 2) == '/i'
|
151 |
+
)
|
152 |
+
) {
|
153 |
+
$buffer = "preg_match('" . str_replace("'", "\\'", $buffer) . "', (string)({{p}}))";
|
154 |
+
} else if (strpos($buffer, '*') !== false) {
|
155 |
+
$buffer = "preg_match('/^"
|
156 |
+
. str_replace(
|
157 |
+
array("'", '*'),
|
158 |
+
array("\\'", '(?:.*)'),
|
159 |
+
$buffer
|
160 |
+
)
|
161 |
+
. "$/', (string)({{p}}))";
|
162 |
+
} else if (preg_match('/^"[^"]+"$/', $buffer)) {
|
163 |
+
$buffer = trim($buffer, '"');
|
164 |
+
$buffer = "({{p}}==={$this->escapeString($buffer)} || {{r}}==={$this->escapeString($buffer)})";
|
165 |
+
} else if (preg_match('/^\'[^\']+\'$/', $buffer)) {
|
166 |
+
$buffer = trim($buffer, "'");
|
167 |
+
$buffer = "({{p}}==={$this->escapeString($buffer)} || {{r}}==={$this->escapeString($buffer)})";
|
168 |
+
} else {
|
169 |
+
$buffer = "({{p}}==={$this->escapeString($buffer)} || {{r}}==={$this->escapeString($buffer)})";
|
170 |
+
}
|
171 |
+
} else if (preg_match('/^[A-Z]{2}$/', $buffer)) {
|
172 |
+
$buffer = "{{c}}==={$this->escapeString($buffer)}";
|
173 |
+
$this->_level = 'country';
|
174 |
+
}
|
175 |
+
return $buffer;
|
176 |
+
}
|
177 |
+
return null;
|
178 |
+
}
|
179 |
+
|
180 |
+
protected function push($text, $onlyIfNotEmpty = false)
|
181 |
+
{
|
182 |
+
if (isset($text)) {
|
183 |
+
if (!$onlyIfNotEmpty || $this->_output) {
|
184 |
+
$this->_output .= $text;
|
185 |
+
}
|
186 |
+
}
|
187 |
+
}
|
188 |
+
}
|
@@ -1,38 +1,14 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
-
|
22 |
-
// if compilation
|
23 |
-
if (file_exists(dirname(__FILE__).'/Owebia_Shipping2_includes_OwebiaShippingHelper.php')) {
|
24 |
-
include_once 'Owebia_Shipping2_includes_OS2_AddressFilterParser.php';
|
25 |
-
include_once 'Owebia_Shipping2_includes_OwebiaShippingHelper.php';
|
26 |
-
} else {
|
27 |
-
include_once Mage::getBaseDir('code').'/community/Owebia/Shipping2/includes/OS2_AddressFilterParser.php';
|
28 |
-
include_once Mage::getBaseDir('code').'/community/Owebia/Shipping2/includes/OwebiaShippingHelper.php';
|
29 |
-
}
|
30 |
|
31 |
abstract class Owebia_Shipping2_Model_Carrier_Abstract extends Mage_Shipping_Model_Carrier_Abstract
|
32 |
{
|
33 |
protected $_config;
|
34 |
-
protected $
|
35 |
-
protected $
|
36 |
|
37 |
/**
|
38 |
* Collect rates for this shipping method based on information in $request
|
@@ -42,23 +18,10 @@ abstract class Owebia_Shipping2_Model_Carrier_Abstract extends Mage_Shipping_Mod
|
|
42 |
*/
|
43 |
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
44 |
{
|
45 |
-
//setlocale(LC_NUMERIC, 'fr_FR');
|
46 |
if (!$this->__getConfigData('active')) return false; // skip if not enabled
|
47 |
-
//$this->display($request->_data);
|
48 |
$process = $this->__getProcess($request);
|
49 |
return $this->getRates($process);
|
50 |
}
|
51 |
-
|
52 |
-
public function display($var)
|
53 |
-
{
|
54 |
-
$i = 0;
|
55 |
-
foreach ($var as $name => $value) {
|
56 |
-
//if ($i>20)
|
57 |
-
echo "{$name} => {$value}<br/>";
|
58 |
-
//$this->_helper->debug($name.' => '.$value.'<br/>');
|
59 |
-
$i++;
|
60 |
-
}
|
61 |
-
}
|
62 |
|
63 |
public function getRates($process)
|
64 |
{
|
@@ -70,11 +33,13 @@ abstract class Owebia_Shipping2_Model_Carrier_Abstract extends Mage_Shipping_Mod
|
|
70 |
{
|
71 |
$process = array();
|
72 |
$config = $this->_getConfig();
|
73 |
-
$
|
74 |
if (count($config)>0) {
|
75 |
-
foreach ($config as $row)
|
|
|
|
|
76 |
}
|
77 |
-
return $
|
78 |
}
|
79 |
|
80 |
public function isTrackingAvailable()
|
@@ -82,96 +47,106 @@ abstract class Owebia_Shipping2_Model_Carrier_Abstract extends Mage_Shipping_Mod
|
|
82 |
return true;
|
83 |
}
|
84 |
|
85 |
-
public function getTrackingInfo($
|
86 |
{
|
87 |
-
$
|
88 |
-
$
|
89 |
-
$
|
90 |
-
$parts = explode(':', $
|
91 |
-
if (count($parts)>=2) {
|
92 |
-
$
|
93 |
|
94 |
$process = array();
|
95 |
$config = $this->_getConfig();
|
96 |
-
|
97 |
if (isset($config[$parts[0]]['tracking_url'])) {
|
98 |
$row = $config[$parts[0]];
|
99 |
-
$
|
100 |
-
if (isset($
|
101 |
}
|
102 |
}
|
103 |
|
104 |
-
$
|
105 |
->setCarrier($this->_code)
|
106 |
->setCarrierTitle($this->__getConfigData('title'))
|
107 |
-
->setTracking($
|
108 |
->addData(
|
109 |
array(
|
110 |
-
'status'=> $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
)
|
112 |
-
)
|
113 |
-
|
114 |
-
|
115 |
-
->append($tracking_status)
|
116 |
-
;
|
117 |
|
118 |
-
if ($trackings = $
|
119 |
return false;
|
120 |
}
|
121 |
-
|
122 |
-
/***************************************************************************************************************************/
|
123 |
|
124 |
protected function _process(&$process)
|
125 |
{
|
126 |
-
$debug = (bool)
|
127 |
-
if ($debug) $this->
|
128 |
|
129 |
-
$
|
130 |
foreach ($process['config'] as $row) {
|
131 |
-
$result = $this->
|
132 |
if ($result->success) {
|
133 |
-
$
|
134 |
$this->__appendMethod($process, $row, $result->result);
|
135 |
if ($process['options']->stop_to_first_match) break;
|
136 |
}
|
137 |
}
|
138 |
-
|
139 |
-
$
|
140 |
-
if ($debug && $this->__checkRequest($
|
141 |
Mage::getSingleton('core/session')
|
142 |
-
->addNotice('DEBUG'
|
143 |
}
|
144 |
}
|
145 |
|
146 |
protected function _getConfig()
|
147 |
{
|
148 |
if (!isset($this->_config)) {
|
149 |
-
$this->
|
150 |
-
|
151 |
-
(boolean)$this->__getConfigData('auto_correction')
|
152 |
-
);
|
153 |
-
$this->_config = $this->_helper->getConfig();
|
154 |
}
|
155 |
return $this->_config;
|
156 |
}
|
157 |
|
158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
|
160 |
-
protected function __checkRequest($
|
161 |
{
|
162 |
list($router, $controller, $action) = explode('/', $path);
|
163 |
-
return $
|
|
|
|
|
164 |
}
|
165 |
|
166 |
protected function __getProcess($request)
|
167 |
{
|
168 |
-
$
|
169 |
-
$os2_config = $this->_getConfig();
|
170 |
-
$data = Mage::helper('owebia_shipping2')->getDataModelMap($this->_helper, $this->_code, $request);
|
171 |
$process = array(
|
172 |
'data' => $data,
|
173 |
'cart.items' => array(),
|
174 |
-
'config' => $
|
175 |
'result' => Mage::getModel('shipping/rate_result'),
|
176 |
'options' => (object)array(
|
177 |
'auto_escaping' => (boolean)$this->__getConfigData('auto_escaping'),
|
@@ -184,7 +159,7 @@ abstract class Owebia_Shipping2_Model_Carrier_Abstract extends Mage_Shipping_Mod
|
|
184 |
|
185 |
public function addDataModel($name, $model)
|
186 |
{
|
187 |
-
$this->
|
188 |
}
|
189 |
|
190 |
protected function __getConfigData($key)
|
@@ -199,11 +174,10 @@ abstract class Owebia_Shipping2_Model_Carrier_Abstract extends Mage_Shipping_Mod
|
|
199 |
->setCarrier($this->_code)
|
200 |
->setCarrierTitle($this->__getConfigData('title'))
|
201 |
->setMethod($row['*id'])
|
202 |
-
->setMethodTitle($helper->getMethodText($this->
|
203 |
-
->setMethodDescription($helper->getMethodText($this->
|
204 |
->setPrice($fees)
|
205 |
-
->setCost($fees)
|
206 |
-
;
|
207 |
|
208 |
$process['result']->append($method);
|
209 |
}
|
@@ -214,4 +188,3 @@ abstract class Owebia_Shipping2_Model_Carrier_Abstract extends Mage_Shipping_Mod
|
|
214 |
return Mage::helper('owebia_shipping2')->__($args);
|
215 |
}
|
216 |
}
|
217 |
-
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
abstract class Owebia_Shipping2_Model_Carrier_Abstract extends Mage_Shipping_Model_Carrier_Abstract
|
8 |
{
|
9 |
protected $_config;
|
10 |
+
protected $_parser;
|
11 |
+
protected $_dataModels = array();
|
12 |
|
13 |
/**
|
14 |
* Collect rates for this shipping method based on information in $request
|
18 |
*/
|
19 |
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
20 |
{
|
|
|
21 |
if (!$this->__getConfigData('active')) return false; // skip if not enabled
|
|
|
22 |
$process = $this->__getProcess($request);
|
23 |
return $this->getRates($process);
|
24 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
public function getRates($process)
|
27 |
{
|
33 |
{
|
34 |
$process = array();
|
35 |
$config = $this->_getConfig();
|
36 |
+
$allowedMethods = array();
|
37 |
if (count($config)>0) {
|
38 |
+
foreach ($config as $row) {
|
39 |
+
$allowedMethods[$row['*id']] = isset($row['label']) ? $row['label']['value'] : 'No label';
|
40 |
+
}
|
41 |
}
|
42 |
+
return $allowedMethods;
|
43 |
}
|
44 |
|
45 |
public function isTrackingAvailable()
|
47 |
return true;
|
48 |
}
|
49 |
|
50 |
+
public function getTrackingInfo($trackingNumber)
|
51 |
{
|
52 |
+
$originalTrackingNumber = $trackingNumber;
|
53 |
+
$globalTrackingUrl = $this->__getConfigData('tracking_view_url');
|
54 |
+
$trackingUrl = $globalTrackingUrl;
|
55 |
+
$parts = explode(':', $trackingNumber);
|
56 |
+
if (count($parts) >= 2) {
|
57 |
+
$trackingNumber = $parts[1];
|
58 |
|
59 |
$process = array();
|
60 |
$config = $this->_getConfig();
|
61 |
+
|
62 |
if (isset($config[$parts[0]]['tracking_url'])) {
|
63 |
$row = $config[$parts[0]];
|
64 |
+
$tmpTrackingUrl = $this->getParser()->getRowProperty($row, 'tracking_url');
|
65 |
+
if (isset($tmpTrackingUrl)) $trackingUrl = $tmpTrackingUrl;
|
66 |
}
|
67 |
}
|
68 |
|
69 |
+
$trackingStatus = Mage::getModel('shipping/tracking_result_status')
|
70 |
->setCarrier($this->_code)
|
71 |
->setCarrierTitle($this->__getConfigData('title'))
|
72 |
+
->setTracking($trackingNumber)
|
73 |
->addData(
|
74 |
array(
|
75 |
+
'status'=> $trackingUrl
|
76 |
+
? '<a target="_blank" href="' . str_replace('{tracking_number}', $trackingNumber, $trackingUrl)
|
77 |
+
. '">' . $this->__('track the package') . '</a>'
|
78 |
+
: "suivi non disponible pour le colis {$trackingNumber}"
|
79 |
+
. " (originalTrackingNumber='{$originalTrackingNumber}',"
|
80 |
+
. " globalTrackingUrl='{$globalTrackingUrl}'"
|
81 |
+
. (isset($row) ? ", tmpTrackingUrl='{$tmpTrackingUrl}'" : '')
|
82 |
+
. ")"
|
83 |
)
|
84 |
+
);
|
85 |
+
$trackingResult = Mage::getModel('shipping/tracking_result')
|
86 |
+
->append($trackingStatus);
|
|
|
|
|
87 |
|
88 |
+
if ($trackings = $trackingResult->getAllTrackings()) return $trackings[0];
|
89 |
return false;
|
90 |
}
|
|
|
|
|
91 |
|
92 |
protected function _process(&$process)
|
93 |
{
|
94 |
+
$debug = (bool)$this->__getConfigData('debug');
|
95 |
+
if ($debug) $this->getParser()->initDebug($this->_code, $process);
|
96 |
|
97 |
+
$valueFound = false;
|
98 |
foreach ($process['config'] as $row) {
|
99 |
+
$result = $this->getParser()->processRow($process, $row);
|
100 |
if ($result->success) {
|
101 |
+
$valueFound = true;
|
102 |
$this->__appendMethod($process, $row, $result->result);
|
103 |
if ($process['options']->stop_to_first_match) break;
|
104 |
}
|
105 |
}
|
106 |
+
|
107 |
+
$httpRequest = Mage::app()->getFrontController()->getRequest();
|
108 |
+
if ($debug && $this->__checkRequest($httpRequest, 'checkout/cart/index')) {
|
109 |
Mage::getSingleton('core/session')
|
110 |
+
->addNotice('DEBUG' . $this->getParser()->getDebug());
|
111 |
}
|
112 |
}
|
113 |
|
114 |
protected function _getConfig()
|
115 |
{
|
116 |
if (!isset($this->_config)) {
|
117 |
+
$this->_config = $this->getParser()
|
118 |
+
->getConfig();
|
|
|
|
|
|
|
119 |
}
|
120 |
return $this->_config;
|
121 |
}
|
122 |
|
123 |
+
protected function getParser()
|
124 |
+
{
|
125 |
+
if (!isset($this->_parser)) {
|
126 |
+
$this->_parser = Mage::getModel('owebia_shipping2/ConfigParser')
|
127 |
+
->init(
|
128 |
+
$this->__getConfigData('config'),
|
129 |
+
(boolean)$this->__getConfigData('auto_correction')
|
130 |
+
);
|
131 |
+
}
|
132 |
+
return $this->_parser;
|
133 |
+
}
|
134 |
|
135 |
+
protected function __checkRequest($httpRequest, $path)
|
136 |
{
|
137 |
list($router, $controller, $action) = explode('/', $path);
|
138 |
+
return $httpRequest->getRouteName() == $router
|
139 |
+
&& $httpRequest->getControllerName() == $controller
|
140 |
+
&& $httpRequest->getActionName() == $action;
|
141 |
}
|
142 |
|
143 |
protected function __getProcess($request)
|
144 |
{
|
145 |
+
$data = Mage::helper('owebia_shipping2')->getDataModelMap($this->getParser(), $this->_code, $request);
|
|
|
|
|
146 |
$process = array(
|
147 |
'data' => $data,
|
148 |
'cart.items' => array(),
|
149 |
+
'config' => $this->_getConfig(),
|
150 |
'result' => Mage::getModel('shipping/rate_result'),
|
151 |
'options' => (object)array(
|
152 |
'auto_escaping' => (boolean)$this->__getConfigData('auto_escaping'),
|
159 |
|
160 |
public function addDataModel($name, $model)
|
161 |
{
|
162 |
+
$this->_dataModels[$name] = $model;
|
163 |
}
|
164 |
|
165 |
protected function __getConfigData($key)
|
174 |
->setCarrier($this->_code)
|
175 |
->setCarrierTitle($this->__getConfigData('title'))
|
176 |
->setMethod($row['*id'])
|
177 |
+
->setMethodTitle($helper->getMethodText($this->getParser(), $process, $row, 'label'))
|
178 |
+
->setMethodDescription($helper->getMethodText($this->getParser(), $process, $row, 'description'))
|
179 |
->setPrice($fees)
|
180 |
+
->setCost($fees);
|
|
|
181 |
|
182 |
$process['result']->append($method);
|
183 |
}
|
188 |
return Mage::helper('owebia_shipping2')->__($args);
|
189 |
}
|
190 |
}
|
|
@@ -1,23 +1,8 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Carrier_OwebiaShipping1 extends Owebia_Shipping2_Model_Carrier_Abstract
|
23 |
{
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Carrier_OwebiaShipping1 extends Owebia_Shipping2_Model_Carrier_Abstract
|
8 |
{
|
@@ -1,23 +1,8 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Carrier_OwebiaShipping2 extends Owebia_Shipping2_Model_Carrier_Abstract
|
23 |
{
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Carrier_OwebiaShipping2 extends Owebia_Shipping2_Model_Carrier_Abstract
|
8 |
{
|
@@ -1,25 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Copyright (c) 2008-14 Owebia
|
5 |
-
*
|
6 |
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
-
|
22 |
-
class Owebia_Shipping2_Model_Carrier_OwebiaShipping3 extends Owebia_Shipping2_Model_Carrier_Abstract
|
23 |
-
{
|
24 |
-
protected $_code = 'owebiashipping3';
|
25 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -0,0 +1,1940 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Owebia_Shipping2_Model_ConfigParser
|
8 |
+
{
|
9 |
+
const FLOAT_REGEX = '[-]?\d+(?:[.]\d+)?';
|
10 |
+
const COUPLE_REGEX = '(?:[0-9.]+|\*) *(?:\[|\])? *\: *[0-9.]+';
|
11 |
+
|
12 |
+
public static $debugIndexCounter = 0;
|
13 |
+
|
14 |
+
public static function esc($input)
|
15 |
+
{
|
16 |
+
$input = htmlspecialchars($input, ENT_NOQUOTES, 'UTF-8');
|
17 |
+
return preg_replace('/<(\/?)span([^&]*)>/', '<\1span\2>', $input);
|
18 |
+
}
|
19 |
+
|
20 |
+
public static function toString($value)
|
21 |
+
{
|
22 |
+
if (!isset($value)) return 'null';
|
23 |
+
else if (is_bool($value)) return $value ? 'true' : 'false';
|
24 |
+
else if (is_float($value)) return str_replace(',', '.', (string)$value); // To avoid locale problems
|
25 |
+
else if (is_array($value)) return 'array(size:' . count($value) . ')';
|
26 |
+
else if (is_object($value)) return get_class($value) . '';
|
27 |
+
else return $value;
|
28 |
+
}
|
29 |
+
|
30 |
+
public static function parseSize($size)
|
31 |
+
{
|
32 |
+
$size = trim($size);
|
33 |
+
$last = strtolower($size[strlen($size)-1]);
|
34 |
+
switch ($last) {
|
35 |
+
case 'g': $size *= 1024;
|
36 |
+
case 'm': $size *= 1024;
|
37 |
+
case 'k': $size *= 1024;
|
38 |
+
}
|
39 |
+
return (float)$size;
|
40 |
+
}
|
41 |
+
|
42 |
+
public static function formatSize($size)
|
43 |
+
{
|
44 |
+
$unit = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
|
45 |
+
$unitIndex = floor(log($size, 1024));
|
46 |
+
$divisor = $unitIndex == 0 ? 1 : pow(1024, $unitIndex);
|
47 |
+
return self::toString(round($size / $divisor, 2)) . ' ' . $unit[$unitIndex];
|
48 |
+
}
|
49 |
+
|
50 |
+
public static function getInfos()
|
51 |
+
{
|
52 |
+
$properties = array(
|
53 |
+
'server_os' => PHP_OS,
|
54 |
+
'server_software' => $_SERVER['SERVER_SOFTWARE'],
|
55 |
+
'php_version' => PHP_VERSION,
|
56 |
+
'memory_limit' => self::formatSize(self::parseSize(ini_get('memory_limit'))),
|
57 |
+
'memory_usage' => self::formatSize(memory_get_usage(true)),
|
58 |
+
);
|
59 |
+
return $properties;
|
60 |
+
}
|
61 |
+
|
62 |
+
public static function getDefaultProcessData()
|
63 |
+
{
|
64 |
+
return array(
|
65 |
+
'info' => Mage::getModel('owebia_shipping2/Os2_Data')->setData(self::getInfos()),
|
66 |
+
'cart' => Mage::getModel('owebia_shipping2/Os2_Data'),
|
67 |
+
'quote' => Mage::getModel('owebia_shipping2/Os2_Data'),
|
68 |
+
'selection' => Mage::getModel('owebia_shipping2/Os2_Data'),
|
69 |
+
'customer' => Mage::getModel('owebia_shipping2/Os2_Data'),
|
70 |
+
'customer_group' => Mage::getModel('owebia_shipping2/Os2_Data'),
|
71 |
+
'customvar' => Mage::getModel('owebia_shipping2/Os2_Data'),
|
72 |
+
'date' => Mage::getModel('owebia_shipping2/Os2_Data'),
|
73 |
+
'origin' => Mage::getModel('owebia_shipping2/Os2_Data'),
|
74 |
+
'shipto' => Mage::getModel('owebia_shipping2/Os2_Data'),
|
75 |
+
'billto' => Mage::getModel('owebia_shipping2/Os2_Data'),
|
76 |
+
'store' => Mage::getModel('owebia_shipping2/Os2_Data'),
|
77 |
+
'request' => Mage::getModel('owebia_shipping2/Os2_Data'),
|
78 |
+
'address_filter' => Mage::getModel('owebia_shipping2/Os2_Data'),
|
79 |
+
);
|
80 |
+
}
|
81 |
+
|
82 |
+
protected static function jsonEncodeArray($data, $beautify, $html, $level, $currentIndent)
|
83 |
+
{
|
84 |
+
$indent = "\t";
|
85 |
+
$newIndent = $currentIndent . $indent;
|
86 |
+
$lineBreak = $html ? '<br/>' : "\n";
|
87 |
+
$outputIndexCount = 0;
|
88 |
+
$output = array();
|
89 |
+
foreach ($data as $key => $value) {
|
90 |
+
if ($outputIndexCount !== null && $outputIndexCount++ !== $key) {
|
91 |
+
$outputIndexCount = null;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
$isAssociative = $outputIndexCount === null;
|
95 |
+
foreach ($data as $key => $value) {
|
96 |
+
if ($isAssociative) {
|
97 |
+
$classes = array();
|
98 |
+
if ($key == 'about') {
|
99 |
+
$classes[] = 'json-about';
|
100 |
+
} elseif ($key == 'conditions' || $key == 'fees') {
|
101 |
+
$classes[] = 'json-formula';
|
102 |
+
}
|
103 |
+
$propertyClasses = array('json-property');
|
104 |
+
if ($level == 0) {
|
105 |
+
$propertyClasses[] = 'json-id';
|
106 |
+
}
|
107 |
+
$output[] = ($html && $classes ? '<span class="' . implode(' ', $classes) . '">' : '')
|
108 |
+
. ($html ? '<span class="' . implode(' ', $propertyClasses) . '">' : '')
|
109 |
+
. self::jsonEncode((string)$key)
|
110 |
+
. ($html ? '</span>' : '') . ':'
|
111 |
+
. ($beautify ? ' ' : '')
|
112 |
+
. self::jsonEncode($value, $beautify, $html, $level+1, $newIndent)
|
113 |
+
. ($html && $classes ? '</span>' : '');
|
114 |
+
} else {
|
115 |
+
$output[] = self::jsonEncode($value, $beautify, $html, $level+1, $currentIndent);
|
116 |
+
}
|
117 |
+
}
|
118 |
+
if ($isAssociative) {
|
119 |
+
$classes = array();
|
120 |
+
if (isset($data['type']) && $data['type']=='meta') $classes[] = 'json-meta';
|
121 |
+
$output = ($html && $classes ? '<span class="' . implode(' ', $classes) . '">' : '')
|
122 |
+
.'{'
|
123 |
+
.($beautify ? "{$lineBreak}{$newIndent}" : '')
|
124 |
+
.implode(',' . ($beautify ? "{$lineBreak}{$newIndent}" : ''), $output)
|
125 |
+
.($beautify ? "{$lineBreak}{$currentIndent}" : '')
|
126 |
+
.'}'
|
127 |
+
.($html && $classes ? '</span>' : '');
|
128 |
+
return $output;
|
129 |
+
} else {
|
130 |
+
return '[' . implode(',' . ($beautify ? ' ' : ''), $output) . ']';
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
public static function jsonEncode($data, $beautify = false, $html = false, $level = 0, $currentIndent = '')
|
135 |
+
{
|
136 |
+
switch ($type = self::getType($data)) {
|
137 |
+
case 'NULL':
|
138 |
+
return ($html ? '<span class=json-reserved>' : '') . 'null' . ($html ? '</span>' : '');
|
139 |
+
case 'boolean':
|
140 |
+
return ($html ? '<span class=json-reserved>' : '')
|
141 |
+
. ($data ? 'true' : 'false')
|
142 |
+
. ($html ? '</span>' : '');
|
143 |
+
case 'integer':
|
144 |
+
case 'double':
|
145 |
+
case 'float':
|
146 |
+
return ($html ? '<span class=json-numeric>' : '') . $data . ($html ? '</span>' : '');
|
147 |
+
case 'string':
|
148 |
+
return ($html ? '<span class=json-string>' : '')
|
149 |
+
. '"'
|
150 |
+
. str_replace(
|
151 |
+
array("\\", '"', "\n", "\r"),
|
152 |
+
array("\\\\", '\"', "\\n", "\\r"),
|
153 |
+
$html ? htmlspecialchars($data, ENT_COMPAT, 'UTF-8') : $data
|
154 |
+
)
|
155 |
+
. '"'
|
156 |
+
. ($html ? '</span>' : '');
|
157 |
+
case 'object':
|
158 |
+
$data = (array)$data;
|
159 |
+
case 'array':
|
160 |
+
return static::jsonEncodeArray($data, $beautify, $html, $level, $currentIndent);
|
161 |
+
default:
|
162 |
+
return ''; // Not supported
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
protected static function json_decode($input)
|
167 |
+
{
|
168 |
+
if (function_exists('json_decode')) { // PHP >= 5.2.0
|
169 |
+
$output = json_decode($input);
|
170 |
+
if (function_exists('json_last_error')) { // PHP >= 5.3.0
|
171 |
+
$error = json_last_error();
|
172 |
+
if ($error != JSON_ERROR_NONE) {
|
173 |
+
Mage::throwException($error);
|
174 |
+
}
|
175 |
+
}
|
176 |
+
return $output;
|
177 |
+
} else {
|
178 |
+
return Zend_Json::decode($input);
|
179 |
+
}
|
180 |
+
}
|
181 |
+
|
182 |
+
protected static function json_encode($input)
|
183 |
+
{
|
184 |
+
if (function_exists('json_encode')) {
|
185 |
+
return json_encode($input);
|
186 |
+
} else {
|
187 |
+
return Zend_Json::encode($input);
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
public static function escapeString($input)
|
192 |
+
{
|
193 |
+
$escaped = self::json_encode($input);
|
194 |
+
$escaped = preg_replace_callback(
|
195 |
+
'/\\\\u([0-9a-fA-F]{4})/',
|
196 |
+
function ($match) {
|
197 |
+
return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
|
198 |
+
},
|
199 |
+
$escaped
|
200 |
+
);
|
201 |
+
return $escaped;
|
202 |
+
}
|
203 |
+
|
204 |
+
protected $_input;
|
205 |
+
protected $_config;
|
206 |
+
protected $_messages;
|
207 |
+
protected $_formulaCache;
|
208 |
+
protected $_expressionCache;
|
209 |
+
protected $_debugPrefix;
|
210 |
+
public $debugCode = null;
|
211 |
+
public $debugOutput = '';
|
212 |
+
public $debugHeader = null;
|
213 |
+
|
214 |
+
public function init($input, $autoCorrection)
|
215 |
+
{
|
216 |
+
$this->_config = array();
|
217 |
+
$this->_messages = array();
|
218 |
+
$this->_formulaCache = array();
|
219 |
+
$this->_expressionCache = array();
|
220 |
+
$this->_debugPrefix = '';
|
221 |
+
$this->_input = $input;
|
222 |
+
$this->_parseInput($autoCorrection);
|
223 |
+
return $this;
|
224 |
+
}
|
225 |
+
|
226 |
+
public function addDebugIndent()
|
227 |
+
{
|
228 |
+
$this->_debugPrefix .= ' ';
|
229 |
+
}
|
230 |
+
|
231 |
+
public function removeDebugIndent()
|
232 |
+
{
|
233 |
+
$this->_debugPrefix = substr($this->_debugPrefix, 0, strlen($this->_debugPrefix) - 3);
|
234 |
+
}
|
235 |
+
|
236 |
+
public function debug($text)
|
237 |
+
{
|
238 |
+
$this->debugOutput .= "<p>{$this->_debugPrefix}{$text}</p>";
|
239 |
+
}
|
240 |
+
|
241 |
+
public function getDebug()
|
242 |
+
{
|
243 |
+
$index = $this->debugCode . '-' . self::$debugIndexCounter++;
|
244 |
+
$output = "<style rel=stylesheet type=\"text/css\">"
|
245 |
+
. ".osh-debug{background:#000;color:#bbb;-webkit-opacity:0.9;-moz-opacity:0.9;opacity:0.9;"
|
246 |
+
. "text-align:left;white-space:pre-wrap;overflow:auto;}"
|
247 |
+
. ".osh-debug p{margin:2px 0;}"
|
248 |
+
. ".osh-formula{color:#f90;} .osh-key{color:#0099f7;} .osh-loop{color:#ff0;}"
|
249 |
+
. ".osh-error{color:#f00;} .osh-warning{color:#ff0;} .osh-info{color:#7bf700;}"
|
250 |
+
. ".osh-debug-content{padding:10px;font-family:monospace}"
|
251 |
+
. ".osh-replacement{color:#ff3000;}"
|
252 |
+
. "</style>"
|
253 |
+
. "<div id=osh-debug-{$index} class=osh-debug>"
|
254 |
+
. "<div class=osh-debug-content>"
|
255 |
+
. "<span class=osh-close style=\"float:right;cursor:pointer;\""
|
256 |
+
. " onclick=\"document.getElementById('osh-debug-{$index}').style.display = 'none';\""
|
257 |
+
. ">[<span style=\"padding:0 5px;color:#f00;\">X</span>]</span>"
|
258 |
+
. "<p>{$this->debugHeader}</p>{$this->debugOutput}</div></div>";
|
259 |
+
return $output;
|
260 |
+
}
|
261 |
+
|
262 |
+
protected function getVariableDisplay($variablePath, $variableValue)
|
263 |
+
{
|
264 |
+
return '<span class=osh-key>'
|
265 |
+
. self::esc(str_replace('.', '</span>.<span class=osh-key>', $variablePath))
|
266 |
+
. '</span> = <span class=osh-formula>'
|
267 |
+
. self::esc(self::toString($variableValue))
|
268 |
+
. '</span> (' . self::getType($variableValue) . ')<br/>';
|
269 |
+
}
|
270 |
+
|
271 |
+
protected function initDebugData($objectName, $data)
|
272 |
+
{
|
273 |
+
$header = '';
|
274 |
+
if (is_object($data) || is_array($data)) {
|
275 |
+
$header .= ' <span class=osh-key>'
|
276 |
+
. self::esc(str_replace('.', '</span>.<span class=osh-key>', $objectName))
|
277 |
+
. '</span> >><br/>';
|
278 |
+
$children = array();
|
279 |
+
if (is_object($data)) {
|
280 |
+
$children = $data->__sleep();
|
281 |
+
} elseif (is_array($data)) {
|
282 |
+
$children = array_keys($data);
|
283 |
+
}
|
284 |
+
foreach ($children as $name) {
|
285 |
+
$key = $name;
|
286 |
+
if ($key == '*') {
|
287 |
+
$header .= ' .<span class=osh-key>'
|
288 |
+
. self::esc(str_replace('.', '</span>.<span class=osh-key>', $key))
|
289 |
+
. '</span> = …<br/>';
|
290 |
+
} else {
|
291 |
+
if (is_object($data)) {
|
292 |
+
$value = $data->{$name};
|
293 |
+
} elseif (is_array($data)) {
|
294 |
+
$children = $data[$name];
|
295 |
+
}
|
296 |
+
$header .= ' .' . $this->getVariableDisplay($key, $value);
|
297 |
+
}
|
298 |
+
}
|
299 |
+
} else {
|
300 |
+
$header .= ' .' . $this->getVariableDisplay($objectName, $data);
|
301 |
+
}
|
302 |
+
return $header;
|
303 |
+
}
|
304 |
+
|
305 |
+
public function initDebug($code, $process)
|
306 |
+
{
|
307 |
+
$header = 'DEBUG ConfigParser.php<br/>';
|
308 |
+
foreach ($process as $index => $processOption) {
|
309 |
+
if (in_array($index, array('data', 'options'))) {
|
310 |
+
$header .= ' <span class=osh-key>'
|
311 |
+
. self::esc(str_replace('.', '</span>.<span class=osh-key>', $index))
|
312 |
+
. '</span> >><br/>';
|
313 |
+
foreach ($processOption as $objectName => $data) {
|
314 |
+
$header .= $this->initDebugData($objectName, $data);
|
315 |
+
}
|
316 |
+
} else {
|
317 |
+
$header .= ' ' . $this->getVariableDisplay($index, $processOption);
|
318 |
+
}
|
319 |
+
}
|
320 |
+
$this->debugCode = $code;
|
321 |
+
$this->debugHeader = $header;
|
322 |
+
}
|
323 |
+
|
324 |
+
public function getConfig()
|
325 |
+
{
|
326 |
+
return $this->_config;
|
327 |
+
}
|
328 |
+
|
329 |
+
public function getConfigRow($id)
|
330 |
+
{
|
331 |
+
return isset($this->_config[$id]) ? $this->_config[$id] : null;
|
332 |
+
}
|
333 |
+
|
334 |
+
public function setConfig($config)
|
335 |
+
{
|
336 |
+
return $this->_config = $config;
|
337 |
+
}
|
338 |
+
|
339 |
+
public function getMessages()
|
340 |
+
{
|
341 |
+
$messages = $this->_messages;
|
342 |
+
$this->_messages = array();
|
343 |
+
return $messages;
|
344 |
+
}
|
345 |
+
|
346 |
+
public function sortProperties($firstKey, $secondKey)
|
347 |
+
{
|
348 |
+
$firstKeyPosition = isset($this->propertiesSort[$firstKey]) ? $this->propertiesSort[$firstKey] : 1000;
|
349 |
+
$secondKeyPosition = isset($this->propertiesSort[$secondKey]) ? $this->propertiesSort[$secondKey] : 1000;
|
350 |
+
return $firstKeyPosition == $secondKeyPosition
|
351 |
+
? strcmp($firstKey, $secondKey) : $firstKeyPosition - $secondKeyPosition;
|
352 |
+
}
|
353 |
+
|
354 |
+
public function formatConfig($compress, $keysToRemove = array(), $html = false)
|
355 |
+
{
|
356 |
+
$objectArray = array();
|
357 |
+
$this->propertiesSort = array_flip(
|
358 |
+
array(
|
359 |
+
'type',
|
360 |
+
'about',
|
361 |
+
'enabled',
|
362 |
+
'label',
|
363 |
+
'description',
|
364 |
+
'shipto',
|
365 |
+
'billto',
|
366 |
+
'origin',
|
367 |
+
'conditions',
|
368 |
+
'fees',
|
369 |
+
'tracking_url',
|
370 |
+
)
|
371 |
+
);
|
372 |
+
foreach ($this->_config as $code => $row) {
|
373 |
+
$object = array();
|
374 |
+
foreach ($row as $key => $property) {
|
375 |
+
if (substr($key, 0, 1) != '*' && !in_array($key, $keysToRemove)) {
|
376 |
+
$object[$key] = $property['value'];
|
377 |
+
}
|
378 |
+
}
|
379 |
+
uksort($object, array($this, 'sortProperties'));
|
380 |
+
$objectArray[$code] = $object;
|
381 |
+
}
|
382 |
+
return self::jsonEncode($objectArray, $beautify = !$compress, $html);
|
383 |
+
}
|
384 |
+
|
385 |
+
public function checkConfig()
|
386 |
+
{
|
387 |
+
$timestamp = (int)Mage::getModel('core/date')->timestamp();
|
388 |
+
$process = array(
|
389 |
+
'config' => $this->_config,
|
390 |
+
'data' => self::getDefaultProcessData(),
|
391 |
+
'result' => null,
|
392 |
+
);
|
393 |
+
foreach ($this->_config as $code => &$row) {
|
394 |
+
$this->processRow($process, $row, $checkAllConditions = true);
|
395 |
+
foreach ($row as $propertyName => $propertyValue) {
|
396 |
+
if (substr($propertyName, 0, 1) != '*') {
|
397 |
+
$this->debug(' check ' . $propertyName);
|
398 |
+
$this->getRowProperty($row, $propertyName);
|
399 |
+
}
|
400 |
+
}
|
401 |
+
}
|
402 |
+
}
|
403 |
+
|
404 |
+
protected function createResult()
|
405 |
+
{
|
406 |
+
return Mage::getModel('owebia_shipping2/Os2_Result')
|
407 |
+
->setConfigParser($this);
|
408 |
+
}
|
409 |
+
|
410 |
+
protected function processRowType(&$row)
|
411 |
+
{
|
412 |
+
$type = $this->getRowProperty($row, 'type');
|
413 |
+
if ($type == 'data') {
|
414 |
+
foreach ($row as $key => $data) {
|
415 |
+
if (in_array($key, array('*id', 'code', 'type'))) continue;
|
416 |
+
$value = isset($data['value']) ? $data['value'] : $data;
|
417 |
+
$this->debug(
|
418 |
+
' .<span class=osh-key>' . self::esc($key) . '</span>'
|
419 |
+
. ' = <span class=osh-formula>' . self::esc(self::toString($value)) . '</span>'
|
420 |
+
. ' (' . self::getType($value) . ')'
|
421 |
+
);
|
422 |
+
}
|
423 |
+
return $this->createResult()
|
424 |
+
->setSuccess(false);
|
425 |
+
}
|
426 |
+
if (isset($type) && $type != 'method') {
|
427 |
+
return $this->createResult()
|
428 |
+
->setSuccess(false);
|
429 |
+
}
|
430 |
+
return null;
|
431 |
+
}
|
432 |
+
|
433 |
+
protected function processRowEnabled(&$row, $isChecking)
|
434 |
+
{
|
435 |
+
$enabled = $this->getRowProperty($row, 'enabled');
|
436 |
+
if (isset($enabled)) {
|
437 |
+
if (!$isChecking && !$enabled) {
|
438 |
+
$this->addMessage('info', $row, 'enabled', 'Configuration disabled');
|
439 |
+
return $this->createResult()
|
440 |
+
->setSuccess(false);
|
441 |
+
}
|
442 |
+
}
|
443 |
+
return null;
|
444 |
+
}
|
445 |
+
|
446 |
+
protected function processRowConditions($process, &$row, $isChecking)
|
447 |
+
{
|
448 |
+
$conditions = $this->getRowProperty($row, 'conditions');
|
449 |
+
if (isset($conditions)) {
|
450 |
+
$result = $this->processFormula($process, $row, 'conditions', $conditions, $isChecking);
|
451 |
+
if (!$isChecking) {
|
452 |
+
if (!$result->success) return $result;
|
453 |
+
if (!$result->result) {
|
454 |
+
$this->addMessage('info', $row, 'conditions', "The cart doesn't match conditions");
|
455 |
+
return $this->createResult()
|
456 |
+
->setSuccess(false);
|
457 |
+
}
|
458 |
+
}
|
459 |
+
}
|
460 |
+
return null;
|
461 |
+
}
|
462 |
+
|
463 |
+
protected function processRowCustomerGroups($process, &$row, $isChecking)
|
464 |
+
{
|
465 |
+
$customerGroups = $this->getRowProperty($row, 'customer_groups');
|
466 |
+
if (isset($customerGroups)) {
|
467 |
+
$groups = explode(',', $customerGroups);
|
468 |
+
$groupMatch = false;
|
469 |
+
$customerGroup = $process['data']['customer_group'];
|
470 |
+
foreach ($groups as $group) {
|
471 |
+
$group = trim($group);
|
472 |
+
if ($group == '*'
|
473 |
+
|| $group == $customerGroup->code
|
474 |
+
|| ctype_digit($group) && $group == $customerGroup->id
|
475 |
+
) {
|
476 |
+
$this->debug(
|
477 |
+
' group <span class=osh-replacement>' . self::esc($customerGroup->code) . '</span>'
|
478 |
+
. ' (id:<span class=osh-replacement>' . self::esc($customerGroup->id) . '</span>) matches'
|
479 |
+
);
|
480 |
+
$groupMatch = true;
|
481 |
+
break;
|
482 |
+
}
|
483 |
+
}
|
484 |
+
if (!$isChecking && !$groupMatch) {
|
485 |
+
$this->addMessage(
|
486 |
+
'info',
|
487 |
+
$row,
|
488 |
+
'customer_groups',
|
489 |
+
"Customer group not allowed (%s)",
|
490 |
+
$customerGroup->code
|
491 |
+
);
|
492 |
+
return $this->createResult()
|
493 |
+
->setSuccess(false);
|
494 |
+
}
|
495 |
+
}
|
496 |
+
return null;
|
497 |
+
}
|
498 |
+
|
499 |
+
protected function processRowAddresses($process, &$row, $isChecking)
|
500 |
+
{
|
501 |
+
$addressProperties = array(
|
502 |
+
'shipto' => "Shipping zone not allowed",
|
503 |
+
'billto' => "Billing zone not allowed",
|
504 |
+
'origin' => "Shipping origin not allowed",
|
505 |
+
);
|
506 |
+
foreach ($addressProperties as $propertyName => $failureMessage) {
|
507 |
+
$propertyValue = $this->getRowProperty($row, $propertyName);
|
508 |
+
if (isset($propertyValue)) {
|
509 |
+
$match = $this->_addressMatch(
|
510 |
+
$process,
|
511 |
+
$row,
|
512 |
+
$propertyName,
|
513 |
+
$propertyValue,
|
514 |
+
$process['data'][$propertyName]
|
515 |
+
);
|
516 |
+
if (!$isChecking && !$match) {
|
517 |
+
$this->addMessage('info', $row, $propertyName, $failureMessage);
|
518 |
+
return $this->createResult()
|
519 |
+
->setSuccess(false);
|
520 |
+
}
|
521 |
+
}
|
522 |
+
}
|
523 |
+
return null;
|
524 |
+
}
|
525 |
+
|
526 |
+
protected function processRowFees($process, &$row, $isChecking)
|
527 |
+
{
|
528 |
+
$fees = $this->getRowProperty($row, 'fees');
|
529 |
+
if (isset($fees)) {
|
530 |
+
$result = $this->processFormula($process, $row, 'fees', $fees, $isChecking);
|
531 |
+
if (!$result->success) return $result;
|
532 |
+
$this->debug(
|
533 |
+
' » <span class=osh-info>result</span>'
|
534 |
+
. ' = <span class=osh-formula>' . self::esc(self::toString($result->result)) . '</span>'
|
535 |
+
);
|
536 |
+
return $this->createResult()
|
537 |
+
->setSuccess(true)
|
538 |
+
->setResult((float)$result->result);
|
539 |
+
}
|
540 |
+
return null;
|
541 |
+
}
|
542 |
+
|
543 |
+
public function processRow($process, &$row, $isChecking = false)
|
544 |
+
{
|
545 |
+
if (!isset($row['*id'])) {
|
546 |
+
$this->debug('skip row with unknown id');
|
547 |
+
return $this->createResult()
|
548 |
+
->setSuccess(false);
|
549 |
+
}
|
550 |
+
$this->debug('process row <span class=osh-key>' . self::esc($row['*id']) . '</span>');
|
551 |
+
|
552 |
+
if (isset($row['about'])) { // Display on debug
|
553 |
+
$about = $this->getRowProperty($row, 'about');
|
554 |
+
}
|
555 |
+
|
556 |
+
$result = $this->processRowType($row);
|
557 |
+
if (isset($result)) {
|
558 |
+
return $result;
|
559 |
+
}
|
560 |
+
|
561 |
+
if (!isset($row['label']['value'])) {
|
562 |
+
$row['label']['value'] = '***';
|
563 |
+
}
|
564 |
+
|
565 |
+
$result = $this->processRowEnabled($row, $isChecking);
|
566 |
+
if (isset($result)) {
|
567 |
+
return $result;
|
568 |
+
}
|
569 |
+
|
570 |
+
$result = $this->processRowConditions($process, $row, $isChecking);
|
571 |
+
if (isset($result)) {
|
572 |
+
return $result;
|
573 |
+
}
|
574 |
+
|
575 |
+
$result = $this->processRowAddresses($process, $row, $isChecking);
|
576 |
+
if (isset($result)) {
|
577 |
+
return $result;
|
578 |
+
}
|
579 |
+
|
580 |
+
$result = $this->processRowCustomerGroups($process, $row, $isChecking);
|
581 |
+
if (isset($result)) {
|
582 |
+
return $result;
|
583 |
+
}
|
584 |
+
|
585 |
+
$result = $this->processRowFees($process, $row, $isChecking);
|
586 |
+
if (isset($result)) {
|
587 |
+
return $result;
|
588 |
+
}
|
589 |
+
return $this->createResult()
|
590 |
+
->setSuccess(false);
|
591 |
+
}
|
592 |
+
|
593 |
+
public function getRowProperty(&$row, $key, $originalRow = null, $originalKey = null)
|
594 |
+
{
|
595 |
+
$property = null;
|
596 |
+
$output = null;
|
597 |
+
if (isset($originalRow) && isset($originalKey) && $originalRow['*id'] == $row['*id'] && $originalKey == $key) {
|
598 |
+
$this->addMessage(
|
599 |
+
'error',
|
600 |
+
$row,
|
601 |
+
$key,
|
602 |
+
'Infinite loop %s',
|
603 |
+
"<span class=\"code\">{{$row['*id']}.{$key}}</span>"
|
604 |
+
);
|
605 |
+
return array('error' => 'Infinite loop');
|
606 |
+
}
|
607 |
+
if (isset($row[$key]['value'])) {
|
608 |
+
$property = $row[$key]['value'];
|
609 |
+
$output = $property;
|
610 |
+
$this->debug(
|
611 |
+
' get <span class=osh-key>' . self::esc($row['*id']) . '</span>'
|
612 |
+
. '.<span class=osh-key>' . self::esc($key) . '</span>'
|
613 |
+
. ' = <span class=osh-formula>' . self::esc(self::toString($property)) . '</span>'
|
614 |
+
);
|
615 |
+
preg_match_all('/{([a-z0-9_]+)\.([a-z0-9_]+)}/i', $output, $resultSet, PREG_SET_ORDER);
|
616 |
+
foreach ($resultSet as $result) {
|
617 |
+
list($original, $refCode, $refKey) = $result;
|
618 |
+
if ($refCode == $row['*id'] && $refKey == $key) {
|
619 |
+
$this->addMessage(
|
620 |
+
'error',
|
621 |
+
$row,
|
622 |
+
$key,
|
623 |
+
'Infinite loop %s',
|
624 |
+
"<span class=\"code\">{$original}</span>"
|
625 |
+
);
|
626 |
+
return null;
|
627 |
+
}
|
628 |
+
if (isset($this->_config[$refCode][$refKey]['value'])) {
|
629 |
+
$replacement = $this->getRowProperty(
|
630 |
+
$this->_config[$refCode],
|
631 |
+
$refKey,
|
632 |
+
isset($originalRow) ? $originalRow : $row,
|
633 |
+
isset($originalKey) ? $originalKey : $key
|
634 |
+
);
|
635 |
+
if (is_array($replacement) && isset($replacement['error'])) {
|
636 |
+
return isset($originalRow) ? $replacement : 'false';
|
637 |
+
}
|
638 |
+
$output = $this->replace('{' . $original . '}', $this->_autoEscapeStrings($replacement), $output);
|
639 |
+
$output = $this->replace($original, $replacement, $output);
|
640 |
+
} else {
|
641 |
+
$replacement = $original;
|
642 |
+
$output = $this->replace($original, $replacement, $output);
|
643 |
+
}
|
644 |
+
}
|
645 |
+
} else {
|
646 |
+
$this->debug(
|
647 |
+
' get <span class=osh-key>' . self::esc($row['*id']) . '</span>'
|
648 |
+
. '.<span class=osh-key>' . self::esc($key) . '</span>'
|
649 |
+
. ' = <span class=osh-formula>null</span>'
|
650 |
+
);
|
651 |
+
}
|
652 |
+
return $output;
|
653 |
+
}
|
654 |
+
|
655 |
+
public function evalInput($process, $row, $propertyName, $input)
|
656 |
+
{
|
657 |
+
$result = $this->_prepareFormula($process, $row, $propertyName, $input, $isChecking = false, $useCache = true);
|
658 |
+
return $result->success ? $result->result : $input;
|
659 |
+
}
|
660 |
+
|
661 |
+
public function parseProperty($input)
|
662 |
+
{
|
663 |
+
if ($input === 'false') return false;
|
664 |
+
if ($input === 'true') return true;
|
665 |
+
if ($input === 'null') return null;
|
666 |
+
if (is_numeric($input)) return (double)$input;
|
667 |
+
$value = str_replace('\"', '"', preg_replace('/^(?:"|\')(.*)(?:"|\')$/s', '$1', $input));
|
668 |
+
return $value === '' ? null : $value;
|
669 |
+
}
|
670 |
+
|
671 |
+
protected function replace($from, $to, $input, $className = null, $message = 'replace')
|
672 |
+
{
|
673 |
+
if ($from === $to) return $input;
|
674 |
+
if (mb_strpos($input, $from) === false) return $input;
|
675 |
+
$to = self::toString($to);
|
676 |
+
$to = preg_replace('/[\r\n\t]+/', ' ', $to);
|
677 |
+
$this->debug(
|
678 |
+
' '
|
679 |
+
. ($className ? '<span class="osh-' . $className . '">' : '')
|
680 |
+
. $message
|
681 |
+
. ' <span class=osh-replacement>' . self::esc(self::toString($from)) . '</span>'
|
682 |
+
. ' by <span class=osh-replacement>' . self::esc($to) . '</span>'
|
683 |
+
. ' => <span class=osh-formula>' . self::esc(
|
684 |
+
str_replace($from, '<span class=osh-replacement>' . $to . '</span>', $input)
|
685 |
+
) . '</span>'
|
686 |
+
. ($className ? '</span>' : '')
|
687 |
+
);
|
688 |
+
return str_replace($from, $to, $input);
|
689 |
+
}
|
690 |
+
|
691 |
+
protected function _min()
|
692 |
+
{
|
693 |
+
$args = func_get_args();
|
694 |
+
$min = null;
|
695 |
+
foreach ($args as $arg) {
|
696 |
+
if (isset($arg) && (!isset($min) || $min > $arg)) $min = $arg;
|
697 |
+
}
|
698 |
+
return $min;
|
699 |
+
}
|
700 |
+
|
701 |
+
protected function _max()
|
702 |
+
{
|
703 |
+
$args = func_get_args();
|
704 |
+
$max = null;
|
705 |
+
foreach ($args as $arg) {
|
706 |
+
if (isset($arg) && (!isset($max) || $max < $arg)) $max = $arg;
|
707 |
+
}
|
708 |
+
return $max;
|
709 |
+
}
|
710 |
+
|
711 |
+
protected function _range($value = -1, $minValue = 0, $maxValue = 1, $includeMin = true, $includeMax = true)
|
712 |
+
{
|
713 |
+
return ($value > $minValue || $includeMin && $value == $minValue)
|
714 |
+
&& ($value < $maxValue || $includeMax && $value == $maxValue);
|
715 |
+
}
|
716 |
+
|
717 |
+
protected function callFunction($functionName, $args)
|
718 |
+
{
|
719 |
+
return call_user_func_array($functionName, $args);
|
720 |
+
}
|
721 |
+
|
722 |
+
protected function _array_match_any()
|
723 |
+
{
|
724 |
+
$args = func_get_args();
|
725 |
+
$result = $this->callFunction('array_intersect', $args);
|
726 |
+
return (bool)$result;
|
727 |
+
}
|
728 |
+
|
729 |
+
protected function _array_match_all()
|
730 |
+
{
|
731 |
+
$args = func_get_args();
|
732 |
+
if (!isset($args[0]) || !isset($args[1])) return false;
|
733 |
+
$result = $this->callFunction('array_intersect', $args);
|
734 |
+
return count($result) == count($args[1]);
|
735 |
+
}
|
736 |
+
|
737 |
+
public function processFormula($process, &$row, $propertyName, $formulaString, $isChecking, $useCache = true)
|
738 |
+
{
|
739 |
+
$result = $this->_prepareFormula($process, $row, $propertyName, $formulaString, $isChecking, $useCache);
|
740 |
+
if (!$result->success) return $result;
|
741 |
+
|
742 |
+
$evalResult = $this->_evalFormula($result->result, $row, $propertyName, $isChecking);
|
743 |
+
if (!$isChecking && !isset($evalResult)) {
|
744 |
+
$this->addMessage('error', $row, $propertyName, 'Empty result');
|
745 |
+
$result = $this->createResult()
|
746 |
+
->setSuccess(false);
|
747 |
+
if ($useCache) $this->_setCache($formulaString, $result);
|
748 |
+
return $result;
|
749 |
+
}
|
750 |
+
$result = $this->createResult()
|
751 |
+
->setSuccess(true)
|
752 |
+
->setResult($evalResult);
|
753 |
+
if ($useCache) $this->_setCache($formulaString, $result);
|
754 |
+
return $result;
|
755 |
+
}
|
756 |
+
|
757 |
+
protected function _setCache($expression, $value)
|
758 |
+
{
|
759 |
+
if ($value instanceof Owebia_Shipping2_Model_Os2_Result) {
|
760 |
+
$this->_formulaCache[$expression] = $value;
|
761 |
+
$this->debug(
|
762 |
+
' cache <span class=osh-replacement>' . self::esc($expression) . '</span>'
|
763 |
+
. ' = <span class=osh-formula>' . self::esc(self::toString($value->result)) . '</span>'
|
764 |
+
. ' (' . self::getType($value->result) . ')'
|
765 |
+
);
|
766 |
+
} else {
|
767 |
+
$this->_expressionCache[$expression] = $value; // Do not use self::toString to make isset work
|
768 |
+
$this->debug(
|
769 |
+
' cache <span class=osh-replacement>' . self::esc($expression) . '</span>'
|
770 |
+
. ' = <span class=osh-formula>' . self::esc(self::toString($value)) . '</span>'
|
771 |
+
. ' (' . self::getType($value) . ')'
|
772 |
+
);
|
773 |
+
}
|
774 |
+
}
|
775 |
+
|
776 |
+
protected function _getCachedExpression($original)
|
777 |
+
{
|
778 |
+
$replacement = $this->_expressionCache[$original];
|
779 |
+
$this->debug(
|
780 |
+
' get cached expression <span class=osh-replacement>' . self::esc($original) . '</span>'
|
781 |
+
. ' = <span class=osh-formula>' . self::esc(self::toString($replacement)) . '</span>'
|
782 |
+
. ' (' . self::getType($replacement) . ')'
|
783 |
+
);
|
784 |
+
return $replacement;
|
785 |
+
}
|
786 |
+
|
787 |
+
protected function _prepare_regexp($regexp)
|
788 |
+
{
|
789 |
+
if (!isset($this->constants)) {
|
790 |
+
$reflector = new ReflectionClass(get_class($this));
|
791 |
+
$this->constants = $reflector->getConstants();
|
792 |
+
}
|
793 |
+
foreach ($this->constants as $name => $value) {
|
794 |
+
$regexp = str_replace('{' . $name . '}', $value, $regexp);
|
795 |
+
}
|
796 |
+
return $regexp;
|
797 |
+
}
|
798 |
+
|
799 |
+
protected function _preg_match($regexp, $input, &$result, $debug = false)
|
800 |
+
{
|
801 |
+
$regexp = $this->_prepare_regexp($regexp);
|
802 |
+
if ($debug) $this->debug(' preg_match <span class=osh-replacement>' . self::esc($regexp) . '</span>');
|
803 |
+
return preg_match($regexp, $input, $result);
|
804 |
+
}
|
805 |
+
|
806 |
+
protected function _preg_match_all($regexp, $input, &$result, $debug = false)
|
807 |
+
{
|
808 |
+
$regexp = $this->_prepare_regexp($regexp);
|
809 |
+
if ($debug) $this->debug(' preg_match_all <span class=osh-replacement>' . self::esc($regexp) . '</span>');
|
810 |
+
$return = preg_match_all($regexp, $input, $result, PREG_SET_ORDER);
|
811 |
+
}
|
812 |
+
|
813 |
+
protected function _loadValue($process, $objectName, $attribute)
|
814 |
+
{
|
815 |
+
switch ($objectName) {
|
816 |
+
case 'item':
|
817 |
+
return isset($process['data']['cart']->items[0])
|
818 |
+
? $process['data']['cart']->items[0]->{$attribute} : null;
|
819 |
+
case 'product':
|
820 |
+
return isset($process['data']['cart']->items[0])
|
821 |
+
? $process['data']['cart']->items[0]->getProduct()->{$attribute} : null;
|
822 |
+
default:
|
823 |
+
return isset($process['data'][$objectName])
|
824 |
+
? $process['data'][$objectName]->{$attribute} : null;
|
825 |
+
}
|
826 |
+
}
|
827 |
+
|
828 |
+
protected function _prepareFormulaForeach($process, $row, $propertyName, $formula, $isChecking, $useCache)
|
829 |
+
{
|
830 |
+
$foreachRegexp = "#{foreach ((?:item|product|p)\.[a-z0-9_\+\-\.]+)}(.*){/foreach}#iU";
|
831 |
+
$itemsCount = count($process['data']['cart']->items);
|
832 |
+
while ($this->_preg_match($foreachRegexp, $formula, $result)) { // ungreedy
|
833 |
+
$original = $result[0];
|
834 |
+
if ($useCache && array_key_exists($original, $this->_expressionCache)) {
|
835 |
+
$replacement = $this->_getCachedExpression($original);
|
836 |
+
} else {
|
837 |
+
$replacement = 0;
|
838 |
+
$loopVar = $result[1];
|
839 |
+
$selections = array();
|
840 |
+
$this->debug(' foreach <span class=osh-key>' . self::esc($loopVar) . '</span>');
|
841 |
+
$this->addDebugIndent();
|
842 |
+
$items = $process['data']['cart']->items;
|
843 |
+
if ($items) {
|
844 |
+
foreach ($items as $item) {
|
845 |
+
$tmpValue = $this->_getItemProperty($item, $loopVar);
|
846 |
+
$values = (array)$tmpValue;
|
847 |
+
foreach ($values as $valueItem) {
|
848 |
+
$key = self::_autoEscapeStrings($valueItem);
|
849 |
+
$sel = isset($selections[$key]) ? $selections[$key] : null;
|
850 |
+
$selections[$key]['items'][] = $item;
|
851 |
+
}
|
852 |
+
$this->debug(
|
853 |
+
' items[<span class=osh-formula>' . self::esc((string)$item) . '</span>]'
|
854 |
+
. '.<span class=osh-key>' . self::esc($loopVar) . '</span>'
|
855 |
+
. ' = [<span class=osh-formula>' . self::esc(
|
856 |
+
implode('</span>, <span class=osh-formula>', $values)
|
857 |
+
) . '</span>]'
|
858 |
+
);
|
859 |
+
}
|
860 |
+
}
|
861 |
+
$this->removeDebugIndent();
|
862 |
+
$this->debug(' <span class=osh-loop>start foreach</span>');
|
863 |
+
$this->addDebugIndent();
|
864 |
+
foreach ($selections as $key => $selection) {
|
865 |
+
$this->debug(
|
866 |
+
' <span class=osh-loop>• value</span>'
|
867 |
+
. ' = <span class=osh-formula>' . self::esc($key) . '</span>'
|
868 |
+
);
|
869 |
+
$this->addDebugIndent();
|
870 |
+
$this->debug(' #### count ' . $itemsCount);
|
871 |
+
$tmpProcess = $process;
|
872 |
+
// Important: clone to not override previous items
|
873 |
+
$tmpProcess['data']['cart'] = clone $tmpProcess['data']['cart'];
|
874 |
+
$tmpProcess['data']['cart']->items = $selection['items'];
|
875 |
+
$selection['qty'] = 0;
|
876 |
+
$selection['weight'] = 0;
|
877 |
+
foreach ($selection['items'] as $item) {
|
878 |
+
$selection['qty'] += $item->qty;
|
879 |
+
$selection['weight'] += $item->weight;
|
880 |
+
}
|
881 |
+
if (isset($tmpProcess['data']['selection'])) {
|
882 |
+
$tmpProcess['data']['selection']->set('qty', $selection['qty']);
|
883 |
+
$tmpProcess['data']['selection']->set('weight', $selection['weight']);
|
884 |
+
}
|
885 |
+
$processResult = $this->processFormula(
|
886 |
+
$tmpProcess,
|
887 |
+
$row,
|
888 |
+
$propertyName,
|
889 |
+
$result[2],
|
890 |
+
$isChecking,
|
891 |
+
$tmpUseCache = false
|
892 |
+
);
|
893 |
+
$replacement += $processResult->result;
|
894 |
+
$this->debug(
|
895 |
+
' » <span class=osh-info>foreach sum result</span>'
|
896 |
+
. ' = <span class=osh-formula>' . self::esc(self::toString($replacement)) . '</span>'
|
897 |
+
);
|
898 |
+
$this->removeDebugIndent();
|
899 |
+
}
|
900 |
+
$this->removeDebugIndent();
|
901 |
+
$this->debug(' <span class=osh-loop>end</span>');
|
902 |
+
if ($useCache) $this->_setCache($original, $replacement);
|
903 |
+
}
|
904 |
+
$formula = $this->replace($original, $replacement, $formula);
|
905 |
+
}
|
906 |
+
return $formula;
|
907 |
+
}
|
908 |
+
|
909 |
+
protected function _prepareFormulaSwitch($row, $propertyName, $formula, $isChecking, $useCache)
|
910 |
+
{
|
911 |
+
while (preg_match("/{switch ([^}]+) in ([^}]+)}/i", $formula, $result)) {
|
912 |
+
$original = $result[0];
|
913 |
+
if ($useCache && array_key_exists($original, $this->_expressionCache)) {
|
914 |
+
$replacement = $this->_getCachedExpression($original);
|
915 |
+
} else {
|
916 |
+
$referenceValue = $this->_evalFormula($result[1], $row, $propertyName, $isChecking);
|
917 |
+
$feesTableString = $result[2];
|
918 |
+
|
919 |
+
$coupleRegexp = '[^}:]+ *\: *[0-9.]+ *';
|
920 |
+
if (!preg_match('#^ *' . $coupleRegexp . '(?:, *' . $coupleRegexp . ')*$#', $feesTableString)) {
|
921 |
+
$this->addMessage(
|
922 |
+
'error',
|
923 |
+
$row,
|
924 |
+
$propertyName,
|
925 |
+
'Error in switch %s',
|
926 |
+
'<span class=osh-formula>' . self::esc($result[0]) . '</span>'
|
927 |
+
);
|
928 |
+
$result = $this->createResult()
|
929 |
+
->setSuccess(false);
|
930 |
+
if ($useCache) $this->_setCache($formulaString, $result);
|
931 |
+
return $result;
|
932 |
+
}
|
933 |
+
$feesTable = explode(',', $feesTableString);
|
934 |
+
|
935 |
+
$replacement = null;
|
936 |
+
foreach ($feesTable as $item) {
|
937 |
+
$feeData = explode(':', $item);
|
938 |
+
|
939 |
+
$fee = trim($feeData[1]);
|
940 |
+
$value = trim($feeData[0]);
|
941 |
+
$value = $value == '*' ? '*' : $this->_evalFormula($feeData[0], $row, $propertyName, $isChecking);
|
942 |
+
|
943 |
+
if ($value == '*' || $referenceValue === $value) {
|
944 |
+
$replacement = $fee;
|
945 |
+
$this->debug(
|
946 |
+
' compare <span class=osh-formula>'
|
947 |
+
. self::esc($this->_autoEscapeStrings($referenceValue)) . '</span>'
|
948 |
+
. ' == <span class=osh-formula>' . self::esc($this->_autoEscapeStrings($value)) . '</span>'
|
949 |
+
);
|
950 |
+
break;
|
951 |
+
}
|
952 |
+
$this->debug(
|
953 |
+
' compare <span class=osh-formula>'
|
954 |
+
. self::esc($this->_autoEscapeStrings($referenceValue)) . '</span>'
|
955 |
+
. ' != <span class=osh-formula>' . self::esc($this->_autoEscapeStrings($value)) . '</span>'
|
956 |
+
);
|
957 |
+
}
|
958 |
+
if ($useCache) $this->_setCache($original, $replacement);
|
959 |
+
}
|
960 |
+
$formula = $this->replace($original, $replacement, $formula);
|
961 |
+
}
|
962 |
+
return $formula;
|
963 |
+
}
|
964 |
+
|
965 |
+
protected function _prepareFormulaTableIncludeMaxValue($lastChar)
|
966 |
+
{
|
967 |
+
if ($lastChar == '[') {
|
968 |
+
return false;
|
969 |
+
} elseif ($lastChar == ']') {
|
970 |
+
return true;
|
971 |
+
} else {
|
972 |
+
return true;
|
973 |
+
}
|
974 |
+
}
|
975 |
+
|
976 |
+
protected function _prepareFormulaTable($row, $propertyName, $formula, $isChecking, $useCache)
|
977 |
+
{
|
978 |
+
while (preg_match("/{table ([^}]+) in ([0-9\.:,\*\[\] ]+)}/i", $formula, $result)) {
|
979 |
+
$original = $result[0];
|
980 |
+
if ($useCache && array_key_exists($original, $this->_expressionCache)) {
|
981 |
+
$replacement = $this->_getCachedExpression($original);
|
982 |
+
} else {
|
983 |
+
$referenceValue = $this->_evalFormula($result[1], $row, $propertyName, $isChecking);
|
984 |
+
$replacement = null;
|
985 |
+
if (isset($referenceValue)) {
|
986 |
+
$feesTableString = $result[2];
|
987 |
+
$feesTableRegexp = '#^' . self::COUPLE_REGEX . '(?:, *' . self::COUPLE_REGEX . ')*$#';
|
988 |
+
if (!preg_match($feesTableRegexp, $feesTableString)) {
|
989 |
+
$this->addMessage(
|
990 |
+
'error',
|
991 |
+
$row,
|
992 |
+
$propertyName,
|
993 |
+
'Error in table %s',
|
994 |
+
'<span class=osh-formula>' . self::esc($result[0]) . '</span>'
|
995 |
+
);
|
996 |
+
$result = $this->createResult()
|
997 |
+
->setSuccess(false);
|
998 |
+
if ($useCache) $this->_setCache($formulaString, $result);
|
999 |
+
return $result;
|
1000 |
+
}
|
1001 |
+
$feesTable = explode(',', $feesTableString);
|
1002 |
+
foreach ($feesTable as $item) {
|
1003 |
+
$feeData = explode(':', $item);
|
1004 |
+
|
1005 |
+
$fee = trim($feeData[1]);
|
1006 |
+
$maxValue = trim($feeData[0]);
|
1007 |
+
|
1008 |
+
$includingMaxValue = $this->_prepareFormulaTableIncludeMaxValue(
|
1009 |
+
$maxValue{strlen($maxValue) - 1}
|
1010 |
+
);
|
1011 |
+
|
1012 |
+
$maxValue = str_replace(array('[', ']'), '', $maxValue);
|
1013 |
+
|
1014 |
+
if ($maxValue == '*'
|
1015 |
+
|| $includingMaxValue && $referenceValue <= $maxValue
|
1016 |
+
|| !$includingMaxValue && $referenceValue < $maxValue
|
1017 |
+
) {
|
1018 |
+
$replacement = $fee;
|
1019 |
+
break;
|
1020 |
+
}
|
1021 |
+
}
|
1022 |
+
}
|
1023 |
+
if ($useCache) $this->_setCache($original, $replacement);
|
1024 |
+
}
|
1025 |
+
$formula = $this->replace($original, $replacement, $formula);
|
1026 |
+
}
|
1027 |
+
return $formula;
|
1028 |
+
}
|
1029 |
+
|
1030 |
+
protected function _prepareFormula($process, $row, $propertyName, $formulaString, $isChecking, $useCache = true)
|
1031 |
+
{
|
1032 |
+
if ($useCache && isset($this->_formulaCache[$formulaString])) {
|
1033 |
+
$result = $this->_formulaCache[$formulaString];
|
1034 |
+
$this->debug(
|
1035 |
+
' get cached formula <span class=osh-replacement>' . self::esc($formulaString) . '</span>'
|
1036 |
+
. ' = <span class=osh-formula>' . self::esc(self::toString($result->result)) . '</span>'
|
1037 |
+
);
|
1038 |
+
return $result;
|
1039 |
+
}
|
1040 |
+
|
1041 |
+
$formula = $formulaString;
|
1042 |
+
|
1043 |
+
$formula = $this->_prepareFormulaForeach($process, $row, $propertyName, $formula, $isChecking, $useCache);
|
1044 |
+
|
1045 |
+
if (isset($process['data']['selection'])) {
|
1046 |
+
if ($process['data']['selection']->weight == null) {
|
1047 |
+
$process['data']['selection']->set('weight', $process['data']['cart']->weight);
|
1048 |
+
}
|
1049 |
+
if ($process['data']['selection']->qty == null) {
|
1050 |
+
$process['data']['selection']->set('qty', $process['data']['cart']->qty);
|
1051 |
+
}
|
1052 |
+
}
|
1053 |
+
|
1054 |
+
// data
|
1055 |
+
$aliases = array(
|
1056 |
+
'p' => 'product',
|
1057 |
+
'c' => 'cart',
|
1058 |
+
's' => 'selection',
|
1059 |
+
);
|
1060 |
+
$formula = $this->_replaceData($process, $formula, 'item|product|p|c|s', $aliases);
|
1061 |
+
|
1062 |
+
// count, sum, min, max
|
1063 |
+
$countRegexp = "/{(count)\s+items\s*(?:\s+where\s+((?:[^\"'}]|'[^']+'|\"[^\"]+\")+))?}/i";
|
1064 |
+
$sumMinMaxCountRegexp = "/{(sum|min|max|count distinct) ((?:item|product|p)\.[a-z0-9_\+\-\.]+)"
|
1065 |
+
. "(?: where ((?:[^\"'}]|'[^']+'|\"[^\"]+\")+))?}/i";
|
1066 |
+
while ($this->_preg_match($countRegexp, $formula, $result)
|
1067 |
+
|| $this->_preg_match($sumMinMaxCountRegexp, $formula, $result)
|
1068 |
+
) {
|
1069 |
+
$original = $result[0];
|
1070 |
+
if ($useCache && array_key_exists($original, $this->_expressionCache)) {
|
1071 |
+
$replacement = $this->_getCachedExpression($original);
|
1072 |
+
} else {
|
1073 |
+
$replacement = $this->_processProduct(
|
1074 |
+
$process['data']['cart']->items,
|
1075 |
+
$result,
|
1076 |
+
$row,
|
1077 |
+
$propertyName,
|
1078 |
+
$isChecking
|
1079 |
+
);
|
1080 |
+
if ($useCache) $this->_setCache($result[0], $replacement);
|
1081 |
+
}
|
1082 |
+
$formula = $this->replace($original, $replacement, $formula);
|
1083 |
+
}
|
1084 |
+
|
1085 |
+
$formula = $this->_prepareFormulaSwitch($row, $propertyName, $formula, $isChecking, $useCache);
|
1086 |
+
$formula = $this->_prepareFormulaTable($row, $propertyName, $formula, $isChecking, $useCache);
|
1087 |
+
|
1088 |
+
$result = $this->createResult()
|
1089 |
+
->setSuccess(true)
|
1090 |
+
->setResult($formula);
|
1091 |
+
return $result;
|
1092 |
+
}
|
1093 |
+
|
1094 |
+
protected function _evalFormula($formula, &$row, $propertyName = null, $isChecking = false)
|
1095 |
+
{
|
1096 |
+
if (is_bool($formula)) return $formula;
|
1097 |
+
if (
|
1098 |
+
!preg_match(
|
1099 |
+
'/^(?:'
|
1100 |
+
. '\b(?:'
|
1101 |
+
. 'E|e|int|float|string|boolean|object|array|true|false|null|and|or|in'
|
1102 |
+
. '|floor|ceil|round|rand|pow|pi|sqrt|log|exp|abs|substr|strtolower|preg_match|in_array'
|
1103 |
+
. '|max|min|range|array_match_any|array_match_all'
|
1104 |
+
. '|date|strtotime'
|
1105 |
+
. ')\b'
|
1106 |
+
. '|\'[^\']*\'|\"[^\"]*\"|[0-9,\'\.\-\(\)\*\/\?\:\+\<\>\=\&\|%!]|\s)*$/',
|
1107 |
+
$formula
|
1108 |
+
)
|
1109 |
+
) {
|
1110 |
+
$errors = array(
|
1111 |
+
PREG_NO_ERROR => 'PREG_NO_ERROR',
|
1112 |
+
PREG_INTERNAL_ERROR => 'PREG_INTERNAL_ERROR',
|
1113 |
+
PREG_BACKTRACK_LIMIT_ERROR => 'PREG_BACKTRACK_LIMIT_ERROR',
|
1114 |
+
PREG_RECURSION_LIMIT_ERROR => 'PREG_RECURSION_LIMIT_ERROR',
|
1115 |
+
PREG_BAD_UTF8_ERROR => 'PREG_BAD_UTF8_ERROR',
|
1116 |
+
defined('PREG_BAD_UTF8_OFFSET_ERROR') ? PREG_BAD_UTF8_OFFSET_ERROR : 'PREG_BAD_UTF8_OFFSET_ERROR'
|
1117 |
+
=> 'PREG_BAD_UTF8_OFFSET_ERROR',
|
1118 |
+
);
|
1119 |
+
$error = preg_last_error();
|
1120 |
+
if (isset($errors[$error])) $error = $errors[$error];
|
1121 |
+
if ($isChecking) {
|
1122 |
+
$this->addMessage('error', $row, $propertyName, $error . ' (' . $formula . ')');
|
1123 |
+
}
|
1124 |
+
$this->debug(' eval <span class=osh-formula>' . self::esc($formula) . '</span>');
|
1125 |
+
$this->debug(' doesn\'t match (' . self::esc($error) . ')');
|
1126 |
+
return null;
|
1127 |
+
}
|
1128 |
+
$formula = preg_replace('@\b(min|max|range|array_match_any|array_match_all)\(@', '\$this->_\1(', $formula);
|
1129 |
+
$evalResult = null;
|
1130 |
+
@eval('$evalResult = (' . $formula . ');');
|
1131 |
+
$this->debug(
|
1132 |
+
' evaluate <span class=osh-formula>' . self::esc($formula) . '</span>'
|
1133 |
+
. ' = <span class=osh-replacement>' . self::esc($this->_autoEscapeStrings($evalResult)) . '</span>'
|
1134 |
+
);
|
1135 |
+
return $evalResult;
|
1136 |
+
}
|
1137 |
+
|
1138 |
+
protected function _parseInputIsValidConfig($config)
|
1139 |
+
{
|
1140 |
+
if ($config) {
|
1141 |
+
foreach ($config as $code => $object) {
|
1142 |
+
if (!is_object($object)) {
|
1143 |
+
return false;
|
1144 |
+
}
|
1145 |
+
}
|
1146 |
+
return true;
|
1147 |
+
} else {
|
1148 |
+
return false;
|
1149 |
+
}
|
1150 |
+
}
|
1151 |
+
|
1152 |
+
protected function _parseInputIgnore($toIgnore, &$json, &$autoCorrectionWarnings)
|
1153 |
+
{
|
1154 |
+
foreach ($toIgnore as $toIgnoreItem) {
|
1155 |
+
$toIgnoreItem = trim($toIgnoreItem);
|
1156 |
+
if (!$toIgnoreItem) continue;
|
1157 |
+
$autoCorrectionWarnings[] = 'JSON: ignored lines (<span class=osh-formula>'
|
1158 |
+
. self::toString($toIgnoreItem) . '</span>)';
|
1159 |
+
$n = 0;
|
1160 |
+
do {
|
1161 |
+
$key = 'meta' . $n;
|
1162 |
+
$n++;
|
1163 |
+
} while (isset($json[$key]));
|
1164 |
+
$json[$key] = array(
|
1165 |
+
'type' => 'meta',
|
1166 |
+
'ignored' => $toIgnoreItem,
|
1167 |
+
);
|
1168 |
+
}
|
1169 |
+
}
|
1170 |
+
|
1171 |
+
protected function getChar($charCode)
|
1172 |
+
{
|
1173 |
+
return utf8_encode(chr($charCode));
|
1174 |
+
}
|
1175 |
+
|
1176 |
+
protected function _parseInputPrepareInput($input)
|
1177 |
+
{
|
1178 |
+
$openingQuote = $this->getChar(147);
|
1179 |
+
$closingQuote = $this->getChar(148);
|
1180 |
+
$input = str_replace(
|
1181 |
+
array('>', '<', '“', '”', $openingQuote, $closingQuote, '«', '»', "\r\n", "\t"),
|
1182 |
+
array('>', '<', '"', '"', '"', '"', '"', '"', "\n", ' '),
|
1183 |
+
$input
|
1184 |
+
);
|
1185 |
+
return $input;
|
1186 |
+
}
|
1187 |
+
|
1188 |
+
protected function _parseInputParseJsonObject($object, &$autoCorrectionWarnings, &$missingEnquoteOfPropertyName)
|
1189 |
+
{
|
1190 |
+
$jsonObject = array();
|
1191 |
+
$propertyRegexp = $this->getPropertyRegexp();
|
1192 |
+
preg_match_all('/' . $propertyRegexp . '/i', $object[0], $propertySet, PREG_SET_ORDER);
|
1193 |
+
$propertiesCount = count($propertySet);
|
1194 |
+
foreach ($propertySet as $j => $property) {
|
1195 |
+
$name = $property['property_name'];
|
1196 |
+
if ($name{0} != '"' || $name{strlen($name) - 1} != '"') {
|
1197 |
+
$autoCorrectionWarnings['missing_enquote_of_property_name'] =
|
1198 |
+
'JSON: missing enquote of property name: %s';
|
1199 |
+
$missingEnquoteOfPropertyName[] = self::toString(trim($name, '"'));
|
1200 |
+
}
|
1201 |
+
$propertySeparator = isset($property['property_separator'])
|
1202 |
+
? $property['property_separator'] : null;
|
1203 |
+
$isLastProperty = ( $j == $propertiesCount - 1 );
|
1204 |
+
if (!$isLastProperty && $propertySeparator != ',') {
|
1205 |
+
$autoCorrectionWarnings[] = 'JSON: missing property separator (comma)';
|
1206 |
+
} else if ($isLastProperty && $propertySeparator == ',') {
|
1207 |
+
$autoCorrectionWarnings[] = 'JSON: no trailing property separator (comma) allowed';
|
1208 |
+
}
|
1209 |
+
$jsonObject[trim($name, '"')] = $this->parseProperty($property['property_value']);
|
1210 |
+
}
|
1211 |
+
return $jsonObject;
|
1212 |
+
}
|
1213 |
+
|
1214 |
+
protected function getPropertyRegexp()
|
1215 |
+
{
|
1216 |
+
return '\\s*(?<property_name>"?[a-z0-9_]+"?)\\s*:\\s*'
|
1217 |
+
. '(?<property_value>"(?:(?:[^"]|\\\\")*[^\\\\])?"|' . self::FLOAT_REGEX . '|false|true|null)'
|
1218 |
+
. '\\s*(?<property_separator>,)?\\s*(?:\\n)?';
|
1219 |
+
}
|
1220 |
+
|
1221 |
+
protected function getObjectRegexp()
|
1222 |
+
{
|
1223 |
+
return '(?:(?<object_name>"?[a-z0-9_]+"?)\\s*:\\s*)?{\\s*'
|
1224 |
+
. '(' . $this->getPropertyRegexp() . ')+\\s*}\\s*(?<object_separator>,)?\\s*';
|
1225 |
+
}
|
1226 |
+
|
1227 |
+
protected function _parseInputParseJsonObjectSet(
|
1228 |
+
&$configString,
|
1229 |
+
&$autoCorrectionWarnings,
|
1230 |
+
&$missingEnquoteOfPropertyName
|
1231 |
+
)
|
1232 |
+
{
|
1233 |
+
$objectRegexp = $this->getObjectRegexp();
|
1234 |
+
preg_match_all('/(' . $objectRegexp . ')/is', $configString, $objectSet, PREG_SET_ORDER);
|
1235 |
+
$json = array();
|
1236 |
+
$objectsCount = count($objectSet);
|
1237 |
+
$toIgnoreCounter = -1;
|
1238 |
+
foreach ($objectSet as $i => $object) {
|
1239 |
+
$pos = strpos($configString, $object[0]);
|
1240 |
+
$toIgnore = trim(substr($configString, 0, $pos));
|
1241 |
+
if ($toIgnore) {
|
1242 |
+
$toIgnoreCounter++;
|
1243 |
+
if ($toIgnoreCounter == 0) {
|
1244 |
+
$bracketPosition = strpos($toIgnore, '{');
|
1245 |
+
if ($bracketPosition !== false) {
|
1246 |
+
$toIgnore = explode('{', $toIgnore, 2);
|
1247 |
+
}
|
1248 |
+
}
|
1249 |
+
$this->_parseInputIgnore((array)$toIgnore, $json, $autoCorrectionWarnings);
|
1250 |
+
$configString = substr($configString, $pos, strlen($configString));
|
1251 |
+
}
|
1252 |
+
$configString = str_replace($object[0], '', $configString);
|
1253 |
+
$objectName = isset($object['object_name']) ? $object['object_name'] : null;
|
1254 |
+
$objectSeparator = isset($object['object_separator']) ? $object['object_separator'] : null;
|
1255 |
+
$isLastObject = ( $i == $objectsCount - 1 );
|
1256 |
+
if (!$isLastObject && $objectSeparator != ',') {
|
1257 |
+
$autoCorrectionWarnings[] = 'JSON: missing object separator (comma)';
|
1258 |
+
} else if ($isLastObject && $objectSeparator == ',') {
|
1259 |
+
$autoCorrectionWarnings[] = 'JSON: no trailing object separator (comma) allowed';
|
1260 |
+
}
|
1261 |
+
$jsonObject = $this->_parseInputParseJsonObject(
|
1262 |
+
$object,
|
1263 |
+
$autoCorrectionWarnings,
|
1264 |
+
$missingEnquoteOfPropertyName
|
1265 |
+
);
|
1266 |
+
if ($objectName) {
|
1267 |
+
$json[trim($objectName, '"')] = $jsonObject;
|
1268 |
+
} elseif (isset($jsonObject['code'])) {
|
1269 |
+
$code = $jsonObject['code'];
|
1270 |
+
unset($jsonObject['code']);
|
1271 |
+
$json[$code] = $jsonObject;
|
1272 |
+
} else {
|
1273 |
+
$json[] = $jsonObject;
|
1274 |
+
}
|
1275 |
+
}
|
1276 |
+
return $json;
|
1277 |
+
}
|
1278 |
+
|
1279 |
+
protected function _parseInputParseComments(&$configString, &$autoCorrectionWarnings)
|
1280 |
+
{
|
1281 |
+
if (preg_match_all('/((?:#+[^{\\n]*\\s+)+)\\s*{/s', $configString, $result, PREG_SET_ORDER)) {
|
1282 |
+
$autoCorrectionWarnings[] = 'JSON: usage of incompatible comments';
|
1283 |
+
foreach ($result as $set) {
|
1284 |
+
$commentLines = explode("\n", $set[1]);
|
1285 |
+
foreach ($commentLines as $i => $line) {
|
1286 |
+
$commentLines[$i] = preg_replace('/^#+\\s/', '', $line);
|
1287 |
+
}
|
1288 |
+
$comment = trim(implode("\n", $commentLines));
|
1289 |
+
$configString = str_replace(
|
1290 |
+
$set[0],
|
1291 |
+
'{"about": "' . str_replace('"', '\\"', $comment) . '",',
|
1292 |
+
$configString
|
1293 |
+
);
|
1294 |
+
}
|
1295 |
+
}
|
1296 |
+
}
|
1297 |
+
|
1298 |
+
protected function _parseInput($autoCorrection)
|
1299 |
+
{
|
1300 |
+
$configString = $this->_parseInputPrepareInput($this->_input);
|
1301 |
+
$this->debug('parse config (auto correction = ' . self::esc(self::toString($autoCorrection)) . ')');
|
1302 |
+
$config = null;
|
1303 |
+
$lastJsonError = null;
|
1304 |
+
try {
|
1305 |
+
$config = self::json_decode($configString);
|
1306 |
+
} catch (Exception $e) {
|
1307 |
+
$lastJsonError = $e;
|
1308 |
+
}
|
1309 |
+
if (!$this->_parseInputIsValidConfig($config)) {
|
1310 |
+
$config = null;
|
1311 |
+
}
|
1312 |
+
$autoCorrectionWarnings = array();
|
1313 |
+
$missingEnquoteOfPropertyName = array();
|
1314 |
+
if ($autoCorrection && !$config && $configString != '[]') {
|
1315 |
+
$this->_parseInputParseComments($configString, $autoCorrectionWarnings);
|
1316 |
+
$json = $this->_parseInputParseJsonObjectSet(
|
1317 |
+
$configString,
|
1318 |
+
$autoCorrectionWarnings,
|
1319 |
+
$missingEnquoteOfPropertyName
|
1320 |
+
);
|
1321 |
+
$toIgnore = trim($configString);
|
1322 |
+
if ($toIgnore) {
|
1323 |
+
$bracketPosition = strpos($toIgnore, '}');
|
1324 |
+
if ($bracketPosition !== false) {
|
1325 |
+
$toIgnore = explode('}', $toIgnore, 2);
|
1326 |
+
}
|
1327 |
+
$this->_parseInputIgnore((array)$toIgnore, $json, $autoCorrectionWarnings);
|
1328 |
+
}
|
1329 |
+
$configString = $this->jsonEncode($json);
|
1330 |
+
$configString = str_replace(array("\n"), array("\\n"), $configString);
|
1331 |
+
|
1332 |
+
$lastJsonError = null;
|
1333 |
+
try {
|
1334 |
+
$config = self::json_decode($configString);
|
1335 |
+
} catch (Exception $e) {
|
1336 |
+
$lastJsonError = $e;
|
1337 |
+
}
|
1338 |
+
}
|
1339 |
+
if ($lastJsonError) {
|
1340 |
+
$autoCorrectionWarnings[] = 'JSON: unable to parse config (' . $lastJsonError->getMessage() . ')';
|
1341 |
+
}
|
1342 |
+
|
1343 |
+
$row = null;
|
1344 |
+
$autoCorrectionWarnings = array_unique($autoCorrectionWarnings);
|
1345 |
+
foreach ($autoCorrectionWarnings as $key => $warning) {
|
1346 |
+
if ($key == 'missing_enquote_of_property_name') {
|
1347 |
+
$missingEnquoteOfPropertyName = array_unique($missingEnquoteOfPropertyName);
|
1348 |
+
$warning = str_replace(
|
1349 |
+
'%s',
|
1350 |
+
'<span class=osh-key>'
|
1351 |
+
. self::esc(implode('</span>, <span class=osh-key>', $missingEnquoteOfPropertyName))
|
1352 |
+
. '</span>',
|
1353 |
+
$warning
|
1354 |
+
);
|
1355 |
+
}
|
1356 |
+
$this->addMessage('warning', $row, null, $warning);
|
1357 |
+
}
|
1358 |
+
$config = (array)$config;
|
1359 |
+
|
1360 |
+
$this->_parseInputAddRows($config, $autoCorrection);
|
1361 |
+
}
|
1362 |
+
|
1363 |
+
protected function _parseInputAddRowsDetectDeprecatedProperties($autoCorrection, &$object, &$deprecatedProperties)
|
1364 |
+
{
|
1365 |
+
if ($autoCorrection) {
|
1366 |
+
if (isset($object['destination'])) {
|
1367 |
+
if (!in_array('destination', $deprecatedProperties)) $deprecatedProperties[] = 'destination';
|
1368 |
+
$object['shipto'] = $object['destination'];
|
1369 |
+
unset($object['destination']);
|
1370 |
+
}
|
1371 |
+
if (isset($object['code'])) {
|
1372 |
+
if (!in_array('code', $deprecatedProperties)) $deprecatedProperties[] = 'code';
|
1373 |
+
$code = $object['code'];
|
1374 |
+
unset($object['code']);
|
1375 |
+
}
|
1376 |
+
}
|
1377 |
+
}
|
1378 |
+
|
1379 |
+
protected function _parseInputAddRowsPrepareRow(
|
1380 |
+
$autoCorrection,
|
1381 |
+
$object,
|
1382 |
+
&$deprecatedProperties,
|
1383 |
+
&$unknownProperties
|
1384 |
+
)
|
1385 |
+
{
|
1386 |
+
$this->_parseInputAddRowsDetectDeprecatedProperties($autoCorrection, $object, $deprecatedProperties);
|
1387 |
+
|
1388 |
+
$reservedKeys = array('*id');
|
1389 |
+
$availableKeys = array(
|
1390 |
+
'type', 'about', 'label', 'enabled', 'description', 'fees', 'conditions',
|
1391 |
+
'shipto', 'billto', 'origin', 'customer_groups', 'tracking_url',
|
1392 |
+
);
|
1393 |
+
if ($autoCorrection) {
|
1394 |
+
$availableKeys = array_merge(
|
1395 |
+
$availableKeys,
|
1396 |
+
array('destination', 'code')
|
1397 |
+
);
|
1398 |
+
}
|
1399 |
+
|
1400 |
+
$row = array();
|
1401 |
+
$i = 1;
|
1402 |
+
foreach ($object as $propertyName => $propertyValue) {
|
1403 |
+
if (in_array($propertyName, $reservedKeys)) {
|
1404 |
+
continue;
|
1405 |
+
}
|
1406 |
+
if (in_array($propertyName, $availableKeys)
|
1407 |
+
|| substr($propertyName, 0, 1) == '_'
|
1408 |
+
|| in_array($object['type'], array('data', 'meta'))
|
1409 |
+
) {
|
1410 |
+
if (isset($propertyValue)) {
|
1411 |
+
$row[$propertyName] = array('value' => $propertyValue, 'original_value' => $propertyValue);
|
1412 |
+
if ($autoCorrection) $this->cleanProperty($row, $propertyName);
|
1413 |
+
}
|
1414 |
+
} else {
|
1415 |
+
if (!in_array($propertyName, $unknownProperties)) $unknownProperties[] = $propertyName;
|
1416 |
+
}
|
1417 |
+
$i++;
|
1418 |
+
}
|
1419 |
+
return $row;
|
1420 |
+
}
|
1421 |
+
|
1422 |
+
protected function _parseInputAddRows($config, $autoCorrection)
|
1423 |
+
{
|
1424 |
+
$this->_config = array();
|
1425 |
+
|
1426 |
+
$deprecatedProperties = array();
|
1427 |
+
$unknownProperties = array();
|
1428 |
+
|
1429 |
+
foreach ($config as $code => $object) {
|
1430 |
+
$row = $this->_parseInputAddRowsPrepareRow(
|
1431 |
+
$autoCorrection,
|
1432 |
+
(array)$object,
|
1433 |
+
$deprecatedProperties,
|
1434 |
+
$unknownProperties
|
1435 |
+
);
|
1436 |
+
$this->addRow($code, $row);
|
1437 |
+
}
|
1438 |
+
$row = null;
|
1439 |
+
if (count($unknownProperties)>0) {
|
1440 |
+
$this->addMessage(
|
1441 |
+
'error',
|
1442 |
+
$row,
|
1443 |
+
null,
|
1444 |
+
'Usage of unknown properties %s',
|
1445 |
+
': <span class=osh-key>' . implode('</span>, <span class=osh-key>', $unknownProperties) . '</span>'
|
1446 |
+
);
|
1447 |
+
}
|
1448 |
+
if (count($deprecatedProperties)>0) {
|
1449 |
+
$this->addMessage(
|
1450 |
+
'warning',
|
1451 |
+
$row,
|
1452 |
+
null,
|
1453 |
+
'Usage of deprecated properties %s',
|
1454 |
+
': <span class=osh-key>' . implode('</span>, <span class=osh-key>', $deprecatedProperties) . '</span>'
|
1455 |
+
);
|
1456 |
+
}
|
1457 |
+
}
|
1458 |
+
|
1459 |
+
public function addRow($code, &$row)
|
1460 |
+
{
|
1461 |
+
if ($code) {
|
1462 |
+
if (isset($this->_config[$code])) {
|
1463 |
+
$this->addMessage('error', $row, 'code', 'The id must be unique, `%s` has been found twice', $code);
|
1464 |
+
}
|
1465 |
+
while (isset($this->_config[$code])) {
|
1466 |
+
$code .= rand(0, 9);
|
1467 |
+
}
|
1468 |
+
}
|
1469 |
+
$row['*id'] = $code;
|
1470 |
+
$this->_config[$code] = $row;
|
1471 |
+
}
|
1472 |
+
|
1473 |
+
public function addMessage($type, &$row, $property)
|
1474 |
+
{
|
1475 |
+
$args = func_get_args();
|
1476 |
+
array_shift($args);
|
1477 |
+
array_shift($args);
|
1478 |
+
array_shift($args);
|
1479 |
+
$message = array_shift($args);
|
1480 |
+
$message = Mage::getModel('owebia_shipping2/Os2_Message')
|
1481 |
+
->setType($type)
|
1482 |
+
->setMessage($message)
|
1483 |
+
->setArgs($args);
|
1484 |
+
if (isset($row)) {
|
1485 |
+
if (isset($property)) {
|
1486 |
+
$row[$property]['messages'][] = $message;
|
1487 |
+
} else {
|
1488 |
+
$row['*messages'][] = $message;
|
1489 |
+
}
|
1490 |
+
}
|
1491 |
+
$this->_messages[] = $message;
|
1492 |
+
$this->debug(' => <span class=osh-' . $message->type . '>' . self::esc((string)$message) . '</span>');
|
1493 |
+
}
|
1494 |
+
|
1495 |
+
protected function _replaceVariable(&$process, $input, $original, $replacement)
|
1496 |
+
{
|
1497 |
+
if (mb_strpos($input, '{' . $original . '}') !== false) {
|
1498 |
+
$input = $this->replace('{' . $original . '}', $this->_autoEscapeStrings($replacement), $input);
|
1499 |
+
}
|
1500 |
+
if (mb_strpos($input, $original) !== false) {
|
1501 |
+
if (!isset($process['options']->auto_escaping) || $process['options']->auto_escaping) {
|
1502 |
+
$input = $this->replace($original, $this->_autoEscapeStrings($replacement), $input);
|
1503 |
+
} else {
|
1504 |
+
$input = $this->replace($original, $replacement, $input);
|
1505 |
+
}
|
1506 |
+
}
|
1507 |
+
return $input;
|
1508 |
+
}
|
1509 |
+
|
1510 |
+
protected function _replaceData(&$process, $input, $keys = '', $aliases = array())
|
1511 |
+
{
|
1512 |
+
$keys = ($keys ? $keys . '|' : '') . implode('|', array_keys($process['data']));
|
1513 |
+
$keys = preg_replace('/[^a-z_\|]/', '_', $keys);
|
1514 |
+
// data
|
1515 |
+
while ($this->_preg_match("#{({$keys})\.([a-z0-9_\+\-\.]+)}#i", $input, $result)) {
|
1516 |
+
$original = $result[0];
|
1517 |
+
$objectName = isset($aliases[$result[1]]) ? $aliases[$result[1]] : $result[1];
|
1518 |
+
$replacement = $this->_loadValue($process, $objectName, $result[2]);
|
1519 |
+
$input = $this->_replaceVariable($process, $input, $original, $replacement);
|
1520 |
+
}
|
1521 |
+
return $input;
|
1522 |
+
}
|
1523 |
+
|
1524 |
+
protected function _addressMatch(&$process, &$row, $propertyName, $addressFilter, $address)
|
1525 |
+
{
|
1526 |
+
$addressFilter = $this->_replaceData($process, $addressFilter);
|
1527 |
+
$addressFilterParser = Mage::getModel('owebia_shipping2/AddressFilterParser', $this);
|
1528 |
+
$addressFilter = $addressFilterParser->parse($addressFilter);
|
1529 |
+
|
1530 |
+
$this->debug(' address filter = <span class=osh-formula>' . self::esc($addressFilter) . '</span>');
|
1531 |
+
$data = array(
|
1532 |
+
'{c}' => $address->getData('country_id'),
|
1533 |
+
'{p}' => $address->getData('postcode'),
|
1534 |
+
'{r}' => $address->getData('region_code'),
|
1535 |
+
);
|
1536 |
+
foreach ($data as $original => $replacement) {
|
1537 |
+
$addressFilter = $this->_replaceVariable($process, $addressFilter, $original, $replacement);
|
1538 |
+
}
|
1539 |
+
return (bool)$this->_evalFormula($addressFilter, $row, $propertyName, $isChecking = false);
|
1540 |
+
}
|
1541 |
+
|
1542 |
+
protected function _getItemProperty($item, $propertyName)
|
1543 |
+
{
|
1544 |
+
$elems = explode('.', $propertyName, $limit = 2);
|
1545 |
+
switch ($elems[0]) {
|
1546 |
+
case 'p':
|
1547 |
+
case 'product':
|
1548 |
+
return $item->getProduct()->getData($elems[1]);
|
1549 |
+
case 'item':
|
1550 |
+
return $item->getData($elems[1]);
|
1551 |
+
}
|
1552 |
+
return null;
|
1553 |
+
}
|
1554 |
+
|
1555 |
+
protected function _autoEscapeStrings($input)
|
1556 |
+
{
|
1557 |
+
if (is_array($input)) {
|
1558 |
+
$items = array();
|
1559 |
+
foreach ($input as $v) {
|
1560 |
+
$items[] = isset($v) && (is_string($v) || empty($v)) ? self::escapeString($v) : self::toString($v);
|
1561 |
+
}
|
1562 |
+
return 'array(' . join(',', $items) . ')';
|
1563 |
+
} else {
|
1564 |
+
return isset($input) && (is_string($input))
|
1565 |
+
? self::escapeString($input) : self::toString($input);
|
1566 |
+
}
|
1567 |
+
}
|
1568 |
+
|
1569 |
+
protected function _processProductGetConditions($operation, $regexpResult)
|
1570 |
+
{
|
1571 |
+
if ($operation == 'sum'
|
1572 |
+
|| $operation == 'min'
|
1573 |
+
|| $operation == 'max'
|
1574 |
+
|| $operation == 'count distinct'
|
1575 |
+
) {
|
1576 |
+
return isset($regexpResult[3]) ? $regexpResult[3] : null;
|
1577 |
+
} elseif ($operation == 'count') {
|
1578 |
+
return isset($regexpResult[2]) ? $regexpResult[2] : null;
|
1579 |
+
}
|
1580 |
+
return null;
|
1581 |
+
}
|
1582 |
+
|
1583 |
+
protected function _processProductGetReference($operation, $regexpResult)
|
1584 |
+
{
|
1585 |
+
if ($operation == 'sum'
|
1586 |
+
|| $operation == 'min'
|
1587 |
+
|| $operation == 'max'
|
1588 |
+
|| $operation == 'count distinct'
|
1589 |
+
) {
|
1590 |
+
return $regexpResult[2];
|
1591 |
+
} elseif ($operation == 'count') {
|
1592 |
+
return 'items';
|
1593 |
+
}
|
1594 |
+
return null;
|
1595 |
+
}
|
1596 |
+
|
1597 |
+
protected function _processProductGetInitialReturnValue($operation)
|
1598 |
+
{
|
1599 |
+
if ($operation == 'sum'
|
1600 |
+
|| $operation == 'count distinct'
|
1601 |
+
|| $operation == 'count'
|
1602 |
+
) {
|
1603 |
+
return 0;
|
1604 |
+
}
|
1605 |
+
return null;
|
1606 |
+
}
|
1607 |
+
|
1608 |
+
protected function _processProductGetReturnValue($operation, $returnValue, $value, $item, &$distinctValues)
|
1609 |
+
{
|
1610 |
+
switch ($operation) {
|
1611 |
+
case 'min':
|
1612 |
+
if (!isset($returnValue) || $value < $returnValue) {
|
1613 |
+
$returnValue = $value;
|
1614 |
+
}
|
1615 |
+
break;
|
1616 |
+
case 'max':
|
1617 |
+
if (!isset($returnValue) || $value > $returnValue) {
|
1618 |
+
$returnValue = $value;
|
1619 |
+
}
|
1620 |
+
break;
|
1621 |
+
case 'sum':
|
1622 |
+
$returnValue = (isset($returnValue) ? $returnValue : 0) + $value * $item->qty;
|
1623 |
+
break;
|
1624 |
+
case 'count distinct':
|
1625 |
+
if (!isset($returnValue)) {
|
1626 |
+
$returnValue = 0;
|
1627 |
+
}
|
1628 |
+
if (!in_array($value, $distinctValues)) {
|
1629 |
+
$distinctValues[] = $value;
|
1630 |
+
$returnValue++;
|
1631 |
+
}
|
1632 |
+
break;
|
1633 |
+
}
|
1634 |
+
return $returnValue;
|
1635 |
+
}
|
1636 |
+
|
1637 |
+
protected function _processProduct($items, $regexpResult, &$row, $propertyName, $isChecking)
|
1638 |
+
{
|
1639 |
+
// count, sum, min, max, count distinct
|
1640 |
+
$operation = strtolower($regexpResult[1]);
|
1641 |
+
$returnValue = $this->_processProductGetInitialReturnValue($operation);
|
1642 |
+
$reference = $this->_processProductGetReference($operation, $regexpResult);
|
1643 |
+
$conditions = $this->_processProductGetConditions($operation, $regexpResult);
|
1644 |
+
|
1645 |
+
$this->debug(
|
1646 |
+
' <span class=osh-loop>start <span class=osh-replacement>' . self::esc($operation) . '</span> '
|
1647 |
+
. '<span class=osh-key>' . self::esc($reference) . '</span>'
|
1648 |
+
. (isset($conditions)
|
1649 |
+
? ' where <span class=osh-replacement>' . self::esc($conditions) . '</span></span>' : '')
|
1650 |
+
);
|
1651 |
+
$this->addDebugIndent();
|
1652 |
+
|
1653 |
+
$properties = array();
|
1654 |
+
$this->_preg_match_all('#(?:item|product|p)\.([a-z0-9_\+\-\.]+)#i', $conditions, $propertiesRegexpResult);
|
1655 |
+
foreach ($propertiesRegexpResult as $propertyRegexpResult) {
|
1656 |
+
if (!isset($properties[$propertyRegexpResult[0]])) {
|
1657 |
+
$properties[$propertyRegexpResult[0]] = $propertyRegexpResult;
|
1658 |
+
}
|
1659 |
+
}
|
1660 |
+
krsort($properties); // To avoid shorter replace
|
1661 |
+
|
1662 |
+
if ($items) {
|
1663 |
+
$distinctValues = array();
|
1664 |
+
foreach ($items as $item) {
|
1665 |
+
$this->debug(
|
1666 |
+
' <span class=osh-loop>• item</span>'
|
1667 |
+
. ' = <span class=osh-formula>' . self::esc((string)$item) . '</span>'
|
1668 |
+
);
|
1669 |
+
$this->addDebugIndent();
|
1670 |
+
if (isset($conditions) && $conditions != '') {
|
1671 |
+
$formula = $conditions;
|
1672 |
+
foreach ($properties as $property) {
|
1673 |
+
$value = $this->_getItemProperty($item, $property[0]);
|
1674 |
+
$from = $property[0];
|
1675 |
+
$to = $this->_autoEscapeStrings($value);
|
1676 |
+
$this->debug(
|
1677 |
+
' replace <span class=osh-replacement>' . self::esc($from) . '</span>'
|
1678 |
+
. ' by <span class=osh-replacement>' . self::esc($to) . '</span>'
|
1679 |
+
. ' => <span class=osh-formula>' . self::esc(
|
1680 |
+
str_replace($from, '<span class=osh-replacement>' . $to . '</span>', $formula)
|
1681 |
+
) . '</span>'
|
1682 |
+
);
|
1683 |
+
$formula = str_replace($from, $to, $formula);
|
1684 |
+
}
|
1685 |
+
$evalResult = $this->_evalFormula($formula, $row, $propertyName, $isChecking);
|
1686 |
+
if (!isset($evalResult)) $returnValue = 'null';
|
1687 |
+
}
|
1688 |
+
else $evalResult = true;
|
1689 |
+
|
1690 |
+
if ($evalResult == true) {
|
1691 |
+
if ($operation == 'count') {
|
1692 |
+
$returnValue = (isset($returnValue) ? $returnValue : 0) + $item->qty;
|
1693 |
+
} else {
|
1694 |
+
$value = $this->_getItemProperty($item, $reference);
|
1695 |
+
$this->debug(
|
1696 |
+
' » <span class=osh-key>' . self::esc($reference) . '</span>'
|
1697 |
+
. ' = <span class=osh-formula>' . self::esc($value) . '</span>'
|
1698 |
+
. ($operation == 'sum' ? ' x <span class=osh-formula>' . $item->qty . '</span>' : '')
|
1699 |
+
);
|
1700 |
+
$returnValue = $this->_processProductGetReturnValue(
|
1701 |
+
$operation,
|
1702 |
+
$returnValue,
|
1703 |
+
$value,
|
1704 |
+
$item,
|
1705 |
+
$distinctValues
|
1706 |
+
);
|
1707 |
+
}
|
1708 |
+
}
|
1709 |
+
$this->debug(
|
1710 |
+
' » <span class=osh-info>' . self::esc($operation) . ' result</span>'
|
1711 |
+
. ' = <span class=osh-formula>' . self::esc($returnValue) . '</span>'
|
1712 |
+
);
|
1713 |
+
$this->removeDebugIndent();
|
1714 |
+
}
|
1715 |
+
}
|
1716 |
+
|
1717 |
+
$this->removeDebugIndent();
|
1718 |
+
$this->debug(' <span class=osh-loop>end</span>');
|
1719 |
+
|
1720 |
+
return $returnValue;
|
1721 |
+
}
|
1722 |
+
|
1723 |
+
protected static function getType($variable)
|
1724 |
+
{
|
1725 |
+
return gettype($variable);
|
1726 |
+
}
|
1727 |
+
|
1728 |
+
protected function cleanPropertyReplaceDeprecatedCustomVarSyntax($context)
|
1729 |
+
{
|
1730 |
+
$input = &$context->input;
|
1731 |
+
while (preg_match('/{{customVar code=([a-zA-Z0-9_-]+)}}/', $input, $resi)) {
|
1732 |
+
$input = $this->replace(
|
1733 |
+
$resi[0],
|
1734 |
+
'{customvar.' . $resi[1] . '}',
|
1735 |
+
$input,
|
1736 |
+
'warning',
|
1737 |
+
'replace deprecated'
|
1738 |
+
);
|
1739 |
+
}
|
1740 |
+
return $input;
|
1741 |
+
}
|
1742 |
+
|
1743 |
+
protected function cleanPropertyReplaceDeprecatedVariables($context)
|
1744 |
+
{
|
1745 |
+
$input = &$context->input;
|
1746 |
+
$regex = "{(weight|products_quantity|price_including_tax|price_excluding_tax|country)}";
|
1747 |
+
if (preg_match('/' . $regex . '/', $input, $resi)) {
|
1748 |
+
$this->addMessage(
|
1749 |
+
'warning',
|
1750 |
+
$context->row,
|
1751 |
+
$context->key,
|
1752 |
+
'Usage of deprecated syntax %s',
|
1753 |
+
'<span class=osh-formula>' . $resi[0] . '</span>'
|
1754 |
+
);
|
1755 |
+
while (preg_match('/' . $regex . '/', $input, $resi)) {
|
1756 |
+
switch ($resi[1]) {
|
1757 |
+
case 'price_including_tax':
|
1758 |
+
$to = "{cart.price+tax+discount}";
|
1759 |
+
break;
|
1760 |
+
case 'price_excluding_tax':
|
1761 |
+
$to = "{cart.price-tax+discount}";
|
1762 |
+
break;
|
1763 |
+
case 'weight':
|
1764 |
+
$to = "{cart.{$resi[1]}}";
|
1765 |
+
break;
|
1766 |
+
case 'products_quantity':
|
1767 |
+
$to = "{cart.qty}";
|
1768 |
+
break;
|
1769 |
+
case 'country':
|
1770 |
+
$to = "{shipto.country_name}";
|
1771 |
+
break;
|
1772 |
+
}
|
1773 |
+
$input = str_replace($resi[0], $to, $input);
|
1774 |
+
}
|
1775 |
+
}
|
1776 |
+
}
|
1777 |
+
|
1778 |
+
protected function cleanPropertyReplaceDeprecatedCopySyntax($context)
|
1779 |
+
{
|
1780 |
+
$input = &$context->input;
|
1781 |
+
$copyRegexp = "{copy '([a-zA-Z0-9_]+)'\.'([a-zA-Z0-9_]+)'}";
|
1782 |
+
if (preg_match('/' . $copyRegexp . '/', $input, $resi)) {
|
1783 |
+
$this->addMessage(
|
1784 |
+
'warning',
|
1785 |
+
$context->row,
|
1786 |
+
$context->key,
|
1787 |
+
'Usage of deprecated syntax %s',
|
1788 |
+
'<span class=osh-formula>' . $resi[0] . '</span>'
|
1789 |
+
);
|
1790 |
+
while (preg_match('/' . $copyRegexp . '/', $input, $resi)) {
|
1791 |
+
$input = str_replace($resi[0], '{' . $resi[1] . '.' . $resi[2] . '}', $input);
|
1792 |
+
}
|
1793 |
+
}
|
1794 |
+
}
|
1795 |
+
|
1796 |
+
protected function cleanPropertyReplaceDeprecatedFunctionsSyntax($context)
|
1797 |
+
{
|
1798 |
+
$input = &$context->input;
|
1799 |
+
$countAllAnyRegexp = "{(count|all|any) (attribute|option) '([^'\)]+)'"
|
1800 |
+
. " ?((?:==|<=|>=|<|>|!=) ?(?:" . self::FLOAT_REGEX . "|true|false|'[^'\)]*'))}";
|
1801 |
+
$sumRegexp = "{(sum) (attribute|option) '([^'\)]+)'}";
|
1802 |
+
if (preg_match('/' . $countAllAnyRegexp . '/', $input, $resi)
|
1803 |
+
|| preg_match('/' . $sumRegexp . '/', $input, $resi)
|
1804 |
+
) {
|
1805 |
+
$this->addMessage(
|
1806 |
+
'warning',
|
1807 |
+
$context->row,
|
1808 |
+
$context->key,
|
1809 |
+
'Usage of deprecated syntax %s',
|
1810 |
+
'<span class=osh-formula>' . $resi[0] . '</span>'
|
1811 |
+
);
|
1812 |
+
while (preg_match('/' . $countAllAnyRegexp . '/', $input, $resi)
|
1813 |
+
|| preg_match('/' . $sumRegexp . '/', $input, $resi)
|
1814 |
+
) {
|
1815 |
+
switch ($resi[1]) {
|
1816 |
+
case 'count':
|
1817 |
+
$to = "{count items where product.{$resi[2]}.{$resi[3]}{$resi[4]}}";
|
1818 |
+
break;
|
1819 |
+
case 'all':
|
1820 |
+
$to = "{count items where product.{$resi[2]}.{$resi[3]}{$resi[4]}}=={cart.qty}";
|
1821 |
+
break;
|
1822 |
+
case 'any':
|
1823 |
+
$to = "{count items where product.{$resi[2]}.{$resi[3]}{$resi[4]}}>0";
|
1824 |
+
break;
|
1825 |
+
case 'sum':
|
1826 |
+
$to = "{sum product.{$resi[2]}.{$resi[3]}}";
|
1827 |
+
break;
|
1828 |
+
}
|
1829 |
+
$input = str_replace($resi[0], $to, $input);
|
1830 |
+
}
|
1831 |
+
}
|
1832 |
+
}
|
1833 |
+
|
1834 |
+
protected function cleanPropertyReplaceDeprecatedProductSyntax($context)
|
1835 |
+
{
|
1836 |
+
$input = &$context->input;
|
1837 |
+
$regex = "((?:{| )product.(?:attribute|option))s.";
|
1838 |
+
if (preg_match('/' . $regex . '/', $input, $resi)) {
|
1839 |
+
$this->addMessage(
|
1840 |
+
'warning',
|
1841 |
+
$context->row,
|
1842 |
+
$context->key,
|
1843 |
+
'Usage of deprecated syntax %s',
|
1844 |
+
'<span class=osh-formula>' . $resi[0] . '</span>'
|
1845 |
+
);
|
1846 |
+
while (preg_match('/' . $regex . '/', $input, $resi)) {
|
1847 |
+
$input = str_replace($resi[0], $resi[1] . '.', $input);
|
1848 |
+
}
|
1849 |
+
}
|
1850 |
+
}
|
1851 |
+
|
1852 |
+
protected function cleanPropertyReplaceDeprecatedTableSyntax($context)
|
1853 |
+
{
|
1854 |
+
$input = &$context->input;
|
1855 |
+
$regex = "{table '([^']+)' (" . self::COUPLE_REGEX . "(?:, *" . self::COUPLE_REGEX . ")*)}";
|
1856 |
+
if (preg_match('/' . $regex . '/', $input, $resi)) {
|
1857 |
+
$this->addMessage(
|
1858 |
+
'warning',
|
1859 |
+
$context->row,
|
1860 |
+
$context->key,
|
1861 |
+
'Usage of deprecated syntax %s',
|
1862 |
+
'<span class=osh-formula>' . $resi[0] . '</span>'
|
1863 |
+
);
|
1864 |
+
while (preg_match('/' . $regex . '/', $input, $resi)) {
|
1865 |
+
switch ($resi[1]) {
|
1866 |
+
case 'products_quantity':
|
1867 |
+
$input = str_replace($resi[0], "{table {cart.weight} in {$resi[2]}}*{cart.qty}", $input);
|
1868 |
+
break;
|
1869 |
+
default:
|
1870 |
+
$input = str_replace($resi[0], "{table {cart.{$resi[1]}} in {$resi[2]}}", $input);
|
1871 |
+
break;
|
1872 |
+
}
|
1873 |
+
}
|
1874 |
+
}
|
1875 |
+
}
|
1876 |
+
|
1877 |
+
/* For auto correction */
|
1878 |
+
public function cleanProperty(&$row, $key)
|
1879 |
+
{
|
1880 |
+
$input = $row[$key]['value'];
|
1881 |
+
if (is_string($input)) {
|
1882 |
+
$context = new stdClass();
|
1883 |
+
$context->row = &$row;
|
1884 |
+
$context->key = &$key;
|
1885 |
+
$context->input = &$input;
|
1886 |
+
$this->cleanPropertyReplaceDeprecatedCustomVarSyntax($context);
|
1887 |
+
$this->cleanPropertyReplaceDeprecatedVariables($context);
|
1888 |
+
$this->cleanPropertyReplaceDeprecatedCopySyntax($context);
|
1889 |
+
$this->cleanPropertyReplaceDeprecatedFunctionsSyntax($context);
|
1890 |
+
$this->cleanPropertyReplaceDeprecatedProductSyntax($context);
|
1891 |
+
$this->cleanPropertyReplaceDeprecatedTableSyntax($context);
|
1892 |
+
|
1893 |
+
$aliases = array(
|
1894 |
+
'{destination.country.code}' => '{shipto.country_id}',
|
1895 |
+
'{destination.country.name}' => '{shipto.country_name}',
|
1896 |
+
'{destination.region.code}' => '{shipto.region_code}',
|
1897 |
+
'{destination.postcode}' => '{shipto.postcode}',
|
1898 |
+
'.destination}' => '.shipto}',
|
1899 |
+
'{cart.price_excluding_tax}' => '{cart.price-tax+discount}',
|
1900 |
+
'{cart.price_including_tax}' => '{cart.price+tax+discount}',
|
1901 |
+
'{cart.weight.unit}' => '{cart.weight_unit}',
|
1902 |
+
'{cart.coupon}' => '{cart.coupon_code}',
|
1903 |
+
'{cart.weight.for-charge}' => '{cart.weight_for_charge}',
|
1904 |
+
'{c.price_excluding_tax}' => '{c.price-tax+discount}',
|
1905 |
+
'{c.price_including_tax}' => '{c.price+tax+discount}',
|
1906 |
+
'{c.weight.unit}' => '{c.weight_unit}',
|
1907 |
+
'{c.coupon}' => '{c.coupon_code}',
|
1908 |
+
'{free_shipping}' => '{cart.free_shipping}',
|
1909 |
+
'{c.weight.for-charge}' => '{c.weight_for_charge}',
|
1910 |
+
'{customer.group.id}' => '{customer_group.id}',
|
1911 |
+
'{customer.group.code}' => '{customer_group.code}',
|
1912 |
+
'{origin.country.code}' => '{origin.country_id}',
|
1913 |
+
'{origin.country.name}' => '{origin.country_name}',
|
1914 |
+
'{origin.region.code}' => '{origin.region_id}',
|
1915 |
+
'{selection.quantity}' => '{selection.qty}',
|
1916 |
+
'product.quantity' => 'item.qty',
|
1917 |
+
'product.stock.quantity' => 'product.stock.qty',
|
1918 |
+
'product.options.' => 'item.option.',
|
1919 |
+
'product.option.' => 'item.option.',
|
1920 |
+
'product.o.' => 'item.o.',
|
1921 |
+
'p.quantity' => 'item.qty',
|
1922 |
+
'p.stock.quantity' => 'p.stock.qty',
|
1923 |
+
'p.options.' => 'item.option.',
|
1924 |
+
'p.option.' => 'item.option.',
|
1925 |
+
'p.o.' => 'item.o.',
|
1926 |
+
'count products ' => 'count items ',
|
1927 |
+
'product.attribute.price+tax+discount' => 'item.price+tax+discount',
|
1928 |
+
'product.attribute.price+tax-discount' => 'item.price+tax-discount',
|
1929 |
+
'product.attribute.price-tax+discount' => 'item.price-tax+discount',
|
1930 |
+
'product.attribute.price-tax-discount' => 'item.price-tax-discount',
|
1931 |
+
);
|
1932 |
+
foreach ($aliases as $from => $to) {
|
1933 |
+
if (mb_strpos($input, $from) !== false) {
|
1934 |
+
$input = $this->replace($from, $to, $input, 'warning', 'replace deprecated');
|
1935 |
+
}
|
1936 |
+
}
|
1937 |
+
}
|
1938 |
+
$row[$key]['value'] = $input;
|
1939 |
+
}
|
1940 |
+
}
|
@@ -1,24 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Copyright (c) 2008-14 Owebia
|
5 |
-
*
|
6 |
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
-
|
22 |
-
class Owebia_Shipping2_Model_Mysql4_Setup extends Mage_Catalog_Model_Resource_Eav_Mysql4_Setup
|
23 |
-
{
|
24 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Owebia_Shipping2_Model_Os2_Data
|
8 |
+
{
|
9 |
+
protected $_data;
|
10 |
+
|
11 |
+
public function __construct($data = null)
|
12 |
+
{
|
13 |
+
$this->setData($data);
|
14 |
+
}
|
15 |
+
|
16 |
+
public function setData($data)
|
17 |
+
{
|
18 |
+
$this->_data = (array)$data;
|
19 |
+
return $this;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function __sleep()
|
23 |
+
{
|
24 |
+
return array_keys($this->_data);
|
25 |
+
}
|
26 |
+
|
27 |
+
public function __get($name)
|
28 |
+
{
|
29 |
+
return $this->getData($name);
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getData($name)
|
33 |
+
{
|
34 |
+
return isset($this->_data[$name]) ? $this->_data[$name] : null;
|
35 |
+
}
|
36 |
+
|
37 |
+
public function set($name, $value)
|
38 |
+
{
|
39 |
+
$this->_data[$name] = $value;
|
40 |
+
}
|
41 |
+
}
|
@@ -1,35 +1,19 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
-
protected $
|
25 |
protected $_attributes;
|
26 |
-
protected $
|
27 |
protected $_data;
|
28 |
|
29 |
public function __construct($arguments = null)
|
30 |
{
|
31 |
$this->_data = (array)$arguments;
|
32 |
-
//echo '<pre>Owebia_Shipping2_Model_Os2_Data_Abstract::__construct<br/>';foreach ($this->_data as $n => $v){echo "\t$n => ".(is_object($v) ? get_class($v) : (is_array($v) ? 'array' : $v))."<br/>";}
|
33 |
}
|
34 |
|
35 |
protected function _loadObject()
|
@@ -39,43 +23,34 @@ class Owebia_Shipping2_Model_Os2_Data_Abstract
|
|
39 |
|
40 |
protected function _getObject()
|
41 |
{
|
42 |
-
if ($this->
|
43 |
-
|
44 |
-
return $this->_loaded_object;
|
45 |
}
|
46 |
|
47 |
protected function _load($name)
|
48 |
{
|
49 |
$object = $this->_getObject();
|
50 |
if (!$object) return null;
|
51 |
-
/*echo get_class($this).'.getData('.$name.')'.$object->getData($name).'<br/>';
|
52 |
-
foreach ($object->getData() as $index => $value) echo "$index = $value<br/>";*/
|
53 |
return $object->getData($name);
|
54 |
}
|
55 |
|
56 |
public function __sleep()
|
57 |
{
|
58 |
if (isset($this->_attributes)) return $this->_attributes;
|
59 |
-
$this->_attributes = array_unique(array_merge(array_keys($this->_data), $this->
|
60 |
-
/*usort($this->_attributes, function($v1, $v2){
|
61 |
-
if ($v1=='id') return -1;
|
62 |
-
if ($v2=='id') return 1;
|
63 |
-
if ($v2=='*') return -1;
|
64 |
-
if ($v1=='*') return 1;
|
65 |
-
return $v1==$v2 ? 0 : ($v1<$v2 ? -1 : 1);
|
66 |
-
});*/
|
67 |
return $this->_attributes;
|
68 |
}
|
69 |
|
70 |
-
public function
|
71 |
{
|
72 |
-
/*$name2 = str_replace('.', '_', $name);
|
73 |
-
if (isset($this->_data[$name2])) return $this->_data[$name2];*/
|
74 |
-
//if (isset($this->_data[$name])) return $this->_data[$name]; // pb if id is null
|
75 |
if (!is_array($this->_data)) $this->_data = array();
|
76 |
if (array_key_exists($name, $this->_data)) return $this->_data[$name];
|
77 |
-
//if (in_array($name, $this->additional_attributes)) $this->_data[$name] = $this->_load($name);
|
78 |
$this->_data[$name] = $this->_load($name);
|
79 |
return $this->_data[$name];
|
80 |
}
|
|
|
|
|
|
|
|
|
|
|
81 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Os2_Data_Abstract
|
8 |
{
|
9 |
+
protected $_additionalAttributes = array();
|
10 |
protected $_attributes;
|
11 |
+
protected $_loadedObject = false;
|
12 |
protected $_data;
|
13 |
|
14 |
public function __construct($arguments = null)
|
15 |
{
|
16 |
$this->_data = (array)$arguments;
|
|
|
17 |
}
|
18 |
|
19 |
protected function _loadObject()
|
23 |
|
24 |
protected function _getObject()
|
25 |
{
|
26 |
+
if ($this->_loadedObject === false) $this->_loadedObject = $this->_loadObject();
|
27 |
+
return $this->_loadedObject;
|
|
|
28 |
}
|
29 |
|
30 |
protected function _load($name)
|
31 |
{
|
32 |
$object = $this->_getObject();
|
33 |
if (!$object) return null;
|
|
|
|
|
34 |
return $object->getData($name);
|
35 |
}
|
36 |
|
37 |
public function __sleep()
|
38 |
{
|
39 |
if (isset($this->_attributes)) return $this->_attributes;
|
40 |
+
$this->_attributes = array_unique(array_merge(array_keys($this->_data), $this->_additionalAttributes));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
return $this->_attributes;
|
42 |
}
|
43 |
|
44 |
+
public function getData($name)
|
45 |
{
|
|
|
|
|
|
|
46 |
if (!is_array($this->_data)) $this->_data = array();
|
47 |
if (array_key_exists($name, $this->_data)) return $this->_data[$name];
|
|
|
48 |
$this->_data[$name] = $this->_load($name);
|
49 |
return $this->_data[$name];
|
50 |
}
|
51 |
+
|
52 |
+
public function __get($name)
|
53 |
+
{
|
54 |
+
return $this->getData($name);
|
55 |
+
}
|
56 |
}
|
@@ -1,32 +1,16 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_AbstractWithAttributes extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
protected function _load($name)
|
25 |
{
|
26 |
-
$elems = explode('.', $name, $limit=2);
|
27 |
$count = count($elems);
|
28 |
-
$
|
29 |
-
if ($count==2) {
|
30 |
switch ($elems[0]) {
|
31 |
case 'a':
|
32 |
case 'attribute':
|
@@ -34,32 +18,30 @@ class Owebia_Shipping2_Model_Os2_Data_AbstractWithAttributes extends Owebia_Ship
|
|
34 |
return $this->_getAttribute($name);
|
35 |
}
|
36 |
}
|
37 |
-
//return parent::_load($name);
|
38 |
return $this->_getAttribute($name);
|
39 |
}
|
40 |
|
41 |
-
protected function _getAttribute($
|
42 |
{
|
43 |
-
$
|
44 |
-
if (substr($
|
45 |
-
$
|
46 |
-
$
|
47 |
}
|
48 |
|
49 |
$object = $this->_getObject();
|
50 |
if (!$object) return null;
|
51 |
-
$attribute = $object->getResource()->getAttribute($
|
52 |
if (!$attribute) return null;
|
53 |
|
54 |
-
$
|
55 |
-
$
|
56 |
-
switch ($
|
57 |
case 'select' :
|
58 |
-
|
59 |
-
$value = !$get_value ? $object->getData($attribute_name) : $attribute_frontend->getValue($object);
|
60 |
break;
|
61 |
default :
|
62 |
-
$value = $object->getData($
|
63 |
break;
|
64 |
}
|
65 |
return $value;
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Os2_Data_AbstractWithAttributes extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
8 |
{
|
9 |
protected function _load($name)
|
10 |
{
|
11 |
+
$elems = explode('.', $name, $limit = 2);
|
12 |
$count = count($elems);
|
13 |
+
if ($count == 2) {
|
|
|
14 |
switch ($elems[0]) {
|
15 |
case 'a':
|
16 |
case 'attribute':
|
18 |
return $this->_getAttribute($name);
|
19 |
}
|
20 |
}
|
|
|
21 |
return $this->_getAttribute($name);
|
22 |
}
|
23 |
|
24 |
+
protected function _getAttribute($attributeName)
|
25 |
{
|
26 |
+
$getValue = false;
|
27 |
+
if (substr($attributeName, strlen($attributeName) - 6, 6) == '.value') {
|
28 |
+
$getValue = true;
|
29 |
+
$attributeName = substr($attributeName, 0, strlen($attributeName) - 6);
|
30 |
}
|
31 |
|
32 |
$object = $this->_getObject();
|
33 |
if (!$object) return null;
|
34 |
+
$attribute = $object->getResource()->getAttribute($attributeName);
|
35 |
if (!$attribute) return null;
|
36 |
|
37 |
+
$attributeFrontend = $attribute->getFrontend();
|
38 |
+
$inputType = $attributeFrontend->getInputType();
|
39 |
+
switch ($inputType) {
|
40 |
case 'select' :
|
41 |
+
$value = !$getValue ? $object->getData($attributeName) : $attributeFrontend->getValue($object);
|
|
|
42 |
break;
|
43 |
default :
|
44 |
+
$value = $object->getData($attributeName);
|
45 |
break;
|
46 |
}
|
47 |
return $value;
|
@@ -1,33 +1,18 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Address extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
-
protected $
|
25 |
|
26 |
protected function _load($name)
|
27 |
{
|
28 |
switch ($name) {
|
29 |
case 'country_name':
|
30 |
-
return Mage::getModel('directory/country')->load($this->country_id)->getName();
|
31 |
}
|
32 |
return parent::_load($name);
|
33 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Os2_Data_Address extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
8 |
{
|
9 |
+
protected $_additionalAttributes = array('country_id', 'country_name', 'postcode');
|
10 |
|
11 |
protected function _load($name)
|
12 |
{
|
13 |
switch ($name) {
|
14 |
case 'country_name':
|
15 |
+
return Mage::getModel('directory/country')->load($this->getData('country_id'))->getName();
|
16 |
}
|
17 |
return parent::_load($name);
|
18 |
}
|
@@ -1,23 +1,8 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_AddressFilter extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
@@ -28,46 +13,73 @@ class Owebia_Shipping2_Model_Os2_Data_AddressFilter extends Owebia_Shipping2_Mod
|
|
28 |
// continents
|
29 |
'AF' => array(
|
30 |
'label' => 'Africa',
|
31 |
-
'replace' =>
|
|
|
|
|
|
|
|
|
|
|
32 |
),
|
33 |
'AS' => array(
|
34 |
'label' => 'Asia',
|
35 |
-
'replace' =>
|
|
|
|
|
|
|
|
|
|
|
36 |
),
|
37 |
'EU' => array(
|
38 |
'label' => 'Europa',
|
39 |
-
'replace' =>
|
|
|
|
|
|
|
|
|
|
|
40 |
),
|
41 |
'NA' => array(
|
42 |
'label' => 'North America',
|
43 |
-
'replace' =>
|
|
|
|
|
|
|
|
|
44 |
),
|
45 |
'SA' => array(
|
46 |
'label' => 'South America',
|
47 |
-
'replace' =>
|
|
|
|
|
48 |
),
|
49 |
'OC' => array(
|
50 |
'label' => 'Oceania',
|
51 |
-
'replace' =>
|
|
|
|
|
|
|
52 |
),
|
53 |
'AN' => array(
|
54 |
'label' => 'Antartica',
|
55 |
-
'replace' => 'AQ,BV,GS,HM,TF',
|
56 |
),
|
57 |
/*UK=>GB*/
|
58 |
'EU-27' => array(
|
59 |
'label' => 'European Union',
|
60 |
-
'replace' =>
|
|
|
|
|
|
|
61 |
),
|
62 |
/* Guadeloupe, Martinique, Guyane, Réunion, Mayotte */
|
63 |
'DOM' => array(
|
64 |
'label' => "Département d'Outre-Mer",
|
65 |
-
'replace' => 'GP,MQ,GF,RE,YT',
|
66 |
),
|
67 |
/* Polynésie française, Saint-Pierre-et-Miquelon, Wallis-et-Futuna, Saint-Martin, Saint-Barthélemy */
|
68 |
'COM' => array(
|
69 |
'label' => "Collectivités d'Outre-Mer",
|
70 |
-
'replace' => 'PF,PM,WF,MF,BL',
|
71 |
),
|
72 |
);
|
73 |
|
@@ -81,7 +93,7 @@ class Owebia_Shipping2_Model_Os2_Data_AddressFilter extends Owebia_Shipping2_Mod
|
|
81 |
}
|
82 |
self::$_countries = $countries;
|
83 |
}
|
84 |
-
|
85 |
$elems = preg_split('/\b/', $input);
|
86 |
$output = '';
|
87 |
foreach ($elems as $elem) {
|
@@ -103,7 +115,7 @@ class Owebia_Shipping2_Model_Os2_Data_AddressFilter extends Owebia_Shipping2_Mod
|
|
103 |
protected function _load($name)
|
104 |
{
|
105 |
if (isset(self::$_shortcuts[$name])) {
|
106 |
-
return self::$_shortcuts[$name]['replace'];
|
107 |
}
|
108 |
return parent::_load($name);
|
109 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Os2_Data_AddressFilter extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
8 |
{
|
13 |
// continents
|
14 |
'AF' => array(
|
15 |
'label' => 'Africa',
|
16 |
+
'replace' => array(
|
17 |
+
'AO', 'BF', 'BI', 'BJ', 'BW', 'CD', 'CF', 'CG', 'CI', 'CM', 'CV', 'DJ', 'DZ', 'EG', 'EH', 'ER', 'ET',
|
18 |
+
'GA', 'GH', 'GM', 'GN', 'GQ', 'GW', 'KE', 'KM', 'LR', 'LS', 'LY', 'MA', 'MG', 'ML', 'MR', 'MU', 'MW',
|
19 |
+
'MZ', 'NA', 'NE', 'NG', 'RE', 'RW', 'SC', 'SD', 'SS', 'SH', 'SL', 'SN', 'SO', 'ST', 'SZ', 'TD', 'TG',
|
20 |
+
'TN', 'TZ', 'UG', 'YT', 'ZA', 'ZM', 'ZW',
|
21 |
+
),
|
22 |
),
|
23 |
'AS' => array(
|
24 |
'label' => 'Asia',
|
25 |
+
'replace' => array(
|
26 |
+
'AE', 'AF', 'AM', 'AZ', 'BD', 'BH', 'BN', 'BT', 'CC', 'CN', 'CX', 'GE', 'HK', 'ID', 'IL', 'IN', 'IO',
|
27 |
+
'IQ', 'IR', 'JO', 'JP', 'KG', 'KH', 'KP', 'KR', 'KW', 'KZ', 'LA', 'LB', 'LK', 'MM', 'MN', 'MO', 'MV',
|
28 |
+
'MY', 'NP', 'OM', 'PH', 'PK', 'PS', 'QA', 'SA', 'SG', 'SY', 'TH', 'TJ', 'TM', 'TR', 'TW', 'UZ', 'VN',
|
29 |
+
'YE',
|
30 |
+
),
|
31 |
),
|
32 |
'EU' => array(
|
33 |
'label' => 'Europa',
|
34 |
+
'replace' => array(
|
35 |
+
'AD', 'AL', 'AT', 'AX', 'BA', 'BE', 'BG', 'BY', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FO',
|
36 |
+
'FR', 'GB', 'GG', 'GI', 'GR', 'HR', 'HU', 'IE', 'IM', 'IS', 'IT', 'JE', 'XK', 'LI', 'LT', 'LU', 'LV',
|
37 |
+
'MC', 'MD', 'ME', 'MK', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'RS', 'RU', 'SE', 'SI', 'SJ', 'SK', 'SM',
|
38 |
+
'UA', 'VA', 'CS',
|
39 |
+
),
|
40 |
),
|
41 |
'NA' => array(
|
42 |
'label' => 'North America',
|
43 |
+
'replace' => array(
|
44 |
+
'AG', 'AI', 'AW', 'BB', 'BL', 'BM', 'BQ', 'BS', 'BZ', 'CA', 'CR', 'CU', 'CW', 'DM', 'DO', 'GD', 'GL',
|
45 |
+
'GP', 'GT', 'HN', 'HT', 'JM', 'KN', 'KY', 'LC', 'MF', 'MQ', 'MS', 'MX', 'NI', 'PA', 'PM', 'PR', 'SV',
|
46 |
+
'SX', 'TC', 'TT', 'US', 'VC', 'VG', 'VI', 'AN',
|
47 |
+
),
|
48 |
),
|
49 |
'SA' => array(
|
50 |
'label' => 'South America',
|
51 |
+
'replace' => array(
|
52 |
+
'AR', 'BO', 'BR', 'CL', 'CO', 'EC', 'FK', 'GF', 'GY', 'PE', 'PY', 'SR', 'UY', 'VE',
|
53 |
+
),
|
54 |
),
|
55 |
'OC' => array(
|
56 |
'label' => 'Oceania',
|
57 |
+
'replace' => array(
|
58 |
+
'AS', 'AU', 'CK', 'FJ', 'FM', 'GU', 'KI', 'MH', 'MP', 'NC', 'NF', 'NR', 'NU', 'NZ', 'PF', 'PG', 'PN',
|
59 |
+
'PW', 'SB', 'TK', 'TL', 'TO', 'TV', 'UM', 'VU', 'WF', 'WS',
|
60 |
+
),
|
61 |
),
|
62 |
'AN' => array(
|
63 |
'label' => 'Antartica',
|
64 |
+
'replace' => array('AQ', 'BV', 'GS', 'HM', 'TF'),
|
65 |
),
|
66 |
/*UK=>GB*/
|
67 |
'EU-27' => array(
|
68 |
'label' => 'European Union',
|
69 |
+
'replace' => array(
|
70 |
+
'AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'EL', 'ES', 'FI', 'FR', 'HU', 'IE', 'IT', 'LT', 'LU',
|
71 |
+
'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SI', 'SK', 'SE', 'GB',
|
72 |
+
),
|
73 |
),
|
74 |
/* Guadeloupe, Martinique, Guyane, Réunion, Mayotte */
|
75 |
'DOM' => array(
|
76 |
'label' => "Département d'Outre-Mer",
|
77 |
+
'replace' => array('GP', 'MQ', 'GF', 'RE', 'YT'),
|
78 |
),
|
79 |
/* Polynésie française, Saint-Pierre-et-Miquelon, Wallis-et-Futuna, Saint-Martin, Saint-Barthélemy */
|
80 |
'COM' => array(
|
81 |
'label' => "Collectivités d'Outre-Mer",
|
82 |
+
'replace' => array('PF', 'PM', 'WF', 'MF', 'BL'),
|
83 |
),
|
84 |
);
|
85 |
|
93 |
}
|
94 |
self::$_countries = $countries;
|
95 |
}
|
96 |
+
|
97 |
$elems = preg_split('/\b/', $input);
|
98 |
$output = '';
|
99 |
foreach ($elems as $elem) {
|
115 |
protected function _load($name)
|
116 |
{
|
117 |
if (isset(self::$_shortcuts[$name])) {
|
118 |
+
return implode(',', self::$_shortcuts[$name]['replace']);
|
119 |
}
|
120 |
return parent::_load($name);
|
121 |
}
|
@@ -1,36 +1,21 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_AttributeSet extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
protected function _loadObject()
|
25 |
{
|
26 |
-
return Mage::getModel('eav/entity_attribute_set')->load($this->id);
|
27 |
}
|
28 |
|
29 |
protected function _load($name)
|
30 |
{
|
31 |
switch ($name) {
|
32 |
case 'name':
|
33 |
-
return $this->
|
34 |
default:
|
35 |
return parent::_load($name);
|
36 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Os2_Data_AttributeSet extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
8 |
{
|
9 |
protected function _loadObject()
|
10 |
{
|
11 |
+
return Mage::getModel('eav/entity_attribute_set')->load($this->getData('id'));
|
12 |
}
|
13 |
|
14 |
protected function _load($name)
|
15 |
{
|
16 |
switch ($name) {
|
17 |
case 'name':
|
18 |
+
return $this->getData('attribute_set_name');
|
19 |
default:
|
20 |
return parent::_load($name);
|
21 |
}
|
@@ -1,23 +1,8 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Billto extends Owebia_Shipping2_Model_Os2_Data_Address
|
23 |
{
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Os2_Data_Billto extends Owebia_Shipping2_Model_Os2_Data_Address
|
8 |
{
|
@@ -1,28 +1,13 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Cart extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
-
protected $
|
25 |
-
protected $
|
26 |
protected $_items;
|
27 |
protected $_quote;
|
28 |
protected $_options;
|
@@ -35,8 +20,9 @@ class Owebia_Shipping2_Model_Os2_Data_Cart extends Owebia_Shipping2_Model_Os2_Da
|
|
35 |
|
36 |
$this->_data = array(
|
37 |
// Do not use quote to retrieve values, totals are not available
|
38 |
-
|
39 |
-
'price-tax
|
|
|
40 |
'price+tax+discount' => null,
|
41 |
'price+tax-discount' => null,
|
42 |
'weight' => $request->getData('package_weight'),
|
@@ -44,10 +30,11 @@ class Owebia_Shipping2_Model_Os2_Data_Cart extends Owebia_Shipping2_Model_Os2_Da
|
|
44 |
'free_shipping' => $request->getData('free_shipping'),
|
45 |
);
|
46 |
|
47 |
-
$
|
48 |
$items = $request->getAllItems();
|
49 |
-
$
|
50 |
-
$
|
|
|
51 |
foreach ($items as $item) {
|
52 |
$product = $item->getProduct();
|
53 |
if ($product instanceof Mage_Catalog_Model_Product) {
|
@@ -57,45 +44,45 @@ class Owebia_Shipping2_Model_Os2_Data_Cart extends Owebia_Shipping2_Model_Os2_Da
|
|
57 |
} else if ($item instanceof Mage_Sales_Model_Quote_Item) { // Onepage checkout
|
58 |
$key = $item->getId();
|
59 |
}
|
60 |
-
$
|
61 |
}
|
62 |
}
|
63 |
|
64 |
// Do not use quote to retrieve values, totals are not available
|
65 |
-
$
|
66 |
-
$
|
67 |
-
$
|
68 |
-
$
|
69 |
$this->_items = array();
|
70 |
-
foreach ($
|
71 |
$type = $item->getProduct()->getTypeId();
|
72 |
-
|
73 |
-
$
|
74 |
-
$
|
75 |
-
|
76 |
-
|
77 |
-
if ($type=='bundle' && $bundle_process_children) {
|
78 |
$this->_data['qty'] -= $item->getQty();
|
79 |
continue;
|
80 |
}
|
81 |
-
if ($
|
82 |
-
if (!$
|
83 |
else $this->_data['qty'] += $item->getQty();
|
84 |
}
|
85 |
-
$this->_items[] = Mage::getModel(
|
|
|
|
|
|
|
86 |
}
|
87 |
-
|
88 |
-
$
|
89 |
-
$
|
90 |
-
|
91 |
-
$
|
92 |
}
|
93 |
-
$this->_data['price-tax+discount'] = $
|
94 |
-
$this->_data['price-tax-discount'] = $
|
95 |
-
$this->_data['price+tax+discount'] = $
|
96 |
-
$this->_data['price+tax-discount'] = $
|
97 |
-
|
98 |
-
//echo '<pre>Owebia_Shipping2_Model_Os2_Data_Abstract::__construct<br/>';foreach ($this->_data as $n => $v){echo "\t$n => ".(is_object($v) ? get_class($v) : (is_array($v) ? 'array' : $v))."<br/>";}echo '</pre>';
|
99 |
}
|
100 |
|
101 |
protected function _getQuote()
|
@@ -107,15 +94,15 @@ class Owebia_Shipping2_Model_Os2_Data_Cart extends Owebia_Shipping2_Model_Os2_Da
|
|
107 |
{
|
108 |
switch ($name) {
|
109 |
case 'weight_for_charge':
|
110 |
-
$
|
111 |
foreach ($this->_items as $item) {
|
112 |
-
if ($item->free_shipping) $
|
113 |
}
|
114 |
-
return $
|
115 |
case 'coupon_code':
|
116 |
-
$
|
117 |
$quote = $this->_getQuote();
|
118 |
-
return $quote->coupon_code;
|
119 |
case 'weight_unit':
|
120 |
return Mage::getStoreConfig('owebia_shipping2/general/weight_unit');
|
121 |
}
|
@@ -131,22 +118,22 @@ class Owebia_Shipping2_Model_Os2_Data_Cart extends Owebia_Shipping2_Model_Os2_Da
|
|
131 |
return parent::__set($name, $value);
|
132 |
}
|
133 |
|
134 |
-
public function
|
135 |
{
|
136 |
switch ($name) {
|
137 |
case 'items':
|
138 |
return $this->_items;
|
139 |
case 'free_shipping':
|
140 |
-
if (isset($this->
|
141 |
-
$
|
142 |
-
if (!$
|
143 |
foreach ($this->_items as $item) {
|
144 |
-
$
|
145 |
-
if (!$
|
146 |
}
|
147 |
}
|
148 |
-
return $this->
|
149 |
}
|
150 |
-
return parent::
|
151 |
}
|
152 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Os2_Data_Cart extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
8 |
{
|
9 |
+
protected $_additionalAttributes = array('coupon_code', 'weight_unit', 'weight_for_charge', 'free_shipping');
|
10 |
+
protected $_freeShipping;
|
11 |
protected $_items;
|
12 |
protected $_quote;
|
13 |
protected $_options;
|
20 |
|
21 |
$this->_data = array(
|
22 |
// Do not use quote to retrieve values, totals are not available
|
23 |
+
// package_value and package_value_with_discount : Bad value in backoffice orders
|
24 |
+
'price-tax+discount' => null,
|
25 |
+
'price-tax-discount' => null,
|
26 |
'price+tax+discount' => null,
|
27 |
'price+tax-discount' => null,
|
28 |
'weight' => $request->getData('package_weight'),
|
30 |
'free_shipping' => $request->getData('free_shipping'),
|
31 |
);
|
32 |
|
33 |
+
$cartItems = array();
|
34 |
$items = $request->getAllItems();
|
35 |
+
$quoteTotalCollected = false;
|
36 |
+
$bundleProcessChildren = isset($this->_options['bundle']['process_children'])
|
37 |
+
&& $this->_options['bundle']['process_children'];
|
38 |
foreach ($items as $item) {
|
39 |
$product = $item->getProduct();
|
40 |
if ($product instanceof Mage_Catalog_Model_Product) {
|
44 |
} else if ($item instanceof Mage_Sales_Model_Quote_Item) { // Onepage checkout
|
45 |
$key = $item->getId();
|
46 |
}
|
47 |
+
$cartItems[$key] = $item;
|
48 |
}
|
49 |
}
|
50 |
|
51 |
// Do not use quote to retrieve values, totals are not available
|
52 |
+
$totalInclTaxWithoutDiscount = 0;
|
53 |
+
$totalExclTaxWithoutDiscount = 0;
|
54 |
+
$totalInclTaxWithDiscount = 0;
|
55 |
+
$totalExclTaxWithDiscount = 0;
|
56 |
$this->_items = array();
|
57 |
+
foreach ($cartItems as $item) {
|
58 |
$type = $item->getProduct()->getTypeId();
|
59 |
+
$parentItemId = $item->getData('parent_item_id');
|
60 |
+
$parentItem = isset($cartItems[$parentItemId]) ? $cartItems[$parentItemId] : null;
|
61 |
+
$parentType = isset($parentItem) ? $parentItem->getProduct()->getTypeId() : null;
|
62 |
+
if ($type != 'configurable') {
|
63 |
+
if ($type == 'bundle' && $bundleProcessChildren) {
|
|
|
64 |
$this->_data['qty'] -= $item->getQty();
|
65 |
continue;
|
66 |
}
|
67 |
+
if ($parentType == 'bundle') {
|
68 |
+
if (!$bundleProcessChildren) continue;
|
69 |
else $this->_data['qty'] += $item->getQty();
|
70 |
}
|
71 |
+
$this->_items[] = Mage::getModel(
|
72 |
+
'owebia_shipping2/Os2_Data_CartItem',
|
73 |
+
array('item' => $item, 'parent_item' => $parentItem, 'options' => $this->_options)
|
74 |
+
);
|
75 |
}
|
76 |
+
$totalExclTaxWithoutDiscount += $item->getData('base_row_total');
|
77 |
+
$totalExclTaxWithDiscount += $item->getData('base_row_total') - $item->getData('base_discount_amount');
|
78 |
+
$totalInclTaxWithDiscount += $item->getData('base_row_total') - $item->getData('base_discount_amount')
|
79 |
+
+ $item->getData('tax_amount');
|
80 |
+
$totalInclTaxWithoutDiscount += $item->getData('base_row_total_incl_tax');
|
81 |
}
|
82 |
+
$this->_data['price-tax+discount'] = $totalExclTaxWithDiscount;
|
83 |
+
$this->_data['price-tax-discount'] = $totalExclTaxWithoutDiscount;
|
84 |
+
$this->_data['price+tax+discount'] = $totalInclTaxWithDiscount;
|
85 |
+
$this->_data['price+tax-discount'] = $totalInclTaxWithoutDiscount;
|
|
|
|
|
86 |
}
|
87 |
|
88 |
protected function _getQuote()
|
94 |
{
|
95 |
switch ($name) {
|
96 |
case 'weight_for_charge':
|
97 |
+
$weightForCharge = $this->getData('weight');
|
98 |
foreach ($this->_items as $item) {
|
99 |
+
if ($item->getData('free_shipping')) $weightForCharge -= $item->getData('weight');
|
100 |
}
|
101 |
+
return $weightForCharge;
|
102 |
case 'coupon_code':
|
103 |
+
$couponCode = null;
|
104 |
$quote = $this->_getQuote();
|
105 |
+
return $quote->getData('coupon_code');
|
106 |
case 'weight_unit':
|
107 |
return Mage::getStoreConfig('owebia_shipping2/general/weight_unit');
|
108 |
}
|
118 |
return parent::__set($name, $value);
|
119 |
}
|
120 |
|
121 |
+
public function getData($name)
|
122 |
{
|
123 |
switch ($name) {
|
124 |
case 'items':
|
125 |
return $this->_items;
|
126 |
case 'free_shipping':
|
127 |
+
if (isset($this->_freeShipping)) return $this->_freeShipping;
|
128 |
+
$freeShipping = parent::getData('free_shipping');
|
129 |
+
if (!$freeShipping) {
|
130 |
foreach ($this->_items as $item) {
|
131 |
+
$freeShipping = $item->getData('free_shipping');
|
132 |
+
if (!$freeShipping) break;
|
133 |
}
|
134 |
}
|
135 |
+
return $this->_freeShipping = $freeShipping;
|
136 |
}
|
137 |
+
return parent::getData($name);
|
138 |
}
|
139 |
}
|
@@ -1,102 +1,63 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_CartItem extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
-
private $parent_cart_item;
|
25 |
-
private $cart_product;
|
26 |
-
private $loaded_product;
|
27 |
-
private $quantity;
|
28 |
-
private $categories;
|
29 |
-
|
30 |
protected $_product;
|
31 |
protected $_item;
|
32 |
-
protected $
|
33 |
protected $_type;
|
34 |
protected $_options;
|
35 |
-
protected $
|
36 |
|
37 |
public function __construct($arguments)
|
38 |
{
|
39 |
parent::__construct();
|
40 |
$this->_item = $item = $arguments['item'];
|
41 |
-
$this->
|
42 |
-
$this->
|
43 |
$this->_product = null;
|
44 |
-
$this->_type = $
|
45 |
-
$this->
|
46 |
-
|
47 |
-
if (false) {
|
48 |
-
echo '---------------------------------<br/>';
|
49 |
-
foreach ($this->_item->getData() as $index => $value) {
|
50 |
-
$value = is_object($value) ? get_class($value) : (is_array($value) ? 'array' : $value);
|
51 |
-
echo "$index = $value<br/>";
|
52 |
-
}
|
53 |
-
if ($parent_item) {
|
54 |
-
echo '----- parent -----<br/>';
|
55 |
-
foreach ($parent_item->getData() as $index => $value) echo "$index = $value<br/>";
|
56 |
-
}
|
57 |
-
echo 'type:'.$this->_type.'<br/>';
|
58 |
-
echo 'sku:'.$this->sku.'<br/>';
|
59 |
-
}
|
60 |
}
|
61 |
|
62 |
public function getProduct()
|
63 |
{
|
64 |
if (!isset($this->_product)) {
|
65 |
-
|
66 |
-
$
|
67 |
-
$this->_product = Mage::getModel('owebia_shipping2/Os2_Data_Product', array('id' => $product_id));
|
68 |
}
|
69 |
return $this->_product;
|
70 |
}
|
71 |
|
72 |
protected function _load($name)
|
73 |
{
|
74 |
-
$elems = explode('.', $name, $limit=2);
|
75 |
$count = count($elems);
|
76 |
-
$
|
77 |
-
|
78 |
-
|
79 |
-
case 'o':
|
80 |
-
case 'option':
|
81 |
-
return $this->_getOption($elems[1]);
|
82 |
}
|
83 |
}
|
84 |
switch ($name) {
|
85 |
-
case 'price-tax+discount':
|
86 |
-
|
|
|
|
|
|
|
87 |
case 'price+tax+discount':
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
echo ' ::: = '.($this->base_original_price+($this->tax_amount-$this->discount_amount)/$this->qty).'<br>';*/
|
93 |
-
return (double)$this->base_original_price+($this->tax_amount-$this->discount_amount)/$this->qty;
|
94 |
-
case 'price+tax-discount': return (double)$this->price_incl_tax;
|
95 |
case 'weight':
|
96 |
-
if ($this->_type=='bundle' && $this->getProduct()->weight_type==0) {
|
97 |
-
return (double)parent::_load($name);
|
98 |
}
|
99 |
-
return $this->qty
|
100 |
default:
|
101 |
return parent::_load($name);
|
102 |
}
|
@@ -104,22 +65,22 @@ class Owebia_Shipping2_Model_Os2_Data_CartItem extends Owebia_Shipping2_Model_Os
|
|
104 |
|
105 |
public function __toString()
|
106 |
{
|
107 |
-
return $this->name.' (id:'
|
108 |
}
|
109 |
|
110 |
-
protected function _getOption($
|
111 |
{
|
112 |
$options = $this->_getOptions();
|
113 |
-
if (isset($options[$
|
|
|
|
|
114 |
else return null;
|
115 |
}
|
116 |
|
117 |
protected function _getItem($what)
|
118 |
{
|
119 |
-
$
|
120 |
-
|
121 |
-
print_r($this->_get_options[$this->_type]);*/
|
122 |
-
return $get_parent ? $this->_parent_item : $this->_item;
|
123 |
}
|
124 |
|
125 |
protected function _getOptions()
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Os2_Data_CartItem extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
8 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
protected $_product;
|
10 |
protected $_item;
|
11 |
+
protected $_parentItem;
|
12 |
protected $_type;
|
13 |
protected $_options;
|
14 |
+
protected $_getOptions;
|
15 |
|
16 |
public function __construct($arguments)
|
17 |
{
|
18 |
parent::__construct();
|
19 |
$this->_item = $item = $arguments['item'];
|
20 |
+
$this->_parentItem = $parentItem = $arguments['parent_item'];
|
21 |
+
$this->_getOptions = $options = $arguments['options'];
|
22 |
$this->_product = null;
|
23 |
+
$this->_type = $parentItem ? $parentItem->getProduct()->getTypeId() : $item->getProduct()->getTypeId();
|
24 |
+
$this->_loadedObject = $this->_getItem('load_item_data_on_parent');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
|
27 |
public function getProduct()
|
28 |
{
|
29 |
if (!isset($this->_product)) {
|
30 |
+
$productId = $this->_getItem('load_product_data_on_parent')->getData('product_id');
|
31 |
+
$this->_product = Mage::getModel('owebia_shipping2/Os2_Data_Product', array('id' => $productId));
|
|
|
32 |
}
|
33 |
return $this->_product;
|
34 |
}
|
35 |
|
36 |
protected function _load($name)
|
37 |
{
|
38 |
+
$elems = explode('.', $name, $limit = 2);
|
39 |
$count = count($elems);
|
40 |
+
if ($count == 2) {
|
41 |
+
if ($elems[0] == 'o' || $elems[0] == 'option') {
|
42 |
+
return $this->_getOption($elems[1]);
|
|
|
|
|
|
|
43 |
}
|
44 |
}
|
45 |
switch ($name) {
|
46 |
+
case 'price-tax+discount':
|
47 |
+
return (double) $this->getData('base_original_price') - $this->getData('discount_amount')
|
48 |
+
/ $this->getData('qty');
|
49 |
+
case 'price-tax-discount':
|
50 |
+
return (double) $this->getData('base_original_price');
|
51 |
case 'price+tax+discount':
|
52 |
+
return (double) $this->getData('base_original_price')
|
53 |
+
+ ( $this->getData('tax_amount') - $this->getData('discount_amount') ) / $this->getData('qty');
|
54 |
+
case 'price+tax-discount':
|
55 |
+
return (double) $this->getData('price_incl_tax');
|
|
|
|
|
|
|
56 |
case 'weight':
|
57 |
+
if ($this->_type == 'bundle' && $this->getProduct()->getData('weight_type') == 0) {
|
58 |
+
return (double) parent::_load($name);
|
59 |
}
|
60 |
+
return $this->getData('qty') * $this->getProduct()->getData('weight');
|
61 |
default:
|
62 |
return parent::_load($name);
|
63 |
}
|
65 |
|
66 |
public function __toString()
|
67 |
{
|
68 |
+
return $this->getData('name') . ' (id:' . $this->getData('product_id') . ', sku:' . $this->getData('sku') . ')';
|
69 |
}
|
70 |
|
71 |
+
protected function _getOption($optionName, $getById = false)
|
72 |
{
|
73 |
$options = $this->_getOptions();
|
74 |
+
if (isset($options[$optionName])) {
|
75 |
+
return $getById ? $options[$optionName]['value_id'] : $options[$optionName]['value'];
|
76 |
+
}
|
77 |
else return null;
|
78 |
}
|
79 |
|
80 |
protected function _getItem($what)
|
81 |
{
|
82 |
+
$getParent = isset($this->_getOptions[$this->_type][$what]) && $this->_getOptions[$this->_type][$what] == true;
|
83 |
+
return $getParent ? $this->_parentItem : $this->_item;
|
|
|
|
|
84 |
}
|
85 |
|
86 |
protected function _getOptions()
|
@@ -1,33 +1,18 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Category extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
protected function _loadObject()
|
25 |
{
|
26 |
-
return Mage::getModel('catalog/category')->load($this->id);
|
27 |
}
|
28 |
|
29 |
public function __toString()
|
30 |
{
|
31 |
-
return $this->name.' (id:'
|
32 |
}
|
33 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Os2_Data_Category extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
8 |
{
|
9 |
protected function _loadObject()
|
10 |
{
|
11 |
+
return Mage::getModel('catalog/category')->load($this->getData('id'));
|
12 |
}
|
13 |
|
14 |
public function __toString()
|
15 |
{
|
16 |
+
return $this->getData('name') . ' (id:' . $this->getData('id') . ', url_key:' . $this->getData('url_key') . ')';
|
17 |
}
|
18 |
}
|
@@ -1,42 +1,29 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Customer extends Owebia_Shipping2_Model_Os2_Data_AbstractWithAttributes
|
23 |
{
|
24 |
-
protected $
|
25 |
|
26 |
-
public function __construct(
|
27 |
{
|
28 |
-
parent::__construct(
|
29 |
-
|
30 |
-
|
|
|
|
|
31 |
}
|
32 |
|
33 |
protected function _loadObject()
|
34 |
{
|
35 |
-
return Mage::getModel('customer/customer')->load($this->id);
|
36 |
}
|
37 |
|
38 |
public function __toString()
|
39 |
{
|
40 |
-
return $this->firstname.' '
|
41 |
}
|
42 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Os2_Data_Customer extends Owebia_Shipping2_Model_Os2_Data_AbstractWithAttributes
|
8 |
{
|
9 |
+
protected $_additionalAttributes = array('*');
|
10 |
|
11 |
+
public function __construct()
|
12 |
{
|
13 |
+
parent::__construct(
|
14 |
+
array(
|
15 |
+
'id' => Mage::getModel('owebia_shipping2/Os2_Data_Quote')->getData('customer_id'),
|
16 |
+
)
|
17 |
+
);
|
18 |
}
|
19 |
|
20 |
protected function _loadObject()
|
21 |
{
|
22 |
+
return Mage::getModel('customer/customer')->load($this->getData('id'));
|
23 |
}
|
24 |
|
25 |
public function __toString()
|
26 |
{
|
27 |
+
return $this->getData('firstname') . ' ' . $this->getData('lastname') . ' (id:' . $this->getData('id') . ')';
|
28 |
}
|
29 |
}
|
@@ -1,81 +1,72 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_CustomerGroup extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
-
protected static $
|
25 |
|
26 |
public static function getCollection()
|
27 |
{
|
28 |
-
if (!self::$
|
29 |
$collection = Mage::getModel('customer/group')->getCollection();
|
30 |
-
$
|
31 |
-
foreach ($collection as $
|
32 |
-
$
|
33 |
}
|
34 |
-
self::$
|
35 |
}
|
36 |
-
return self::$
|
37 |
}
|
38 |
|
39 |
public static function readable($input)
|
40 |
{
|
41 |
-
$
|
42 |
$elems = preg_split('/\b/', $input);
|
43 |
$output = '';
|
44 |
foreach ($elems as $elem) {
|
45 |
-
$output .= isset($
|
46 |
}
|
47 |
return $output;
|
48 |
}
|
49 |
|
50 |
-
protected $
|
51 |
|
52 |
-
public function __construct(
|
53 |
{
|
54 |
-
$
|
55 |
-
if ($
|
56 |
-
$
|
57 |
-
if (isset($
|
|
|
|
|
58 |
}
|
59 |
-
parent::__construct(
|
60 |
-
|
61 |
-
|
|
|
|
|
62 |
}
|
63 |
|
64 |
protected function _load($name)
|
65 |
{
|
66 |
switch ($name) {
|
67 |
-
case 'code':
|
68 |
-
|
|
|
|
|
69 |
}
|
70 |
}
|
71 |
|
72 |
protected function _loadObject()
|
73 |
{
|
74 |
-
return Mage::getSingleton('customer/group')->load($this->id);
|
75 |
}
|
76 |
|
77 |
public function __toString()
|
78 |
{
|
79 |
-
return $this->code.' (id:'
|
80 |
}
|
81 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Os2_Data_CustomerGroup extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
8 |
{
|
9 |
+
protected static $_customerGroups = null;
|
10 |
|
11 |
public static function getCollection()
|
12 |
{
|
13 |
+
if (!self::$_customerGroups) {
|
14 |
$collection = Mage::getModel('customer/group')->getCollection();
|
15 |
+
$customerGroups = array();
|
16 |
+
foreach ($collection as $customerGroup) {
|
17 |
+
$customerGroups[$customerGroup->getId()] = $customerGroup->getCustomerGroupCode();
|
18 |
}
|
19 |
+
self::$_customerGroups = $customerGroups;
|
20 |
}
|
21 |
+
return self::$_customerGroups;
|
22 |
}
|
23 |
|
24 |
public static function readable($input)
|
25 |
{
|
26 |
+
$customerGroups = self::getCollection();
|
27 |
$elems = preg_split('/\b/', $input);
|
28 |
$output = '';
|
29 |
foreach ($elems as $elem) {
|
30 |
+
$output .= isset($customerGroups[$elem]) ? $customerGroups[$elem] : $elem;
|
31 |
}
|
32 |
return $output;
|
33 |
}
|
34 |
|
35 |
+
protected $_additionalAttributes = array('*');
|
36 |
|
37 |
+
public function __construct()
|
38 |
{
|
39 |
+
$customerGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
|
40 |
+
if ($customerGroupId == 0) { // Pour les commandes depuis Adminhtml
|
41 |
+
$adminCustomerGroupId = Mage::getSingleton('adminhtml/session_quote')->getQuote()->getCustomerGroupId();
|
42 |
+
if (isset($adminCustomerGroupId)) {
|
43 |
+
$customerGroupId = $adminCustomerGroupId;
|
44 |
+
}
|
45 |
}
|
46 |
+
parent::__construct(
|
47 |
+
array(
|
48 |
+
'id' => $customerGroupId,
|
49 |
+
)
|
50 |
+
);
|
51 |
}
|
52 |
|
53 |
protected function _load($name)
|
54 |
{
|
55 |
switch ($name) {
|
56 |
+
case 'code':
|
57 |
+
return $this->getData('customer_group_code');
|
58 |
+
default:
|
59 |
+
return parent::_load($name);
|
60 |
}
|
61 |
}
|
62 |
|
63 |
protected function _loadObject()
|
64 |
{
|
65 |
+
return Mage::getSingleton('customer/group')->load($this->getData('id'));
|
66 |
}
|
67 |
|
68 |
public function __toString()
|
69 |
{
|
70 |
+
return $this->getData('code') . ' (id:' . $this->getData('id') . ')';
|
71 |
}
|
72 |
}
|
@@ -1,23 +1,8 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Customvar extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Os2_Data_Customvar extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
8 |
{
|
@@ -1,27 +1,12 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Date extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
-
|
25 |
|
26 |
public function __construct()
|
27 |
{
|
@@ -34,17 +19,31 @@ class Owebia_Shipping2_Model_Os2_Data_Date extends Owebia_Shipping2_Model_Os2_Da
|
|
34 |
return array('timestamp', 'year', 'month', 'day', 'hour', 'minute', 'second', 'weekday');
|
35 |
}
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
protected function _load($name)
|
38 |
{
|
39 |
switch ($name) {
|
40 |
-
case 'timestamp':
|
41 |
-
|
42 |
-
case '
|
43 |
-
|
44 |
-
case '
|
45 |
-
|
46 |
-
case '
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
}
|
49 |
return null;
|
50 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Os2_Data_Date extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
8 |
{
|
9 |
+
protected $_timestamp;
|
10 |
|
11 |
public function __construct()
|
12 |
{
|
19 |
return array('timestamp', 'year', 'month', 'day', 'hour', 'minute', 'second', 'weekday');
|
20 |
}
|
21 |
|
22 |
+
protected function getDate($format)
|
23 |
+
{
|
24 |
+
return (int)Mage::getModel('core/date')
|
25 |
+
->date($format, $this->_timestamp);
|
26 |
+
}
|
27 |
+
|
28 |
protected function _load($name)
|
29 |
{
|
30 |
switch ($name) {
|
31 |
+
case 'timestamp':
|
32 |
+
return $this->_timestamp;
|
33 |
+
case 'year':
|
34 |
+
return $this->getDate('Y');
|
35 |
+
case 'month':
|
36 |
+
return $this->getDate('m');
|
37 |
+
case 'day':
|
38 |
+
return $this->getDate('d');
|
39 |
+
case 'hour':
|
40 |
+
return $this->getDate('H');
|
41 |
+
case 'minute':
|
42 |
+
return $this->getDate('i');
|
43 |
+
case 'second':
|
44 |
+
return $this->getDate('s');
|
45 |
+
case 'weekday':
|
46 |
+
return $this->getDate('w');
|
47 |
}
|
48 |
return null;
|
49 |
}
|
@@ -1,24 +1,10 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Info extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
|
|
24 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Os2_Data_Info extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
8 |
{
|
9 |
+
const INFO = true;
|
10 |
}
|
@@ -1,85 +1,85 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Product extends Owebia_Shipping2_Model_Os2_Data_AbstractWithAttributes
|
23 |
{
|
24 |
protected $_categories;
|
25 |
-
protected $
|
26 |
-
protected $
|
27 |
-
|
28 |
protected function _loadObject()
|
29 |
{
|
30 |
-
return Mage::getModel('catalog/product')->load($this->id);
|
31 |
}
|
32 |
|
33 |
-
protected function
|
34 |
{
|
35 |
-
$elems = explode('.', $name, $limit=2);
|
36 |
-
$count = count($elems);
|
37 |
-
$last_index = $count-1;
|
38 |
-
if ($count==2) {
|
39 |
-
switch ($elems[0]) {
|
40 |
-
case 'attribute_set':
|
41 |
-
return $this->getAttributeSet()->{$elems[1]};
|
42 |
-
case 'stock':
|
43 |
-
return $this->_getStockItem()->{$elems[1]};
|
44 |
-
case 'category':
|
45 |
-
$category = $this->_getCategory();
|
46 |
-
return $category ? $category->{$elems[1]} : null;
|
47 |
-
}
|
48 |
-
}
|
49 |
switch ($name) {
|
50 |
-
case 'attribute_set':
|
|
|
51 |
case 'category': // Compatibility
|
52 |
$category = $this->_getCategory();
|
53 |
-
return $category ? $category->name : null;
|
54 |
case 'categories': // Compatibility
|
55 |
$categories = $this->getCategories();
|
56 |
$output = array();
|
57 |
foreach ($categories as $category) {
|
58 |
-
$output[] = $category->name;
|
59 |
}
|
60 |
return $output;
|
61 |
case 'categories.id': // Compatibility
|
62 |
$categories = $this->getCategories();
|
63 |
$output = array();
|
64 |
foreach ($categories as $category) {
|
65 |
-
$output[] = $category->id;
|
66 |
}
|
67 |
return $output;
|
68 |
-
default:
|
|
|
69 |
}
|
70 |
}
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
public function getAttributeSet()
|
73 |
{
|
74 |
-
if (isset($this->
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
|
78 |
protected function _getStockItem()
|
79 |
{
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
|
|
83 |
}
|
84 |
|
85 |
protected function _getCategory()
|
@@ -100,27 +100,18 @@ class Owebia_Shipping2_Model_Os2_Data_Product extends Owebia_Shipping2_Model_Os2
|
|
100 |
return $this->_categories;
|
101 |
}
|
102 |
|
103 |
-
protected function _getAttribute($
|
104 |
{
|
105 |
-
switch ($
|
106 |
-
case 'weight':
|
107 |
-
|
|
|
|
|
108 |
}
|
109 |
}
|
110 |
|
111 |
-
/*public function _getAttribute($attribute_name)
|
112 |
-
{
|
113 |
-
return parent::_getAttribute($attribute_name);
|
114 |
-
|
115 |
-
// Dynamic weight for bundle product
|
116 |
-
if ($this->type=='bundle' && $attribute_name=='weight' && $product->getData('weight_type')==0) {
|
117 |
-
// !!! Use cart_product and not product
|
118 |
-
return $this->cart_product->getTypeInstance(true)->getWeight($this->cart_product);
|
119 |
-
}
|
120 |
-
}*/
|
121 |
-
|
122 |
public function __toString()
|
123 |
{
|
124 |
-
return $this->name.' (id:'
|
125 |
}
|
126 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Os2_Data_Product extends Owebia_Shipping2_Model_Os2_Data_AbstractWithAttributes
|
8 |
{
|
9 |
protected $_categories;
|
10 |
+
protected $_attributeSet;
|
11 |
+
protected $_stockItem;
|
12 |
+
|
13 |
protected function _loadObject()
|
14 |
{
|
15 |
+
return Mage::getModel('catalog/product')->load($this->getData('id'));
|
16 |
}
|
17 |
|
18 |
+
protected function _loadDefault($name)
|
19 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
switch ($name) {
|
21 |
+
case 'attribute_set':
|
22 |
+
return $this->getAttributeSet()->getData('name'); // Compatibility
|
23 |
case 'category': // Compatibility
|
24 |
$category = $this->_getCategory();
|
25 |
+
return $category ? $category->getData('name') : null;
|
26 |
case 'categories': // Compatibility
|
27 |
$categories = $this->getCategories();
|
28 |
$output = array();
|
29 |
foreach ($categories as $category) {
|
30 |
+
$output[] = $category->getData('name');
|
31 |
}
|
32 |
return $output;
|
33 |
case 'categories.id': // Compatibility
|
34 |
$categories = $this->getCategories();
|
35 |
$output = array();
|
36 |
foreach ($categories as $category) {
|
37 |
+
$output[] = $category->getData('id');
|
38 |
}
|
39 |
return $output;
|
40 |
+
default:
|
41 |
+
return parent::_load($name);
|
42 |
}
|
43 |
}
|
44 |
|
45 |
+
protected function _load($name)
|
46 |
+
{
|
47 |
+
$elems = explode('.', $name, $limit = 2);
|
48 |
+
$count = count($elems);
|
49 |
+
if ($count == 2) {
|
50 |
+
switch ($elems[0]) {
|
51 |
+
case 'attribute_set':
|
52 |
+
return $this->getAttributeSet()->getData($elems[1]);
|
53 |
+
case 'stock':
|
54 |
+
return $this->_getStockItem()->getData($elems[1]);
|
55 |
+
case 'category':
|
56 |
+
$category = $this->_getCategory();
|
57 |
+
return $category ? $category->getData($elems[1]) : null;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
return $this->_loadDefault($name);
|
61 |
+
}
|
62 |
+
|
63 |
public function getAttributeSet()
|
64 |
{
|
65 |
+
if (isset($this->_attributeSet)) {
|
66 |
+
return $this->_attributeSet;
|
67 |
+
}
|
68 |
+
return $this->_attributeSet = Mage::getModel(
|
69 |
+
'owebia_shipping2/Os2_Data_AttributeSet',
|
70 |
+
array('id' => (int)$this->getData('attribute_set_id'))
|
71 |
+
);
|
72 |
}
|
73 |
|
74 |
protected function _getStockItem()
|
75 |
{
|
76 |
+
if (isset($this->_stockItem)) {
|
77 |
+
return $this->_stockItem;
|
78 |
+
}
|
79 |
+
return $this->_stockItem = Mage::getModel(
|
80 |
+
'owebia_shipping2/Os2_Data_StockItem',
|
81 |
+
array('product_id' => (int)$this->getData('id'))
|
82 |
+
);
|
83 |
}
|
84 |
|
85 |
protected function _getCategory()
|
100 |
return $this->_categories;
|
101 |
}
|
102 |
|
103 |
+
protected function _getAttribute($attributeName)
|
104 |
{
|
105 |
+
switch ($attributeName) {
|
106 |
+
case 'weight':
|
107 |
+
return (double)parent::_getAttribute($attributeName);
|
108 |
+
default:
|
109 |
+
return parent::_getAttribute($attributeName);
|
110 |
}
|
111 |
}
|
112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
public function __toString()
|
114 |
{
|
115 |
+
return $this->getData('name') . ' (id:' . $this->getData('id') . ', sku:' . $this->getData('sku') . ')';
|
116 |
}
|
117 |
}
|
@@ -1,38 +1,25 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Quote extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
-
protected $
|
|
|
|
|
|
|
25 |
|
26 |
protected function _loadObject()
|
27 |
{
|
28 |
-
// Backend
|
29 |
if (Mage::app()->getStore()->isAdmin()) {
|
|
|
30 |
$sessionQuote = Mage::getSingleton('adminhtml/session_quote');
|
31 |
if (!$sessionQuote->getQuoteId()) return; // Avoid infinite loop
|
32 |
$quote = $sessionQuote->getQuote();
|
33 |
-
}
|
34 |
-
|
35 |
-
else {
|
36 |
$session = Mage::getSingleton('checkout/session');
|
37 |
if (!$session->getQuoteId()) return; // Avoid infinite loop
|
38 |
$quote = $session->getQuote();
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Os2_Data_Quote extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
8 |
{
|
9 |
+
protected $_additionalAttributes = array(
|
10 |
+
'subtotal', 'subtotal_with_discount', 'grand_total', 'base_subtotal',
|
11 |
+
'base_subtotal_with_discount', 'base_grand_total', '*',
|
12 |
+
);
|
13 |
|
14 |
protected function _loadObject()
|
15 |
{
|
|
|
16 |
if (Mage::app()->getStore()->isAdmin()) {
|
17 |
+
// Backend
|
18 |
$sessionQuote = Mage::getSingleton('adminhtml/session_quote');
|
19 |
if (!$sessionQuote->getQuoteId()) return; // Avoid infinite loop
|
20 |
$quote = $sessionQuote->getQuote();
|
21 |
+
} else {
|
22 |
+
// Frontend
|
|
|
23 |
$session = Mage::getSingleton('checkout/session');
|
24 |
if (!$session->getQuoteId()) return; // Avoid infinite loop
|
25 |
$quote = $session->getQuote();
|
@@ -1,23 +1,8 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Selection extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Os2_Data_Selection extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
8 |
{
|
@@ -1,39 +1,26 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_StockItem extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
protected function _loadObject()
|
25 |
{
|
26 |
-
return Mage::getModel('cataloginventory/stock_item')->loadByProduct($this->product_id);
|
27 |
}
|
28 |
|
29 |
protected function _load($name)
|
30 |
{
|
31 |
switch ($name) {
|
32 |
-
case 'is_in_stock':
|
|
|
33 |
case 'qty':
|
34 |
$qty = parent::_load($name);
|
35 |
-
return $this->is_qty_decimal ? (float)$qty : (int)$qty;
|
36 |
-
default:
|
|
|
37 |
}
|
38 |
}
|
39 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Os2_Data_StockItem extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
8 |
{
|
9 |
protected function _loadObject()
|
10 |
{
|
11 |
+
return Mage::getModel('cataloginventory/stock_item')->loadByProduct($this->getData('product_id'));
|
12 |
}
|
13 |
|
14 |
protected function _load($name)
|
15 |
{
|
16 |
switch ($name) {
|
17 |
+
case 'is_in_stock':
|
18 |
+
return (bool)parent::_load($name);
|
19 |
case 'qty':
|
20 |
$qty = parent::_load($name);
|
21 |
+
return $this->getData('is_qty_decimal') ? (float)$qty : (int)$qty;
|
22 |
+
default:
|
23 |
+
return parent::_load($name);
|
24 |
}
|
25 |
}
|
26 |
}
|
@@ -1,27 +1,12 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Model_Os2_Data_Store extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
23 |
{
|
24 |
-
|
25 |
|
26 |
public function __construct($arguments=null)
|
27 |
{
|
@@ -45,7 +30,7 @@ class Owebia_Shipping2_Model_Os2_Data_Store extends Owebia_Shipping2_Model_Os2_D
|
|
45 |
case 'name':
|
46 |
case 'address':
|
47 |
case 'phone':
|
48 |
-
return $this->_store->getConfig('general/store_information/'
|
49 |
}
|
50 |
return null;
|
51 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Model_Os2_Data_Store extends Owebia_Shipping2_Model_Os2_Data_Abstract
|
8 |
{
|
9 |
+
protected $_store;
|
10 |
|
11 |
public function __construct($arguments=null)
|
12 |
{
|
30 |
case 'name':
|
31 |
case 'address':
|
32 |
case 'phone':
|
33 |
+
return $this->_store->getConfig('general/store_information/' . $name);
|
34 |
}
|
35 |
return null;
|
36 |
}
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Owebia_Shipping2_Model_Os2_Message
|
8 |
+
{
|
9 |
+
public $type;
|
10 |
+
public $message;
|
11 |
+
public $args;
|
12 |
+
|
13 |
+
public function setType($type)
|
14 |
+
{
|
15 |
+
$this->type = $type;
|
16 |
+
return $this;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function setMessage($message)
|
20 |
+
{
|
21 |
+
$this->message = $message;
|
22 |
+
return $this;
|
23 |
+
}
|
24 |
+
|
25 |
+
public function setArgs($args)
|
26 |
+
{
|
27 |
+
$this->args = $args;
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function __toString()
|
32 |
+
{
|
33 |
+
return vsprintf($this->message, $this->args);
|
34 |
+
}
|
35 |
+
}
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class Owebia_Shipping2_Model_Os2_Result
|
8 |
+
{
|
9 |
+
protected $_configParser;
|
10 |
+
public $success;
|
11 |
+
public $result;
|
12 |
+
|
13 |
+
public function setConfigParser($configParser)
|
14 |
+
{
|
15 |
+
$this->_configParser = $configParser;
|
16 |
+
return $this;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function setSuccess($success)
|
20 |
+
{
|
21 |
+
$this->success = $success;
|
22 |
+
return $this;
|
23 |
+
}
|
24 |
+
|
25 |
+
public function setResult($result)
|
26 |
+
{
|
27 |
+
$this->result = $result;
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function __toString()
|
32 |
+
{
|
33 |
+
return $this->_configParser->toString($this->result);
|
34 |
+
}
|
35 |
+
}
|
@@ -1,26 +1,15 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
-
class Owebia_Shipping2_Model_System_Config_Source_LoadOnParent
|
|
|
23 |
{
|
|
|
|
|
|
|
24 |
public function toOptionArray($addEmpty = true)
|
25 |
{
|
26 |
$options = array(
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
class Owebia_Shipping2_Model_System_Config_Source_LoadOnParent
|
8 |
+
extends Mage_Adminhtml_Model_System_Config_Source_Category
|
9 |
{
|
10 |
+
/**
|
11 |
+
* {@inheritdoc}
|
12 |
+
*/
|
13 |
public function toOptionArray($addEmpty = true)
|
14 |
{
|
15 |
$options = array(
|
@@ -1,26 +1,15 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
-
class Owebia_Shipping2_Model_System_Config_Source_ProcessChildren
|
|
|
23 |
{
|
|
|
|
|
|
|
24 |
public function toOptionArray($addEmpty = true)
|
25 |
{
|
26 |
$options = array(
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
class Owebia_Shipping2_Model_System_Config_Source_ProcessChildren
|
8 |
+
extends Mage_Adminhtml_Model_System_Config_Source_Category
|
9 |
{
|
10 |
+
/**
|
11 |
+
* {@inheritdoc}
|
12 |
+
*/
|
13 |
public function toOptionArray($addEmpty = true)
|
14 |
{
|
15 |
$options = array(
|
@@ -1,3 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
1 |
[2.5.24 - September 07, 2016]
|
2 |
Update documentation
|
3 |
|
1 |
+
[2.6.0 - October 24, 2016]
|
2 |
+
Refactor code to comply to Magento coding standards
|
3 |
+
Remove compress functionality
|
4 |
+
Only one carrier available for new installations
|
5 |
+
|
6 |
[2.5.24 - September 07, 2016]
|
7 |
Update documentation
|
8 |
|
@@ -1,198 +1,258 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
|
22 |
class Owebia_Shipping2_Adminhtml_Os2_AjaxController extends Owebia_Shipping2_Controller_Abstract
|
23 |
{
|
24 |
-
protected function
|
25 |
{
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
return $helper;
|
30 |
}
|
31 |
-
|
32 |
protected function _getEditor($data)
|
33 |
{
|
34 |
-
$
|
35 |
-
$
|
36 |
-
$config = $
|
37 |
-
$block = $this->getLayout()->createBlock(
|
38 |
-
|
|
|
|
|
|
|
|
|
39 |
}
|
40 |
|
41 |
protected function _getCorrection($config, $compress = false, $html = false)
|
42 |
{
|
43 |
-
$
|
44 |
-
return $
|
45 |
}
|
46 |
-
|
47 |
-
protected function _processHelp($
|
48 |
{
|
49 |
-
$block = $this->getLayout()->createBlock(
|
50 |
-
'
|
51 |
-
'
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
55 |
return $block->getHtml();
|
56 |
}
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
{
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
case '
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
."</div>"
|
75 |
-
;
|
76 |
-
$layout_content['west'] = "<div class=ui-layout-north><h4 class=os2-section-title>{$this->__('Editor')}</h4></div><div id=os2-editor class=ui-layout-center></div>";
|
77 |
-
$layout_content['center'] = "<div class=ui-layout-north><h4 class=os2-section-title>{$this->__('Source')}</h4></div><textarea id=os2-source class=ui-layout-center></textarea>";
|
78 |
-
$layout_content['east'] = "<div class=ui-layout-north><h4 class=os2-section-title>{$this->__('Correction')}</h4></div><div id=os2-correction class=ui-layout-center></div>";
|
79 |
-
$layout_content['south'] = "<div class=ui-layout-north><h4 class=os2-section-title>{$this->__('Debug')}</h4></div><div id=os2-debug class=ui-layout-center></div>";
|
80 |
-
break;
|
81 |
-
case 'help':
|
82 |
-
$output = $this->__('{os2editor.help.'.$_POST['input'].'}');
|
83 |
-
$layout_content['center'] = $this->_processHelp($_POST['input'], $output);
|
84 |
-
break;
|
85 |
-
case 'donate':
|
86 |
-
$layout_content['center'] = "<div class=\"ui-layout-north os2-help-header\"><h4>".$this->__('You appreciate this extension and would like to help?')."</h4></div>"
|
87 |
-
."<div id=os2-help class=ui-layout-center>".$this->__('{os2editor.donate-page.content}')."</div>";
|
88 |
-
break;
|
89 |
-
}
|
90 |
-
echo $this->page($page, $layout_content, $with_dialog);
|
91 |
-
exit;
|
92 |
-
case 'correction':
|
93 |
-
$helper = $this->_getOs2Helper($_POST['source']);
|
94 |
-
$helper->checkConfig();
|
95 |
-
echo json_encode(array(
|
96 |
-
'correction' => $helper->formatConfig($compress = false, $keys_to_remove = array('*id'), $html = true),
|
97 |
-
'debug' => $helper->getDebug(),
|
98 |
-
'editor' => $this->_getEditor($_POST),
|
99 |
-
));
|
100 |
-
exit;
|
101 |
-
case 'property-tools':
|
102 |
-
$block = $this->getLayout()->createBlock('owebia_shipping2/adminhtml_os2_editor');
|
103 |
-
echo $block->getPropertyTools($this, $_POST['property']);
|
104 |
-
exit;
|
105 |
-
case 'update-property':
|
106 |
-
$helper = $this->_getOs2Helper($_POST['source']);
|
107 |
-
$config = $helper->getConfig();
|
108 |
-
$row_id = $_POST['row'];
|
109 |
-
$property = $_POST['property'];
|
110 |
-
$value = $_POST['value'];
|
111 |
-
if ($property==='type' && $value=='method' || $property==='enabled' && $value=='1' || $property!=='enabled' && empty($value)) {
|
112 |
-
unset($config[$row_id][$property]);
|
113 |
-
} else if ($property==='enabled') {
|
114 |
-
$config[$row_id][$property]['value'] = (bool)$value;
|
115 |
-
} else {
|
116 |
-
$config[$row_id][$property]['value'] = $value;
|
117 |
-
}
|
118 |
-
if ($property=='*id' && $value!=$row_id) {
|
119 |
-
$config[$value] = $config[$row_id];
|
120 |
-
unset($config[$row_id]);
|
121 |
-
}
|
122 |
-
$helper->setConfig($config);
|
123 |
-
echo json_encode(array(
|
124 |
-
'source' => $helper->formatConfig($compress = false, $keys_to_remove = array('*id'), $html = false),
|
125 |
-
));
|
126 |
-
exit;
|
127 |
-
case 'add-row':
|
128 |
-
$helper = $this->_getOs2Helper($_POST['source']);
|
129 |
-
$row = array('label' => array('value' => $this->__('New shipping method')), 'fees' => array('value' => 0)); // By reference
|
130 |
-
$helper->addRow('new'.time(), $row);
|
131 |
-
echo json_encode(array(
|
132 |
-
'source' => $helper->formatConfig($compress = false, $keys_to_remove = array('*id'), $html = false),
|
133 |
-
));
|
134 |
-
exit;
|
135 |
-
case 'remove-row':
|
136 |
-
$helper = $this->_getOs2Helper($_POST['source']);
|
137 |
-
$config = $helper->getConfig();
|
138 |
-
unset($config[$_POST['id']]);
|
139 |
-
$helper->setConfig($config);
|
140 |
-
echo json_encode(array(
|
141 |
-
'source' => $helper->formatConfig($compress = false, $keys_to_remove = array('*id'), $html = false),
|
142 |
-
));
|
143 |
-
exit;
|
144 |
-
case 'row-ui':
|
145 |
-
$helper = $this->_getOs2Helper($_POST['source']);
|
146 |
-
$row = $helper->getConfigRow($_POST['id']);
|
147 |
-
$block = $this->getLayout()->createBlock('owebia_shipping2/adminhtml_os2_editor');
|
148 |
-
echo $block->getRowUI($row, true);
|
149 |
-
exit;
|
150 |
-
case 'readable-selection':
|
151 |
-
switch ($_POST['property']) {
|
152 |
-
case 'shipto':
|
153 |
-
case 'billto':
|
154 |
-
case 'origin':
|
155 |
-
echo Mage::getModel('owebia_shipping2/Os2_Data_AddressFilter')->readable($_POST['input']);
|
156 |
-
break;
|
157 |
-
case 'customer_groups':
|
158 |
-
echo Mage::getModel('owebia_shipping2/Os2_Data_CustomerGroup')->readable($_POST['input']);
|
159 |
-
break;
|
160 |
-
}
|
161 |
-
exit;
|
162 |
-
case 'save-config':
|
163 |
-
$compress = (bool)Mage::getStoreConfig('carriers/'.$_POST['shipping_code'].'/compression');
|
164 |
-
$config = $compress ? $this->_getCorrection($_POST['source'], $compress) : $_POST['source'];
|
165 |
-
//Mage::getConfig()->saveConfig('carriers/'.$_POST['shipping_code'].'/config',$output);
|
166 |
-
echo $config;
|
167 |
-
exit;
|
168 |
-
case 'save-to-file':
|
169 |
-
$config = $_POST['source'];
|
170 |
-
$this->forceDownload('owebia-shipping-config.txt', $config);
|
171 |
-
exit;
|
172 |
}
|
|
|
|
|
173 |
|
174 |
-
|
175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
}
|
177 |
|
178 |
-
|
179 |
{
|
180 |
-
|
181 |
-
|
182 |
-
$
|
183 |
-
$
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
}
|
195 |
-
|
196 |
-
|
197 |
}
|
198 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
5 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class Owebia_Shipping2_Adminhtml_Os2_AjaxController extends Owebia_Shipping2_Controller_Abstract
|
8 |
{
|
9 |
+
protected function getParser($config, $autocorrection = true)
|
10 |
{
|
11 |
+
$parser = Mage::getModel('owebia_shipping2/ConfigParser')
|
12 |
+
->init($config, $autocorrection);
|
13 |
+
return $parser;
|
|
|
14 |
}
|
15 |
+
|
16 |
protected function _getEditor($data)
|
17 |
{
|
18 |
+
$parser = $this->getParser($data['source'], $autocorrection = true);
|
19 |
+
$parser->checkConfig();
|
20 |
+
$config = $parser->getConfig();
|
21 |
+
$block = $this->getLayout()->createBlock(
|
22 |
+
'owebia_shipping2/adminhtml_os2_editor',
|
23 |
+
'os2_editor',
|
24 |
+
array('config' => $config, 'opened_row_ids' => isset($data['row_ids']) ? $data['row_ids'] : array())
|
25 |
+
);
|
26 |
+
return $block->getHtml();
|
27 |
}
|
28 |
|
29 |
protected function _getCorrection($config, $compress = false, $html = false)
|
30 |
{
|
31 |
+
$parser = $this->getParser($config);
|
32 |
+
return $parser->formatConfig($compress, $keysToRemove = array('*id'), $html);
|
33 |
}
|
34 |
+
|
35 |
+
protected function _processHelp($helpId, $content)
|
36 |
{
|
37 |
+
$block = $this->getLayout()->createBlock(
|
38 |
+
'owebia_shipping2/adminhtml_os2_help',
|
39 |
+
'os2_help',
|
40 |
+
array(
|
41 |
+
'controller' => $this,
|
42 |
+
'help_id' => $helpId,
|
43 |
+
'content' => $content,
|
44 |
+
'helper' => $this->getParser(''),
|
45 |
+
)
|
46 |
+
);
|
47 |
return $block->getHtml();
|
48 |
}
|
49 |
+
|
50 |
+
protected function ajaxPage()
|
51 |
+
{
|
52 |
+
$request = $this->getRequest();
|
53 |
+
$withDialog = (bool)$request->getPost('with_dialog');
|
54 |
+
$page = $request->getPost('page');
|
55 |
+
$layoutContent = array();
|
56 |
+
switch ($page) {
|
57 |
+
case 'source':
|
58 |
+
$layoutContent['north'] = "<div class=\"os2-page-header ui-layout-center\">"
|
59 |
+
. $this->button__('Apply', "os2editor.save();", 'save')
|
60 |
+
. $this->button__('Export', "os2editor.saveToFile();", '')
|
61 |
+
. $this->button__('Add a shipping method', "os2editor.addRow();", 'add')
|
62 |
+
. "</div>"
|
63 |
+
;
|
64 |
+
$layoutContent['west'] = "<div class=ui-layout-north>"
|
65 |
+
. "<h4 class=os2-section-title>{$this->__('Editor')}</h4>"
|
66 |
+
. "</div><div id=os2-editor class=ui-layout-center></div>";
|
67 |
+
$layoutContent['center'] = "<div class=ui-layout-north>"
|
68 |
+
. "<h4 class=os2-section-title>{$this->__('Source')}</h4>"
|
69 |
+
. "</div><textarea id=os2-source class=ui-layout-center></textarea>";
|
70 |
+
$layoutContent['east'] = "<div class=ui-layout-north>"
|
71 |
+
. "<h4 class=os2-section-title>{$this->__('Correction')}</h4>"
|
72 |
+
. "</div><div id=os2-correction class=ui-layout-center></div>";
|
73 |
+
$layoutContent['south'] = "<div class=ui-layout-north>"
|
74 |
+
. "<h4 class=os2-section-title>{$this->__('Debug')}</h4>"
|
75 |
+
. "</div><div id=os2-debug class=ui-layout-center></div>";
|
76 |
+
break;
|
77 |
+
case 'help':
|
78 |
+
$output = $this->__('{os2editor.help.' . $request->getPost('input') . '}');
|
79 |
+
$layoutContent['center'] = $this->_processHelp($request->getPost('input'), $output);
|
80 |
+
break;
|
81 |
+
}
|
82 |
+
return $this->outputContent(
|
83 |
+
$this->page($page, $layoutContent, $withDialog)
|
84 |
+
);
|
85 |
+
}
|
86 |
+
|
87 |
+
protected function ajaxCorrection()
|
88 |
+
{
|
89 |
+
$request = $this->getRequest();
|
90 |
+
$parser = $this->getParser($request->getPost('source'));
|
91 |
+
$parser->checkConfig();
|
92 |
+
return $this->json(
|
93 |
+
array(
|
94 |
+
'correction' => $parser->formatConfig(
|
95 |
+
$compress = false,
|
96 |
+
$keysToRemove = array('*id'),
|
97 |
+
$html = true
|
98 |
+
),
|
99 |
+
'debug' => $parser->getDebug(),
|
100 |
+
'editor' => $this->_getEditor($request->getPost()),
|
101 |
+
)
|
102 |
+
);
|
103 |
+
}
|
104 |
+
|
105 |
+
protected function ajaxUpdateProperty()
|
106 |
+
{
|
107 |
+
$request = $this->getRequest();
|
108 |
+
$parser = $this->getParser($request->getPost('source'));
|
109 |
+
$config = $parser->getConfig();
|
110 |
+
$rowId = $request->getPost('row');
|
111 |
+
$property = $request->getPost('property');
|
112 |
+
$value = $request->getPost('value');
|
113 |
+
if ($property === 'type' && $value == 'method'
|
114 |
+
|| $property === 'enabled' && $value == '1'
|
115 |
+
|| $property !== 'enabled' && empty($value)
|
116 |
+
) {
|
117 |
+
unset($config[$rowId][$property]);
|
118 |
+
} else if ($property === 'enabled') {
|
119 |
+
$config[$rowId][$property]['value'] = (bool)$value;
|
120 |
+
} else {
|
121 |
+
$config[$rowId][$property]['value'] = $value;
|
122 |
+
}
|
123 |
+
if ($property == '*id' && $value != $rowId) {
|
124 |
+
$config[$value] = $config[$rowId];
|
125 |
+
unset($config[$rowId]);
|
126 |
+
}
|
127 |
+
$parser->setConfig($config);
|
128 |
+
return $this->json(
|
129 |
+
array(
|
130 |
+
'source' => $parser->formatConfig(
|
131 |
+
$compress = false,
|
132 |
+
$keysToRemove = array('*id'),
|
133 |
+
$html = false
|
134 |
+
),
|
135 |
+
)
|
136 |
+
);
|
137 |
+
}
|
138 |
+
|
139 |
+
protected function ajaxAddRow()
|
140 |
+
{
|
141 |
+
$request = $this->getRequest();
|
142 |
+
$parser = $this->getParser($request->getPost('source'));
|
143 |
+
$row = array(
|
144 |
+
'label' => array('value' => $this->__('New shipping method')),
|
145 |
+
'fees' => array('value' => 0),
|
146 |
+
); // By reference
|
147 |
+
$parser->addRow('new' . uniqid(), $row);
|
148 |
+
return $this->json(
|
149 |
+
array(
|
150 |
+
'source' => $parser->formatConfig(
|
151 |
+
$compress = false,
|
152 |
+
$keysToRemove = array('*id'),
|
153 |
+
$html = false
|
154 |
+
),
|
155 |
+
)
|
156 |
+
);
|
157 |
+
}
|
158 |
+
|
159 |
+
protected function ajaxRemoveRow()
|
160 |
+
{
|
161 |
+
$request = $this->getRequest();
|
162 |
+
$parser = $this->getParser($request->getPost('source'));
|
163 |
+
$config = $parser->getConfig();
|
164 |
+
unset($config[$request->getPost('id')]);
|
165 |
+
$parser->setConfig($config);
|
166 |
+
return $this->json(
|
167 |
+
array(
|
168 |
+
'source' => $parser->formatConfig(
|
169 |
+
$compress = false,
|
170 |
+
$keysToRemove = array('*id'),
|
171 |
+
$html = false
|
172 |
+
),
|
173 |
+
)
|
174 |
+
);
|
175 |
+
}
|
176 |
+
|
177 |
+
protected function ajaxReadableSelection()
|
178 |
{
|
179 |
+
$request = $this->getRequest();
|
180 |
+
switch ($request->getPost('property')) {
|
181 |
+
case 'shipto':
|
182 |
+
case 'billto':
|
183 |
+
case 'origin':
|
184 |
+
return $this->outputContent(
|
185 |
+
Mage::getModel('owebia_shipping2/Os2_Data_AddressFilter')
|
186 |
+
->readable($request->getPost('input'))
|
187 |
+
);
|
188 |
+
case 'customer_groups':
|
189 |
+
return $this->outputContent(
|
190 |
+
Mage::getModel('owebia_shipping2/Os2_Data_CustomerGroup')
|
191 |
+
->readable($request->getPost('input'))
|
192 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
}
|
194 |
+
return $this->outputContent('');
|
195 |
+
}
|
196 |
|
197 |
+
protected function ajaxSaveConfig()
|
198 |
+
{
|
199 |
+
$request = $this->getRequest();
|
200 |
+
$shippingCode = $request->getPost('shipping_code');
|
201 |
+
$config = $request->getPost('source');
|
202 |
+
return $this->outputContent($config);
|
203 |
+
}
|
204 |
+
|
205 |
+
protected function ajaxSaveToFile()
|
206 |
+
{
|
207 |
+
$request = $this->getRequest();
|
208 |
+
$config = $request->getPost('source');
|
209 |
+
return $this->forceDownload('owebia-shipping-config.txt', $config);
|
210 |
}
|
211 |
|
212 |
+
protected function ajaxRowUi()
|
213 |
{
|
214 |
+
$request = $this->getRequest();
|
215 |
+
$parser = $this->getParser($request->getPost('source'));
|
216 |
+
$row = $parser->getConfigRow($request->getPost('id'));
|
217 |
+
$block = $this->getLayout()->createBlock('owebia_shipping2/adminhtml_os2_editor');
|
218 |
+
return $this->outputContent(
|
219 |
+
$block->getRowUI($row, true)
|
220 |
+
);
|
221 |
+
}
|
222 |
+
|
223 |
+
protected function ajaxPropertyTools()
|
224 |
+
{
|
225 |
+
$request = $this->getRequest();
|
226 |
+
$block = $this->getLayout()->createBlock('owebia_shipping2/adminhtml_os2_editor');
|
227 |
+
return $this->outputContent(
|
228 |
+
$block->getPropertyTools($this, $request->getPost('property'))
|
229 |
+
);
|
230 |
+
}
|
231 |
+
|
232 |
+
public function indexAction()
|
233 |
+
{
|
234 |
+
$this->getResponse()
|
235 |
+
->setHeader('Content-Type', 'text/html; charset=UTF-8');
|
236 |
+
|
237 |
+
$request = $this->getRequest();
|
238 |
+
$map = array(
|
239 |
+
'page' => 'ajaxPage',
|
240 |
+
'correction' => 'ajaxCorrection',
|
241 |
+
'property-tools' => 'ajaxPropertyTools',
|
242 |
+
'update-property' => 'ajaxUpdateProperty',
|
243 |
+
'add-row' => 'ajaxAddRow',
|
244 |
+
'remove-row' => 'ajaxRemoveRow',
|
245 |
+
'row-ui' => 'ajaxRowUi',
|
246 |
+
'readable-selection' => 'ajaxReadableSelection',
|
247 |
+
'save-config' => 'ajaxSaveConfig',
|
248 |
+
'save-to-file' => 'ajaxSaveToFile',
|
249 |
+
);
|
250 |
+
$what = $request->getPost('what');
|
251 |
+
if (isset($map[$what])) {
|
252 |
+
$callback = $map[$what];
|
253 |
+
return $this->$callback();
|
254 |
}
|
255 |
+
|
256 |
+
return $this->outputContent('');
|
257 |
}
|
258 |
}
|
@@ -1,27 +1,14 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
*
|
5 |
-
*
|
6 |
-
* NOTICE OF LICENSE
|
7 |
-
*
|
8 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
-
* that is bundled with this package in the file LICENSE.txt.
|
10 |
-
* It is also available through the world-wide-web at this URL:
|
11 |
-
* http://opensource.org/licenses/osl-3.0.php
|
12 |
-
* If you did not receive a copy of the license and are unable to
|
13 |
-
* obtain it through the world-wide-web, please send an email
|
14 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
-
*
|
16 |
-
* DISCLAIMER
|
17 |
-
*
|
18 |
-
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
|
19 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
-
* @author Magento, Owebia
|
21 |
*/
|
22 |
|
23 |
-
if (file_exists(dirname(__FILE__).'
|
24 |
-
|
|
|
|
|
|
|
25 |
|
26 |
class Owebia_Shipping2_Checkout_CartController extends Mage_Checkout_CartController
|
27 |
{
|
@@ -43,7 +30,7 @@ class Owebia_Shipping2_Checkout_CartController extends Mage_Checkout_CartControl
|
|
43 |
->setRegionId($regionId)
|
44 |
->setRegion($region)
|
45 |
->setCollectShippingRates(true);
|
46 |
-
|
47 |
/*<owebia>*/
|
48 |
// Recalcul des totaux
|
49 |
$this->_getQuote()->collectTotals();
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
4 |
+
* See COPYING.txt for license details.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
*/
|
6 |
|
7 |
+
if (file_exists(dirname(__FILE__) . DS . 'Mage_Checkout_CartController.php')) {
|
8 |
+
require_once 'Mage_Checkout_CartController.php';
|
9 |
+
} else {
|
10 |
+
require_once Mage::getModuleDir('controllers', 'Mage_Checkout') . DS . 'CartController.php';
|
11 |
+
}
|
12 |
|
13 |
class Owebia_Shipping2_Checkout_CartController extends Mage_Checkout_CartController
|
14 |
{
|
30 |
->setRegionId($regionId)
|
31 |
->setRegion($region)
|
32 |
->setCollectShippingRates(true);
|
33 |
+
|
34 |
/*<owebia>*/
|
35 |
// Recalcul des totaux
|
36 |
$this->_getQuote()->collectTotals();
|
@@ -2,7 +2,7 @@
|
|
2 |
<html>
|
3 |
<head lang="fr">
|
4 |
<meta charset="utf-8"/>
|
5 |
-
<title>Documentation of Owebia Shipping 2.
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/css/bootstrap.min.css" rel="stylesheet">
|
8 |
<style>
|
@@ -114,7 +114,7 @@ pre.changelog{white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre
|
|
114 |
</div>
|
115 |
<div class="col-lg-9">
|
116 |
<!-- doc content start -->
|
117 |
-
<h1>Documentation of Owebia Shipping 2.
|
118 |
<div id="introduction">
|
119 |
<h2>Introduction</h2>
|
120 |
|
@@ -867,6 +867,11 @@ pre.changelog{white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre
|
|
867 |
<h2>Changelog</h2>
|
868 |
|
869 |
<pre class=changelog>
|
|
|
|
|
|
|
|
|
|
|
870 |
[2.5.24 - September 07, 2016]
|
871 |
Update documentation
|
872 |
|
2 |
<html>
|
3 |
<head lang="fr">
|
4 |
<meta charset="utf-8"/>
|
5 |
+
<title>Documentation of Owebia Shipping 2.6.0 extension for Magento</title>
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/css/bootstrap.min.css" rel="stylesheet">
|
8 |
<style>
|
114 |
</div>
|
115 |
<div class="col-lg-9">
|
116 |
<!-- doc content start -->
|
117 |
+
<h1>Documentation of Owebia Shipping 2.6.0 extension for Magento</h1>
|
118 |
<div id="introduction">
|
119 |
<h2>Introduction</h2>
|
120 |
|
867 |
<h2>Changelog</h2>
|
868 |
|
869 |
<pre class=changelog>
|
870 |
+
[2.6.0 - October 24, 2016]
|
871 |
+
Refactor code to comply to Magento coding standards
|
872 |
+
Remove compress functionality
|
873 |
+
Only one carrier available for new installations
|
874 |
+
|
875 |
[2.5.24 - September 07, 2016]
|
876 |
Update documentation
|
877 |
|
@@ -2,7 +2,7 @@
|
|
2 |
<html>
|
3 |
<head lang="fr">
|
4 |
<meta charset="utf-8"/>
|
5 |
-
<title>Documentation de l'extension Owebia Shipping 2.
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/css/bootstrap.min.css" rel="stylesheet">
|
8 |
<style>
|
@@ -114,7 +114,7 @@ pre.changelog{white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre
|
|
114 |
</div>
|
115 |
<div class="col-lg-9">
|
116 |
<!-- doc content start -->
|
117 |
-
<h1>Documentation de l'extension Owebia Shipping 2.
|
118 |
<div id="introduction">
|
119 |
<h2>Introduction</h2>
|
120 |
|
@@ -863,6 +863,11 @@ pre.changelog{white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre
|
|
863 |
<h2>Changelog</h2>
|
864 |
|
865 |
<pre class=changelog>
|
|
|
|
|
|
|
|
|
|
|
866 |
[2.5.24 - September 07, 2016]
|
867 |
Update documentation
|
868 |
|
2 |
<html>
|
3 |
<head lang="fr">
|
4 |
<meta charset="utf-8"/>
|
5 |
+
<title>Documentation de l'extension Owebia Shipping 2.6.0</title>
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/css/bootstrap.min.css" rel="stylesheet">
|
8 |
<style>
|
114 |
</div>
|
115 |
<div class="col-lg-9">
|
116 |
<!-- doc content start -->
|
117 |
+
<h1>Documentation de l'extension Owebia Shipping 2.6.0 pour Magento</h1>
|
118 |
<div id="introduction">
|
119 |
<h2>Introduction</h2>
|
120 |
|
863 |
<h2>Changelog</h2>
|
864 |
|
865 |
<pre class=changelog>
|
866 |
+
[2.6.0 - October 24, 2016]
|
867 |
+
Refactor code to comply to Magento coding standards
|
868 |
+
Remove compress functionality
|
869 |
+
Only one carrier available for new installations
|
870 |
+
|
871 |
[2.5.24 - September 07, 2016]
|
872 |
Update documentation
|
873 |
|
@@ -1,23 +1,9 @@
|
|
1 |
<?xml version="1.0" ?>
|
2 |
<!--
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
-->
|
22 |
<!-- Magento 1.4.0 and upper -->
|
23 |
<config>
|
1 |
<?xml version="1.0" ?>
|
2 |
<!--
|
3 |
/**
|
4 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
5 |
+
* See COPYING.txt for license details.
|
6 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
-->
|
8 |
<!-- Magento 1.4.0 and upper -->
|
9 |
<config>
|
@@ -1,28 +1,14 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<!--
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
-->
|
22 |
<config>
|
23 |
<modules>
|
24 |
<Owebia_Shipping2>
|
25 |
-
<version>2.
|
26 |
<depends>
|
27 |
<Mage_Shipping />
|
28 |
</depends>
|
@@ -49,21 +35,17 @@
|
|
49 |
<owebia_shipping2_setup>
|
50 |
<setup>
|
51 |
<module>Owebia_Shipping2</module>
|
52 |
-
<class>Owebia_Shipping2_Model_Mysql4_Setup</class>
|
53 |
</setup>
|
54 |
</owebia_shipping2_setup>
|
55 |
<sales>
|
56 |
<shipping>
|
57 |
<carriers>
|
58 |
-
<owebiashipping1>
|
59 |
-
<class>Owebia_Shipping2_Model_Carrier_OwebiaShipping1</class>
|
60 |
-
</owebiashipping1>
|
61 |
<owebiashipping2>
|
62 |
<class>Owebia_Shipping2_Model_Carrier_OwebiaShipping2</class>
|
63 |
</owebiashipping2>
|
64 |
-
<
|
65 |
-
<class>
|
66 |
-
</
|
67 |
</carriers>
|
68 |
</shipping>
|
69 |
</sales>
|
@@ -153,23 +135,6 @@
|
|
153 |
</configurable_product>
|
154 |
</owebia_shipping2>
|
155 |
<carriers>
|
156 |
-
<owebiashipping1>
|
157 |
-
<active>0</active>
|
158 |
-
<title>Owebia Shipping - Mode de livraison 1</title>
|
159 |
-
<model>Owebia_Shipping2_Model_Carrier_OwebiaShipping1</model>
|
160 |
-
<tracking_view_url></tracking_view_url>
|
161 |
-
<config>{
|
162 |
-
"demo": {
|
163 |
-
"label": "Frais de port fixes",
|
164 |
-
"fees": 10
|
165 |
-
}
|
166 |
-
}</config>
|
167 |
-
<debug>0</debug>
|
168 |
-
<auto_escaping>0</auto_escaping>
|
169 |
-
<auto_correction>1</auto_correction>
|
170 |
-
<stop_to_first_match>0</stop_to_first_match>
|
171 |
-
<sort_order>1</sort_order>
|
172 |
-
</owebiashipping1>
|
173 |
<owebiashipping2>
|
174 |
<active>0</active>
|
175 |
<title>Owebia Shipping - Mode de livraison 2</title>
|
@@ -177,23 +142,23 @@
|
|
177 |
<tracking_view_url></tracking_view_url>
|
178 |
<config></config>
|
179 |
<debug>0</debug>
|
180 |
-
<auto_escaping>
|
181 |
<auto_correction>1</auto_correction>
|
182 |
<stop_to_first_match>0</stop_to_first_match>
|
183 |
<sort_order>2</sort_order>
|
184 |
</owebiashipping2>
|
185 |
-
<
|
186 |
<active>0</active>
|
187 |
-
<title>
|
188 |
-
<model>
|
189 |
<tracking_view_url></tracking_view_url>
|
190 |
<config></config>
|
191 |
<debug>0</debug>
|
192 |
-
<auto_escaping>
|
193 |
<auto_correction>1</auto_correction>
|
194 |
<stop_to_first_match>0</stop_to_first_match>
|
195 |
-
<sort_order>
|
196 |
-
</
|
197 |
</carriers>
|
198 |
</default>
|
199 |
</config>
|
1 |
<?xml version="1.0"?>
|
2 |
<!--
|
3 |
/**
|
4 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
5 |
+
* See COPYING.txt for license details.
|
6 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
-->
|
8 |
<config>
|
9 |
<modules>
|
10 |
<Owebia_Shipping2>
|
11 |
+
<version>2.6.0</version>
|
12 |
<depends>
|
13 |
<Mage_Shipping />
|
14 |
</depends>
|
35 |
<owebia_shipping2_setup>
|
36 |
<setup>
|
37 |
<module>Owebia_Shipping2</module>
|
|
|
38 |
</setup>
|
39 |
</owebia_shipping2_setup>
|
40 |
<sales>
|
41 |
<shipping>
|
42 |
<carriers>
|
|
|
|
|
|
|
43 |
<owebiashipping2>
|
44 |
<class>Owebia_Shipping2_Model_Carrier_OwebiaShipping2</class>
|
45 |
</owebiashipping2>
|
46 |
+
<owebiashipping1>
|
47 |
+
<class>Owebia_Shipping2_Model_Carrier_OwebiaShipping1</class>
|
48 |
+
</owebiashipping1>
|
49 |
</carriers>
|
50 |
</shipping>
|
51 |
</sales>
|
135 |
</configurable_product>
|
136 |
</owebia_shipping2>
|
137 |
<carriers>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
<owebiashipping2>
|
139 |
<active>0</active>
|
140 |
<title>Owebia Shipping - Mode de livraison 2</title>
|
142 |
<tracking_view_url></tracking_view_url>
|
143 |
<config></config>
|
144 |
<debug>0</debug>
|
145 |
+
<auto_escaping>1</auto_escaping>
|
146 |
<auto_correction>1</auto_correction>
|
147 |
<stop_to_first_match>0</stop_to_first_match>
|
148 |
<sort_order>2</sort_order>
|
149 |
</owebiashipping2>
|
150 |
+
<owebiashipping1>
|
151 |
<active>0</active>
|
152 |
+
<title>Chronopost</title>
|
153 |
+
<model>Owebia_Shipping2_Model_Carrier_OwebiaShipping1</model>
|
154 |
<tracking_view_url></tracking_view_url>
|
155 |
<config></config>
|
156 |
<debug>0</debug>
|
157 |
+
<auto_escaping>1</auto_escaping>
|
158 |
<auto_correction>1</auto_correction>
|
159 |
<stop_to_first_match>0</stop_to_first_match>
|
160 |
+
<sort_order>1</sort_order>
|
161 |
+
</owebiashipping1>
|
162 |
</carriers>
|
163 |
</default>
|
164 |
</config>
|
@@ -1,23 +1,9 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<!--
|
3 |
/**
|
4 |
-
* Copyright
|
5 |
-
*
|
6 |
-
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
-->
|
22 |
<config>
|
23 |
<tabs>
|
@@ -30,115 +16,6 @@
|
|
30 |
<carriers>
|
31 |
<show_in_store>1</show_in_store>
|
32 |
<groups>
|
33 |
-
<owebiashipping1 translate="label" module="shipping">
|
34 |
-
<label>Owebia Shipping - Mode de livraison 1</label>
|
35 |
-
<frontend_type>text</frontend_type>
|
36 |
-
<sort_order>-19</sort_order>
|
37 |
-
<show_in_default>1</show_in_default>
|
38 |
-
<show_in_website>1</show_in_website>
|
39 |
-
<show_in_store>1</show_in_store>
|
40 |
-
<fields>
|
41 |
-
<informations translate="label">
|
42 |
-
<label>Informations</label>
|
43 |
-
<frontend_model>owebia_shipping2/adminhtml_system_config_form_field_informations</frontend_model>
|
44 |
-
<sort_order>0</sort_order>
|
45 |
-
<show_in_default>1</show_in_default>
|
46 |
-
<show_in_website>1</show_in_website>
|
47 |
-
<show_in_store>1</show_in_store>
|
48 |
-
</informations>
|
49 |
-
<active translate="label">
|
50 |
-
<label>Enabled</label>
|
51 |
-
<frontend_type>select</frontend_type>
|
52 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
53 |
-
<sort_order>1</sort_order>
|
54 |
-
<show_in_default>1</show_in_default>
|
55 |
-
<show_in_website>1</show_in_website>
|
56 |
-
<show_in_store>1</show_in_store>
|
57 |
-
</active>
|
58 |
-
<title translate="label">
|
59 |
-
<label>Title</label>
|
60 |
-
<frontend_type>text</frontend_type>
|
61 |
-
<sort_order>2</sort_order>
|
62 |
-
<show_in_default>1</show_in_default>
|
63 |
-
<show_in_website>1</show_in_website>
|
64 |
-
<show_in_store>1</show_in_store>
|
65 |
-
</title>
|
66 |
-
<config translate="label">
|
67 |
-
<label>Configuration</label>
|
68 |
-
<frontend_model>owebia_shipping2/adminhtml_system_config_form_field_config</frontend_model>
|
69 |
-
<frontend_type>textarea</frontend_type>
|
70 |
-
<sort_order>3</sort_order>
|
71 |
-
<show_in_default>1</show_in_default>
|
72 |
-
<show_in_website>1</show_in_website>
|
73 |
-
<show_in_store>1</show_in_store>
|
74 |
-
</config>
|
75 |
-
<tracking_view_url translate="label">
|
76 |
-
<label>Tracking URL</label>
|
77 |
-
<frontend_type>text</frontend_type>
|
78 |
-
<sort_order>4</sort_order>
|
79 |
-
<show_in_default>1</show_in_default>
|
80 |
-
<show_in_website>1</show_in_website>
|
81 |
-
<show_in_store>1</show_in_store>
|
82 |
-
</tracking_view_url>
|
83 |
-
<debug translate="label">
|
84 |
-
<label>Debug</label>
|
85 |
-
<frontend_type>select</frontend_type>
|
86 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
87 |
-
<comment>{debug_help}</comment>
|
88 |
-
<sort_order>5</sort_order>
|
89 |
-
<show_in_default>1</show_in_default>
|
90 |
-
<show_in_website>1</show_in_website>
|
91 |
-
<show_in_store>1</show_in_store>
|
92 |
-
</debug>
|
93 |
-
<compression translate="label">
|
94 |
-
<label>Compression</label>
|
95 |
-
<frontend_type>select</frontend_type>
|
96 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
97 |
-
<comment>{compression_help}</comment>
|
98 |
-
<sort_order>6</sort_order>
|
99 |
-
<show_in_default>1</show_in_default>
|
100 |
-
<show_in_website>1</show_in_website>
|
101 |
-
<show_in_store>1</show_in_store>
|
102 |
-
</compression>
|
103 |
-
<auto_escaping translate="label">
|
104 |
-
<label>Auto-escaping</label>
|
105 |
-
<frontend_type>select</frontend_type>
|
106 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
107 |
-
<comment>{auto_escaping_help}</comment>
|
108 |
-
<sort_order>7</sort_order>
|
109 |
-
<show_in_default>1</show_in_default>
|
110 |
-
<show_in_website>1</show_in_website>
|
111 |
-
<show_in_store>1</show_in_store>
|
112 |
-
</auto_escaping>
|
113 |
-
<auto_correction translate="label">
|
114 |
-
<label>Auto-correction</label>
|
115 |
-
<frontend_type>select</frontend_type>
|
116 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
117 |
-
<comment>{auto_correction_help}</comment>
|
118 |
-
<sort_order>8</sort_order>
|
119 |
-
<show_in_default>1</show_in_default>
|
120 |
-
<show_in_website>1</show_in_website>
|
121 |
-
<show_in_store>1</show_in_store>
|
122 |
-
</auto_correction>
|
123 |
-
<stop_to_first_match translate="label">
|
124 |
-
<label>Stop to first match</label>
|
125 |
-
<frontend_type>select</frontend_type>
|
126 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
127 |
-
<sort_order>9</sort_order>
|
128 |
-
<show_in_default>1</show_in_default>
|
129 |
-
<show_in_website>1</show_in_website>
|
130 |
-
<show_in_store>1</show_in_store>
|
131 |
-
</stop_to_first_match>
|
132 |
-
<sort_order translate="label">
|
133 |
-
<label>Sort order</label>
|
134 |
-
<frontend_type>text</frontend_type>
|
135 |
-
<sort_order>100</sort_order>
|
136 |
-
<show_in_default>1</show_in_default>
|
137 |
-
<show_in_website>1</show_in_website>
|
138 |
-
<show_in_store>1</show_in_store>
|
139 |
-
</sort_order>
|
140 |
-
</fields>
|
141 |
-
</owebiashipping1>
|
142 |
<owebiashipping2 translate="label" module="shipping">
|
143 |
<label>Owebia Shipping - Mode de livraison 2</label>
|
144 |
<frontend_type>text</frontend_type>
|
@@ -199,16 +76,6 @@
|
|
199 |
<show_in_website>1</show_in_website>
|
200 |
<show_in_store>1</show_in_store>
|
201 |
</debug>
|
202 |
-
<compression translate="label">
|
203 |
-
<label>Compression</label>
|
204 |
-
<frontend_type>select</frontend_type>
|
205 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
206 |
-
<comment>{compression_help}</comment>
|
207 |
-
<sort_order>6</sort_order>
|
208 |
-
<show_in_default>1</show_in_default>
|
209 |
-
<show_in_website>1</show_in_website>
|
210 |
-
<show_in_store>1</show_in_store>
|
211 |
-
</compression>
|
212 |
<auto_escaping translate="label">
|
213 |
<label>Auto-escaping</label>
|
214 |
<frontend_type>select</frontend_type>
|
@@ -248,10 +115,10 @@
|
|
248 |
</sort_order>
|
249 |
</fields>
|
250 |
</owebiashipping2>
|
251 |
-
<
|
252 |
-
<label>
|
253 |
<frontend_type>text</frontend_type>
|
254 |
-
<sort_order>-
|
255 |
<show_in_default>1</show_in_default>
|
256 |
<show_in_website>1</show_in_website>
|
257 |
<show_in_store>1</show_in_store>
|
@@ -308,16 +175,6 @@
|
|
308 |
<show_in_website>1</show_in_website>
|
309 |
<show_in_store>1</show_in_store>
|
310 |
</debug>
|
311 |
-
<compression translate="label">
|
312 |
-
<label>Compression</label>
|
313 |
-
<frontend_type>select</frontend_type>
|
314 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
315 |
-
<comment>{compression_help}</comment>
|
316 |
-
<sort_order>6</sort_order>
|
317 |
-
<show_in_default>1</show_in_default>
|
318 |
-
<show_in_website>1</show_in_website>
|
319 |
-
<show_in_store>1</show_in_store>
|
320 |
-
</compression>
|
321 |
<auto_escaping translate="label">
|
322 |
<label>Auto-escaping</label>
|
323 |
<frontend_type>select</frontend_type>
|
@@ -356,7 +213,7 @@
|
|
356 |
<show_in_store>1</show_in_store>
|
357 |
</sort_order>
|
358 |
</fields>
|
359 |
-
</
|
360 |
</groups>
|
361 |
</carriers>
|
362 |
</sections>
|
1 |
<?xml version="1.0"?>
|
2 |
<!--
|
3 |
/**
|
4 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
5 |
+
* See COPYING.txt for license details.
|
6 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
-->
|
8 |
<config>
|
9 |
<tabs>
|
16 |
<carriers>
|
17 |
<show_in_store>1</show_in_store>
|
18 |
<groups>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
<owebiashipping2 translate="label" module="shipping">
|
20 |
<label>Owebia Shipping - Mode de livraison 2</label>
|
21 |
<frontend_type>text</frontend_type>
|
76 |
<show_in_website>1</show_in_website>
|
77 |
<show_in_store>1</show_in_store>
|
78 |
</debug>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
<auto_escaping translate="label">
|
80 |
<label>Auto-escaping</label>
|
81 |
<frontend_type>select</frontend_type>
|
115 |
</sort_order>
|
116 |
</fields>
|
117 |
</owebiashipping2>
|
118 |
+
<owebiashipping1 translate="label" module="shipping">
|
119 |
+
<label>Chronopost</label>
|
120 |
<frontend_type>text</frontend_type>
|
121 |
+
<sort_order>-19</sort_order>
|
122 |
<show_in_default>1</show_in_default>
|
123 |
<show_in_website>1</show_in_website>
|
124 |
<show_in_store>1</show_in_store>
|
175 |
<show_in_website>1</show_in_website>
|
176 |
<show_in_store>1</show_in_store>
|
177 |
</debug>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
<auto_escaping translate="label">
|
179 |
<label>Auto-escaping</label>
|
180 |
<frontend_type>select</frontend_type>
|
213 |
<show_in_store>1</show_in_store>
|
214 |
</sort_order>
|
215 |
</fields>
|
216 |
+
</owebiashipping1>
|
217 |
</groups>
|
218 |
</carriers>
|
219 |
</sections>
|
@@ -1,148 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Copyright (c) 2008-14 Owebia
|
5 |
-
*
|
6 |
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
-
|
22 |
-
class OS2_AddressFilterParser
|
23 |
-
{
|
24 |
-
protected $input = null;
|
25 |
-
protected $position = null;
|
26 |
-
protected $buffer_start = null;
|
27 |
-
|
28 |
-
protected $output = '';
|
29 |
-
protected $level = null;
|
30 |
-
protected $parent_level = null;
|
31 |
-
protected $regexp = false;
|
32 |
-
protected $litteral = false;
|
33 |
-
protected $litteral_quote = null;
|
34 |
-
protected $case_insensitive = false;
|
35 |
-
|
36 |
-
public function parse($input) {
|
37 |
-
$this->current = array();
|
38 |
-
|
39 |
-
$this->input = $input;
|
40 |
-
$this->length = strlen($this->input);
|
41 |
-
// look at each character
|
42 |
-
$join = ' && ';
|
43 |
-
for ($this->position=0; $this->position < $this->length; $this->position++) {
|
44 |
-
$char = $this->input[$this->position];
|
45 |
-
switch ($char) {
|
46 |
-
case ')':
|
47 |
-
if ($this->regexp) break;
|
48 |
-
if ($this->litteral) break;
|
49 |
-
$this->push($this->buffer().')');
|
50 |
-
$this->parent_level = null;
|
51 |
-
break;
|
52 |
-
case ' ':
|
53 |
-
if ($this->regexp) break;
|
54 |
-
if ($this->litteral) break;
|
55 |
-
$this->push($this->buffer());
|
56 |
-
break;
|
57 |
-
case '-':
|
58 |
-
if ($this->regexp) break;
|
59 |
-
if ($this->litteral) break;
|
60 |
-
$this->push($this->buffer());
|
61 |
-
$join = ' && !';
|
62 |
-
break;
|
63 |
-
case ',':
|
64 |
-
if ($this->regexp) break;
|
65 |
-
if ($this->litteral) break;
|
66 |
-
$this->push($this->buffer());
|
67 |
-
$this->push(' || ');
|
68 |
-
break;
|
69 |
-
case '(':
|
70 |
-
if ($this->regexp) break;
|
71 |
-
if ($this->litteral) break;
|
72 |
-
$this->push($this->buffer());
|
73 |
-
$this->push($join, $only_if_not_empty = true);
|
74 |
-
$this->push('(');
|
75 |
-
$this->parent_level = $this->level;
|
76 |
-
$join = ' && ';
|
77 |
-
break;
|
78 |
-
case "'":
|
79 |
-
case '"':
|
80 |
-
if (!$this->litteral || $this->litteral_quote == $char) {
|
81 |
-
$this->litteral = !$this->litteral;
|
82 |
-
$this->litteral_quote = $char;
|
83 |
-
}
|
84 |
-
if ($this->buffer_start === null) {
|
85 |
-
$this->buffer_start = $this->position;
|
86 |
-
}
|
87 |
-
break;
|
88 |
-
case '/':
|
89 |
-
$this->regexp = !$this->regexp;
|
90 |
-
default:
|
91 |
-
if ($this->buffer_start === null) {
|
92 |
-
$this->buffer_start = $this->position;
|
93 |
-
}
|
94 |
-
}
|
95 |
-
}
|
96 |
-
$this->push($this->buffer());
|
97 |
-
return $this->output;
|
98 |
-
}
|
99 |
-
|
100 |
-
protected function escapeString($input)
|
101 |
-
{
|
102 |
-
return OwebiaShippingHelper::escapeString($input);
|
103 |
-
}
|
104 |
-
|
105 |
-
protected function buffer() {
|
106 |
-
if ($this->buffer_start !== null) {
|
107 |
-
// extract string from buffer start to current position
|
108 |
-
$buffer = substr($this->input, $this->buffer_start, $this->position - $this->buffer_start);
|
109 |
-
// clean buffer
|
110 |
-
$this->buffer_start = null;
|
111 |
-
// throw token into current scope
|
112 |
-
//var_export($buffer);echo "\n";
|
113 |
-
if ($buffer=='*') {
|
114 |
-
$buffer = 1;
|
115 |
-
} else if ($this->parent_level=='country') {
|
116 |
-
if (preg_match('/^[A-Z]{2}$/', $buffer)) {
|
117 |
-
$buffer = "{{c}}==={$this->escapeString($buffer)}";
|
118 |
-
$this->level = 'country';
|
119 |
-
} else if (substr($buffer, 0, 1)=='/' && (substr($buffer, strlen($buffer)-1, 1)=='/' || substr($buffer, strlen($buffer)-2, 2)=='/i')) {
|
120 |
-
$case_insensitive = substr($buffer, strlen($buffer)-2, 2)=='/i';
|
121 |
-
$buffer = "preg_match('".str_replace("'", "\\'", $buffer)."', (string)({{p}}))";
|
122 |
-
} else if (strpos($buffer, '*')!==false) {
|
123 |
-
$buffer = "preg_match('/^".str_replace(array("'", '*'), array("\\'", '(?:.*)'), $buffer)."$/', (string)({{p}}))";
|
124 |
-
} else if (preg_match('/^"[^"]+"$/', $buffer)) {
|
125 |
-
$buffer = trim($buffer, '"');
|
126 |
-
$buffer = "({{p}}==={$this->escapeString($buffer)} || {{r}}==={$this->escapeString($buffer)})";
|
127 |
-
} else if (preg_match('/^\'[^\']+\'$/', $buffer)) {
|
128 |
-
$buffer = trim($buffer, "'");
|
129 |
-
$buffer = "({{p}}==={$this->escapeString($buffer)} || {{r}}==={$this->escapeString($buffer)})";
|
130 |
-
} else {
|
131 |
-
$buffer = "({{p}}==={$this->escapeString($buffer)} || {{r}}==={$this->escapeString($buffer)})";
|
132 |
-
}
|
133 |
-
} else if (preg_match('/^[A-Z]{2}$/', $buffer)) {
|
134 |
-
$buffer = "{{c}}==={$this->escapeString($buffer)}";
|
135 |
-
$this->level = 'country';
|
136 |
-
}
|
137 |
-
return $buffer;
|
138 |
-
}
|
139 |
-
return null;
|
140 |
-
}
|
141 |
-
|
142 |
-
protected function push($text, $only_if_not_empty = false) {
|
143 |
-
if (isset($text)) {
|
144 |
-
if (!$only_if_not_empty || $this->output) $this->output .= $text;
|
145 |
-
//echo "\"$this->output\"<br/>";
|
146 |
-
}
|
147 |
-
}
|
148 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1,1467 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Copyright (c) 2008-14 Owebia
|
5 |
-
*
|
6 |
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
7 |
-
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 |
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9 |
-
*
|
10 |
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
13 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
14 |
-
* IN THE SOFTWARE.
|
15 |
-
*
|
16 |
-
* @website http://www.owebia.com/
|
17 |
-
* @project Magento Owebia Shipping 2 module
|
18 |
-
* @author Antoine Lemoine
|
19 |
-
* @license http://www.opensource.org/licenses/MIT The MIT License (MIT)
|
20 |
-
**/
|
21 |
-
|
22 |
-
// moved in app/code/community/Owebia/Shipping2/Model/Carrier/Abstract.php
|
23 |
-
//require_once dirname(__FILE__).'/OS2_AddressFilterParser.php';
|
24 |
-
|
25 |
-
class OwebiaShippingHelper
|
26 |
-
{
|
27 |
-
const FLOAT_REGEX = '[-]?\d+(?:[.]\d+)?';
|
28 |
-
const COUPLE_REGEX = '(?:[0-9.]+|\*) *(?:\[|\])? *\: *[0-9.]+';
|
29 |
-
|
30 |
-
public static $DEBUG_INDEX_COUNTER = 0;
|
31 |
-
public static $UNCOMPRESSED_STRINGS = array(
|
32 |
-
' product.attribute.',
|
33 |
-
' item.option.',
|
34 |
-
'{product.attribute.',
|
35 |
-
'{item.option.',
|
36 |
-
'{product.',
|
37 |
-
'{cart.',
|
38 |
-
'{selection.',
|
39 |
-
);
|
40 |
-
public static $COMPRESSED_STRINGS = array(
|
41 |
-
' p.a.',
|
42 |
-
' item.o.',
|
43 |
-
'{p.a.',
|
44 |
-
'{item.o.',
|
45 |
-
'{p.',
|
46 |
-
'{c.',
|
47 |
-
'{s.',
|
48 |
-
);
|
49 |
-
|
50 |
-
public static function esc($input)
|
51 |
-
{
|
52 |
-
$input = htmlspecialchars($input, ENT_NOQUOTES, 'UTF-8');
|
53 |
-
return preg_replace('/<(\/?)span([^&]*)>/', '<\1span\2>', $input);
|
54 |
-
}
|
55 |
-
|
56 |
-
public static function toString($value)
|
57 |
-
{
|
58 |
-
if (!isset($value)) return 'null';
|
59 |
-
else if (is_bool($value)) return $value ? 'true' : 'false';
|
60 |
-
else if (is_float($value)) return str_replace(',', '.', (string)$value); // To avoid locale problems
|
61 |
-
else if (is_array($value)) return 'array(size:'.count($value).')';
|
62 |
-
else if (is_object($value)) return get_class($value).'';
|
63 |
-
else return $value;
|
64 |
-
}
|
65 |
-
|
66 |
-
public static function parseSize($size)
|
67 |
-
{
|
68 |
-
$size = trim($size);
|
69 |
-
$last = strtolower($size[strlen($size)-1]);
|
70 |
-
switch ($last) {
|
71 |
-
case 'g': $size *= 1024;
|
72 |
-
case 'm': $size *= 1024;
|
73 |
-
case 'k': $size *= 1024;
|
74 |
-
}
|
75 |
-
return (float)$size;
|
76 |
-
}
|
77 |
-
|
78 |
-
public static function formatSize($size)
|
79 |
-
{
|
80 |
-
$unit = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
|
81 |
-
return self::toString(@round($size/pow(1024, ($i=floor(log($size, 1024)))), 2)).' '.$unit[$i];
|
82 |
-
}
|
83 |
-
|
84 |
-
public static function getInfos()
|
85 |
-
{
|
86 |
-
$properties = array(
|
87 |
-
'server_os' => PHP_OS,
|
88 |
-
'server_software' => $_SERVER['SERVER_SOFTWARE'],
|
89 |
-
'php_version' => PHP_VERSION,
|
90 |
-
'memory_limit' => self::formatSize(self::parseSize(ini_get('memory_limit'))),
|
91 |
-
'memory_usage' => self::formatSize(memory_get_usage(true)),
|
92 |
-
);
|
93 |
-
return $properties;
|
94 |
-
}
|
95 |
-
|
96 |
-
public static function getDefaultProcessData()
|
97 |
-
{
|
98 |
-
return array(
|
99 |
-
'info' => new OS2_Data(self::getInfos()),
|
100 |
-
'cart' => new OS2_Data(),
|
101 |
-
'quote' => new OS2_Data(),
|
102 |
-
'selection' => new OS2_Data(),
|
103 |
-
'customer' => new OS2_Data(),
|
104 |
-
'customer_group' => new OS2_Data(),
|
105 |
-
'customvar' => new OS2_Data(),
|
106 |
-
'date' => new OS2_Data(),
|
107 |
-
'origin' => new OS2_Data(),
|
108 |
-
'shipto' => new OS2_Data(),
|
109 |
-
'billto' => new OS2_Data(),
|
110 |
-
'store' => new OS2_Data(),
|
111 |
-
'request' => new OS2_Data(),
|
112 |
-
'address_filter' => new OS2_Data(),
|
113 |
-
);
|
114 |
-
}
|
115 |
-
|
116 |
-
public static function jsonEncode($data, $beautify = false, $html = false, $level = 0, $current_indent = '')
|
117 |
-
{
|
118 |
-
//$html = true;
|
119 |
-
$indent = "\t";//$html ? ' ' : "\t";//
|
120 |
-
$line_break = $html ? '<br/>' : "\n";
|
121 |
-
$new_indent = $current_indent.$indent;
|
122 |
-
switch ($type = gettype($data)) {
|
123 |
-
case 'NULL':
|
124 |
-
return ($html ? '<span class=json-reserved>' : '').'null'.($html ? '</span>' : '');
|
125 |
-
case 'boolean':
|
126 |
-
return ($html ? '<span class=json-reserved>' : '').($data ? 'true' : 'false').($html ? '</span>' : '');
|
127 |
-
case 'integer':
|
128 |
-
case 'double':
|
129 |
-
case 'float':
|
130 |
-
return ($html ? '<span class=json-numeric>' : '').$data.($html ? '</span>' : '');
|
131 |
-
case 'string':
|
132 |
-
return ($html ? '<span class=json-string>' : '').'"'.str_replace(array("\\", '"', "\n", "\r"), array("\\\\", '\"', "\\n", "\\r"), $html ? htmlspecialchars($data, ENT_COMPAT, 'UTF-8') : $data).'"'.($html ? '</span>' : '');
|
133 |
-
case 'object':
|
134 |
-
$data = (array)$data;
|
135 |
-
case 'array':
|
136 |
-
$output_index_count = 0;
|
137 |
-
$output = array();
|
138 |
-
foreach ($data as $key => $value) {
|
139 |
-
if ($output_index_count!==null && $output_index_count++!==$key) {
|
140 |
-
$output_index_count = null;
|
141 |
-
}
|
142 |
-
}
|
143 |
-
$is_associative = $output_index_count===null;
|
144 |
-
foreach ($data as $key => $value) {
|
145 |
-
if ($is_associative) {
|
146 |
-
$classes = array();
|
147 |
-
if ($key=='about') $classes[] = 'json-about';
|
148 |
-
if ($key=='conditions' || $key=='fees') $classes[] = 'json-formula';
|
149 |
-
$property_classes = array('json-property');
|
150 |
-
if ($level==0) $property_classes[] = 'json-id';
|
151 |
-
$output[] = ($html && $classes ? '<span class="'.implode(' ', $classes).'">' : '')
|
152 |
-
.($html ? '<span class="'.implode(' ', $property_classes).'">' : '')
|
153 |
-
.self::jsonEncode((string)$key)
|
154 |
-
.($html ? '</span>' : '').':'
|
155 |
-
.($beautify ? ' ' : '')
|
156 |
-
.self::jsonEncode($value, $beautify, $html, $level+1, $new_indent)
|
157 |
-
.($html && $classes ? '</span>' : '');
|
158 |
-
} else {
|
159 |
-
$output[] = self::jsonEncode($value, $beautify, $html, $level+1, $current_indent);
|
160 |
-
}
|
161 |
-
}
|
162 |
-
if ($is_associative) {
|
163 |
-
$classes = array();
|
164 |
-
if (isset($data['type']) && $data['type']=='meta') $classes[] = 'json-meta';
|
165 |
-
$output = ($html && $classes ? '<span class="'.implode(' ', $classes).'">' : '')
|
166 |
-
.'{'
|
167 |
-
.($beautify ? "{$line_break}{$new_indent}" : '')
|
168 |
-
.implode(','.($beautify ? "{$line_break}{$new_indent}" : ''), $output)
|
169 |
-
.($beautify ? "{$line_break}{$current_indent}" : '')
|
170 |
-
.'}'
|
171 |
-
.($html && $classes ? '</span>' : '');
|
172 |
-
//echo $output;
|
173 |
-
return $output;
|
174 |
-
} else {
|
175 |
-
return '['.implode(','.($beautify ? ' ' : ''), $output).']';
|
176 |
-
}
|
177 |
-
default:
|
178 |
-
return ''; // Not supported
|
179 |
-
}
|
180 |
-
}
|
181 |
-
|
182 |
-
protected static function json_decode($input)
|
183 |
-
{
|
184 |
-
if (function_exists('json_decode')) { // PHP >= 5.2.0
|
185 |
-
$output = json_decode($input);
|
186 |
-
if (function_exists('json_last_error')) { // PHP >= 5.3.0
|
187 |
-
$error = json_last_error();
|
188 |
-
if ($error!=JSON_ERROR_NONE) throw new Exception($error);
|
189 |
-
}
|
190 |
-
return $output;
|
191 |
-
} else {
|
192 |
-
return Zend_Json::decode($input);
|
193 |
-
}
|
194 |
-
}
|
195 |
-
|
196 |
-
protected static function json_encode($input)
|
197 |
-
{
|
198 |
-
if (function_exists('json_encode')) {
|
199 |
-
return json_encode($input);
|
200 |
-
} else {
|
201 |
-
return Zend_Json::encode($input);
|
202 |
-
}
|
203 |
-
}
|
204 |
-
|
205 |
-
public static function escapeString($input)
|
206 |
-
{
|
207 |
-
$escaped = self::json_encode($input);
|
208 |
-
$escaped = preg_replace_callback('/\\\\u([0-9a-fA-F]{4})/', function ($match) {
|
209 |
-
return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
|
210 |
-
}, $escaped);
|
211 |
-
return $escaped;
|
212 |
-
}
|
213 |
-
|
214 |
-
protected $_input;
|
215 |
-
protected $_config = array();
|
216 |
-
protected $_messages = array();
|
217 |
-
protected $_formula_cache = array();
|
218 |
-
protected $_expression_cache = array();
|
219 |
-
public $debug_code = null;
|
220 |
-
public $debug_output = '';
|
221 |
-
public $debug_header = null;
|
222 |
-
protected $debug_prefix = '';
|
223 |
-
|
224 |
-
public function __construct($input, $auto_correction)
|
225 |
-
{
|
226 |
-
$this->_input = $input;
|
227 |
-
$this->_parseInput($auto_correction);
|
228 |
-
}
|
229 |
-
|
230 |
-
public function addDebugIndent()
|
231 |
-
{
|
232 |
-
$this->debug_prefix .= ' ';
|
233 |
-
}
|
234 |
-
|
235 |
-
public function removeDebugIndent()
|
236 |
-
{
|
237 |
-
$this->debug_prefix = substr($this->debug_prefix, 0, strlen($this->debug_prefix)-3);
|
238 |
-
}
|
239 |
-
|
240 |
-
public function debug($text)
|
241 |
-
{
|
242 |
-
$this->debug_output .= "<p>{$this->debug_prefix}{$text}</p>";
|
243 |
-
}
|
244 |
-
|
245 |
-
public function getDebug()
|
246 |
-
{
|
247 |
-
$index = $this->debug_code.'-'.self::$DEBUG_INDEX_COUNTER++;
|
248 |
-
$output = "<style rel=stylesheet type=\"text/css\">"
|
249 |
-
.".osh-debug{background:#000;color:#bbb;-webkit-opacity:0.9;-moz-opacity:0.9;opacity:0.9;text-align:left;white-space:pre-wrap;overflow:auto;}"
|
250 |
-
.".osh-debug p{margin:2px 0;}"
|
251 |
-
.".osh-formula{color:#f90;} .osh-key{color:#0099f7;} .osh-loop{color:#ff0;}"
|
252 |
-
.".osh-error{color:#f00;} .osh-warning{color:#ff0;} .osh-info{color:#7bf700;}"
|
253 |
-
.".osh-debug-content{padding:10px;font-family:monospace}"
|
254 |
-
.".osh-replacement{color:#ff3000;}"
|
255 |
-
."</style>"
|
256 |
-
."<div id=osh-debug-{$index} class=osh-debug><div class=osh-debug-content><span class=osh-close style=\"float:right;cursor:pointer;\" onclick=\"document.getElementById('osh-debug-{$index}').style.display = 'none';\">[<span style=\"padding:0 5px;color:#f00;\">X</span>]</span>"
|
257 |
-
."<p>{$this->debug_header}</p>{$this->debug_output}</div></div>";
|
258 |
-
return $output;
|
259 |
-
}
|
260 |
-
|
261 |
-
public function initDebug($code, $process)
|
262 |
-
{
|
263 |
-
$header = 'DEBUG OwebiaShippingHelper.php<br/>';
|
264 |
-
foreach ($process as $index => $process_option) {
|
265 |
-
if (in_array($index, array('data', 'options'))) {
|
266 |
-
$header .= ' <span class=osh-key>'.self::esc(str_replace('.', '</span>.<span class=osh-key>', $index)).'</span> >><br/>';
|
267 |
-
foreach ($process_option as $object_name => $data) {
|
268 |
-
if (is_object($data) || is_array($data)) {
|
269 |
-
$header .= ' <span class=osh-key>'.self::esc(str_replace('.', '</span>.<span class=osh-key>', $object_name)).'</span> >><br/>';
|
270 |
-
$children = array();
|
271 |
-
if (is_object($data)) $children = $data->__sleep();
|
272 |
-
else if (is_array($data)) $children = array_keys($data);
|
273 |
-
foreach ($children as $name) {
|
274 |
-
$key = $name;
|
275 |
-
if ($key=='*') {
|
276 |
-
$header .= ' .<span class=osh-key>'.self::esc(str_replace('.', '</span>.<span class=osh-key>', $key)).'</span> = …<br/>';
|
277 |
-
} else {
|
278 |
-
if (is_object($data)) $value = $data->{$name};
|
279 |
-
else if (is_array($data)) $children = $data[$name];
|
280 |
-
$header .= ' .<span class=osh-key>'.self::esc(str_replace('.', '</span>.<span class=osh-key>', $key)).'</span> = <span class=osh-formula>'.self::esc(self::toString($value)).'</span> ('.gettype($value).')<br/>';
|
281 |
-
}
|
282 |
-
}
|
283 |
-
} else {
|
284 |
-
$header .= ' .<span class=osh-key>'.self::esc(str_replace('.', '</span>.<span class=osh-key>', $object_name)).'</span> = <span class=osh-formula>'.self::esc(self::toString($data)).'</span> ('.gettype($data).')<br/>';
|
285 |
-
}
|
286 |
-
}
|
287 |
-
} else {
|
288 |
-
$header .= ' <span class=osh-key>'.self::esc(str_replace('.', '</span>.<span class=osh-key>', $index)).'</span> = <span class=osh-formula>'.self::esc(self::toString($process_option)).'</span> ('.gettype($process_option).')<br/>';
|
289 |
-
}
|
290 |
-
}
|
291 |
-
$this->debug_code = $code;
|
292 |
-
$this->debug_header = $header;
|
293 |
-
}
|
294 |
-
|
295 |
-
public function getConfig()
|
296 |
-
{
|
297 |
-
return $this->_config;
|
298 |
-
}
|
299 |
-
|
300 |
-
public function getConfigRow($id)
|
301 |
-
{
|
302 |
-
return isset($this->_config[$id]) ? $this->_config[$id] : null;
|
303 |
-
}
|
304 |
-
|
305 |
-
public function setConfig($config)
|
306 |
-
{
|
307 |
-
return $this->_config = $config;
|
308 |
-
}
|
309 |
-
|
310 |
-
public function getMessages()
|
311 |
-
{
|
312 |
-
$messages = $this->_messages;
|
313 |
-
$this->_messages = array();
|
314 |
-
return $messages;
|
315 |
-
}
|
316 |
-
|
317 |
-
public function sortProperties($k1, $k2)
|
318 |
-
{
|
319 |
-
$i1 = isset($this->properties_sort[$k1]) ? $this->properties_sort[$k1] : 1000;
|
320 |
-
$i2 = isset($this->properties_sort[$k2]) ? $this->properties_sort[$k2] : 1000;
|
321 |
-
return $i1==$i2 ? strcmp($k1, $k2) : $i1-$i2;
|
322 |
-
}
|
323 |
-
|
324 |
-
public function formatConfig($compress, $keys_to_remove=array(), $html = false)
|
325 |
-
{
|
326 |
-
$object_array = array();
|
327 |
-
$this->properties_sort = array_flip(array(
|
328 |
-
'type',
|
329 |
-
'about',
|
330 |
-
'enabled',
|
331 |
-
'label',
|
332 |
-
'description',
|
333 |
-
'shipto',
|
334 |
-
'billto',
|
335 |
-
'origin',
|
336 |
-
'conditions',
|
337 |
-
'fees',
|
338 |
-
'tracking_url',
|
339 |
-
));
|
340 |
-
foreach ($this->_config as $code => $row) {
|
341 |
-
$object = array();
|
342 |
-
foreach ($row as $key => $property) {
|
343 |
-
if (substr($key, 0, 1)!='*' && !in_array($key, $keys_to_remove)) {
|
344 |
-
$object[$key] = $property['value'];
|
345 |
-
}
|
346 |
-
}
|
347 |
-
uksort($object, array($this, 'sortProperties'));
|
348 |
-
$object_array[$code] = $object;
|
349 |
-
}
|
350 |
-
$output = self::jsonEncode($object_array, $beautify = !$compress, $html);
|
351 |
-
return $compress ? $this->compress($output) : $this->uncompress($output);
|
352 |
-
}
|
353 |
-
|
354 |
-
public function checkConfig()
|
355 |
-
{
|
356 |
-
$timestamp = time();
|
357 |
-
$process = array(
|
358 |
-
'config' => $this->_config,
|
359 |
-
'data' => self::getDefaultProcessData(),
|
360 |
-
'result' => null,
|
361 |
-
);
|
362 |
-
foreach ($this->_config as $code => &$row) {
|
363 |
-
$this->processRow($process, $row, $check_all_conditions=true);
|
364 |
-
foreach ($row as $property_name => $property_value) {
|
365 |
-
if (substr($property_name, 0, 1)!='*') {
|
366 |
-
$this->debug(' check '.$property_name);
|
367 |
-
$this->getRowProperty($row, $property_name);
|
368 |
-
}
|
369 |
-
}
|
370 |
-
}
|
371 |
-
}
|
372 |
-
|
373 |
-
public function processRow($process, &$row, $is_checking=false)
|
374 |
-
{
|
375 |
-
if (!isset($row['*id'])) {
|
376 |
-
$this->debug('skip row with unknown id');
|
377 |
-
return new OS_Result(false);
|
378 |
-
}
|
379 |
-
$this->debug('process row <span class=osh-key>'.self::esc($row['*id']).'</span>');
|
380 |
-
|
381 |
-
if (isset($row['about'])) { // Display on debug
|
382 |
-
$about = $this->getRowProperty($row, 'about');
|
383 |
-
}
|
384 |
-
|
385 |
-
$type = $this->getRowProperty($row, 'type');
|
386 |
-
if ($type=='data') {
|
387 |
-
foreach ($row as $key => $data) {
|
388 |
-
if (in_array($key, array('*id', 'code', 'type'))) continue;
|
389 |
-
$value = isset($data['value']) ? $data['value'] : $data;
|
390 |
-
$this->debug(' .<span class=osh-key>'.self::esc($key).'</span> = <span class=osh-formula>'.self::esc(self::toString($value)).'</span> ('.gettype($value).')');
|
391 |
-
}
|
392 |
-
return new OS_Result(false);
|
393 |
-
}
|
394 |
-
if (isset($type) && $type!='method') return new OS_Result(false);
|
395 |
-
|
396 |
-
if (!isset($row['label']['value'])) $row['label']['value'] = '***';
|
397 |
-
|
398 |
-
$enabled = $this->getRowProperty($row, 'enabled');
|
399 |
-
if (isset($enabled)) {
|
400 |
-
if (!$is_checking && !$enabled) {
|
401 |
-
$this->addMessage('info', $row, 'enabled', 'Configuration disabled');
|
402 |
-
return new OS_Result(false);
|
403 |
-
}
|
404 |
-
}
|
405 |
-
|
406 |
-
$conditions = $this->getRowProperty($row, 'conditions');
|
407 |
-
if (isset($conditions)) {
|
408 |
-
$result = $this->processFormula($process, $row, 'conditions', $conditions, $is_checking);
|
409 |
-
if (!$is_checking) {
|
410 |
-
if (!$result->success) return $result;
|
411 |
-
if (!$result->result) {
|
412 |
-
$this->addMessage('info', $row, 'conditions', "The cart doesn't match conditions");
|
413 |
-
return new OS_Result(false);
|
414 |
-
}
|
415 |
-
}
|
416 |
-
}
|
417 |
-
|
418 |
-
$address_properties = array(
|
419 |
-
'shipto' => "Shipping zone not allowed",
|
420 |
-
'billto' => "Billing zone not allowed",
|
421 |
-
'origin' => "Shipping origin not allowed",
|
422 |
-
);
|
423 |
-
foreach ($address_properties as $property_name => $failure_message) {
|
424 |
-
$property_value = $this->getRowProperty($row, $property_name);
|
425 |
-
if (isset($property_value)) {
|
426 |
-
$match = $this->_addressMatch($process, $row, $property_name, $property_value, $process['data'][$property_name]);
|
427 |
-
if (!$is_checking && !$match) {
|
428 |
-
$this->addMessage('info', $row, $property_name, $failure_message);
|
429 |
-
return new OS_Result(false);
|
430 |
-
}
|
431 |
-
}
|
432 |
-
}
|
433 |
-
|
434 |
-
$customer_groups = $this->getRowProperty($row, 'customer_groups');
|
435 |
-
if (isset($customer_groups)) {
|
436 |
-
$groups = explode(',', $customer_groups);
|
437 |
-
$group_match = false;
|
438 |
-
$customer_group = $process['data']['customer_group'];
|
439 |
-
foreach ($groups as $group) {
|
440 |
-
$group = trim($group);
|
441 |
-
if ($group=='*' || $group==$customer_group->code || ctype_digit($group) && $group==$customer_group->id) {
|
442 |
-
$this->debug(' group <span class=osh-replacement>'.self::esc($customer_group->code).'</span> (id:<span class=osh-replacement>'.self::esc($customer_group->id).'</span>) matches');
|
443 |
-
$group_match = true;
|
444 |
-
break;
|
445 |
-
}
|
446 |
-
}
|
447 |
-
if (!$is_checking && !$group_match) {
|
448 |
-
$this->addMessage('info', $row, 'customer_groups', "Customer group not allowed (%s)", $customer_group->code);
|
449 |
-
return new OS_Result(false);
|
450 |
-
}
|
451 |
-
}
|
452 |
-
|
453 |
-
$fees = $this->getRowProperty($row, 'fees');
|
454 |
-
if (isset($fees)) {
|
455 |
-
$result = $this->processFormula($process, $row, 'fees', $fees, $is_checking);
|
456 |
-
if (!$result->success) return $result;
|
457 |
-
$this->debug(' » <span class=osh-info>result</span> = <span class=osh-formula>'.self::esc(self::toString($result->result)).'</span>');
|
458 |
-
return new OS_Result(true, (float)$result->result);
|
459 |
-
}
|
460 |
-
return new OS_Result(false);
|
461 |
-
}
|
462 |
-
|
463 |
-
public function getRowProperty(&$row, $key, $original_row=null, $original_key=null)
|
464 |
-
{
|
465 |
-
$property = null;
|
466 |
-
$output = null;
|
467 |
-
if (isset($original_row) && isset($original_key) && $original_row['*id']==$row['*id'] && $original_key==$key) {
|
468 |
-
$this->addMessage('error', $row, $key, 'Infinite loop %s', "<span class=\"code\">{{$row['*id']}.{$key}}</span>");
|
469 |
-
return array('error' => 'Infinite loop');
|
470 |
-
}
|
471 |
-
if (isset($row[$key]['value'])) {
|
472 |
-
$property = $row[$key]['value'];
|
473 |
-
$output = $property;
|
474 |
-
$this->debug(' get <span class=osh-key>'.self::esc($row['*id']).'</span>.<span class=osh-key>'.self::esc($key).'</span> = <span class=osh-formula>'.self::esc(self::toString($property)).'</span>');
|
475 |
-
preg_match_all('/{([a-z0-9_]+)\.([a-z0-9_]+)}/i', $output, $result_set, PREG_SET_ORDER);
|
476 |
-
foreach ($result_set as $result) {
|
477 |
-
list($original, $ref_code, $ref_key) = $result;
|
478 |
-
if ($ref_code==$row['*id'] && $ref_key==$key) {
|
479 |
-
$this->addMessage('error', $row, $key, 'Infinite loop %s', "<span class=\"code\">{$original}</span>");
|
480 |
-
return null;
|
481 |
-
}
|
482 |
-
if (isset($this->_config[$ref_code][$ref_key]['value'])) {
|
483 |
-
$replacement = $this->getRowProperty($this->_config[$ref_code], $ref_key,
|
484 |
-
isset($original_row) ? $original_row : $row, isset($original_key) ? $original_key : $key);
|
485 |
-
if (is_array($replacement) && isset($replacement['error'])) {
|
486 |
-
return isset($original_row) ? $replacement : 'false';
|
487 |
-
}
|
488 |
-
$output = $this->replace('{'.$original.'}', $this->_autoEscapeStrings($replacement), $output);
|
489 |
-
$output = $this->replace($original, $replacement, $output);
|
490 |
-
} else {
|
491 |
-
$replacement = $original;
|
492 |
-
$output = $this->replace($original, $replacement, $output);
|
493 |
-
}
|
494 |
-
//$this->addMessage('error', $row, $key, $original.' => '.$replacement.' = '.$output);
|
495 |
-
}
|
496 |
-
} else {
|
497 |
-
$this->debug(' get <span class=osh-key>'.self::esc($row['*id']).'</span>.<span class=osh-key>'.self::esc($key).'</span> = <span class=osh-formula>null</span>');
|
498 |
-
}
|
499 |
-
return $output;
|
500 |
-
}
|
501 |
-
|
502 |
-
public function evalInput($process, $row, $property_name, $input)
|
503 |
-
{
|
504 |
-
$result = $this->_prepareFormula($process, $row, $property_name, $input, $is_checking=false, $use_cache=true);
|
505 |
-
return $result->success ? $result->result : $input;
|
506 |
-
}
|
507 |
-
|
508 |
-
public function compress($input)
|
509 |
-
{
|
510 |
-
$input = str_replace(
|
511 |
-
self::$UNCOMPRESSED_STRINGS,
|
512 |
-
self::$COMPRESSED_STRINGS,
|
513 |
-
$input
|
514 |
-
);
|
515 |
-
if (function_exists('gzcompress') && function_exists('base64_encode')) {
|
516 |
-
$input = 'gz64'.base64_encode(gzcompress($input));
|
517 |
-
}
|
518 |
-
return '$$'.$input;
|
519 |
-
}
|
520 |
-
|
521 |
-
public function uncompress($input)
|
522 |
-
{
|
523 |
-
if (substr($input, 0, 4)=='gz64' && function_exists('gzuncompress') && function_exists('base64_decode')) {
|
524 |
-
$input = gzuncompress(base64_decode(substr($input, 4, strlen($input))));
|
525 |
-
}
|
526 |
-
return str_replace(
|
527 |
-
self::$COMPRESSED_STRINGS,
|
528 |
-
self::$UNCOMPRESSED_STRINGS,
|
529 |
-
$input
|
530 |
-
);
|
531 |
-
}
|
532 |
-
|
533 |
-
public function parseProperty($input)
|
534 |
-
{
|
535 |
-
if ($input==='false') return false;
|
536 |
-
if ($input==='true') return true;
|
537 |
-
if ($input==='null') return null;
|
538 |
-
if (is_numeric($input)) return (double)$input;
|
539 |
-
$value = str_replace('\"', '"', preg_replace('/^(?:"|\')(.*)(?:"|\')$/s', '$1', $input));
|
540 |
-
return $value==='' ? null : $value;
|
541 |
-
}
|
542 |
-
|
543 |
-
protected function replace($from, $to, $input, $class_name=null, $message='replace')
|
544 |
-
{
|
545 |
-
if ($from===$to) return $input;
|
546 |
-
if (mb_strpos($input, $from)===false) return $input;
|
547 |
-
$to = self::toString($to);
|
548 |
-
$to = preg_replace('/[\r\n\t]+/', ' ', $to);
|
549 |
-
$this->debug(' '
|
550 |
-
.($class_name ? '<span class="osh-'.$class_name.'">' : '')
|
551 |
-
.$message.' <span class=osh-replacement>'.self::esc(self::toString($from)).'</span> by <span class=osh-replacement>'.self::esc($to).'</span>'
|
552 |
-
.' => <span class=osh-formula>'.self::esc(str_replace($from, '<span class=osh-replacement>'.$to.'</span>', $input)).'</span>'
|
553 |
-
.($class_name ? '</span>' : ''));
|
554 |
-
return str_replace($from, $to, $input);
|
555 |
-
}
|
556 |
-
|
557 |
-
protected function _min()
|
558 |
-
{
|
559 |
-
$args = func_get_args();
|
560 |
-
$min = null;
|
561 |
-
foreach ($args as $arg) {
|
562 |
-
if (isset($arg) && (!isset($min) || $min>$arg)) $min = $arg;
|
563 |
-
}
|
564 |
-
return $min;
|
565 |
-
}
|
566 |
-
|
567 |
-
protected function _max()
|
568 |
-
{
|
569 |
-
$args = func_get_args();
|
570 |
-
$max = null;
|
571 |
-
foreach ($args as $arg) {
|
572 |
-
if (isset($arg) && (!isset($max) || $max<$arg)) $max = $arg;
|
573 |
-
}
|
574 |
-
return $max;
|
575 |
-
}
|
576 |
-
|
577 |
-
protected function _range($value=-1, $min_value=0, $max_value=1, $include_min_value=true, $include_max_value=true)
|
578 |
-
{
|
579 |
-
return ($value>$min_value || $include_min_value && $value==$min_value) && ($value<$max_value || $include_max_value && $value==$max_value);
|
580 |
-
}
|
581 |
-
|
582 |
-
protected function _array_match_any()
|
583 |
-
{
|
584 |
-
$args = func_get_args();
|
585 |
-
$result = call_user_func_array('array_intersect', $args);
|
586 |
-
return (bool)$result;
|
587 |
-
}
|
588 |
-
|
589 |
-
protected function _array_match_all()
|
590 |
-
{
|
591 |
-
$args = func_get_args();
|
592 |
-
if (!isset($args[0])) return false;
|
593 |
-
$result = call_user_func_array('array_intersect', $args);
|
594 |
-
return count($result)==count($args[0]);
|
595 |
-
}
|
596 |
-
|
597 |
-
public function processFormula($process, &$row, $property_name, $formula_string, $is_checking, $use_cache=true)
|
598 |
-
{
|
599 |
-
$result = $this->_prepareFormula($process, $row, $property_name, $formula_string, $is_checking, $use_cache);
|
600 |
-
if (!$result->success) return $result;
|
601 |
-
|
602 |
-
$eval_result = $this->_evalFormula($result->result, $row, $property_name, $is_checking);
|
603 |
-
if (!$is_checking && !isset($eval_result)) {
|
604 |
-
$this->addMessage('error', $row, $property_name, 'Empty result');
|
605 |
-
$result = new OS_Result(false);
|
606 |
-
if ($use_cache) $this->_setCache($formula_string, $result);
|
607 |
-
return $result;
|
608 |
-
}
|
609 |
-
$result = new OS_Result(true, $eval_result);
|
610 |
-
if ($use_cache) $this->_setCache($formula_string, $result);
|
611 |
-
return $result;
|
612 |
-
}
|
613 |
-
|
614 |
-
protected function _setCache($expression, $value)
|
615 |
-
{
|
616 |
-
if ($value instanceof OS_Result) {
|
617 |
-
$this->_formula_cache[$expression] = $value;
|
618 |
-
$this->debug(' cache <span class=osh-replacement>'.self::esc($expression).'</span> = <span class=osh-formula>'.self::esc(self::toString($value->result)).'</span> ('.gettype($value->result).')');
|
619 |
-
} else {
|
620 |
-
$this->_expression_cache[$expression] = $value; //self::toString($value); // In order to make isset work
|
621 |
-
$this->debug(' cache <span class=osh-replacement>'.self::esc($expression).'</span> = <span class=osh-formula>'.self::esc(self::toString($value)).'</span> ('.gettype($value).')');
|
622 |
-
}
|
623 |
-
}
|
624 |
-
|
625 |
-
protected function _getCachedExpression($original)
|
626 |
-
{
|
627 |
-
$replacement = $this->_expression_cache[$original];
|
628 |
-
$this->debug(' get cached expression <span class=osh-replacement>'.self::esc($original).'</span> = <span class=osh-formula>'.self::esc(self::toString($replacement)).'</span> ('.gettype($replacement).')');
|
629 |
-
return $replacement;
|
630 |
-
}
|
631 |
-
|
632 |
-
protected function _prepare_regexp($regexp)
|
633 |
-
{
|
634 |
-
if (!isset($this->constants)) {
|
635 |
-
$reflector = new ReflectionClass(get_class($this));
|
636 |
-
$this->constants = $reflector->getConstants();
|
637 |
-
}
|
638 |
-
foreach ($this->constants as $name => $value) {
|
639 |
-
$regexp = str_replace('{'.$name.'}', $value, $regexp);
|
640 |
-
}
|
641 |
-
return $regexp;
|
642 |
-
}
|
643 |
-
|
644 |
-
protected function _preg_match($regexp, $input, &$result, $debug=false)
|
645 |
-
{
|
646 |
-
$regexp = $this->_prepare_regexp($regexp);
|
647 |
-
if ($debug) $this->debug(' preg_match <span class=osh-replacement>'.self::esc($regexp).'</span>');
|
648 |
-
return preg_match($regexp, $input, $result);
|
649 |
-
}
|
650 |
-
|
651 |
-
protected function _preg_match_all($regexp, $input, &$result, $debug=false)
|
652 |
-
{
|
653 |
-
$regexp = $this->_prepare_regexp($regexp);
|
654 |
-
if ($debug) $this->debug(' preg_match_all <span class=osh-replacement>'.self::esc($regexp).'</span>');
|
655 |
-
$return = preg_match_all($regexp, $input, $result, PREG_SET_ORDER);
|
656 |
-
}
|
657 |
-
|
658 |
-
protected function _loadValue($process, $object_name, $attribute)
|
659 |
-
{
|
660 |
-
switch ($object_name) {
|
661 |
-
case 'item': return isset($process['data']['cart']->items[0]) ? $process['data']['cart']->items[0]->{$attribute} : null;
|
662 |
-
case 'product': return isset($process['data']['cart']->items[0]) ? $process['data']['cart']->items[0]->getProduct()->{$attribute} : null;
|
663 |
-
default: return isset($process['data'][$object_name]) ? $process['data'][$object_name]->{$attribute} : null;
|
664 |
-
}
|
665 |
-
}
|
666 |
-
|
667 |
-
protected function _prepareFormula($process, $row, $property_name, $formula_string, $is_checking, $use_cache=true)
|
668 |
-
{
|
669 |
-
if ($use_cache && isset($this->_formula_cache[$formula_string])) {
|
670 |
-
$result = $this->_formula_cache[$formula_string];
|
671 |
-
$this->debug(' get cached formula <span class=osh-replacement>'.self::esc($formula_string).'</span> = <span class=osh-formula>'.self::esc(self::toString($result->result)).'</span>');
|
672 |
-
return $result;
|
673 |
-
}
|
674 |
-
|
675 |
-
$formula = $formula_string;
|
676 |
-
//$this->debug(' formula = <span class=osh-formula>'.self::esc($formula).'</span>');
|
677 |
-
|
678 |
-
// foreach
|
679 |
-
while ($this->_preg_match("#{foreach ((?:item|product|p)\.[a-z0-9_\+\-\.]+)}(.*){/foreach}#iU", $formula, $result)) { // ungreedy
|
680 |
-
$original = $result[0];
|
681 |
-
if ($use_cache && array_key_exists($original, $this->_expression_cache)) {
|
682 |
-
$replacement = $this->_getCachedExpression($original);
|
683 |
-
} else {
|
684 |
-
$replacement = 0;
|
685 |
-
$loop_var = $result[1];
|
686 |
-
$selections = array();
|
687 |
-
$this->debug(' foreach <span class=osh-key>'.self::esc($loop_var).'</span>');
|
688 |
-
$this->addDebugIndent();
|
689 |
-
$items = $process['data']['cart']->items;
|
690 |
-
if ($items) {
|
691 |
-
foreach ($items as $item) {
|
692 |
-
$tmp_value = $this->_getItemProperty($item, $loop_var);
|
693 |
-
$values = (array)$tmp_value;
|
694 |
-
foreach ($values as $value_i) {
|
695 |
-
$key = self::_autoEscapeStrings($value_i);
|
696 |
-
$sel = isset($selections[$key]) ? $selections[$key] : null;
|
697 |
-
$selections[$key]['items'][] = $item;
|
698 |
-
}
|
699 |
-
$this->debug(' items[<span class=osh-formula>'.self::esc((string)$item).'</span>].<span class=osh-key>'.self::esc($loop_var).'</span> = [<span class=osh-formula>'.self::esc(implode('</span>, <span class=osh-formula>', $values)).'</span>]');
|
700 |
-
}
|
701 |
-
}
|
702 |
-
$this->removeDebugIndent();
|
703 |
-
$this->debug(' <span class=osh-loop>start foreach</span>');
|
704 |
-
$this->addDebugIndent();
|
705 |
-
foreach ($selections as $key => $selection) {
|
706 |
-
$this->debug(' <span class=osh-loop>• value</span> = <span class=osh-formula>'.self::esc($key).'</span>');
|
707 |
-
$this->addDebugIndent();
|
708 |
-
$this->debug(' #### count '.count($process['data']['cart']->items));
|
709 |
-
$process2 = $process;
|
710 |
-
$process2['data']['cart'] = clone $process2['data']['cart']; // Important to not override previous items
|
711 |
-
$process2['data']['cart']->items = $selection['items'];
|
712 |
-
$selection['qty'] = 0;
|
713 |
-
$selection['weight'] = 0;
|
714 |
-
foreach ($selection['items'] as $item) {
|
715 |
-
$selection['qty'] += $item->qty;
|
716 |
-
$selection['weight'] += $item->weight;
|
717 |
-
}
|
718 |
-
if (isset($process2['data']['selection'])) {
|
719 |
-
$process2['data']['selection']->set('qty', $selection['qty']);
|
720 |
-
$process2['data']['selection']->set('weight', $selection['weight']);
|
721 |
-
}
|
722 |
-
$process_result = $this->processFormula($process2, $row, $property_name, $result[2], $is_checking, $tmp_use_cache=false);
|
723 |
-
$replacement += $process_result->result;
|
724 |
-
$this->debug(' » <span class=osh-info>foreach sum result</span> = <span class=osh-formula>'.self::esc(self::toString($replacement)).'</span>');
|
725 |
-
$this->removeDebugIndent();
|
726 |
-
}
|
727 |
-
$this->removeDebugIndent();
|
728 |
-
$this->debug(' <span class=osh-loop>end</span>');
|
729 |
-
if ($use_cache) $this->_setCache($original, $replacement);
|
730 |
-
}
|
731 |
-
$formula = $this->replace($original, $replacement, $formula);
|
732 |
-
}
|
733 |
-
|
734 |
-
if (isset($process['data']['selection'])) {
|
735 |
-
if ($process['data']['selection']->weight==null) $process['data']['selection']->set('weight', $process['data']['cart']->weight);
|
736 |
-
if ($process['data']['selection']->qty==null) $process['data']['selection']->set('qty', $process['data']['cart']->qty);
|
737 |
-
}
|
738 |
-
|
739 |
-
// data
|
740 |
-
$aliases = array(
|
741 |
-
'p' => 'product',
|
742 |
-
'c' => 'cart',
|
743 |
-
's' => 'selection',
|
744 |
-
);
|
745 |
-
$formula = $this->_replaceData($process, $formula, 'item|product|p|c|s', $aliases);
|
746 |
-
|
747 |
-
// count, sum, min, max
|
748 |
-
//while ($this->_preg_match("/{(count) products(?: where ([^}]+))?}/i", $formula, $result)
|
749 |
-
// || $this->_preg_match("/{(sum|min|max|count distinct) {PRODUCT_REGEX}\.({ATTRIBUTE_REGEX}|{OPTION_REGEX}|stock)\.([a-z0-9_+-]+)(?: where ([^}]+))?}/i", $formula, $result)
|
750 |
-
// || $this->_preg_match("/{(sum|min|max|count distinct) {PRODUCT_REGEX}\.(quantity)()(?: where ([^}]+))?}/i", $formula, $result)
|
751 |
-
while ($this->_preg_match("/{(count)\s+items\s*(?:\s+where\s+((?:[^\"'}]|'[^']+'|\"[^\"]+\")+))?}/i", $formula, $result)
|
752 |
-
|| $this->_preg_match("/{(sum|min|max|count distinct) ((?:item|product|p)\.[a-z0-9_\+\-\.]+)(?: where ((?:[^\"'}]|'[^']+'|\"[^\"]+\")+))?}/i", $formula, $result)
|
753 |
-
) {
|
754 |
-
$original = $result[0];
|
755 |
-
if ($use_cache && array_key_exists($original, $this->_expression_cache)) {
|
756 |
-
$replacement = $this->_getCachedExpression($original);
|
757 |
-
} else {
|
758 |
-
$replacement = $this->_processProduct($process['data']['cart']->items, $result, $row, $property_name, $is_checking);
|
759 |
-
if ($use_cache) $this->_setCache($result[0], $replacement);
|
760 |
-
}
|
761 |
-
$formula = $this->replace($original, $replacement, $formula);
|
762 |
-
}
|
763 |
-
|
764 |
-
// switch
|
765 |
-
while (preg_match("/{switch ([^}]+) in ([^}]+)}/i", $formula, $result)) {
|
766 |
-
$original = $result[0];
|
767 |
-
if ($use_cache && array_key_exists($original, $this->_expression_cache)) {
|
768 |
-
$replacement = $this->_getCachedExpression($original);
|
769 |
-
} else {
|
770 |
-
$reference_value = $this->_evalFormula($result[1], $row, $property_name, $is_checking);
|
771 |
-
$fees_table_string = $result[2];
|
772 |
-
|
773 |
-
$couple_regex = '[^}:]+ *\: *[0-9.]+ *';
|
774 |
-
if (!preg_match('#^ *'.$couple_regex.'(?:, *'.$couple_regex.')*$#', $fees_table_string)) {
|
775 |
-
$this->addMessage('error', $row, $property_name, 'Error in switch %s', '<span class=osh-formula>'.self::esc($result[0]).'</span>');
|
776 |
-
$result = new OS_Result(false);
|
777 |
-
if ($use_cache) $this->_setCache($formula_string, $result);
|
778 |
-
return $result;
|
779 |
-
}
|
780 |
-
$fees_table = explode(',', $fees_table_string);
|
781 |
-
|
782 |
-
$replacement = null;
|
783 |
-
foreach ($fees_table as $item) {
|
784 |
-
$fee_data = explode(':', $item);
|
785 |
-
|
786 |
-
$fee = trim($fee_data[1]);
|
787 |
-
$value = trim($fee_data[0]);
|
788 |
-
$value = $value=='*' ? '*' : $this->_evalFormula($fee_data[0], $row, $property_name, $is_checking);
|
789 |
-
|
790 |
-
if ($value=='*' || $reference_value===$value) {
|
791 |
-
$replacement = $fee;
|
792 |
-
$this->debug(' compare <span class=osh-formula>'.self::esc($this->_autoEscapeStrings($reference_value)).'</span> == <span class=osh-formula>'.self::esc($this->_autoEscapeStrings($value)).'</span>');
|
793 |
-
break;
|
794 |
-
}
|
795 |
-
$this->debug(' compare <span class=osh-formula>'.self::esc($this->_autoEscapeStrings($reference_value)).'</span> != <span class=osh-formula>'.self::esc($this->_autoEscapeStrings($value)).'</span>');
|
796 |
-
}
|
797 |
-
//$replacement = self::toString($replacement);
|
798 |
-
if ($use_cache) $this->_setCache($original, $replacement);
|
799 |
-
}
|
800 |
-
$formula = $this->replace($original, $replacement, $formula);
|
801 |
-
}
|
802 |
-
|
803 |
-
// range table
|
804 |
-
while (preg_match("/{table ([^}]+) in ([0-9\.:,\*\[\] ]+)}/i", $formula, $result)) {
|
805 |
-
$original = $result[0];
|
806 |
-
if ($use_cache && array_key_exists($original, $this->_expression_cache)) {
|
807 |
-
$replacement = $this->_getCachedExpression($original);
|
808 |
-
} else {
|
809 |
-
$reference_value = $this->_evalFormula($result[1], $row, $property_name, $is_checking);
|
810 |
-
$replacement = null;
|
811 |
-
if (isset($reference_value)) {
|
812 |
-
$fees_table_string = $result[2];
|
813 |
-
|
814 |
-
if (!preg_match('#^'.self::COUPLE_REGEX.'(?:, *'.self::COUPLE_REGEX.')*$#', $fees_table_string)) {
|
815 |
-
$this->addMessage('error', $row, $property_name, 'Error in table %s', '<span class=osh-formula>'.self::esc($result[0]).'</span>');
|
816 |
-
$result = new OS_Result(false);
|
817 |
-
if ($use_cache) $this->_setCache($formula_string, $result);
|
818 |
-
return $result;
|
819 |
-
}
|
820 |
-
$fees_table = explode(',', $fees_table_string);
|
821 |
-
foreach ($fees_table as $item) {
|
822 |
-
$fee_data = explode(':', $item);
|
823 |
-
|
824 |
-
$fee = trim($fee_data[1]);
|
825 |
-
$max_value = trim($fee_data[0]);
|
826 |
-
|
827 |
-
$last_char = $max_value{strlen($max_value)-1};
|
828 |
-
if ($last_char=='[') $including_max_value = false;
|
829 |
-
else if ($last_char==']') $including_max_value = true;
|
830 |
-
else $including_max_value = true;
|
831 |
-
|
832 |
-
$max_value = str_replace(array('[', ']'), '', $max_value);
|
833 |
-
|
834 |
-
if ($max_value=='*' || $including_max_value && $reference_value<=$max_value || !$including_max_value && $reference_value<$max_value) {
|
835 |
-
$replacement = $fee;
|
836 |
-
break;
|
837 |
-
}
|
838 |
-
}
|
839 |
-
}
|
840 |
-
//$replacement = self::toString($replacement);
|
841 |
-
if ($use_cache) $this->_setCache($original, $replacement);
|
842 |
-
}
|
843 |
-
$formula = $this->replace($original, $replacement, $formula);
|
844 |
-
}
|
845 |
-
$result = new OS_Result(true, $formula);
|
846 |
-
return $result;
|
847 |
-
}
|
848 |
-
|
849 |
-
protected function _evalFormula($formula, &$row, $property_name=null, $is_checking=false)
|
850 |
-
{
|
851 |
-
if (is_bool($formula)) return $formula;
|
852 |
-
if (!preg_match('/^(?:'
|
853 |
-
.'\b(?:'
|
854 |
-
.'E|e|int|float|string|boolean|object|array|true|false|null|and|or|in'
|
855 |
-
.'|floor|ceil|round|rand|pow|pi|sqrt|log|exp|abs|substr|strtolower|preg_match|in_array'
|
856 |
-
.'|max|min|range|array_match_any|array_match_all'
|
857 |
-
.'|date|strtotime'
|
858 |
-
.')\b'
|
859 |
-
.'|\'[^\']*\'|\"[^\"]*\"|[0-9,\'\.\-\(\)\*\/\?\:\+\<\>\=\&\|%!]|\s)*$/', $formula)) {
|
860 |
-
$errors = array(
|
861 |
-
PREG_NO_ERROR => 'PREG_NO_ERROR',
|
862 |
-
PREG_INTERNAL_ERROR => 'PREG_INTERNAL_ERROR',
|
863 |
-
PREG_BACKTRACK_LIMIT_ERROR => 'PREG_BACKTRACK_LIMIT_ERROR',
|
864 |
-
PREG_RECURSION_LIMIT_ERROR => 'PREG_RECURSION_LIMIT_ERROR',
|
865 |
-
PREG_BAD_UTF8_ERROR => 'PREG_BAD_UTF8_ERROR',
|
866 |
-
defined('PREG_BAD_UTF8_OFFSET_ERROR') ? PREG_BAD_UTF8_OFFSET_ERROR : 'PREG_BAD_UTF8_OFFSET_ERROR' => 'PREG_BAD_UTF8_OFFSET_ERROR',
|
867 |
-
);
|
868 |
-
$error = preg_last_error();
|
869 |
-
if (isset($errors[$error])) $error = $errors[$error];
|
870 |
-
if ($is_checking) $this->addMessage('error', $row, $property_name, $error.' ('.$formula.')');
|
871 |
-
$this->debug(' eval <span class=osh-formula>'.self::esc($formula).'</span>');
|
872 |
-
$this->debug(' doesn\'t match ('.self::esc($error).')');
|
873 |
-
return null;
|
874 |
-
}
|
875 |
-
$formula = preg_replace('@\b(min|max|range|array_match_any|array_match_all)\(@', '\$this->_\1(', $formula);
|
876 |
-
$eval_result = null;
|
877 |
-
//echo $formula.'<br/>';
|
878 |
-
@eval('$eval_result = ('.$formula.');');
|
879 |
-
$this->debug(' evaluate <span class=osh-formula>'.self::esc($formula).'</span> = <span class=osh-replacement>'.self::esc($this->_autoEscapeStrings($eval_result)).'</span>');
|
880 |
-
return $eval_result;
|
881 |
-
}
|
882 |
-
|
883 |
-
protected function _parseInput($auto_correction)
|
884 |
-
{
|
885 |
-
$config_string = str_replace(
|
886 |
-
array('>', '<', '“', '”', utf8_encode(chr(147)), utf8_encode(chr(148)), '«', '»', "\r\n", "\t"),
|
887 |
-
array('>', '<', '"', '"', '"', '"', '"', '"', "\n", ' '),
|
888 |
-
$this->_input
|
889 |
-
);
|
890 |
-
|
891 |
-
if (substr($config_string, 0, 2)=='$$') $config_string = $this->uncompress(substr($config_string, 2, strlen($config_string)));
|
892 |
-
|
893 |
-
//echo ini_get('pcre.backtrack_limit');
|
894 |
-
//exit;
|
895 |
-
|
896 |
-
$this->debug('parse config (auto correction = '.self::esc(self::toString($auto_correction)).')');
|
897 |
-
$config = null;
|
898 |
-
$last_json_error = null;
|
899 |
-
try {
|
900 |
-
$config = self::json_decode($config_string);
|
901 |
-
} catch (Exception $e) {
|
902 |
-
$last_json_error = $e;
|
903 |
-
}
|
904 |
-
$auto_correction_warnings = array();
|
905 |
-
$missing_enquote_of_property_name = array();
|
906 |
-
if ($config) {
|
907 |
-
foreach ($config as $code => $object) {
|
908 |
-
if (!is_object($object)) {
|
909 |
-
$config = null;
|
910 |
-
break;
|
911 |
-
}
|
912 |
-
}
|
913 |
-
}
|
914 |
-
if ($auto_correction && !$config && $config_string!='[]') {
|
915 |
-
if (preg_match_all('/((?:#+[^{\\n]*\\s+)+)\\s*{/s', $config_string, $result, PREG_SET_ORDER)) {
|
916 |
-
$auto_correction_warnings[] = 'JSON: usage of incompatible comments';
|
917 |
-
foreach ($result as $set) {
|
918 |
-
$comment_lines = explode("\n", $set[1]);
|
919 |
-
foreach ($comment_lines as $i => $line) {
|
920 |
-
$comment_lines[$i] = preg_replace('/^#+\\s/', '', $line);
|
921 |
-
}
|
922 |
-
$comment = trim(implode("\n", $comment_lines));
|
923 |
-
$config_string = str_replace($set[0], '{"about": "'.str_replace('"', '\\"', $comment).'",', $config_string);
|
924 |
-
}
|
925 |
-
}
|
926 |
-
$property_regex = '\\s*(?<property_name>"?[a-z0-9_]+"?)\\s*:\\s*(?<property_value>"(?:(?:[^"]|\\\\")*[^\\\\])?"|'.self::FLOAT_REGEX.'|false|true|null)\\s*(?<property_separator>,)?\\s*(?:\\n)?';
|
927 |
-
$object_regex = '(?:(?<object_name>"?[a-z0-9_]+"?)\\s*:\\s*)?{\\s*('.$property_regex.')+\\s*}\\s*(?<object_separator>,)?\\s*';
|
928 |
-
preg_match_all('/('.$object_regex.')/is', $config_string, $object_set, PREG_SET_ORDER);
|
929 |
-
//print_r($object_set);
|
930 |
-
$json = array();
|
931 |
-
$objects_count = count($object_set);
|
932 |
-
$to_ignore_counter = -1;
|
933 |
-
foreach ($object_set as $i => $object) {
|
934 |
-
$pos = strpos($config_string, $object[0]);
|
935 |
-
$to_ignore = trim(substr($config_string, 0, $pos));
|
936 |
-
if ($to_ignore) {
|
937 |
-
$to_ignore_counter++;
|
938 |
-
if ($to_ignore_counter==0) {
|
939 |
-
$bracket_pos = strpos($to_ignore, '{');
|
940 |
-
if ($bracket_pos!==false) {
|
941 |
-
$to_ignore = explode('{', $to_ignore, 2);
|
942 |
-
}
|
943 |
-
}
|
944 |
-
$to_ignore = (array)$to_ignore;
|
945 |
-
foreach ($to_ignore as $to_ignore_i) {
|
946 |
-
$to_ignore_i = trim($to_ignore_i);
|
947 |
-
if (!$to_ignore_i) continue;
|
948 |
-
$auto_correction_warnings[] = 'JSON: ignored lines (<span class=osh-formula>'.self::toString($to_ignore_i).'</span>)';
|
949 |
-
$n = 0;
|
950 |
-
do {
|
951 |
-
$key = 'meta'.$n;
|
952 |
-
$n++;
|
953 |
-
} while(isset($json[$key]));
|
954 |
-
$json[$key] = array(
|
955 |
-
'type' => 'meta',
|
956 |
-
'ignored' => $to_ignore_i,
|
957 |
-
);
|
958 |
-
}
|
959 |
-
$config_string = substr($config_string, $pos, strlen($config_string));
|
960 |
-
}
|
961 |
-
$config_string = str_replace($object[0], '', $config_string);
|
962 |
-
$object_name = isset($object['object_name']) ? $object['object_name'] : null;
|
963 |
-
$object_separator = isset($object['object_separator']) ? $object['object_separator'] : null;
|
964 |
-
$is_last_object = ($i==$objects_count-1);
|
965 |
-
if (!$is_last_object && $object_separator!=',') {
|
966 |
-
$auto_correction_warnings[] = 'JSON: missing object separator (comma)';
|
967 |
-
} else if ($is_last_object && $object_separator==',') {
|
968 |
-
$auto_correction_warnings[] = 'JSON: no trailing object separator (comma) allowed';
|
969 |
-
}
|
970 |
-
$json_object = array();
|
971 |
-
preg_match_all('/'.$property_regex.'/i', $object[0], $property_set, PREG_SET_ORDER);
|
972 |
-
$properties_count = count($property_set);
|
973 |
-
foreach ($property_set as $j => $property) {
|
974 |
-
$name = $property['property_name'];
|
975 |
-
if ($name{0}!='"' || $name{strlen($name)-1}!='"') {
|
976 |
-
$auto_correction_warnings['missing_enquote_of_property_name'] = 'JSON: missing enquote of property name: %s';
|
977 |
-
$missing_enquote_of_property_name[] = self::toString(trim($name, '"'));
|
978 |
-
}
|
979 |
-
$property_separator = isset($property['property_separator']) ? $property['property_separator'] : null;
|
980 |
-
$is_last_property = ($j==$properties_count-1);
|
981 |
-
if (!$is_last_property && $property_separator!=',') {
|
982 |
-
$auto_correction_warnings[] = 'JSON: missing property separator (comma)';
|
983 |
-
} else if ($is_last_property && $property_separator==',') {
|
984 |
-
$auto_correction_warnings[] = 'JSON: no trailing property separator (comma) allowed';
|
985 |
-
}
|
986 |
-
$json_object[trim($name, '"')] = $this->parseProperty($property['property_value']);
|
987 |
-
}
|
988 |
-
if ($object_name) $json[trim($object_name, '"')] = $json_object;
|
989 |
-
else if (isset($json_object['code'])) {
|
990 |
-
$code = $json_object['code'];
|
991 |
-
unset($json_object['code']);
|
992 |
-
$json[$code] = $json_object;
|
993 |
-
} else $json[] = $json_object;
|
994 |
-
}
|
995 |
-
$to_ignore = trim($config_string);
|
996 |
-
if ($to_ignore) {
|
997 |
-
$bracket_pos = strpos($to_ignore, '}');
|
998 |
-
if ($bracket_pos!==false) {
|
999 |
-
$to_ignore = explode('}', $to_ignore, 2);
|
1000 |
-
}
|
1001 |
-
$to_ignore = (array)$to_ignore;
|
1002 |
-
foreach ($to_ignore as $to_ignore_i) {
|
1003 |
-
$to_ignore_i = trim($to_ignore_i);
|
1004 |
-
if (!$to_ignore_i) continue;
|
1005 |
-
$auto_correction_warnings[] = 'JSON: ignored lines (<span class=osh-formula>'.self::toString($to_ignore_i).'</span>)';
|
1006 |
-
$n = 0;
|
1007 |
-
do {
|
1008 |
-
$key = 'meta'.$n;
|
1009 |
-
$n++;
|
1010 |
-
} while(isset($json[$key]));
|
1011 |
-
$json[$key] = array(
|
1012 |
-
'type' => 'meta',
|
1013 |
-
'ignored' => $to_ignore_i,
|
1014 |
-
);
|
1015 |
-
}
|
1016 |
-
}
|
1017 |
-
$config_string = $this->jsonEncode($json);//'['.$config_string2.']';
|
1018 |
-
$config_string = str_replace(array("\n"), array("\\n"), $config_string);
|
1019 |
-
//echo $config_string;
|
1020 |
-
|
1021 |
-
$last_json_error = null;
|
1022 |
-
try {
|
1023 |
-
$config = self::json_decode($config_string);
|
1024 |
-
} catch (Exception $e) {
|
1025 |
-
$last_json_error = $e;
|
1026 |
-
}
|
1027 |
-
}
|
1028 |
-
if ($last_json_error) {
|
1029 |
-
$auto_correction_warnings[] = 'JSON: unable to parse config ('.$last_json_error->getMessage().')';
|
1030 |
-
}
|
1031 |
-
|
1032 |
-
$row = null;
|
1033 |
-
$auto_correction_warnings = array_unique($auto_correction_warnings);
|
1034 |
-
foreach ($auto_correction_warnings as $key => $warning) {
|
1035 |
-
if ($key=='missing_enquote_of_property_name') {
|
1036 |
-
$missing_enquote_of_property_name = array_unique($missing_enquote_of_property_name);
|
1037 |
-
$warning = str_replace('%s', '<span class=osh-key>'.self::esc(implode('</span>, <span class=osh-key>', $missing_enquote_of_property_name)).'</span>', $warning);
|
1038 |
-
}
|
1039 |
-
$this->addMessage('warning', $row, null, $warning);
|
1040 |
-
}
|
1041 |
-
$config = (array)$config;
|
1042 |
-
|
1043 |
-
$this->_config = array();
|
1044 |
-
$available_keys = array('type', 'about', 'label', 'enabled', 'description', 'fees', 'conditions', 'shipto', 'billto', 'origin', 'customer_groups', 'tracking_url');
|
1045 |
-
$reserved_keys = array('*id');
|
1046 |
-
if ($auto_correction) {
|
1047 |
-
$available_keys = array_merge($available_keys, array(
|
1048 |
-
'destination', 'code',
|
1049 |
-
));
|
1050 |
-
}
|
1051 |
-
|
1052 |
-
$deprecated_properties = array();
|
1053 |
-
$unknown_properties = array();
|
1054 |
-
|
1055 |
-
foreach ($config as $code => $object) {
|
1056 |
-
$object = (array)$object;
|
1057 |
-
if ($auto_correction) {
|
1058 |
-
if (isset($object['destination'])) {
|
1059 |
-
if (!in_array('destination', $deprecated_properties)) $deprecated_properties[] = 'destination';
|
1060 |
-
$object['shipto'] = $object['destination'];
|
1061 |
-
unset($object['destination']);
|
1062 |
-
}
|
1063 |
-
if (isset($object['code'])) {
|
1064 |
-
if (!in_array('code', $deprecated_properties)) $deprecated_properties[] = 'code';
|
1065 |
-
$code = $object['code'];
|
1066 |
-
unset($object['code']);
|
1067 |
-
}
|
1068 |
-
}
|
1069 |
-
|
1070 |
-
$row = array();
|
1071 |
-
$i = 1;
|
1072 |
-
foreach ($object as $property_name => $property_value) {
|
1073 |
-
if (in_array($property_name, $reserved_keys)) {
|
1074 |
-
continue;
|
1075 |
-
}
|
1076 |
-
if (in_array($property_name, $available_keys)
|
1077 |
-
|| substr($property_name, 0, 1)=='_'
|
1078 |
-
|| in_array($object['type'], array('data', 'meta'))) {
|
1079 |
-
if (isset($property_value)) {
|
1080 |
-
$row[$property_name] = array('value' => $property_value, 'original_value' => $property_value);
|
1081 |
-
if ($auto_correction) $this->cleanProperty($row, $property_name);
|
1082 |
-
}
|
1083 |
-
} else {
|
1084 |
-
if (!in_array($property_name, $unknown_properties)) $unknown_properties[] = $property_name;
|
1085 |
-
}
|
1086 |
-
$i++;
|
1087 |
-
}
|
1088 |
-
$this->addRow($code, $row);
|
1089 |
-
}
|
1090 |
-
$row = null;
|
1091 |
-
if (count($unknown_properties)>0) $this->addMessage('error', $row, null, 'Usage of unknown properties %s', ': <span class=osh-key>'.implode('</span>, <span class=osh-key>', $unknown_properties).'</span>');
|
1092 |
-
if (count($deprecated_properties)>0) $this->addMessage('warning', $row, null, 'Usage of deprecated properties %s', ': <span class=osh-key>'.implode('</span>, <span class=osh-key>', $deprecated_properties).'</span>');
|
1093 |
-
}
|
1094 |
-
|
1095 |
-
public function addRow($code, &$row)
|
1096 |
-
{
|
1097 |
-
if ($code) {
|
1098 |
-
if (isset($this->_config[$code])) $this->addMessage('error', $row, 'code', 'The id must be unique, `%s` has been found twice', $code);
|
1099 |
-
while (isset($this->_config[$code])) $code .= rand(0, 9);
|
1100 |
-
}
|
1101 |
-
$row['*id'] = $code;
|
1102 |
-
$this->_config[$code] = $row;
|
1103 |
-
}
|
1104 |
-
|
1105 |
-
public function addMessage($type, &$row, $property)
|
1106 |
-
{
|
1107 |
-
$args = func_get_args();
|
1108 |
-
array_shift($args);
|
1109 |
-
array_shift($args);
|
1110 |
-
array_shift($args);
|
1111 |
-
$message = new OS_Message($type, $args);
|
1112 |
-
if (isset($row)) {
|
1113 |
-
if (isset($property)) {
|
1114 |
-
$row[$property]['messages'][] = $message;
|
1115 |
-
} else {
|
1116 |
-
$row['*messages'][] = $message;
|
1117 |
-
}
|
1118 |
-
}
|
1119 |
-
$this->_messages[] = $message;
|
1120 |
-
$this->debug(' => <span class=osh-'.$message->type.'>'.self::esc((string)$message).'</span>');
|
1121 |
-
}
|
1122 |
-
|
1123 |
-
protected function _replaceVariable(&$process, $input, $original, $replacement)
|
1124 |
-
{
|
1125 |
-
if (mb_strpos($input, '{'.$original.'}')!==false) {
|
1126 |
-
$input = $this->replace('{'.$original.'}', $this->_autoEscapeStrings($replacement), $input);
|
1127 |
-
}
|
1128 |
-
if (mb_strpos($input, $original)!==false) {
|
1129 |
-
if (!isset($process['options']->auto_escaping) || $process['options']->auto_escaping) {
|
1130 |
-
$input = $this->replace($original, $this->_autoEscapeStrings($replacement), $input);
|
1131 |
-
} else {
|
1132 |
-
$input = $this->replace($original, $replacement, $input);
|
1133 |
-
}
|
1134 |
-
}
|
1135 |
-
return $input;
|
1136 |
-
}
|
1137 |
-
|
1138 |
-
protected function _replaceData(&$process, $input, $keys = '', $aliases = array())
|
1139 |
-
{
|
1140 |
-
$keys = ($keys ? $keys.'|' : '').implode('|', array_keys($process['data']));
|
1141 |
-
$keys = preg_replace('/[^a-z_\|]/', '_', $keys);
|
1142 |
-
// data
|
1143 |
-
while ($this->_preg_match("#{({$keys})\.([a-z0-9_\+\-\.]+)}#i", $input, $result)) {
|
1144 |
-
$original = $result[0];
|
1145 |
-
$object_name = isset($aliases[$result[1]]) ? $aliases[$result[1]] : $result[1];
|
1146 |
-
$replacement = $this->_loadValue($process, $object_name, $result[2]);
|
1147 |
-
$input = $this->_replaceVariable($process, $input, $original, $replacement);
|
1148 |
-
}
|
1149 |
-
return $input;
|
1150 |
-
}
|
1151 |
-
|
1152 |
-
protected function _addressMatch(&$process, &$row, $property_name, $address_filter, $address)
|
1153 |
-
{
|
1154 |
-
//$address_filter = '(* - ( europe (FR-(25,26),DE(40,42) ))';
|
1155 |
-
//echo '<pre>';
|
1156 |
-
$address_filter = $this->_replaceData($process, $address_filter);
|
1157 |
-
$parser = new OS2_AddressFilterParser();
|
1158 |
-
$address_filter = $parser->parse($address_filter);
|
1159 |
-
|
1160 |
-
$this->debug(' address filter = <span class=osh-formula>'.self::esc($address_filter).'</span>');
|
1161 |
-
$data = array(
|
1162 |
-
'{c}' => $address->country_id,
|
1163 |
-
'{p}' => $address->postcode,
|
1164 |
-
'{r}' => $address->region_code,
|
1165 |
-
);
|
1166 |
-
foreach ($data as $original => $replacement) {
|
1167 |
-
$address_filter = $this->_replaceVariable($process, $address_filter, $original, $replacement);
|
1168 |
-
}
|
1169 |
-
return (bool)$this->_evalFormula($address_filter, $row, $property_name, $is_checking=false);
|
1170 |
-
}
|
1171 |
-
|
1172 |
-
protected function _getItemProperty($item, $property_name)
|
1173 |
-
{
|
1174 |
-
$elems = explode('.', $property_name, $limit=2);
|
1175 |
-
switch ($elems[0]) {
|
1176 |
-
case 'p':
|
1177 |
-
case 'product': return $item->getProduct()->{$elems[1]};
|
1178 |
-
case 'item': return $item->{$elems[1]};
|
1179 |
-
}
|
1180 |
-
return null;
|
1181 |
-
}
|
1182 |
-
|
1183 |
-
protected function _autoEscapeStrings($input)
|
1184 |
-
{
|
1185 |
-
if (is_array($input)) {
|
1186 |
-
$items = array();
|
1187 |
-
foreach ($input as $v) {
|
1188 |
-
$items[] = isset($v) && (is_string($v) || empty($v)) ? self::escapeString($v) : self::toString($v);
|
1189 |
-
}
|
1190 |
-
return 'array('.join(',', $items).')';
|
1191 |
-
} else {
|
1192 |
-
return isset($input) && (is_string($input)/* || empty($input)*/) ? self::escapeString($input) : self::toString($input);
|
1193 |
-
}
|
1194 |
-
}
|
1195 |
-
|
1196 |
-
protected function _processProduct($items, $regex_result, &$row, $property_name, $is_checking)
|
1197 |
-
{
|
1198 |
-
// count, sum, min, max, count distinct
|
1199 |
-
$operation = strtolower($regex_result[1]);
|
1200 |
-
$return_value = null;
|
1201 |
-
$reference = 'items';
|
1202 |
-
switch ($operation) {
|
1203 |
-
case 'sum':
|
1204 |
-
case 'min':
|
1205 |
-
case 'max':
|
1206 |
-
case 'count distinct':
|
1207 |
-
$reference = $regex_result[2];
|
1208 |
-
$conditions = isset($regex_result[3]) ? $regex_result[3] : null;
|
1209 |
-
break;
|
1210 |
-
case 'count':
|
1211 |
-
$conditions = isset($regex_result[2]) ? $regex_result[2] : null;
|
1212 |
-
break;
|
1213 |
-
}
|
1214 |
-
switch ($operation) {
|
1215 |
-
case 'sum':
|
1216 |
-
case 'count distinct':
|
1217 |
-
case 'count':
|
1218 |
-
$return_value = 0;
|
1219 |
-
break;
|
1220 |
-
}
|
1221 |
-
|
1222 |
-
$this->debug(' <span class=osh-loop>start <span class=osh-replacement>'.self::esc($operation).'</span> '
|
1223 |
-
.'<span class=osh-key>'.self::esc($reference).'</span>'
|
1224 |
-
.(isset($conditions) ? ' where <span class=osh-replacement>'.self::esc($conditions).'</span></span>' : '')
|
1225 |
-
);
|
1226 |
-
$this->addDebugIndent();
|
1227 |
-
|
1228 |
-
$properties = array();
|
1229 |
-
$this->_preg_match_all('#(?:item|product|p)\.([a-z0-9_\+\-\.]+)#i', $conditions, $properties_regex_result);
|
1230 |
-
foreach ($properties_regex_result as $property_regex_result) {
|
1231 |
-
if (!isset($properties[$property_regex_result[0]])) $properties[$property_regex_result[0]] = $property_regex_result;
|
1232 |
-
}
|
1233 |
-
krsort($properties); // To avoid shorter replace
|
1234 |
-
|
1235 |
-
if ($items) {
|
1236 |
-
foreach ($items as $item) {
|
1237 |
-
$this->debug(' <span class=osh-loop>• item</span> = <span class=osh-formula>'.self::esc((string)$item).'</span>');
|
1238 |
-
$this->addDebugIndent();
|
1239 |
-
if (isset($conditions) && $conditions!='') {
|
1240 |
-
$formula = $conditions;
|
1241 |
-
foreach ($properties as $property) {
|
1242 |
-
$value = $this->_getItemProperty($item, $property[0]);
|
1243 |
-
$from = $property[0];
|
1244 |
-
$to = $this->_autoEscapeStrings($value);
|
1245 |
-
$this->debug(' replace <span class=osh-replacement>'.self::esc($from).'</span> by <span class=osh-replacement>'.self::esc($to).'</span> => <span class=osh-formula>'.self::esc(str_replace($from, '<span class=osh-replacement>'.$to.'</span>', $formula)).'</span>');
|
1246 |
-
$formula = str_replace($from, $to, $formula);
|
1247 |
-
}
|
1248 |
-
$eval_result = $this->_evalFormula($formula, $row, $property_name, $is_checking);
|
1249 |
-
if (!isset($eval_result)) $return_value = 'null';
|
1250 |
-
}
|
1251 |
-
else $eval_result = true;
|
1252 |
-
|
1253 |
-
if ($eval_result==true) {
|
1254 |
-
if ($operation=='count') {
|
1255 |
-
$return_value = (isset($return_value) ? $return_value : 0) + $item->qty;
|
1256 |
-
} else {
|
1257 |
-
$value = $this->_getItemProperty($item, $reference);
|
1258 |
-
$this->debug(' » <span class=osh-key>'.self::esc($reference).'</span> = <span class=osh-formula>'.self::esc($value).'</span>'
|
1259 |
-
.($operation=='sum' ? ' x <span class=osh-formula>'.$item->qty.'</span>' : ''));
|
1260 |
-
switch ($operation) {
|
1261 |
-
case 'min': if (!isset($return_value) || $value<$return_value) $return_value = $value; break;
|
1262 |
-
case 'max': if (!isset($return_value) || $value>$return_value) $return_value = $value; break;
|
1263 |
-
case 'sum':
|
1264 |
-
//$this->debug(self::esc($item->getProduct()->sku).'.'.self::esc($reference).' = "'.self::esc($value).'" x '.self::esc($item->qty));
|
1265 |
-
$return_value = (isset($return_value) ? $return_value : 0) + $value*$item->qty;
|
1266 |
-
break;
|
1267 |
-
case 'count distinct':
|
1268 |
-
if (!isset($return_value)) $return_value = 0;
|
1269 |
-
if (!isset($distinct_values)) $distinct_values = array();
|
1270 |
-
if (!in_array($value, $distinct_values)) {
|
1271 |
-
$distinct_values[] = $value;
|
1272 |
-
$return_value++;
|
1273 |
-
}
|
1274 |
-
break;
|
1275 |
-
}
|
1276 |
-
}
|
1277 |
-
}
|
1278 |
-
$this->debug(' » <span class=osh-info>'.self::esc($operation).' result</span> = <span class=osh-formula>'.self::esc($return_value).'</span>');
|
1279 |
-
$this->removeDebugIndent();
|
1280 |
-
}
|
1281 |
-
}
|
1282 |
-
|
1283 |
-
$this->removeDebugIndent();
|
1284 |
-
$this->debug(' <span class=osh-loop>end</span>');
|
1285 |
-
|
1286 |
-
return $return_value;
|
1287 |
-
}
|
1288 |
-
|
1289 |
-
/* For auto correction */
|
1290 |
-
public function cleanProperty(&$row, $key)
|
1291 |
-
{
|
1292 |
-
$input = $row[$key]['value'];
|
1293 |
-
if (is_string($input)) {
|
1294 |
-
while (preg_match('/{{customVar code=([a-zA-Z0-9_-]+)}}/', $input, $resi)) {
|
1295 |
-
$input = $this->replace($resi[0], '{customvar.'.$resi[1].'}', $input, 'warning', 'replace deprecated');
|
1296 |
-
}
|
1297 |
-
|
1298 |
-
$regex = "{(weight|products_quantity|price_including_tax|price_excluding_tax|country)}";
|
1299 |
-
if (preg_match('/'.$regex.'/', $input, $resi)) {
|
1300 |
-
$this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class=osh-formula>'.$resi[0].'</span>');
|
1301 |
-
while (preg_match('/'.$regex.'/', $input, $resi)) {
|
1302 |
-
switch ($resi[1]) {
|
1303 |
-
case 'price_including_tax': $to = "{cart.price+tax+discount}"; break;
|
1304 |
-
case 'price_excluding_tax': $to = "{cart.price-tax+discount}"; break;
|
1305 |
-
case 'weight': $to = "{cart.{$resi[1]}}"; break;
|
1306 |
-
case 'products_quantity': $to = "{cart.qty}"; break;
|
1307 |
-
case 'country': $to = "{shipto.country_name}"; break;
|
1308 |
-
}
|
1309 |
-
$input = str_replace($resi[0], $to, $input);
|
1310 |
-
}
|
1311 |
-
}
|
1312 |
-
|
1313 |
-
$regex1 = "{copy '([a-zA-Z0-9_]+)'\.'([a-zA-Z0-9_]+)'}";
|
1314 |
-
if (preg_match('/'.$regex1.'/', $input, $resi)) {
|
1315 |
-
$this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class=osh-formula>'.$resi[0].'</span>');
|
1316 |
-
while (preg_match('/'.$regex1.'/', $input, $resi)) $input = str_replace($resi[0], '{'.$resi[1].'.'.$resi[2].'}', $input);
|
1317 |
-
}
|
1318 |
-
|
1319 |
-
$regex1 = "{(count|all|any) (attribute|option) '([^'\)]+)' ?((?:==|<=|>=|<|>|!=) ?(?:".self::FLOAT_REGEX."|true|false|'[^'\)]*'))}";
|
1320 |
-
$regex2 = "{(sum) (attribute|option) '([^'\)]+)'}";
|
1321 |
-
if (preg_match('/'.$regex1.'/', $input, $resi) || preg_match('/'.$regex2.'/', $input, $resi)) {
|
1322 |
-
$this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class=osh-formula>'.$resi[0].'</span>');
|
1323 |
-
while (preg_match('/'.$regex1.'/', $input, $resi) || preg_match('/'.$regex2.'/', $input, $resi)) {
|
1324 |
-
switch ($resi[1]) {
|
1325 |
-
case 'count': $to = "{count items where product.{$resi[2]}.{$resi[3]}{$resi[4]}}"; break;
|
1326 |
-
case 'all': $to = "{count items where product.{$resi[2]}.{$resi[3]}{$resi[4]}}=={cart.qty}"; break;
|
1327 |
-
case 'any': $to = "{count items where product.{$resi[2]}.{$resi[3]}{$resi[4]}}>0"; break;
|
1328 |
-
case 'sum': $to = "{sum product.{$resi[2]}.{$resi[3]}}"; break;
|
1329 |
-
}
|
1330 |
-
$input = str_replace($resi[0], $to, $input);
|
1331 |
-
}
|
1332 |
-
}
|
1333 |
-
|
1334 |
-
$regex = "((?:{| )product.(?:attribute|option))s.";
|
1335 |
-
if (preg_match('/'.$regex.'/', $input, $resi)) {
|
1336 |
-
$this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class=osh-formula>'.$resi[0].'</span>');
|
1337 |
-
while (preg_match('/'.$regex.'/', $input, $resi)) {
|
1338 |
-
$input = str_replace($resi[0], $resi[1].'.', $input);
|
1339 |
-
}
|
1340 |
-
}
|
1341 |
-
|
1342 |
-
$regex = "{table '([^']+)' (".self::COUPLE_REGEX."(?:, *".self::COUPLE_REGEX.")*)}";
|
1343 |
-
if (preg_match('/'.$regex.'/', $input, $resi)) {
|
1344 |
-
$this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class=osh-formula>'.$resi[0].'</span>');
|
1345 |
-
while (preg_match('/'.$regex.'/', $input, $resi)) {
|
1346 |
-
switch ($resi[1]) {
|
1347 |
-
case 'products_quantity':
|
1348 |
-
$input = str_replace($resi[0], "{table {cart.weight} in {$resi[2]}}*{cart.qty}", $input);
|
1349 |
-
break;
|
1350 |
-
default:
|
1351 |
-
$input = str_replace($resi[0], "{table {cart.{$resi[1]}} in {$resi[2]}}", $input);
|
1352 |
-
break;
|
1353 |
-
}
|
1354 |
-
}
|
1355 |
-
}
|
1356 |
-
|
1357 |
-
$aliases = array(
|
1358 |
-
'{destination.country.code}' => '{shipto.country_id}',
|
1359 |
-
'{destination.country.name}' => '{shipto.country_name}',
|
1360 |
-
'{destination.region.code}' => '{shipto.region_code}',
|
1361 |
-
'{destination.postcode}' => '{shipto.postcode}',
|
1362 |
-
'.destination}' => '.shipto}',
|
1363 |
-
'{cart.price_excluding_tax}' => '{cart.price-tax+discount}',
|
1364 |
-
'{cart.price_including_tax}' => '{cart.price+tax+discount}',
|
1365 |
-
'{cart.weight.unit}' => '{cart.weight_unit}',
|
1366 |
-
'{cart.coupon}' => '{cart.coupon_code}',
|
1367 |
-
'{cart.weight.for-charge}' => '{cart.weight_for_charge}',
|
1368 |
-
'{c.price_excluding_tax}' => '{c.price-tax+discount}',
|
1369 |
-
'{c.price_including_tax}' => '{c.price+tax+discount}',
|
1370 |
-
'{c.weight.unit}' => '{c.weight_unit}',
|
1371 |
-
'{c.coupon}' => '{c.coupon_code}',
|
1372 |
-
'{free_shipping}' => '{cart.free_shipping}',
|
1373 |
-
'{c.weight.for-charge}' => '{c.weight_for_charge}',
|
1374 |
-
'{customer.group.id}' => '{customer_group.id}',
|
1375 |
-
'{customer.group.code}' => '{customer_group.code}',
|
1376 |
-
'{origin.country.code}' => '{origin.country_id}',
|
1377 |
-
'{origin.country.name}' => '{origin.country_name}',
|
1378 |
-
'{origin.region.code}' => '{origin.region_id}',
|
1379 |
-
'{selection.quantity}' => '{selection.qty}',
|
1380 |
-
'product.quantity' => 'item.qty',
|
1381 |
-
'product.stock.quantity' => 'product.stock.qty',
|
1382 |
-
'product.options.' => 'item.option.',
|
1383 |
-
'product.option.' => 'item.option.',
|
1384 |
-
'product.o.' => 'item.o.',
|
1385 |
-
'p.quantity' => 'item.qty',
|
1386 |
-
'p.stock.quantity' => 'p.stock.qty',
|
1387 |
-
'p.options.' => 'item.option.',
|
1388 |
-
'p.option.' => 'item.option.',
|
1389 |
-
'p.o.' => 'item.o.',
|
1390 |
-
'count products ' => 'count items ',
|
1391 |
-
'product.attribute.price+tax+discount' => 'item.price+tax+discount',
|
1392 |
-
'product.attribute.price+tax-discount' => 'item.price+tax-discount',
|
1393 |
-
'product.attribute.price-tax+discount' => 'item.price-tax+discount',
|
1394 |
-
'product.attribute.price-tax-discount' => 'item.price-tax-discount',
|
1395 |
-
);
|
1396 |
-
foreach ($aliases as $from => $to) {
|
1397 |
-
if (mb_strpos($input, $from)!==false) {
|
1398 |
-
$input = $this->replace($from, $to, $input, 'warning', 'replace deprecated');
|
1399 |
-
}
|
1400 |
-
}
|
1401 |
-
}
|
1402 |
-
$row[$key]['value'] = $input;
|
1403 |
-
}
|
1404 |
-
|
1405 |
-
}
|
1406 |
-
|
1407 |
-
class OS2_Data
|
1408 |
-
{
|
1409 |
-
protected $_data;
|
1410 |
-
|
1411 |
-
public function __construct($data=null)
|
1412 |
-
{
|
1413 |
-
$this->_data = (array)$data;
|
1414 |
-
}
|
1415 |
-
|
1416 |
-
public function __sleep()
|
1417 |
-
{
|
1418 |
-
return array_keys($this->_data);
|
1419 |
-
}
|
1420 |
-
|
1421 |
-
public function __get($name)
|
1422 |
-
{
|
1423 |
-
return isset($this->_data[$name]) ? $this->_data[$name] : null;
|
1424 |
-
}
|
1425 |
-
|
1426 |
-
public function set($name, $value)
|
1427 |
-
{
|
1428 |
-
$this->_data[$name] = $value;
|
1429 |
-
}
|
1430 |
-
}
|
1431 |
-
|
1432 |
-
class OS_Message
|
1433 |
-
{
|
1434 |
-
public $type;
|
1435 |
-
public $message;
|
1436 |
-
public $args;
|
1437 |
-
|
1438 |
-
public function __construct($type, $args)
|
1439 |
-
{
|
1440 |
-
$this->type = $type;
|
1441 |
-
$this->message = array_shift($args);
|
1442 |
-
$this->args = $args;
|
1443 |
-
}
|
1444 |
-
|
1445 |
-
public function __toString()
|
1446 |
-
{
|
1447 |
-
return vsprintf($this->message, $this->args);
|
1448 |
-
}
|
1449 |
-
}
|
1450 |
-
|
1451 |
-
class OS_Result
|
1452 |
-
{
|
1453 |
-
public $success;
|
1454 |
-
public $result;
|
1455 |
-
|
1456 |
-
public function __construct($success, $result=null)
|
1457 |
-
{
|
1458 |
-
$this->success = $success;
|
1459 |
-
$this->result = $result;
|
1460 |
-
}
|
1461 |
-
|
1462 |
-
public function __toString()
|
1463 |
-
{
|
1464 |
-
return OwebiaShippingHelper::toString($this->result);
|
1465 |
-
}
|
1466 |
-
}
|
1467 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1,11 +1,20 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
//UPDATE `magento__core_config_data` SET `path` = REPLACE(`path`, 'owebia_shipping2/', 'owebia-shipping2/') WHERE `path` LIKE 'owebia_shipping2/%';
|
4 |
-
//DELETE FROM `magento__core_resource` WHERE code = 'owebia_shipping2_setup';
|
5 |
-
|
6 |
$installer = $this; /* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
$installer->startSetup();
|
8 |
-
$installer->run(
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
$installer->endSetup();
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
3 |
$installer = $this; /* @var $installer Mage_Core_Model_Resource_Setup */
|
4 |
$installer->startSetup();
|
5 |
+
$installer->run(
|
6 |
+
"UPDATE `{$this->getTable('core_config_data')}`
|
7 |
+
SET `path` = REPLACE(`path`, 'owebia-shipping2/bundle-product/', 'owebia_shipping2/bundle_product/')
|
8 |
+
WHERE `path` LIKE 'owebia-shipping2/bundle-product/%';"
|
9 |
+
);
|
10 |
+
$installer->run(
|
11 |
+
"UPDATE `{$this->getTable('core_config_data')}`
|
12 |
+
SET `path` = REPLACE(`path`, 'owebia-shipping2/configurable-product/', 'owebia_shipping2/configurable_product/')
|
13 |
+
WHERE `path` LIKE 'owebia-shipping2/configurable-product/%';"
|
14 |
+
);
|
15 |
+
$installer->run(
|
16 |
+
"UPDATE `{$this->getTable('core_config_data')}`
|
17 |
+
SET `path` = REPLACE(`path`, 'owebia-shipping2/', 'owebia_shipping2/')
|
18 |
+
WHERE `path` LIKE 'owebia-shipping2/%';"
|
19 |
+
);
|
20 |
$installer->endSetup();
|
@@ -1,23 +1,8 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<!--
|
3 |
/**
|
4 |
-
*
|
5 |
-
*
|
6 |
-
* NOTICE OF LICENSE
|
7 |
-
*
|
8 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
-
* that is bundled with this package in the file LICENSE.txt.
|
10 |
-
* It is also available through the world-wide-web at this URL:
|
11 |
-
* http://opensource.org/licenses/osl-3.0.php
|
12 |
-
* If you did not receive a copy of the license and are unable to
|
13 |
-
* obtain it through the world-wide-web, please send an email
|
14 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
-
*
|
16 |
-
* @category Owebia
|
17 |
-
* @package Owebia_Shipping
|
18 |
-
* @copyright Copyright (c) 2008-14 Owebia (http://www.owebia.com)
|
19 |
-
* @author Antoine Lemoine
|
20 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
*/
|
22 |
-->
|
23 |
<config>
|
1 |
<?xml version="1.0"?>
|
2 |
<!--
|
3 |
/**
|
4 |
+
* Copyright © 2008-2016 Owebia. All rights reserved.
|
5 |
+
* See COPYING.txt for license details.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
*/
|
7 |
-->
|
8 |
<config>
|
@@ -74,8 +74,6 @@
|
|
74 |
"Export","Export"
|
75 |
"Add a shipping method","Add a shipping method"
|
76 |
"New shipping method","New shipping method"
|
77 |
-
"You appreciate this extension and would like to help?","You appreciate this extension and would like to help?"
|
78 |
-
"{os2editor.donate-page.content}","<p>The extension Owebia Shipping 2 is offered by the company Owebia (<a href=""http://www.owebia.com/"">http://www.owebia.com/</a>).<br/>If you want to support the developement of the extension, you can make a donation.</p><p>You will receive an invoice to keep trace of the donation.</p><p>Thanks to all donators.</p>"
|
79 |
|
80 |
# app/code/community/Owebia/Shipping2/etc/system.xml
|
81 |
"Configuration","Configuration"
|
@@ -99,7 +97,7 @@
|
|
99 |
"Item data on","Item data on"
|
100 |
"Product data on","Product data on"
|
101 |
|
102 |
-
# app/code/community/Owebia/Shipping2/
|
103 |
"Configuration disabled","Configuration disabled"
|
104 |
"The cart doesn't match conditions","The cart doesn't match conditions"
|
105 |
"Infinite loop %s","Infinite loop %s"
|
@@ -124,727 +122,3 @@
|
|
124 |
# app/code/community/Owebia/Shipping2/Model/System/Config/Source/LoadOnParent.php
|
125 |
"Self","Self"
|
126 |
"Parent","Parent"
|
127 |
-
|
128 |
-
# Help
|
129 |
-
"{os2editor.help.summary}","
|
130 |
-
<h4>Summary</h4>
|
131 |
-
<div class=""table-of-contents"">
|
132 |
-
<table><tr>
|
133 |
-
<td>
|
134 |
-
<ol class=level1>
|
135 |
-
<li class=new><a href=""#introduction"">Introduction: JSON syntax, items and properties</a></li>
|
136 |
-
<li><a href=""#unique_id"">The unique identifier</a></li>
|
137 |
-
<li class=new>The item types:
|
138 |
-
<ul>
|
139 |
-
<li><a href=""#type_method""><property>method</property>: shipping method</a></li>
|
140 |
-
<li><a href=""#type_data""><property>data</property>: data</a></li>
|
141 |
-
<li><a href=""#type_meta""><property>meta</property>: meta data</a></li>
|
142 |
-
</ul>
|
143 |
-
</li>
|
144 |
-
<li class=new>Common properties:
|
145 |
-
<ul>
|
146 |
-
<li><a href=""#property_type""><property>type</property>: the type of the item</a></li>
|
147 |
-
<li><a href=""#property_about""><property>about</property>: comment on the item</a></li>
|
148 |
-
</ul>
|
149 |
-
</li>
|
150 |
-
<li>Properties of <property>method</property> items:
|
151 |
-
<ul>
|
152 |
-
<li class=important><a href=""#property_label""><property>label</property></a></li>
|
153 |
-
<li><a href=""#property_description""><property>description</property></a></li>
|
154 |
-
<li class=important><a href=""#property_conditions""><property>conditions</property></a></li>
|
155 |
-
<li class=new><a href=""#property_shipto""><property>shipto</property>: the shipping address</a> (<property>destination</property> bef. 2.4.8)</li>
|
156 |
-
<li class=new><a href=""#property_shipto""><property>billto</property>: the billing address</a> (since 2.4.8)</li>
|
157 |
-
<li><a href=""#property_shipto""><property>origin</property>: the origin address</a></li>
|
158 |
-
<li><a href=""#property_customer_groups""><property>customer_groups</property></a></li>
|
159 |
-
<li class=important><a href=""#property_fees""><property>fees</property>: the shipping fees</a></li>
|
160 |
-
<li><a href=""#property_tracking_url""><property>tracking_url</property></a></li>
|
161 |
-
<li><a href=""#property_enabled""><property>enabled</property></a></li>
|
162 |
-
</ul>
|
163 |
-
</li>
|
164 |
-
</ol>
|
165 |
-
</td>
|
166 |
-
<td>
|
167 |
-
<ol class=level1 start=6>
|
168 |
-
<li><a href=""#more_formulas"">Introduction to Formulas</a>
|
169 |
-
<ol>
|
170 |
-
<li class=new><a href=""#more_vars"">Available variables</a></li>
|
171 |
-
<li class=new><a href=""#more_special-functions"">Special Functions in Formulas</a> (update 2.5)<br/> min, max, range, substr, in_array, array_match_any, array_match_all</li>
|
172 |
-
<li><a href=""#more_copy"">Make a copy of a property from an other item</a></li>
|
173 |
-
<li><a href=""#more_tables"">Using <c>table</c></a></li>
|
174 |
-
<li><a href=""#more_switch"">Using <c>switch</c></a> (update 2.4.5)</li>
|
175 |
-
<li class=new><a href=""#more_attributes-options"">Using product properties (sum, count, min, max)</a> (update 2.4.8)</li>
|
176 |
-
<li><a href=""#more_foreach"">Using <c>foreach</c> loops</a></li>
|
177 |
-
<li class=new><a href=""#more_categories"">Particular case: examples of use of product categories</a> (update 2.5)</li>
|
178 |
-
</ol>
|
179 |
-
</li>
|
180 |
-
<li><a href=""#changelog"">Changelog</a></li>
|
181 |
-
</ol>
|
182 |
-
</td>
|
183 |
-
</tr></table>
|
184 |
-
</div>
|
185 |
-
"
|
186 |
-
"{os2editor.help.introduction}","
|
187 |
-
<h4>Introduction: JSON syntax, items and properties</h4>
|
188 |
-
<p class=new>
|
189 |
-
If you have a question, use the following topic: <a href=""http://www.magentocommerce.com/boards/viewthread/38223/"" target=_blank>http://www.magentocommerce.com/boards/viewthread/38223/</a>
|
190 |
-
</p>
|
191 |
-
|
192 |
-
<p>
|
193 |
-
<span class=new>Since version 2.5, the syntax of configuration is full JSON <a href=""http://en.wikipedia.org/wiki/JavaScript_Object_Notation"" target=_blank>JSON</a>.</span>
|
194 |
-
</p>
|
195 |
-
<p>
|
196 |
-
Example:
|
197 |
-
</p>
|
198 |
-
{code=json}{
|
199 |
-
""ex0"":{""about"":""National"",""label"":""National"",""shipto"":""AD,FR,MC"",""conditions"":""{cart.price-tax+discount}<1000.00"",""fees"":""1.30 + {table {cart.weight} in 0.5:5.30, 1.0:6.50, 2.0:7.40, 3.0:8.30, 5.0:10.10}""}
|
200 |
-
}{/code}
|
201 |
-
|
202 |
-
<p>
|
203 |
-
The configuration is a JSON object containing <strong>properties</strong>.<br/>
|
204 |
-
Each property has a unique name, wich will serve as <a href=""#unique_id"">unique identifier</a>.<br/>
|
205 |
-
Each property will consiste on a configuration <strong>item</strong> (also a JSON object).<br/>
|
206 |
-
</p>
|
207 |
-
<p>
|
208 |
-
Items have always a <property>type</property> property. This sets the type of the item:
|
209 |
-
</p>
|
210 |
-
<ul>
|
211 |
-
<li><a href=""#type_method""><property>method</property>: shipping method (default if not specified)</a></li>
|
212 |
-
<li><a href=""#type_data""><property>data</property>: data that can be used in shipping methods</a></li>
|
213 |
-
<li><a href=""#type_meta""><property>meta</property>: informative data</a></li>
|
214 |
-
</p>
|
215 |
-
"
|
216 |
-
"{os2editor.help.unique_id}","
|
217 |
-
<h4>The unique identifier</h4>
|
218 |
-
<p>Each configuration item has a unique identifier. This unique identifier is then used to reference the item.</p>
|
219 |
-
<p>Example:</p>
|
220 |
-
{code=json}{
|
221 |
-
""europe"":{""label"":""Europa"",""fees"":10},
|
222 |
-
""us"":{""label"":""US"",""fees"":""{europe.fees}+20""}
|
223 |
-
}{/code}
|
224 |
-
|
225 |
-
<p class=warning><strong><u>Warning</u>:</strong> to avoid conflicts, use only the following characters <c>a-z</c>, <c>A-Z</c>, <c>0-9</c>, <c>-</c> and <c>_</c> to make the unique identifier.<br/>You have also to avoid identifiers that match to any variable name (<c>cart</c>, <c>product</c>, <c>item</c>…).</p>
|
226 |
-
"
|
227 |
-
"{os2editor.help.type_method}","
|
228 |
-
<h4><property>method</property> item</h4>
|
229 |
-
<p>A <property>method</property> item allow to specify a shipping method.</p>
|
230 |
-
<p>Example with only required properties:</p>
|
231 |
-
{code=json}{
|
232 |
-
""ex0"":{""label"":""Free shipping"",""fees"":0}
|
233 |
-
}{/code}
|
234 |
-
<p>Full example:</p>
|
235 |
-
{code=json}{
|
236 |
-
""ex0"":{""about"":""Colissimo National"",""type"":""method"",""label"":""Colissimo"",""description"":""Delivery within 24/48h"",""enabled"":true,""conditions"":""range({cart.weight},0.2,1.0)"",""shipto"":""FR(01,02,39600,/^25[0-9]{3}$/),CH,DE"",""billto"":""FR"",""origin"":""DE"",""customer_groups"":""NOT LOGGED IN,Retailer"",""fees"":""{table {cart.weight} in 0.5:5.30, 1.0:6.50}""}
|
237 |
-
}{/code}
|
238 |
-
"
|
239 |
-
"{os2editor.help.type_data}","
|
240 |
-
<h4><property>data</property> item</h4>
|
241 |
-
<p>A <property>data</property> item allow to specify data that can be used in shipping methods.</p>
|
242 |
-
<p>Example of <property>data</property> item:</p>
|
243 |
-
{code=json}{
|
244 |
-
""mydata"":{""type"":""data"",""reference"":""100""}
|
245 |
-
}{/code}
|
246 |
-
<p>Example of data usage:</p>
|
247 |
-
{code=json}{
|
248 |
-
""ex0"":{""type"":""method"",""label"":""Colissimo"",""fees"":""{mydata.reference}*1.5""}
|
249 |
-
}{/code}
|
250 |
-
"
|
251 |
-
"{os2editor.help.type_meta}","
|
252 |
-
<h4><property>meta</property> item</h4>
|
253 |
-
<p>A <property>meta</property> item allow to add informative data (author, date…).</p>
|
254 |
-
<p>Example:</p>
|
255 |
-
{code=json}{
|
256 |
-
""about"":{""type"":""meta"",""author"":""Owebia"",""date"":""16/11/2012"",""about"":""Prices 2012""}
|
257 |
-
}{/code}
|
258 |
-
"
|
259 |
-
"{os2editor.help.property_type}","
|
260 |
-
<h4><property>type</property>: the type of the item</h4>
|
261 |
-
<p>This sets the type of the item:</p>
|
262 |
-
<ul>
|
263 |
-
<li><a href=""#type_method""><property>method</property>: shipping method (default if not specified)</a></li>
|
264 |
-
<li><a href=""#type_data""><property>data</property>: data that can be used in shipping methods</a></li>
|
265 |
-
<li><a href=""#type_meta""><property>meta</property>: informative data</a></li>
|
266 |
-
</p>
|
267 |
-
{code=json}{
|
268 |
-
""about"":{""type"":""meta"",""author"":""Owebia"",""date"":""16/11/2012"",""about"":""Prices 2012""},
|
269 |
-
""mydata"":{""type"":""data"",""reference"":""100""},
|
270 |
-
""ex0"":{""type"":""method"",""label"":""Colissimo"",""fees"":""{mydata.reference}*1.5""}
|
271 |
-
}{/code}
|
272 |
-
"
|
273 |
-
"{os2editor.help.property_about}","
|
274 |
-
<h4><property>about</property>: comment on the item</h4>
|
275 |
-
<p>You can add a comment to a configuration item.</p>
|
276 |
-
{code=json}{""ex0"":{""about"":""My comment"",""label"":""Example with a comment"",""fees"":10}}{/code}
|
277 |
-
"
|
278 |
-
"{os2editor.help.property_label}","
|
279 |
-
<h4>The <property>label</property></h4>
|
280 |
-
<p>The name given to the shipping method.</p>
|
281 |
-
<p>We can insert some data like the package weight in the label.<br/>
|
282 |
-
To do that, use the following variables:</p>
|
283 |
-
<ul>
|
284 |
-
<li>The shipping address:
|
285 |
-
<ul>
|
286 |
-
<li class=new><c><strike>{destination.country.name}</strike> {shipto.country_name}</c></li>
|
287 |
-
<li class=new><c><strike>{destination.country.code}</strike> {shipto.country_id}</c></li>
|
288 |
-
<li class=new><c><strike>{destination.region.code}</strike> {shipto.region_code}</c></li>
|
289 |
-
<li class=new><c><strike>{destination.postcode}</strike> {shipto.postcode}</c></li>
|
290 |
-
</ul>
|
291 |
-
</li>
|
292 |
-
<li><c>{cart.weight}</c>: the package weight</li>
|
293 |
-
<li class=new><c><strike>{cart.weight.unit}</strike> {cart.weight_unit}</c>: the weight unit</li>
|
294 |
-
<li><a href=""#more_vars"">See the full list of variables</a></li>
|
295 |
-
</ul>
|
296 |
-
{code=json}{
|
297 |
-
""ex0"":{""label"":""Colissimo ({cart.weight} / {shipto.country_name})"",""fees"":10}
|
298 |
-
}{/code}
|
299 |
-
<p>The above line will display for example <string>""Colissimo (3.0kg / France)""</string>.</p>
|
300 |
-
"
|
301 |
-
"{os2editor.help.property_description}","
|
302 |
-
<h4>The <property>description</property></h4>
|
303 |
-
<p>The description of the shipping method.</p>
|
304 |
-
<p>The usage is the same as <a href=""#property_label""><property>label</property></a> property.</p>
|
305 |
-
"
|
306 |
-
"{os2editor.help.property_conditions}","
|
307 |
-
<h4><property>conditions</property></h4>
|
308 |
-
<p>
|
309 |
-
<property>conditions</property> property is specified as a <a href=""#more_formulas"">formula (see introduction to formulas)</a>
|
310 |
-
that must return a boolean value (<c>true</c> or <c>false</c>).
|
311 |
-
</p>
|
312 |
-
|
313 |
-
{code=json}{
|
314 |
-
""ex0"":{""label"":""Price from 0 to 70 incl. tax"",""conditions"":""{cart.price+tax+discount}<=70"",""fees"":10},
|
315 |
-
""ex1"":{""label"":""Price from 0 to 70 excl. tax"",""conditions"":""{cart.price-tax+discount}<=70"",""fees"":10},
|
316 |
-
""ex2"":{""label"":""Price from 20 excluded to 70 included"",""conditions"":""range({cart.price-tax+discount},20,70,false,true)"",""fees"":10},
|
317 |
-
""ex3"":{""label"":""Price from 10 included to 50 excluded"",""conditions"":""range({cart.price-tax+discount},10,50,true,false)"",""fees"":10},
|
318 |
-
""ex4"":{""label"":""Weight from 0.5 excluded to 3 included"",""conditions"":""range({cart.weight},0.5,3.0,false,true)"",""fees"":10},
|
319 |
-
""ex5"":{""label"":""Weight from 1 included to 5 excluded"",""conditions"":""range({cart.weight},1.0,5.0,true,false)"",""fees"":10},
|
320 |
-
""ex6"":{""label"":""Only if free shipping"",""conditions"":""{cart.free_shipping}"",""fees"":10},
|
321 |
-
""ex7"":{""label"":""Only if not free shipping"",""conditions"":""!{cart.free_shipping}"",""fees"":10},
|
322 |
-
""ex8"":{""label"":""If any product has a 'color' attribute equal to 'Blue'"",""conditions"":""{count items where product.attribute.color=='Blue'}>1"",""fees"":10},
|
323 |
-
""ex9"":{""label"":""If all products have 'size' option greater or equal to '1'"",""conditions"":""{count items where product.option.size>='1'}=={cart.qty}"",""fees"":10}
|
324 |
-
}{/code}
|
325 |
-
"
|
326 |
-
"{os2editor.help.property_shipto}","
|
327 |
-
<h4>Addresses: <property>shipto</property>, <property>billto</property> and <property>origin</property></h4>
|
328 |
-
<p>
|
329 |
-
The extension allow to filter addresses:
|
330 |
-
</p>
|
331 |
-
<ul>
|
332 |
-
<li class=new>The shipping address <strike><property>destination</property></strike> <property>shipto</property>.</li>
|
333 |
-
<li class=new>The billing address <property>billto</property></li>
|
334 |
-
<li>The origin address <property>origin</property></li>
|
335 |
-
</ul>
|
336 |
-
<p>
|
337 |
-
Country codes used are those used by Magento.<br/>
|
338 |
-
It's possible to specify region codes (only with <property>shipto</property>) or postcodes.
|
339 |
-
</p>
|
340 |
-
<p class=new>
|
341 |
-
You can use the wildcard character <c>*</c> or regular expressions to filter postcodes.<br/>
|
342 |
-
A regular expression must start and end width the character <c>/</c>. If you want to use characters <c>(</c>, <c>)</c> or <c>,</c>, you have to escape them with character <c>\</c> (ex: <string>""FR(/^25\([0-9]{3}\)$/)""</string>).<br/>
|
343 |
-
You can use the case insensitive modifier (ex: <string>""GB(/^PO.*$/i)""</string>).
|
344 |
-
</p>
|
345 |
-
|
346 |
-
{code=json}{
|
347 |
-
""ex0"":{""label"":""France, Germany, Switzerland, Spain, Italy"",""shipto"":""FR,DE,CH,ES,IT"",""fees"":10},
|
348 |
-
""ex1"":{""label"":""France except Corsica"",""shipto"":""FR-(2A,2B)"",""fees"":10},
|
349 |
-
""ex2"":{""label"":""Corsica"",""shipto"":""FR(2A,2B)"",""fees"":10},
|
350 |
-
""ex3"":{""label"":""World except Germany and Corsica"",""shipto"":""* - ( DE, FR(2A,2B) )"",""fees"":10},
|
351 |
-
""ex4"":{""label"":""Postal codes beginning with 25 using the wildcard character"",""shipto"":""FR(25*)"",""fees"":10},
|
352 |
-
""ex5"":{""label"":""Postal codes beginning with 25 using a regular expression"",""shipto"":""FR(/^25[0-9]{3}$/)"",""fees"":10}
|
353 |
-
}{/code}
|
354 |
-
|
355 |
-
<div class=""tips"">
|
356 |
-
<p><strong>Tip</strong><br/>To shorten the seizure of countries, you can use the following variables:</p>
|
357 |
-
<ul>
|
358 |
-
<li><c>{address_filter.AF}</c>: countries of Africa</li>
|
359 |
-
<li><c>{address_filter.AS}</c>: countries of Asia</li>
|
360 |
-
<li><c>{address_filter.EU}</c>: countries of Europa</li>
|
361 |
-
<li><c>{address_filter.NA}</c>: countries of North America</li>
|
362 |
-
<li><c>{address_filter.SA}</c>: countries of South America</li>
|
363 |
-
<li><c>{address_filter.OC}</c>: countries of Oceania</li>
|
364 |
-
<li><c>{address_filter.AN}</c>: countries of Antartica</li>
|
365 |
-
<li><c>{address_filter.EU-27}</c>: countries of the European Union</li>
|
366 |
-
<li><c>{address_filter.DOM}</c>: country codes of overseas french department</li>
|
367 |
-
<li><c>{address_filter.COM}</c>: country codes of overseas french communities</li>
|
368 |
-
</ul>
|
369 |
-
</div>
|
370 |
-
|
371 |
-
{code=json}{
|
372 |
-
""ex0"":{""label"":""Europa except France"",""shipto"":""({address_filter.EU-27}) - (FR)"",""fees"":10}
|
373 |
-
}{/code}
|
374 |
-
"
|
375 |
-
"{os2editor.help.property_billto}","
|
376 |
-
<h4><property>billto</property>: the billing address</h4>
|
377 |
-
<p><a href=""#property_shipto"">Filtering addresses</a></p>
|
378 |
-
"
|
379 |
-
"{os2editor.help.property_origin}","
|
380 |
-
<h4><property>origin</property>: the origin address</h4>
|
381 |
-
<p><a href=""#property_shipto"">Filtering addresses</a></p>
|
382 |
-
"
|
383 |
-
"{os2editor.help.property_customer_groups}","
|
384 |
-
<h4><property>customer_groups</property></h4>
|
385 |
-
<p>We can use the name or the ID of customer groups.</p>
|
386 |
-
|
387 |
-
{code=json}{
|
388 |
-
""ex0"":{""label"":""NOT LOGGED IN and General groups"",""customer_groups"":""NOT LOGGED IN,General"",""fees"":10},
|
389 |
-
""ex1"":{""label"":""NOT LOGGED IN and General groups by their ID"",""customer_groups"":""0,1"",""fees"":10},
|
390 |
-
""ex2"":{""label"":""Retailer group"",""customer_groups"":""Retailer"",""fees"":10}
|
391 |
-
}{/code}
|
392 |
-
"
|
393 |
-
"{os2editor.help.property_fees}","
|
394 |
-
<h4><property>fees</property>: the shipping fees</h4>
|
395 |
-
<p>
|
396 |
-
<property>fees</property> property is specified as a <a href=""#more_formulas"">formula (see introduction to formulas)</a>.
|
397 |
-
</p>
|
398 |
-
{code=json}{
|
399 |
-
""ex0"":{""label"":""Fixed fees"",""fees"":10},
|
400 |
-
""ex1"":{""label"":""Fees table"",""fees"":""{table {cart.weight} in 0.5:5.30, 1.0:6.50}""},
|
401 |
-
""ex2"":{""label"":""Formula"",""fees"":""0.1 * {cart.price-tax+discount} + 10.00""},
|
402 |
-
""ex3"":{""label"":""Combination"",""fees"":""0.1 * {cart.price-tax+discount} + {table {cart.weight} in 0.5:5.30, 1.0:6.50} + 10.00""}
|
403 |
-
}{/code}
|
404 |
-
"
|
405 |
-
"{os2editor.help.property_tracking_url}","
|
406 |
-
<h4><property>tracking_url</property></h4>
|
407 |
-
<p class=warning>
|
408 |
-
<strong>The use of <property>tracking_url</property> property is reserved for experienced users. If you don't understand the instructions below, it is recommended that you avoid using this feature.</strong>
|
409 |
-
</p>
|
410 |
-
<p>
|
411 |
-
The <property>tracking_url</property> property overrides the field ""Tracking URL"" of an Owebia Shipping shipping mode. So you can specify a tracking URL <strong>foreach shipping method</strong> rather than one for all shipping mode.
|
412 |
-
</p>
|
413 |
-
<p>
|
414 |
-
To automatically insert the tracking number in the tracking URL, you must use <c>{tracking_number}</c>.
|
415 |
-
</p>
|
416 |
-
|
417 |
-
{code=json}{
|
418 |
-
""ex0"":{""label"":""Example of tracking URL for the carrier Colissimo"",""fees"":10,""tracking_url"":""http://www.coliposte.net/particulier/suivi_particulier.jsp?colispart={tracking_number}""}
|
419 |
-
}{/code}
|
420 |
-
|
421 |
-
<p>
|
422 |
-
Magento does not support tracking links but tracking statuses. The extension Owebia Shipping 2 provides an HTML link instead of the status, link allowing you to go on the carrier's website and follow the progress of the parcel.
|
423 |
-
</p>
|
424 |
-
<p>
|
425 |
-
When the tracking URL is built by the extension, the only information available is the tracking number and there was nowhere an access to the shipping method selected. In order to find the tracking URL in the configuration, you must specify the shipping method inside the tracking number, for example: <c>colissimo:8Lxxxxxxxxxxx</c> where <c>colissimo</c> is the code of the shipping method selected.<br/>
|
426 |
-
If no code is specified (if you enter only the tracking number), the URL used will be the one of the shipping mode.
|
427 |
-
</p>
|
428 |
-
<p class=warning>
|
429 |
-
To answer a recurrent question, Magento displays the tracking status from the back office or front office. <strong>If you want to insert the tracking URL in shipping mails, you need to develop yourself the retrieval of tracking URL and its incorporation in the mail, in fact, the Owebia Shipping extension simply provides customizable shipping methods without making big changes to Magento core to reduce incompatibility and update problems.</strong>
|
430 |
-
</p>
|
431 |
-
<p class=warning>
|
432 |
-
If you get a blank popup when you click on the tracking link, your problem is most likely related to the fact that you did not specify the code of the shipping method in the tracking number (see instructions above) and your global field ""Tracking URL"" is empty.
|
433 |
-
</p>
|
434 |
-
<p class=warning>There are currently no plans to change this feature.</p>
|
435 |
-
"
|
436 |
-
"{os2editor.help.property_enabled}","
|
437 |
-
<h4><property>enabled</property></h4>
|
438 |
-
<p>Allow to activate or desactivate the shipping method.</p>
|
439 |
-
<p>The value must be boolean.</p>
|
440 |
-
{code=json}{
|
441 |
-
""ex0"":{""enabled"":true,""label"":""Example with activation"",""fees"":10}
|
442 |
-
}{/code}
|
443 |
-
"
|
444 |
-
"{os2editor.help.more_formulas}","
|
445 |
-
<h4>Introduction to formulas</h4>
|
446 |
-
<p>
|
447 |
-
Properties <property>fees</property> and <property>conditions</property> are specified as formulas.
|
448 |
-
</p>
|
449 |
-
<p>
|
450 |
-
Mathematical signs available:
|
451 |
-
</p>
|
452 |
-
<ul>
|
453 |
-
<li>operators: <c>*</c>, <c>/, <c>+</c> and <c>-</c></li>
|
454 |
-
<li>modulo: <c>%</c></li>
|
455 |
-
<li>brackets: <c>(</c> et <c>)</c></li>
|
456 |
-
<li>boolean operators <c>&&</c>, <c>and</c>, <c>||</c>, <c>or</c>, <c>==</c>, <c><</c>, <c>></c>, <c><=</c>, <c>>=</c></li>
|
457 |
-
<li>binary operators <c>&</c> and <c>|</c></li>
|
458 |
-
<li>operators group <c>C ? X : Y</c> (ex: <c><span class=string>""{cart.price_exluding_tax}>100 ? 15*{cart.weight} : 20*{cart.weight}""</span></c>)</li>
|
459 |
-
</ul>
|
460 |
-
<p>
|
461 |
-
Variables available:
|
462 |
-
</p>
|
463 |
-
<ul>
|
464 |
-
|
465 |
-
<li><c>{cart.weight}</c>: full package weight</li>
|
466 |
-
<li><c>{cart.qty}</c>: items count in cart</li>
|
467 |
-
<li><c>{cart.price-tax+discount}</c>: price excluding tax after discount</li>
|
468 |
-
<li><c>{cart.price+tax+discount}</c>: price including tax after discount</li>
|
469 |
-
<li><c>{cart.price-tax-discount}</c>: price excluding tax before discount</li>
|
470 |
-
<li><c>{cart.price+tax-discount}</c>: price including tax before discount</li>
|
471 |
-
<li><a href=""#more_vars"">See full list of variables</a></li>
|
472 |
-
</ul>
|
473 |
-
<p>
|
474 |
-
You can put spaces and line returns in formulas (to air).
|
475 |
-
</p>
|
476 |
-
<p>
|
477 |
-
Functions available:
|
478 |
-
</p>
|
479 |
-
<ul>
|
480 |
-
<li>rounds: <c>round(x)</c>, <c>floor(x)</c>, <c>ceil(x)</c></li>
|
481 |
-
<li>absolute value: <c>abs(x)</c></li>
|
482 |
-
<li>maximum: <c>max(x,y)</c></li>
|
483 |
-
<li>minimum: <c>min(x,y)</c></li>
|
484 |
-
<li>random integer: <c>rand(min,max)</c></li>
|
485 |
-
<li>power: <c>pow(x,puissance)</c></li>
|
486 |
-
<li>PI number: <c>pi()</c></li>
|
487 |
-
<li>square root: <c>sqrt(x)</c></li>
|
488 |
-
<li>logarithm: <c>log(x)</c> for the natural logarithm or <c>log(x,base)</c></li>
|
489 |
-
<li>exponential: <c>exp(x)</c></li>
|
490 |
-
</ul>
|
491 |
-
<p>
|
492 |
-
Ability to use advanced features like: casting to integer <c>(int)</c> casting to floating number <c>(float)</c>, comparison with <c>null</c> or boolean values <c>true</c> and <c>false</c>.
|
493 |
-
</p>
|
494 |
-
<p class=""new"" style=""font-weight: bold;"">
|
495 |
-
You can also use advanced features such as rates tables, copy of a property of another method,
|
496 |
-
special functions, usage of product's attributes and options or usage of custom variables.
|
497 |
-
</p>
|
498 |
-
<p class=new style=""font-weight: bold;"">
|
499 |
-
When you use alphanumeric variables, you can escape them with quotes or you can use the autoescape syntax <c>{{ }}</c>.
|
500 |
-
</p>
|
501 |
-
{code=json}{
|
502 |
-
""ex0"":{""label"":""Escaping with quotes"",""conditions"":""'{cart.coupon_code}'=='test'"",""fees"":10},
|
503 |
-
""ex1"":{""about"":""Since version 2.4.5, {{cart.coupon_code}} will be replaced by 'moncoupon' or by null depending on its value"",""label"":""Auto-escaping"",""conditions"":""{{cart.coupon_code}}!='test'"",""fees"":10}
|
504 |
-
}{/code}
|
505 |
-
"
|
506 |
-
"{os2editor.help.more_vars}","
|
507 |
-
<h4>Variables available</h4>
|
508 |
-
<p>
|
509 |
-
The following variables can be used in different properties of shipping methods (in particular in properties <property>conditions</property> and <property>fees</property>).
|
510 |
-
</p>
|
511 |
-
<ul>
|
512 |
-
<li>The cart:
|
513 |
-
<ul>
|
514 |
-
<li><c>{cart.weight}</c>: package weight</li>
|
515 |
-
<li><c class=new><strike>{cart.quantity}</strike> {cart.qty}</c>: items quantity</li>
|
516 |
-
<li class=new><c><strike>{cart.price_excluding_tax}</strike> {cart.price-tax+discount}</c>: price excl. tax after discount</li>
|
517 |
-
<li class=new><c><strike>{cart.price_including_tax}</strike> {cart.price+tax+discount}</c>: price incl. tax after discount</li>
|
518 |
-
<li class=new><c>{cart.price-tax-discount}</c>: price excl. tax before discount</li>
|
519 |
-
<li class=new><c>{cart.price+tax-discount}</c>: price incl. tax before discount</li>
|
520 |
-
<li class=new><c><strike>{cart.coupon}</strike> {cart.coupon_code}</c></li>
|
521 |
-
<li><c class=new><strike>{free_shipping}</strike> {cart.free_shipping}</c>: shipping offered (by a rule in Magento) [true/false]</li>
|
522 |
-
<li><c class=new><strike>{cart.weight.unit}</strike> {cart.weight_unit}</c></li>
|
523 |
-
<li><c class=new><strike>{cart.weight.for-charge}</strike> {cart.weight_for_charge}</c>: weight of goods whose delivery is not offered (by a cart price rule in Magento)</li>
|
524 |
-
</ul>
|
525 |
-
</li>
|
526 |
-
<li class=new>The customer group:
|
527 |
-
<ul>
|
528 |
-
<li><c><strike>{customer.group.id}</strike> {customer_group.id}</c></li>
|
529 |
-
<li><c><strike>{customer.group.code}</strike> {customer_group.code}</c>: name of customer group</li>
|
530 |
-
<li><c>{customer_group.*}</c>: property of customer group (ex: <c>{customer_group.tax_class_id}</c>)</li>
|
531 |
-
</ul>
|
532 |
-
</li>
|
533 |
-
<li class=new>The customer:
|
534 |
-
<ul>
|
535 |
-
<li><c>{customer.id}</c></li>
|
536 |
-
<li><c>{customer.attribute.*}</c>: attribute of the customer (ex: lastname, firstname, group_id…)</li>
|
537 |
-
<li class=new><c>{customer.attribute.*.value}</c>: in case of attributes of type dropdown, <c>{customer.attribute.*}</c> returns the id, to get the value you must use <c>{customer.attribute.*.value}</c></li>
|
538 |
-
<li><c>{customer.*}</c>: same as <c>{customer.attribute.*}</c> if the variable isn't defined (ex: <c>{customer.id}</c> is already defined)</li>
|
539 |
-
</ul>
|
540 |
-
</li>
|
541 |
-
<li class=new>Custom Variables (since version 1.4.0.1 of Magento):
|
542 |
-
<ul>
|
543 |
-
<li><c>{customvar.*}</c>: Magento custom variable (ex: <c>{customvar.my_var}</c>)</li>
|
544 |
-
<li><c><strike>{{customVar code=*}}</strike></c>: use the syntax above</li>
|
545 |
-
</ul>
|
546 |
-
</li>
|
547 |
-
<li>The shipping address:
|
548 |
-
<ul>
|
549 |
-
<li><c class=new><strike>{destination.country.name}</strike> {shipto.country_name}</c></li>
|
550 |
-
<li><c class=new><strike>{destination.country.code}</strike> {shipto.country_id}</c>: the country code</li>
|
551 |
-
<li class=new><c>{shipto.region_id}</c></li>
|
552 |
-
<li><c class=new><strike>{destination.region.code}</strike> {shipto.region_code}</c></li>
|
553 |
-
<li class=new><c>{shipto.street}</c></li>
|
554 |
-
<li class=new><c>{shipto.city}</c></li>
|
555 |
-
<li><c class=new><strike>{destination.postcode}</strike> {shipto.postcode}</c></li>
|
556 |
-
</ul>
|
557 |
-
</li>
|
558 |
-
<li class=new>The billing address:
|
559 |
-
<ul>
|
560 |
-
<li><c>{billto.country_name}</c></li>
|
561 |
-
<li><c>{billto.country_id}</c>: the country code</li>
|
562 |
-
<li><c>{billto.postcode}</c></li>
|
563 |
-
<li><c>{billto.*}</c>: property of the billing address (ex: <c>{billto.city}</c>)</li>
|
564 |
-
</ul>
|
565 |
-
</li>
|
566 |
-
<li>The origin address:
|
567 |
-
<ul>
|
568 |
-
<li><c class=new><strike>{origin.country.name}</strike> {origin.country_name}</c></li>
|
569 |
-
<li><c class=new><strike>{origin.country.code}</strike> {origin.country_id}</c>: the country code</li>
|
570 |
-
<li><c class=new><strike>{origin.region.code}</strike> {origin.region_id}</c></li>
|
571 |
-
<li class=new><c>{origin.city}</c></li>
|
572 |
-
<li><c>{origin.postcode}</c></li>
|
573 |
-
</ul>
|
574 |
-
</li>
|
575 |
-
<li>The store:
|
576 |
-
<ul>
|
577 |
-
<li><c>{store.id}</c> <c>{store.code}</c> <c>{store.name}</c> <c>{store.address}</c> <c>{store.phone}</c>: id, code, name, address and phone number of the store</li>
|
578 |
-
</ul>
|
579 |
-
</li>
|
580 |
-
<li>The current date:
|
581 |
-
<ul>
|
582 |
-
<li><c>{date.timestamp}</c>: UNIX timestamp of current date</li>
|
583 |
-
<li><c>{date.year}</c> <c>{date.month}</c> <c>{date.day}</c> <c>{date.hour}</c> <c>{date.minute}</c></li>
|
584 |
-
<li><c>{date.weekday}</c>: weekday for current date from 0 (Sunday) to 6 (Saturday)</li>
|
585 |
-
</ul>
|
586 |
-
</li>
|
587 |
-
<li class=new>The <c>request</c> object:
|
588 |
-
<ul>
|
589 |
-
<li><c>{request.*}</c>: property of the request object (Mage_Shipping_Model_Rate_Request) parameter given by Magento (ex: <c>{request.package_qty}</c>). Use the ""Debug"" option to have more details on available properties.</li>
|
590 |
-
</ul>
|
591 |
-
</li>
|
592 |
-
</ul>
|
593 |
-
"
|
594 |
-
"{os2editor.help.more_special-functions}","
|
595 |
-
<h4>Special functions in formulas</h4>
|
596 |
-
|
597 |
-
<p>
|
598 |
-
You can use special functions in formulas.
|
599 |
-
</p>
|
600 |
-
<p>
|
601 |
-
List of special functions:
|
602 |
-
</p>
|
603 |
-
<ul>
|
604 |
-
<li><c>min(x, y, …)</c> : calculate the minimum of several values (possibly more than two values). If one value is null, it is ignored.</li>
|
605 |
-
<li><c>max(x, y, …)</c> : calculate the maximum of several values (possibly more than two values). If one value is null, it is ignored.</li>
|
606 |
-
<li class=new><c>range(value, min, max, include_min, include_max)</c> : returns <c>true</c> if <c>value</c> is between <c>min</c> and <c>max</c>. By default, <c>include_min</c> and <c>include_max</c> are set to <c>true</c>.</li>
|
607 |
-
<li class=new><c>substr(string, start, length)</c> : returns a segment of a string.</li>
|
608 |
-
<li class=new><c>in_array(value, array(value1, value2, …))</c> : returns true if the value is in the array.</li>
|
609 |
-
<li class=new><c>array_match_any(array(value1, value2, …), array(value1, value2, …))</c> : returns true if any value is in both arrays.</li>
|
610 |
-
<li class=new><c>array_match_all(array(value1, value2, …), array(value1, value2, …))</c> : returns true if both arrays have the same values.</li>
|
611 |
-
</ul>
|
612 |
-
|
613 |
-
{code=json}{
|
614 |
-
""ex0"":{""label"":""Example with min function"",""fees"":""min({cart.weight},{cart.price+tax+discount},{cart.qty})""},
|
615 |
-
""ex1"":{""label"":""Example with range function"",""conditions"":""range({cart.weight},1.0,3.0)"",""fees"":10},
|
616 |
-
""ex2"":{""label"":""Example with substr function *"",""conditions"":""substr('{cart.coupon_code}', 0, 5)=='free_'"",""fees"":10},
|
617 |
-
""ex3"":{""label"":""Example with in_array and strings *"",""conditions"":""in_array({{cart.coupon_code}}, array('free1', 'free2'))"",""fees"":10},
|
618 |
-
""ex4"":{""label"":""Example with in_array and numbers"",""conditions"":""in_array({cart.qty}, array(10,20,30))"",""fees"":10},
|
619 |
-
""ex5"":{""label"":""Example with array_match_any"",""about"":""5 x weight of products contained in categories 2 or 3"",""fees"":""{sum product.weight where array_match_any(product.categories.id, array(2, 3))}*5.0""},
|
620 |
-
""ex6"":{""label"":""Example with array_match_all"",""about"":""5 x weight of products contained in category 2 and in category 3"",""fees"":""{sum product.weight where array_match_all(product.categories.id, array(2, 3))}*5.0""}
|
621 |
-
}{/code}
|
622 |
-
|
623 |
-
<p class=new>
|
624 |
-
* About strings escaping, refer to the <a href=""#more_formulas"">introduction to formulas</a>.
|
625 |
-
</p>
|
626 |
-
"
|
627 |
-
"{os2editor.help.more_copy}","
|
628 |
-
<h4>Make a copy of a property of another method</h4>
|
629 |
-
<p>It is possible to make a copy of a property in another using the syntax below.</p>
|
630 |
-
<p>You can use this technique in all properties (<property>conditions</property>, <property>fees</property>, …).</p>
|
631 |
-
|
632 |
-
{code=json}{
|
633 |
-
""colissimo"":{""label"":""Colissimo"",""shipto"":""AD,FR,MC"",""conditions"":""{cart.price-tax+discount}<1000.00"",""fees"":""1.30 + {table {cart.weight} in 0.5:5.30, 1.0:6.50, 2.0:7.40, 3.0:8.30, 5.0:10.10}""},
|
634 |
-
""ex1"":{""label"":""Copy of conditions from another method"",""conditions"":""({colissimo.conditions}) and ({cart.weight}>=0)"",""fees"":10},
|
635 |
-
""ex2"":{""label"":""Copy of fees from another method"",""fees"":""({colissimo.fees}) + 15.00""}
|
636 |
-
}{/code}
|
637 |
-
"
|
638 |
-
"{os2editor.help.more_tables}","
|
639 |
-
<h4>Using <c>table</c></h4>
|
640 |
-
<p>
|
641 |
-
In a <c>table</c>, you can include or exclude a limit value with characters <c>[</c> et <c>]</c>:
|
642 |
-
</p>
|
643 |
-
{code=json}{
|
644 |
-
""f0"":{""label"":""Upper limit included"",""fees"":""{table {cart.weight} in 1.0]:5.00}""},
|
645 |
-
""f1"":{""label"":""Upper limit excluded"",""fees"":""{table {cart.weight} in 1.0[:5.00}""}
|
646 |
-
}{/code}
|
647 |
-
|
648 |
-
<p>
|
649 |
-
In a <c>table</c>, you must specify the reference value. For this, we can use one of the <a href=""#more_vars"">available variables</a>.<br/>
|
650 |
-
You can also use a formula to define another reference variable.
|
651 |
-
</p>
|
652 |
-
|
653 |
-
{code=json}{
|
654 |
-
""ex0"":{""label"":""Table with cart weight"",""fees"":""{table {cart.weight} in 0.5:5.30, 1.0:6.50}""},
|
655 |
-
""ex1"":{""label"":""Table with cart quantity"",""fees"":""{table {cart.qty} in 10:5.30, 20:6.50}""},
|
656 |
-
""ex2"":{""label"":""Table with price incl. tax"",""fees"":""{table {cart.price+tax+discount} in 15.00:5.30, 30.00:6.50, *:10.00}""},
|
657 |
-
""ex3"":{""label"":""Table with price excl. tax"",""fees"":""{table {cart.price-tax+discount} in 15.00:5.30, 30.00:6.50, *:10.00}""},
|
658 |
-
""ex4"":{""label"":""Table with user defined value"",""fees"":""{table ceil({cart.weight}/10) in 1:5.30, 2:6.50}""}
|
659 |
-
}{/code}
|
660 |
-
"
|
661 |
-
"{os2editor.help.more_switch}","
|
662 |
-
<h4>Using <c>switch</c></h4>
|
663 |
-
|
664 |
-
<p>
|
665 |
-
In a <c>switch</c>, you must specify the reference value. For this, we can use one of the <a href=""#more_vars"">available variables</a>.<br/>
|
666 |
-
You can also use a formula to define another reference variable.
|
667 |
-
</p>
|
668 |
-
|
669 |
-
{code=json}{
|
670 |
-
""ex0"":{""label"":""Switch with coupon code"",""fees"":""{switch {{cart.coupon_code}} in 'coupon1':5.30, 'coupon2':6.50, null:10.00, *:7.50}""},
|
671 |
-
""ex1"":{""label"":""Switch with shipping country"",""fees"":""{switch {{shipto.country_id}} in 'FR':5.30, 'BE':6.50, 'DE':10.00, *:7.50}""}
|
672 |
-
}{/code}
|
673 |
-
"
|
674 |
-
"{os2editor.help.more_attributes-options}","
|
675 |
-
<h4>Using product properties</h4>
|
676 |
-
|
677 |
-
<p class=new>
|
678 |
-
In order to match to Magento Models, the version 2.4.8 of the extension adds a separation between <c>item</c> and <c>product</c>.
|
679 |
-
An <c>item</c> is a <c>product</c> variation with some options. Each <c>item</c> has a quantity.
|
680 |
-
</p>
|
681 |
-
<p>
|
682 |
-
List of available properties:
|
683 |
-
</p>
|
684 |
-
<ul>
|
685 |
-
<li class=new>The <c>item</c>:
|
686 |
-
<ul>
|
687 |
-
<li><c>item.qty</c>: the quantity in cart</li>
|
688 |
-
<li><c>item.price-tax+discount</c>: the price excl. tax after discount</li>
|
689 |
-
<li><c>item.price-tax-discount</c>: the price excl. tax before discount</li>
|
690 |
-
<li><c>item.price+tax+discount</c>: the price incl. tax after discount</li>
|
691 |
-
<li><c>item.price+tax-discount</c>: the price incl. tax before discount</li>
|
692 |
-
<li><c>item.option.*</c>: option (depends on product)</li>
|
693 |
-
</ul>
|
694 |
-
</li>
|
695 |
-
<li>The <c>product</c>:
|
696 |
-
<ul>
|
697 |
-
<li><c><strike>product.quantity</strike></c>: use <c class=new>item.qty</c></li>
|
698 |
-
<li><c>product.attribute.*</c>: attribute<br/>List of interesting attributes:
|
699 |
-
<ul>
|
700 |
-
<li><c>sku</c></li>
|
701 |
-
<li><c>name</c></li>
|
702 |
-
<li><c>weight</c></li>
|
703 |
-
<li><c>price</c> (as defined in product)</li>
|
704 |
-
<li><c>special_price</c> (as defined in product)</li>
|
705 |
-
<li><c><strike>price-tax+discount</strike></c>: use <c class=new>item.price-tax+discount</c></li>
|
706 |
-
<li><c><strike>price-tax-discount</strike></c>: use <c class=new>item.price-tax-discount</c></li>
|
707 |
-
<li><c><strike>price+tax+discount</strike></c>: use <c class=new>item.price+tax+discount</c></li>
|
708 |
-
<li><c><strike>price+tax-discount</strike></c>: use <c class=new>item.price+tax-discount</c></li>
|
709 |
-
</ul>
|
710 |
-
</li>
|
711 |
-
<li class=new><c>product.attribute.*.value</c>: value of the attribute<br/>In case of attributes of type dropdown, <c>product.attribute.*</c> returns the id. To get the value, you must use <c>product.attribute.*.value</c></li>
|
712 |
-
<li class=new><c>product.*</c>: same as <c>product.attribute.*</c> if variable is not defined (ex: <c>product.category</c> is defined)</li>
|
713 |
-
<li><c><strike>product.option.*</strike></c>: use <c class=new>item.option.*</c></li>
|
714 |
-
<li>First category of the product:
|
715 |
-
<ul>
|
716 |
-
<li><c>product.category</c>: name of the category</li>
|
717 |
-
<li><c>product.category.id</c></li>
|
718 |
-
<li class=new><c>product.category.*</c>: attribute of the category (ex: <c>product.category.is_active</c>)<br/>List of interesting attributes:
|
719 |
-
<ul>
|
720 |
-
<li><c>is_active</c></li>
|
721 |
-
<li><c>name</c></li>
|
722 |
-
<li>…</li>
|
723 |
-
</ul>
|
724 |
-
</li>
|
725 |
-
</ul>
|
726 |
-
</li>
|
727 |
-
<li>All categories of the product (returns an array, <a href=""#more_categories"">explanation section</a>) :
|
728 |
-
<ul>
|
729 |
-
<li><c>product.categories</c>: array of categories names</li>
|
730 |
-
<li><c>product.categories.id</c>: array of categories ids</li>
|
731 |
-
</ul>
|
732 |
-
</li>
|
733 |
-
<li>Attribute set of the product:
|
734 |
-
<ul>
|
735 |
-
<li><c>product.attribute_set</c>: name of attribute set</li>
|
736 |
-
<li><c>product.attribute_set.id</c></li>
|
737 |
-
<li class=new><c>product.attribute_set.*</c>: attribute of attribute set (ex: <c>product.attribute_set.attribute_set_name</c>)</li>
|
738 |
-
</ul>
|
739 |
-
</li>
|
740 |
-
<li class=new><c>product.stock.*</c>: attribute of product stock<br/>List of interesting attributes:
|
741 |
-
<ul>
|
742 |
-
<li><c>is_in_stock</c></li>
|
743 |
-
<li><c>qty</c>: product stock</li>
|
744 |
-
<li>…</li>
|
745 |
-
</ul>
|
746 |
-
</li>
|
747 |
-
</ul>
|
748 |
-
</li>
|
749 |
-
</ul>
|
750 |
-
|
751 |
-
{code=json}{
|
752 |
-
""ex0"":{""label"":""If at least one product has an attribute 'color' equals to 'Blue'"",""conditions"":""{count items where product.color=='Blue'}>0"",""fees"":10},
|
753 |
-
""ex1"":{""label"":""If all products have the option 'size' greater or equal to '1'"",""conditions"":""{count items where item.option.size>='1'}=={cart.qty}"",""fees"":10},
|
754 |
-
""ex2"":{""label"":""Different SKU count"",""conditions"":""{count distinct product.sku}"",""fees"":10},
|
755 |
-
""ex3"":{""label"":""Sum of all options 'size' is greater than 30"",""conditions"":""{sum item.option.size}>30"",""fees"":10},
|
756 |
-
""ex4"":{""label"":""Minimum price excl. tax without discount of products in cart is greater than 10"",""conditions"":""{min item.price-tax-discount}>10"",""fees"":10},
|
757 |
-
""ex5"":{""label"":""Maximum value of option 'size' is lower than 50"",""conditions"":""{max item.option.size}<50"",""fees"":10},
|
758 |
-
""ex6"":{""label"":""Count products in stock"",""conditions"":""{count items where product.stock.is_in_stock==true}"",""fees"":10}
|
759 |
-
}{/code}
|
760 |
-
</div>
|
761 |
-
|
762 |
-
<p>
|
763 |
-
Available prefixes list:
|
764 |
-
</p>
|
765 |
-
<ul>
|
766 |
-
<li><c>count</c>: count (always followed by <c>items</c>)</li>
|
767 |
-
<li><c>count distinct</c> : distinct count (always followed by a property)</li>
|
768 |
-
<li><c>sum</c> : sum (always followed by a property)</li>
|
769 |
-
<li class=new><c>min</c> : minimum (always followed by a property)</li>
|
770 |
-
<li class=new><c>max</c> : maximum (always followed by a property)</li>
|
771 |
-
</ul>
|
772 |
-
<p>
|
773 |
-
It's possible to specify conditions that must be met by products to be taken into account. To do this, simply add <c> where </c> followed by a formula.
|
774 |
-
</p>
|
775 |
-
<p>
|
776 |
-
If the property type is <strong>Yes/No</strong>, you should use <c>true</c>/<c>false</c> or <c>1</c>/<c>0</c> without quotes.
|
777 |
-
</p>
|
778 |
-
{code=json}{
|
779 |
-
""ex0"":{""label"":""Example property of type Yes/No: 0"",""conditions"":""{count items where product.attribute.colissimo_allowed==0}"",""fees"":10},
|
780 |
-
""ex1"":{""label"":""Example property of type Yes/No: false"",""conditions"":""{count items where product.attribute.colissimo_allowed==false}"",""fees"":10}
|
781 |
-
}{/code}
|
782 |
-
|
783 |
-
<p>
|
784 |
-
If the property type is <strong>Drop-down</strong> and you want to make a comparison with the value rather than with the id, you must use the following syntax:
|
785 |
-
</p>
|
786 |
-
<strike>{code=json}{
|
787 |
-
""ex0"":{""label"":""If the color attribute's id is different to 1"",""conditions"":""{count items where product.color.id!=1}"",""fees"":10}
|
788 |
-
}{/code}</strike>
|
789 |
-
{code=json}{
|
790 |
-
""ex0"":{""label"":""If the value of color attribute is different to 'Bleu'"",""conditions"":""{count items where product.color.value!='Bleu'}"",""fees"":10}
|
791 |
-
}{/code}
|
792 |
-
"
|
793 |
-
"{os2editor.help.more_foreach}","
|
794 |
-
<h4>Using <c>foreach</c> loops</h4>
|
795 |
-
|
796 |
-
<p>
|
797 |
-
<c>foreach</c> loops can perform calculations on groups of products rather than consider all the products in the basket.<br/>
|
798 |
-
The overall result of a <c>foreach</c> loop is the sum of the results of each pass through the loop.
|
799 |
-
</p>
|
800 |
-
<p>
|
801 |
-
Inside a <c>foreach</c> loop, it is possible to use new variables:
|
802 |
-
</p>
|
803 |
-
<ul>
|
804 |
-
<li><c>{selection.weight}</c></li>
|
805 |
-
<li><c class=new><strike>{selection.quantity}</strike> {selection.qty}</c>: items count in the selection</li>
|
806 |
-
</ul>
|
807 |
-
<p>
|
808 |
-
When the selection is done on the sku, each selection is composed of a single article. We can use other variables:
|
809 |
-
</p>
|
810 |
-
<ul>
|
811 |
-
<li><c>{item.*}</c></li>
|
812 |
-
<li><c>{product.*}</c></li>
|
813 |
-
<li><a href=""#more_attributes-options"">See the full list of products properties</a></li>
|
814 |
-
</ul>
|
815 |
-
|
816 |
-
{code=json}{
|
817 |
-
""ex0"":{""label"":""Grouping products by origin and treat groups seperatly"",""fees"":""{foreach product.attribute.code_origin}{table {selection.weight} in 0.0:0.00, 1.0:11.00, 3.0:12.00, 5.0:13.00}{/foreach}""},
|
818 |
-
""ex1"":{""label"":""Individual calculation of shipping fees"",""fees"":""{foreach product.attribute.sku}{product.attribute.shipping}*{item.qty}{/foreach}""}
|
819 |
-
}{/code}
|
820 |
-
"
|
821 |
-
"{os2editor.help.more_categories}","
|
822 |
-
<h4>Particular case: examples of use of the product categories</h4>
|
823 |
-
|
824 |
-
<p>
|
825 |
-
Since version 2.4.2, it is possible to use product categories in formulas.
|
826 |
-
</p>
|
827 |
-
<p class=warning>
|
828 |
-
<strong>Warning, you must notice that in Magento, a product can be in more than one category.</strong> So be particularly careful how you use this property.
|
829 |
-
</p>
|
830 |
-
<p>
|
831 |
-
To filter products found in several specific categories, you can use <c>array_match_any()</c> function.
|
832 |
-
</p>
|
833 |
-
<p>
|
834 |
-
Examples of use:
|
835 |
-
</p>
|
836 |
-
{code=json}{
|
837 |
-
""ex0"":{""label"":""foreach loop with an iteration on categories"",""fees"":""{foreach product.categories}{selection.weight}{/foreach}""},
|
838 |
-
""ex1"":{""label"":""Using category inside a foreach loop"",""fees"":""{foreach product.sku}({{product.category}}=='Test' ? 2.00 : 1.00)*{item.qty}{/foreach}""},
|
839 |
-
""ex2"":{""label"":""Using the category id inside a foreach loop"",""fees"":""{foreach product.sku}({product.category.id}==12 ? 2.00 : 1.00)*{item.qty}{/foreach}""},
|
840 |
-
""ex3"":{""about"":""The function in_array() is used because product.categories returns an array"",""label"":""Sum of weights of products in category 'Test'"",""fees"":""{sum product.weight where in_array('Test', product.categories)}""},
|
841 |
-
""ex4"":{""about"":""The function in_array() is used because product.categories.id returns an array"",""label"":""Sum of weights of products in category having the id 12"",""fees"":""{sum product.weight where in_array(12, product.categories.id)}""},
|
842 |
-
""ex5"":{""about"":""The function array_match_any() is used because product.categories.id returns an array"",""label"":""Sum of weights of products in categories having the id 11 and 12"",""fees"":""{sum product.weight where array_match_any(product.categories.id, array(11, 12))}""},
|
843 |
-
""ex6"":{""label"":""Sum of weights of products having the first category equal to 'Test'"",""fees"":""{sum product.weight where product.category=='Test'}""},
|
844 |
-
""ex7"":{""label"":""Sum of weights of products having the id of the first category equal to 12"",""fees"":""{sum product.weight where product.category.id==12}""}
|
845 |
-
}{/code}
|
846 |
-
"
|
847 |
-
"{os2editor.help.changelog}","
|
848 |
-
<h4>Changelog</h4>
|
849 |
-
<div class=changelog>{changelog}</div>
|
850 |
-
"
|
74 |
"Export","Export"
|
75 |
"Add a shipping method","Add a shipping method"
|
76 |
"New shipping method","New shipping method"
|
|
|
|
|
77 |
|
78 |
# app/code/community/Owebia/Shipping2/etc/system.xml
|
79 |
"Configuration","Configuration"
|
97 |
"Item data on","Item data on"
|
98 |
"Product data on","Product data on"
|
99 |
|
100 |
+
# app/code/community/Owebia/Shipping2/Model/ConfigParser.php
|
101 |
"Configuration disabled","Configuration disabled"
|
102 |
"The cart doesn't match conditions","The cart doesn't match conditions"
|
103 |
"Infinite loop %s","Infinite loop %s"
|
122 |
# app/code/community/Owebia/Shipping2/Model/System/Config/Source/LoadOnParent.php
|
123 |
"Self","Self"
|
124 |
"Parent","Parent"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -74,8 +74,6 @@
|
|
74 |
"Export","Exporter"
|
75 |
"Add a shipping method","Ajouter une méthode de livraison"
|
76 |
"New shipping method","Nouvelle méthode de livraison"
|
77 |
-
"You appreciate this extension and would like to help?","Vous appréciez cette extension et vous aimeriez apporter votre soutien ?"
|
78 |
-
"{os2editor.donate-page.content}","<p>L'extension Owebia Shipping 2 est développée bénévolement par l'entreprise Owebia (<a href=""http://www.owebia.com/"">http://www.owebia.com/</a>).<br/>Si vous souhaitez soutenir financièrement le développement de l'extension, vous pouvez faire un « don ».</p><p>En France, seules certaines associations peuvent recevoir des dons, c'est pourquoi nous ne pouvons recevoir une somme d'argent sans qu'elle soit déclarée.<br/>Pour cela, nous enverrons à chaque « donateur » une facture (acquitée) du montant du « don ».</p><p>Cela permettra à chacun de garder une trace de ces « dons ».</p><p><strong>Pour effectuer un « don », merci d'envoyer un chèque à l'adresse suivante :</strong></p><p class=""owebia-address"">Owebia<br/>4, Rue du Collège<br/>25500 Morteau (France)</p><p><strong>N'oubliez pas de joindre à ce chèque les coordonnées qui doivent figurer sur la facture qui vous sera envoyée.</strong></p><p>Merci à tous les donateurs.</p>"
|
79 |
|
80 |
# app/code/community/Owebia/Shipping2/etc/system.xml
|
81 |
"Configuration","Configuration"
|
@@ -99,7 +97,7 @@
|
|
99 |
"Item data on","Données de l'article sur"
|
100 |
"Product data on","Données du produit sur"
|
101 |
|
102 |
-
# app/code/community/Owebia/Shipping2/
|
103 |
"Configuration disabled","Configuration désactivée"
|
104 |
"The cart doesn't match conditions","Le panier ne correspond pas aux conditions"
|
105 |
"Infinite loop %s","Boucle infinie %s"
|
@@ -128,747 +126,3 @@
|
|
128 |
# app/code/community/Owebia/Shipping2/Model/System/Config/Source/ProcessChildren.php
|
129 |
"Self","Lui-même"
|
130 |
"Children","Enfants"
|
131 |
-
|
132 |
-
# Help
|
133 |
-
"{os2editor.help.summary}","
|
134 |
-
<h4>Sommaire</h4>
|
135 |
-
<div class=""table-of-contents"">
|
136 |
-
<table><tr>
|
137 |
-
<td>
|
138 |
-
<ol class=level1>
|
139 |
-
<li class=new><a href=""#introduction"">Introduction : syntaxe JSON, éléments et propriétés</a></li>
|
140 |
-
<li><a href=""#unique_id"">L'identifiant unique</a></li>
|
141 |
-
<li class=new>Les types d'éléments :
|
142 |
-
<ul>
|
143 |
-
<li><a href=""#type_method""><property>method</property> : méthode de livraison</a></li>
|
144 |
-
<li><a href=""#type_data""><property>data</property> : données</a></li>
|
145 |
-
<li><a href=""#type_meta""><property>meta</property> : données méta</a></li>
|
146 |
-
</ul>
|
147 |
-
</li>
|
148 |
-
<li class=new>Les propriétés communes :
|
149 |
-
<ul>
|
150 |
-
<li><a href=""#property_type""><property>type</property> : le type de l'élément</a></li>
|
151 |
-
<li><a href=""#property_about""><property>about</property> : commentaire sur l'élément</a></li>
|
152 |
-
</ul>
|
153 |
-
</li>
|
154 |
-
<li>Les propriétés des éléments <property>method</property> :
|
155 |
-
<ul>
|
156 |
-
<li class=important><a href=""#property_label""><property>label</property> : le libellé</a></li>
|
157 |
-
<li><a href=""#property_description""><property>description</property> : la description</a></li>
|
158 |
-
<li class=important><a href=""#property_conditions""><property>conditions</property> : les conditions</a></li>
|
159 |
-
<li class=new><a href=""#property_shipto""><property>shipto</property> : l'adresse de livraison</a> (<property>destination</property> av. 2.4.8)</li>
|
160 |
-
<li class=new><a href=""#property_shipto""><property>billto</property> : l'adresse de facturation</a> (depuis 2.4.8)</li>
|
161 |
-
<li><a href=""#property_shipto""><property>origin</property> : l'adresse d'envoi</a></li>
|
162 |
-
<li><a href=""#property_customer_groups""><property>customer_groups</property> : les groupes client</a></li>
|
163 |
-
<li class=important><a href=""#property_fees""><property>fees</property> : les frais de port</a></li>
|
164 |
-
<li><a href=""#property_tracking_url""><property>tracking_url</property> : l'URL de suivi</a> (maj doc 2.4.0)</li>
|
165 |
-
<li><a href=""#property_enabled""><property>enabled</property> : l'activation/désactivation</a></li>
|
166 |
-
</ul>
|
167 |
-
</li>
|
168 |
-
</ol>
|
169 |
-
</td>
|
170 |
-
<td>
|
171 |
-
<ol class=level1 start=6>
|
172 |
-
<li><a href=""#more_formulas"">Initiation aux formules</a>
|
173 |
-
<ol>
|
174 |
-
<li class=new><a href=""#more_vars"">Les variables disponibles</a></li>
|
175 |
-
<li class=new><a href=""#more_special-functions"">Fonctions spéciales dans les formules</a> (maj 2.5)<br/> min, max, range, substr, in_array, array_match_any, array_match_all</li>
|
176 |
-
<li><a href=""#more_copy"">Faire une copie d'une propriété d'un autre élément</a></li>
|
177 |
-
<li><a href=""#more_tables"">Utilisation des tables <c>table</c></a></li>
|
178 |
-
<li><a href=""#more_switch"">Utilisation des tables de correspondance <c>switch</c></a> (maj 2.4.5)</li>
|
179 |
-
<li class=new><a href=""#more_attributes-options"">Utilisation des propriétés des produits (sum, count, min, max)</a> (maj 2.4.8)</li>
|
180 |
-
<li><a href=""#more_foreach"">Utilisation des boucles <c>foreach</c></a></li>
|
181 |
-
<li class=new><a href=""#more_categories"">Cas particulier : exemples d'utilisation des catégories de produits</a> (maj 2.5)</li>
|
182 |
-
</ol>
|
183 |
-
</li>
|
184 |
-
<li><a href=""#changelog"">Changelog</a></li>
|
185 |
-
</ol>
|
186 |
-
</td>
|
187 |
-
</tr></table>
|
188 |
-
</div>
|
189 |
-
"
|
190 |
-
"{os2editor.help.introduction}","
|
191 |
-
<h4>Introduction : syntaxe JSON, éléments et propriétés</h4>
|
192 |
-
<p class=new>
|
193 |
-
Si vous souhaitez poser une question, utilisez le sujet suivant sur le forum Magento : <a href=""http://www.magentocommerce.com/boards/viewthread/38223/"" target=_blank>http://www.magentocommerce.com/boards/viewthread/38223/</a>
|
194 |
-
</p>
|
195 |
-
|
196 |
-
<p>
|
197 |
-
<strike>La syntaxe de configuration est une syntaxe proche de la syntaxe JSON.</strike><br/>
|
198 |
-
<span class=new>Depuis la version 2.5, la syntaxe de configuration est 100% <a href=""http://fr.wikipedia.org/wiki/JavaScript_Object_Notation"" target=_blank>JSON</a>.</span>
|
199 |
-
</p>
|
200 |
-
<p>
|
201 |
-
Exemple :
|
202 |
-
</p>
|
203 |
-
{code=json}{
|
204 |
-
""ex0"":{""about"":""National"",""label"":""National"",""shipto"":""AD,FR,MC"",""conditions"":""{cart.price-tax+discount}<1000.00"",""fees"":""1.30 + {table {cart.weight} in 0.5:5.30, 1.0:6.50, 2.0:7.40, 3.0:8.30, 5.0:10.10}""}
|
205 |
-
}{/code}
|
206 |
-
|
207 |
-
<p>
|
208 |
-
La configuration est un objet JSON contenant plusieurs <strong>propriétés</strong>.<br/>
|
209 |
-
Comme imposé par JSON, chaque propriété a un nom unique, qui servira d'<a href=""#unique_id"">identifiant unique</a>.<br/>
|
210 |
-
Chaque propriété constitue un <strong>élément</strong> de configuration (qui est également un objet JSON).<br/>
|
211 |
-
</p>
|
212 |
-
<p>
|
213 |
-
Les éléments possèdent tous une propriété <property>type</property>. Celle-ci permet de définir le type de l'élément :
|
214 |
-
</p>
|
215 |
-
<ul>
|
216 |
-
<li><a href=""#type_method""><property>method</property> : méthode de livraison (par défaut si non spécifié)</a></li>
|
217 |
-
<li><a href=""#type_data""><property>data</property> : données pouvant être utilisées dans une ou plusieurs méthodes de livraison</a></li>
|
218 |
-
<li><a href=""#type_meta""><property>meta</property> : données informatives</a></li>
|
219 |
-
</p>
|
220 |
-
<!--
|
221 |
-
<p>
|
222 |
-
Chaque élément peut avoir une propriété <property>about</property>, celle-ci permet de placer un commentaire sur l'élément.
|
223 |
-
</p>
|
224 |
-
|
225 |
-
<p>
|
226 |
-
Liste des propriétés d'un élément de type <property>method</property> :
|
227 |
-
</p>
|
228 |
-
<ul>
|
229 |
-
<li><property>label</property> : nom (libellé)</li>
|
230 |
-
<li><property>description</property> : description (visible seulement si le template l'affiche)</li>
|
231 |
-
<li><property>enabled</property> : méthode de livraison activée ou non (ex: <c>true</c> ou <c>false</c>)</li>
|
232 |
-
<li class=new><property>fees</property> : frais de port (ex: <string>""15.00""</string> ou <string>""{table {cart.weight} in 0.5:5.30, 1.0:6.50}""</string> ou <string>""100 * {cart.weight}""</string>)</li>
|
233 |
-
<li class=new><property>conditions</property> : conditions d'activation (ex: <string>""{cart.weight}>=1.0""</string> ou <string>""{cart.price-tax+discount}<100.00""</string> ou <string>""range({cart.weight},1.0,3.0) and {cart.free_shipping}""</string> ou <string>""{count items where product.attribute.color=='Bleu'}>1 or {count items where item.option.size=='2m'}>2""</string>)</li>
|
234 |
-
<li class=new><property><strike>destination</strike> shipto</property> : pays (régions, codes postaux) autorisés à la livraison (ex: <string>""FR,DE,US""</string> ou <string>""FR(2A,2B,25000)""</string> ou <string>""FR-(2A,2B)""</string> ou <string>""FR(01,02,39600),CH,DE""</string>)</li>
|
235 |
-
<li class=new><property>billto</property> : pays (régions, codes postaux) autorisés à la facturation (ex: idem <property>shipto</property>)</li>
|
236 |
-
<li><property>origin</property> : pays (régions, codes postaux) autorisés en origine (ex: idem <property>shipto</property>)</li>
|
237 |
-
<li><property>customer_groups</property> : groupes de client autorisés (ex: <string>""NOT LOGGED IN,Retailer""</string> ou <string>""0,3""</string>)</li>
|
238 |
-
</ul>
|
239 |
-
-->
|
240 |
-
"
|
241 |
-
"{os2editor.help.unique_id}","
|
242 |
-
<h4>L'identifiant unique</h4>
|
243 |
-
<p>Chaque élément de configuration possède un identifiant unique. Cet identifiant unique permet ensuite de faire référence à l'élément.</p>
|
244 |
-
<p>Exemple :</p>
|
245 |
-
{code=json}{
|
246 |
-
""europe"":{""label"":""Livraison Europe"",""fees"":10},
|
247 |
-
""us"":{""label"":""Livraison US"",""fees"":""{europe.fees}+20""}
|
248 |
-
}{/code}
|
249 |
-
|
250 |
-
<p class=warning><strong><u>Attention</u> :</strong> pour éviter les conflicts, n'utiliser que les caractères <c>a-z</c>, <c>A-Z</c>, <c>0-9</c>, <c>-</c> et <c>_</c> pour former l'identifiant unique.<br/>Vous devez également éviter les identifiants qui correspondent déjà à des noms de variable (<c>cart</c>, <c>product</c>, <c>item</c>…).</p>
|
251 |
-
"
|
252 |
-
"{os2editor.help.type_method}","
|
253 |
-
<h4>Élément de type <property>method</property></h4>
|
254 |
-
<p>Un élément de type <property>method</property> permet de spécifier une méthode de livraison.</p>
|
255 |
-
<p>Exemple minimal avec uniquement les propriétés obligatoires :</p>
|
256 |
-
{code=json}{
|
257 |
-
""ex0"":{""label"":""Port offert"",""fees"":0}
|
258 |
-
}{/code}
|
259 |
-
<p>Exemple complet :</p>
|
260 |
-
{code=json}{
|
261 |
-
""ex0"":{""about"":""Colissimo National"",""type"":""method"",""label"":""Colissimo"",""description"":""Livraison sous 24/48h"",""enabled"":true,""conditions"":""range({cart.weight},0.2,1.0)"",""shipto"":""FR(01,02,39600,/^25[0-9]{3}$/),CH,DE"",""billto"":""FR"",""origin"":""DE"",""customer_groups"":""NOT LOGGED IN,Retailer"",""fees"":""{table {cart.weight} in 0.5:5.30, 1.0:6.50}""}
|
262 |
-
}{/code}
|
263 |
-
"
|
264 |
-
"{os2editor.help.type_data}","
|
265 |
-
<h4>Élément de type <property>data</property></h4>
|
266 |
-
<p>Un élément de type <property>data</property> permet de spécifier des données utilisables dans les méthodes de livraison.</p>
|
267 |
-
<p>Exemple d'élément de type <property>data</property> :</p>
|
268 |
-
{code=json}{
|
269 |
-
""mydata"":{""type"":""data"",""reference"":""100""}
|
270 |
-
}{/code}
|
271 |
-
<p>Exemple d'utilisation des données :</p>
|
272 |
-
{code=json}{
|
273 |
-
""ex0"":{""type"":""method"",""label"":""Colissimo"",""fees"":""{mydata.reference}*1.5""}
|
274 |
-
}{/code}
|
275 |
-
"
|
276 |
-
"{os2editor.help.type_meta}","
|
277 |
-
<h4>Élément de type <property>meta</property></h4>
|
278 |
-
<p>Un élément de type <property>meta</property> permet d'ajouter des données informatives (auteur, date…).</p>
|
279 |
-
<p>Exemple :</p>
|
280 |
-
{code=json}{
|
281 |
-
""about"":{""type"":""meta"",""author"":""Owebia"",""date"":""16/11/2012"",""about"":""Tarifs 2012""}
|
282 |
-
}{/code}
|
283 |
-
"
|
284 |
-
"{os2editor.help.property_type}","
|
285 |
-
<h4><property>type</property> : le type de l'élément</h4>
|
286 |
-
<p>Il permet de spécifier le type de l'élément :</p>
|
287 |
-
<ul>
|
288 |
-
<li><a href=""#type_method""><property>method</property> : méthode de livraison (par défaut si non spécifié)</a></li>
|
289 |
-
<li><a href=""#type_data""><property>data</property> : données pouvant être utilisées dans une ou plusieurs méthodes de livraison</a></li>
|
290 |
-
<li><a href=""#type_meta""><property>meta</property> : données informatives</a></li>
|
291 |
-
</ul>
|
292 |
-
{code=json}{
|
293 |
-
""about"":{""type"":""meta"",""author"":""Owebia"",""date"":""16/11/2012"",""about"":""Tarifs 2012""},
|
294 |
-
""mydata"":{""type"":""data"",""reference"":""100""},
|
295 |
-
""ex0"":{""type"":""method"",""label"":""Colissimo"",""fees"":""{mydata.reference}*1.5""}
|
296 |
-
}{/code}
|
297 |
-
"
|
298 |
-
"{os2editor.help.property_about}","
|
299 |
-
<h4><property>about</property> : commentaire sur l'élément</h4>
|
300 |
-
<p>Vous pouvez ajouter un commentaire à un élément de configuration.</p>
|
301 |
-
{code=json}{""ex0"":{""about"":""Mon commentaire"",""label"":""Exemple avec commentaire"",""fees"":10}}{/code}
|
302 |
-
"
|
303 |
-
"{os2editor.help.property_label}","
|
304 |
-
<h4><property>label</property> : le libellé</h4>
|
305 |
-
<p>Il s'agit du nom qui sera donné à la méthode de livraison.</p>
|
306 |
-
<p>On peut insérer certains éléments comme le poids des marchandises dans le libellé.<br/>
|
307 |
-
Pour ce faire, utiliser les variables suivantes :</p>
|
308 |
-
<ul>
|
309 |
-
<li>L'adresse de livraison :
|
310 |
-
<ul>
|
311 |
-
<li class=new><c><strike>{destination.country.name}</strike> {shipto.country_name}</c> : le nom du pays</li>
|
312 |
-
<li class=new><c><strike>{destination.country.code}</strike> {shipto.country_id}</c> : le code du pays</li>
|
313 |
-
<li class=new><c><strike>{destination.region.code}</strike> {shipto.region_code}</c> : le code de la région</li>
|
314 |
-
<li class=new><c><strike>{destination.postcode}</strike> {shipto.postcode}</c> : le code postal</li>
|
315 |
-
</ul>
|
316 |
-
</li>
|
317 |
-
<li><c>{cart.weight}</c> : poids des marchandises</li>
|
318 |
-
<li class=new><c><strike>{cart.weight.unit}</strike> {cart.weight_unit}</c> : l'unité de poids</li>
|
319 |
-
<li><a href=""#more_vars"">Voir la liste complète des variables</a></li>
|
320 |
-
</ul>
|
321 |
-
{code=json}{
|
322 |
-
""ex0"":{""label"":""Colissimo ({cart.weight} / {shipto.country_name})"",""fees"":10}
|
323 |
-
}{/code}
|
324 |
-
<p>La ligne ci-dessus affichera par exemple <string>""Colissimo (3.0kg / France)""</string>.</p>
|
325 |
-
"
|
326 |
-
"{os2editor.help.property_description}","
|
327 |
-
<h4><property>description</property> : la description</h4>
|
328 |
-
<p>Il s'agit de la description de la méthode de livraison.</p>
|
329 |
-
<p>Le fonctionnement est identique à la propriété <a href=""#property_label""><property>label</property></a>.</p>
|
330 |
-
"
|
331 |
-
"{os2editor.help.property_conditions}","
|
332 |
-
<h4><property>conditions</property> : les conditions</h4>
|
333 |
-
<p>
|
334 |
-
La propriété <property>conditions</property> se spécifie sous la forme d'une <a href=""#more_formulas"">formule (voir l'initiation aux formules)</a>
|
335 |
-
qui doit retourner une valeur booléenne (<c>true</c> ou <c>false</c>).
|
336 |
-
</p>
|
337 |
-
|
338 |
-
{code=json}{
|
339 |
-
""ex0"":{""label"":""Prix de 0 à 70 TTC"",""conditions"":""{cart.price+tax+discount}<=70"",""fees"":10},
|
340 |
-
""ex1"":{""label"":""Prix de 0 à 70 HT"",""conditions"":""{cart.price-tax+discount}<=70"",""fees"":10},
|
341 |
-
""ex2"":{""label"":""Prix de 20 exclu à 70 inclu"",""conditions"":""range({cart.price-tax+discount},20,70,false,true)"",""fees"":10},
|
342 |
-
""ex3"":{""label"":""Prix de 10 inclu à 50 exclu"",""conditions"":""range({cart.price-tax+discount},10,50,true,false)"",""fees"":10},
|
343 |
-
""ex4"":{""label"":""Poids de 0.5 exclu à 3 inclu"",""conditions"":""range({cart.weight},0.5,3.0,false,true)"",""fees"":10},
|
344 |
-
""ex5"":{""label"":""Poids de 1 inclu à 5 exclu"",""conditions"":""range({cart.weight},1.0,5.0,true,false)"",""fees"":10},
|
345 |
-
""ex6"":{""label"":""Seulement si port offert"",""conditions"":""{cart.free_shipping}"",""fees"":10},
|
346 |
-
""ex7"":{""label"":""Seulement si port non offert"",""conditions"":""!{cart.free_shipping}"",""fees"":10},
|
347 |
-
""ex8"":{""label"":""Si au moins un produit possède l'attribut 'color' égal à 'Bleu'"",""conditions"":""{count items where product.attribute.color=='Bleu'}>1"",""fees"":10},
|
348 |
-
""ex9"":{""label"":""Si tous les produits possèdent l'option 'size' supérieure ou égal à '1'"",""conditions"":""{count items where product.option.size>='1'}=={cart.qty}"",""fees"":10}
|
349 |
-
}{/code}
|
350 |
-
"
|
351 |
-
"{os2editor.help.property_shipto}","
|
352 |
-
<h4>Les adresses : <property>shipto</property>, <property>billto</property> et <property>origin</property></h4>
|
353 |
-
<p>
|
354 |
-
L'extension permet de filtrer plusieurs adresses :
|
355 |
-
</p>
|
356 |
-
<ul>
|
357 |
-
<li class=new>L'adresse de livraison <strike><property>destination</property></strike> <property>shipto</property>.</li>
|
358 |
-
<li class=new>L'adresse de facturation <property>billto</property></li>
|
359 |
-
<li>L'adresse d'origine <property>origin</property></li>
|
360 |
-
</ul>
|
361 |
-
<p>
|
362 |
-
Les codes pays utilisés sont ceux de Magento (à priori ils sont les mêmes que les <a href=""http://fr.wikipedia.org/wiki/ISO_3166-1"" target=_blank>codes ISO 3166-1 alpha-2</a>).<br/>
|
363 |
-
Il est possible de spécifier les codes régions (uniquement avec <property>shipto</property>) ou les codes postaux que l'on veut filtrer ou exclure.
|
364 |
-
</p>
|
365 |
-
<p class=new>
|
366 |
-
Vous pouvez utiliser le caractère jocker <c>*</c> ou les expressions régulières pour les codes postaux.<br/>
|
367 |
-
Une expression régulière doit commencer et se terminer par le caractère <c>/</c>. Si vous souhaitez utiliser les caractères <c>(</c>, <c>)</c> ou <c>,</c>, vous devez les échapper avec le caractère <c>\</c> (ex: <string>""FR(/^25\([0-9]{3}\)$/)""</string>).<br/>
|
368 |
-
Vous pouvez utiliser l'option d'insensibilité à la casse (ex: <string>""GB(/^PO.*$/i)""</string>).
|
369 |
-
</p>
|
370 |
-
|
371 |
-
{code=json}{
|
372 |
-
""ex0"":{""label"":""France, Allemagne, Suisse, Espagne, Italie"",""shipto"":""FR,DE,CH,ES,IT"",""fees"":10},
|
373 |
-
""ex1"":{""label"":""France sauf la Corse"",""shipto"":""FR-(2A,2B)"",""fees"":10},
|
374 |
-
""ex2"":{""label"":""Corse"",""shipto"":""FR(2A,2B)"",""fees"":10},
|
375 |
-
""ex3"":{""label"":""Monde entier sauf l'Allemagne et la Corse"",""shipto"":""* - ( DE, FR(2A,2B) )"",""fees"":10},
|
376 |
-
""ex4"":{""label"":""Codes postaux commençant par 25 en utilisant le caractère jocker"",""shipto"":""FR(25*)"",""fees"":10},
|
377 |
-
""ex5"":{""label"":""Codes postaux commençant par 25 en utilisant une expression régulière"",""shipto"":""FR(/^25[0-9]{3}$/)"",""fees"":10}
|
378 |
-
}{/code}
|
379 |
-
|
380 |
-
<div class=""tips"">
|
381 |
-
<p><strong>Astuce</strong><br/>Pour raccourcir la saisie des pays, vous pouvez utiliser les variables suivantes :</p>
|
382 |
-
<ul>
|
383 |
-
<li><c>{address_filter.AF}</c> : pays d'Afrique</li>
|
384 |
-
<li><c>{address_filter.AS}</c> : pays d'Asie</li>
|
385 |
-
<li><c>{address_filter.EU}</c> : pays d'Europe</li>
|
386 |
-
<li><c>{address_filter.NA}</c> : pays d'Amérique du Nord</li>
|
387 |
-
<li><c>{address_filter.SA}</c> : pays d'Amérique du Sud</li>
|
388 |
-
<li><c>{address_filter.OC}</c> : pays d'Océanie</li>
|
389 |
-
<li><c>{address_filter.AN}</c> : pays d'Antartique</li>
|
390 |
-
<li><c>{address_filter.EU-27}</c> : pays de l'Union Européenne</li>
|
391 |
-
<li><c>{address_filter.DOM}</c> : codes pays des département d'Outre-Mer Français</li>
|
392 |
-
<li><c>{address_filter.COM}</c> : codes pays des Collectivités d'Outre-Mer Françaises</li>
|
393 |
-
</ul>
|
394 |
-
</div>
|
395 |
-
|
396 |
-
{code=json}{
|
397 |
-
""ex0"":{""label"":""Europe sauf la France"",""shipto"":""({address_filter.EU-27}) - (FR)"",""fees"":10}
|
398 |
-
}{/code}
|
399 |
-
"
|
400 |
-
"{os2editor.help.property_billto}","
|
401 |
-
<h4><property>billto</property> : l'adresse de facturation</h4>
|
402 |
-
<p><a href=""#property_shipto"">Filtrage des adresses</a></p>
|
403 |
-
"
|
404 |
-
"{os2editor.help.property_origin}","
|
405 |
-
<h4><property>origin</property> : l'adresse d'envoi</h4>
|
406 |
-
<p><a href=""#property_shipto"">Filtrage des adresses</a></p>
|
407 |
-
"
|
408 |
-
"{os2editor.help.property_customer_groups}","
|
409 |
-
<h4><property>customer_groups</property> : les groupes client</h4>
|
410 |
-
<p>On peut utiliser le nom ou l'ID des groupes client.</p>
|
411 |
-
|
412 |
-
{code=json}{
|
413 |
-
""ex0"":{""label"":""Groupes NOT LOGGED IN et General"",""customer_groups"":""NOT LOGGED IN,General"",""fees"":10},
|
414 |
-
""ex1"":{""label"":""Groupes NOT LOGGED IN et General par leur ID"",""customer_groups"":""0,1"",""fees"":10},
|
415 |
-
""ex2"":{""label"":""Groupe Retailer"",""customer_groups"":""Retailer"",""fees"":10}
|
416 |
-
}{/code}
|
417 |
-
"
|
418 |
-
"{os2editor.help.property_fees}","
|
419 |
-
<h4><property>fees</property> : les frais de port</h4>
|
420 |
-
<p>
|
421 |
-
La propriété <property>fees</property> se spécifie sous la forme d'une <a href=""#more_formulas"">formule (voir l'initiation aux formules)</a>.
|
422 |
-
</p>
|
423 |
-
{code=json}{
|
424 |
-
""ex0"":{""label"":""Frais fixes"",""fees"":10},
|
425 |
-
""ex1"":{""label"":""Table de prix"",""fees"":""{table {cart.weight} in 0.5:5.30, 1.0:6.50}""},
|
426 |
-
""ex2"":{""label"":""Formule"",""fees"":""0.1 * {cart.price-tax+discount} + 10.00""},
|
427 |
-
""ex3"":{""label"":""Combinaison"",""fees"":""0.1 * {cart.price-tax+discount} + {table {cart.weight} in 0.5:5.30, 1.0:6.50} + 10.00""}
|
428 |
-
}{/code}
|
429 |
-
"
|
430 |
-
"{os2editor.help.property_tracking_url}","
|
431 |
-
<h4><property>tracking_url</property> : l'URL de suivi</h4>
|
432 |
-
<p class=warning>
|
433 |
-
<strong>L'utilisation de la propriété <property>tracking_url</property> est réservée aux utilisateurs expérimentés. Si vous ne comprenez pas les indications ci-dessous, il est préférable que vous évitiez d'utiliser cette fonctionnalité.</strong>
|
434 |
-
</p>
|
435 |
-
<p>
|
436 |
-
La propriété <property>tracking_url</property> permet de surcharger le champ ""URL de suivi"" d'un mode de livraison Owebia Shipping et ainsi de spécifier une URL de suivi <strong>par méthode de livraison</strong> plutôt qu'une pour tout le mode de livraison.
|
437 |
-
</p>
|
438 |
-
<p>
|
439 |
-
Pour insérer automatiquement le numéro de colis dans l'URL de suivi, vous devez utiliser <c>{tracking_number}</c>.
|
440 |
-
</p>
|
441 |
-
|
442 |
-
{code=json}{
|
443 |
-
""ex0"":{""label"":""Exemple avec URL de suivi pour le transporteur Colissimo"",""fees"":10,""tracking_url"":""http://www.coliposte.net/particulier/suivi_particulier.jsp?colispart={tracking_number}""}
|
444 |
-
}{/code}
|
445 |
-
|
446 |
-
<p>
|
447 |
-
Magento ne gère pas les liens de tracking mais un statut de tracking. L'extension Owebia Shipping 2 fournit un lien HTML à la place du statut, lien qui permet d'aller sur le site du transporteur et de suivre l'avancement de la livraison du colis.
|
448 |
-
</p>
|
449 |
-
<p>
|
450 |
-
Lorsque l'URL de suivi est construite par l'extension, la seule information disponible est le numéro de colis et on n'a nul part accès à la méthode de livraison sélectionnée. Afin de pouvoir retrouver l'url de suivi dans la configuration, il faut spécifier la méthode de livraison dans le numéro de tracking, par exemple : <c>colissimo:8Lxxxxxxxxxxx</c> où <c>colissimo</c> est le code de la méthode de livraison sélectionnée.<br/>
|
451 |
-
Si aucun code n'est spécifié (si vous saisissez uniquement le numéro de tracking), l'url utilisée sera celle globale au mode de livraison.
|
452 |
-
</p>
|
453 |
-
<p class=warning>
|
454 |
-
Pour répondre à une question récurrente, Magento affiche le statut de livraison depuis le back office ou le front office. <strong>Si vous souhaitez insérer l'URL de suivi dans les mails d'expédition, vous devrez développer vous même la récupération de l'URL de suivi et son insertion dans le mail, en effet, l'extension Owebia Shipping 2 se contente de fournir des modes de livraison paramétrables sans apporter de grande modification au coeur de Magento afin de réduire les problèmes d'incompatibilité et de mise à jour.</strong>
|
455 |
-
</p>
|
456 |
-
<p class=warning>
|
457 |
-
Si vous obtenez un popup vide lorsque vous cliquez sur le lien de suivi, votre problème est très certainement lié au fait que vous n'avez pas spécifié le code de la méthode de livraison dans le numéro de suivi (voir indications plus haut) et que votre champ global ""URL de suivi"" est vide.
|
458 |
-
</p>
|
459 |
-
<p class=warning>Il n'est actuellement pas prévu de modifier les fonctionnalitées de l'extension liées à l'URL de suivi.</p>
|
460 |
-
"
|
461 |
-
"{os2editor.help.property_enabled}","
|
462 |
-
<h4><property>enabled</property> : l'activation/désactivation</h4>
|
463 |
-
<p>Permet d'activer ou de désactiver la méthode de livraison.</p>
|
464 |
-
<p>La valeur doit être booléenne.</p>
|
465 |
-
{code=json}{
|
466 |
-
""ex0"":{""enabled"":true,""label"":""Exemple avec activation"",""fees"":10}
|
467 |
-
}{/code}
|
468 |
-
"
|
469 |
-
"{os2editor.help.more_formulas}","
|
470 |
-
<h4>Initiation aux formules</h4>
|
471 |
-
<p>
|
472 |
-
Les propriétés <property>fees</property> et <property>conditions</property> sont spécifiées sous la forme de formules.
|
473 |
-
</p>
|
474 |
-
<p>
|
475 |
-
Signes mathématiques disponibles :
|
476 |
-
</p>
|
477 |
-
<ul>
|
478 |
-
<li>opérateurs : <c>*</c>, <c>/</c>, <c>+</c> et <c>-</c></li>
|
479 |
-
<li>modulo : <c>%</c></li>
|
480 |
-
<li>parenthèses : <c>(</c> et <c>)</c></li>
|
481 |
-
<li>les opérateurs booléens <c>&&</c>, <c>and</c>, <c>||</c>, <c>or</c>, <c>==</c>, <c><</c>, <c>></c>, <c><=</c>, <c>>=</c></li>
|
482 |
-
<li>les opérateurs binaires <c>&</c> et <c>|</c></li>
|
483 |
-
<li>le groupe d'opérateur <c>C ? X : Y</c> (ex: <c><span class=string>""{cart.price_exluding_tax}>100 ? 15*{cart.weight} : 20*{cart.weight}""</span></c>)</li>
|
484 |
-
</ul>
|
485 |
-
<p>
|
486 |
-
Variables disponibles :
|
487 |
-
</p>
|
488 |
-
<ul>
|
489 |
-
<li><c>{cart.weight}</c> : poids des marchandises</li>
|
490 |
-
<li><c class=new><strike>{cart.quantity}</strike> {cart.qty}</c> : nombre d'articles dans le panier</li>
|
491 |
-
<li><c class=new><strike>{cart.price_excluding_tax}</strike> {cart.price-tax+discount}</c> : prix HT après remise</li>
|
492 |
-
<li><c class=new><strike>{cart.price_including_tax}</strike> {cart.price+tax+discount}</c> : prix TTC après remise</li>
|
493 |
-
<li><c>{cart.price-tax-discount}</c> : prix HT avant remise</li>
|
494 |
-
<li><c>{cart.price+tax-discount}</c> : prix TTC avant remise</li>
|
495 |
-
<li><a href=""#more_vars"">Voir la liste complète des variables</a></li>
|
496 |
-
</ul>
|
497 |
-
<p>
|
498 |
-
Vous avez la possibilité de mettre des espaces et des retours à la ligne dans les formules (pour aérer).
|
499 |
-
</p>
|
500 |
-
<p>
|
501 |
-
Fonctions disponibles :
|
502 |
-
</p>
|
503 |
-
<ul>
|
504 |
-
<li>arrondis : <c>round(x)</c>, <c>floor(x)</c>, <c>ceil(x)</c></li>
|
505 |
-
<li>valeur absolue : <c>abs(x)</c></li>
|
506 |
-
<li>maximum : <c>max(x,y)</c></li>
|
507 |
-
<li>minimum : <c>min(x,y)</c></li>
|
508 |
-
<li>entier aléatoire : <c>rand(min,max)</c></li>
|
509 |
-
<li>puissance : <c>pow(x,puissance)</c></li>
|
510 |
-
<li>nombre PI : <c>pi()</c></li>
|
511 |
-
<li>racine carrée : <c>sqrt(x)</c></li>
|
512 |
-
<li>logarithme : <c>log(x)</c> pour le logarithme népérien ou <c>log(x,base)</c></li>
|
513 |
-
<li>exponentiel : <c>exp(x)</c></li>
|
514 |
-
</ul>
|
515 |
-
<p>
|
516 |
-
Possibilité d'utiliser les fonctionnalités avancées suivantes : casting en entier <c>(int)</c> ou en nombre flottant <c>(float)</c>,
|
517 |
-
comparaison avec la valeur <c>null</c> ou les valeurs booléennes <c>true</c> et <c>false</c>.
|
518 |
-
</p>
|
519 |
-
<p class=new style=""font-weight: bold;"">
|
520 |
-
Vous pouvez également utiliser des fonctionnalités avancées telles que les tables de tarifs, la copie d'une propriété d'une autre méthode,
|
521 |
-
les fonctions spéciales, l'utilisation des attributs et des options des produits ou encore l'utilisation des variables personnalisées.
|
522 |
-
</p>
|
523 |
-
<p class=new style=""font-weight: bold;"">
|
524 |
-
Lorsque vous utilisez des variables qui ne sont pas numériques ou booléennes, vous devez les échapper avec des guillemets simples ou utiliser la syntaxe d'auto-échappement <c>{{ }}</c>.
|
525 |
-
</p>
|
526 |
-
{code=json}{
|
527 |
-
""ex0"":{""label"":""Échappement avec des guillemets"",""conditions"":""'{cart.coupon_code}'=='test'"",""fees"":10},
|
528 |
-
""ex1"":{""about"":""Depuis la version 2.4.5, {{cart.coupon_code}} sera remplacé par 'moncoupon' ou par null en fonction de sa valeur"",""label"":""Auto-échappement"",""conditions"":""{{cart.coupon_code}}!='test'"",""fees"":10}
|
529 |
-
}{/code}
|
530 |
-
"
|
531 |
-
"{os2editor.help.more_vars}","
|
532 |
-
<h4>Les variables disponibles</h4>
|
533 |
-
<p>
|
534 |
-
Les variables suivantes peuvent être utilisées dans les différents propriétés des méthodes de livraison (en particulier les propriétés <property>conditions</property> et <property>fees</property>).
|
535 |
-
</p>
|
536 |
-
<ul>
|
537 |
-
<li>Le panier :
|
538 |
-
<ul>
|
539 |
-
<li><c>{cart.weight}</c> : poids des marchandises</li>
|
540 |
-
<li><c class=new><strike>{cart.quantity}</strike> {cart.qty}</c> : la quantité d'articles</li>
|
541 |
-
<li class=new><c><strike>{cart.price_excluding_tax}</strike> {cart.price-tax+discount}</c> : prix HT avec remise</li>
|
542 |
-
<li class=new><c><strike>{cart.price_including_tax}</strike> {cart.price+tax+discount}</c> : prix TTC avec remise</li>
|
543 |
-
<li class=new><c>{cart.price-tax-discount}</c> : prix HT sans remise</li>
|
544 |
-
<li class=new><c>{cart.price+tax-discount}</c> : prix TTC sans remise</li>
|
545 |
-
<li class=new><c><strike>{cart.coupon}</strike> {cart.coupon_code}</c> : coupon de réduction</li>
|
546 |
-
<li><c class=new><strike>{free_shipping}</strike> {cart.free_shipping}</c> : frais de port offert (par une règle dans Magento) [true/false]</li>
|
547 |
-
<li><c class=new><strike>{cart.weight.unit}</strike> {cart.weight_unit}</c> : l'unité de poids</li>
|
548 |
-
<li><c class=new><strike>{cart.weight.for-charge}</strike> {cart.weight_for_charge}</c> : poids des marchandises dont la livraison n'est pas offerte (par les règles de prix panier de Magento)</li>
|
549 |
-
</ul>
|
550 |
-
</li>
|
551 |
-
<li class=new>Le group client :
|
552 |
-
<ul>
|
553 |
-
<li><c><strike>{customer.group.id}</strike> {customer_group.id}</c> : id du groupe client</li>
|
554 |
-
<li><c><strike>{customer.group.code}</strike> {customer_group.code}</c> : nom du groupe client</li>
|
555 |
-
<li><c>{customer_group.*}</c> : propriété du groupe client (ex: <c>{customer_group.tax_class_id}</c>)</li>
|
556 |
-
</ul>
|
557 |
-
</li>
|
558 |
-
<li class=new>Le client :
|
559 |
-
<ul>
|
560 |
-
<li><c>{customer.id}</c> : id du client</li>
|
561 |
-
<li><c>{customer.attribute.*}</c> : attribut du client (ex: lastname, firstname, group_id…)</li>
|
562 |
-
<li class=new><c>{customer.attribute.*.value}</c> : dans le cas des attributs de type liste de sélection, <c>{customer.attribute.*}</c> retourne l'id, pour obtenir la valeur il faut utiliser <c>{customer.attribute.*.value}</c></li>
|
563 |
-
<li><c>{customer.*}</c> : identique à <c>{customer.attribute.*}</c>, sauf si la variable est déjà définie (ex: <c>{customer.id}</c> est déjà définie)</li>
|
564 |
-
</ul>
|
565 |
-
</li>
|
566 |
-
<li class=new>Les variables personnalisées ou `Custom Variables` (depuis la version 1.4.0.1 de Magento) :
|
567 |
-
<ul>
|
568 |
-
<li><c>{customvar.*}</c> : variable personnalisée de Magento (ex: <c>{customvar.my_var}</c>)</li>
|
569 |
-
<li><c><strike>{{customVar code=*}}</strike></c> : utiliser la syntaxe ci-dessus</li>
|
570 |
-
</ul>
|
571 |
-
</li>
|
572 |
-
<li>L'adresse de livraison :
|
573 |
-
<ul>
|
574 |
-
<li><c class=new><strike>{destination.country.name}</strike> {shipto.country_name}</c> : le nom du pays</li>
|
575 |
-
<li><c class=new><strike>{destination.country.code}</strike> {shipto.country_id}</c> : le code du pays</li>
|
576 |
-
<li class=new><c>{shipto.region_id}</c> : l'id de la région</li>
|
577 |
-
<li><c class=new><strike>{destination.region.code}</strike> {shipto.region_code}</c> : le code de la région</li>
|
578 |
-
<li class=new><c>{shipto.street}</c> : la rue</li>
|
579 |
-
<li class=new><c>{shipto.city}</c> : la ville</li>
|
580 |
-
<li><c class=new><strike>{destination.postcode}</strike> {shipto.postcode}</c> : le code postal</li>
|
581 |
-
</ul>
|
582 |
-
</li>
|
583 |
-
<li class=new>L'adresse de facturation :
|
584 |
-
<ul>
|
585 |
-
<li><c>{billto.country_name}</c> : le nom du pays</li>
|
586 |
-
<li><c>{billto.country_id}</c> : le code du pays</li>
|
587 |
-
<li><c>{billto.postcode}</c> : le code postal</li>
|
588 |
-
<li><c>{billto.*}</c> : propriété de l'adresse de facturation (ex: <c>{billto.city}</c>)</li>
|
589 |
-
</ul>
|
590 |
-
</li>
|
591 |
-
<li>L'adresse d'envoi :
|
592 |
-
<ul>
|
593 |
-
<li><c class=new><strike>{origin.country.name}</strike> {origin.country_name}</c> : le nom du pays</li>
|
594 |
-
<li><c class=new><strike>{origin.country.code}</strike> {origin.country_id}</c> : le code du pays</li>
|
595 |
-
<li><c class=new><strike>{origin.region.code}</strike> {origin.region_id}</c> : l'id de la région</li>
|
596 |
-
<li class=new><c>{origin.city}</c> : la ville</li>
|
597 |
-
<li><c>{origin.postcode}</c> : le code postal</li>
|
598 |
-
</ul>
|
599 |
-
</li>
|
600 |
-
<li>Le magasin :
|
601 |
-
<ul>
|
602 |
-
<li><c>{store.id}</c> <c>{store.code}</c> <c>{store.name}</c> <c>{store.address}</c> <c>{store.phone}</c> : id, code, nom, adresse et téléphone du magasin</li>
|
603 |
-
</ul>
|
604 |
-
</li>
|
605 |
-
<li>La date courante :
|
606 |
-
<ul>
|
607 |
-
<li><c>{date.timestamp}</c> : timestamp UNIX de la date actuelle</li>
|
608 |
-
<li><c>{date.year}</c> <c>{date.month}</c> <c>{date.day}</c> <c>{date.hour}</c> <c>{date.minute}</c> <c>{date.second}</c> : année, mois, jour, heure, minute et seconde de la date actuelle</li>
|
609 |
-
<li><c>{date.weekday}</c> : jour de la semaine de la date actuelle de 0 (dimanche) à 6 (samedi)</li>
|
610 |
-
</ul>
|
611 |
-
</li>
|
612 |
-
<li class=new>L'objet <c>request</c> :
|
613 |
-
<ul>
|
614 |
-
<li><c>{request.*}</c> : propriété de l'objet request (Mage_Shipping_Model_Rate_Request) passé en paramètre par Magento (ex: <c>{request.package_qty}</c>). Utiliser l'option ""Déboguage"" pour obtenir plus de détail sur les propriétés disponibles.</li>
|
615 |
-
</ul>
|
616 |
-
</li>
|
617 |
-
</ul>
|
618 |
-
"
|
619 |
-
"{os2editor.help.more_special-functions}","
|
620 |
-
<h4>Fonctions spéciales dans les formules</h4>
|
621 |
-
|
622 |
-
<p>
|
623 |
-
Vous pouvez utiliser dans les formules des fonctions spéciales.
|
624 |
-
</p>
|
625 |
-
<p>
|
626 |
-
Liste des fonctions spéciales :
|
627 |
-
</p>
|
628 |
-
<ul>
|
629 |
-
<li><c>min(x, y, …)</c> : calcule le minimum entre plusieurs valeurs (éventuellement plus de deux valeurs). Si l'une des valeurs est nulle, elle est ignorée.</li>
|
630 |
-
<li><c>max(x, y, …)</c> : calcule le maximum entre plusieurs valeurs (éventuellement plus de deux valeurs). Si l'une des valeurs est nulle, elle est ignorée.</li>
|
631 |
-
<li class=new><c>range(value, min, max, include_min, include_max)</c> : retourne <c>true</c> si <c>value</c> est comprise entre <c>min</c> et <c>max</c>. Par défaut, <c>include_min</c> et <c>include_max</c> sont égales à <c>true</c>.</li>
|
632 |
-
<li class=new><c>substr(string, start, length)</c> : retourne un segment de chaîne de caractères.</li>
|
633 |
-
<li class=new><c>in_array(value, array(value1, value2, …))</c> : indique si une valeur appartient à un tableau.</li>
|
634 |
-
<li class=new><c>array_match_any(array(value1, value2, …), array(value1, value2, …))</c> : indique si au moins une valeur est présente dans les deux tableaux.</li>
|
635 |
-
<li class=new><c>array_match_all(array(value1, value2, …), array(value1, value2, …))</c> : indique si le contenu des tableaux est identique.</li>
|
636 |
-
</ul>
|
637 |
-
|
638 |
-
{code=json}{
|
639 |
-
""ex0"":{""label"":""Exemple avec fonction min"",""fees"":""min({cart.weight},{cart.price+tax+discount},{cart.qty})""},
|
640 |
-
""ex1"":{""label"":""Exemple avec fonction range"",""conditions"":""range({cart.weight},1.0,3.0)"",""fees"":10},
|
641 |
-
""ex2"":{""label"":""Exemple avec fonction substr *"",""conditions"":""substr('{cart.coupon_code}', 0, 5)=='free_'"",""fees"":10},
|
642 |
-
""ex3"":{""label"":""Exemple avec fonction in_array avec des chaînes de caractères *"",""conditions"":""in_array({{cart.coupon_code}}, array('free1', 'free2'))"",""fees"":10},
|
643 |
-
""ex4"":{""label"":""Exemple avec fonction in_array avec des nombres"",""conditions"":""in_array({cart.qty}, array(10,20,30))"",""fees"":10},
|
644 |
-
""ex5"":{""label"":""Exemple avec fonction array_match_any"",""about"":""5 x poids des produits qui se trouvent dans la catégorie 2 ou 3"",""fees"":""{sum product.weight where array_match_any(product.categories.id, array(2, 3))}*5.0""},
|
645 |
-
""ex6"":{""label"":""Exemple avec fonction array_match_all"",""about"":""5 x poids des produits qui se trouvent à la fois dans la catégorie 2 et dans la catégorie 3"",""fees"":""{sum product.weight where array_match_all(product.categories.id, array(2, 3))}*5.0""}
|
646 |
-
}{/code}
|
647 |
-
|
648 |
-
<p class=new>
|
649 |
-
* Concernant l'échappement des chaînes de caractères, se référer à l'<a href=""#more_formulas"">initiation aux formules</a>.
|
650 |
-
</p>
|
651 |
-
"
|
652 |
-
"{os2editor.help.more_copy}","
|
653 |
-
<h4>Faire une copie d'une propriété d'un autre élément</h4>
|
654 |
-
<p>Il est possible de faire une copie d'une propriété dans un autre élément à l'aide de la syntaxe ci-dessous.</p>
|
655 |
-
<p>Vous pouvez utiliser cette technique dans toutes les propriétés (<property>conditions</property>, <property>fees</property>, …).</p>
|
656 |
-
|
657 |
-
{code=json}{
|
658 |
-
""colissimo"":{""label"":""Colissimo"",""shipto"":""AD,FR,MC"",""conditions"":""{cart.price-tax+discount}<1000.00"",""fees"":""1.30 + {table {cart.weight} in 0.5:5.30, 1.0:6.50, 2.0:7.40, 3.0:8.30, 5.0:10.10}""},
|
659 |
-
""ex1"":{""label"":""Copie des conditions d'une autre méthode"",""conditions"":""({colissimo.conditions}) and ({cart.weight}>=0)"",""fees"":10},
|
660 |
-
""ex2"":{""label"":""Copie des frais de port d'une autre méthode"",""fees"":""({colissimo.fees}) + 15.00""}
|
661 |
-
}{/code}
|
662 |
-
"
|
663 |
-
"{os2editor.help.more_tables}","
|
664 |
-
<h4>Utilisation des tables <c>table</c></h4>
|
665 |
-
<p>
|
666 |
-
Dans une <c>table</c>, on peut inclure ou exclure une valeur limite avec les caractères <c>[</c> et <c>]</c> :
|
667 |
-
</p>
|
668 |
-
{code=json}{
|
669 |
-
""f0"":{""label"":""Limite supérieure incluse"",""fees"":""{table {cart.weight} in 1.0]:5.00}""},
|
670 |
-
""f1"":{""label"":""Limite supérieure exclue"",""fees"":""{table {cart.weight} in 1.0[:5.00}""}
|
671 |
-
}{/code}
|
672 |
-
|
673 |
-
<p>
|
674 |
-
Dans une <c>table</c>, on doit spécifier la valeur de référence. Pour cela, on peut utiliser une des <a href=""#more_vars"">variables disponibles</a>.<br/>
|
675 |
-
Vous pouvez aussi utiliser une formule afin de définir une autre variable de référence.
|
676 |
-
</p>
|
677 |
-
|
678 |
-
{code=json}{
|
679 |
-
""ex0"":{""label"":""Table avec poids du panier"",""fees"":""{table {cart.weight} in 0.5:5.30, 1.0:6.50}""},
|
680 |
-
""ex1"":{""label"":""Table avec quantité d'articles"",""fees"":""{table {cart.qty} in 10:5.30, 20:6.50}""},
|
681 |
-
""ex2"":{""label"":""Table avec prix TTC"",""fees"":""{table {cart.price+tax+discount} in 15.00:5.30, 30.00:6.50, *:10.00}""},
|
682 |
-
""ex3"":{""label"":""Table avec prix HT"",""fees"":""{table {cart.price-tax+discount} in 15.00:5.30, 30.00:6.50, *:10.00}""},
|
683 |
-
""ex4"":{""label"":""Table avec valeur personnalisée"",""fees"":""{table ceil({cart.weight}/10) in 1:5.30, 2:6.50}""}
|
684 |
-
}{/code}
|
685 |
-
"
|
686 |
-
"{os2editor.help.more_switch}","
|
687 |
-
<h4>Utilisation des tables de correspondance <c>switch</c></h4>
|
688 |
-
|
689 |
-
<p>
|
690 |
-
Dans un <c>switch</c>, on doit spécifier la valeur de référence. Pour cela, on peut utiliser une des <a href=""#more_vars"">variables disponibles</a>.<br/>
|
691 |
-
Vous pouvez aussi utiliser une formule afin de définir une autre variable de référence.
|
692 |
-
</p>
|
693 |
-
|
694 |
-
{code=json}{
|
695 |
-
""ex0"":{""label"":""Table de correspondance avec le coupon"",""fees"":""{switch {{cart.coupon_code}} in 'coupon1':5.30, 'coupon2':6.50, null:10.00, *:7.50}""},
|
696 |
-
""ex1"":{""label"":""Table de correspondance avec le pays de livraison"",""fees"":""{switch {{shipto.country_id}} in 'FR':5.30, 'BE':6.50, 'DE':10.00, *:7.50}""}
|
697 |
-
}{/code}
|
698 |
-
"
|
699 |
-
"{os2editor.help.more_attributes-options}","
|
700 |
-
<h4>Utilisation des propriétés des produits</h4>
|
701 |
-
|
702 |
-
<p class=new>
|
703 |
-
Afin de mieux correspondre aux Models de Magento, la version 2.4.8 de l'extension introduit la séparation entre les objects <c>item</c> et <c>product</c>.
|
704 |
-
Un <c>item</c> est une déclinaison d'un <c>product</c> auquel on a ajouté d'éventuelles options. Chaque <c>item</c> a une quantité.
|
705 |
-
</p>
|
706 |
-
<p>
|
707 |
-
Liste des propriétés disponibles :
|
708 |
-
</p>
|
709 |
-
<ul>
|
710 |
-
<li class=new>L'article (ou <c>item</c>) :
|
711 |
-
<ul>
|
712 |
-
<li><c>item.qty</c> : quantité dans le panier</li>
|
713 |
-
<li><c>item.price-tax+discount</c> : le prix HT avec remise</li>
|
714 |
-
<li><c>item.price-tax-discount</c> : le prix HT sans remise</li>
|
715 |
-
<li><c>item.price+tax+discount</c> : le prix TTC avec remise</li>
|
716 |
-
<li><c>item.price+tax-discount</c> : le prix TTC sans remise</li>
|
717 |
-
<li><c>item.option.*</c> : option (la liste des options disponibles dépendra des produits)</li>
|
718 |
-
</ul>
|
719 |
-
</li>
|
720 |
-
<li>Le produit (ou <c>product</c>) :
|
721 |
-
<ul>
|
722 |
-
<li><c><strike>product.quantity</strike></c> : utiliser <c class=new>item.qty</c></li>
|
723 |
-
<li><c>product.attribute.*</c> : attribut<br/>Liste d'attributs intéressants :
|
724 |
-
<ul>
|
725 |
-
<li><c>sku</c> : la référence</li>
|
726 |
-
<li><c>name</c> : le nom</li>
|
727 |
-
<li><c>weight</c> : le poids</li>
|
728 |
-
<li><c>price</c> : le prix (tel qu'il a été saisi sur la fiche du produit)</li>
|
729 |
-
<li><c>special_price</c> : le prix promotionnel (tel qu'il a été saisi sur la fiche du produit)</li>
|
730 |
-
<li><c><strike>price-tax+discount</strike></c> : utiliser <c class=new>item.price-tax+discount</c></li>
|
731 |
-
<li><c><strike>price-tax-discount</strike></c> : utiliser <c class=new>item.price-tax-discount</c></li>
|
732 |
-
<li><c><strike>price+tax+discount</strike></c> : utiliser <c class=new>item.price+tax+discount</c></li>
|
733 |
-
<li><c><strike>price+tax-discount</strike></c> : utiliser <c class=new>item.price+tax-discount</c></li>
|
734 |
-
</ul>
|
735 |
-
</li>
|
736 |
-
<li class=new><c>product.attribute.*.value</c> : valeur de l'attribut<br/>Dans le cas des attributs de type liste de sélection, <c>product.attribute.*</c> retourne l'id. Pour obtenir la valeur, il faut utiliser <c>product.attribute.*.value</c></li>
|
737 |
-
<li class=new><c>product.*</c> : identique à <c>product.attribute.*</c> sauf si la variable est définie (ex: <c>product.category</c>)</li>
|
738 |
-
<li><c><strike>product.option.*</strike></c> : utiliser les propriétés <c class=new>item.option.*</c></li>
|
739 |
-
<li>Première catégorie du produit :
|
740 |
-
<ul>
|
741 |
-
<li><c>product.category</c> : nom de la catégorie</li>
|
742 |
-
<li><c>product.category.id</c> : id de la catégorie</li>
|
743 |
-
<li class=new><c>product.category.*</c> : attribut de la catégorie (ex: <c>product.category.is_active</c>)<br/>Liste d'attributs intéressants :
|
744 |
-
<ul>
|
745 |
-
<li><c>is_active</c> : catégorie activée ou non</li>
|
746 |
-
<li><c>name</c> : nom</li>
|
747 |
-
<li>…</li>
|
748 |
-
</ul>
|
749 |
-
</li>
|
750 |
-
</ul>
|
751 |
-
</li>
|
752 |
-
<li>Toutes les catégories du produit (retourne un tableau, <a href=""#more_categories"">rubrique explicative</a>) :
|
753 |
-
<ul>
|
754 |
-
<li><c>product.categories</c> : tableau du nom des catégories</li>
|
755 |
-
<li><c>product.categories.id</c> : tableau de l'id des catégories</li>
|
756 |
-
</ul>
|
757 |
-
</li>
|
758 |
-
<li>Le jeu d'attributs du produit :
|
759 |
-
<ul>
|
760 |
-
<li><c>product.attribute_set</c> : nom du jeu d'attributs</li>
|
761 |
-
<li><c>product.attribute_set.id</c> : id du jeu d'attributs</li>
|
762 |
-
<li class=new><c>product.attribute_set.*</c> : attribut du jeu d'attributs (ex: <c>product.attribute_set.attribute_set_name</c>)</li>
|
763 |
-
</ul>
|
764 |
-
</li>
|
765 |
-
<li class=new><c>product.stock.*</c> : attribut du stock du produit<br/>Liste d'attributs intéressants :
|
766 |
-
<ul>
|
767 |
-
<li><c>is_in_stock</c> : disponibilité du produit</li>
|
768 |
-
<li><c>qty</c> : stock du produit</li>
|
769 |
-
<li>…</li>
|
770 |
-
</ul>
|
771 |
-
</li>
|
772 |
-
</ul>
|
773 |
-
</li>
|
774 |
-
</ul>
|
775 |
-
|
776 |
-
{code=json}{
|
777 |
-
""ex0"":{""label"":""Si au moins un produit possède l'attribut 'color' égal à 'Bleu'"",""conditions"":""{count items where product.color=='Bleu'}>0"",""fees"":10},
|
778 |
-
""ex1"":{""label"":""Si tous les produits possèdent l'option 'size' supérieure ou égal à '1'"",""conditions"":""{count items where item.option.size>='1'}=={cart.qty}"",""fees"":10},
|
779 |
-
""ex2"":{""label"":""Nombre de SKU différents"",""conditions"":""{count distinct product.sku}"",""fees"":10},
|
780 |
-
""ex3"":{""label"":""Somme de toutes les options 'size' est supérieure à 30"",""conditions"":""{sum item.option.size}>30"",""fees"":10},
|
781 |
-
""ex4"":{""label"":""Prix HT sans remise minimum des produits dans le panier est supérieur à 10"",""conditions"":""{min item.price-tax-discount}>10"",""fees"":10},
|
782 |
-
""ex5"":{""label"":""Valeur maximum de l'option 'size' des produits dans le panier est inférieure à 50"",""conditions"":""{max item.option.size}<50"",""fees"":10},
|
783 |
-
""ex6"":{""label"":""Nombre de produits en stock"",""conditions"":""{count items where product.stock.is_in_stock==true}"",""fees"":10}
|
784 |
-
}{/code}
|
785 |
-
|
786 |
-
<p>
|
787 |
-
Liste des préfixes possibles :
|
788 |
-
</p>
|
789 |
-
<ul>
|
790 |
-
<li><c>count</c> : nombre (toujours suivi de <c>items</c>)</li>
|
791 |
-
<li><c>count distinct</c> : nombre distinct (toujours suivi d'une propriété)</li>
|
792 |
-
<li><c>sum</c> : somme (toujours suivi d'une propriété)</li>
|
793 |
-
<li class=new><c>min</c> : minimum (toujours suivi d'une propriété)</li>
|
794 |
-
<li class=new><c>max</c> : maximum (toujours suivi d'une propriété)</li>
|
795 |
-
</ul>
|
796 |
-
<p>
|
797 |
-
Il est possible de spécifier des conditions que doivent remplir les produits pour être pris en compte. Pour cela, il suffit d'ajouter <c> where </c> suivi d'une formule.
|
798 |
-
</p>
|
799 |
-
<p>
|
800 |
-
Si la propriété est de type <strong>Oui/Non</strong>, vous devez utiliser les valeurs <c>true</c>/<c>false</c> ou <c>1</c>/<c>0</c> sans les guillemets.
|
801 |
-
</p>
|
802 |
-
{code=json}{
|
803 |
-
""ex0"":{""label"":""Exemple propriété de type Oui/Non : 0"",""conditions"":""{count items where product.attribute.colissimo_allowed==0}"",""fees"":10},
|
804 |
-
""ex1"":{""label"":""Exemple propriété de type Oui/Non : false"",""conditions"":""{count items where product.attribute.colissimo_allowed==false}"",""fees"":10}
|
805 |
-
}{/code}
|
806 |
-
|
807 |
-
<p>
|
808 |
-
Si la propriété est de type <strong>Liste de sélection</strong> et que vous souhaitez faire une comparaison avec <strike>l'id</strike> la valeur plutôt qu'avec <strike>la valeur</strike> l'id, vous devez utiliser la syntaxe suivante :</strike>
|
809 |
-
</p>
|
810 |
-
<strike>{code=json}{
|
811 |
-
""ex0"":{""label"":""Si l'attribut 'color' est égale à la valeur dont l'id différente de 1"",""conditions"":""{count items where product.color.id!=1}"",""fees"":10}
|
812 |
-
}{/code}</strike>
|
813 |
-
{code=json}{
|
814 |
-
""ex0"":{""label"":""Si la valeur de l'attribut 'color' est différente de 'Bleu'"",""conditions"":""{count items where product.color.value!='Bleu'}"",""fees"":10}
|
815 |
-
}{/code}
|
816 |
-
"
|
817 |
-
"{os2editor.help.more_foreach}","
|
818 |
-
<h4>Utilisation des boucles <c>foreach</c></h4>
|
819 |
-
|
820 |
-
<p>
|
821 |
-
Les boucles <c>foreach</c> permettent d'effectuer un calcul sur des groupes de produits plutôt que de tenir compte de tous les produits du panier.<br/>
|
822 |
-
Le résultat global d'une boucle <c>foreach</c> est la somme des résultats de chaque passage dans la boucle.
|
823 |
-
</p>
|
824 |
-
<p>
|
825 |
-
A l'intérieur d'une boucle <c>foreach</c>, il est possible d'utiliser de nouvelles variables :
|
826 |
-
</p>
|
827 |
-
<ul>
|
828 |
-
<li><c>{selection.weight}</c> : poids de la sélection</li>
|
829 |
-
<li><c class=new><strike>{selection.quantity}</strike> {selection.qty}</c> : nombre d'articles dans la sélection</li>
|
830 |
-
</ul>
|
831 |
-
<p>
|
832 |
-
Lorsque la sélection se fait sur le sku, chaque sélection est composée d'un seul article. On peut donc utiliser d'autres variables :
|
833 |
-
</p>
|
834 |
-
<ul>
|
835 |
-
<li><c>{item.*}</c> : propriété de l'article</li>
|
836 |
-
<li><c>{product.*}</c> : propriété du produit</li>
|
837 |
-
<li><a href=""#more_attributes-options"">Voir la liste complète des propriétés produit</a></li>
|
838 |
-
</ul>
|
839 |
-
|
840 |
-
{code=json}{
|
841 |
-
""ex0"":{""label"":""Regroupement des produits par origine puis traitement des groupes séparémment"",""fees"":""{foreach product.attribute.code_origin}{table {selection.weight} in 0.0:0.00, 1.0:11.00, 3.0:12.00, 5.0:13.00}{/foreach}""},
|
842 |
-
""ex1"":{""label"":""Calcul des frais de port par produit"",""fees"":""{foreach product.attribute.sku}{product.attribute.shipping}*{item.qty}{/foreach}""}
|
843 |
-
}{/code}
|
844 |
-
"
|
845 |
-
"{os2editor.help.more_categories}","
|
846 |
-
<h4>Cas particulier : exemples d'utilisation des catégories de produits</h4>
|
847 |
-
|
848 |
-
<p>
|
849 |
-
Depuis la version 2.4.2, il est possible d'utiliser les catégories des produits dans les formules.
|
850 |
-
</p>
|
851 |
-
<p class=warning>
|
852 |
-
<strong>Attention, il est à noter que dans Magento, un produit peut être dans plusieurs catégories.</strong> Faites donc particulièrement attention à la façon dont vous utilisez cette propriété.
|
853 |
-
</p>
|
854 |
-
<p>
|
855 |
-
Pour filtrer les produits qui se trouvent dans plusieurs catégories spécifiques, vous pouvez utiliser la fonction <c>array_match_any()</c>.
|
856 |
-
</p>
|
857 |
-
<p>
|
858 |
-
Voici quelques exemples d'utilisation :
|
859 |
-
</p>
|
860 |
-
{code=json}{
|
861 |
-
""ex0"":{""label"":""Boucle foreach dont l'itération se fait sur la catégorie"",""fees"":""{foreach product.categories}{selection.weight}{/foreach}""},
|
862 |
-
""ex1"":{""label"":""Utilisation de la catégorie à l'intérieur d'une boucle foreach"",""fees"":""{foreach product.sku}({{product.category}}=='Test' ? 2.00 : 1.00)*{item.qty}{/foreach}""},
|
863 |
-
""ex2"":{""label"":""Utilisation de l'id de la catégorie à l'intérieur d'une boucle foreach"",""fees"":""{foreach product.sku}({product.category.id}==12 ? 2.00 : 1.00)*{item.qty}{/foreach}""},
|
864 |
-
""ex3"":{""about"":""La fonction in_array() est utilisée car product.categories retourne un tableau"",""label"":""Somme des attributs weight des produits de la catégorie 'Test'"",""fees"":""{sum product.weight where in_array('Test', product.categories)}""},
|
865 |
-
""ex4"":{""about"":""La fonction in_array() est utilisée car product.categories.id retourne un tableau"",""label"":""Somme des attributs weight des produits de la catégorie dont l'id est 12"",""fees"":""{sum product.weight where in_array(12, product.categories.id)}""},
|
866 |
-
""ex5"":{""about"":""La fonction array_match_any() est utilisée car product.categories.id retourne un tableau"",""label"":""Somme des attributs weight des produits des catégories dont les id sont 11 et 12"",""fees"":""{sum product.weight where array_match_any(product.categories.id, array(11, 12))}""},
|
867 |
-
""ex6"":{""label"":""Somme des poids des produits dont la première catégorie est 'Test'"",""fees"":""{sum product.weight where product.category=='Test'}""},
|
868 |
-
""ex7"":{""label"":""Somme des poids des produits dont l'id de la première catégorie est 12"",""fees"":""{sum product.weight where product.category.id==12}""}
|
869 |
-
}{/code}
|
870 |
-
"
|
871 |
-
"{os2editor.help.changelog}","
|
872 |
-
<h4>Changelog</h4>
|
873 |
-
<div class=changelog>{changelog}</div>
|
874 |
-
"
|
74 |
"Export","Exporter"
|
75 |
"Add a shipping method","Ajouter une méthode de livraison"
|
76 |
"New shipping method","Nouvelle méthode de livraison"
|
|
|
|
|
77 |
|
78 |
# app/code/community/Owebia/Shipping2/etc/system.xml
|
79 |
"Configuration","Configuration"
|
97 |
"Item data on","Données de l'article sur"
|
98 |
"Product data on","Données du produit sur"
|
99 |
|
100 |
+
# app/code/community/Owebia/Shipping2/Model/ConfigParser.php
|
101 |
"Configuration disabled","Configuration désactivée"
|
102 |
"The cart doesn't match conditions","Le panier ne correspond pas aux conditions"
|
103 |
"Infinite loop %s","Boucle infinie %s"
|
126 |
# app/code/community/Owebia/Shipping2/Model/System/Config/Source/ProcessChildren.php
|
127 |
"Self","Lui-même"
|
128 |
"Children","Enfants"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Owebia_Shipping_2</name>
|
4 |
-
<version>2.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/MIT">The MIT License (MIT)</license>
|
7 |
<channel>community</channel>
|
@@ -10,7 +10,12 @@
|
|
10 |
<description>[EN] This module provides 3 shipping modes configurable with a very flexible syntax.
|
11 |

|
12 |
[FR] Ce module met à disposition 3 modes de livraison configurables avec une syntaxe très souple.</description>
|
13 |
-
<notes>[2.
|
|
|
|
|
|
|
|
|
|
|
14 |
Update documentation
|
15 |

|
16 |
[2.5.23 - August 18, 2016]
|
@@ -39,9 +44,9 @@ Fix bug: usage of regular expressions inside {count ...}, {sum ...}, {min ...} a
|
|
39 |
Allow usage of php functions date and strtotime (ex: "label": "'Your package will be delivered between ' . date('d/m', strtotime('+5 days')) . ' and ' . date('d/m Y', strtotime('+7 days'))",
|
40 |
</notes>
|
41 |
<authors><author><name>owebia</name><user>owebia</user><email>antoine.lemoine@owebia.com</email></author></authors>
|
42 |
-
<date>2016-
|
43 |
-
<time>
|
44 |
-
<contents><target name="magecommunity"><dir name="Owebia"><dir name="Shipping2"><dir name="Block"><dir name="Adminhtml"><dir name="Os2"><dir name="Editor"><dir name="Property"><file name="Input.php" hash="
|
45 |
<compatible/>
|
46 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
47 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Owebia_Shipping_2</name>
|
4 |
+
<version>2.6.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/MIT">The MIT License (MIT)</license>
|
7 |
<channel>community</channel>
|
10 |
<description>[EN] This module provides 3 shipping modes configurable with a very flexible syntax.
|
11 |

|
12 |
[FR] Ce module met à disposition 3 modes de livraison configurables avec une syntaxe très souple.</description>
|
13 |
+
<notes>[2.6.0 - October 24, 2016]
|
14 |
+
Refactor code to comply to Magento coding standards
|
15 |
+
Remove compress functionality
|
16 |
+
Only one carrier available for new installations
|
17 |
+

|
18 |
+
[2.5.24 - September 07, 2016]
|
19 |
Update documentation
|
20 |

|
21 |
[2.5.23 - August 18, 2016]
|
44 |
Allow usage of php functions date and strtotime (ex: "label": "'Your package will be delivered between ' . date('d/m', strtotime('+5 days')) . ' and ' . date('d/m Y', strtotime('+7 days'))",
|
45 |
</notes>
|
46 |
<authors><author><name>owebia</name><user>owebia</user><email>antoine.lemoine@owebia.com</email></author></authors>
|
47 |
+
<date>2016-10-24</date>
|
48 |
+
<time>19:47:17</time>
|
49 |
+
<contents><target name="magecommunity"><dir name="Owebia"><dir name="Shipping2"><dir name="Block"><dir name="Adminhtml"><dir name="Os2"><dir name="Editor"><dir name="Property"><file name="Input.php" hash="8cdb100fd25222c7450a25ff873cd1da"/></dir></dir><file name="Editor.php" hash="16e246b791a5a685f6027cf335bfe5df"/><file name="Help.php" hash="d2e37784656cc951aeba3942be0ac42f"/></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Config.php" hash="cb6502a0695a8dcb57f56b5d5303676b"/><file name="Informations.php" hash="32b8e4d0903a4cb0be8bdd3c1b142266"/></dir></dir></dir></dir></dir></dir><dir name="Controller"><file name="Abstract.php" hash="fa15391be4efc43358c3277653eecf37"/></dir><dir name="Helper"><file name="Data.php" hash="730481ebb1ee55c64a4f9dad4dca13bf"/></dir><dir name="Model"><file name="AddressFilterParser.php" hash="08d0a219d1f4de294544283864b92938"/><dir name="Carrier"><file name="Abstract.php" hash="d1d5bea90009c28e32c856e84d2113cc"/><file name="OwebiaShipping1.php" hash="9467b52a584de6a7bd9ee08065bc1f97"/><file name="OwebiaShipping2.php" hash="524c6e94b4ea199a1bdc1df2bbd312da"/></dir><file name="ConfigParser.php" hash="62dc6435d348295375c6e4a9dd5e823f"/><dir name="Os2"><dir name="Data"><file name="Abstract.php" hash="d6aaf0134a616a9833606e970ccfa264"/><file name="AbstractWithAttributes.php" hash="d4c7ce6ab00494c23488701107406520"/><file name="Address.php" hash="79e07b1df46f44ef8da19f5fc1c0cd32"/><file name="AddressFilter.php" hash="5917e91072a9dd5736378554c4ee3003"/><file name="AttributeSet.php" hash="068f1deab8dea7be870fa538c4a9fad5"/><file name="Billto.php" hash="f4ed4db12b8a73e217eddd76766903a6"/><file name="Cart.php" hash="5670ffb3647ff6d9d62b56ac5a0b1597"/><file name="CartItem.php" hash="160931a51d30bf7b57209eb739d788d8"/><file name="Category.php" hash="6c862821fb6fbce53184349483b86a55"/><file name="Customer.php" hash="efe4aeb8faaa74cbc9040048fdbfbdca"/><file name="CustomerGroup.php" hash="fd499150ee9e91129127859d5d8c7eda"/><file name="Customvar.php" hash="6d3b0ca09d1490cba4c0c4dd776389ad"/><file name="Date.php" hash="4d7037c3c5965de97d1c5b124abba916"/><file name="Info.php" hash="868413ebd17d4cb178eb6ed59c476d37"/><file name="Product.php" hash="47e261d33a6cf982ca2e6631d2bafb14"/><file name="Quote.php" hash="a6e91dff929f7edc0cb95d37c0210e0e"/><file name="Selection.php" hash="fcb23bf8b4dfa32d1f82881d35f71805"/><file name="StockItem.php" hash="25b1f47002a82e65aa5e583b290b121c"/><file name="Store.php" hash="0376a14dc46b9b4b64ff37d651efa3c6"/></dir><file name="Data.php" hash="def44564356396bd3763dafa90a65b9d"/><file name="Message.php" hash="1024d52be591b6041396f49f2f524189"/><file name="Result.php" hash="ab72e49c33d2b3109244ccd899f7b3ad"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="LoadOnParent.php" hash="563a0e86b4efb6605a801e30a6382616"/><file name="ProcessChildren.php" hash="b095a31901d440ba44f0e5a9e94978ec"/></dir></dir></dir></dir><file name="changelog" hash="089483fa57abc43764207465a01db9ed"/><dir name="controllers"><dir name="Adminhtml"><dir name="Os2"><file name="AjaxController.php" hash="60114592152cfab7557654d46428912c"/></dir></dir><dir name="Checkout"><file name="CartController.php" hash="0195801073b3a6a4e6e69d76535ee6b4"/></dir></dir><file name="doc_en_US.html" hash="6d2473aec6ea75585472d54924708d77"/><file name="doc_fr_FR.html" hash="976893cc9971eaa5589ab18791f978b3"/><dir name="etc"><file name="adminhtml.xml" hash="035d9b8e49872922a7566471d2f65837"/><file name="config.xml" hash="595fcc9c0614e19e723e50286d2cb954"/><file name="system.xml" hash="01a80a7e56ced4ccd159ede356d99c06"/></dir><dir name="sql"><dir name="owebia_shipping2_setup"><file name="mysql4-install-2.5.13.php" hash="80e6429fc6913a49214363f99685d1f1"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Owebia_Shipping2.xml" hash="dc47154a03320de3c514a8340c6a17e4"/></dir></target><target name="magelocale"><dir name="fr_FR"><file name="Owebia_Shipping2.csv" hash="6b8253c74586bf8729301c494af74b98"/></dir><dir name="en_US"><file name="Owebia_Shipping2.csv" hash="e7cf17d6f42d6f5a831d8b5e00c19049"/></dir></target><target name="mageweb"><dir name="js"><dir name="owebia"><dir name="shipping2"><dir name="colorbox"><file name="colorbox.css" hash="1a7dd23f5d2962260d5bb26a57046db1"/><dir name="images"><file name="border.png" hash="439d585a4e35279cf1eddec5729f7144"/><file name="border.png-" hash="7ca8a1d2eb0763b35c266cd54bee2fa5"/><file name="controls.png" hash="4cbe54bbf6c352ea181a5739842215e2"/><file name="controls.png-" hash="b68b9ecaae424de4862ba0d055b7a560"/><dir name="ie6"><file name="borderBottomCenter.png" hash="1936585831e8bcf4eb5ef1081c8e2574"/><file name="borderBottomLeft.png" hash="7ceeb01563f030dc47837fd8bad29488"/><file name="borderBottomRight.png" hash="297fb77440870d91f519bcecdb312725"/><file name="borderMiddleLeft.png" hash="64df0244eeaade27764d2cf33606527b"/><file name="borderMiddleRight.png" hash="9fa458eaaa35b80b2452f35a1d6b4d0c"/><file name="borderTopCenter.png" hash="01ecb01841270f3a765aadf4900929f3"/><file name="borderTopLeft.png" hash="bf4949b95b09d255edd9bcb8358a3557"/><file name="borderTopRight.png" hash="51315fa19507a33d5f1b5411598593e7"/></dir><file name="loading.gif" hash="e6611f867d63754b7a2a974fb0a0e7dc"/><file name="loading_background.png" hash="acf427e932fb9413700a4b8b58b41eec"/><file name="overlay.png" hash="790376e15a036959e358a19d4a7ea437"/></dir><file name="jquery.colorbox-min.js" hash="afa27e7333f494cf87e4c07297c2160b"/></dir><dir name="img"><file name="btn-edit.png" hash="abc9f604977fc6dc75547a2e04c9748f"/><file name="btn-help.png" hash="b743486f26c3b69871490049147ef14b"/><file name="btn-remove.png" hash="42492684e24356a4081134894eabeb9e"/><dir name="famfamsilk"><file name="help.png" hash="c3812c74bc524179f4ccf5d2db7b3cbf"/><file name="pencil.png" hash="a34e71ab08a6d1162b948d26321dea50"/></dir></dir><file name="jquery-1.8.2.min.js" hash="cfa9051cc0b05eb519f1e16b2a6645d7"/><dir name="jquery-ui-1.8.23.custom"><dir name="css"><dir name="ui-lightness"><dir name="images"><file name="ui-bg_diagonals-thick_18_b81900_40x40.png" hash="95f9cceeb9d742dd3e917ec16ed754f8"/><file name="ui-bg_diagonals-thick_20_666666_40x40.png" hash="f040b255ca13e693da34ab33c7d6b554"/><file name="ui-bg_flat_10_000000_40x100.png" hash="c18cd01623c7fed23c80d53e2f5e7c78"/><file name="ui-bg_glass_100_f6f6f6_1x400.png" hash="5f1847175ba18c41322cb9cb0581e0fb"/><file name="ui-bg_glass_100_fdf5ce_1x400.png" hash="d26e8f463195a7b86f86b7d550cfc114"/><file name="ui-bg_glass_65_ffffff_1x400.png" hash="e5a8f32e28fd5c27bf0fed33c8a8b9b5"/><file name="ui-bg_gloss-wave_35_f6a828_500x100.png" hash="58d2cd501e01573cf537089c694ba899"/><file name="ui-bg_highlight-soft_100_eeeeee_1x100.png" hash="384c3f17709ba0f809b023b6e7b10b84"/><file name="ui-bg_highlight-soft_75_ffe45c_1x100.png" hash="b806658954cb4d16ade8977af737f486"/><file name="ui-icons_222222_256x240.png" hash="ebe6b6902a408fbf9cac6379a1477525"/><file name="ui-icons_228ef1_256x240.png" hash="79f41c0765e9ec18562b20b0801d748b"/><file name="ui-icons_ef8c08_256x240.png" hash="ef9a6ccfe3b14041928ddc708665b226"/><file name="ui-icons_ffd27a_256x240.png" hash="ab8c30acc0e3608fb79e01fccf832c70"/><file name="ui-icons_ffffff_256x240.png" hash="342bc03f6264c75d3f1d7f99e34295b9"/></dir><file name="jquery-ui-1.8.23.custom.css" hash="d4a4e04116e9bed6a2b00c5e8c260914"/></dir></dir><dir name="js"><file name="jquery-1.8.0.min.js" hash="cd8b0bffc85bb5614385ee4ce3596d07"/><file name="jquery-ui-1.8.23.custom.min.js" hash="c406c4654466fbeee1cf9173b69ec55c"/></dir></dir><file name="jquery.caret.1.02.min.js" hash="ee130de5e6b9ae2be7579a5fd77f7b23"/><file name="jquery.layout-1.3.0-rc30.6.min.js" hash="745e5e2084b6330c3f837a0169a96320"/><file name="jquery.layout.min.js" hash="d91b61c69554cd02f4cf3bbbf97b95a8"/><file name="jquery.noconflict.js" hash="3179f2255b046d5f2e9a71e365287bef"/><file name="os2editor.css" hash="96805f469cf7d6f2a7269d5d372fa46b"/><file name="os2editor.js" hash="107807e905cb39f178c1e349c7d89cb8"/></dir></dir></dir></target><target name="mage"><dir name="."><file name="README.md" hash="f3cf1845ab56b7f884bff0c063b73aca"/></dir></target></contents>
|
50 |
<compatible/>
|
51 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
52 |
</package>
|