I needed to make some customization on the checkout_form in ec 5x-3.6, i tried building a simple module with a hook_form_alter as usual...
I noticed how difficult would have been to place a new form element inside the address fieldset, both the shipping and the billing one.
But i tried...
Normally you would use some simple array_slice and array_search to find the key where you wanted to place your new form element but that's impossibile with checkout_form this way, because you can only decide to place it before or after the fieldsets.
So i managed to go deeply inside the form to find the single elements to place my new one.
That worked, even if difficult and dangerous but the i had to collect the array again, using the pieces i've made using array_slice for the most.
Now i have everything in the right place, but something might have changed in the form, the result is that i can't see any info i gave when submitting the checkout form.
In the review screen i don't have addresses or any other information anymore, even if see them correctly inside the $form, the same obviously happens in the transactions list page.
Is there any other way to change the fields the checkout_form provides?
I paste here the code i used to put my array ($n3_fields) where i wanted it to be:
$address =array_slice($form, 0, 1);
$secondaparte =array_slice($form, 1, 300);
foreach($address as $item) {
$shipping = array_slice($item, 0, 1);
$billing = array_slice($item, 1, 300);
foreach($shipping as $fields ) {
$newaddress = array_merge(array_slice($fields, 0, 2,true),$n3_fields,array_slice($fields, 2, 300),$billing);
$recreate['address']['billing'][] = $newaddress;
}
}
$form = array_merge($recreate,$secondaparte);
I know it is quite twisted, but i had to recover the fieldset i lost dividing the array into fragments,
hope to find someone interested as much as i am in cusotmizing this $form
Thanks,
Da.
Comments
Comment #1
planctus commentedWell, this is a typical situation...
I write an issue and some time later i find a solution by myself...
What i was doing was really useless, since i had only to alter the $form['address'] actually, not the whole $form array that was harder to do.
Now i managed to make my changes in that array and everything is working.
I think i can close this issue, but there's another typical situation...i close an issue and after a few minutes something bad happens :-)
Hope it won't this time...
Thanks,
Da.
Comment #2
planctus commentedI know...i'm doing all by myself :-)
But now the question is:
how to store this additional infos to bring them in the next screen (review for me) and finally in the transaction list?
Here i find another form_id "store-transaction-form" where does it get informations? what's the module creating that form?
This is the first time i use ec, i was quite happy because it worked well and it was easy to theme the cart but now i'm asking why it needs to be that difficult to choose which informations to ask the users when they buy something...
Did anyone manage the whole process (checkout - review - transaction list) successfully?
Thanks, anyway...to everyone involved in the ec development, this is a powerful feature for drupal.
Da.
Comment #3
planctus commentedI think i'm giving up...
I saw what happens during the transaction, there are columns for each address info in the db.
I should add one for every new field i'm adding to make that info appear in the transaction list.
I won't do that.
Da.
Comment #4
planctus commentedComment #5
davea commentedHello there,
One thing you could do is copy the ecommerce address module, modify it and use it in place of the original. Then you could modify it as you see fit.
DaveA