Simple Server-Side Shopping Cart.


Instructions for CPG 1.3x

This is a server-side Java (.js) shopping cart script, often referred to as a 2nd party cart. This mod uses one of your image's custom description fields to assign different price options for different pictures (current default is the first field). The script serves as an interface between your on site and PayPal. Users only interact with your shopping page so there are no official, encrypted "PayPal button" for this mod. Everything you need is included in this module, you simply need to edit the orders.phppage to suit your needs.

You can test drive this mod, yourself, without having to install it permanently. Simply copy the files into the appropriate coppermine folders and open an intermediate view of any file. Next, replace the "displayimage.php" part of the URL located in the address bar of your browser with "orders.php" while leaving the rest of the URL intact. Click 'enter' or 'go'.

Making it a permanent installation that works with any product or picture in your Coppermine gallery only requires a few lines of code to be added to files that reside in the coppermine folders. See installation directions at the bottom of this page.

Files included in this installation: (copy gif files into CPG/images and themes/images folder; remaining files go into the CPG root directory.)
ecart1.gif < -- navbar button1
orders.php < -- user interface for standard mounts of pictures.
CS_Paypal_Instructions.html < -- this file

FEATURES THAT THIS MOD OFFERS:

Installing this program: (copy gif file into CPG/images and themes/images folder; remaining file goes into the CPG root directory.) Choose one, two, or all three of the following options.


To install into Coppermine as buttons under the intermediate image:
NOTE: These buttons will not display unless your picture has a title.

Open your Coppermine theme's theme.php file which is located in your cpg/theme's folder. Just under line 23 which reads:
// HTML template for intermediate image display
Add the following:
$pid2 = (int)$HTTP_GET_VARS['pid'];
$album2 = $HTTP_GET_VARS['album'];
$pos2 = (int)$HTTP_GET_VARS['pos'];
Near the end of that block of code, where it reads:
<!-- END caption -->
                         </table>
Add the following lines just after:
<table width="80%" align = "center" cellspacing="10px">

<td class="button" height="20" ><a href="orders.php?album=$album2&cat=$cat2&pos=$pos2"> <div align="center">Order this Print</div></a></td>

<td class="button" height="20" ><a href="displayimage.php?album=$album2&cat=$cat2&pos=$pos2"> <div align="center">Return to Browse Mode</div></a></td>

</table>
NEXT, and this is very important, scroll down below this and cut the following line:
<!-- END img_desc -->
NOW, paste it just above the entries you just added.

If you skip this step, your buttons will not display when your image has no title.

Finally, change the Paypal user ID information and the currency information in the orders.php file as instructed below.

That's it. Have fun and prosper!



To install into Coppermine as links in the info fields under the intermediate image:
You will need to edit both your language file and displayimage.php for this to work.

In displayimage.php, search for:
$info[$lang_picinfo['Filename']] = htmlspecialchars($CURRENT_PIC_DATA['filename']);
Below that, add:
global $album, $cat, $pos, $pic_count, $lang_img_nav_bar, $lang_text_dir, $template_img_navbar;
$info[$lang_picinfo['Filename']] = htmlspecialchars($CURRENT_PIC_DATA['filename']);
$info[$lang_picinfo['Title2']] = ($CURRENT_PIC_DATA['title']);
$info[$lang_picinfo['Description']] = ($CURRENT_PIC_DATA['caption']);
$info[$lang_picinfo['Orders']] = "<a href=orders.php?album=$album&cat=$cat&pos=$pos>" . $lang_picinfo['orders2'] . '';
Arrange these as you want them listed under your intermediate picture and save displayimage.php.

Next, open your language file and search for:
$lang_picinfo
Paste the following in that section (Translate each descriptive string after => as necessary. Make sure each entry is surrounded by single quotes[']):
'Title2' =>'Picture Title',
'Description' =>'Description',
'Orders' =>'Orders',
'Orders2' =>'Click here to order this print.',
Save your language file.

That's it. You may want to go to the Admin/CONFIG menu and disable the showing of captions under your thumbnail and intermediate images as these will now display in a field in the info section under your intermediate images. This will encourage your guests to scroll down below the picture to read any caption you have added to the image.



To install into Coppermine as a button in the navbar over the intermediate image display:

This works well if you know how to create your own gif files to use as buttons. You will need to create your own buttons as I am not a button designer. But for our installation purposes we will use the ecart1.gif and ecart2.gif buttons provided. For themes that have their own navbar buttons (fruity, eyeball, igames, hardwired,and rainyday) you will need to copy these two gif files into the theme's images folder.

Open your theme's theme.php file

Then search for:
<a href="{ECARD_TGT}" title="{ECARD_TITLE}">
And add after the </td> that follows that line: (I'm not a button designer, so you will probably want to design your own buttons instead of using the ones I have provided.):
<td align="center" valign="middle" class="navmenu" width="48">
<a href="{ECART1_TGT}" class="navmenu_pic" title="View Purchase Information"><img src="{LOCATION}images/ecart1.gif" border="0" align="middle" alt="View Standard Print Options" /></a>
</td>
Save your theme.php file and in Displayimage.php, search for:
$thumb_tgt = "thumbnails.php?album=$album$cat_link&page=$page";
and insert the following just above that statement.

$ecart1_tgt = "orders.php?album=$album&cat=$cat&pos=$pos";
Next, look for:

'{ECARD_TGT}' => $ecard_tgt,
and insert somewhere below that:
'{ECART1_TGT}' => $ecart1_tgt,
Save your displayimage.php file.

That is it! Your ecart is now installed!

Edit to your heart's content and remove any buttons or items that you deem superfluous for your setup.



Review the orders.php options and edit/set them to your needs.

Edit orders.php to your specific needs and tastes. Should you decide to rename the files, make sure you change the appropriate references to these files in the installation steps above. Remember also that this mod uses one of your image's custom description fields to assign different price options for different pictures. The current default is the first field. Default entries are Standards, Squares, and Panoramics. If the script does not find any of these words in the first field, it defaults to the Standards price structure (See the "//  IF/Else Set Pricing Block" block in orders.php).

If you need to use a custom description field other than the first field, you will have to change the "$pricing_setup = $user1;" variable in orders.php to $user2, $user3, or $user4, as appropriate.

You can also change the entries in the user field to whatever you wish. Just be sure to change the IF/ELSE statements accordingly.
In orders.php search for
Set paypal ID and currency type
Set your paypal ID and currency, accordingly.
Above this you will see the list of variables that have been defined.

Just below that you will see: "$pricing_setup = $user1;".
Change $user1 to $user2, $user3, or $user4 if you are already using the first custom image description field for something else.

Just below that is the following " IF/Else Set Pricing Block "
if ($pricing_setup=="Panoramics"||$pricing_setup=="panoramics") //custom field entry is "Panoramics"
{
$Option1 = " Matted size: 10\" x 20\" (image size: 6\" x 16\") @35.00 ";
$Desc1 = " &nbsp; 10\" x 20\" @ $35.00 USD&nbsp;( image size: 6\" x 16\") " ;
$Option2 = " Matted size: 14\" x 28\" (image size: 9\" x 23\") @95.00 ";
$Desc2 = " 14\" x 28\" @ $95.00 USD&nbsp;( image size: 9\" x 23\") ";
$Option3 = " Matted size: 16\" x 32\" (image size: 11\" x 27\") @125.00 ";
$Desc3 = " 16\" x 32\" @ $125.00 USD&nbsp;( image size: 11\" x 27\") ";
$Option4 = " Matted size: 18\" x 36\" (image size: 12\" x 30\") @135.00 ";
$Desc4 = " 18\" x 36\" @ $135.00 USD&nbsp;( image size: 12\" x 30\")";
$Option5 = " Matted size: 20\" x 40\" (image size: 13\" x 33\") @150.00 ";
$Desc5 = " 20\" x 40\" @ $150.00 USD&nbsp;( image size: 13\" x 33\")"; $Option6 = "";
$Desc6 = "";
$Option7 = "";
$Desc7 = "";
$Option8 = "";
$Desc8 = "";
$Option9 = "";
$Desc9 = "";
$Option10 = "";
$Desc10 = "";
}
else
// 11-20 for 2nd option or "Squares"
if ($pricing_setup=="Squares"||$pricing_setup=="squares") //custom field entry is "Squares"
{
$Option1 = " Matted size: 8\" x 8\" (image size: 6\" x 6\") @15.00 ";
$Desc1 = " &nbsp; 8\" x 8\" @ $15.00 USD&nbsp;( image size: 6\" x 6\") " ;
$Option2 = " Matted size: 10\" x 10\" (image size: 8\" x 8\") @30.00 ";
$Desc2 = " 10\" x 10\" @ $30.00 USD&nbsp;( image size: 8\" x 8\") ";
$Option3 = " Matted size: 12\" x 12\" (image size: 9\" x 9\") @40.00 ";
$Desc3 = " 12\" x 12\" @ $40.00 USD&nbsp;( image size: 9\" x 9\") ";
$Option4 = " Matted size: 14\" x 14\" (image size: 11\" x 11\") @60.00 ";
$Desc4 = " 14\" x 14\" @ $60.00 USD&nbsp;( image size: 11\" x 11\")";
$Option5 = " Matted size: 16\" x 16\" (image size: 12\" x 12\") @75.00 ";
$Desc5 = " 16\" x 16\" @ $75.00 USD&nbsp;( image size: 12\" x 12\")";
$Option6 = " Matted size: 18\" x 18\" (image size: 13\" x 13\") @90.00 ";
$Desc6 = " 18\" x 18\" @ $90.00 USD&nbsp;( image size: 13\" x 13\")";
$Option7 = "";
$Desc7 = "";
$Option8 = "";
$Desc8 = "";
$Option9 = "";
$Desc9 = "";
$Option10 = "";
$Desc10 = "";
}
else
// 21-30 for third option or "Standards and all else"
if ($pricing_setup=="Standards"||$pricing_setup=="standards"||$pricing_setup=="")
{
$Option1 = " Matted size: 8\" x 10\" (image size: 5\" x 7\") @15.00 ";
$Desc1 = " &nbsp; 8\" x 10\" @ $15.00 USD&nbsp;( image size: 5\" x 7\") " ;
$Option2 = " Matted size: 11\" x 14\" (image size: 6\" x 9\") @30.00 ";
$Desc2 = " 11\" x 14\" @ $30.00 USD&nbsp;( image size: 6\" x 9\") ";
$Option3 = " Matted size: 16\" x 20\" (image size: 11\" x 15\") @50.00 ";
$Desc3 = " 16\" x 20\" @ $50.00 USD&nbsp;( image size: 11\" x 15\") ";
$Option4 = " Matted size: 18\" x 24\" (image size: 13\" x 19\") @75.00 ";
$Desc4 = " 18\" x 24\" @ $75.00 USD&nbsp;( image size: 13\" x 19\")";
$Option5 = " ";
$Desc5 = " ";
$Option6 = " ";
$Desc6 = " ";
$Desc8 = " ";
$Option9 = " ";
$Desc9 = " ";
$Option10 = " ";
$Desc10 = " ";
}
else
// fall back when nothing matches, SAME AS STANDARDS.
{
$Option1 = " Matted size: 8\" x 10\" (image size: 5\" x 7\") @15.00 ";
$Desc1 = " &nbsp; 8\" x 10\" @ $15.00 USD&nbsp;( image size: 5\" x 7\") " ;
$Option2 = " Matted size: 11\" x 14\" (image size: 6\" x 9\") @30.00 ";
$Desc2 = " 11\" x 14\" @ $30.00 USD&nbsp;( image size: 6\" x 9\") ";
$Option3 = " Matted size: 16\" x 20\" (image size: 11\" x 15\") @50.00 ";
$Desc3 = " 16\" x 20\" @ $50.00 USD&nbsp;( image size: 11\" x 15\") ";
$Option4 = " Matted size: 18\" x 24\" (image size: 13\" x 19\") @75.00 ";
$Desc4 = " 18\" x 24\" @ $75.00 USD&nbsp;( image size: 13\" x 19\")";
$Option5 = " ";
$Desc5 = " ";
$Option6 = " ";
$Desc6 = " ";
$Desc8 = " ";
$Option9 = " ";
$Desc9 = " ";
$Option10 = " ";
$Desc10 = " ";
}
Each option field ($Option#) is paired with a corresponding description field ($Desc#). The $Option# field is what the script reads and posts to your paypal cart. The $Desc# field is what your customer sees in the dropdown lists. The \" is an 'escaped' expression for double quotes("), representing inches. You must use the escaped expressions for special characters in the Options fields for the script to work. &nbsp " is used to add extra spaces between words to space things out aesthetically. The @ character followed immediately by numbers is how the script reads prices to send to paypal. You can have as many Options as you want in your dropdown list. Just remember to pair them accordingly.

The IF/ELSE code above reads the custom image display field and if an entry matches, "Panoramics, Squares, or Standards" it will display the appropriate price group to the customer. If it does not find any matching word, it will display the last group of options. Which by default are the same as the "Standards" group. From Admin Mode in your CONFIG options, enter a name for the custom image description field of your choice. If you can't think of anything better, use "Available Editions" (If you only need one dropdown list of prices, don't bother with this step and just edit the last ELSE block for your needs).

Scrolling down orders.php, in the "< !--// Display image storyline-- > " block of text. Several of the defined variables are used to customize text for the picture being displayed.

Search for:
Start Form Block for purchase options
This is the user interface purchase < FORM > code block.
You will need to edit the text in this form for your particular needs.
These include:
Select Finished size and Medium
Select matted size
Select print type
Select print medium
Select Mat Color
Decorative Mat Overlay (Optional, Double Matting)
Gift Wrap (+$7.50) (Includes greeting card of picture)
You will probably want to edit the various "Select Type" dropdown list options as well.
Pay close attention to how % surcharges and + fixed value charges are handled in the value= options. The + or % sign is immediately followed by the value without a space between the sign and number. The left half of each entry is what is read into the cart. The right half is what your user will see.

Edit the rest of the file as you see fit.
Enjoy.