Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Textpattern form for Paypal shopping-cart integration (See related posts)

A site I've been working on has a retail area which uses Paypal's shopping cart; since the whole site is Textpattern powered, the necessary HTML for each item is generated by a form. This code is based on 1.0rc1 and using the rei_show_custom plugin. I know that in rc3 there's probably something built in to pull out arbitrary custom fields, so just substitute that.

To use, add each product as an article; in the first custom field put the name you want passed to the cart, and in the second custom field put the price of the item. Then make sure this is called by the article form:

<fieldset>
<legend>Buy this product:legend>

Our fine /> is available for the low, low price of $<txp:rei_show_custom customid="2" />.p>

/> <input type="hidden" name="business" value="yourbiz@yourdomain" /> <input type="hidden" name="item_name" value="" /> <input type="hidden" name="amount" value=""2" />" /> <input type="image" id="add_to_cart" src="/path/to/your_cart_image" name="submit" alt="Add this item to your cart" /> <input type="hidden" name="add" value="1" /> p> </form> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <p> <input type="hidden" name="cmd" value="_cart" /> <input type="hidden" name="business" value="yourbiz@yourdomain" /> <input type="image" id="view_cart" src="/path/to/your_view_cart_image.png" name="submit" alt="View all items currently in your cart" /> <input type="hidden" name="display" value="1" /> p> </form> fieldset>



That'll display both an "add to cart" and a "view cart" button.

You'll want to fill in your own Paypal account address and product options, of course.

You need to create an account or log in to post comments to this site.


Related Posts