Public Ticket #3629442

Quote Button Validation

Closed
Comments
4 Tickets 5
Eduardo Andres started the conversation 2 years ago on April 17, 2024 at 12:23am

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:

2,762
KingsPlugins replied 2 years ago on April 20, 2024 at 9:40am

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://b2bkingplugin.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

1

Sign In