Schlo_50 Posted March 19, 2008 Share Posted March 19, 2008 Hi there, Not sure if I can get any help for this here so forgive me if it's in the wrong section. I am looking at integrating paypal as a method of payment on my site. I can setup my bespoke shopping cart software to send the total owed to paypal but this is just displays a total and not a break down of each individual item and it's price. Paypal say this: "Include a set of required variables and any optional variables from the table above for each item included in your buyers' cart. The first item included in the cart should be defined with parameters ending in "_1", such as "item_name_1", "amount_1", etc. Similarly the second item should be denoted with variables like "item_name_2", "amount_2", etc. Note: the "_x" values must increment by one continuously in order to be recognized. If you skip from item #1 to item #3 without defining an item #2, the third item will be ignored." e.g <input type="hidden" name="item_name_1" value="<?php print $item; ?>"> <input type="hidden" name="amount_1" value="<?php print $price; ?>"> <input type="hidden" name="item_name_2" value="<?php print $item; ?>"> <input type="hidden" name="amount_2" value="<?php print $price; ?>"> <input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> </form> At the moment i have the variable $item and the variable $price built into my cart which stores an array of data. How can I separate that array of data and setup the form paypal requires? Thanks for any help given! Quote Link to comment Share on other sites More sharing options...
Schlo_50 Posted March 19, 2008 Author Share Posted March 19, 2008 Sorry! I can describe my problem better now! I am using a php shopping cart and would like to upload the entire contents of the cart to Paypal when the user is ready to checkout, including the individual item title/description and price. I gather that the code I need to put on my checkout button is as follows: <form 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="seller@blah.com"> <input type="hidden" name="item_name_1" value="Item Name 1"> <input type="hidden" name="amount_1" value="1.00"> <input type="hidden" name="item_name_2" value="Item Name 2"> <input type="hidden" name="amount_2" value="2.00"> <input type="submit" value="PayPal"></form> However, I don't want to have to hard code the items and amounts, but would prefer to have a loop that runs for the item_name and amount incrementing the names (item_name_x and amount_x) and passing in the values using my variables ($item_title and $item_price). My question is this .... am I dreaming of something impossible? I can't seem to get it to work ... Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 19, 2008 Share Posted March 19, 2008 what you're trying to do is done often. you've got the right idea: "have a loop that runs for the item_name and amount incrementing the names (item_name_x and amount_x) and passing in the values using my variables ($item_title and $item_price)." while you're looping, keep track of the total order value, as you'll be sending that to PayPal. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.