Jump to content


Photo

Quantity can't=0?


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

#1 adamesq

adamesq

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 25 February 2005 - 03:02 PM

I'm having a problem with a very simple site where I want to pass the individual items to Paypal. Everything is in place, but if 1 of the 3 items has a quantity of 0, I get a "You must enter a quantity of at least one" error. If quantities are at least "1", all items pass just fine. I need to allow my customers to select the quantity they want of each item. If they want none of any item, they should be able to use "0" and paypal should recognize that NONE of this item are being ordered and go on to the next item.

Please explain how I need to do this to work around this weirdness. I'm hoping Paypal will just adjust this - seems strange to me.

I posted the test site at http://www.feinsilve...roblemsite.html

#2 Andrew Chang

Andrew Chang

    Average Member

  • Members
  • 738 posts

Posted 25 February 2005 - 04:04 PM

you could always not send it if quantity = 0

Why does everyone look to paypal to solve everything?

Andrew Chang
Script to sell downloads: http://itemseller.scorpionsystems.net
Web Design & Scripting: http://scorpionsystems.net
Web & Image Hosting includes global SSL: http://scorpionwebhosting.com
Photographer Gallery Software: http://Photo-Seller.com
Become an affiliate and make money http://worldannounce....com/affiliates http://scorpionwebho...g.com/affiliate
Free Web Traffic: http://www.trafficsw...m/go.cgi?169137 , http://www.ts25.com/...ScorpionSystems

#3 adamesq

adamesq

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 25 February 2005 - 04:29 PM

I was trying to avoid having to figure out the coding for that. It seems like using a sledghammer to kill a mosquito.

As for your question...you could start your own thread on that. I can only answer for myself. IMHO, the thread is here for these sorts of questions. Paypal ultimately benefits from it. As a business owner, my guess is that opinions and expressions on these forums help Paypal develop and improve their services. Not everyone spends 24/7 learning to code websites. Although, I remember years ago, as a kid, feeling that the mouse would lead to computer-illiteracy through mouse-dependence. Destructive reasoning...hmfff.

#4 Andrew Chang

Andrew Chang

    Average Member

  • Members
  • 738 posts

Posted 25 February 2005 - 05:16 PM

If I could have a look at the code you are using I may be of some assistance with the code to not send items with a value of 0.

EDIT: For some reason I did not see your link I will post code for you in a few hours.

Andrew Chang
Script to sell downloads: http://itemseller.scorpionsystems.net
Web Design & Scripting: http://scorpionsystems.net
Web & Image Hosting includes global SSL: http://scorpionwebhosting.com
Photographer Gallery Software: http://Photo-Seller.com
Become an affiliate and make money http://worldannounce....com/affiliates http://scorpionwebho...g.com/affiliate
Free Web Traffic: http://www.trafficsw...m/go.cgi?169137 , http://www.ts25.com/...ScorpionSystems

#5 Andrew Chang

Andrew Chang

    Average Member

  • Members
  • 738 posts

Posted 25 February 2005 - 05:26 PM

Actually before I start can you use cgi on your server? If not maybe one ov these VB/JS guys can help ya out.

Andrew Chang
Script to sell downloads: http://itemseller.scorpionsystems.net
Web Design & Scripting: http://scorpionsystems.net
Web & Image Hosting includes global SSL: http://scorpionwebhosting.com
Photographer Gallery Software: http://Photo-Seller.com
Become an affiliate and make money http://worldannounce....com/affiliates http://scorpionwebho...g.com/affiliate
Free Web Traffic: http://www.trafficsw...m/go.cgi?169137 , http://www.ts25.com/...ScorpionSystems

#6 adamesq

adamesq

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 25 February 2005 - 08:20 PM

Thanx Andrew! Yes, the server I'm on supports cgi. Unfortunately, I have little experience with it. I've been trying to get a hang of JS in my spare time, but haven't gotten around to cgi yet. I wish this stuff were around when I was coding pascal back in school days! It certainly would have had a lot more practical benefit!

#7 Andrew Chang

Andrew Chang

    Average Member

  • Members
  • 738 posts

Posted 25 February 2005 - 08:38 PM

I will have a sample for you in a in a little bit.

Andrew Chang
Script to sell downloads: http://itemseller.scorpionsystems.net
Web Design & Scripting: http://scorpionsystems.net
Web & Image Hosting includes global SSL: http://scorpionwebhosting.com
Photographer Gallery Software: http://Photo-Seller.com
Become an affiliate and make money http://worldannounce....com/affiliates http://scorpionwebho...g.com/affiliate
Free Web Traffic: http://www.trafficsw...m/go.cgi?169137 , http://www.ts25.com/...ScorpionSystems

#8 Andrew Chang

Andrew Chang

    Average Member

  • Members
  • 738 posts

Posted 25 February 2005 - 09:29 PM

Ok

The test form is on http://scorpionsyste...t/orderform.htm

you may view the form code by viewing the source

This is the cgi code it can be shortened by passing everything from the form and doing a loop but I figured it would be easier to under stand this way.

#!/usr/bin/perl -w
print "Content-Type:text/html\n\n";
my @pairs;
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
if ($ENV{'QUERY_STRING'}) {
@getpairs = split(/&/,$ENV{'QUERY_STRING'});
push (@pairs, @getpairs);
}
}
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$value =~ tr/+/ /;
$name =~ s/%(..)/pack("C", hex($1))/eg;
$value =~ s/%(..)/pack ("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
if ($in{$name}){
$in{$name}.=", $value";
}else {
$in{$name} = $value;
}
}


###Start Form
print <<"EOT";

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
<meta name="generator" content="order form">
<title>Welcome to MourningStones</title>

</head>

<body bgcolor="#d2b48c">

<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="adam\@feinsilver.com">

EOT
$i=1;


### Check amount fields
if ($in{'quantity_1'} ne "0") {
$total = 0;
$total = 29.95 * $in{'quantity_1'};
print <<"EOT";

Check Out<br>

EOT ITEM 1<br>
Complete Package<br><br>

This Item Costs \$29.95<br>
Quantity: $in{'quantity_1'} <br><br>

Total: $total<br><br><br>

<input type="hidden" name="item_name_$i" value="MourningStones">
<input type="hidden" name="amount_$i" value="29.95">
<input type="hidden" name="item_number_$i" value="0001">
<input type="hidden" name="quantity_$i" value = $in{'quantity_1'}>
EOT
$i++
}

if ($in{'quantity_2'} ne "0"){
$total = 0;
$total = 18.95 * $in{'quantity_2'};

print <<"EOT";
<input type="hidden" name="item_name_$i" value="Refills">
<input type="hidden" name="amount_$i" value="18.95">
<input type="hidden" name="item_number_$i" value="0002">
<input type="hidden" name="quantity_$i" value = "$in{'quantity_2'}">

ITEM 2<br>
Refill Package<br><br>


This Item Costs \$18.95 <br>
Quantity: $in{'quantity_2'}<br><br>

Total: $total<br><br><br>
EOT
$i++
}

print <<"EOT";
<input type="hidden" name="item_name_$i" value="Shipping">
<input type="hidden" name="quantity_$i" value="1">
<input type="hidden" name="amount_$i">
<select name="amount_$i" size="1">
<option value="4.95">Standard (\$4.95 added to total above)</option>
<option value="15.95">Overnight (\$15.95 added to total above)>
</select><br>Select Shipping<br>
<input type="submit" name="submit" value="Upload Cart"></p>
</form>
</body>
</html>
EOT


Should be pretty straight foward.

Good Luck
If you need more help email me

Andrew Chang
Script to sell downloads: http://itemseller.scorpionsystems.net
Web Design & Scripting: http://scorpionsystems.net
Web & Image Hosting includes global SSL: http://scorpionwebhosting.com
Photographer Gallery Software: http://Photo-Seller.com
Become an affiliate and make money http://worldannounce....com/affiliates http://scorpionwebho...g.com/affiliate
Free Web Traffic: http://www.trafficsw...m/go.cgi?169137 , http://www.ts25.com/...ScorpionSystems

#9 adamesq

adamesq

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 25 February 2005 - 10:53 PM

Thank you very much. I'm going to try this out tomorrow! I really appreciate all the time you've put in to this!

#10 adamesq

adamesq

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 02 March 2005 - 12:45 PM

Hi Andrew,

I just wanted to post a follow up thanking you again! I really appreciate your help. I had tried a javaform out - but I want to keep this site very simple. This is also helpful code for someone trying to learn more about cgi. Thank you very much!

#11 marcquey

marcquey

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 17 June 2005 - 03:41 AM

Is there a way of using this script so that one of the 2 variables is shipping and then proceed directely to upload cart in one step instead of 2?

Marcquey

#12 ron

ron

    Advanced Member

  • Members
  • 2,003 posts

Posted 17 June 2005 - 05:51 AM

Here's a totally client-side solution (JavaScript). Right now it uses a "get" method to send to PayPal, but I am changing that to a "post" method.

http://members.aol.c...lper/meth2.html

(yes, Virginia, there is a way to programatically "post" with JavaScript on the client-side.)

Ron.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users