Home › Forums › Themes Support › Claue › Add Title Field to Checkout
- This topic has 13 replies, 2 voices, and was last updated 5 years ago by Harry.
-
AuthorPosts
-
-
April 4, 2019 at 6:43 am #30136
Hi Harry,
On the checkout page:
Before the First Name Field I would like to add the field Title which would be a drop down list (select) of:
Mr
Mrs
Miss
Ms
Drand have this a mandatory field.
I hope you can help with this.
Many Thanks for your continued support and help, always appreciated.
Kind Regards,
Rizwan -
April 4, 2019 at 9:44 am #30139
Hi Rizwan,
Please follow this topic https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/#section-7 and https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/#section-3
Kind regards
Harry
Premium Wordpress themes and plugins, Best WooCommerce theme https://themeforest.net/user/janstudio/portfolio?ref=janstudio -
April 12, 2019 at 10:15 pm #30320
Hi Harry,
Thank you for links. I have been trying to add Title field to funtions.php of child theme however getting the error message:
I have seen else where this code, which might work but, says I cannot edit templete.
$address_fields[‘title’] = array(
‘label’ => __(‘Title’, ‘woocommerce’),
‘required’ => false,
‘class’ => array(‘form-row-custom’),
‘type’ => ‘select’,
‘options’ => array (” => __(‘Select option’, ‘woocommerce’), ‘MR’ => __(‘Mr’, ‘woocommerce’), ‘MRS’ => __(‘Mrs’, ‘woocommerce’), ‘MISS’ => __(‘Miss’, ‘woocommerce’), ‘MS’ => __(‘Ms’, ‘woocommerce’), ‘DR’ => __(‘Dr’, ‘woocommerce’))
);On the Checkout page before the First Name, need the Title filed as a Select drop down and a mandatory filed, SO
Title * , First Name * , Last Name * are all on one row.
I have been trying, I hope you can help me with this.
Many thanks and alias appreciate all your help.Kind Regards,
Rizwan -
April 12, 2019 at 10:38 pm #30322
Hi,
The issue because your site doesn’t set permission to edit file in theme. You should add code in FTP or use plugin AceIde
Kind regards
Harry
Premium Wordpress themes and plugins, Best WooCommerce theme https://themeforest.net/user/janstudio/portfolio?ref=janstudio -
April 13, 2019 at 12:03 am #30324
Hi,
Thank you for that. I have used AceIde however having issues saving. The WordPress editor gives me error above, however if I refresh page and then edit , it is fine.
I have used your links however I am having problems placing the position at the top next to :
Title * , First Name * , Last Name * are all on one row.Using:
add_action(‘woocommerce_after_order_notes’, ‘customise_checkout_field’);
function customise_checkout_field($checkout)
{woocommerce_form_field(‘title’, array(
‘label’ => __(‘Title’, ‘woocommerce’),
‘required’ => true,
‘class’ => array(‘form-row-wide’),
‘type’ => ‘select’,
‘options’ => array(‘Mr’ => __(‘Mr’, ‘woocommerce’), ‘Mrs’ => __(‘Mrs’, ‘woocommerce’), ‘Miss’ => __(‘Miss’, ‘woocommerce’))
), $checkout->get_value(‘title’));}
/**
* Checkout Process
*/
add_action(‘woocommerce_checkout_process’, ‘customise_checkout_field_process’);
function customise_checkout_field_process()
{
// if the field is set, if not then show an error message.
if (!$_POST[‘title’]) wc_add_notice(__(‘Please enter Title’) , ‘error’);
}https://ipac.donate.studio/wp-admin/theme-editor.php?file=functions.php&theme=claue-child
Any help in getting the Title in the correct position would be much appreciated.
I have looked at Priority @
https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/#section-4but could not figure it out.
Any help would be much appreciated.
Kind Regards,
Rizwan -
April 13, 2019 at 7:24 am #30327
Hi Rizwan,
Please change your code to
add_action('woocommerce_before_checkout_billing_form', 'customise_checkout_field'); function customise_checkout_field($checkout) { woocommerce_form_field('title', array( 'label' => __('Title', 'woocommerce'), 'required' => true, 'class' => array('form-row-wide'), 'type' => 'select', 'options' => array('Mr' => __('Mr', 'woocommerce'), 'Mrs' => __('Mrs', 'woocommerce'), 'Miss' => __('Miss', 'woocommerce')) ), $checkout->get_value('title')); } /** * Checkout Process */ add_action('woocommerce_checkout_process', 'customise_checkout_field_process'); function customise_checkout_field_process() { // if the field is set, if not then show an error message. if (!$_POST['title']) wc_add_notice(__('Please enter Title') , 'error'); }
Kind regards
Harry
Premium Wordpress themes and plugins, Best WooCommerce theme https://themeforest.net/user/janstudio/portfolio?ref=janstudio -
April 13, 2019 at 2:22 pm #30330
Hi Harry,
Many Thanks for the update. Its on the top which is great now.
1. Is it possble now to have it on one row, with First and Last Name fields, so:
Title * , First Name * , Last Name * are all on one row.
2. I can see when I press Place Order button at:
Since Mr is already set, it does not promote the Donor to select their title. Is it possble to have Title (this name) as the default value and if nothing is selected then a pop up notification asking to add Title would appear if the Place Order button was pressed.
3. On the Checkout Order confirmation page:
Where it says Billing address can I add the Title before the First Name field. i.e if I selected Mr as Title on checkout page, then here it would say:
Mr. Fred Dred
23 …4. Also on the Order Details page:
Under Billing can I have the same as 3, so we have i.e Mr. Fred Dred and then address underneath that.
5. Also same for the email I would get can we add Title before the First Name – i.e Mr. Fred Dred
Would appreciate your help and as always really appreciate all your help so far.
Kind Regards,
Rizwan -
April 13, 2019 at 5:03 pm #30335
Hi Rizwan,
For this case, please contact with WordPress expert at https://bit.ly/2Loo6ke to help you check this.
Kind regards
Harry
Premium Wordpress themes and plugins, Best WooCommerce theme https://themeforest.net/user/janstudio/portfolio?ref=janstudio -
April 30, 2019 at 2:21 pm #30714
Hi Harry,
Many Thanks for all your help.
I have used your script and links and they have helped a lot , many thanks.
I added a user and donation with Email: [email protected]
The Title field I set was set to Prof. However when I export both customer and order data, I do not get the title column to appear. Please find attached files.
Can you show me how we can get this column to appear in the export or where it is in the SQL server database table, column?
Appreciate all your help with this. Ideally would like the title to appear in the customer export where we have name, details etc..
Many Thanks again for all your help.
I hope you can help.Kind Regards,
RizwanAttachments:
You must be logged in to view attached files. -
April 30, 2019 at 10:25 pm #30725
Hi Rizwan,
I don’t have experience with this, please contact to wordpres expert at https://bit.ly/2Loo6ke.
Kind regards
Harry
Premium Wordpress themes and plugins, Best WooCommerce theme https://themeforest.net/user/janstudio/portfolio?ref=janstudio -
May 1, 2019 at 8:17 pm #30759
Hi Harry,
OK, I understand. Can you help me with the following code
/**
* ADD TITLE
*
*/add_action(‘woocommerce_before_checkout_billing_form’, ‘customise_checkout_field’);
function customise_checkout_field($checkout)
{woocommerce_form_field(‘title’, array(
‘label’ => __(‘Title’, ‘woocommerce’),
‘required’ => true,
‘class’ => array(‘form-row-wide’),
‘type’ => ‘select’,‘options’ => array(‘mr’ => __(‘Mr’, ‘woocommerce’), ‘mrs’ => __(‘Mrs’, ‘woocommerce’), ‘ms’ => __(‘Ms’, ‘woocommerce’), ‘miss’ => __(‘Miss’, ‘woocommerce’), ‘dr’ => __(‘Dr’, ‘woocommerce’), ‘prof’ => __(‘Prof’, ‘woocommerce’))
), $checkout->get_value(‘title’));}
//Checkout Process
add_action(‘woocommerce_checkout_process’, ‘customise_checkout_field_process’);
function customise_checkout_field_process()
{
// if the field is set, if not then show an error message.
if (!$_POST[‘title’]) wc_add_notice(__(‘Please enter Title’) , ‘error’);
}/**
* Update the order meta with field value
*/
add_action( ‘woocommerce_checkout_update_order_meta’, ‘my_custom_checkout_field_update_order_meta’ );function my_custom_checkout_field_update_order_meta( $order_id ) {
if ( ! empty( $_POST[‘title’] ) ) {
update_post_meta( $order_id, ‘title’, sanitize_text_field( $_POST[‘title’] ) );
}
}Which I have taken from the links you supplied.
I am trying to find out the table in which this Title field is being stored.
Can you please see the code and see if you can tell there the Title filed is being stored in MYSQL database.If you can find it, it would be great and I can use this table in my export plugin to get the field I need.
Any help with this would be helpful.
Kind Regards,
Rizwan -
May 3, 2019 at 10:25 am #30831
Hi,
I just front-end developer and do not know more about database so can’t help you in this case.
Kind regards
Harry
Premium Wordpress themes and plugins, Best WooCommerce theme https://themeforest.net/user/janstudio/portfolio?ref=janstudio -
May 3, 2019 at 5:01 pm #30839
Hi Harry,
OK yes I understand. Harry can you then please try and help with me the following:
Hi Harry, Many Thanks for the update. Its on the top which is great now.
1. Is it possble now to have it on one row, with First and Last Name fields, so: Title * , First Name * , Last Name * are all on one row.
If you can help place the Title, First Name and Last Name on one row, that would be great and would rally appreciate if you could look into this.
Kind Regards,
Rizwan -
May 3, 2019 at 5:47 pm #30840
Hi Rizwan,
It in different form of HTML not in one div so can’t make it in same row.
Kind regards
Harry
Premium Wordpress themes and plugins, Best WooCommerce theme https://themeforest.net/user/janstudio/portfolio?ref=janstudio
-
-
AuthorPosts
You must be logged in to reply to this topic.