wc-plugin-framework icon indicating copy to clipboard operation
wc-plugin-framework copied to clipboard

Apple Pay integration bypasses WooCommerce "Enable guest checkout" setting

Open sidedwards opened this issue 6 years ago • 1 comments

I have guest checkout disabled in my WooCommerce settings.

Screen Shot 2019-11-21 at 6 21 05 PM

However, when I create orders through Apple Pay, it allows guest checkout.

Screen Shot 2019-11-21 at 6 33 08 PM

I noticed the WooCommerce Stripe gateway had the same issue a while back. https://github.com/woocommerce/woocommerce-gateway-stripe/issues/148

Is there any workaround to this?

sidedwards avatar Nov 22 '19 01:11 sidedwards

@sidedwards thanks for the report! We'll look at ways that can be improved for a future update.

In the meantime, you could use the sv_wc_apple_pay_is_available filter for determining Apple Pay availability that could be used to disable it in certain circumstances, like for guest users or users with certain permissions.

For instance, a snippet like this would do the trick:

function sv_wc_conditional_apple_pay( $is_available ) {

	if ( $is_available && ! get_current_user_id() && 'yes' !== get_option( 'woocommerce_enable_guest_checkout' ) ) {
		$is_available = false;
	}

	return $is_available;
}
add_filter( 'sv_wc_apple_pay_is_available', 'sv_wc_conditional_apple_pay' );

ChaseWiseman avatar Nov 26 '19 18:11 ChaseWiseman