Handling WooCommerce Shipping and Local Pickup Confusion

A new Business Bloomer Club member recently sought help with a common WooCommerce issue: clarifying the checkout process when local pickup is selected. Their prospective client faced confusion among customers who believed they were selecting a shipping option when they actually chose local pickup. To address this, the member aimed to:

  1. Disable the checkout button unless customers either select “local pickup” or enter a postcode in the shipping calculator.
  2. Update the checkout page header to reflect “Billing Address” only if local pickup is selected.
  3. Remove the “Shipping to” text on the order summary when local pickup is chosen.

Let’s explore possible solutions to address each of these challenges, helping streamline the checkout process and avoid customer confusion.

Solution 1: Disable Checkout Button Until Shipping Method is Selected

The provided snippet checks if a shipping method is selected and disables the checkout button if it is not. However, it seems to only apply on the initial cart page load, not after any shipping updates. A conditional approach is needed, possibly using JavaScript to monitor the shipping method selection dynamically.

Snippet Example

function disable_checkout_button_no_shipping() {
    $package_counts = array();
    $packages = WC()->shipping->get_packages();
    foreach( $packages as $key => $pkg ) {
        $package_counts[ $key ] = count( $pkg[ 'rates' ] );
    }
    if( in_array( 0, $package_counts ) ) {
        remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
    }
}
add_action( 'woocommerce_proceed_to_checkout', 'disable_checkout_button_no_shipping', 1 );

For added functionality, integrating JavaScript to dynamically disable the checkout button on the cart page could improve user experience.

Solution 2: Update Checkout Header to “Billing Address” for Local Pickup

To make this change conditional based on the selected shipping method, use WooCommerce hooks to modify the checkout page title. For example:

add_filter( 'woocommerce_checkout_fields', 'bbloomer_modify_checkout_title' );
function bbloomer_modify_checkout_title( $fields ) {
    if ( WC()->session->get('chosen_shipping_methods')[0] === 'local_pickup' ) {
        add_filter( 'gettext', 'bbloomer_change_checkout_text', 20, 3 );
    }
    return $fields;
}

function bbloomer_change_checkout_text( $translated_text, $text, $domain ) {
    if ( $text === 'Billing and Shipping Address' ) {
        $translated_text = 'Billing Address';
    }
    return $translated_text;
}

This modification updates the title only when local pickup is chosen, providing a clearer message to customers.

Solution 3: Remove “Shipping to” Text on Order Summary for Local Pickup

To hide the “Shipping to” text in the order summary if local pickup is chosen, you can conditionally filter the content on the order summary page. This method checks the selected shipping method, and if it’s set to local pickup, it removes the shipping text.

add_filter( 'woocommerce_order_item_meta_start', 'bbloomer_remove_shipping_text', 10, 3 );
function bbloomer_remove_shipping_text( $item_id, $item, $order ) {
    if ( $order->get_shipping_method() === 'Local Pickup' ) {
        remove_action( 'woocommerce_order_item_meta_start', 'woocommerce_display_item_meta', 10 );
    }
}

With these adjustments, you can clarify the WooCommerce checkout and order summary processes, reducing the likelihood of customers misunderstanding the local pickup option. Testing these snippets and adjusting them as necessary should provide a smoother customer experience.

Related content

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

Reply

Your email address will not be published. Required fields are marked *