en Jump to content
  • 0
guil182

Cart.js and step PrestaShop : 1.7.3.2

Question

Hi,

I want to update the cart quantity of a product by step and stop to the max quantity available.

So in cart.js, I add the max and step property of the spinner

 

function createSpin()
{
  $.each($(spinnerSelector), function (index, spinner) {
     $(spinner).TouchSpin({
       verticalbuttons: true,
       verticalupclass: 'fa fa-angle-up touchspin-up',
       verticaldownclass: 'fa fa-angle-down touchspin-down',
       buttondown_class: 'btn btn-touchspin  js-touchspin js-increase-product-quantity',
       buttonup_class: 'btn btn-touchspin js-decrease-product-quantity',
       min: parseInt($(spinner).attr('min'), 10),
       max: parseInt($(spinner).attr('max'), 10),
       step: parseInt($(spinner).attr('step'), 10)   
    });
  });

  CheckUpdateQuantityOperations.switchErrorStat();
}

and in the cart-detailed-product-line.tpl

div class="col col-auto col-md qty">
                {if isset($product.is_gift) && $product.is_gift}
                    <span class="gift-quantity">{$product.quantity}</span>
                {else}
                    <input
                            class="js-cart-line-product-quantity"
                            data-down-url="{$product.down_quantity_url}"
                            data-up-url="{$product.up_quantity_url}"
                            data-update-url="{$product.update_quantity_url}"
                            data-product-id="{$product.id_product}"
                            type="text"
                            value="{$product.quantity}"
                            name="product-quantity-spin"
                            min="{$product.minimal_quantity}"
                            step="{$product.minimal_quantity}"
                            max="{$product.quantity_available}"
                    />
                {/if}
            </div>

so..it works with the spinner but just after that, the right block is refresh (sub total and total) with +1 and not with the step and the js-cart-line-product-quantity zone class is refresh (where the spinner is) with +1 quantity two.

So, the spinner don't give the quantity to the link "http://www.prestashop.lenclosdesvins.com/panier?update=1&id_product=25&id_product_attribute=46&token=bfd9f14c6636ce0491077ff97106e997&op=up"

but I don"t kwon where modify this ...:/

Thank you for your help

Regards

Edited by guil182

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

So, I progress....I think.

There is two different behaviors :

In the cart page, if I change the quantity directly in the input it works with quantity and the post parameters are :

ajax=1
qty=6
action=update
op=up

and when I clic the spinner, it doesn't work :

the post parameters are :

ajax=1
action=update

and I don't find where the two different URL are build ...:/

regards

Share this post


Link to post
Share on other sites
  • 0

I found or almost :

cart.js ...around line 140 :

let requestData = {
      ajax: '1',
      action: 'update',
    };

to change to :

let requestData = {
      ajax: '1',
      qty: '6',    
      action: 'update',
      op: 'up'
    };

 

now....I have to try the change dynamically qty and op...if you have an idea ?

 

 regards

Share this post


Link to post
Share on other sites
  • 0

It works....but the right block don't stop with the product max.

let cartAction = parseCartAction($target, event.namespace);
     let requestData = {
       ajax: '1',
       qty: $target[0].step,
       action: 'update'
     };

 

Share this post


Link to post
Share on other sites
  • 0

Stop whith the product max works, after setting "allow ordering out-of-stock products" to NO.

 

Edited by netfuchs
Wrong answer

Share this post


Link to post
Share on other sites
  • 0

I'm trying to achieve the exact same thing.

I edited the cart.js and  cart-detailed-product-line.tpl files, but this has no effect. I think that the minimized theme.js file has the touchspin main configuration code, which is used to update the quantity values.

Does anyone know how I can update the quantity by step, and consequently update the total cart price ?

Share this post


Link to post
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

×

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More