Repository Forums Support WooCommerce Extended Coupon Features PRO FREE products at PRO version: not updating

Topic Resolution: Resolved
Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #1474
    Juliane Dreyer
    Participant

    Hi there,

    I have some problems with the free products at the pro version:

    I have 3 free products for choice.
    I choose one of the three, and the chosen one is added to cart.
    I return to shop, then go back to the cart and change the free selected product.

    PROBLEM:
    –> The previously selected free product stays in the cart, and there is no chance of refreshing the cart amount
    –> Also, I cannot delete the free product from the cart so I could change to the new free product
    –> If I then click “Checkout”, the previously selected free product is still selected

    So the problem is, once the free product is chosen, I cannot change it. It works if I do something that makes the cart refreshing, but the cart does not refresh automatically if the free product changes… which is quiet annyoing for the customer. Is there any way this can be fixed? Or is something wrong with my implementation or my shop?

    Thanks for your help!

    #1476
    Soft79
    Keymaster

    That’s the way WooCommerce works; changes to the cart are only updated after pressing ‘Refresh cart’.

    You could use this jQuery snippet, though:

    
    jQuery( document ).on(
      'change input',
      '.wjecf-select-free-products :input',
      function() { 
        jQuery('form.woocommerce-cart-form input[name="update_cart"]').click();
    } );
    

    Might need some tweaking.

    #1478
    Juliane Dreyer
    Participant

    Hi Jos,

    I know that the cart needs to be refreshed, that’s why I wonder why the plugin does not do this. Because the chosen free product is not applied at the moment. If I am in the cart and chose one of three products, and then click “checkout”, the product is not applied. And if I am in the checkout and chose one of the three products, the product is also not applied. Meaning, it is not working. No free product gets applied unless I somehow manage to refresh the cart, but the user does not know this and there is no message or button like “apply free product to cart”… so how is this feature supposed to work? Or do I miss something?

    Thanks again for your help!

    #1479
    Soft79
    Keymaster

    The chose product is applied when ‘Update cart’ is clicked. Just like any other change in the cart.

    My plugin does not submit the change by itself, because I don’t want to change the WooCommerce UX too much and it might conflict with certain themes. In the future I might add an option for this.

    If you paste javascript snippet in the footer, it will work.

    #1480
    Juliane Dreyer
    Participant

    Hi Jos,

    ok I will give the snippet a try. Just for further development: If it only works with updating cart, the button “Update cart” needs to be enabled. It is disabled now, so the user has no chance of updating it. Same for the checkout, there needs to be a button. By now this feature cannot be used as the user has no chance of applying it to the cart. I understand not changing the WooCommerce UX too much, but if you say the pro plugin has this feature and then it is not working… that is not so good. I don’t want to be rude, I think the rest of the plugin is pretty awesome, but it should work if the plugin feature list says so…

    Hope I can fix it with the snippet!
    Juliane

    #1481
    Soft79
    Keymaster

    Can you please send an url to your store and instructions to reproduce the issue?

    Because the ‘update cart’ button should be enabled whenever you click a free item. Also, when checking out the item should be applied when the user clicks the ‘checkout’ button.

    #1484
    Juliane Dreyer
    Participant

    Hi Jos,

    this is the url:

    http://www.kullaloo.de

    If you have 5 items from the category “Plüsch” in cart (http://www.kullaloo.de/produktkategorie/pluesch/), you can apply this coupon: freeEbookAb5Pluesch

    Note: I have not activated the AUTO coupon at the moment, as the coupon is not working properly…

    Before I wrote you the first time, I deactivated all plugins to check whether its something with other plugins that it doesn’t work. I only had WooCommerce and the PRO Plugin active and I also had the Twenty Fourteen activated, not my own theme. But I did not work, the button was still disabled and the product was not applied when checking out.

    So maybe you can find the error, would be great!

    Thank you, Juliane

    #1486
    Soft79
    Keymaster

    Are you using Internet Explorer by any chance?

    It’s working fine on Firefox, but when testing on Internet Explorer I see that the button stays disabled.
    Please open this file: wp-content/plugins/woocommerce-auto-added-coupons-pro/includes/pro/WJECF_Pro_Free_Products/js/wjecf-free-products.js

    and replace this line:

    me.update_totalizer = function( totalizer_id, updated_input = undefined ) {

    with:

    me.update_totalizer = function( totalizer_id, updated_input) {

    Then clear your browser cache and try again. Does that help? If so please let me know, and I implement the fix in the next release.

    #1489
    Soft79
    Keymaster

    Did this work for you? Or do you need assistance?

    #1490
    Juliane Dreyer
    Participant

    Hi Jos,

    I am not using IE, I am using Safari. I changed the line of of code like you suggested. This is what’s happening:

    The button “refresh cart” is enabled, I can click it and my selection is applied! Cool 🙂

    What’s not happening:
    If I do not click “update cart” and proceed to checkout, the product is not applied. Is this supposed to work or only by clicking “update cart”? Because you wrote before “Also, when checking out the item should be applied when the user clicks the ‘checkout’ button.”

    But in the checkout itself is no way of updating the cart? I mean if the user has not chosen the free product before… then is there a way to remove the free product selection from the checkout? Otherwise I will use CSS to simple not display it.

    Thanks for your help!

    #1491
    Soft79
    Keymaster

    I’m glad the fix worked, I’ll add the fix to the next version.

    • On the CART-page ‘Update cart’ must be clicked to append the free product (or use the snippet provided above).
    • On the CHECKOUT-page the ‘Select free gift’ will only be displayed if no free product was selected before.
    • On the CHECKOUT-page, pressing ‘PLACE ORDER’ will apply the free product.
    • If you don’t want to display free product selection on CHECKOUT, you can use CSS or template override. To override the template copy
      /wp-content/plugins/woocommerce-auto-added-coupons-pro/checkout/select-free-product.php
      to
      /wp-content/themes/YOUR_THEME/woocommerce-auto-added-coupons/checkout/select-free-product.php
      and delete or edit the contents.
    #1492
    Juliane Dreyer
    Participant

    Hi Jos,

    the ‘Select free gift’ is always shown on checkout page, no matter if I selected the free product before or not.

    I will try adding the jquery. Just one question: I am not very familiar with jquery… how do I put this in an external javascript file? (to load it with wp_enqueue_script)

    #1494
    Soft79
    Keymaster

    Hi Juliane,

    I just sent you v2.5.3-b1. This fixes the JS error, and also the fact that free product selection was ALWAYS visible on checkout page.

    About the jQuery:

    – create a new JS file in your child theme (preferably in an assets/js/ directory). Let’s name it my-custom.js
    – This contents:

    
    jQuery( document ).on(
      'change input',
      '.wjecf-select-free-products :input',
      function() { 
        jQuery('form.woocommerce-cart-form input[name="update_cart"]').click();
    } );
    

    – Enqueue the script with this snippet in functions.php:

    
    function enqueue_my_custom_script() {
      wp_enqueue_script( 'my-custom-js', get_template_directory_uri() . '/assets/js/my-custom.js', array( 'wjecf-free-products' ) );
    };
    add_action( 'wp_enqueue_scripts', 'my_custom_script' );
    
    #1497
    Juliane Dreyer
    Participant

    Hi Jos,

    oh cool, thanks for the update! I replaced the files and it works, I think it is much more usable und less confusing if the selection is hidden from the checkout. Thank you very much for this adjustment!

    I also integrated the jquery, and I think it works pretty well except the product is only applied every second click. I tested in Safari and Chrome, in both browsers only every second click forces the cart to update. Any ideas why this is happening?

    #1498
    Soft79
    Keymaster

    Hmm, maybe because the button is still disabled at the first click.

    Try this script instead:

    
    if ( undefined !== jQuery ) {
        jQuery( function( $ ) {
            $( document ).on(
              'change input',
              '.wjecf-select-free-products :input',
              function() { 
                $('form.woocommerce-cart-form input[name="update_cart"]').click();
            } );
        } );
    }
    

    Make sure you clear browsercache before trying.

Viewing 15 posts - 1 through 15 (of 17 total)
  • You must be logged in to reply to this topic.