Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

options price update V3 - work with GB Pound ? ???


mr_biggles

Recommended Posts

Posted

Hi guys n gals.

 

I have been trying to get this thing working for about a month and have, so-far, had no helpful answers to solve this problem.

 

I have now installed this Contribution onto a new install of OSC with USD being default etc.

 

And it works.

 

Changed my currency to ? GB Pound etc , stops working !

 

Here is the JS code that i think effects it

 

<script language="javascript">
<!--
  function FormatNumber(num)
  {
 if(isNaN(num)) { num = "0"; }
 sign = (num == (num = Math.abs(num)));
 num = Math.floor(num*100+0.50000000001);
 cents = num%100;
 num = Math.floor(num/100).toString();
 if(cents<10) { cents = "0" + cents; }
 for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
 {
   num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3));
 }
 return (((sign)?'':'-') + num + '.' + cents);
  }
 function showPrice(form)
 {  
var myTotalPrice = 0;
var showUP = 0;
var myMathProblem = "";
myItemPrice = parseFloat(form.nuPrice.value);
for (var i = 0; i < form.elements.length; i++)
{
  var e = form.elements[i];
  if ( e.type == 'select-one' )
  {
	showUP = 1;
	Item = e.selectedIndex;
	myPrice = e.options[Item].text;
	myDollarSign = myPrice.indexOf("?",0)
	if ( myDollarSign != "-1" )
	{
	  myParSign = myPrice.indexOf(")", myDollarSign);
	  myAttributeString = myPrice.substring(myDollarSign+1, myParSign);
	  myAttributeString = myAttributeString.replace(/,/,"");
	  myAttributePrice = parseFloat(myAttributeString);
	  myMathProblem = myPrice.charAt(myDollarSign - 1);
	} else { myAttributePrice = 0; }
	  if (myMathProblem == "-")
	  {
		myTotalPrice = myTotalPrice - myAttributePrice;
	  } else {
		myTotalPrice = myTotalPrice + myAttributePrice;
	  }
  }
}  
if ( showUP )
{
	myTotalPrice = FormatNumber(myTotalPrice + myItemPrice);
	document.getElementById("productNEWprice").innerHTML = "Subtotal Price with Options ?" + myTotalPrice;
}
 }  
//-->
</script>

 

 

Have tried changing lots of things but it just got worse! somehow it showed everything as 0 cost even when in admin it was 329.58 !

 

PLEASE HELP ME !!!

 

LOL OMG !!!

 

After all of that messing around! I have finally got it working !

 

I missed a part of the code that i add to product_info.php

 

Add the following line afterwards.:

<input type="hidden" name="nuPrice" value="<?php echo str_replace("$","",$nuPrice); ?>">

 

Changed ("$","",$nuPrice) to read ("?","",$nuPrice)

 

 

SO so So Simple!!!

 

Cheers guys, i am a happy bunny once again !!

Archived

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

×
×
  • Create New...