Добрый день.
В ОС 2.02 пытаюсь использовать для обновления корзины cart.update():
'update': function(key, quantity) {
$.ajax({
url: 'index.php?route=checkout/cart/edit',
type: 'post',
data: 'key=' + key + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1),
dataType: 'json',
beforeSend: function() {
$('#cart > button').button('loading');
},
complete: function() {
$('#cart > button').button('reset');
},
success: function(json) {
// Need to set timeout otherwise it wont update the total
setTimeout(function () {
$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
}, 100);
if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
location = 'index.php?route=checkout/cart';
} else {
$('#cart > ul').load('index.php?route=common/cart/info ul li');
}
}
});
},
На запрос
key "YToxOntzOjEwOiJwcm9kdWN0X2lkIjtpOjQyO30"
quantity "4"
Получаю ответ:
<b>Warning</b>: Invalid argument supplied for foreach() in <b>/Users/MacBook/Sites/TEXNOSALES/catalog/controller/checkout/cart.php</b> on line <b>414</b><b>Warning</b>: Cannot modify header information - headers already sent by (output started at /Users/MacBook/Sites/TEXNOSALES/index.php:102) in <b>/Users/MacBook/Sites/TEXNOSALES/system/library/response.php</b> on line <b>12</b>
foreach:
if (!empty($this->request->post['quantity'])) {
foreach ($this->request->post['quantity'] as $key => $value) {
$this->cart->update($key, $value);
}
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
unset($this->session->data['reward']);
$this->response->redirect($this->url->link('checkout/cart'));
}
и так с любой позицией.
html запрос работает, но хотелось бы разобраться с JSON.
Пробовал в свежей установке ОС 2.02 в дефолтной теме и то же самое.
Подскажите пожалуйста, что я делаю не так?
Благодарю.