silvershop / silvershop-core

SilverShop is an e-commerce shopping cart module for the SilverStripe CMS
http://silvershop.github.io
BSD 2-Clause "Simplified" License
113 stars 119 forks source link

VariationTable Quantity #785

Open jakmax76 opened 1 year ago

jakmax76 commented 1 year ago

Hi, when i use variation with VariationTable template, i cannot set quantity, it put always 1 item on cart. Is it the right functioning?

This is the addLink url:

https://localhost/shoppingcart/add/SilverShop-Model-Variation-Variation/277?SecurityID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx

but add quantity 1 each time

jakmax76 commented 1 year ago

Ok i tried this workaround:

this is my link for each Variation Item

/shoppingcart/setquantity/SilverShop-Model-Variation-Variation/$ID?quantity=&SecurityID=$SecurityID

with jquery i get the quantity input value that i pass to the quantity parameter .

image

$('.link-variation-cart').on('click', function (e){ e.preventDefault(); // Previene il comportamento di default del link

    var quantity = $(this).closest('.link-container').find('.quantity-input').val();

    var href = $(this).attr('href');

    var regEx = /([?&]quantity)=([^#&]*)/g;
    var newurl = href.replace(regEx, '$1='+quantity);

    $(this).attr('href', newurl);

    window.location.href = newurl;

});