• Default avatar
    yaniv2    
     a year ago  last edited a year ago
    0

    Hi,
    How can i trigger Awcoupon on edit order in virtuemart?
    I want to edit items in the order, like change the quantity or delete 1 item, but i can't get the calculation to take in consideration the coupon in the admin area.
    Thanks
    yaniv
  • Your avatar
    seyi    
     a year ago
    0

    Hello,

    Do not think there is a way to do it with Virtuemart on its own, not without making core modifications.  Invoice software, such as artio invoice can handle backend editing, recalculating.
  • Default avatar
    yaniv2    
     a year ago
    0

    I can manage Virtuemart to do that, i have developed a plugin that expend the ability of edit order by the admin, but i can't manage to trigger Awocoupon to recalculating the coupon in use for the new quantity or maybe if one of the product was deleted, so the recalculation will know to

    subtract the discount from the total and remove it from the history of used coupon

  • Your avatar
    seyi    
     a year ago
    0

    Hello,

    Ok, not sure how you are modifying orders in your code, but the only way to do it is through a cart, as that is how Awocoupon calculates discounts.  So in the backend code, you would have to create a cart for the specific order, example:
    <?php
    $data 
    = new stdclass;
    $data->virtuemart_paymentmethod_id x;
    $data->virtuemart_shipmentmethod_id y;
    ....
    $cart VirtuemartCart::getCarttrue, [], $data );
    $cart->setCouponCode'coupon' );
    $prices $cart->getCartPricestrue );
    ?>

    Then with $prices, you can update the coupon discount
    <?php
    $order
    ->coupon_discount $prices['salesPriceCoupon'];
    ?>