News:

AbanteCart v1.4.2 is released.

Main Menu

Adding new fields on checkout pages

Started by Rey, January 27, 2017, 01:29:47 PM

Previous topic - Next topic

Rey

Hello, I need to add three text fields on ?rt=checkout/payment page, to take important information needed for the services I provide via my store.
I have taken following steps: -

1. I have added the required fields in this page - \storefront\controller\pages\checkout\payment.php like this -


2. Have modified the database and created the required fields and edited this file - \storefront\model\checkout\order.php to modify the SQL, like this -


3. Have modified these two template files - \storefront\view\default\template\pages\checkout\payment.tpl and \storefront\view\default\template\pages\checkout\confirm.tpl, to add the textboxes on ?rt=checkout/payment page and show the entered values on the ?rt=checkout/confirm page. Have edited templates like this -
payment.tpl: -


confirm.tpl: -


The textboxes are shown on ?rt=checkout/payment page but the values are not shown on ?rt=checkout/confirm page, neither are they geting inserted in the database. e.g.:-
Textboxes are shown: (Not able to correctly position the Red required asterisk as well)


Values are not shown on checkout/confirm page:


Please advise whether I have done it correctly or have missed or overlooked something?

Many thanks.

P.S. I do not want to use any extension from the marketplace.

maxter

For correct display for the fields you need to use right HTML structure of the bootstrap v3.

Try something like this:


<div class="form-group <?php if (${'error_'.$field_name}) echo 'has-error'?>">
<label class="control-label col-md-5"><?php echo ${'entry_'.$field_name}; ?></label>
<div class="input-group col-md-7">
    <?php echo $form[$field_id]; ?>
</div>
<span class="help-block"><?php echo ${'error_'.$field_name}; ?></span>
</div>


The rest of your steps are correct.

If you do not see data saved in the order, please double check that your fields are located between <form></form> tags.
Check what data is posted into the controller on the submit.

Thank you for sharing these in details

Rey

Quote from: maxter on January 28, 2017, 04:51:20 PM
For correct display for the fields you need to use right HTML structure of the bootstrap v3.

Try something like this:


<div class="form-group <?php if (${'error_'.$field_name}) echo 'has-error'?>">
<label class="control-label col-md-5"><?php echo ${'entry_'.$field_name}; ?></label>
<div class="input-group col-md-7">
    <?php echo $form[$field_id]; ?>
</div>
<span class="help-block"><?php echo ${'error_'.$field_name}; ?></span>
</div>


The rest of your steps are correct.

If you do not see data saved in the order, please double check that your fields are located between <form></form> tags.
Check what data is posted into the controller on the submit.

Thank you for sharing these in details

Thanks for the input. The thing is there is a comment field already on the page where I want to put new fields. I have followed exact details of how the comment field works, but still new fields are not working.

The new fields are exactly below comment field and between <form></form> tags, still not working.

Should I add the above code in the .tpl file?

Thank you.

Rey

UPDATE: I am literally at my wits end on this one. There is absolutely nothing left that I haven't done to make this work.
Sure someone else must have done something like this? Kindly share your doings please.

yonghan

Hi,

Since you are going to add the data into orders table, you need to alter the lib/order.php first. Otherwise the data won't be stored. As for confirm.tpl, you need to fetch the data from database and pass it from checkout/confirm.php. Hope it helps.

Rey

Quote from: handoyo on January 30, 2017, 01:40:55 AM
Hi,

Since you are going to add the data into orders table, you need to alter the lib/order.php first. Otherwise the data won't be stored. As for confirm.tpl, you need to fetch the data from database and pass it from checkout/confirm.php. Hope it helps.

Thanks a ton for the tip.
Let me try doing this at once and will post the results.
Cheers.

Rey

UPDATE: Nothing works. I have simply given up. Such small thing but obviously missing out on something. (That too when I am not new to programming)

Anyway, So now can you guys recommend some other ways to take some additional information from the customer, while making an order or after the checkout is successful?

Many thanks.


Rey

#8
Yes, apparently that is the only thing left to do. But the latest version supported by that extension is 1.2.8 and I am running 1.2.9, so I don't know..

Rey


Forum Rules Code of conduct
AbanteCart.com 2010 -