Есть возможность добавить товары в Список желаний с количеством и другими атрибутами в корзину в prestashop

Можно ли добавить товары в избранное в корзину в prestashop?

Я использовал приведенный ниже код в managewishlist.tpl, чтобы добавить товар в корзину и удалить его из списка желаний.

<a class="button btn-default ajax_add_to_cart_button btn btn-default"href="{$link->getPageLink('cart',false, NULL, "add=1&amp;id_product={$product.id_product|intval}&amp;qty={$product.quantity}", false)|escape:'html':'UTF-8'}"rel="nofollow" title="{l s='Add to cart'}"data-id-product="{$product.id_product|intval}"onclick="WishlistProductManage('wlp_bought', 'delete', '{$id_wishlist}', '{$product.id_product}', '{$product.id_product_attribute}', $('#quantity_{$product.id_product}_{$product.id_product_attribute}').val(), $('#priority_{$product.id_product}_{$product.id_product_attribute}').val());">
<span>{l s='Add to cart'}</span>
</a>

пожалуйста, дайте мне знать, как передать значение количества, чтобы я мог получить результат.

например, если у меня есть один продукт в списке желаний и его количество составляет 3.

поэтому, когда я нажимаю на добавить в корзину, он должен добавить 3 количества того же продукта.

Также дайте мне знать, как я могу передать цвет и размер атрибута, который доступен в списке пожеланий.

1

Решение

Код для кнопки (в темах / your_template / modules / blockwishlist / views / templates / front / managewishlist.tpl:

<a class="exclusive button ajax_add_to_cart_button add-to-cart-in-wl" href="{$link->getPageLink('cart', true, NULL, "qty={$product.quantity|intval}&amp;id_product={$product.id_product|intval}&amp;add")|escape:'html':'UTF-8'}" data-id-attribute="{$product.id_product_attribute}" data-id-product="{$product.id_product|intval}" data-minimal_quantity="{$product.quantity|intval}" title="{l s='Add to cart' mod='blockwishlist'}"><span>{l s='Add to cart' mod='blockwishlist'}</span></a>

И вам нужно изменить код в файле themes / your_template / js / modules / blockcart / ajax-cart.js, который обрабатывает событие «click» для элемента «.ajax_add_to_cart_button»:

$(document).off('click', '.ajax_add_to_cart_button').on('click', '.ajax_add_to_cart_button', function(e){
e.preventDefault();
var idProduct =  parseInt($(this).data('id-product'));
var idProductAttribute =  parseInt($(this).data('id-product-attribute'));
var minimalQuantity =  parseInt($(this).data('minimal_quantity'));
if ($(this).is('.add-to-cart-in-wl')) {
quan = $(this).closest('.product_infos').find('.wishlist_product_detail input.form-control').val();
if (quan != minimalQuantity)
minimalQuantity = quan;
}
if (!minimalQuantity)
minimalQuantity = 1;
if ($(this).prop('disabled') != 'disabled')
ajaxCart.add(idProduct, idProductAttribute, false, this, minimalQuantity);
});
2

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector