user14906105
user14906105

Reputation:

Move product section to top when on mobile on WooCommerce checkout

I'm trying to move the product section to the top when on mobile on WooCommerce Checkout. I do not want the the billing section to be on top.

I tried with the following, without success:

add_action('wp_footer', 'mobile_checkout');
function mobile_checkout() {
    if ( wp_is_mobile() && is_checkout() ) {
        remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
        add_action( 'woocommerce_before_checkout_billing_form', 'woocommerce_order_review', 1 );
    }
}

Any ideas on how to move it?

Upvotes: 3

Views: 310

Answers (1)

7uc1f3r
7uc1f3r

Reputation: 29650

This should suffice:

function action_woocommerce_before_checkout_billing_form() {
    // Test if the current browser runs on a mobile device (smart phone, tablet, etc.)
    if ( wp_is_mobile() ) {
        remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
        add_action( 'woocommerce_before_checkout_billing_form', 'woocommerce_order_review', 5 );
    }
}
add_action( 'woocommerce_before_checkout_billing_form', 'action_woocommerce_before_checkout_billing_form', 1 );

Upvotes: 1

Related Questions