Buy X get Y - need to refresh the cart ?


  • Default avatar
    gingerweb    
     11 months ago
    0

    I have setup a buy 2 saddlebags get a third one free from this category:

    http://www.huntingvintage.co.uk/component/virtuemart/saddle-bags

    the free one is the "starter" saddlebag but any combination of the 4 will give you a free 3rd one if you input code BUY2GET3.


    the problem is the free item doesnt automatically go into the cart after saving the coupon code - you have to refresh the cart to make it appear, this isnt going to work with 90% of customers. is there any way to make it auto add to the cart please?

  • Your avatar
    seyi    
     11 months ago
    0

    Hello,

    In my testing, if you add 2 products in the category and go to the cart, then the 3rd shows up automatically.

    The only time I get the problem is when there is only one product in the cart and I update the quantity and save.  In this case, a page refresh is needed.  Your updating of cart is done through ajax, and it just updates the quantity as per what you entered, it does not (and cannot) look at any other functions that might be run on updating of cart.  So the only way to get this to work on update is to disable updating cart via ajax, if you have such an option in your opc.
  • Default avatar
    gingerweb    
     11 months ago  last edited 11 months ago
    0

    ok thanks it isnt working like it did earlier now! now if i add a second saddle bag it automatically adds the free one and not the one i have selected, tried this on Ipad, phone and laptop and its the same, behaving very strangely ! im now using the coupon code either, is there supposed to be a need for this ?

    I have checked settings and cant see anything wrong, is there any chance you could take a look please?


    for instance add a "little fox saddle bag" to the cart and then when you try and open another item in this category like the "otter saddle bag" it takes you to the cart where it has added 2 of the "free" items which is the "starter saddle bag" ?

    i have tried this on several devices all with the same result.

    baffled!

  • Your avatar
    seyi    
     11 months ago  last edited 11 months ago
    0

    Hello,

    Is it possible for you to send a private message with temp admin access so I can look at the settings?

    Thanks for the access.  Was able to reproduce the problem locally, looks like the Virtuemart shopping cart has changed causing this issue.  So here is the fix:
    in the file www/administrator/components/com_awoocupon/helpers/estore/virtuemart/couponhandler.php, around line 1018 is this
    <?php
            
    foreach ($cart_products as $cartpricekey=>$product){
    ?>

    Right before that, add this:
    <?php
            
    unset($cart_products['virtual']);
    ?>


    That should fix that strange behavior
  • Default avatar
    gingerweb    
     11 months ago  last edited 11 months ago
    0

    Yes that works perfectly now thank you.

    There is a possible anomaly though - 


    if you put the two qualifying items in the shopping cart so that the third "free" one is automatically added but then you "delete from cart" one of the qualifying items it leaves the "free" item in the cart still discounted. Now granted the shopkeeper will spot this and not send the item but if this could be corrected it would then be perfect!


    thanks for your help

  • Your avatar
    seyi    
     11 months ago
    0

    Hello,

    If I remember correctly your delete works on ajax, which is why it still shows the item as discounted.  If you refreshed the page, you would see the real total, and this is what would be sent to the confirm screen.
  • Default avatar
    gingerweb    
     11 months ago
    0

    ok yes that seems to be the case, after a refresh, not a major issue anyway. thanks for help.