samedi 28 octobre 2017

how to insert if statement in Wordpress Functions.php file

I am using woocommerce and I am editing the wordpress functions.php file.

My store has two checkout pages, one before admins review orders (CHECKOUT) and the other after admins approve orders (final-checkout).

I'd like to remove the billing info from the first checkout page, and only display it in the second (final) checkout page.

In the functions.php page, I used the following if statement, but its not working. I think the if statement is being tested against the functions.php page, rather than the checkout page.

if ( is_page( 'checkout' )){

        add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );

            function custom_override_checkout_fields( $fields ) {
                unset($fields['billing']['billing_first_name']);
                unset($fields['billing']['billing_last_name']);
                unset($fields['billing']['billing_company']);
                unset($fields['billing']['billing_address_1']);

                return $fields;
            }

 }

If someone can help me only show the billing info on the second checkout page and not the first, it would be very much appreciated

THANKS

Aucun commentaire:

Enregistrer un commentaire