Jump to content


Photo

Multiple quantities same item


  • This topic is locked This topic is locked
5 replies to this topic

#1 timdabel

timdabel

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 18 August 2004 - 11:54 PM

I am working on a website that sells multiple quantities of the same item. (Chestnuts by the pound) I would like to use a text box for the customer to enter the quantity of chestnuts in pounds, then add to cart, the price of the 1 lb of chestnuts would just be multiplied by the value of the textbox to create the entry into the paypal cart. I can work with scripts or plain html. Thanks in advance for any help.



Tim Dabel
Manager
Arrowhead Chestnut Farms

#2 ron

ron

    Advanced Member

  • Members
  • 2,003 posts

Posted 19 August 2004 - 05:30 AM

Tim,

This can be done without script. Just set up your button so that it is set for the purchase of 1 lb, then the little trick is to ask for pounds, but record that into a quantity field.

Enter Pounds -
<input type="text" name="quantity" size="3" value="1" />

See? Your amount field is set for 1 lb, and the customer enters the number of pounds as a quantity of 1 lb increments.

You may want to have some validity checking tripped from an event handler in the FORM...

<form target="paypal" ...
onsubmit="return Validate (this);">

where Validate is a JS function in the <head>...

<script type="text/javascript">
<!-- hide from HTML editors, and validators
function Validate (obj1) {
if (isNaN (obj1.quantity.value)) {
alert("Enter proper number for pounds.");
return false;
}
}
-->
</script>


OR - since PayPal ignors anything it does not recognize in FORM-submitted data, you could have a text field with some name unknown to PayPal and go to a JS function to calculate it with an onchange event handler...

<input type="text" name="lbs" size="3" value="1"
onchange="CalcTot (this.form);">

And in that function you would calculate the amount and plug it...

function CalTot (obj1) {
var amt = 1.29;
var lbs = obj1.lbs.value;
var tot = lbs * amt;
obj1.amount.value = Dollar (tot); // format and stuff
}

function Dollar (val) { // force to valid dollar amount
var str,pos,rnd=0;
if (val < .995) rnd = 1; // for old Netscape browsers
str = escape (val*1.0 + 0.005001 + rnd); // float, round, escape
pos = str.indexOf (".");
if (pos > 0) str = str.substring (rnd, pos + 3);
return str;
}



Ron.

#3 timdabel

timdabel

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 19 August 2004 - 09:18 PM

Ron,

Thanks so much for the quick reply. I got your suggestion of using the text box to work correctly. I haven't had time to try the validity checking, but I will probably put that in eventually. Thanks again.



Tim Dabel
Manager
Arrowhead Chestnut Farms

#4 timdabel

timdabel

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 19 August 2004 - 09:40 PM

One more question about using a quantity text box. I have another chestnut sales site that I manage this one I have used text links in place of the add to cart buttons. I don't suppose there is a way that I can have a text box to input quantity for this method? I am sure this way would require some form of script, but I am not proficient at any scripting language. (Maybe I should get a book huh?) Thanks again.



Tim Dabel
Manager
Arrowhead Chestnut Farms

#5 ron

ron

    Advanced Member

  • Members
  • 2,003 posts

Posted 20 August 2004 - 06:50 AM

clicking on a link (image, text) has nothing to do with the input of a quantity amount. The same technique works for either methos of submitting to the cart.

Ron.

#6 timdabel

timdabel

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 20 August 2004 - 11:36 PM

Ron,

I am not sure about how to format my code. Here is how I have it implemented now:

<-- <a href="#Stone Chestnut Roaster" onclick="window.open('https://www.paypal.com/cart/add=1&business=sales@arrowheadchestnuts.com&item_name=Stone+Chestnut+Roaster&item_number=stone_roast&amount=24.95&return=http://www.arrowheadchestnuts.com.com/success.htm&cancel_return=http://www.arrowheadchestnuts.com/cancel.htm','paypal', 'width=600,height=400,scrollbars,location,resizable,status');">Add to Cart</a> -->

I don't know if this is correct, but it seems to work. Is there a better way to to this? My website (if you'd like to see it) is www.arrowheadchestnuts.com

Thanks again.


Tim Dabel
Manager
Arrowhead Chestnut Farms




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users