WordPress.org

Support

Support » Plugins and Hacks » WooCommerce » Force document download before add to cart

Force document download before add to cart

Viewing 2 replies - 1 through 2 (of 2 total)
  • bheadrick

    @bheadrick

    this would require a bit of jquery to do, but it’s definitely doable.

    I’m not sure if you could really confirm that the file was fully downloaded, but you could check whether the link had been clicked. You would need to make your download link have a class of “download” for this to work.

    (function($) {
    
    var checkclick = false;
    $('a.download').click(function(){
    checkclick=true;
    return true;
    }
    $('form.cart button').click(function(event){
    if(!checkclick){
    event.preventDefault();
    $('form.cart button').before('<span id="message"><div class="error_message"><div class="error_alert">You must download the waiver before you can purchase "Transcript (Former Student)"<br></div></div></span>');}
    });
    })( jQuery );

    Thank you so much – and yes, you are right. I just need to prompt the customer to click on the download link. I will give this a try. Happy Thanksgiving!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Force document download before add to cart’ is closed to new replies.
Skip to toolbar