Different Prices For Variations Of The Same Item

Get help with nopcart formatting or style related issues.

Moderators: Koibito, Stefko, Randy

Different Prices For Variations Of The Same Item

Postby peterlewis » Fri Dec 12, 2003 3:25 am

Hi, I've been given some code for a shopping cart item where the price is determined by the size option chosen eg. 1L, 5L, or 10L. Unfortunately the code I've been given me doesn't work, as it seems to contain an unknown Javascript function. He is adamant that it's not necessary to alter nopcart.js, but it appears that it is necessary because the function AddOneOfManyToCart(this.form) is not referred to at all in the current nopcart.js. Here is the form code I've been given:

<form name=order action="managecart.htm">
<div align="right">
<input type=text size=2 maxlength=3 name=QUANTITY onChange='this.value=CKquantity(this.value)' value="1">
<input name=PRICE type=hidden id="PRICE" value="">
<input name=NAME type=hidden id="NAME" value="">
<input name=ID_NUM type=hidden id="ID_NUM" value="">
<input type=hidden name=SHIPPING value="">
<select name="PRODUCTSELECTOR">
<option selected>Please select
<option cost="41.50" id_num="Noromectin 1L" name="Noromectin Oral Liquid for Sheep 1 Litre" shipping="">Noromectin Oral 1 Litre Liquid for Sheep
<option cost="105.00" id_num="Noromectin 5L" name="Noromectin Oral Liquid for Sheep 5 Litres" shipping="">Noromectin Oral 5 Litres Liquid for Sheep
<option cost="350.00" id_num="Noromectin 20L" name="Noromectin Oral Liquid for Sheep 20 Litres" shipping="">Noromectin Oral 20 Litres Liquid for Sheep
</select>
<input name="image" type="image" onClick='AddOneOfManyToCart(this.form)' value="Add to Cart" src="../assets/buynow.gif" align=top width="90" height="35" border=0>
</div>
</form>

I gather the PRICE field is supposed to be populated by the 'cost' of the item chosen, but it doesn't work - it comes up as "Na". If I fill in the PRICE field with a real value, that becomes the fixed price no matter what option is chosen in PRODUCTSELECTOR.
Can anyone help?
peterlewis
WebMaster
 
Posts: 18
Joined: Tue Nov 11, 2003 11:50 pm
Location: New Zealand

Postby stevew_35 » Fri Dec 12, 2003 11:12 am

you would also need to add this code to the head of your page.

Code: Select all
<SCRIPT>
function AddOneOfManyToCart(formToUpdate)
{
   selectedObj = formToUpdate.PRODUCTSELECTOR[formToUpdate.PRODUCTSELECTOR.selectedIndex];

   nameVal = selectedObj.getAttribute("name");
   if (nameVal == "NOTHING") {
      alert('Please select a product');
      return false;
   }

   formToUpdate.NAME.value = nameVal;

   costVal = selectedObj.getAttribute("cost");
   formToUpdate.PRICE.value = costVal;


   id_numVal = selectedObj.getAttribute("id_num");
   formToUpdate.ID_NUM.value = id_numVal;

   shippingVal = selectedObj.getAttribute("shipping");
   formToUpdate.SHIPPING.value = shippingVal;


   switch( formToUpdate.PRODUCTSELECTOR[formToUpdate.PRODUCTSELECTOR.selectedIndex].value ) {
   }
   AddToCart(formToUpdate);
}
</script>
stevew_35
 
Posts: 5
Joined: Fri Dec 12, 2003 11:10 am
Location: Surrey

Thanks!

Postby peterlewis » Mon Dec 15, 2003 3:15 am

Thanks Steve, that works like a dream :)

Peter

[quote="stevew_35"]you would also need to add this code to the head of your page......
peterlewis
WebMaster
 
Posts: 18
Joined: Tue Nov 11, 2003 11:50 pm
Location: New Zealand

Various Prices

Postby Randy » Mon Dec 15, 2003 10:03 pm

Thank you Peter and Steve for posting that snipit of script.

It works better if you set the shipping:

<option cost="41.50" id_num="Noromectin 1L" name="Noromectin Oral Liquid for Sheep 1 Litre" shipping="">Noromectin Oral 1 Litre Liquid for Sheep

should be

<option cost="105.00" id_num="Noromectin 5L" name="Noromectin Oral Liquid for Sheep 5 Litres" shipping="0.00">Noromectin Oral 5 Litres Liquid for Sheep

Otherwize your shipping and tax row ends up $NaN

And put the name "NOTHING" in the <option selected> as in:

<option selected name="NOTHING">Please select </option>
Otherwize you don't get the alert, order a "null" and get NaN s all over the place!

I foresee great utility in this code:

1.) Childrens Clothes are tax exempt while Adults have to pay...it is based on size rather than age...now I don't need 2 listings!

2.) many items have a different catalogue numger based on size, colour etc. Now they can have that PLUS a different price!

3.) As you have shown, we can now package items in a "family pack" and a "group pack" with different catalogue numbers, different prices, and who knows what else!

Thanks again for the posting! I have tried all 3 applications, and it works as expected. BTW it doesn't interfere with the ADDITIONALINFO field.

Randy
Randy
Guru
 
Posts: 1511
Joined: Tue Apr 22, 2003 12:21 pm
Location: Thunder Bay, Ontario

Postby Gamblor » Mon Feb 23, 2004 8:32 pm

This script is wonderful and is almost working how I want. The only problem is some place around <option cost="350.00" id_num="Noromectin 20L" name="Noromectin Oral Liquid for Sheep 20 Litres" shipping=""> I put in a name for the product I have but on the checkout page it does not show the name just the id_num and price. Im not sure why its doing that everything is exactly the same as the code posted above but i cant get it to show the name in the checkout.
Gamblor
 
Posts: 8
Joined: Fri Jan 23, 2004 8:18 pm
Location: dallas

Sheep Dip Mod

Postby Randy » Mon Feb 23, 2004 10:14 pm

What is the product, and how do I find it?

I went to the store, but didn't know where to look...Do you have a test URL?

I don't know why it wouldn't work...when you select the product and hit the buy button --onClick='AddOneOfManyToCart(this.form)'
This function replaces the standard fields with the one chosen, and then heads for the AddToCart funtion, just like every other order form.

If it shows up on the manageCart table, it is in the cookie, and must show up on the CheckoutCart table.

"Confused" in Minnisota.
Randy
Guru
 
Posts: 1511
Joined: Tue Apr 22, 2003 12:21 pm
Location: Thunder Bay, Ontario

Postby Gamblor » Tue Feb 24, 2004 4:21 am

http://www.texmood.com/texcart/masterlock/cable2.htm

thats my test page i edited the code some trying to get it to work but nothing i did worked the first product is the one im trying to get to work with the pull down menu
Gamblor
 
Posts: 8
Joined: Fri Jan 23, 2004 8:18 pm
Location: dallas

Postby Gamblor » Tue Feb 24, 2004 8:18 pm

Below is the code that I am using. I think the problem is with the <input type="hidden" name="NAME" value> and it doesnt recognize what I put in on the <option cost="3.50" id_num="005-61DAT" name="Individuals" shipping="0.00"> I dont know this kind of code that well mainly have just played with it to get it to work and the wonderful help everyone has provided me on here. So if I can get more help that would rock. This website has helped my family out a whole whole lot.

Code: Select all
<table border="1" width="100%">
  <tr>
    <td width="30%" align="center">6', 1/4& Diameter: Self Coiling Black Cable (3.50)</td>
    <td width="36%" align="center">005-61DAT <form name="order" action="../managecart.htm">
      <input type="hidden" name="PRICE" value><input type="hidden" name="NAME" value><input
      type="hidden" name="ID_NUM" value><input type="hidden" name="SHIPPING" value><dl>
        <dd><input type="text" size="2" maxlength="3" name="QUANTITY"
          onChange="this.value=CKquantity(this.value)" value="1"> <select name="PRODUCTSELECTOR"
          size="1">
            <option selected>Please select </option>
            <option cost="3.50" id_num="005-61DAT" name="Individuals" shipping="0.00">individuals</option>
            <option cost="4.00" id_num="005-61DAT" name="Case Pack" shipping="0.00">Case Pack</option>
            <option cost="56.00" id_num="005-61DAT" name="Master Case" shipping="0.00">Master Case</option>
          </select> <p><input type="button" onClick="AddOneOfManyToCart(this.form)"
          value="Add to Cart"> </p>
          <p><a href="../managecart.htm">Check out now</a> </p>
        </dd>
      </dl>
    </form>
    </td>
  </tr>
:D :D :)
Gamblor
 
Posts: 8
Joined: Fri Jan 23, 2004 8:18 pm
Location: dallas

Postby Stefko » Tue Feb 24, 2004 8:58 pm

By-the-way, this is all wrong:

Code: Select all
input type="hidden" name="PRICE" value><input type="hidden" name="NAME" value>


Should be like:

Code: Select all
input type="hidden" name="PRICE" value=""><input type="hidden" name="NAME" value="">


Stick with it, you will get it to work!!
Last edited by Stefko on Sun May 16, 2004 6:10 am, edited 1 time in total.
KFL Technologies
Web-Enabled Solutions
e-Commerence Solutions
Stefko
Contributor / Guru
 
Posts: 833
Joined: Wed Sep 18, 2002 1:11 am
Location: Wichita, KS

Postby Gamblor » Tue Feb 24, 2004 9:35 pm

Thanks for the help the value=""> and value> thats just something frontpage does. It doesnt seem to change anything. I try not to use front page if possible but sometimes when doing pictures and such its faster but as for the code I looked at your site and tried to edit it to work with mine however I realized that when you checkout on your cart in the checkout it doesnt give the product name just product id thats the same problem I am having. On my cart it will show product names along with id on products not using the pulldown. I do like the thing that pops up to tell you it is in your cart im looking over your code for that. I wish they taught all this stuff in highschool Im 19 and just learning how much fun this stuff is.
Gamblor
 
Posts: 8
Joined: Fri Jan 23, 2004 8:18 pm
Location: dallas

voarious prices mod

Postby Randy » Tue Feb 24, 2004 10:54 pm

You are using a DL without a DT...not that it would cause an error...but 2 selects would. So get rid of the stuff in Red.

I tested out your site ( Before you added the Large Big Dog Bags) and found everything worked. Both ManageCart and CheckoutCart display the proper tables. Maybe it is something else that is causing a problem...



<table border="1" width="100%">
<tr>
<td width="30%" align="center">6', 1/4& Diameter: Self Coiling Black Cable (3.50)</td>
<td width="36%" align="center">005-61DAT

<form name="order" onsubmit='return false' action="../managecart.htm">

<input type="hidden" name="PRICE" value="">
<input type="hidden" name="NAME" value="">
<input type="hidden" name="ID_NUM" value="">
<input type="hidden" name="SHIPPING" value="">
<dl>
<dd>
<input type="text" size="2" maxlength="3" name="QUANTITY"
onChange="this.value=CKquantity(this.value)" value="1">
<SELECT NAME="PRODUCTSELECTOR">
<OPTION qty="0" cost=".00" name="NOTHING" id_num="S68" shipping="0.00" weight="0">
select

<OPTION qty="100" cost=".76" name="LARGE 'BIG DOG' BAGS" id_num="B02" shipping="0.00" weight="11">
100 - $76.00

<OPTION qty="250" cost=".47" name="LARGE 'BIG DOG' BAGS" id_num="B02" shipping="0.00" weight="24.5">
250 - $117.50

<OPTION qty="500" cost=".41" name="LARGE 'BIG DOG' BAGS" id_num="B02" shipping="0.00" weight="47">
500 - $205.00

<OPTION qty="1000" cost=".39" name="LARGE 'BIG DOG' BAGS" id_num="B02" shipping="0.00" weight="94">
1000 - $390.00

<OPTION qty="2000" cost=".34" name="LARGE 'BIG DOG' BAGS" id_num="B02" shipping="0.00" weight="188">
2000 - $680.00

<OPTION qty="3000" cost=".33" name="LARGE 'BIG DOG' BAGS" id_num="B02" shipping="0.00" weight="282">
3000 - $990.00

</SELECT>
</select> <p>
<input type="button" onClick="AddOneOfManyToCart(this.form)"
value="Add to Cart"> </p>
<p>
<a href="../managecart.htm">Check out now</a> </p>
</dd>
</dl>

</form>
</td>
</tr>



Here is the one I use:

Code: Select all
<!-- -=#=-=#=- start of item -->
<TR><TD align="center"><A name="33251"></A>
<IMG src=cable1.jpg" width="107" height="160" alt="cable1.jpg (7992 bytes)" border="0"><BR>
</TD>
<TD>      
<DL>
      <DT><B>Sheep Dip Mod & & $1.00 and $10.00</B></DT>
<DD>This product tests the AddOneOfManyToCart(this.form) function<BR><BR>
      <!--Shopping Cart Begin-->
<form name=order>
<input name="PRICE" type=hidden id="PRICE" value="">
<input name=NAME type=hidden id="NAME" value="">
<input name=ID_NUM type=hidden id="ID_NUM" value="">
<input type=hidden name="WEIGHT" value="0.00">
<input type=hidden name="SHIPPING" value="0.00">

<select name="PRODUCTSELECTOR">
<option selected name="select">Please select size</option>
<option cost="1.00" id_num="33251" name="1L bottle Sheep Dip" weight="1.5" shipping="1.00">1 Litre bottle $1.00 Shipping $1.00 Weight 1.5</option>
<option cost="1.00" id_num="33253" name="1L bag Sheep Dip" weight="1.25" shipping="1.00">1 Litre bag $1.00 shipping $1.00 Weight 1.25</option>
<option cost="3.00" id_num="33252" name="4L can Sheep Dip with hady pour spout" weight="4.5" shipping="2.00">4 Litre can $3.00 Shipping $2.00 Weight 4.5</option>
<option cost="10.00" id_num="33254" name="255L Drum Sheep Dip" weight="225" shipping="120.00" >255 Litre (45 Gal/55 US Gal) Drum $200.00  Shipping $120.00 Weight 255</option>
</select><BR>
      Quantity: <input type=text size=2 maxlength=3 name=QUANTITY onChange='this.value=CKquantity(this.value)' value="1"> & &
      <input type="image" onClick='AddOneOfManyToCart(this.form)'  src="./images/a2_cart.gif" name="buy" WIDTH="38" HEIGHT="30"  border=0 value="Add to Cart" ALT="Add to Cart" align=top>
</form>
      <!--Shopping Cart End  -->
<BR><BR></DD>
</DL>         
</TD></TR>
<!-- -=*=-=*=- End of item -->



I know it works, and I know the Large big dog bags work too...

R
Randy
Guru
 
Posts: 1511
Joined: Tue Apr 22, 2003 12:21 pm
Location: Thunder Bay, Ontario

Postby Gamblor » Wed Feb 25, 2004 6:54 pm

I cant figure out where I am going wrong. I have tried everyones scripts that they have posted and none are working. I tried a new page just blank and started there. I am thinking that there is something I am missing maybe in the header to get it to work correctly. You can check out the page at http://www.texmood.com/texcart/test.htm I just cant figure out why it wont show the product name in the check out but it will show the product id.
Chase
Gamblor
 
Posts: 8
Joined: Fri Jan 23, 2004 8:18 pm
Location: dallas

Postby Gamblor » Wed Feb 25, 2004 7:03 pm

I am really kicking myself for this one. I use the browser Opera because I despise Internet Explorer and it turns out that in Opera it doesnt display the product name. However if I use Explorer it works fine. So that is something everyone may want to keep in mind. I am not sure about any other browsers but it may be something to check. Thank you everyone for all the help.
Chase
Gamblor
 
Posts: 8
Joined: Fri Jan 23, 2004 8:18 pm
Location: dallas

Tweaking?

Postby peterlewis » Wed Mar 03, 2004 11:46 pm

Hi Steve,
I've just implemented this code in another page, and the warning about selecting an item doesn't seem to work. When I try to add an item without selecting a format, the message I get is '1 null added to your cart' instead of 'Please select a product'. Can you check my code and see if I've done something wrong.
Pasted javascript and form follow:

<SCRIPT>
function AddOneOfManyToCart(formToUpdate)
{
selectedObj = formToUpdate.PRODUCTSELECTOR[formToUpdate.PRODUCTSELECTOR.selectedIndex];

nameVal = selectedObj.getAttribute("name");
if (nameVal == "NOTHING") {
alert('Please select a product');
return false;
}

formToUpdate.NAME.value = nameVal;

costVal = selectedObj.getAttribute("cost");
formToUpdate.PRICE.value = costVal;


id_numVal = selectedObj.getAttribute("id_num");
formToUpdate.ID_NUM.value = id_numVal;

shippingVal = selectedObj.getAttribute("shipping");
formToUpdate.SHIPPING.value = shippingVal;


switch( formToUpdate.PRODUCTSELECTOR[formToUpdate.PRODUCTSELECTOR.selectedIndex].value ) {
}
AddToCart(formToUpdate);
}
</script>

<form name=order>
<input name="NAME" type=hidden id="NAME" value="">
<input name="ID_NUM" type=hidden id="ID_NUM" value="">
<input name="PRICE" type=hidden id="PRICE" value="">
<input type=hidden name="SHIPPING" value="3.00">
<input name=QUANTITY type=text id="QUANTITY" onChange='this.value=CKquantity(this.value)' value="1" size=1 maxlength=2 class="tinyblk">
<select name="PRODUCTSELECTOR">
<option selected>Select
<option cost="20.00" id_num="034CD" name="Throw - Rememory CD">CD
<option cost="11.75" id_num="034CASS" name="Throw - Rememory Cassette">Cassette
</select>
&&
<input name="button" type=button class="button" id="button" onClick='AddOneOfManyToCart(this.form)' value='Buy'>
&&<strong>CD$20.00 / CASS$11.75</strong>
</form>
peterlewis
WebMaster
 
Posts: 18
Joined: Tue Nov 11, 2003 11:50 pm
Location: New Zealand

Postby Gamblor » Thu Mar 04, 2004 12:57 am

well ive messed with this code enough that i think ive noticed what it may be this should fix it
instead of
Code: Select all
<option selected>Select

it should be
Code: Select all
<option selected name="select">Please select size</option>
[/code]
Gamblor
 
Posts: 8
Joined: Fri Jan 23, 2004 8:18 pm
Location: dallas

Next

Return to Help: Formatting and Style

Who is online

Users browsing this forum: No registered users and 0 guests