Witam,
Mam problem z koszykiem (presta 1.7), a mianowicie gdy produkt jest w koszyku przy zwiększaniu/zmniejszaniu przyciskami +/- przy produkcie bądź usuwaniu z koszyka nic się nie dzieje (nie zmienia się automatycznie, ani produkt analogicznie się nie usuwa) - dopóki nie odświeżę strony. Templatka nie jest domyślna classic. Podejrzewam że problem jest gdzieś w js. Jestem w js totalnie noga ale wydaje mi się że to ten fragment:
Quote/**
* Attach Bootstrap TouchSpin event handlers
*/
function createSpin() {
_jquery2['default'].each((0, _jquery2['default'])(spinnerSelector), function (index, spinner) {
(0, _jquery2['default'])(spinner).TouchSpin({
verticalbuttons: true,
verticalupclass: 'material-icons touchspin-up',
verticaldownclass: 'material-icons touchspin-down',
buttondown_class: 'btn btn-touchspin js-touchspin js-increase-product-quantity',
buttonup_class: 'btn btn-touchspin js-touchspin js-decrease-product-quantity',
min: parseInt((0, _jquery2['default'])(spinner).attr('min'), 10),
max: 1000000
});
});
}
(0, _jquery2['default'])(document).ready(function () {
var productLineInCartSelector = '.js-cart-line-product-quantity';
var promises = [];
_prestashop2['default'].on('updateCart', function () {
(0, _jquery2['default'])('.quickview').modal('hide');
});
createSpin();
var $body = (0, _jquery2['default'])('body');
function isTouchSpin(namespace) {
return namespace === 'on.startupspin' || namespace === 'on.startdownspin';
}
function shouldIncreaseProductQuantity(namespace) {
return namespace === 'on.startupspin';
}
function findCartLineProductQuantityInput($target) {
var $input = $target.parents('.bootstrap-touchspin').find(productLineInCartSelector);
if ($input.is(':focus')) {
return null;
} else {
return $input;
}
}
function camelize(subject) {
var actionTypeParts = subject.split('-');
var i = undefined;
var part = undefined;
var camelizedSubject = '';
for (i = 0; i < actionTypeParts.length; i++) {
part = actionTypeParts;
if (0 !== i) {
part = part.substring(0, 1).toUpperCase() + part.substring(1);
}
camelizedSubject = camelizedSubject + part;
}
return camelizedSubject;
}
function parseCartAction($target, namespace) {
if (!isTouchSpin(namespace)) {
return {
url: $target.attr('href'),
type: camelize($target.data('link-action'))
};
}
var $input = findCartLineProductQuantityInput($target);
if (!$input) {
return;
}
var cartAction = {};
if (shouldIncreaseProductQuantity(namespace)) {
cartAction = {
url: $input.data('up-url'),
type: 'increaseProductQuantity'
};
} else {
cartAction = {
url: $input.data('down-url'),
type: 'decreaseProductQuantity'
};
}
return cartAction;
}
var abortPreviousRequests = function abortPreviousRequests() {
var promise;
while (promises.length > 0) {
promise = promises.pop();
promise.abort();
}
};
var getTouchSpinInput = function getTouchSpinInput($button) {
return (0, _jquery2['default'])($button.parents('.bootstrap-touchspin').find('input'));
};
var handleCartAction = function handleCartAction(event) {
event.preventDefault();
var $target = (0, _jquery2['default'])(event.currentTarget);
var cartAction = parseCartAction($target, event.namespace);
var requestData = {
ajax: '1',
action: 'update'
};
if (typeof cartAction === 'undefined') {
return;
}
abortPreviousRequests();
_jquery2['default'].ajax({
url: cartAction.url,
method: 'POST',
data: requestData,
dataType: 'json',
beforeSend: function beforeSend(jqXHR) {
promises.push(jqXHR);
}
}).then(function (resp) {
var $quantityInput = getTouchSpinInput($target);
$quantityInput.val(resp.quantity);
// Refresh cart preview
_prestashop2['default'].emit('updateCart', {
reason: $target.dataset
});
}).fail(function (resp) {
_prestashop2['default'].emit('handleError', {
eventType: 'updateProductInCart',
resp: resp,
cartAction: cartAction.type
});
});
};
$body.on('click', '[data-link-action="delete-from-cart"], [data-link-action="remove-voucher"]', handleCartAction);
(0, _jquery2['default'])(spinnerSelector).on('touchspin.on.startdownspin', handleCartAction);
(0, _jquery2['default'])(spinnerSelector).on('touchspin.on.startupspin', handleCartAction);
function sendUpdateQuantityInCartRequest(updateQuantityInCartUrl, requestData, $target) {
abortPreviousRequests();
return _jquery2['default'].ajax({
url: updateQuantityInCartUrl,
method: 'POST',
data: requestData,
dataType: 'json',
beforeSend: function beforeSend(jqXHR) {
promises.push(jqXHR);
}
}).then(function (resp) {
$target.val(resp.quantity);
var dataset;
if ($target) {
dataset = $target.dataset;
} else {
dataset = null;
}
// Refresh cart preview
_prestashop2['default'].emit('updateCart', {
reason: dataset
});
}).fail(function (resp) {
_prestashop2['default'].emit('handleError', { eventType: 'updateProductQuantityInCart', resp: resp });
});
}
function getRequestData(quantity) {
return {
ajax: '1',
qty: Math.abs(quantity),
action: 'update',
op: getQuantityChangeType(quantity)
};
}
function getQuantityChangeType($quantity) {
return $quantity > 0 ? 'up' : 'down';
}
function updateProductQuantityInCart(event) {
var $target = (0, _jquery2['default'])(event.currentTarget);
var updateQuantityInCartUrl = $target.data('update-url');
var baseValue = $target.attr('value');
// There should be a valid product quantity in cart
var targetValue = $target.val();
if (targetValue != parseInt(targetValue) || targetValue < 0 || isNaN(targetValue)) {
$target.val(baseValue);
return;
}
// There should be a new product quantity in cart
var qty = targetValue - baseValue;
if (qty == 0) {
return;
}
var requestData = getRequestData(qty);
sendUpdateQuantityInCartRequest(updateQuantityInCartUrl, requestData, $target);
}
$body.on('focusout', productLineInCartSelector, function (event) {
updateProductQuantityInCart(event);
});
$body.on('keyup', productLineInCartSelector, function (event) {
if (event.keyCode == 13) {
updateProductQuantityInCart(event);
}
});
$body.on('click', '.js-discount .code', function (event) {
event.stopPropagation();
var $code = (0, _jquery2['default'])(event.currentTarget);
var $discountInput = (0, _jquery2['default'])('[name=discount_name]');
$discountInput.val($code.text());
return false;
});
});
Z góry dziękuję za pomoc