skip to Main Content

How can I modify the Flatsome theme and WooCommerce settings to achieve the following:

  • Remove the default alert that appears when a customer fails to choose a product variant.
  • Integrate a quick view option into the shopping process, allowing customers to easily select product variants from a pop-up modal if they initially forget to do so?

This would improve the user experience by providing a more seamless and convenient way for customers to choose product options without disrupting their shopping flow.

enter image description here

What I to add the functions.php, but did not work:


function flatsome_child_custom_js() {
    $custom_js = "
        jQuery(document).ready(function($) {
            $('body').on('click', '.single_add_to_cart_button', function(e) {
                let $variationForm = $(this).closest('.variations_form');
                
                if ($variationForm.length > 0 && !$variationForm.find('input[name="variation_id"]').val()) {
                    e.preventDefault();
                    e.stopPropagation();
                    
                    // Remove or comment the next line to disable the default message
                    
                }
            });
        });
    ";
    
    wp_add_inline_script('flatsome-js', $custom_js);
}

add_action('wp_enqueue_scripts', 'flatsome_child_custom_js', 20);

Please signup or login to give your own answer.
Back To Top
Search