Yet another paypal hack

Lilly252

Joined: 2004-02-02
Posts: 8
Posted: Mon, 2004-02-02 11:35

This is based on rroades's code, but does not require adding any extra fields.

Here are the features:
- Can be used on the album properties so that people can add photos to paypal form the thumbnail gallery.
- Uses three different sizes of pictures for ordering (you can add more if you like)
- Is used on individual pictures ordering
- It uses the file names as the name for Paypal for ordering

In the html_wrap directory, do the following:

Copy inline_photo.header.template to inline_photo.header.

Add the following code at the top:

<center>
<?php
/* constants */
$email = "email@youremail.com";  /* your paypal business account i.e. e-mail */
$s = " ";  /* spacer */

/* Application Variables */
$Sizes= $gallery->album->getExtraField($GLOBALS['index'],Sizes);
$title= $gallery->album->getExtraField($GLOBALS['index'],Title);
$Caption = $gallery->album->getPhotoID($GLOBALS['index'],Caption);

$item_array = preg_split("/[\s,]+/", $Sizes);
$ii=count($item_array);

/* echo "<font size=\"2\"><b>Purchase:</b></font>"; */
echo "<SELECT size=1 name=\"Product\" onChange=\"if(options[selectedIndex].value) window.open(options[selectedIndex].value, 'paypal',
'width=640,height=400,screenX=192,screenY=174,left=192,top=174,status=yes,location=yes,scrollbars=yes,resizable=yes')\">";

echo "<OPTION value=>Purchase Options - Add to Cart</option>";
echo "<option value = \"https://www.paypal.com/cart/add=1&business=$email&item_name=$Caption&item_number=11x17GLOSSY&amount=27\">11x17 Glossy - $25 + $2 S/H";
echo "<option value = \"https://www.paypal.com/cart/add=1&business=$email&item_name=$Caption&item_number=8x10GLOSSY&amount=22\">8x10 Glossy - $20 + $2 S/H";
echo "<option value = \"https://www.paypal.com/cart/add=1&business=$email&item_name=$Caption&item_number=6x8GLOSSY&amount=22\">6x8 Glossy - $20 + $2 S/H";
echo "</option><p>&amp;</p>";

NOTE: Right after this code, and right before the //$Id: inline_photo, there's a <? you'll have to take out, or it will crash the script.

Copy inline_photothumb.frame.default to inline_photothumb.frame, and add this code at the beginning:

<?php
/* constants */
$email = "email@youremail.com";  /* your paypal business account i.e. e-mail */
$s = " ";  /* spacer */

/* Application Variables */
$Caption = $gallery->album->getPhotoID($GLOBALS['i'],Caption);

$item_array = preg_split("/[\s,]+/", $Sizes);
$ii=count($item_array);

/* echo "<font size=\"2\"><b>Purchase:</b></font>"; */
echo "<SELECT size=1 name=\"Product\" onChange=\"if(options[selectedIndex].value) window.open(options[selectedIndex].value, 'paypal','width=640,height=400,scre$

echo "<OPTION value=>Purchase This Print</option>";
echo "<option value = \"https://www.paypal.com/cart/add=1&business=$email&item_name=$Caption&item_number=11x17GLOSSY&amount=27\">11x17 Glossy - $25 + $2 S/H";
echo "<option value = \"https://www.paypal.com/cart/add=1&business=$email&item_name=$Caption&item_number=8x10GLOSSY&amount=22\">8x10 Glossy - $20 + $2 S/H";
echo "<option value = \"https://www.paypal.com/cart/add=1&business=$email&item_name=$Caption&item_number=6x8GLOSSY&amount=22\">6x8 Glossy - $20 + $2 S/H";
echo "</option><p>&amp;</p>";

NOTE: Right after this code, and right before the //$Id: inline_photo, there's a <? you'll have to take out, or it will crash the script.

You might also want to add a checkout button at the bottom of your pages. To do that, make the following changes:

Copy photo.footer.default to photo.footer, and insert the following code to replace the prior code (modifies tables and widths, etc.)

<?php
// $Id: photo.footer.default,v 1.17.2.2 2003/11/14 13:49:01 jefmcg Exp $
// This is the default photo footer (for the gallery photo
// page: view_photo.php). It's companion is photo.header.default.
//
// To override this header, create a file called photo.footer
// in this directory.
//
// NOTE: This header gets inserted above the </body> tag.
?>

    <table width="100%" cellspacing="0" cellpadding="0">
      <tr>
        <td class="modfooter">
          <!-- The Gallery code version number, linked to the Gallery home page -->
          <table width="100%" border="0">
            <tr>
              <td width="100">
                <span class="fineprint">
                  <?php print poweredBy() ?>
                </span>
    <?php
    if (! isset($GALLERY_EMBEDDED_INSIDE) &&
                    $gallery->app->devMode == "yes") {
            global $id;
            print "<br><br>";
            print album_validation_link($gallery->session->albumName, $id);
            print "Not valid yet.";
    } ?>
              </td>
        <td align="center"><a href="https://www.paypal.com/cart/checkout=1"><img
src="pathtoyourcheckoutgifhere" border=0></A>
</td>
<td align="right" width="10%">
<img src="pathtoyourcreditcardgifhere"></td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
  </td>
  </tr>
</table>
<?php
includeHtmlWrap("wrapper.footer");
?>

And, if you want the checkout to be also placed on the album.footer, copy album.footer.default to album.footer, and replace all text with the following:

<?php
// This is the default album footer (for the gallery album
// page: view_album.php). It's companion is album.header.default.
//
// To override this header, create a file called album.footer
// in this directory.
//
// NOTE: This header gets inserted above the </body> tag.
// $Id: album.footer.default,v 1.25.2.1 2003/11/14 13:49:01 jefmcg Exp $
?>
          
      <table width="100%" cellspacing=0 cellpadding=0 class="modfooter">
        <tr>  
          <td valign=top width="10%">
            <!-- The Gallery code version number, linked to the Gallery home page -->
            <span class="fineprint">
            <?php print poweredBy() ?>
            </span>
          <!-- PayPal donation block -->
          <?php if ($gallery->app->devMode == 'yes') {
                  if (! isset($GALLERY_EMBEDDED_INSIDE)) {
                          print "<br><br>";
                          print album_validation_link($gallery->session->albumName);
                          print "Not valid yet.";
                  }
          } ?>
          </td>
              </td>
        <td align="center"><a href="https://www.paypal.com/cart/checkout=1">
        <img src="pathtoyourcheckoutgifhere" border=0></A>
</td>
<td align="right" width="10%">
<img src="pathtoyourcreditcardgifhere"></td>
            </tr>
          
          <?php if ($gallery->user->isAdmin()) { ?>
              
              </td>

          
          <td width=300 align=right>
            <span class="fineprint">
              Are you happy with Gallery?<br>
              Make us happy too!  Donate!<br>
              (only admins see this message and button)<br>
            </span>
          </td>
          <td width="90" align="right">
            <a href="<?php echo $gallery->url ?>/donate.php?donate_tag=v<?php echo $gallery->version ?>"><img align="right"
              src="<?php echo getImagePath('donate.jpg') ?>" width="88" height="31" border="0" ALT="<?php echo _("Donate to Gallery now!!") ?>"></a>
          </td><?php } ?>
        </tr> 
      </table>
    </td>
  </tr>
</table>
<?php
includeHtmlWrap("wrapper.footer");
?>

It's only four files that will need to modified. You guys are welcome to steal my "Checkout" graphic and the credit card files at the bottom.

Here's an example of what all of this looks like (buy a photo while you're at it too! :))

http://musicalpeace.org/Rattlebox/gallery/animals

 
graphius
graphius's picture

Joined: 2006-03-29
Posts: 11
Posted: Mon, 2008-03-03 19:31

Umm, attention moderators, I think you have some spam...

http://klughammer.dnsalias.com