I want that when someone click on 10 Stuck the quantity and price will be changed. If someone click on 20 Stuck the quantity changed to 20 and 25.1% discount will be applied to the price.
What I’ve done till now is,
First I’m doing for only quantity that the quantity will be changed.
I put each of them in ANCHOR tags, and then in DT tag I put the DATA-QTY so I can use it on JQUERRY. This is how my PRICEINFO.tpl looks like
And my jquerry looks like this
$(’.dl-horizontal > a’).click(function(){
$(this).each(function() {
$(this).html();
$(’#amountToBasket’).val(‘data-qty’);
});
});
Any Idea what I’m doing wrong??
Because in $(’#amountToBasket’).val(‘data-qty’); when i put 10 instead of ‘data-qty’ and click on the link in my shop, and click on link it changes the quantity to 10. But on every link it does the same. I want that when someone click on 10 Stuck the quantity change to 10 and when click on 20 stuck it change to 20.
I’ll be really happy if someone help me regarding that.
i tried to reconstruct your problem and wasn’t able. Are you trying to also change the displayed price beside the “In den Warenkorb” button? In the wave theme the “Staffelpreis” logic seems only to be calculated in the cart and not on the normal page.
lets have a look on your JavaScript: i am not sure, if i understand what you were trying to do. If you output the interim results with console.log(), you can see a bit more clearly, that things are a bit messed up. After throwing the following into the console, it seemed to work as you wanted (i am no JS guru and prefer the easy solutions ):
$('.dl-horizontal > a').click(function(){
let qty = $(this).find('dt').attr('data-qty');
$('#amountToBasket').val(qty);
});
I also lack in Jquery stuffs so I’m thinking to do the easiest way by doing it locally on HTML, CSS and JS. If it works perfectly then I’ll try to do it on it too.
And I’ll use your method too so I can understand what my problem is. Thanks a lot for helping me