X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Changing quantity on the fly (https://forum.x-cart.com/showthread.php?t=73724)

Tontinuk 03-15-2016 01:43 AM

Changing quantity on the fly
 
This cant be too difficult I am sure all I need is an element id.

I need to change the product quantity using the validation script, my customers need to order products in a bank (h x w), that's easy just by adding the options, then using validation I want to change the quantity for example 3h x 4w = 12 units so I need to change the quantity to 12.

using xcart 4.66 ,

Tontinuk 03-17-2016 04:31 AM

Re: Changing quantity on the fly
 
Ive done this now with the following
Code:

var value = parseInt(product_option_value("MUH"));

var value2 = parseInt(product_option_value("MUW"));

var newquant = (value * value2);

document.getElementById("product_avail").value = newquant ;

var qtybox = parseInt(document.getElementById("product_avail").value);

if (  qtybox !== newquant) {

alert("Sorry, the quantity does not match the mailbox bank sizer ytybox " + qtybox + "newquant " + newquant);

return false;

}


the problem with this is it only changes the quantity when the add to cart button is pressed thus calling the checkoptions routine,

can I call the routine when either of the dropdowns are changed and if so how and where should I put the code.:mad:

qualiteam 03-31-2016 03:58 AM

Re: Changing quantity on the fly
 
You should add the routine as a function and then use the "onchange" event to call it every time the dropboxes change.

If your sites uses jQuery you can add the handler to the dropboxes with this:
https://api.jquery.com/change/


All times are GMT -8. The time now is 05:24 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.