Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Add this to the functions.php will work!

    add_filter('woocommerce_checkout_update_customer_data', '__return_false' );

    Hi, you pointing at the wrong element in the array. It should be

    unset($fields[‘shipping’][‘fields’][‘shipping_last_name’]);

    I’m adding another field under the shipping address and sorting the order.

    add_filter( 'woocommerce_customer_meta_fields' , 'sort_shipping' );
    
    function sort_shipping( $fields ) {
    
        // temporary store existing array elements
        $f = $fields['shipping']['fields'];
        $shipping_first_name = $f['shipping_first_name'];
        $shipping_last_name = $f['shipping_last_name'];
        $shipping_company = $f['shipping_company'];
        $shipping_address_1 = $f['shipping_address_1'];
        $shipping_address_2 = $f['shipping_address_2'];
        $shipping_city = $f['shipping_city'];
        $shipping_postcode = $f['shipping_postcode'];
        $shipping_country = $f['shipping_country'];
        $shipping_state = $f['shipping_state'];
    
        // reassign elements in the shipping array
        $fields['shipping']['fields'] = array(
            'shipping_first_name' => $shipping_first_name,
            'shipping_last_name' => $shipping_last_name,
            'shipping_company' => $shipping_company,
            'shipping_attn' => array(
                'label' => 'Attention To',
                'description' => ''
            ),
            'shipping_address_1' => $shipping_address_1,
            'shipping_address_2' => $shipping_address_2,
            'shipping_city' => $shipping_city,
            'shipping_postcode' => $shipping_postcode,
            'shipping_country' => $shipping_country,
            'shipping_state' => $shipping_state,
        );
    
        return $fields;
    }

    thanks for the info.

Viewing 3 replies - 1 through 3 (of 3 total)