Hi,
i'm trying to change the price of a product in the cart with the help of a system plugin that i have created.
I've managed to change the the total and the the total discount of the cart but not the product's discount and price.
i set for example $cart->pricesUnformatted[$key]['discountAmount']=2;
where $key is the product id.
At the end of the function i add $calculator->setCartPrices($cart->pricesUnformatted);
The issue is that the total cart prices change, but the product's no.
Any suggestions?
why a system plugin & not a customfield plugin?
not sure ;)
I 've created a system plugin with a function function plgVmOnCheckoutAdvertise
maybe you need to
$cart->product
or something similar, if you are changing the total
- probably spam -ample in a shipping plugin you do
foreach ($cart->products as $product) {
modify here
}
On this foreach loop i change the discountAmount of the product. If i var_dump the cart i see the changed discount but it is not added on cart
what happens when you refresh the page?
explain what your system plugin does?
It checks if a user belongs to a specific user group and if yes it applies a discount.
The issue is that i want to exclude some products from this discount.
The discount is applied on cart without any issue. But the discount on product doesn't.
QuoteIt checks if a user belongs to a specific user group and if yes it applies a discount.
The issue is that i want to exclude some products from this discount.
surely a standard discount (tax & calc rule) applied to a shoppergroup and certain categories will do this?
The extra thing is that the plugin checks the total and then it applies the discount. This is something that the standard virtuemart rules cannot do.
negative tax per bill? haven't tried...
nope.
The question still remains. Why VM Cart doesn't accept the discount i apply, as soon as the discount in cart is acceptable?
in my quantity discount plugin
I change the price of a product like this
if ($product->quantity >=$qdisc[0] && $product->quantity<=$qdisc[1])
{$product->allPrices[$product->selectedPrice]["product_price"]=$product->allPrices[$product->selectedPrice]["product_price"]-$customfield->pdisc;}
But, it is in a product custom plugin,
in function plgVmPrepareCartProduct
can you modify anything about the product ? change the sku? , name etc?
How are you trying to modify it?
Well i have this code $cart->pricesUnformatted[$key]['discountAmount']=2;
for example to add the discount to the current product where $key is the product key.
I can see the new discount amount if i dump the $cart but it's not applied on cart.
I cannot change anything on cart. Everything i change this way, i see it in the dump but is not applied.
I dont know what to tell you, I know this can be done with a product plugin