|
|
Thread Tools | Display Modes |
|
|
|
#1
|
|
|
Major grins
|
How to add a PayPal shopping cart to your site!
This has been written about many times before across a number of threads and I have finally managed to pull everything together into a working solution.
Why? The reason is I am based out of Australia and my clients do not like paying in US$ or paying the international shipping costs. I still love smugmug for the ability to show off my photos in their best light, so teaming smugmug with the paypal solution is the best of both worlds for me. Since I have posted a few bits and pieces on paypal in different threads, I hope the code below pulls it together for everybody and is easy to understand. I am not necessarily an expert in HTML, Javascript or CSS so the code presented here is a result of much help from other dgrinners (so thank you to all). Header Code Place the following code in your header to create the product drop down and a buy now and view cart button. Where items are enclosed in [] replace with your own values (dont forget you need to create your own paypal account) Code:
<div id="paypalButtonSet" style="display:none;" class="paypalButton"> <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" onSubmit="setPaypalForm(this)" > <input type="hidden" name="add" value="1"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="business" value="[PayPal Account ID]"> <input type="hidden" name="item_name" value=""> <input type="hidden" name="amount" value=""> <input type="hidden" name="no_shipping" value="0"> <input type="hidden" name="no_note" value="1"> <input type="hidden" name="currency_code" value="AUD"> <input type="hidden" name="lc" value="AU"> <input type="hidden" name="bn" value="PP-ShopCartBF"> <select ID="paypalSelect" name="photoselection"> <option selected value="10.00">Product Option 1</option> <option value="20.00">Product Option 2</option> </select> <input ID="paypalBuy" type="image" src="[URL to Buy Button]" border="0" name="submit" alt="Buy"> <img alt="" border="0" src="https://www.paypal.com/en_AU/i/scr/pixel.gif" width="1" height="1"> </form> <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input ID="paypalView" type="image" src="[URL to View Cart Button]" border="0" name="submit" alt="View Cart"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="business" value="[PayPal Account ID]"> <input type="hidden" name="display" value="1"> </form> </div> Javascript function to create a URL for the image currently selected and pass back to Paypal. Code:
/*========================================*/
/*== Paypal shopping functionality ==*/
/*========================================*/
function setPaypalForm(form) {
urlToImage = webServer + "/gallery/" + AlbumID + "_" + AlbumKey + "/1/" + ImageID + "_" + ImageKey + "/Large" + " " + photoInfo[ImageID]['fileName'];
i = form.photoselection.selectedIndex
sPhotoType = form.photoselection.options[i].text;
sPhotoPrice = form.photoselection.options[i].value;
urlToImage = urlToImage + " " + sPhotoType ;
form.item_name.value = urlToImage;
form.amount.value = sPhotoPrice;
}
Code to dyamically position the previously defined DIV into the altViews DIV i.e. placement on the screen. Code:
/*=========================================*/
/*== Position Paypal - ==*/
/*=========================================*/
YE.onContentReady("altViews", MovePaypalContent);
function MovePaypalContent()
{
var paypalObj = document.getElementById("paypalButtonSet");
var altViews = document.getElementById("altViews");
var smugmug= document.getElementById("smugmug");
if (altViews && paypalObj && smugmug)
{
var paypalSetObj = paypalObj.parentNode.removeChild(paypalObj);
altViews.appendChild(paypalSetObj);
paypalSetObj.style.display = "inline";
}
}
Of course, you can check my website out to see it in action (still in some phases of redevelopment but at least paypal is working). Cheers.
__________________
My Site: http://www.craigridley.com Facebook: http://www.facebook.com/craigridleyoutdoorphotography Want to save $5 on a smugmug account? Use this coupon code: WzG2eZLQPGrqI |
|
|
|
|
#2
|
|
|
panasonikon
|
Well Done, Craig
I've added this to our wiki page! http://wiki.smugmug.net/display/Smug...kout+or+Paypal |
|
|
|
|
#3
|
||
|
Big grins
|
Quote:
|
|
|
|
||
|
#4
|
||
|
Major grins
|
Quote:
Can you provide us a link to your site where you are having the problems and advise us of the steps you took and the problem you are having?
__________________
My Site: http://www.craigridley.com Facebook: http://www.facebook.com/craigridleyoutdoorphotography Want to save $5 on a smugmug account? Use this coupon code: WzG2eZLQPGrqI |
|
|
|
||
|
#5
|
||
|
Major grins
|
Quote:
If you can explain the behaviour you are after perhaps we can help. Cheers.
__________________
My Site: http://www.craigridley.com Facebook: http://www.facebook.com/craigridleyoutdoorphotography Want to save $5 on a smugmug account? Use this coupon code: WzG2eZLQPGrqI |
|
|
|
||
|
#6
|
|
|
Big grins
|
ahhh US dollars??
I can not seem to get it to change from AU to US dollars..
HELP?! Thanks! :) |
|
|
|
|
#7
|
|
|
Robert
|
buying photos
Well, I added this to my galleries, and it works great accept there are a few problems with the gallery pages that it's on. First, when you click on a photo to view it, it shows up on the bottom rather than on the side, and looks really funky. How can I fix this? second, I was wondering if there was a way to align my buy and view cart buttons with the scroll down menu with my print prices? Thanks for any help!
|
|
|
|
|
#8
|
|
|
Robert
|
Well, I added this to my galleries, and it works great accept there's one problem with the gallery pages that it's on. I was wondering if there was a way to align my "buy" and "view cart" buttons with the scroll down menu thats holding my print prices? Because If you look at one of my galleries, you'll see that they are just a tad bit higher than the scroll down menu. Thanks for any help!
__________________
http://sharperimaging.org/ Pentax K20D | AF-360 Flash | 70-300mm f4 telephoto | 50mm f2.8 macro | 17-70mm f4 wide angle |
|
|
|
|
#9
|
|
|
Sad grimace
|
I've just added this to my site, so far seems to all be good. Thanks Craig for putting this together.
Adding $ in place of $ signs in the drop down fixes the missing $ sign problem. Last edited by darklightphotography; May-10-2009 at 04:19 PM. |
|
|
|
|
#10
|
||
|
Major grins
|
Quote:
Code:
/* Slight position adjustments for paypal buttons */
#paypalBuy {position: relative; top: 4px;}
#paypalView {position: relative; top: 4px;}
__________________
My Site: http://www.craigridley.com Facebook: http://www.facebook.com/craigridleyoutdoorphotography Want to save $5 on a smugmug account? Use this coupon code: WzG2eZLQPGrqI |
|
|
|
||
|
#11
|
||
|
Major grins
|
Quote:
Doing paypal this way means that it shows up in every gallery, right? Or, I believe that if I wanted this in only one gallery I could put the header code stuff in my gallery description,right? ? plus in the option in palpal, I would like to see my filename that is under the photos, could this be possible? thanks janis
__________________
(2) Canon 20d, (1) canon 30d, 70-200is 2.8, tamron 17-50,canon 50mm 1.4 http://www.photographybywidget.com Last edited by magicpic; Jan-07-2009 at 04:27 AM. |
|
|
|
||
|
#12
|
|||
|
Major grins
|
Quote:
Quote:
I have not tried getting the specific filename before. I will need some time over the weekend to look at that one and see if I can find the answer for you.
__________________
My Site: http://www.craigridley.com Facebook: http://www.facebook.com/craigridleyoutdoorphotography Want to save $5 on a smugmug account? Use this coupon code: WzG2eZLQPGrqI |
||
|
|
|||
|
#13
|
||
|
Major grins
|
Quote:
TAKE A LOOK http://www.photographybywidget.com/g...25320658_efNjU
__________________
(2) Canon 20d, (1) canon 30d, 70-200is 2.8, tamron 17-50,canon 50mm 1.4 http://www.photographybywidget.com Last edited by magicpic; Jan-08-2009 at 02:10 PM. |
|
|
|
||
|
#14
|
|
|
Major grins
|
Try this: change ..."lc" value="AU" to ..."lc" value="US"
Change the last part of your code under </select> to this: Code:
<input ID="paypalBuy" type="image" src="https://www.paypal.com/en_US/i/btn/btn_cart_LG.gif" border="0" name="submit" alt=""> <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input ID="paypalView" type="image" src="INSERT VIEW CART URL" border="0" name="submit" alt="View Cart"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="business" value="photowidget@comcast.net"> <input type="hidden" name="display" value="1"> </form></div> |
|
|
|
|
#15
|
|
|
Major grins
|
Added for reference - the possible extension from Jerry for adding file names http://www.dgrin.com/showpost.php?p=772317&postcount=65
This might be helpful: list of paypal variables: https://www.paypal.com/IntegrationCe...reference.html Add this to Footer: ******** type="text/javascript" language="javascript"> var albumtitlepp = YD.get('albumTitle').childNodes[0].innerHTML; </******** Add this to javascript: document.formname.on1.value = 'Album Title'; document.formname.os1.value= albumtitlepp + ' File Name: ' + mainPhotoFileName; The on1 and os1 variables are set and used in the form for paypal.
__________________
My Site: http://www.craigridley.com Facebook: http://www.facebook.com/craigridleyoutdoorphotography Want to save $5 on a smugmug account? Use this coupon code: WzG2eZLQPGrqI |
|
|
|
|
#16
|
||
|
Big grins
|
Quote:
Can someone help? Thanks! |
|
|
|
||
|
#17
|
|
|
Big grins
|
Quick question. If I use the PayPal option, am I now responsible for filling the print order too or does it still go through smugmug's print services?
Thanks!
__________________
chadjockphotography.com |
|
|
|
|
#18
|
||
|
Major grins
|
Quote:
|
|
|
|
||
|
#19
|
|
|
Big grins
|
Ok, I'm having a problem.
My paypal links are now showing up on every page.... and I mean every page... Any help?? Here's the site www.trulyalaskan.com |
|
|
|
|
#20
|
||
|
Major grins
|
Quote:
https://www.paypal.com/en_US/i/btn/btn_cart_LG.gif And don't forget to delete the [] brackets after inserting. In the future it helps to have a link to a specific gallery that you are working on. Chris |
|
|
|
||
| Tell The World! | |
| Thread Tools | |
| Display Modes | |
|
|