1

When I click the "Add to cart" button on a variable product, with no variation selected, the WooCommerce pops up an alert: "Please select some product options before adding this product to your cart.".

The problem is, it shows up as an Alert (browser window with Ok button). I would like to display it as a classic WooCommerce notice box within the page (or possibly to do some custom actions), but I am unable to find the responsible actions.

I tried to look for "single_add_to_cart_button". The theme is Shopkeeper, but I've looked for other themes and they seem to display it in the same manner - so I believe it is WooCommerce's default.

Any hints on how to achieve this?

0

if you remove the responsible JavaScript for this action Woocommerce by default add html box to the product page and to do so use the following code:

function dequeue_script()
{
wp_dequeue_script('wc-add-to-cart-variation');
}
add_action('wp_print_scripts', ' dequeue_script', 100);

you should put this code in your child theme functions.php

| improve this answer | |
  • Thank you but this doesn't seem to work. It adds some sort of Wamp debug table on top of my Woo product page (no errors, it just seems like the executed method/hooks flow) and clicking on the "Add to cart" button still pops up the alert window. – Kristián Filo Aug 6 '18 at 7:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.