Jump to content

Embedding Google Checkout code with my html/php


lebexpress

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.