Woocommerce checkout fields keep changing
P粉394812277
P粉394812277 2023-08-31 23:23:19
0
1
507
<p>I use this code to change my checkout field layout, using the Woocommerce Checkout shortcode I put in the product page [woocommerce_checkout], it looks fine, but not in the checkout page, 1 sec It will then return to its original state. I tried changing the theme and disabling all plugins except Woocommerce, still happens. how to solve this problem? </p> <pre class="brush:php;toolbar:false;">/**Remove all possible fields **/ function wc_checkout_fields( $fields ) { echo '<style> .woocommerce-additional-fields { display: none; } .woocommerce-checkout #customer_details>* { margin-bottom: 1rem !important; } </style>'; $fields['billing']['billing_first_name']['priority'] = 10; $fields['billing']['billing_first_name']['label'] = 'Name'; $fields['billing']['billing_first_name']['class'] = array( 'form-row-wide' ); $fields['billing']['billing_address_1']['priority'] = 20; $fields['billing']['billing_address_1']['label'] = 'Address'; $fields['billing']['billing_country']['priority'] = 30; $fields['billing']['billing_country']['label'] = 'Country'; $fields['billing']['billing_country']['class'] = array( 'form-row-first' ); $fields['billing']['billing_state']['priority'] = 40; $fields['billing']['billing_state']['label'] = 'State'; $fields['billing']['billing_state']['class'] = array( 'form-row-last' ); $fields['billing']['billing_city']['priority'] = 50; $fields['billing']['billing_city']['label'] = 'City'; $fields['billing']['billing_city']['class'] = array( 'form-row-first' ); $fields['billing']['billing_postcode']['priority'] = 60; $fields['billing']['billing_postcode']['label'] = 'Postcode'; $fields['billing']['billing_postcode']['class'] = array( 'form-row-last' ); $fields['billing']['billing_phone']['priority'] = 70; $fields['billing']['billing_phone']['label'] = 'Phone'; $fields['billing']['billing_phone']['class'] = array( 'form-row-first' ); $fields['billing']['billing_email']['priority'] = 80; $fields['billing']['billing_email']['label'] = 'Email'; $fields['billing']['billing_email']['class'] = array( 'form-row-last' ); unset( $fields['billing']['billing_last_name'] ); unset( $fields['billing']['billing_address_2'] ); unset( $fields['billing']['billing_company'] ); unset( $fields['order']['order_comments'] ); return $fields; } add_filter( 'woocommerce_checkout_fields', 'wc_checkout_fields' );</pre> <p> With shortcode and first view at checkout</p> <p> Checkout page changes after 1 second</p> <p> After disabling JavaScript on your browser</p>
P粉394812277
P粉394812277

reply all(1)
P粉617597173

I tried using this to remove the wc-checkout script and the layout became what I wanted

add_action( 'wp_enqueue_scripts', 'remove_woocommerce_checkout_scripts', 9999 );
function remove_woocommerce_checkout_scripts() {
    wp_dequeue_script( 'wc-checkout' );
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template