[cpg1.4.x]: Shopping cart (new version) [cpg1.4.x]: Shopping cart (new version)
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

[cpg1.4.x]: Shopping cart (new version)

Started by Stramm, December 21, 2008, 11:43:01 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Stramm

    demo:
http://stramm.st.funpic.org
supported languages atm: english

I'm starting a new thread for the new photo shop version 1.4 to avoid cluttering the old announcement thread even more. Also there are a lot of new features. Therefore I think that's OK.

This plugin adds a shopping cart to CPG.


  • You can decide to either let users download the purcheased pictures or send the customers prints (!! either or). In addition to that you can let customers bundle a CD that you'll have to send them.  Different price levels for CDs are supported. Eg. 25 images for 40USD and up to 50 images for 70USD.
  • Free downloads are now supported as well.
  • The next new feature is PayPal IPN support (instant payment notification). Paypal sends back a notification to your server. The shop then knows the customer has paid and (if you opt for downloads) then creates the download folder for the customer and copies his items in that password protected dir. A warning: You should use SSL (https) for the checkout. That way IPN (communication between your server and Paypal) will be more secure as well.
  • The configuration now is all done in the shops config backend (no more gateway.inc.php needed).
  • Basic VAT support.
  • Modpack support (it's even recommended to use or at least the watermarking mod if you go for the download feature – more later)
  • Oh, and in that version it's possible to change currency in the config. No more need to edit the lang files.

Now a quick installation guide:

  • Upgrade:
Uninstall the old version using the plugin manager. Don't opt to remove the database.
Upload all files replacing the old shop files.
In the plugin manager install the new version
  • New install:
Upload the shop directory and everything it contains into your Coppermines plugins folder.
Use the plugin manager to install the plugin.
Have a look at photo_shop/images_to_move/css_changes.txt - that file describes the additional css the shop is using (add it to your themes style.css) . Copy the images in that very directory to the images folder of the theme you're using.
[/list]

Preparing Coppermine – user data:
For the shop to work it's necessary that a customer can be identified. As a registered user he'll get assigned a user id. That's what the shop uses, too. So if a not logged in customer checks out, he'll get redirected to a login/ register page (even if disabled in Coppermines config). I recommend to go to the coppermine config -> Custom fields for user profile and add there the user data you need from your customers (street, zip, city etc.).

Preparing the confirmation emails:
You should modify the confirmation email template in the plugins lang file.
You can use placeholders
{USER_NAME}
{SITE_NAME}
{ORDER_ID}
{PRICE}
{ADMIN}
{USER_PROFILE1} - {USER_PROFILE6}

Adding items:
Open  the shop admin (link 'Shop' in admin menu). Now below the shop button you clicked in the table  header click 'config'. Have a look around, most is self explaining.
However the shop won't do anything if you do not create items. So click 'create new item'.
-   Type: Photo, CD or Shipping -> CD to create a CD item, photo (download or 'for print' item), shipping to define the global shipping fee
-   Description: The name to use for your item (eg. Download 1280px image or 15x10 photo)
-   Price: OK, everyone should know what that means. As delimiter you have to use . (point). If you set the price to -1 that item will be a free item (0.00). In the lang file is an entry for free items that'll get added in the dropdown (atm 'free') ->  'free' => 'free',
-   Max items on CD: If you have set type to CD, then you can set here some number. The set price is valid up to that number.
-   Shipping: You can override the global shipping (eg. 2USD) with the shipping for a specific item (eg. a framed image 5USD)
-   (max)w/h: If you set here anything other than 0 (zero), then the system will treat that item as a 'for download item'. It'll get resized to the defined size and put into the customers download folder. If the set size is bigger than the size of the image you've uploaded, then this item won't be offered to the customer. It's good to use my watermarking mod or the modpack. Enable watermarking. This will lead in the sytem, to create backup copies of the uploaded images. This backups will get used to create the resized downloads for your customers. Means you have a eg. 2000x1000px image as original on your server. The image you show your customers is a 500x300px watermarked image. If the customer purcheases the image he'll get the not watermarked image in a bigger version into his download folder. You should protect the orig_ files (backups) from access from the web. For that purpose copy sample.htaccess (in the shops main dir) to the albums dir and rename it to .htaccess (only *nix boxes)

Test the shop:
Try to add some items to your basket. Delete them, increase/ decrease amounts etc.. Just get familiar with it. As guest checkout (only possible when items are in your cart). You'll get to a combined signup/ login form. Enter a new username/ pwd etc. and submit. The user'll get automatically logged in and directed back to the checkout. Here he sees an overview of his items. If he confirms the purchease,  the stuff is added to the SQL and emails sent to the user and you.

Now open the shop admin again (link 'Shop' in admin menu)
You'll see the new order in an overview. Icons in front  meaning (order) viewed, paid, (items) sent (to user). When clicking the order you'll see the detail view. Thumbs of the items etc, pid, price, amounts, cd or photo (and size). In the header user name-> link to profile, email, total price. Just have a look. You can mark the checkboxes and do certain actions (delete, mark paid/ sent, mark unpaid, unsent). If you mark all items of one order as sent or paid then the status changes in the overview for the entire order as well. In detail view click an item to go back to the overview. When order has been processed you can here move the order to the archive.
If it's a download order, then you'll see some small buttons in the order overview.
d: crate directory (email sent to user with password – you only have to do that if problems occur)
c: copy files into the download folder (same as above)
x: delete dir (as above, after deleting the down dir, you can test create dir and copy files)
p: paypal ipn log

Per Album Settings:
If you do not want global prices for all items, then you have the possibility to set different prices for each album or to disable the shop for certain albums.
For that check in the shops config the 'Per Album Settings'. If you set as price 0.00 for an item in the per album settings, the this item won't show in the dropdown anymore.

More features:
-   If you need the basket buttons elsewhere, then edit template.html and use the placeholder {CART_MENU} where you need it.
-   In the shops admin you can download a zip of all purcheased items of an order (in the order overview)
-    basic support for google checkout (this is just a theoretical implementation. Utterly untested, enable it only for testing purposes and to report back here. I'm from Europe and didn't want to sign up with google using fake info)  
-   invoices (plain text attached to the confirmation email) sent to the user and the admin with the order confirmation
-   -added support for discounts. Default off. There's no gui where you can set the discounts. You'll have to open functions.inc.php in the plugins include dir, scroll down to the bottom and find function calculate_discount. It's pretty easy to do. I've already added there two examples. You just need to uncomment one to enable it. The two examples are:
1. 10% discount if user orders more than 10 pics for print
2. 10% discount if order volume is >= 100 USD
-   MyOrders page. Users can view their orders (history). It's a stripped down version of the shop admin. User of course can't change or delete stuff. If the admin deletes an order, moves it to the archive or marks an order as paid/ sent, then the user will see these changes.  If it's a download order, the user can create the dir or initiate the copy process for files
-   if you use the modpack you may like that one. If enbabled, minithumbs get used
-   added global shipping/ shipping per item
Now you can set as usual a global shipping (in the shop admin set as type not cd or photo but shipping) and one per item. As with the discount you can easily change (in the code functions.inc.php, function calculate_shipping()) the beahaviour of the shipping calculation. Out of the box it's doing the following. Using the global shipping. If a user buys an item where you specified a different shipping than the global and it's higher than the global then the new (per item) shipping is used. You have nearly unlimited possibilities to customize that.

Don't forget the backups!!!


[Edit GauGau 2010-03-05]
This plugin has been added to the subversion repository: http://coppermine.svn.sourceforge.net/viewvc/coppermine/branches/cpg1.4.x/plugins/

It has been updated as well to reflect the version checking routines in the plugin manager that are meant to make sure that galleries don't break because of plugins installed that aren't meant for that particular version of the gallery.

Download: https://sourceforge.net/projects/coppermine/files/Plugins/1.4.x/cpg1.4.x_plugin_photo-shop_v1.4.1.zip/download
[/Edit]

Stramm

#1
FAQ: (later)

Screenshots (older version): http://forum.coppermine-gallery.net/index.php/topic,32231.msg149770.html#msg149770
In this thread already a lot of questiones got answered.

Pascal YAP

Nice news  ;D
But i can't find any ZIPs in your previous Post !
A mistake from me ?

Sorry Stramm you'd placed your ZIP during my Post, too funny  ;D

Stramm

No, you're just to impatient. I'm still writing and preparing the zip...

jaus

Stramm,

I set up the new version, and tried a test order to see if the return url is working, but when I log into the sandbox with my buyer account and hit "Pay Now"  I am sent to a screen that says :

"This invoice has already been paid. For more information, please contact the merchant"

There is no 'Return to...' button on this screen.  I have tried a couple of orders and they both have done the same.  In each case I have cleaned out the orders cue in photo_shop prior to submitting the order.  I'm not quite sure where to look for a solution.

Also , what should appear in the "Description" on the paypal sand box.  What I get now is something like "Title=No title  ID NO. 2" .  I don't see any configs for this field.  Am I missing something?




Stramm

Set up a new sandbox seller. The one you use atm has already a order id processed the photo shop tries to send now (or fiddle around with mysql to raise the oid manually).

If you have assigned a title to your pics that'll appeare. If not, then you'll see 'no title'. As easy as that.

The return URL is needed after payment processing. Read paypal forums, help and FAQ. There's plenty to find there. Best help source are the PDFs.

jaus

Ok, seems to be working now.  Is there an easy mod that I can do to substitute 'file name' for 'title' when transmitting to Paypal?

phill104

Great stuff. Just a couple of questions.

Does this work with bridging enabled or have you not tested it? Does the script need changing for different countries paypal?

I am in the process of writing a plugin to allow purchase through Joomla's virtuemart but have been struggling with a few things so this seems like a great interrim option for me.
It is a mistake to think you can solve any major problems just with potatoes.

Stramm

Quote from: jaus on December 21, 2008, 05:20:28 PM
Ok, seems to be working now.  Is there an easy mod that I can do to substitute 'file name' for 'title' when transmitting to Paypal?


$query = cpg_db_query("SELECT title FROM {$CONFIG['TABLE_PICTURES']} WHERE pid={$item_id['pid']}");


not tested and I'm not sure if I use title anywhere else... just replace title with filename (in photo_shop_checkout.php)

Stramm

Quote from: Phill Luckhurst on December 21, 2008, 06:00:12 PM
Does this work with bridging enabled or have you not tested it? Does the script need changing for different countries paypal?

I've tested bridged with smf and phpbb. Should work with the other by cpg supported apps, too.
In the shops config you can set the currency to use and the paypal URL... just try it.

jaus

Do I remember incorrectly or weren't there drop down options on the admin-orders page to set orders to sent/unsent, paid/unpaid. I don't see those options anymore.  How do you change the paid/sent icons?

I thought maybe a completed Paypal transaction would flip the 'unpaid' to 'paid' but that doesn't seem to be the case.

Thanks,
Joe

Stramm

#11
Quote from: jaus on December 21, 2008, 09:36:37 PM
Do I remember incorrectly or weren't there drop down options on the admin-orders page to set orders to sent/unsent, paid/unpaid. I don't see those options anymore.  How do you change the paid/sent icons?
I have that on my testbed... atm just english is supported

Quote from: jaus on December 21, 2008, 09:36:37 PM
I thought maybe a completed Paypal transaction would flip the 'unpaid' to 'paid' but that doesn't seem to be the case.
If paid, the status changes to paid. If it doesn't then probably something went wrong. Check the IPN log. Most important.... make sure you use a currency your sandbox supports (US sandbox USD, German sandbox EUR etc. - or setup multicurrency)

It's adviced to read all the paypal docs before playing with IPN and the sandbox as mentioned above.

beeroll

You are a champion Stramm! I have been looking all over for nice ways to integrate this functionality at a reasonable cost for my client, and this is exactly what I required!

Big ups and thank you for the Christmas present!
;D ;D

ben


jaus

Quote from: Stramm on December 22, 2008, 10:44:38 AM
I have that on my testbed... atm just english is supported
If paid, the status changes to paid. If it doesn't then probably something went wrong. Check the IPN log. Most important.... make sure you use a currency your sandbox supports (US sandbox USD, German sandbox EUR etc. - or setup multicurrency)


I am using USD. I have enabled Paypal and Paypal IPN notifications and enabled the ipn txt log file in the default location.  I have not enabled downloads.  I have specified my sandbox merchant account but left all other urls as default.  I have left the notify, return, and cancel urls untouched.

On the Paypal side I believe I have followed all of Paypal's documetation steps to setting up a sandbox account and enabling IPN  on it but, after confirming an order (in photo_shop) and completing the Paypal 'buy now' transaction,  I do not see any txt log files in the photo_shop log directory or the cpg log directory.  The sandbox transaction seems to complete normally, but I can see no evidence of IPN back to photo_shop ( no ipn logs, orders remain 'unpaid').

I am working my way through the IPN documentation but I don't see anything that I have left out.  Could sure use a point in the right direction.

Thanks,
Joe.

jaus

 ::) DOH! nevermind , I am currently running on a localhost testserver and completely forgot Paypal won't be able to get through to it with the ipn (or at least I think that is the problem...).  I suspect all will be fine once I migrate to the live server. Sorry, its tough biting off more than you can chew...

metalguy639

Stramm thansk for all your help on this plugin I've got mine working 100% now. :)

Stramm

Quote from: jaus on December 23, 2008, 01:32:51 AM
... I am currently running on a localhost testserver and completely forgot Paypal won't be able to get through to it with the ipn (or at least I think that is the problem...)

you're right with your guess

jaus

Well I have installed the plugin on the live server, and I can complete paypal transactions, but the ipn is still not working.  I do get ipn logs now but they show 'Invalid'.  Here is one:
[12/23/2008 5:50 PM] - SUCCESS!
IPN POST Vars from Paypal:
mc_gross=58.95, invoice=5, protection_eligibility=Eligible, address_status=confirmed, item_number1=, payer_id=TAZC44ZHJYFF4, tax=0.00, address_street=1 Main St, payment_date=15:50:12 Dec 23, 2008 PST, payment_status=Completed, charset=windows-1252, address_zip=95131, mc_shipping=0.00, mc_handling=8.95, first_name=Test, mc_fee=2.01, address_country_code=US, address_name=Test User, notify_version=2.6, custom=, payer_status=verified, business=japbuy_1229875538_biz@comcast.net, address_country=United States, num_cart_items=1, mc_handling1=0.00, address_city=San Jose, verify_sign=A9F9w5tdSkq8F-YyOlaWFJKCTZK.AXpC8ThmC304ocsFWWW.MJQFv2xk, payer_email=joebuy_1230075886_per@comcast.net, mc_shipping1=0.00, tax1=0.00, txn_id=88B88875CA166342K, payment_type=instant, last_name=User, address_state=CA, item_name1= => Title: bird02875-w.jpg - ID: 2, receiver_email=japbuy_1229875538_biz@comcast.net, payment_fee=2.01, quantity1=1, receiver_id=JQ5FZ5DVUKK38, txn_type=cart, mc_gross_1=50.00, mc_currency=USD, residence_country=US, test_ipn=1, transaction_subject=Shopping Cart, payment_gross=58.95,
IPN Response from Paypal Server:
HTTP/1.1 200 OK
Date: Tue, 23 Dec 2008 23:50:20 GMT
Server: Apache/1.3.33 (Unix) mod_fastcgi/2.4.2 mod_gzip/1.3.26.1a mod_ssl/2.8.22 OpenSSL/0.9.7e
Set-Cookie: c9MWDuvPtT9GIMyPc3jwol1VSlO=Xv9TEVbaUhAdsijv2vcFkcgre-KjWg3wrFIllayIOz8Q00hHteOl1mPNk8GfMJ6M0gYmaNSEppK-Pc6JAg4pdbe1Gyr_9s41aZVZClA4NGRf3taDPisuFfRnY2ukkNNGcroPmW%7csGMfbIGcs0hGESwDgVMNR0lYeDRZR7M5XFmgqs6OyN0YpY3JzAS4RHA6J1lSMBXfmBqZVW%7cXtz4_Wr2vvO28KozCo0jbrmRUcCLOz2caHegWrFp5ABV9Hk-TM4Y1OA8NynP8PUYxdoVJ0%7c1230076220; domain=.paypal.com; path=/
Set-Cookie: cookie_check=yes; expires=Fri, 21-Dec-2018 23:50:20 GMT; domain=.paypal.com; path=/
Set-Cookie: navcmd=_notify-validate; domain=.paypal.com; path=/
Set-Cookie: navlns=0; expires=Mon, 18-Dec-2028 23:50:20 GMT; domain=.paypal.com; path=/
Set-Cookie: Apache=10.191.196.11.246661230076220514; path=/; expires=Mon, 10-Nov-02 17:22:04 GMT
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

7  
INVALID
0




This appears in the log as soon as the paypal transaction is complete.  I am using the paypal sandbox, so all of the transactions are my own and should be ok.

I have read the sandbox docs on IPN and it seems like it should be working (does the plugin check the test_ipn variable?). But I can't really say because I don't know how the plugin responds to paypal.

Also the return and cancel urls, which worked on the localhost test server, now give me a "Internal Server error -500"
I have left all of the default url's in place in the plugin config.

Can you suggest any leads for me to investigate?

Thanks,
Joe.

Stramm

Recheck all your settings... INVALID means, that the process itself is OK but was declined by PayPal. Lots of reasons for that.

- paypal webmaster email not valid (check for a space at the end or something similar)
- the mentioned currency setup. Make sure PayPal accepts the currency you've set
- Try an item with a plain title/ description (no special chars)
- if nothing helps, setup a new seller account in the sandbox (and a new buyer)

jaus

When you say 'paypal webmaster email' you do mean the 'paypal merchant email' from the photo_shop config, correct?

If so, I have tried each of those suggestions in turn, but the results are the same.  The ipn log looks the same as before (except for the title change to remove special characters).

I also set up new accounts for both seller and buyer, but again no change.


One thing that I am not clear on is how the 'SSL url to coppermine base dir' works.  The default value is my coppermine root directory.  If I leave this set do I need to have SSL set up on my website?  Does the http: need to be changed to https:  in the default value?  The config says to leave blank to not use SSL, but also says that SSL is mandatory, so I'm a little confused about what to expect from this parameter.