Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

PayPalCart

Summary: Provides markup for PayPal shopping cart buttons.
Version: 1.0
Prerequisites: a PayPal account
Status: in active use
Maintainer: Ben Stallings
Categories: Form Tools | Payment

Questions answered by this recipe

This section is optional; use it to indicate the types of questions (if any) this recipe is intended to answer.

How can I integrate PayPal shopping cart into my site without having to code all those form fields?

Description

Enter your recipe's description here.

  1. Download this file into your cookbook: paypalcart.phpΔ
  2. Add the following lines to your config.php:
    $PayPal_Account = 'email@example.com';
    include("$FarmD/cookbook/paypalcart.php");
  3. Use the following markup in your pages:
    (:AddToCart name="item name" id="item number" amount="5.00":)
    (:ViewCart:)

Additional customization is possible by editing the forms in the recipe file. This is just a quick and dirty solution, based closely on PayPalButtons2.

Notes

Release Notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

Comments

You can add a quick-and-dirty Donate button option by adding this code to the recipe:

#Define PayPal Donate button markup
Markup('DonateButton', 'inline',  '/\\(:DonateButton (.*?):\\)/e', 'PayPalDonate("$1")');

function PayPalDonate($opts) {
	global $PayPal_Account;
  $args = ParseArgs($opts);
  $output = "<form target='paypal' action='https://www.paypal.com/cgi-bin/webscr' method='post'>\n"
	. "<input type='hidden' name='add' value='1'>\n"
	. "<input type='hidden' name='cmd' value='_xclick'>\n"
	. "<input type='hidden' name='business' value='$PayPal_Account' />\n"
	. "<input type='hidden' name='item_name' value='".$args['name']."' />\n"
	. "<input type='hidden' name='item_number' value='".$args['id']."' />\n"
	. ($args['amount'] ? "<input type='hidden' name='amount' value='".$args['amount']."' />" : "$<input type='text' size='3' name='amount' />") ."\n"
	. "<input type='hidden' name='no_note' value='1' />\n"
	. "<input type='hidden' name='currency_code' value='USD' />\n"
	. "<input type='hidden' name='lc' value='US'>";
	$output .= "<input type='image' src='https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif'\n"
	. "border='0' name='submit' alt='PayPal - The safer, easier way to pay online!'>\n"
	. "<img alt='' border='0' src='https://www.paypal.com/en_US/i/scr/pixel.gif' width='1' height='1'>\n"
	. "</form>";
	return Keep($output);
}
The markup is then
(:DonateButton name="Name of the charity or fund here" amount="optional amount to donate":)

If you don't specify the amount, a small form field will appear to the left of the button so users can specify the amount before leaving your site.

BenStallings December 08, 2010, at 10:06 AM

See Also

PayPalButtons2

Contributors

Ben Stallings January 10, 2007, at 03:01 PM

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.

Edit - History - Print - Recent Changes - Search
Page last modified on September 10, 2011, at 11:42 AM