Questions around the TYPO3 integration and plugins as well as Flow and NeosCMS
Forum rules: Always add your TYPO3/Flow, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#7900 by Moritz
12 Apr 2019, 14:00

I want to change the price of all products and its sum in the basket if my self created payment provider is selected as payment option.
I try to do that in the calcPrice() method.
On the confirmation page the price is correctly changed but after completion the old price is shown again in the order.
Is that the right place to change the prices or might be a basket plugin the better place?

Best regard,
#7909 by aimeos
14 Apr 2019, 09:47
In calcPrice() of service decorators can should only set the shipping costs or shipping rebates but not modify the price items of the basket because calcPrice() is called even if it isn't selected. In a basket plugin you can do what you want but make sure that you add a new line with the rebate in the basket because the total is constantly recalculated based on the basket content.
#7915 by Moritz
15 Apr 2019, 09:48
Ok, thanks!
I tried it with a plugin to set all prices to 0.00€ if the configured payment is selected.
That works until I click 'change payment' on confirmation page and select a different payment.
The prices then are 0.00€ aswell.
Maybe I should call something like resetPrices() if a different payment as the configured is set.
Here is my code for better understanding:
basket_plugin.png (80.25 KiB) Viewed 131 times
#7920 by Moritz
15 Apr 2019, 11:10
The price will only be updated when I return to the shopping cart or click on "Buy Now".
However, I get an error message that the price has changed and have to click the button again to continue.
This may make sense if the price changes from 0.00€ to 19.99€.
However, if the prices are all changed to 0.00€ due to the chosen payment method, I would like to avoid the error message.
#7922 by aimeos
15 Apr 2019, 15:07
You have to disable the ProductPrice basket plugin to avoid this.
In the latest version, modified prices are skipped by the ProductPrice plugin so they will stay as is.
#7923 by Moritz
16 Apr 2019, 09:30
Disable the ProductPrice plugin is no option for me because then no price will be reset if I choose an other payment.
I think the error messages are ok for me.
My main problem is currently that I can't place an order if the prices are set to 0.00€ before.
When clicking "buy now" I get the price changed error again and again.
#7927 by aimeos
17 Apr 2019, 14:24
Because you ar getting into a loop at which the ProductPrice plugin updates the price again and throws an error that displays the warning. The solution is that you manage the product price in your own plugin (reduce the price if necessary and restore the price if a different option is chosen) with the ProductPrice plugin disabled.