Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Sign in to follow this  
marcianokent

Quantity box with plus and minus buttons

Recommended Posts

Hello,

 

I am interested in using this contribution

 

http://addons.oscommerce.com/info/6369

 

but this contribution can only be used in the product_info.php page, how do I change this script

 

 

// JavaScript Document

// calculate price based on quantity

function changeQty(change){

var currentQty = parseInt($F('quant')) // Where quant is the id of your quantity input field. Gets value of currentQty field

 

switch (change) {

case 'add':

currentQty += 1

$('quant').value = currentQty

calculate()

break

case 'subtract':

if (currentQty > 1) { // only subtract if qty is greater than zero

currentQty -= 1

$('quant').value = currentQty

calculate()

}

break

case 'field':

if (currentQty > 0) {

window.setTimeout('calculate()', 500)

}

break

}

}

function calculate(){

var currentQty = parseInt($F('quant')) // Where quant is the id of your quantity input field. Gets value of currentQty field

var jsnormalprice = $F('jsnormalprice') // Where jsnormalprice is the id of your hidden base price field. Gets value of base_price field

var jsspecialprice = $F('jsspecialprice') // Where is the id of your hidden base price field. Gets value of base_price field

 

if (currentQty > 0) { // Don't want price to display if zero if customer zeros out quantity

var new_jsnormalprice = jsnormalprice * currentQty // Calculate the price.

var new_jsnormalprice = new_jsnormalprice.toFixed(2) // Only allow 2 decimals. I'll let you add rounding features up or down.

 

var new_jsspecialprice = jsspecialprice * currentQty // Calculate the price.

var new_jsspecialprice = new_jsspecialprice.toFixed(2) // Only allow 2 decimals. I'll let you add rounding features up or down.

 

} else { // set price back to original price

new_jsnormalprice = jsnormalprice

new_jsspecialprice = jsspecialprice

}

 

$('jsnormalpriceshow').update(new_jsnormalprice) // Where jsnormalpriceshow is the id of your span for the echoed product price

$('jsspecialpriceshow').update(new_jsspecialprice) // Where jsspecialpriceshow is the id of your span for the echoed product price

 

}

 

 

 

can be used in product_listing.php page?

 

Maybe someone can help? because I am not a programmer

 

 

Thanks before

Kent

Share this post


Link to post
Share on other sites
can be used in product_listing.php page?

can be done, but you need to put the quantity in array and process it. The above mentioned script is javascript only and don't process the function.


Please read this line: Do you want to find all the answers to your questions? click here. As for contribution database it's located here!

8 people out of 10 don't bother to read installation manuals. I can recommend: if you can't read the installation manual, don't bother to install any contribution yourself.

Before installing contribution or editing/updating/deleting any files, do the full backup, it will save to you & everyone here on the forum time to fix your issues.

Any issues with oscommerce, I am here to help you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×