• Resolved carver1g

    (@carver1g)


    I am using the woocommerce 2.6 plugin and have a popup that opens when a customer clicks on the ‘add to cart button’ which is just a simple popup that states ‘Adding to cart – Please wait’. This keeps my impatient customers from clicking on the add to cart button repeatedly because they feel nothing is happening. I have designed the popup so the only way it closes is by redirection to the cart page upon successfully adding a product.

    This works great for my regular and variable products but need some advise for my personalized products. I hand carve names supplied by the customer into many of my wood products. For example, I sell a small cedar box which has a name field the customer fills out. This field is required and validated to be sure the customer has not left the name field empty. This validation triggers upon clicking the add to cart button. If the validation returns ‘false’ the add to cart button is then disabled until the customer corrects the problem.

    Since the popup triggers upon clicking the add to cart button, should there be a validation error, the customer is unable to correct the error and nothing is added to the cart.

    I am not using a custom selector but have this code in my functions.php:

    function custom_footer_popup_scripts() {
    ?>
    <script>
    (function ($, document, undefined) {

    $(‘#content .single_add_to_cart_button’).on(‘click’, function () {
    $(‘#popmake-1309’).popmake(‘open’);
    });
    }(jQuery, document));
    </script>
    <?php
    }
    add_action( ‘wp_footer’, ‘custom_footer_popup_scripts’ );

    I figured by using this code and not a custom selector I could maybe modify the code in some way that the popup would not trigger until the validations return ‘true’ and then the add to cart button is clicked.

    I operated ‘dinosaur’ computers while serving in the USAF during the Nam war but this new stuff has me baffled!?

    Any help will be greatly appreciated.

    https://www.ads-software.com/plugins/popup-maker/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Daniel Iser

    (@danieliser)

    @carver1g – So your on the right track, alternatively you could also go the route of closing the popup should add to cart validation fail.

    In any case I am by no means proficient with WooCommerce JS, but I would guess there are JS events for those things. In which case you simply do something like

    jQuery(document)
      .on('addToCart', function () {
        jQuery('#pum-123').popmake('open');
      })
      .on('addToCartError', function () {
        jQuery('#pum-123').popmake('close');
      });

    As for the exact events, that may take some research but seems to be the cleanest solution likely available.

    Hope that helps.

    Thread Starter carver1g

    (@carver1g)

    @danieliser
    Thanks, I’ll give it a try. Didin’t think of closing the popup on error, but it sure makes sense. With the little knowledge I have of woocommerce js I may have to tweak a bit. Will let you know what happens.

    Thanks, again

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Help with woocommerce add to cart popup’ is closed to new replies.