buy x get y: total price wrong (only first display)


  • Default avatar
    andrea2    
     11 years ago
    0

    Hi,
    with "AWO Coupon PRO" I would give the product Y to customers who register. I created the coupon "buy x get y" (I have not found another way, but if there is .. I ask for help). It works fine, but when I insert the "Coupon Code":
    1. AWO adds the product Y;
    2. changes the total products price with the sum of X and Y;
    3. after the total products price AWO enter the discount (Y value);
    4. the total sales price, however, becomes X - discount (Y) as it should be x + y - y.
    Refreshing the page or paying everything falls into place! It seems, therefore, only a display issue which, however, creates a problem for customers.

    I'm trying with Joomla 2.5.13 and Virtuemart 2.0.22a

    It also appears to you?


    Coupon is configured as follows:

    Function Type: Coupon
    Function Type2: Buy X Get Y
    Coupon Code: RegaloNuoviClienti
    Published: Published
    Percent or Amount: Percent
    Discount Type: Overall
    Value: 100
    Process Type: First found match
    Number of Uses: per Customer 1
    Minimum Value: 20
    Maximum Discount Qty: 1
    Expiration: blank
    Automatically add to cart 'Get Y' product: ā€œvā€

    Customer Type: shopper group ( -default- )

    For Buy X input
    Number: 1
    Type: category
    Product list: all category

    For Get Y input
    Number: 1
    Type: product
    Product list: product Y

    Regards,
    Andrea
  • Your avatar
    seyi    
     11 years ago
    0

    Hello,

    I was able to reproduce the problem. Have to make a virtuemart hack to get this to work the first time:
    in www/administrator/components/com_virtuemart/helpers/calculationh.php, around line 798 is this code
    <?php
            $toTax 
    $this->_cartPrices['salesPrice'] + $cartdiscountBeforeTax;

            
    //Avalara wants to calculate the tax of the shipment. Only disadvantage to set shipping here is that the discounts per bill respectivly the tax per bill
            // is not considered.
            
    $shipment_id = empty($cart->virtuemart_shipmentmethod_id) ? $cart->virtuemart_shipmentmethod_id;
            
    $this->calculateShipmentPrice($cart,  $shipment_id$checkAutomaticSelected);

            
    // next step is handling a coupon, if given
            
    $this->_cartData['vmVat'] = TRUE;
            
    $this->_cartPrices['salesPriceCoupon'] = 0.0;
            if (!empty(
    $cart->couponCode)) {
                
    $this->couponHandler($cart->couponCode);
            }
    ?>


    Take the first line and add it right after the coupon handling like this:
    <?php
            $toTax 
    $this->_cartPrices['salesPrice'] + $cartdiscountBeforeTax;

            
    //Avalara wants to calculate the tax of the shipment. Only disadvantage to set shipping here is that the discounts per bill respectivly the tax per bill
            // is not considered.
            
    $shipment_id = empty($cart->virtuemart_shipmentmethod_id) ? $cart->virtuemart_shipmentmethod_id;
            
    $this->calculateShipmentPrice($cart,  $shipment_id$checkAutomaticSelected);

            
    // next step is handling a coupon, if given
            
    $this->_cartData['vmVat'] = TRUE;
            
    $this->_cartPrices['salesPriceCoupon'] = 0.0;
            if (!empty(
    $cart->couponCode)) {
                
    $this->couponHandler($cart->couponCode);
            }
            
    $toTax $this->_cartPrices['salesPrice'] + $cartdiscountBeforeTax;
    ?>


    That should fix it.
  • Default avatar
    andrea2    
     11 years ago
    0

    It works!
    Thank you very much Seyi, you were fast!
  • Default avatar
    doekenorg    
     11 years ago
    0

    Wauw. I'm happy i'm not the only one who encountered this problem.
    Thanks for the quick fix!

    However, is it possible to fix this issue without the need to change the Virtuemart core?

    I'd really like my customers to be able to update Virtuemart without any problems. I duplicated modules to change behaviour, and am even using a system-plugin to overwrite controllers so I wont get in to trouble when updating. This core-patch unfortunately puts a dent in that approach.

    I realize the $toTax line is just in the wrong place. But can we not update the couponHandler so it updates the right price?