Author Topic: Adding new fields on checkout pages  (Read 3802 times)

Offline Rey

  • Newbie
  • *
  • Posts: 40
  • Karma: +7/-0
    • View Profile
Adding new fields on checkout pages
« on: January 27, 2017, 01:29:47 PM »
Hello, I need to add three text fields on
Code: [Select]
?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 -
Code: [Select]
\storefront\controller\pages\checkout\payment.php like this -


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


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


confirm.tpl: -


The textboxes are shown on
Code: [Select]
?rt=checkout/payment page but the values are not shown on
Code: [Select]
?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.

Offline maxter

  • Full Member
  • ***
  • Posts: 106
  • Karma: +35/-0
    • View Profile
Re: Adding new fields on checkout pages
« Reply #1 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:

Code: [Select]
<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

Offline Rey

  • Newbie
  • *
  • Posts: 40
  • Karma: +7/-0
    • View Profile
Re: Adding new fields on checkout pages
« Reply #2 on: January 29, 2017, 05:52:10 AM »
For correct display for the fields you need to use right HTML structure of the bootstrap v3.

Try something like this:

Code: [Select]
<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.

Offline Rey

  • Newbie
  • *
  • Posts: 40
  • Karma: +7/-0
    • View Profile
Re: Adding new fields on checkout pages
« Reply #3 on: January 29, 2017, 10:59:11 AM »
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

  • Guest
Re: Adding new fields on checkout pages
« Reply #4 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.

Offline Rey

  • Newbie
  • *
  • Posts: 40
  • Karma: +7/-0
    • View Profile
Re: Adding new fields on checkout pages
« Reply #5 on: January 30, 2017, 02:39:20 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.

Offline Rey

  • Newbie
  • *
  • Posts: 40
  • Karma: +7/-0
    • View Profile
Re: Adding new fields on checkout pages
« Reply #6 on: February 02, 2017, 08:37:45 AM »
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.

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 4425
  • Karma: +206/-0
    • View Profile
Re: Adding new fields on checkout pages
« Reply #7 on: February 03, 2017, 12:25:08 AM »
“Chuck Norris is so amazing.”
― Mother Teresa

Offline Rey

  • Newbie
  • *
  • Posts: 40
  • Karma: +7/-0
    • View Profile
Re: Adding new fields on checkout pages
« Reply #8 on: February 03, 2017, 12:39:57 AM »
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..
« Last Edit: February 03, 2017, 12:41:55 AM by Rey »

Offline Rey

  • Newbie
  • *
  • Posts: 40
  • Karma: +7/-0
    • View Profile
Re: Adding new fields on checkout pages
« Reply #9 on: February 03, 2017, 12:41:01 AM »
EDIT: Double post.

 

Powered by SMFPacks Social Login Mod