AWOCoupon an incorrect calculation of the Sum of discounts for not integer type in quantity of goods in order.


  • Default avatar
    lslisa    
     8 years ago
    0

    Thank you so much for best Product for Joomla!

    I am a use:

    Joomla! 2.5.28
    VirtueMart 2.6.6
    AWO 2.3.3

    and i am encountered such a problem. In view of the requirements for implementation of the "quantity" ordered goods must be between 0 and 1. When calculating the discount is taken into account only integer number in the "quantity" of the order.

    for example:
    "Price" = 48.00 "Quantity" = 0.50 "Sum" = 24 "discount (1%)" = 0.24

    but I get a
    "discount (1%)" = 0.48 at the rate that the "Quantity" of the goods in order = 1

    When calculating the amount of the discount value of the "Quantity" is rounded to the nearest whole number(int function is applied as i am understand).

    Could you suggest how to correct the calculation of the amount of discounts. Thank you
    P.S. sorry for my English.
  • Your avatar
    seyi    
     8 years ago
    0

    Hello,

    AwoCoupon requires the quantity to be an integer, decimal would not work.

    Maybe what could work would be to alter the quantity and the price at the same time. So using your example we find the multiplication factor as 1/0.5 = 2

    Quantity = 0.5 * 2 = 1
    Price = 48/2 = 24

    Thn the discount should calculate correctly.

    For that you would need to modify the file
    www/administrator/components/com_awocoupon/helpers/estore/virtuemart/couponhandler.php, function defineCartItems

    This is where the cart items for AwoCoupon are defined.

    So right before:
    <?php
                $this
    ->cart->items_def[$productId]['product'] = $productId;
                
    $this->cart->items [] = array(
    ?>


    Add something like this:
    <?php
                $factor 
    1;
                if(
    $product->quantity 1$factor $product->quantity;
                
    $product->quantity *= * $factor;
                
    $product_price /= $factor;
                
    $product_price_notax /= $factor;
                
    $product_discount /= $factor;
    ?>


    I think that should do it.
  • Default avatar
    lslisa    
     8 years ago
    0

    Thank you fo help.

    But when i am add this is code, my cart row has been changed. Data has been changed. Field "Quantity" was = 0.5 became a = 1 and field Price was ="24" became a =48.

  • Your avatar
    seyi    
     8 years ago
    0

    Hello,

    It should not affect the price in the cart. This is just an example code so you may need to make some adjustments to it. Instead of altering $product->quantity, put it into a new variable, something like $qty = $product->quantity / $factor; and then add the to the array, 'qty'=>$qty, instead of 'qty'=>$product->quantity.
  • Default avatar
    lslisa    
     8 years ago
    0

    Seyi, thanks so much to your tips. Now i could do what I wanted. Thanks again for help and a great component and good luck in your work.