[checkout module] make another field required

cwildermuth

Joined: 2007-04-23
Posts: 16
Posted: Sun, 2008-04-20 05:23

I was hoping to find someone on here that is intimately familiar with the checkout and checkout by email module. I would like to be able to make another field "required" and if possible to name that field as well. There are a few fields that seem to be thrown in that dont really have a purpose that I'd like to utilize.

Also, is there any way to charge extra for certain paper types or options?

Thanks,
~C

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sun, 2008-04-20 09:31

I guess if anyone's familiar with Checkout, it's me.

Are you using the latest version? 0.3.2 - get it from this thread: http://gallery.menalto.com/node/74849

To add fields to the tables you'll need to write some code. There aren't any fields that are unused (except some of the binary flags - they will likely be used in future updates, so if you use one for something other than its titular role you're probably screwing your update path. You certainly shouldn't rename any of the fields as they are referenced by name throughout the code.

A better way to do it that won't break anything is to write a new module and create a new Map table for your extra data. Depending on what you want to put in it, you should use the various interfaces in Checkout to reference your code which will add the data; that way you preserve your upgrade path and don't have to alter any code in checkout itself. If you explain what the 'required' field is for, I can be more specific.

To charge extra for certain paper types: the easy way is to include them as separate products, and give them different prices. The neater way involves creating a new module which will implement the CheckoutTransactionDetailsInterface_1_0.class to modify the cart contents (obviously adjusting the prices according to the paper selections); if you do that you can (probably should) give it a per-album/item admin page by implementing the CheckoutCustomPageInterface_1_0.class. Then you can post your code and everyone else can use it too. If you want to go that route let me know and I can give more details.

 
cwildermuth

Joined: 2007-04-23
Posts: 16
Posted: Sun, 2008-04-20 17:29

hmmm I have 0.1.18... am I really that far behind? I thought i had nearly the latest version? :(

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sun, 2008-04-20 17:42

0.1.18 is the latest 'released' version, but it hasn't been updated for about a year. I took on some updates a couple of months ago and moved quickly through version 2 to where it is today, 0.3.2. That seems pretty stable and I've been using it on a production site for the last couple of weeks, as have a few others. On my to do list is to get it moved back into the SF server. There are dozens of new features and the architecture is much more extensible, so at this stage I'd recommend giving it a go especially if you're considering modifying or adding to it. Version 0.1.18 is functional but basically dead, and you'll find it hard to move any changes forward from there as the architecture has changed quite a lot.

 
cwildermuth

Joined: 2007-04-23
Posts: 16
Posted: Sun, 2008-04-20 17:59

Oh wow! Well I'll have to check it out then and see what has changed. It's amazing how much can change in a few months; it seems like I had only just installed this 4 or 5 months ago. If no one has complimented you yet for taking this on let me be the first. I love the module but I felt like it was quite 'unfinished' so I'm excited to see you carrying on the work. Thank you so much. I'll go downlod 3.2 and get that loaded and see if I need anything from there.

Do the other 'checkout' modules still work with this version or have they been updated as well? Currently I use the Checkout by E-Mail but maybe Checkout via Paypal in the future...

On my requests though, the main field we needed to be "required" was a telephone number field. In the version I have there are 3 fields for users to put information in but they are neither labeled nor required. One the second request what is actually needed is a way to charge $5 for custom text on an image. In 1.18 I saw that you could put in different paper types, so I figured I would just label one of those "Custom Image Text" but then I didnt see a way to charge for that. I assumed different paper types might need to change the price some, so I wasnt sure if that was a feature or something I was just missing.

Anyhow, Like I said I'll checkout the new version and then let you know. If it doesnt seem to expand into exactly what we need do you do any custom development on the side to write the pieces we would need to do this?

Thanks so much!
~C

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sun, 2008-04-20 18:11

You'll need to use the new versions of checkoutemail (and checkoutpaypal if you require it) that are included; there shouldn't be any problem upgrading them.

I think a phone number field is a good idea, should be quite straightforward to implement. It will be difficult to make it required, because, for instance, paypal doesn't (I don't think) return that information so checkoutpaypal orders couldn't have it. (Might be wrong, will have to investigate.) There should be no problem with you implementing a custom mod to require it in your own checkoutemail module though.

You could also by the way have a module that 1) asked for the custom text 2) charged appropriately and 3) on download or whatever added the text automatically - if you wanted.

I'm open to offers on custom development - pm me if you like. Otherwise, best move discussion of new features for 0.3.2 to the thread http://gallery.menalto.com/node/74849 rather than here.

Good luck!

 
cwildermuth

Joined: 2007-04-23
Posts: 16
Posted: Fri, 2008-04-25 04:58

Help! It's busted!

I copied the folders over the old ones, then ran the upgrade from the plugin admin page. I then went in to look at the new options and noticed that part of the options and page seemed to be missing... I remember that I had this same problem when I first installed 1.18 and the cause was permissions on the module folder. I went back and gave the web server user write privileges to the folder and tried again..still nothing. So I deactivated checkout by email first, then checkout, then uninstalled checkout by email (which I always..even with old version.. got error about not being able to completely delete checkout by email module), then uninstalled checkout. Then I deleted folders from module directory, copied new ones, activated and configured and I'm in the same boat... The checkout module I can activate and configure, but the checkout by email module will never actually let me configure. I can go into it and put options and save them, and when I go back they are gone and the module can never be activated now.

I'm not sure what to do... I'm not sure if this has anything to do with your new version, or if it's a carry-over from the old version I was running before and all the issues I had with it trying to get it working.

What should I try? I'm out of ideas since I've deleted them, deleted folders, and tried to reinstall. The only thing I havent done (and dont know how to do) is delete any references to the modules in the database or any tables that might still exist.

Of course this is a production site... so I'm kinda screwed now. Any ideas?

I think I might try putting the old version back.. but of course all my options will be gone now.

Thanks for the help.
~C

 
cwildermuth

Joined: 2007-04-23
Posts: 16
Posted: Fri, 2008-04-25 05:48

Yep... I'm convinced that my checkout by email config is FUBAR. I uninstalled (as much as I could) the new version...still getting the "failed to completely delete checkout by email" error. Then I deleted the directories and put the old version back... got the old version working again. Just so I could put salt in my own wound, now that I fixed it.. I figured "oh what the hell maybe it will work the second time around." So I copied the new version of the modules in, did the upgrade, did the configure and activate...and same thing. The checkout part looks complete (and options look to be the same as the old version...is that right?) The checkout by email config though is the one that is all messed up. Most of the options are missing... I've attached a screen shot.

Any ideas? I still think the original issues I was having with 1.18 somehow screwed stuff up in the DB and so those issues are carrying over into this upgrade. How difficult is it to remove the tables and rows in the DB that checkout and checkout by email reference? Maybe I can start completely clean from scratch...

Let me know what you think. I think I'll put the old version back..again.. :-)

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2008-04-25 07:33

It's fine, I think - there's a gallery bug that means you need to clear the template cache (from the admin/maintenance page) when you upgrade certain modules. So run the upgrade, clear the cache, and the page should appear ok.

By the way, you can't mix-n-match different versions of checkoutemail and checkout - you have to use the latest version of checkoutemail (supplied with) if you're using checkout 0.3.2. And yes, most of the options should have gone - there's much less to configure in the latest checkoutemail than the one that works with checkout 0.1.18.

 
lucasmarin
lucasmarin's picture

Joined: 2010-07-14
Posts: 37
Posted: Sun, 2010-07-25 01:03

Hi Alec. I read what you wrote above regarding the CheckoutCustomPageInterface_1_0.class.
I think i need to do what you said: "The neater way involves creating a new module which will implement the CheckoutTransactionDetailsInterface_1_0.class".

Let me explain myself. I want to sell prints and also license images. I´m not interested in using the printing modules right now, because i want the customers to stay on the site. So i thought of doing just one checkout, they would pay through paypal and if it is a print, i´ll do all the printing and shipping.
The thing is that if i add all the options for printing (sizes, paper, etc) plus all the options for licensing (size, uses, etc), it gets pretty messy. And that is just for 1 picture. Plus clients buying prints shouldnt see options for licensing and viceversa.

My rudimentary solution was to duplicate the module, renaming all the corresponding parts. The original checkout would be for licensing and the copy named "buyprints" for printing. It worked great, until i had to use the paypal module. There can´t be 2 paypal modules apparently, as gallery don´t get the notifications back from paypal and the photos remain unpaid.
Is it my solution then using the interface you proposed there?
Can you give me a hand?
Thanks!

http://www.lucasmarin.com

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2010-07-26 01:36

You can have as many paypal modules as you like; they'll all have to have different names which means they'll automatically have different urls for the callback from Paypal. But you'll also have to change the interface names in the two different checkout modules (also having different names) so only one paypal module connects to each checkout module.

But that's a really ugly solution: you'll have two view cart commands, two "add to cart" commands for each image, two config pages, two sets of orders and so on.

What is it that you really want to achieve?

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2010-07-26 02:05
Quote:
My rudimentary solution was to duplicate the module, renaming all the corresponding parts.

So you're going to have two different "Add to cart" links for each picture? And two different sets of cart contents? And two different "view cart" commands?

Quote:
The original checkout would be for licensing and the copy named "buyprints" for printing. It worked great, until i had to use the paypal module. There can´t be 2 paypal modules apparently, as gallery don´t get the notifications back from paypal and the photos remain unpaid.

You can have as many paypal modules as you want, if you change enough of one of them so it's distinguishable from the other. That will include changing all the interface names *everywhere*, and making sure that the second paypal module implements only the changed payment interface, and since it will have to have a different module name it will have a different callback url automatically.

Quote:
Is it my solution then using the interface you proposed there?

I'm not sure - what would you be trying to do with it?

 
lucasmarin
lucasmarin's picture

Joined: 2010-07-14
Posts: 37
Posted: Mon, 2010-07-26 04:32

Hey Alec. Thanks a lot for the replies. Yes, i would have 2 "add to cart", but i would rename them with something like "licensing" and "printing". Thats no problem. I would have 2 of everything, like you say, but i rather have it like that, than licensing and printing categories mixed. I think one thing has nothing to do with the other.
Yes, ideally i would have just one cart and one paypal module, and 2 links under each picture. If they clicked in "licensing" they would see those options, and if they clicked on "prints" they would see sizes and paper and stuff. But i don´t know how to do it. Its too advanced for me.
When you say "everywhere", you mean in the whole site, or just in the checkout and paypal modules? Because inside the duplicated modules, there are no references at all to the original checkout or paypal modules, i made sure of that. No code, no text, anything. I renamed everything to "buyprints". And it worked great all the way, except getting the notifications back from paypal.
Any ideas?

http://www.lucasmarin.com

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2010-07-26 13:03
Quote:
Because inside the duplicated modules, there are no references at all to the original checkout or paypal modules, i made sure of that. No code, no text, anything.

There are references that you missed; but they're indirect. This is how it works:

The checkout module defines a class CheckoutPaymentInterface_1_3 (see the eponymous .class file) and all of the payment modules including checkoutpaypal implement a different implementation of this class (see checkoutpaypal/classes/CheckoutPaypalPaymentPlugin.class for the code) and register that implementation in the FactoryMap table when the payment module is installed - for checkoutpaypal this is in checkoutpaypal/module.inc line 53.

Then when checkout builds the confirm page (the one with the payment methods at the bottom) it calls CheckoutInterfaceHelper::getPaymentPlugins() which checks through the FactoryMap table for implementations of the payment interface to know which sub-templates to include at the bottom of that page. See CheckoutInterfaceHelper.class line 52ff.

In order to have two paypal modules and for each of two checkout modules to recognise one and only one paypal module, you will have to change this interface name ("CheckoutPaymentInterface_1_3") everywhere it apears (filenames and contents), before installing those modules.

This de-duplication effort will have to be applied to *everything* *else* either of the two modules registers in the FactoryMap, too: look in the respective module.inc files for function performFactoryRegistrations() to see what that refers to. Then you have to mirror those changed names *everywhere* in the code files and code file titles they appear making sure that the changes are consistent across the two modules.

For instance, the CheckoutEmailInterface_1_0 is used for having payment modules (or other modules) add contents to the emails that checkout builds; that needs to be disambiguated.

Also the names of the different GalleryEntities that the two checkoutpaypal and checkout modules use have to be distinguished; you can only have one module declaring (and using) a GalleryCheckoutPaypalIPN Entity, a GalleryCheckoutTransaction Entity, a GalleryCheckoutItem Entity and so on. The second pair of modules will have to have different entity names so the tables in the db are distinct. In order to change an Entity name you'll need not only to change the php code files (and names) but also to go right back to the .xml files and mirror the changed name, including in all revision files (there are 12 revisions for the CheckoutTransaction Entity/class table.) When you've changed all the xml files you'll have to recompile with the developer tools to automatically generate the schema.tpl file which is the code Gallery uses to build the tables (with the correct names, now) when the modules are installed.

I hope you've nothing else planned for the next couple of weeks!

 
lucasmarin
lucasmarin's picture

Joined: 2010-07-14
Posts: 37
Posted: Tue, 2010-07-27 01:33

Hey Alec. Thank you for taking the time to explain all that to me. While i would be more than glad to spend those couple of weeks to do that, i think that is way beyond my capabilities. I read the whole thing a few times and i have no idea what you are talking about :)
The good thing is that now this whole explanation is posted, and may be of some use to somebody else, and also to broaden the community knowledge.
My skills, if any, are more CSS oriented. So i was thinking, is there a way to send a custom parameter from the "add to cart" button to the checkout module, so i can with CSS hide either the License or Prints section? That way i can use 2 links like "License photo" and "Buy prints" but both go to the same checkout, only i am hiding what i dont want to be displayed.

Thanks again Alec.

http://www.lucasmarin.com

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Tue, 2010-07-27 03:07
Quote:
I read the whole thing a few times and i have no idea what you are talking about

ROFL. I'm so glad I spent the hour and half it took me to research and write it, then.

Quote:
is there a way to send a custom parameter from the "add to cart" button to the checkout module

No, not really.

 
lucasmarin
lucasmarin's picture

Joined: 2010-07-14
Posts: 37
Posted: Wed, 2010-07-28 08:30

Hi alec. Sorry for that! At least now is there, and i'm sure is going to be useful to somebody! Someone with more knowledge than me. I have no idea of compiling.
Anyway, i thought of dropping the whole thing, and i was going to just have a big list of items with an explanation at the beginning, in checkout step 1.
But then i thought i could just hide the prints or the licensing with {$thisProduct.name} and CSS. Because i have just 2 categories "license" and "prints" with a few options each. But i couldnt get too far. My only achievement was to show only the prints category using a line that is already there:
{if $thisProduct.paperSet}

With that i was able to hide the licensing options. But i have no way to do it viceversa, i dont know how.
Is it too complicated what i´m trying to do?
This image:
http://www.lucasmarin.com/checkout.jpg
shows something like what im trying to achieve.
I don´t know, i´m lost with all the arrays that are there, i cant understand how they work, and the references i´ve been reading dindt help me much.
I used this page for reference mostly: http://www.w3schools.com/php/php_arrays.asp
Are the arrays in SessionContents.tpl numeric? Associative? Multidimensional?
I´m going crazy here, and i think this should be really easy for someone who knows php.
Any ideas?

Anyway, i want to thank you for all your support.

http://www.lucasmarin.com

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2010-07-28 13:01

You could have a little module that adds an extra attribute to each product, "licence" or "print" then test that attribute in your modified template and change the css. Then you can write your own javascript that hides/reveals each class appropriately. To do the first part of this you'd need to understand a lot of G2 structure: modules, interfaces etc as well as be comfortable with php and Smarty (the templating system G2 uses).

Alternatively you could just prefix the product names with "licence" or "print" in the text, then test for that (and strip it out) in the Smarty template.

I can't help you with the CSS or javascript required as I know very little about those two things.

Quote:
Is it too complicated what i´m trying to do?

I can't comment on that; only you know how badly you want this.

Quote:
I´m going crazy here, and i think this should be really easy for someone who knows php.

Oh yes, trivial for someone who's familiar with all the things you'd need to be familiar with.

Good luck!