Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PLease Help!


cemfundog

Recommended Posts

I have a code (written by someone else, namely BIGZELF) that will update the price on my product info page by pressing a plus or minus button. The problem that is killing me right now is that it does not take into account the specials. When a product is on special it will not display or calculate correcly. This has been a very popular script and is an extremly cool freebie from BIGZELF, so no complaints but I really need a fix or I can not use it. Thank you all so much for helping.

 

Here is the JS code I am useing:

// 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 > 0) { // 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 startPrice = $F('base_price') // Where base_price is the id of your hidden base price field. Gets value of base_price field
   var currentQty = parseInt($F('quant')) // Where quant is the id of your quantity input field. Gets value of currentQty field

   if (currentQty > 0) { // Don't want price to display if zero if customer zeros out quantity
       var qtyPrice = startPrice * currentQty // Calculate the price.
       var qtyPrice = qtyPrice.toFixed(2) // Only allow 2 decimals. I'll let you add rounding features up or down.
   } else { // set price back to original price
       qtyPrice = startPrice
   }
   var qtyPrice = '$' + qtyPrice // Add a dollar sign
   $('priceHeading2').update(qtyPrice) // Where priceHeading2 is the id of your span for the echoed product price
   new Effect.Highlight($('priceHeading2'))
}

 

 

Any help will be greatly appreciated. I have allready given all of this package to the community as an addon to help others and I will update the package as soon as I get a fix figured out. I will aslo make sure the correct people get the credit.

 

The package I uploaded earlier is at:

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

 

Please help, this is the last fix I need...

Link to comment
Share on other sites

i've made an update.

the 3rd version should do all things correct !!

(normal price, special price (+with the old price))

 

if anybody won't at special prices, that the old price should not be shown, make the <span> (for the old price) "invisible"

or write the script better ;-)

Link to comment
Share on other sites

i've made an update.

the 3rd version should do all things correct !!

(normal price, special price (+with the old price))

 

if anybody won't at special prices, that the old price should not be shown, make the <span> (for the old price) "invisible"

or write the script better ;-)

 

M5E.at, I'm trying to install, but i have some errors on page.

I found 1 error in code.... 'icons/plus.gif' shoud be 'icons/plus.PNG'.

but even when i change the name, my page doesnt update the quantity.

 

 

Sorry for my english, i'm from Brazil.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...