1

i have installed word press + woo commerce, my site is running in Arabic language.

my check out page is contain these fields (first name - last name - E-mail - phone)

what i want: i hope to edit my checkout page by adding an extra fields like (Company name - position) how to do this

i hope if you explain me i didn't have any experience in PHP, CSS just i will apply your suggestions

1

If you at least know how to open your "functions.php" file, the following should work if you simply add it at the bottom of your functions.php file of your (child-)theme:

// Hook in

add_filter( 'woocommerce_checkout_fields' , 'custom_add_checkout_fields' );

// Our hooked in function - $fields is passed via the filter!
function custom_add_checkout_fields( $fields ) {
     $fields['billing']['Company'] = array(
        'label'     => __('Company', 'woocommerce'),
    'placeholder'   => _x('Company Name', 'placeholder', 'woocommerce'),
    'required'  => true,
    'class'     => array('form-row-wide'),
    'clear'     => true
     );


    $fields['billing']['Position'] = array(
        'label'     => __('Position', 'woocommerce'),
    'placeholder'   => _x('Position', 'placeholder', 'woocommerce'),
    'required'  => true,
    'class'     => array('form-row-wide'),
    'clear'     => true
     );


     return $fields;
}

This should add the fields to the checkout page and have them be required. Then if you want to also add that information to the emails:

add_filter('woocommerce_email_order_meta_keys', 'my_custom_order_meta_keys');

function my_custom_order_meta_keys( $keys ) {
     $keys[] = 'Company'; // This will look for a custom field called 'Company' and add it to emails
     $keys[] = 'Position';
     return $keys;
}

Snippets used from this woocommerce doc

PLEASE NOTE

Adding this directly to your functions.php file of your theme and then updating your theme removes it - creating a child theme is best practice. I know this whole answer might not help you, but it might help someone else.

0

Try to use a plugin to acheive this. there are several plugins on repository https://wordpress.org/plugins/search.php?type=term&q=custom+field+checkout.

So from here you can test some of these and choose your favorite. For example this one is easy to use https://wordpress.org/plugins/woo-custom-checkout-field/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.