Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Discounts to a Shopping Cart...

Status
Not open for further replies.

RichCha

Technical User
Nov 28, 2005
6
US
Hello Everyone…

I have a shopping that determines the unit price of an item by the number of quantities ordered. I have two forms... 1 - Power Charges. 2 - Bridge Plugs. I need to configure a way to add a 5% discount to the Total Price of Power Charges only if 20 or more Bridge Plugs are ordered.

Thanks,

(See Code Below)

------------------------------------------------------


<SCRIPT SRC="language-en.js"></SCRIPT>
<SCRIPT SRC="nopcart_sm.js"></SCRIPT>
<script language="JavaScript" type="text/JavaScript">
function updatePrice00()
{
var QUANTITY = parseInt(document.order[0].QUANTITY.value);
var TOTAL = parseInt(document.order[0].QUANTITY.value);
var PRICE;

if( QUANTITY <=1 )
PRICE = 342.00;
else if( QUANTITY >= 2 && QUANTITY <=4 )
PRICE = 273.60;
else if( QUANTITY > 4 )
PRICE = 222.30;
else
PRICE = 342.00;
document.order[0].PRICE.value = PRICE.toFixed(2);
document.order[0].TOTAL.value = Math.round(PRICE*QUANTITY*100)/100

//document.write(QUANTITY);
//document.write(PRICE);
//document.write(TOTAL);
}


function updatePrice01()

{
var QUANTITY = parseInt(document.order[1].QUANTITY.value);
var TOTAL = parseInt(document.order[1].QUANTITY.value);
var PRICE;

if( QUANTITY >= 1 && QUANTITY <=9 )
PRICE = 1150.00;
else if( QUANTITY >= 10 && QUANTITY <=19 )
PRICE = 1035.00;
else if( QUANTITY >= 20 && QUANTITY <=49 )
PRICE = 977.50;
else if( QUANTITY > 49 )
PRICE = 920.00;
else
PRICE = 1150.00;

document.order[1].PRICE.value = PRICE.toFixed(2);
document.order[1].TOTAL.value = Math.round(PRICE*QUANTITY*100)/100

//document.write(QUANTITY);
//document.write(PRICE);
//document.write(TOTAL);
}


</script>

<!--Shopping Cart Product Begin-->
<div align="left">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="100%" bgcolor="#00004E"><strong><font color="#FFFFFF" size="1">&nbsp;</font><font color="#FFFFFF" size="3">Wireline
Order System (Service Providers)</font></strong></td>
</tr>
<tr>
<td width="100%"><font size="1">&nbsp;</font></td>
</tr>
</table>
</div>
<div align="center">
<center>
<table width="95%" border="0" cellspacing="2" cellpadding="0" height="30">
<tr>
<td bgcolor="#026CAF" height="21" width="100%"><strong><font color="#FFFFFF">&nbsp;Power
Charges and Bridge Plugs</font></strong></td>
</tr>
<tr>
<td height="21" width="100%"><strong><font color="#FFFFFF">&nbsp;</font></strong></td>
</tr>
<tr>
<td height="21" width="100%"><strong>&nbsp;Power
Charges</strong></td>
</tr>
<tr>
<td height="103" valign="top" width="100%">
<FORM NAME=order>
<input name="ID_NUM" type=hidden id="ID_NUM0" value="H437431000">
<input name="NAME" type=hidden id="NAME0" value="SECONDARY IGNITOR (20 Per Box)">
<input type=hidden name="FSTAXABLE" value="false">
<input type=hidden name="TAXABLE" value="false">
<input type=hidden name="SHIPPING" value="0.00">
<input type=hidden name="WEIGHT" value="0.00">
<input name="LIMIT" type=hidden value="1000">
<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#000000">
<tr bgcolor="#CCCCCC">
<td width="15%"><strong><font size="1">Material Number</font></strong></td>
<td width="25%"><strong><font size="1">Description</font></strong></td>
<td width="10%" align="center"><strong><font size="1">List Price<br>
Qty 1</font></strong></td>
<td width="10%" align="center"><strong><font size="1">Qty 2-4</font></strong></td>
<td width="10%" align="center"><strong><font size="1">
Over 4</font></strong></td>
<td width="10%" align="center"><strong><font size="1">Qty</font></strong></td>
<td width="10%" align="center"><strong><font size="1">Unit Price</font></strong></td>
<td width="10%" align="center"><strong><font size="1">Total Price</font></strong></td>
<td width="5%" align="center"><div align="center"><strong><font size="1">Action</font></strong></div></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><font size="1">H437431000<br>
</font></td>
<td bgcolor="#FFFFFF"><font size="1">
SECONDARY IGNITOR (20 Per Box)
</font></td>
<td align="center" bgcolor="#FFFFCC"><font size="1">$342.00<br>
</font></td>
<td align="center" bgcolor="#FFFFFF"><font size="1">
$273.60<br>
</font></td>
<td align="center" bgcolor="#FFFFFF"><font size="1">
$222.30<br>
</font></td>
<td align="center" bgcolor="#FFFFFF"><font size="1">
<input type=text size=2 maxlength=10 name=QUANTITY onChange='this.value=CKquantity(this.value); updatePrice00();'>
</font></td>
<td align="center" bgcolor="#FFFFFF"><font size="1">

<input name="PRICE" type=text size="6" maxlength="15" onfocus="window.document.order[0].PRICE.blur()"
READONLY=true>
</font></td>
<td align="center" bgcolor="#FFFFFF"><font size="1"><input name="TOTAL" type=text size="6" maxlength="15" onfocus="window.document.order[0].PRICE.blur()"
READONLY=true>
</font></td>
<td valign="middle" align="center" bgcolor="#FFFFFF"><div align="center"><font size="1">
<input name="button" type=button onClick='AddToCart(this.form)' value='Add to Cart'>
</font></div></td>
</tr>
</table>
</FORM>
</center>
<center>
</center>
<tr>
<td height="21" width="100%"><strong><font color="#FFFFFF">&nbsp;</font>Bridge
Plugs</strong></td>
</tr>
<tr>
<td height="50" valign="top" width="100%">
<FORM NAME=order>
<input name="ID_NUM" type=hidden id="ID_NUM10" value="H401394500">
<input name="NAME" type=hidden id="NAME10" value="5-1/2 in. 450 FASTFrac Composite BP">
<input type=hidden name="FSTAXABLE" value="false">
<input type=hidden name="TAXABLE" value="false">
<input type=hidden name="SHIPPING" value="0.00">
<input type=hidden name="WEIGHT" value="0.00">
<input name="LIMIT" type=hidden value="1000">
<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#000000">
<tr bgcolor="#CCCCCC">
<td width="15%"><strong><font size="1">Material Number</font></strong></td>
<td width="25%"><strong><font size="1">Description</font></strong></td>
<td width="10%" align="center"><strong><font size="1">List Price<br>
Qty 1-9</font></strong></td>
<td width="10%" align="center"><b><font size="1">Qty 10-19</font></b></td>
<td width="10%" align="center"><strong><font size="1">Qty 20-49</font></strong></td>
<td width="10%" align="center"><strong><font size="1">
Over 49</font></strong></td>
<td width="10%" align="center"><strong><font size="1">Qty</font></strong></td>
<td width="10%" align="center"><strong><font size="1">Unit Price</font></strong></td>
<td width="10%" align="center"><strong><font size="1">Total Price</font></strong></td>
<td width="5%" align="center"><div align="center"><strong><font size="1">Action</font></strong></div></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><font size="1">H401394500<br>
</font></td>
<td bgcolor="#FFFFFF"><font size="1">5-1/2 in. 450 FASTFrac Composite BP
</font></td>
<td align="center" bgcolor="#FFFFCC"><font size="1">$1,150.00<br>
</font></td>
<td align="center" bgcolor="#FFFFFF"><font size="1">
$1,035.00<br>
</font></td>
<td align="center" bgcolor="#FFFFFF"><font size="1">
$977.50<br>
</font></td>
<td align="center" bgcolor="#FFFFFF"><font size="1">
$920.00<br>
</font></td>
<td align="center" bgcolor="#FFFFFF"><font size="1">
<input type=text size=2 maxlength=10 name=QUANTITY onChange='this.value=CKquantity(this.value); updatePrice01();'>
</font></td>
<td align="center" bgcolor="#FFFFFF"><font size="1">

<input name="PRICE" type=text size="6" maxlength="15" onfocus="window.document.order[1].PRICE.blur()"
READONLY=true>
</font></td>
<td align="center" bgcolor="#FFFFFF"><font size="1"><input name="TOTAL" type=text size="6" maxlength="15" onfocus="window.document.order[1].PRICE.blur()"
READONLY=true>
</font></td>
<td valign="middle" align="center" bgcolor="#FFFFFF"><div align="center"><font size="1">
<input name="button" type=button onClick='AddToCart(this.form)' value='Add to Cart'>
</font></div></td>
</tr>
</table>
</FORM>

</td>


 
I've only tried what's in my code (See Above). I'm really new to Javascript, and really don't know where to start to make this happen. Any ideas???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top