This week I have taken another stab at improving the ZenMagick pricing code. The main reason right now is to further reduce the number of SQL queries per request. As part of the process to encapsulate zen-cart logic as much as possible there is a class ZenCartCheckoutOrder that is compatible with zen-cart. However, it is populated entirely from the ZenMagick shopping cart class.
Unfortunately, the shopping cart class itself still relies on zen-cart, so the more logic is in ZenMagick, the better, because with the internal caching in the ZenMagick service classes, all relevant data will only be loaded once and once only!
Of course, pricing is not the most trivial part of zen-cart, so getting that right is a mission and tracking down pieces of code one by one to see what is actually going on.
The good news is, that so far all common cases like discounts, attribute pricing, quantity discounts, sales and one time costs are already working. The remaining differences are all around word count issues, etc. Hopefully one more improvement to come with the next version.
To make things work reliably, there is an option to assert that calculated values are in sync with zen-cart, which makes life a lot easier…