• Resolved jas1jas

    (@jas1jas)


    Hi!

    I want to keep the First name and Last name fields in Billing tab and move all other to shipping tab. I can do this with following code in functions.php. However I get internal server error when trying to checkout. Any help would be highly appreciated.

    function billing_fields_another_group( $checkout_fields ){

    // 1. We assign a field array to another group here
    $checkout_fields[ ‘order’ ][ ‘billing_company’ ] = $checkout_fields[ ‘billing’ ][ ‘billing_company’ ];

    $checkout_fields[ ‘order’ ][ ‘billing_country’ ] = $checkout_fields[ ‘billing’ ][ ‘billing_country’ ];

    $checkout_fields[ ‘order’ ][ ‘billing_address_1’ ] = $checkout_fields[ ‘billing’ ][ ‘billing_address_1’ ];

    $checkout_fields[ ‘order’ ][ ‘billing_address_2’ ] = $checkout_fields[ ‘billing’ ][ ‘billing_address_2’ ];

    $checkout_fields[ ‘order’ ][ ‘billing_city’ ] = $checkout_fields[ ‘billing’ ][ ‘billing_city’ ];

    $checkout_fields[ ‘order’ ][ ‘billing_state’ ] = $checkout_fields[ ‘billing’ ][ ‘billing_state’ ];

    $checkout_fields[ ‘order’ ][ ‘billing_postcode’ ] = $checkout_fields[ ‘billing’ ][ ‘billing_postcode’ ];

    $checkout_fields[ ‘order’ ][ ‘billing_phone’ ] = $checkout_fields[ ‘billing’ ][ ‘billing_phone’ ];

    // 2. Remove a field from a previous location
    unset( $checkout_fields[ ‘billing’ ][ ‘billing_company’ ] );
    unset( $checkout_fields[ ‘billing’ ][ ‘billing_country’ ] );
    unset( $checkout_fields[ ‘billing’ ][ ‘billing_address_1’ ] );
    unset( $checkout_fields[ ‘billing’ ][ ‘billing_address_2’ ] );
    unset( $checkout_fields[ ‘billing’ ][ ‘billing_city’ ] );
    unset( $checkout_fields[ ‘billing’ ][ ‘billing_state’ ] );
    unset( $checkout_fields[ ‘billing’ ][ ‘billing_postcode’ ] );
    unset( $checkout_fields[ ‘billing’ ][ ‘billing_phone’ ] );

    return $checkout_fields;

    }

    Regards,
    J.

Viewing 1 replies (of 1 total)
  • Plugin Author Diana Burduja

    (@diana_burduja)

    Hello J.,

    I assume your billing_fields_another_group function is attached to the woocommerce_checkout_fields filter with the add_filter( 'woocommerce_checkout_fields' , 'billing_fields_another_group' ); line.

    The WooCommerce plugin needs certain fields to be in the Billing section, as the validation and the saving to the database is based on certain assumptions about where to look for the fields.

    That is independent of the Multi-Step Checkout plugin. You’ll get the “Internal Server Error” also when the Multi-Step Checkout plugin is deactivated/uninstalled on the website.

    In your case, because “moving the fields” should have an effect only on the frontend, you could try moving them from one section to another with a JavaScript snippet called at page load. Internally the fields will still be assigned to the Billing section, though on the frontend they will show up in the Order section.

    Another solution would be to move the fields with the woocommerce_checkout_fields filter, as in your code, but then additionally to move them back from the Order to the Billing section before the field validation and the saving to the database is performed. That can be done with a similar function attached to the woocommerce_checkout_posted_data filter.

    For more information you could try asking for help in the support forum for the WooCommerce plugin. The issue is not related to the Multi-Step Checkout plugin, it has to do entirely with the internal functioning of the WooCommerce plugin.

    Best regards

Viewing 1 replies (of 1 total)
  • The topic ‘Shifting of billing fields to shipping tab’ is closed to new replies.