How to display automatic discount in ajax cart popup?


  • Default avatar
    stephanbais    
     11 years ago
    0

    I have successfully been able to configure the automatic discount when purchasing a certain amount of products. My problem is that this discount is not visible in the ajax cart popup after adding the last required product. Only after a page refresh the cart incorporates the coupon discount in the prices.

    The automatic coupon code does load without the page refresh ($cart->couponCode) The actual discount ($cart->salesPriceCoupon) does only get loaded on a page refresh however. I assume this is more a VM issue than a AwoCoupon, however you might be able to get me in the right direction.

    Best regards,

    Stephan

    VM 2.0.18a
    AWOCOUPON PRO 2.1.4
    Joomla 2.5.8
  • Your avatar
    seyi    
     11 years ago
    0

    Looks like it stopped working in Virtuemart 2.0.16.

    Virtuemart implemented cache in order not to keep recalculating the order totals over and over, but it does not take into account coupon codes. You can effectively disable it if there is a coupon code in the shopping cart

    in www/administrator/components/com_virtuemart/helpers/calculationHelper.php in at the top of function getCheckoutPrices is this
    <?php
            
    if(isset($this->_cartPrices) and is_array($this->_cartPrices) and count($this->_cartPrices)>and isset($this->_cartData['totalProduct']) and $this->_cartData['totalProduct']==count($cart->products)){
                return 
    $this->_cartPrices;
            }
    ?>


    changing it to the below, disables it when there is a coupon code in the cart
    <?php
            
    //if(isset($this->_cartPrices) and is_array($this->_cartPrices) and count($this->_cartPrices)>0 and isset($this->_cartData['totalProduct']) and $this->_cartData['totalProduct']==count($cart->products)){
            
    if(empty($cart->couponCode) && (isset($this->_cartPrices) and is_array($this->_cartPrices) and count($this->_cartPrices)>and isset($this->_cartData['totalProduct']) and $this->_cartData['totalProduct']==count($cart->products))){
                return 
    $this->_cartPrices;
            }
    ?>
  • Default avatar
    stephanbais    
     11 years ago
    0

    Hi Seyi,

    Many thanks! This did the trick.

    Best regards,

    Stephan