![]() |
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! |
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. |
All times are GMT -8. The time now is 06:38 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.