Public Ticket #2961435

showing pricing

Closed
Comments
14 Tickets 7
CANDY started the conversation 5 years ago on January 19, 2022 at 2:06pm

we want to show our top pricing to guests but not allow guests to check out.. I read on the hiding pricing info page that hiding pricing also disallows checkout for guests.  we want our pricing to show but not allow guest checkout,.

2,762
KingsPlugins replied 5 years ago on January 19, 2022 at 9:23pm

Hi there,

Our plugin doesn't have a direct feature for this.

However, I've written a code snippet to help in this situation;

if (!is_user_logged_in()){
    global $b2bking_public;
    // If go to checkout page, redirect to cart
    add_action( 'template_redirect', array($b2bking_public, 'b2bking_checkout_redirect_to_cart'), 100 );
    // Hide proceed to checkout button
    remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 ); 
    // Hide cart totals entirely
    remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cart_totals', 10 );
    // show message
    add_action( 'woocommerce_before_cart', function(){
        wc_print_notice( esc_html__('You need to be logged in, in order to be able to place orders.', 'b2bking'), 'error' );
    }, 10);
}

A PHP snippet can be added to functions.php, or by following our guide here: https://b2bkingplugin.com/docs/how-to-add-a-snippet-php-or-js/

It will look like this in Cart, for guests:

3561498448.png

Kind regards,

Stefan

Sign In