Okay
  Public Ticket #3629442
Quote Button Validation
Closed

Comments

  •  5
    Eduardo Andres started the conversation

    Is posible to validate the Request a Quote button if there is Dinamics Rules in the cart see image atached as example , I dont want customers to Request a Quote if Dinamic Rules are valid for thar minimun amount for the requested products.

    Attached files:  QuoteButtonValidation.png

  •  2,214
    WebWizards replied

    Hello Eduardo,

    There's no default feature for that, but I tried writing a code snippet for it. 


    I believe you can add this PHP code snippet to your site:

    add_action('wp_head', function(){
        ?>
        <script>
            jQuery(document).ready(function(){
                jQuery('#b2bking_request_custom_quote_button').click(function(e) {
                    // Check if any element with class 'woocommerce-error' exists
                    if (jQuery('.woocommerce-error').length > 0) {
                        e.preventDefault();
                        e.stopPropagation();
                        alert('Please resolve cart errors before requesting a quote.');
                    }
                });
            });
        </script>
        <?php
    });

    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/


    Clicking the button should then show an error as follows:

    2275977496.png

    The code may need some small adjustments depending on your theme though. Let me know if that code works as needed for you,


    Kind regards,

    Stefan

  •  5
    Eduardo Andres replied

    Yes it works just fine, thanks.