Okay
  Public Ticket #3626404
Only Show Request a Quote for Specific Categories and Roles
Closed

Comments

  •  2
    Greg Hill started the conversation

    Hello,

    We have Request a Quote enabled for all users with Hide Prices in quote-only mode option. We have the following dynamic rule:

    Type: Quotes on Specific Products

    Applies to: Widgets [product category example]

    For Who: All registered B2C users, All guest users (logged out), Technician

    Our issue is that the request a quote button and form appear in the cart for all products, not just the ones defined in the dynamic rule.

    How would we set request a quote for roles only on specific product categories?

    Note: I assume that "Enabled for ALL" is part of the issue in the ""Request a Custom Quote" settings. However, if we set it to:

    Disabled = The request a quote button does not appear in the cart for anyone.
    Enaabled for B2B = We have 2 B2B roles and only 1 should see pricing, the other should have their Dealer pricing.
    Enabled for Guests + B2C = We have a B2B role that should see request a quote and another that should have wholesale pricing.

    Do you have any suggestions on how we should we configure this?

    Many thanks!





  •  1,881
    WebWizards replied

    Hi Greg,

    Normally our plugin indeed adds that button to the cart irrespective of the kind of products in cart. The idea is that it's 'optional' for all orders, whereas what the "quotes on products" rules do is to make it 'mandatory' for those products. 

    I believe that you can modify this behaviour to achieve what you're looking for by adding the following PHP code snippet to your site:

    add_action('wp', function(){
        // check if there are quote products in cart
        if (b2bking()->user_has_p_in_cart('quote') !== 'yes'){
            global $b2bking_public;
            remove_action( 'woocommerce_cart_actions', array($b2bking_public, 'b2bking_add_request_quote_button') );
            remove_action( 'woocommerce_blocks_enqueue_cart_block_scripts_after', array($b2bking_public, 'b2bking_add_request_quote_button') , 100000);
        }
    });
    

    This should remove that button if the cart does not contain quote products.


    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/


    Let me know if that can solve it for you,


    Kind regards,

    Stefan