About Magewire not being part of the Loki Checkout anymore

First versions of the Loki Checkout were heavily based on Magewire. While it resembled the Hyvä Checkout somewhat, it went for an architecture that relied heavily upon client-side validation and the strategy of using a granular component for every single piece of logic. While this offered a lot of flexibility, the key features of Magewire were used less and less.

For instance, instead of using the Magewire wire:model directive, the Alpine x-model directive was used instead, to intercept any change to a form field by using Alpine components and then to make a call to the Magewire component backend by using Magewire.find(componentId). In other words, Magewire was used often only for making a simple AJAX call.

Another burden was that - at the time of coding the Loki Checkout - Magewire 1 was alive but Magewire 3 was not. Because of this, bundling multiple component updates in a single HTTP request was missing. And while the basic features of the checkout did not really suffer from this, this problem became more and more an issue while building more advanced features. One such a feature was the Postcode NL integration, where a streetname and city would be determined, based upon the input of a postcode, house number and house number addition. This involved 5 components, but after saving values to these components, other components would need to be refreshed as well (shipping methods, payment methods, quote totals, address preview, etc). While developing all this under Magewire, this led into too many AJAX calls. And this led to the conclusion that Magewire was not fitting the Loki Checkout project anymore.

As mentioned, Magewire 3 could be a possible solution here, but we couldn't wait for it anymore. Plus, because the Loki Checkout relied heavily upon clever Alpine components already, it was quite doable to just write a simple AJAX mechanism, add a Magento controller to handle incoming request and reply with the updates needed. A proof of concept was built first with the Alpine AJAX plugin. But this was also dropped in favor of a 30 line AJAX call and custom backend logic.

We still love Magewire and Yireo continues to support its development. We believe that Magewire is still a great choice if you don't have a heavy focus upon client-side features like JS validation and/or where numerous requests to the backend are less of a problem. However, specifically for the Loki Checkout, we made the choice to continue without it.

Sidenote

Currently adding Magewire components as part of Loki Components is again investigated. This basically means that a Loki Component is able to ship with client-side validation and filtering, but still call upon a Magewire component as well - combining (possibly) the best of two worlds.

Last modified: January 12, 2025