Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Иконка Корзины то есть то нет


Gamburg
 Share

Recommended Posts

Добрый гдень, появилась проблема - есть изображение корзины, рядом вывод когдачества в кружке (рис.1), после добавления товара, изображение корзины пропадает, кружок с когдачеством вигден и обновился до единицы (рис.2), после перезагрузки, появляется изображение корзины, кружок с единиэтот тоже вигден (рис.3).

Нажимаем на изображение корзины открывается мнонькое окно с добавленным товаром, удаляем товар, пропадает изображение корзины, кружок с когдачеством вигден и обновился до нуля (рис.4), перезагружаем страницу, видим изображение корзины, кружок с когдачеством нуль тоже вигден (рис.1).

Помогите разобраться ггде я мог допустить ошибку - вывод изображения корзины с добавленным товаром и почему нужна перезагрузка страницы для появления изображения корзины?.

1) error01.jpg.127c9f3bb216a7821f7a45078de0e732.jpg

2) error02.jpg.18ee0f38dab92f78f305d55079e4e81e.jpg

3) error022.jpg.0aab05cea9f9c707a2c6142f3ff59192.jpg

4) error03.jpg.2369daa922ff49d7857c21619b508c6e.jpg

Link to comment
Share on other sites


скорее всего нужно смотреть, что им происходит при добавлении товара в корзину ( add - при добавлении товара в корзину) и при обновлении (update) 

Edited by sasha3337774
Link to comment
Share on other sites

Вот HTML код корзины:

  <button type="button" data-toggle="dropdown" data-loading-text="Загрузка..." class="btn btn-inverse btn-block btn-lg dropdown-toggle">
    <span id="cart-total">0</span>
    <span class="cart-icon"></span>
  </button>

 

ггде:

<span class="cart-icon"></span>

изображение корзины

 

после добавления товара:

  <button type="button" data-toggle="dropdown" data-loading-text="Загрузка..." class="btn btn-inverse btn-block btn-lg dropdown-toggle">
    <span id="cart-total">0</span>
  </button>

 

т.е. <span class="cart-icon"></span> 

отсутствует

---------------------------------------------------

common.js

// Cart add remove functions
var cart = {
    'add': function(product_id, quantity) {
        $.ajax({
            url: 'index.php?route=checkout/cart/add',
            type: 'post',
            data: 'product_id=' + product_id + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1),
            dataType: 'json',
            success: function(json) {
                if (json['redirect']) {
                    location = json['redirect'];
                }

                if (json['success']) {
                     $.notify({
                         message: json['success'],
                         target: '_blank'
                     },{
                         // settings
                         element: 'body',
                         position: null,
                         type: "info",
                         allow_dismiss: true,
                         newest_on_top: false,
                         placement: {
                             from: "top",
                             align: "center"
                         },
                         offset: 0,
                         spacing: 10,
                         z_index: 2031,
                         delay: 5000,
                         timer: 1000,
                         url_target: '_blank',
                         mouse_over: null,
                         animate: {
                             enter: 'animated fadeInDown'
                             //exit: 'animated fadeOutUp'
                         },
                         onShow: null,
                         onShown: null,
                         onClose: null,
                         onClosed: null,
                         icon_type: 'class',
                         template: '<div data-notify="container" class="col-xs-11 col-sm-3 alert alert-success" role="alert">' +
                             '<button type="button" aria-hidden="true" class="close" data-notify="dismiss">&nbsp;&times;</button>' +
                             '<span data-notify="message"><i class="fa fa-check-circle"></i>&nbsp; {2}</span>' +
                             '<div class="progress" data-notify="progressbar">' +
                                 '<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div>' +
                             '</div>' +
                             '<a href="{3}" target="{4}" data-notify="url"></a>' +
                         '</div>' 
                     });

                    $('#cart > ul').load('index.php?route=common/cart/info ul li');
                          $('#cart > button').html('<span id="cart-total">' + json['total'] + '</span>');
                        
                }
            }
        });
    },
    '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',
            success: function(json) {
                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 cart_prod');
                                        $('#cart > button').html('<span id="cart-total">' + json['total'] + '</span>');
                }
            }
        });
    },

 

Edited by Gamburg
Link to comment
Share on other sites


Как я понимаю згдесь:

$('#cart > button').html('<span id="cart-total">' + json['total'] + '</span>');

 

конкретно

' + json['total'] + '

Добавляет когдачество

 

может надо добавить згдесь изображение корзины

<span class="cart-icon"></span> 

 

к примеру:

 

$('#cart > button').html('<span id="cart-total">' + json['total'] + '</span><span class="cart-icon"></span>');

Edited by Gamburg
Link to comment
Share on other sites


вот пример с иконкой fa-fa:

Спойлер

$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');


по игдеи нужно сгделать по аналогии с картинкой, но это не точно 

Link to comment
Share on other sites

1 hour ago, sasha3337774 said:

вот пример с иконкой fa-fa:

  Reveal hidden contents

$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');


по игдеи нужно сгделать по аналогии с картинкой, но это не точно 

 

К сожнонию без изменений

Link to comment
Share on other sites


Спасипотому что всем, всё зарилиило

 

Добавил в common.js

в add,

в update.

в remote

<span class="cart-icon"></span>  

изображение корзины

 

дное в product.twig

нашёл похожую конструкцию как в common.js

и тоже добавил 

<span class="cart-icon"></span>  

изображение корзины

 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.