lebexpress Posted August 3, 2008 Share Posted August 3, 2008 Hello, I am trying to attach google checkout buttons to my site. The original code given by google is: <form method="POST" action="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/*******" accept-charset="utf-8"> <input type="hidden" name="item_name_1" value="Peanut Butter"/> <input type="hidden" name="item_description_1" value="Chunky peanut butter."/> <input type="hidden" name="item_quantity_1" value="1"/> <input type="hidden" name="item_price_1" value="3.99"/> <input type="hidden" name="ship_method_name_1" value="UPS Ground"/> <input type="hidden" name="ship_method_price_1" value="10.99"/> <input type="hidden" name="_charset_"/> <input type="image" name="Google Checkout" alt="Fast checkout through Google" src="http://checkout.google.com/buttons/checkout.gif?merchant_id=*****&w=180&h=46&style=white&variant=text&loc=en_US" height="46" width="180"/> </form> I edited and pasted it to my view_cart page so it looked: echo"<form method=\"POST\" action=\"https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/*********\" accept-charset=\"utf-8\"> <input type=\"hidden\" name=\"$product_title\" value=\"Product Title\"/> <input type=\"hidden\" name=\"$p_model\" value=\"Product Model Number.\"/> <input type=\"hidden\" name=\"$quantity\" value=\"Quantity\"/> <input type=\"hidden\" name=\"$price\" value=\"Price\"/> <input type=\"hidden\" name=\"USPS Priority\" value=\"UPS Ground\"/> <input type=\"hidden\" name=\"$shipping\" value=\"Shipping\"/> <input type=\"hidden\" name=\"_charset_\"/> <input type=\"image\" name=\"Google Checkout\" alt=\"Fast checkout through Google\" src=\"http://checkout.google.com/buttons/checkout.gif?merchant_id=*******&w=180&h=46&style=white&variant=text&loc=en_US\" height=\"36\" width=\"100\"/> </form>"; I need to know how would that code absorb the order if there was more than one kind of an item? because it will have to have two different prices, quantities, etc.. PHP is new to me, and I am learning, so please ask me questions if more explanation is needed. Thanks! Link to comment https://forums.phpfreaks.com/topic/117917-embedding-google-checkout-code-with-my-htmlphp/ Share on other sites More sharing options...
unkwntech Posted August 3, 2008 Share Posted August 3, 2008 If you read through this example http://code.google.com/apis/checkout/developer/Google_Checkout_HTML_API.html#create_checkout_cart In the Google API documentation you'll see how they label each item <input type="hidden" name="item_name[b]_1[/b]" value="5 lbs. Dog Food"/> <input type="hidden" name="item_description[b]_1[/b]" value="5 lb. bag of nutritious Dog Food"/> <input type="hidden" name="item_price[b]_1[/b]" value="35.00"/> <input type="hidden" name="item_currency[b]_1[/b]" value="USD"/> <input type="hidden" name="item_quantity[b]_1[/b]" value="1"/> <input type="hidden" name="item_merchant_id[b]_1[/b]" value="5LBDOGCHOW"/> Link to comment https://forums.phpfreaks.com/topic/117917-embedding-google-checkout-code-with-my-htmlphp/#findComment-606547 Share on other sites More sharing options...
lebexpress Posted August 3, 2008 Author Share Posted August 3, 2008 Thanks for the reply!! I do not see where I can place my php variables, and how would they be stored in case I had two or more different items with different quantities/prices. Don't I have to have an array to handle that? Link to comment https://forums.phpfreaks.com/topic/117917-embedding-google-checkout-code-with-my-htmlphp/#findComment-606552 Share on other sites More sharing options...
PHPTOM Posted August 3, 2008 Share Posted August 3, 2008 You'd need set up a MySQL database and get the information from there. Example: $query = mysql_query("SELECT * FROM `products`"); while($a = mysql_fetch_array($query)){ echo"<form method=\"POST\" action=\"https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/*********\" accept-charset=\"utf-8\"> <input type=\"hidden\" name=\"$a[product_title]\" value=\"Product Title\"/> <input type=\"hidden\" name=\"$a[p_model]\" value=\"Product Model Number.\"/> <input type=\"hidden\" name=\"$a[quantity]\" value=\"Quantity\"/> <input type=\"hidden\" name=\"$a[price]\" value=\"Price\"/> <input type=\"hidden\" name=\"USPS Priority\" value=\"UPS Ground\"/> <input type=\"hidden\" name=\"$a[shipping]\" value=\"Shipping\"/> <input type=\"hidden\" name=\"_charset_\"/> <input type=\"image\" name=\"Google Checkout\" alt=\"Fast checkout through Google\" src=\"http://checkout.google.com/buttons/checkout.gif?merchant_id=*******&w=180&h=46&style=white&variant=text&loc=en_US\" height=\"36\" width=\"100\"/> </form>"; } Of course you would need to setup a database. If you want me to help you with that and your host has PHPMYadmin I will help you. Email me tlomas [at] gmail [dot] com ---------------- Now playing: Jay-Z And Linkin Park - Numb/Encore via FoxyTunes ---------------- Now playing: Jay-Z And Linkin Park - Numb/Encore via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/117917-embedding-google-checkout-code-with-my-htmlphp/#findComment-606592 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.