PayPal buttons ....
There are two methods to construct your shop system : modify your existing web pages by adding buttons and cart displays which is useful if you are only selling a few items, or use the dynamic store front which is based on a template system.
This section explains how to integrate PayPal 'buy now' buttons, 'add to cart' buttons, and the 'cart display' into your existing web pages. If you wish to use the full shopping cart system then refer to shopping cart page.
Adding buy now buttons
Clicking on a 'Buy now' button immediately takes you to the PayPal checkout where you buy that single item.
Buy now buttons are used where you only have a few items to sell and you do not expect purchasers to buy more than one item at a time. If you think that a purchaser would want to buy more than one item, then use the 'Add to cart buttons' described below.
An example of a buy now button is shown here.
The button or buttons may be placed anywhere on an existing web page which makes it easy to integrate into an existing design. The web page can be of php extension or an ordinary htm page.
<input type="hidden" name="item_number" value="item1">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
The fields that you enter to create the button are :
- The action url is http://www.yourservername/eseller/ipn/process.php assuming that you have installed PHP-eSeller at the root of your web site in a folder called 'eseller'.
- The value of the 'item_number' entry is the item number of the product you wish to create the button for. This is what you entered in the item number field in the Products display of the admin pages, for example item1.
- The image can be any of the PayPal images or one of your own.
Click on the following button which shows what happens when someone wants to buy PHP-eSeller script.
When the purchaser clicks on the buy now button, the php script will extract all the relevant data from the database and post it to the PayPal server.
Adding cart buttons
The shopping cart system provides 'Add to cart' buttons and 'View cart' buttons enabling a purchaser to add items to a cart before purchase. Physical goods and digital goods can be added to a cart at the same time and purchased at the same time.
This method enables you to add a button or buttons anywhere to an existing web page. The web page can be of php extension or an ordinary htm page.
An example of a cart button is shown here.
Below, is an example of an 'Add to Cart' button.
<input type="hidden" name="item_number" value="item1">
<input type="hidden" name="from" value="http://www.yourservername/eseller/cart/button.php">
<input type="hidden" name="action" value="add">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but22.gif" alt="Add item to cart">
</form>
The fields that you enter to create the button are :
- The action url is the full url of viewcart.php and will be http://www.yourservername/eseller/cart/viewcart.php assuming that you have installed PHP-eSeller at the root of your web site in a folder called 'eseller'.
- The value of the 'item_number' entry is the item number of the product you wish to create the button for. This is what you entered in the item number field in the Products display of the admin pages, for example item1.
- The value of the 'from' field is the full url of the page that the button is placed on and is used by the viewcart.php page to know where the to return to.
- The image can be any of the PayPal images or one of your own.
When you click on the 'Add to Cart' button, you are taken to the viewcart.php page where you may remove items or complete the purchase.
In addition to the 'Add to Cart' button you also need a 'View Cart' button as follows :
<input type="hidden" name="from" value="http://www.yourservername/eseller/cart/button.php">
<input type="image" src="https://www.paypal.com/en_US/i/btn/view_cart_02.gif" alt="view cart">
</form>
The fields that you enter to create the button are :
- The action url is the full url of viewcart.php and will be http://www.yourservername/eseller/cart/viewcart.php assuming that you have installed PHP-eSeller at the root of your web site in a folder called 'eseller'.
- The value of the from field is the full url of the page that the button is placed on and is used by the viewcart.php page to know where to return to.
- The image can be any of the PayPal images or one of your own.
Click the following Add to cart button to show what happens when someone wants to add the PHP-eSeller script to the shopping cart.
Click the following View cart button to show what happens when someone wants to add the PHP-eSeller script to the shopping cart.
The View Cart display
An example on how to use the view cart display is in the file 'viewcart.php' which is located in the cart folder.
This file uses an include file cart.php. The file viewcart.php can be easily modified to fit in to your own site.
To use the view cart page, you need to place the following include file onto your web page.
<?php include_once ("includes/cart.php"); ?>
|
NOTE : you must also put session_start(); at the top of the page. As a starting point, it may be better to modify the existing viewcart.php file in the cart folder. |
Drop down list selection
Use this type of code to allow the selection of different options from a drop down list.
<select name="item_number">
<option value="">Select a product</option>
<option value="item_a">item 1 $10.00</option>
<option value="item_b">item 2 $20.00</option>
<option value="item_c">item 3 $30.00</option>
</select>
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
Button with hidden custom tag
Use this to add a custom tag to the button. The custom field is sent to PayPal and then returns via the PayPal IPN where it is stored in the tblSalesHistory table.
<input type="hidden" name="item_number" value="test01" />
<input type="hidden" name="custom" value="ref-27" />
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
Button with input box
Use this to allow the customer to enter specific information into a text box. The information will be returned via IPN where it is stored in the tblSalesHistory table.
<input type="hidden" name="item_number" value="test01" />
<input type="text" name="custom" />
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
Buy now button with shipping
To add shipping to a buy now button, use the following :
<input type="hidden" name="item_number" value="test01" />
<input type="hidden" name="shipping" value="0.02" />
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" />
</form>
Buy now button for multiple shipping rates
eSeller cart is unable to handle multiple shipping rates per product. The only way to do this at present is to use single item buy now buttons with a drop down list as follows :
<input type="hidden" name="item_number" value="item10" />
<select name="shipping">
<option value="">Select shipping</option>
<option value="4.00">UK Shipping $4.00</option>
<option value="5.00">US Shipping $5.00</option>
<option value="6.00">International Shipping $6.00</option>
</select>
<br/>
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
Use http links
You can add items to the cart and remove items from the cart using http links rather than buttons.
To add an item use the following in an http link :
viewcart.php?action=add&item_number=prod_a&from=/eseller/cart/list.php
To remove an item use the following in an http link :
viewcart.php?action=remove&item_number=prod_a&from=/eseller/cart/list.php
where item_number is the name that you have given the product when it was created and from is the url of the page the link is placed on which is used by the viewcart.php page to know where to return to.
Another method is :
viewcart.php?action=add&id=1&from=/eseller/cart/list.php
To remove an item use the following in an http link :
viewcart.php?action=remove&id=1&from=/eseller/cart/list.php
where id is the record id of the item you are adding and from is the url of the page the link is placed on which is used by the viewcart.php page to know where to return to.
Placing your include files onto a page
For those who are not familiar with adding include files to your web page, here is a brief description.
- First start with a page you have created which matches your layout.
- Change the file extension to .php The base file name can be anything you want.
- At the point where you want the display to appear enter :
<?php include_once("includefilename.php"); ?> - Copy your file into the /eseller/store/ folder.
Files which use PHP-eSeller include files need to be placed into the correct folder because it will using other include files from the application.
Conventional PayPal buttons ....
If you wish, you may want to use standard PayPal buttons and the PayPal shopping cart rather than the template driven system or the buttons as described elsewhere on this site. You may do this using the PayPal cart factory, but you have to becareful to enter in the correct item name, item number, cost and currency or otherwise PHP-eSeller will not match the values to the database and hence the purchase will fail.
This method allows you to add the digital download system onto an existing set of PayPal buttons so that you to continue using your exsiting payment set up.
The PayPal cart factory at :
https://www.paypal.com/cgi-bin/webscr?cmd=_cart-factory
is used to create various buy now butons, add to cart buttons and view cart buttons.
Creating conventional PayPal Buy Now button
Go to :
https://www.paypal.com/cgi-bin/webscr?cmd=_cart-factory
- Select the radio 'Buy Now' button option.
- In 'Item Name', enter in a description of the product.
- In 'ItemID', enter in the item number of the product which must match the item number that you entered when you created the product in PHP-eSeller.
- In 'Price', enter in the price of the product which must match the price entered in PHP-eSeller.
- In 'Currency', enter in the currency which must be the same as you entered in the PHP-eSeller.
- You may want to set the postage to 0.00 to prevent any postage calculations being added to the digital product.
- In the 'Customise advanced features' section, enter in :
notify_url=http://www.yourserver.com/eseller/ipn/confirm.php
You need to enter in the notify_url which can be found in the admin section of PHP-eSeller global set up page. In the above example, it is assumed that PHP-eSeller is isntalled in the folder /eseller/.
- Click on Save Changes and copy the code on to your web site.
Example Buy now button
Creating conventional PayPal Add to Cart button
The procedure to create an Add to Cart button is the same as described above, but you select the radio 'Add to cart' button option.

