Автор Тема: Кнопка добавить в корзину - в корзине  (Прочитано 341 раз)

18 Август 2018, 23:38:22
  • Ветеран
  • *****
  • Сообщений: 520
  • Репутация: +4/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Добрый день, понадобилось добавить кнопку - купить, в выпадающем блоке корзины в шапке. Добавила в blockcart.tpl и в ajax-cart.jsvar domIdProduct = this.id + '_' + (this.idCombination ? this.idCombination : '0') + '_' + (this.idAddressDelivery ? this.idAddressDelivery : '0');
                var domIdProductAttribute = this.id + '_' + (this.idCombination ? this.idCombination : '0');

                if ($('dt[data-id="cart_block_product_' + domIdProduct + '"]').length == 0)
                {
                    var productId = parseInt(this.id);
                    var productAttributeId = (this.hasAttributes ? parseInt(this.attributes) : 0);
                    var content = '<dt class="unvisible" data-id="cart_block_product_' + domIdProduct + '">';
                    var name = $.trim($('<span />').html(this.name).text());
                    name = (name.length > 12 ? name.substring(0, 10) + '...' : name);
                    content += '<a class="cart-images" href="' + this.link + '" title="' + name + '"><img  src="' + this.image_cart + '" alt="' + this.name + '"></a>';
                    content += '<a class="button ajax_add_to_cart_button" href="' + this.link + '"></a>';
                    content += '<div class="cart-info"><div class="product-name">' + '<span class="quantity-formated"><span class="quantity">' + this.quantity + '</span>&nbsp;x&nbsp;</span><a href="' + this.link + '" title="' + this.name + '" class="cart_block_product_name">' + name + '</a></div>';
                    if (this.hasAttributes)
                        content += '<div class="product-atributes"><a href="' + this.link + '" title="' + this.name + '">' + this.attributes + '</a></div>';
                    if (typeof (freeProductTranslation) != 'undefined')
                        content += '<span class="price">' + (parseFloat(this.price_float) > 0 ? this.priceByLine : freeProductTranslation) + '</span></div>';

                    if (typeof (this.is_gift) == 'undefined' || this.is_gift == 0)
                        content += '<span class="remove_link"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseUri + '?controller=cart&amp;delete=1&amp;id_product=' + productId + '&amp;token=' + static_token + (this.hasAttributes ? '&amp;ipa=' + parseInt(this.idCombination) : '') + '"> </a></span>';
                    else
                        content += '<span class="remove_link"></span>';
                    content += '</dt>';
                    if (this.hasAttributes)
                        content += '<dd data-id="cart_block_combination_of_' + domIdProduct + '" class="unvisible">';
                    if (this.hasCustomizedDatas)
                        content += ajaxCart.displayNewCustomizedDatas(this);
                    if (this.hasAttributes)
                        content += '</dd>';

                    $('.cart_block dl.products').append(content);
                }

Но проблема, что кнопка добавляется только после перезагрузки страницы, как сделать , чтобы она сразу появлялась при добавлении товара в корзину.
19 Август 2018, 10:41:26
Ответ #1
  • Ветеран
  • *****
  • Сообщений: 1808
  • Репутация: +49/-1
  • Сообщество PrestaShop
    • Просмотр профиля
В $(document).ready(function() можно показать кнопку при загрузке $('ид/класс кноки').show();
19 Август 2018, 14:15:00
Ответ #2
  • Ветеран
  • *****
  • Сообщений: 3419
  • Репутация: +79/-6
  • Сообщество PrestaShop
    • Просмотр профиля
В стилях поставить display:block для кнопки и сразу будет показанна.