[Solved] Checkout - bypass payment when free purchase + combining download and physical delivery

Jiheffe

Joined: 2009-07-19
Posts: 14
Posted: Sun, 2009-09-27 14:18

I'm quite new to Gallery2, but I am already impressed by it's features. I've tested a lot of packages, from easy (Jalbum) to complex (Coppermine, Joomla or Wordpress based galleries), but G2 really meets almost all my needs ;-) .

I have one question regarding Checkout, and couldn't find the answer on the forums or in the codex.

I'd like to set up a gallery where photos could be ordered in following flavours, for instance:

1) Low-res JPG (say 600 px @ 72 dpi) for free - Download
2) 10x15 print res JPG for a fee - Download
3) A3+ sized fine art prints for a fee - Physical delivery

(of course, I could restrict some flavours for selected albums)

Furthermore I want to standardize on the checkout module for all downloads, even those for free. So the scenarios would be:

  • If someone has only selected items of flavour 1) (free downloads), he/she could directly download the ZIP without further payment processing
  • If someone only has selected items of flavour 1) and 2) (downloadable items), he/she would be able to download the complete package after payment cleared for flavour 2) items
  • If someone has selected also flavour 3) items, he/she would be able to download flavour 1) and 2) items (if any) after payment cleared (in addition to having the flavour 3) items sent to him/her)

Can I set up this kind of configuration, as if so, can somebody help me out how to achieve this?

Thanks a lot,

Jean-François

Quote:
URL de Gallery = http://www.jfschmitz.net/gallery2/main.php
Gallery version = 2.3 noyau 1.3.0
API = Noyau 7.54, Module 3.9, Thème 2.6, Intégré 1.5
PHP version = 5.2.1 cgi-fcgi
Serveur Web = Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.7e mod_auth_pgsql/2.0.3
Base de données = mysqli 5.0.32-Debian_7etch5~bpo31+1-log, lock.system=flock
Boîtes à outils = ArchiveUpload, Exif, LinkItemToolkit, Thumbnail, Gd, SquareThumb, ImageMagick
Accélération = none, none
Système d'exploitation = Linux supremecenter14.co.uk 2.6.24.2-smp-AM #13 SMP Tue Feb 19 18:35:20 GMT 2008 i686
Thème par défaut = x_treme
gettext = activé
Langage = fr_FR
Navigateur Web = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3
Lignes dans la table GalleryAccessMap = 92
Lignes dans la table GalleryAccessSubscriberMap = 868
Lignes dans la table GalleryUser = 3
Lignes dans la table GalleryItem = 864
Lignes dans la table GalleryAlbumItem = 26
Lignes dans la table GalleryCacheMap = 0

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2009-09-28 22:33

You can give some (or all) checkout products a zero price.

You can also select whether a product has a delivery/shipping/cost or not, and with checkoutdownloads you can attach a downloadable version of an image to any product as well as or instead of a physical deliverable.

If an order total cost is zero (no shipping, no products with non-zero price, or the discount applied makes the total equal or less than zero) the order is marked as "payment cleared" as soon as it is confirmed. This means that any downloads can happen straightaway. Otherwise downloads only happen after the (non-zero) payment is cleared.

checkoutpaypal and checkoutgoogle won't activate for zero-cost orders. If you are expecting zero-cost orders, you must install checkoutemail (which will be the only available 'payment' choice for orders with zero cost). When the customer details are entered in checkoutemail a zero-cost order will proceed to the "payment-cleared" stage as described instead of waiting for you the admin to receive a cheque.

 
Jiheffe

Joined: 2009-07-19
Posts: 14
Posted: Tue, 2009-09-29 05:36

Hi,

thanks for this info, I'll check it out ;-)

JF

 
Jiheffe

Joined: 2009-07-19
Posts: 14
Posted: Tue, 2009-09-29 15:08

Works like a charm ;-)

I was wondering, however, if I can get rid of the (in my case) unneeded step "Checkout Customer Details" in the mail checkout process, and go directly to the download step. Basically, I will either allow free downloads or use Paypal for payments, but I do not plan to use the email module for payments.

Now, I came across another issue "Security Violation The action you attempted is not permitted." when adding an entire album to the cart, but I suspect it could be a theme issue (using X_treme). I was initially able to add albums to the cart, but in the meantime I have been playing with the tons of options in X_treme theme, and now I get this error. I can still add single pictures, but no albums any more. It does still work correctly with the Matrix theme. I guess I will post the issue in the appropriate forum ;-)

 
Jiheffe

Joined: 2009-07-19
Posts: 14
Posted: Tue, 2009-10-06 15:07

Update:

I've been "playing" with the different options, setting up the Paypal module to use the sandbox, etc...

So I had set up both email and Paypal checkout.

Using the email checkout is a nice solution for the free downloads as long as you don't need Paypal for chargeable items. But what happens is that when someone checks out a cart with chargeable items, both the email checkout and the Paypal checkout options appear. I actually don't want people to use email checkout to pay, I just want them to use Paypal.

Not sure there is a way to show only email checkout when the cart contains only zero-value items, and use only Paypal checkout when there is some amount to pay? Is it possible or did I miss something obvious? ;-)

A workaround is to disable email check-out and use the Download link module to allow people to download directly pictures without using the Checkout Cart, but this has two tradeoffs: (a) it is less flexible in selecting which sizes to offer for download, and (b) people need to download pictures separately, they cant download complete albums or "shop" for pictures and download them altogether at the end.

JF

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Tue, 2009-10-06 15:34
Quote:
Not sure there is a way to show only email checkout when the cart contains only zero-value items, and use only Paypal checkout when there is some amount to pay? Is it possible or did I miss something obvious? ;-)

Bit of programming for you:

Edit checkoutemail/templates/Payment.tpl to read

 {if ($payment.paymentVariables.orderTotal == 0)  && $payment.paymentVariables.active}

Usual rules about editing template files, details at the top of the file if you're not familiar with them.

 
Jiheffe

Joined: 2009-07-19
Posts: 14
Posted: Tue, 2009-10-06 20:04

I edited the file in that way, but that didn't change anything. (I did the changes in ./local and I did flush the template cache after each change).

Just to test out things, I changed it to read ($payment.paymentVariables.orderTotal != 0), and then I never get the email option, even not when the cart is not empty. When only free stuff is in the cart, there is no payment option at all, and when there are chargeable items, the Paypal module is available but not the email module.

What is the $payment.paymentVariables.active variable?

Also, "&&" means logical "and", correct? (it's been a very loooong time since I last programmed, and it was Cobol ;-) ).

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2009-10-07 01:55

Oh, the $payment.paymentVariables.orderTotal isn't being set in checkoutemail because (up till your mod) it isn't needed.

You need to add to checkoutemail/classes/CheckoutEmailPaymentPlugin.class as follows:

line 61: $orderTotal = $session->get('checkout.total');
(old) line 78: 'orderTotal' => $orderTotal,

or somesuch - you might have to tidy up etc, it's late and I haven't tested.

Which reminds me that checkoutemail doesn't use the CheckoutApi class like it should. Never mind - one to tidy up in the future.

Quote:
What is the $payment.paymentVariables.active variable?

It's set in the module's config page, something about "activate this method of payment", as I recall.

Debugging is the same in Smarty as it is in Cobol.

 
Jiheffe

Joined: 2009-07-19
Posts: 14
Posted: Wed, 2009-10-07 03:32

I've changed checkoutemail/classes/CheckoutEmailPaymentPlugin.class as follows:

$session->put('checkoutemail.transactionId', $session->get('checkout.transactionId'));
$session->put('checkoutemail.total', $session->get('checkout.total'));
$orderTotal = $session->get('checkout.total');
list ($ret, $paymentButtonText) = GalleryCoreApi::getPluginParameter('module', 'checkoutemail', 'paymentButtonText');

and

return array(null, array('paymentButtonText' => $paymentButtonText, 
			'paymentText' => $paymentText,
                        'orderTotal' => $orderTotal,
			'active' => $active));

I still get the same results, as if orderTotal is not returned (or returned empty).
Do I need to change something in the getVariables() function declaration in modules/checkout/classes/CheckoutPaymentInterface_1_3.class ?

BTW, does the ./local override system also apply to classes? I understood from the codex or forum it's only for templates?

Quote:
Debugging is the same in Smarty as it is in Cobol.

:-)

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2009-10-07 09:16
Quote:
Do I need to change something in the getVariables() function declaration in modules/checkout/classes/CheckoutPaymentInterface_1_3.class ?

No

Quote:
BTW, does the ./local override system also apply to classes?

No
Ok, you'll have to do it like this then (in CheckoutEmailPaymentPlugin.class:

        GalleryCoreApi::requireOnce('modules/checkout/classes/GalleryCheckoutApi.class');
        list ($ret, $transaction) = GalleryCheckoutApi::getCurrentTransactionForPayment();
        if ($ret) {
            return array($ret, null);
        }
        $orderTotal = $transaction->getAmount();

etc.

 
Jiheffe

Joined: 2009-07-19
Posts: 14
Posted: Wed, 2009-10-07 12:50

Yep, that worked out! Thanks a lot for your support and responsiveness. Very appreciated!

Now, I was wondering... Instead of modding the checkoutemail module, I could duplicate it to, say, "checkoutfree", and add that as an additional module. I could then further tweak it to either completely bypass the form requesting user info, or just ask for an email address to send out the download link. I'll check that out and if there interest, I could share it as well :-)

Thanks!

 
coryvdh

Joined: 2010-02-09
Posts: 2
Posted: Sun, 2010-06-13 20:51

Hi,

I'm attempting to setup the email download link exactly as described above but I'm not following. Can someone explain a little clearer exactly what needs to be edited\changed to get this to work?

Thanks
Cory

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2010-06-14 19:49
Quote:
I'm attempting to setup the email download link exactly as described above but I'm not following. Can someone explain a little clearer exactly what needs to be edited\changed to get this to work?

There are various things describe above, but unless you can explain a) what you're trying to do and b) which bit of the editing instructions above isn't clear - it's hard to help you without just repeating what's already been said.