Okay
  Public Ticket #2961435
showing pricing
Closed

Comments

  •  7
    CANDY started the conversation

    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,218
    WebWizards replied

    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://woocommerce-b2b-plugin.com/docs/how-to-add-a-snippet-php-or-js/


    It will look like this in Cart, for guests:

    3561498448.png


    Kind regards,

    Stefan

  •  7
    CANDY replied

    thank you very much...