logo
Ask your WordPress questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$30
WooCommerce modify shipping fields in edit My Account page

I ship to a third-party email address provided by my customers. I'm using the Wordpress Karma theme with a WooCommerce plug in. I have already edited the functions.php file for my child theme to delete the land address fields and add an email address field in Shipping Address portion of the checkout form, but I need to do the same thing when my customer clicks on the My Account page and hits edit Shipping Address. I also need to edit the Order Received email that goes out to customers and includes the Shipping Address. Not sure what the right hook is to use. Would prefer to make edits to functions.php so I don't lose these mods when I version up my WooCommerce plug in. Here's my website.

Lowell Ness | 02/03/13 at 9:04pm Edit
Tutorial: How to assign prize money


(5) Responses

See a threaded view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    02/03/13
    9:08pm
    Fahad Murtaza says:

    I can look into it if you send me access details.

  • avatar
    Last edited:
    02/04/13
    12:48am
    Dbranes says:

    In the core code for woocommerce_save_address() you have:


    // Hook to allow modification of value
    $_POST[$key] = apply_filters('woocommerce_process_myaccount_field_' . $key, $_POST[$key]);


    so it looks like you will have to replace $key in

    woocommerce_process_myaccount_field_.$key


    with your relavant $key, in your add_filter code.

    So you could try out filters like:

    woocommerce_process_myaccount_field_shipping

    woocommerce_process_myaccount_field_shipping_first_name

    woocommerce_process_myaccount_field_shipping_last_name

    woocommerce_process_myaccount_field_shipping_company

    ...

    Previous versions of this answer: 02/04/13 at 12:48am

  • avatar
    Last edited:
    02/03/13
    9:14pm
    Lowell Ness says:

    URL is https://www.accreditedinvestorsolutions.com

  • avatar
    Last edited:
    02/03/13
    9:37pm
    Fahad Murtaza says:

    Well, if you can send me FTP and login to wordpress, I can help. Send it via message.

  • avatar
    Last edited:
    02/03/13
    9:51pm
    Lowell Ness says:

    I'm just looking for the right code hook to use. I don't need you to do that for me. Here's what I've tried so far. The first two filter hooks worked to change the shipping fields in the checkout form (there's a nice easy to follow tutorial available for that one), but the third one for 'woocommerce_process_myaccount_field_' didn't change the shipping fields in the edit Shipping Address page on My Account. The WooCommerce API docs say this is a valid filter hook, but it must not be the correct hook because it didn't change the page I needed to change. The page I'm trying to change comes up when you hit My Account and then you hit edit Shipping Address. Or, it's possible my filter is not correctly coded.


    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
    function custom_override_checkout_fields( $fields ) {
    $fields['shipping']['shipping_first_name']['placeholder'] = 'Recipient First Name';
    $fields['shipping']['shipping_last_name']['placeholder'] = 'Recipient Last Name';
    $fields['shipping']['shipping_company']['placeholder'] = 'Company to receive certification';
    unset($fields['shipping']['shipping_address_1']);
    unset($fields['shipping']['shipping_address_2']);
    unset($fields['shipping']['shipping_city']);
    unset($fields['shipping']['shipping_postcode']);
    unset($fields['shipping']['shipping_country']);
    unset($fields['shipping']['shipping_state']);
    $fields['shipping']['shipping_email'] = array(
    'label' => __('Email Address', 'woocommerce'),
    'placeholder' => _x('Email address to receive certification', 'placeholder', 'woocommerce'),
    'required' => true,
    'class' => array('form-row-wide'),
    'clear' => true
    );
    $fields['order']['order_comments']['placeholder'] = 'Notes about your order, e.g. special notes for delivery of our certification to additional recipients';
    return $fields;
    }

    add_filter( 'woocommerce_email_order_meta_keys', 'my_custom_checkout_field_order_meta_keys');
    function my_custom_checkout_field_order_meta_keys( $keys ) {
    $keys['shipping']['shipping_email'] = 'Shipping Email';
    return $keys;
    }
    add_filter( 'woocommerce_process_myaccount_field_' , 'custom_override_procees_myaccount_field_' );
    function custom_override_proceess_myaccount_field_( $keys ) {
    $keys['shipping']['shipping_first_name']['placeholder'] = 'Recipient First Name';
    $keys['shipping']['shipping_last_name']['placeholder'] = 'Recipient Last Name';
    $keys['shipping']['shipping_company']['placeholder'] = 'Company to receive certification';
    unset($keys['shipping']['shipping_address_1']);
    unset($keys['shipping']['shipping_address_2']);
    unset($keys['shipping']['shipping_city']);
    unset($keys['shipping']['shipping_postcode']);
    unset($keys['shipping']['shipping_country']);
    unset($keys['shipping']['shipping_state']);
    $keys['shipping']['shipping_email'] = array(
    'label' => __('Email Address', 'woocommerce'),
    'placeholder' => _x('Email address to receive certification', 'placeholder', 'woocommerce'),
    'required' => true,
    'class' => array('form-row-wide'),
    'clear' => true
    );
    return $keys;
    }

This question has expired.





Current status of this question: Community pot



Please log in to add additional discourse to this page.





Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.