A
A
Alexander Sinelnikov2020-05-01 04:04:21
JavaScript
Alexander Sinelnikov, 2020-05-01 04:04:21

How to recalculate the price depending on the quantity of goods Ajax?

Hello, help me solve the issue, I want to recalculate the price depending on the number of goods in the product categories, I set the counter, but I can’t implement the recalculation. OcStore 3.0.2
5eab747e70811015487881.png
Here is the code in category.twig responsible for displaying the price

<div class="us-module-price">
                    {% if not product.special %}
                    <span class="us-module-price-actual">{{ product.price }}</span>
                    {% else %}
                    <span class="us-module-price-old">{{ product.price }}</span><span class="us-module-price-new">{{ product.special }}</span>
                    {% endif %}
                    {% if product.tax %}
                    <div class="price-tax">{{ text_tax }} {{ product.tax }}</div>
                    {% endif %}
                  </div>
                  {% endif %}


And below is the counter itself
{% if oc_quantity_category_status and oc_quantity_status %}
  <a href="javascript:void(0);" onclick="cart.add('{{ product.product_id }}', $(this).parent().parent().find('.input-number').val());" class="us-module-cart-btn button-cart">{{ button_cart }}</a>
{% else %}
  <a href="javascript:void(0);" onclick="cart.add('{{ product.product_id }}', '{{ product.minimum }}');" class="us-module-cart-btn button-cart">{{ button_cart }}</a>
{% endif %}
{% if oc_quantity_category_status and oc_quantity_status %}
  <div class="input-group">
    <span class="input-group-btn">
      <button type="button" class="minus-square" data-type="minus" data-field="category" onclick="descrement($(this).parent().parent())" )><i class="fas fa-minus-square"></i>
        <span class="glyphicon glyphicon-minus"></span>
      </button>
    </span>
    <input type="text" name="quantity" class="form-control input-number" id="category" value="1">
    <span class="input-group-btn">
      <button type="button" class="plus-square" data-type="plus" data-field="category" onclick="increment($(this).parent().parent())"><i class="fas fa-plus-square"></i>
        <span class="glyphicon glyphicon-plus"></span>
      </button>
    </span>
  </div>
{% endif %}</div></div></div>{% endfor %}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question