View Full Version : Adding Dynamic Paypal Cart Buttons

RL Joneson
08-18-2008, 04:39 PM
Not sure if i should have posted this in the MYSQL forum but here it goes.

I'm a designer by trade, but have recently started to train myself on backend stuff for sites. I'm not doing too bad either. I have a simple store I set up DWCS3 and had manually created each product description page for each item (:eek:)

After learning basics of record sets and using myphpadmin, i was able to set up a Users table for logging in, and an Events page that the admin can update, insert, and delete records on, once logged in. Works like a charm!

Now my goal is to tackle the product pages. I want to set up a dynamic page to display each product's information on, as well as an "Add to Cart" Paypal button.

The first part of this I'm confident in handling. I'll set up a table with an auto-inc id, product id, name, description, price, etc. And I will be using the Record Set tools in DWCS3 to add, retrieve, and display these with no trouble at all.

The problem I'm going to run into is how to dynamically create a Paypal button so that it is unique to the product displayed, with the correct product id and pricing.

As of now, I've been using WebAssist's "Add to Cart" extension that writes the code for me by having me input the details in it's GUI. It opens a new window and adds the item to the paypal cart on their remote site. More on the extension and paypals cart feature:

So by doing it this way, I could create fast product pages dynamically, but i would have to go back and add a custom "cart" button to each page. So what's the point right!?!?!

Here is the code that the PayPal extension plops in. I would like to set this up dynamically. Any help would be appreciated. But remember, i'm a designer just getting into backend stuff so go easy on me! ;)

<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<table><tr><td><input type="hidden" name="on0" value="Size">
<span class="contact">Size</span></td>
<td><select name="os0" class="contact">
<option value="Small 47-53">Small 47-53<option value="Medium 52-510">Medium 52-510<option value="Large 510-66">Large 510-66</select>
</td></tr><tr><td><input type="hidden" name="on1" value="Color">
<span class="contact">Color</span></td>
<td><select name="os1" class="contact">
<option value="Royal Blue">Royal Blue<option value="Pink">Pink<option value="Blasted Black">Blasted Black<option value="Violet">Violet<option value="Red">Red<option value="Aqua">Aqua<option value="Forrest Green">Forrest Green<option value="Toxic Green">Toxic Green<option value="Lime Yellow">Lime Yellow</select>
<input type="image" src="http://images.paypal.com/images/x-click-but22.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="info@prettyhurt.com">
<input type="hidden" name="item_name" value="Knight Crutches">
<input type="hidden" name="item_number" value="CLKNT016">
<input type="hidden" name="amount" value="170.00">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="return" value="http://prettyhurt.com/success.html">
<input type="hidden" name="cancel_return" value="http://prettyhurt.com/cancel.html">
<input type="hidden" name="logo_custom" value="http://images.paypal.com/images/x-click-but22.gif">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-ShopCartBF">

08-18-2008, 07:35 PM
You could use PHP's GD functions. I have no experience with them, but I believe there are tutorials allover the place for making butotns. Look at this page:


RL Joneson
08-18-2008, 08:42 PM
Thanks, but its not a visual need I am requesting assistance with. It doesn't matter to me if the link is as simple as some html text saying "Add to Cart". What I need to do is dynamically place the correct information from the Product page into the Paypal shopping cart through the link.

Maybe replacing the values of this part of the code?

<input type="hidden" name="item_name" value="Knight Crutches">
<input type="hidden" name="item_number" value="CLKNT016">
<input type="hidden" name="amount" value="170.00">

I guess im looking for some script to replace these values with matching values of the record set.

RL Joneson
08-19-2008, 12:46 AM
I'm telling you, im VERY new to this. I played around with it, and i plugged some PHP in the field value. And it worked!! I know I sound stupid, but for any other noobs wandering in the forum, simple retrieve your records in form value like so:

<input type="hidden" name="item_name" value="<?php echo $row_Products['productName']; ?>">

That's it for now! But I guarantee I will be back with more questions!

08-19-2008, 03:44 AM
If I had known what you menat I could have told you that lol sorry:)

RL Joneson
08-19-2008, 04:19 PM
Haha no prob. I don't expect everyone to understand a rook :D