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

Set product quantity by counting characters in a text field.

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 11-18-2015, 07:42 AM
 
npav npav is offline
 

Member
  
Join Date: Nov 2015
Posts: 15
 

Question Set product quantity by counting characters in a text field.

Hey guys,

I'm trying to change how quantity is calculated on the product page.

We sell dimensional letters, which are sold by the letter. For example, if someone orders "Elementary School", that's a quantity of 16 letters.

I'd like to calculate the quantity based on the characters that typed into a text field, rather than have the customer select the quantity from a dropdown and risk them mis-counting / mis-selecting the number of letters.

I've written the javascript to calculate the number of letters (minus spaces) from a text field, and am trying to get it integrated into x-cart through the "custom javascript" page in the admin area. It works on it's own, but I am not sure of the correct selectors to use to get it to work with x-cart.

Here is a link to a JSFiddle with the code I wrote: http://jsfiddle.net/npav42/n7khd6kr/3/

If there is anyone that could help out with this that would be a huge help!
__________________
X Cart 5.3.4.5
mountingstandoffs.com
Reply With Quote
  #2  
Old 11-19-2015, 09:10 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: Set product quantity by counting characters in a text field.

The "Custom JavaScript" page is definitely not the way to go for such a complex modification.

Instead you should create a custom module that loads your JavaScript file on the product page: http://kb.x-cart.com/display/XDD/Adding+CSS+and+JS+files
The tutorial explains how to load a custom JS file on every site page, but in your case you should inject it into one of the widget classes that are displayed on the product page only. Perhaps, the quantity box is the widget that you should extend from your module.
__________________
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 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may 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 11:24 PM.

   

 
X-Cart forums © 2001-2020