VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: noras on June 21, 2016, 15:52:42 PM

Title: Need plugin event calculation
Post by: noras on June 21, 2016, 15:52:42 PM
Hello,

I have a problem. I need help. He wants to create a plugin that will initiate in your shopping cart corresponding discounts. Calculations have several assumptions, depending on the specific product quantity.
I found the course https://dev.virtuemart.net/projects/virtuemart/wiki/Calculation_Plugins

He needs a clue how I can change the price of the basket. I was able to change the price by:

$pricesUnformatted[0]['salesPriceWithDiscount'] = 8;
        $pricesUnformatted[0]['discountAmount'] = 2;
        $pricesUnformatted[0]['salesPriceTemp'] = 8;
        $pricesUnformatted['billDiscountAmount'] = 2;
        $pricesUnformatted['billTotal'] = $pricesUnformatted['billTotal'] - $pricesUnformatted['billDiscountAmount'];

        $cart->pricesUnformatted = $pricesUnformatted;
        $cart->setCartIntoSession(false,true);
        $cart->saveCartFieldsInCart();


This changes the price in view of the cart. Sadly after confirmation of the order, the old prices are visible in the mail and on the list of orders.

You can specify some way?
Title: Re: Need plugin event calculation
Post by: Studio 42 on June 24, 2016, 11:58:55 AM
Can you not use awocoupon ?
Title: Re: Need plugin event calculation
Post by: noras on June 24, 2016, 12:21:49 PM
It is not possible.
Individualspecific implementation of the discounts.
I came up with even the idea to use a pluginvm shopper. I think to use the plgVmOnUserOrder () I have yet to see it. But I think it will be.

Can you hint there anything better?