This free PHP PayPal shopping cart script can display an unlimited number of products from a Microsoft Excel spreadsheet. Just export your Microsoft Excel product spreadsheet as a delimited text file (tab) and your Paypal shopping cart can be ready in minutes.
<"e;php
/**************************************************************
Free PHP PayPal shopping cart script
download the latest version from:
http://www.perl-studio.com/paypal/free
Copyright Notice
Copyright (c) 1996-2002 AyerSoft/Perl-Studio. All rights reserved.
# Created on Sunday, September 15, 2002 using
# Perl Studio by AyerSoft copyright(C) 2002
###################################################
# You are free to customize this script as you wish, but do not
# redistribute without written permission from AyerSoft.
# DISCLAIMER
# The information and code provided is provided 'as is' without
# warranty of any kind, either express or implied. In no event
# shall the AyerSoft Company be liable for any damages whatsoever
# including direct, indirect, incidental, consequential, loss of
# business profits or special damages, even if the author has been
# advised of the possibility of such damages.
# DO NOT USE THIS SCRIPT UNLESS YOU CAN FULLY AGREE WITH THIS
# DISCLAIMER.
#####################################################
This PHP PayPal shopping cart script can display an unlimited number
of products from a Microsoft Excel spreadsheet. Just export your
Microsoft Excel product spreadsheet as a delimited text file (tab)
and your Paypal shopping cart can be ready in minutes
Implementation:
Enter the details of each item you wish to sell into your
Microsoft Excel product spreadsheet.
Export your Microsoft Excel product spreadsheet as a delimited
text file (tab) saved as products.txt.
Edit the PayPal business name (email address) in the PHP PayPal
shopping cart scripts, to reflect the PayPal email address that
you receive the PayPal payments at.
Upload the PHP PayPal shopping cart scripts to a FTP directory
on your WebSite.
Upload the products.txt to the same FTP directory the PHP PayPal
shopping cart scripts are in. Code SYNOPSIS:
The PHP PayPal shopping cart script reads in the delimited text file
and writes the HTML add to cart buttons for each product in the delimited text file.
All the PayPal add to cart buttons code is automatically generated.
The PayPal view cart button code is also automatically generated. Microsoft Excel product spreadsheet Implementation:
Three required columns/fields
item_number
item_name
item_amount
The item_number field is an ID, SKU or tracking number for your item.
The item_name field is the name of the item or service you wish to sell.
The item_amount field is the price of the item you wish to sell.
*/
// start user configuration
//=============================================================
/* Quick install:
edit the $business_email variable
upload the script and products.txt to the same FTP directory
*/
/* $products_path: path to Microsoft Excel tab delimited text
file with fields item_number, item_name, item_amount on each line.
*/
$products_path = "products.txt";
// PayPal business name (email address)
$business_email = "paypal@no-spam.com";
/* optional user configuration */
/***************************************************************/
// back ground color for products table
$bgcolor="#ffffff";
// type of delimiter used in products delimited text file
$delimiter = "\t";
/* $image_url = Add Your Logo
Customize the look of your PayPal payment pages by adding your logo. This
image, which must be 150 by 50 pixels in size, will appear in the upper left
hand corner of the page when your customer presses your Shopping Cart
button.
*/
$image_url = "https://www.paypal.com/images/logo-xclick.gif";
/* $return_url = Successful Payment URL
Enter the URL where you would like to send your customers after they have
completed payment. Once your customer has completed their payment, they will
see a payment confirmation page. From this page, they will press the
'Continue' button and return to the Successful Payment URL you have
specified. If you do not enter a Successful Payment URL, customers who click
this link will be taken to a PayPal web page.
*/
$return_url = "http://$HTTP_HOST";
/* $cancel_return = Cancel Payment URL
Enter the URL where you would like to send your customers if they cancel
their payment at any point in the Shopping Cart payment flow. If you do
not enter a Cancel Payment URL, customers who click this link will be taken
to a PayPal web page.
*/
$cancel_return = "http://$HTTP_HOST";
/*
Enter the currency symbols PayPal uses to designate US dollars
or Euros or Pounds Sterlings. Enter a backslash before the $ symbol.
US: $
Euros: �
Pounds Sterling: �
Canadian Dollar (C$)
Japanese Yen (�)
*/
$m_symbol = "$";
/*
The currency of the payment is U.S.Dollars: USD
The currency of the payment is British Pounds Sterling: GBP
The currency of the payment is Euros: EUR
The currency of the payment is Canadian Dollar: CAD
The currency of the payment is Yen: JPY
*/
$currency_code = "USD";
//=============================================================
// end user configurationsite_header('Our Products');/* load products.txt. */
$fp = fopen($products_path, "r");
$file_contents = fread($fp, filesize($products_path));
fclose($fp);
// Place each line in the products file into an array
$line = explode("\n", $file_contents);
$i = 0;
/* urlencode the PayPal business email address */
$email = urlencode($business_email);
/* loop through the array of products and display the HTML add to cart buttons */
while($i <= sizeof($line)) {
/* split the line with delimiter used in the file */
list ($item_number,$item_name,$item_amount) = split($delimiter, $line[$i],3);
if($item_amount > 0){
$number = urlencode($item_number);
$item_name = str_replace("\"", " ", $item_name);
$name_value = $item_name;
/* remove characters that migh cause problems with the javascript functions */
$name_value = preg_replace("/[\,\;\`\'\|\*\~\^\[\]\{\}\$\"]/", " ", $name_value);
$name_value = preg_replace("/^\s+|\s+$/", "", $name_value);
$name = urlencode($name_value);
$amount = urlencode($item_amount);
$url = "https://www.paypal.com/cart/add=1&business=$email&item_number=$number&item_name=$name&amount=$amount¤cy_code=$currency_code&bn=AyerSoft.PerlStudio";
$url .= "&return=$return_url&cancel_return=$cancel_return&image_url=$image_url";
/* create the code for the add to cart buttons for each product */
$html_row=<<<HTML_ROW
<tr>
<td>$item_number</td><td>$item_name</td><td>$m_symbol$item_amount</td>
<td>
<a href="javascript:onclick=window.paypalwinOpen('$url');"><img src="http://images.paypal.com/images/x-click-but22.gif" border="0"></a>
</td></tr>
HTML_ROW;
/* display the code for the add to cart buttons for each product */
echo $html_row;
}
$i++;
}
site_footer();
exit;
/* site header and footer functions */
/* read in a html header file or print out a HTML header section */
//************************************************************************************
function site_header($title) {
global $DOCUMENT_ROOT,$bgcolor;
$file = $DOCUMENT_ROOT .'/header.html';
if (!(is_readable($file))){
$file = "header.html";
}$header=<<<HEADER
<HTML>
<HEAD>
<TITLE>$title</TITLE>
<script language="JavaScript">
<!--
var pixels_width = window.screen.width;
var pixels_height = window.screen.height;
var nWidth= "600";
var nHeight="400";
if(pixels_width < 740){
nWidth = "540";
}
if(pixels_height < 540){
nHeight = "350";
}
var optionString = "scrollbars,location,resizable,status,";
optionString += "height=" + nHeight + ",width=" + nWidth;
optionString += ",screenX=10,screenY=10,top=10,left=10";
var cartWindow = null;
function paypalwinOpen(url){
if (!cartWindow || cartWindow.closed) {
cartWindow = window.open(url,"cart",optionString);
} else {
// window already exists, so bring it forward
cartWindow.location.href=url;
cartWindow.focus();
}
}
// -->
</script>
<style type="text/css">
.cartTD {font-size: 11px; font-family: verdana,helvetica,arial,sans-serif;}
</style>
</HEAD>
HEADER; echo $header;
if ((is_readable($file))){
include($file);
}
echo "\n<table width=550 bgcolor=\"$bgcolor\" cellspacing=0 cellpadding=0 border=1>\n";
}
/* read in a html footer file or print out a HTML footer section */
//************************************************************************************
function site_footer() {
global $DOCUMENT_ROOT,$email;
$file = $DOCUMENT_ROOT .'/footer.html';
if (!(is_readable($file))){
$file = "footer.html";
}
$cart_url = "https://www.paypal.com/cart/display=1&business=$email";
$footer=<<<FOOTER
</table>
<p align=center>
<a href="javascript:onclick=window.paypalwinOpen('$cart_url');"><img src="https://www.paypal.com/images/view_cart_02.gif" border="0"></a>
</p>
FOOTER;
echo $footer;
if ((is_readable($file))){
include($file);
}
else{
echo "\n
</body>
</HTML>\n";
}
}
//************************************************************************************
"e;>
&nbsp;
/**************************************************************
Free PHP PayPal shopping cart script
download the latest version from:
http://www.perl-studio.com/paypal/free
Copyright Notice
Copyright (c) 1996-2002 AyerSoft/Perl-Studio. All rights reserved.
# Created on Sunday, September 15, 2002 using
# Perl Studio by AyerSoft copyright(C) 2002
###################################################
# You are free to customize this script as you wish, but do not
# redistribute without written permission from AyerSoft.
# DISCLAIMER
# The information and code provided is provided 'as is' without
# warranty of any kind, either express or implied. In no event
# shall the AyerSoft Company be liable for any damages whatsoever
# including direct, indirect, incidental, consequential, loss of
# business profits or special damages, even if the author has been
# advised of the possibility of such damages.
# DO NOT USE THIS SCRIPT UNLESS YOU CAN FULLY AGREE WITH THIS
# DISCLAIMER.
#####################################################
This PHP PayPal shopping cart script can display an unlimited number
of products from a Microsoft Excel spreadsheet. Just export your
Microsoft Excel product spreadsheet as a delimited text file (tab)
and your Paypal shopping cart can be ready in minutes
Implementation:
Enter the details of each item you wish to sell into your
Microsoft Excel product spreadsheet.
Export your Microsoft Excel product spreadsheet as a delimited
text file (tab) saved as products.txt.
Edit the PayPal business name (email address) in the PHP PayPal
shopping cart scripts, to reflect the PayPal email address that
you receive the PayPal payments at.
Upload the PHP PayPal shopping cart scripts to a FTP directory
on your WebSite.
Upload the products.txt to the same FTP directory the PHP PayPal
shopping cart scripts are in. Code SYNOPSIS:
The PHP PayPal shopping cart script reads in the delimited text file
and writes the HTML add to cart buttons for each product in the delimited text file.
All the PayPal add to cart buttons code is automatically generated.
The PayPal view cart button code is also automatically generated. Microsoft Excel product spreadsheet Implementation:
Three required columns/fields
item_number
item_name
item_amount
The item_number field is an ID, SKU or tracking number for your item.
The item_name field is the name of the item or service you wish to sell.
The item_amount field is the price of the item you wish to sell.
*/
// start user configuration
//=============================================================
/* Quick install:
edit the $business_email variable
upload the script and products.txt to the same FTP directory
*/
/* $products_path: path to Microsoft Excel tab delimited text
file with fields item_number, item_name, item_amount on each line.
*/
$products_path = "products.txt";
// PayPal business name (email address)
$business_email = "paypal@no-spam.com";
/* optional user configuration */
/***************************************************************/
// back ground color for products table
$bgcolor="#ffffff";
// type of delimiter used in products delimited text file
$delimiter = "\t";
/* $image_url = Add Your Logo
Customize the look of your PayPal payment pages by adding your logo. This
image, which must be 150 by 50 pixels in size, will appear in the upper left
hand corner of the page when your customer presses your Shopping Cart
button.
*/
$image_url = "https://www.paypal.com/images/logo-xclick.gif";
/* $return_url = Successful Payment URL
Enter the URL where you would like to send your customers after they have
completed payment. Once your customer has completed their payment, they will
see a payment confirmation page. From this page, they will press the
'Continue' button and return to the Successful Payment URL you have
specified. If you do not enter a Successful Payment URL, customers who click
this link will be taken to a PayPal web page.
*/
$return_url = "http://$HTTP_HOST";
/* $cancel_return = Cancel Payment URL
Enter the URL where you would like to send your customers if they cancel
their payment at any point in the Shopping Cart payment flow. If you do
not enter a Cancel Payment URL, customers who click this link will be taken
to a PayPal web page.
*/
$cancel_return = "http://$HTTP_HOST";
/*
Enter the currency symbols PayPal uses to designate US dollars
or Euros or Pounds Sterlings. Enter a backslash before the $ symbol.
US: $
Euros: �
Pounds Sterling: �
Canadian Dollar (C$)
Japanese Yen (�)
*/
$m_symbol = "$";
/*
The currency of the payment is U.S.Dollars: USD
The currency of the payment is British Pounds Sterling: GBP
The currency of the payment is Euros: EUR
The currency of the payment is Canadian Dollar: CAD
The currency of the payment is Yen: JPY
*/
$currency_code = "USD";
//=============================================================
// end user configurationsite_header('Our Products');/* load products.txt. */
$fp = fopen($products_path, "r");
$file_contents = fread($fp, filesize($products_path));
fclose($fp);
// Place each line in the products file into an array
$line = explode("\n", $file_contents);
$i = 0;
/* urlencode the PayPal business email address */
$email = urlencode($business_email);
/* loop through the array of products and display the HTML add to cart buttons */
while($i <= sizeof($line)) {
/* split the line with delimiter used in the file */
list ($item_number,$item_name,$item_amount) = split($delimiter, $line[$i],3);
if($item_amount > 0){
$number = urlencode($item_number);
$item_name = str_replace("\"", " ", $item_name);
$name_value = $item_name;
/* remove characters that migh cause problems with the javascript functions */
$name_value = preg_replace("/[\,\;\`\'\|\*\~\^\[\]\{\}\$\"]/", " ", $name_value);
$name_value = preg_replace("/^\s+|\s+$/", "", $name_value);
$name = urlencode($name_value);
$amount = urlencode($item_amount);
$url = "https://www.paypal.com/cart/add=1&business=$email&item_number=$number&item_name=$name&amount=$amount¤cy_code=$currency_code&bn=AyerSoft.PerlStudio";
$url .= "&return=$return_url&cancel_return=$cancel_return&image_url=$image_url";
/* create the code for the add to cart buttons for each product */
$html_row=<<<HTML_ROW
<tr>
<td>$item_number</td><td>$item_name</td><td>$m_symbol$item_amount</td>
<td>
<a href="javascript:onclick=window.paypalwinOpen('$url');"><img src="http://images.paypal.com/images/x-click-but22.gif" border="0"></a>
</td></tr>
HTML_ROW;
/* display the code for the add to cart buttons for each product */
echo $html_row;
}
$i++;
}
site_footer();
exit;
/* site header and footer functions */
/* read in a html header file or print out a HTML header section */
//************************************************************************************
function site_header($title) {
global $DOCUMENT_ROOT,$bgcolor;
$file = $DOCUMENT_ROOT .'/header.html';
if (!(is_readable($file))){
$file = "header.html";
}$header=<<<HEADER
<HTML>
<HEAD>
<TITLE>$title</TITLE>
<script language="JavaScript">
<!--
var pixels_width = window.screen.width;
var pixels_height = window.screen.height;
var nWidth= "600";
var nHeight="400";
if(pixels_width < 740){
nWidth = "540";
}
if(pixels_height < 540){
nHeight = "350";
}
var optionString = "scrollbars,location,resizable,status,";
optionString += "height=" + nHeight + ",width=" + nWidth;
optionString += ",screenX=10,screenY=10,top=10,left=10";
var cartWindow = null;
function paypalwinOpen(url){
if (!cartWindow || cartWindow.closed) {
cartWindow = window.open(url,"cart",optionString);
} else {
// window already exists, so bring it forward
cartWindow.location.href=url;
cartWindow.focus();
}
}
// -->
</script>
<style type="text/css">
.cartTD {font-size: 11px; font-family: verdana,helvetica,arial,sans-serif;}
</style>
</HEAD>
HEADER; echo $header;
if ((is_readable($file))){
include($file);
}
echo "\n<table width=550 bgcolor=\"$bgcolor\" cellspacing=0 cellpadding=0 border=1>\n";
}
/* read in a html footer file or print out a HTML footer section */
//************************************************************************************
function site_footer() {
global $DOCUMENT_ROOT,$email;
$file = $DOCUMENT_ROOT .'/footer.html';
if (!(is_readable($file))){
$file = "footer.html";
}
$cart_url = "https://www.paypal.com/cart/display=1&business=$email";
$footer=<<<FOOTER
</table>
<p align=center>
<a href="javascript:onclick=window.paypalwinOpen('$cart_url');"><img src="https://www.paypal.com/images/view_cart_02.gif" border="0"></a>
</p>
FOOTER;
echo $footer;
if ((is_readable($file))){
include($file);
}
else{
echo "\n
</body>
</HTML>\n";
}
}
//************************************************************************************
"e;>
&nbsp;