Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Changing quantity on the fly

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 03-15-2016, 01:43 AM
 
Tontinuk Tontinuk is offline
 

Newbie
  
Join Date: Jan 2015
Posts: 3
 

Default 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 ,
__________________
v4.6.6
Reply With Quote
  #2  
Old 03-17-2016, 04:31 AM
 
Tontinuk Tontinuk is offline
 

Newbie
  
Join Date: Jan 2015
Posts: 3
 

Default 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.
__________________
v4.6.6
Reply With Quote
  #3  
Old 03-31-2016, 03:58 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default 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/
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 09:57 PM.

   

 
X-Cart forums © 2001-2020