I have been working on the checkout module trying to add and additional field to the shoppers details, namely "mobile phone".
I called the new field "mobile", and added it to the page as a part of the Email Checkout modules templates (the Email checkout module I have installed along with the checkout module).
However I have now come across some problems it (the mobile phone) is not being recorded in the database. How do you store the mobile phone number in the database. By store i mean how do i put it into the new table column I have created called g_mobile.
Also I need to know how to retrieve the information from the database once it has been successfully entered. At the moment the values for the admin view are being retrieved like $transaction->getPhone(); I tried using $transaction->getMobile(); but that does not work. I can't find any function on the entire site called getPhone(), so I am at a loss to know where the values are coming from.
Posts: 4342
I'm afraid you won't find it as easy as that - and if you do the required changes you'll break your checkout installation for future upgrades.
Briefly you need to update the GalleryCheckoutTransaction.class with your new field, including adding the field itself, the schema and the get... and set... functions. Also update the schema version from 1.12 to 1.13 (as it stands now)
Also create a scheme addition file in the module's GalleryStorage/xml-src folder (1.12 is missing from the distribution, I've added it to the repository version so you should be able to get it in a few hours time.) Your new one will need to be called A_GalleryCheckoutTransaction_1.13.xml and it needs to contain the schema for the added field to match the entry in GalleryCheckoutTransaction.class.
Then recompile the database entries for the module: go to the module's GalleryStorage directory and run "make", also run "make" in the classes directory. (You need to be on a unix/linux or mac system, or otherwise have access to make.)
When you've done all that, bump the module version in module.inc and add the schema addition to the upgrade() function.
If you've done all that right then you should be able to go to the plugins page and see "upgrade" next to the checkout entry, click on it, and Gallery will add all the required entries in the multiple database tables to add your new field.
If there's an error somewhere, your upgrade will stall half-way through - at which point your best option is to fix the error, uninstall checkout completely and reinstall your new version.
When you've done all that... you can start editing code to actually insert data into the field!
However, since you've now rewritten your code and database structure to a version number that's out of step with the checkout in the repository, you won't ever be able to use the code from there to upgrade again. Sorry.
Posts: 15
Where do i find this version. I went to the repository, to the "get more plugins" tab. I tried updating checkout but there was no new file. How do I access your repository version.
Also as a side note, could you explain how checkout saves the contact/postal-address information. What functions does it uses to save the data. The process is not clear to me.
Posts: 4342
You need to go to "get more plugins", make sure the community repository is ticked and "update plugin list" then you should be able to download the latest Checkout code revision.
For saving contact details: each payment plugin does it differently, because the information comes from different places (checkoutemail the customer types it in, checkoutpaypal it's sent by paypal as part of the Instant Payment Notification) but it's included in data that's sent as an event to CheckoutTransactionEventHelper::handleTransactionUpdate(...) which updates the GalleryCheckoutTransactionEvent Entity.
Good luck!