Правильное обозначение для обновления на странице корзины - PullRequest
0 голосов
/ 21 сентября 2019

Я ищу решение этой проблемы.Возможно, кто-то может помочь, подсказать, что делать.Спасибо за помощь.

{% assign total_cart_compare_price = 0 %}{% for item in cart.items%} {% assign compare_price = item.variant.compare_at_price | times: item.quantity %} {% assign total_cart_compare_price = total_cart_compare_price | plus: compare_price %}{% endfor %}

Это хорошо, с этим проблем нет.

      {% assign savings = 0 %}{% for item in cart.items %}{% if item.variant.compare_at_price > item.variant.price %}{% assign difference = item.variant.compare_at_price | minus: item.variant.price %}{% assign diffSaving = difference | times: item.quantity %}{% assign savings = savings | plus: diffSaving %}{% endif %}{% endfor %}

Это HTML-код:

        <div class="cart-subtotal">
                <p><span style="font-size:14px;">Full Price: </span>
  <span data-cart-fullprice>{{ total_cart_compare_price | money }}</span><span style="font-size: 14px;">Total Savings: </span> <span style="color: orange; font-size:18px;" data-cart-totalsavings>{{ savings | money }}</span</p>             <span class="cart-subtotal__title">{{ 'cart.general.subtotal' | t }}</span>
         <span class="cart-subtotal__price" data-cart-subtotal>{{ cart.total_price | money }}</span></p>
        </div>

Свсе в порядке, страница отображается так, как должно быть.Все значения верны.

$(selectors.cartSubtotal, this.$container).html(
    theme.Currency.formatMoney(
      state.total_price,
      theme.moneyFormat
    )
  );
  $(selectors.fullprice, this.$container).html(
    theme.Currency.formatMoney(
      state.total_cart_compare_price,
      theme.moneyFormat
    )
  );
  $(selectors.totalsavings, this.$container).html(
    theme.Currency.formatMoney(
      state.savings,
      theme.moneyFormat
    )
  );

При изменении количества единиц общая цена и сэкономленные деньги обнуляются.Как я понимаю, в строках состояния неверное значение?Строка промежуточного итога работает как надо.

Надеюсь, кто-то может помочь, спасибо.

...