Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Quantity box with plus and minus buttons


marcianokent

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

Link to comment
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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...