Updated build of the online store on MODX Revolution. Multiple currencies

    More than a year ago, I wrote about our finished assembly of an online store based on MODX Revolution. Given the current situation with exchange rates in Russia (with the need to indicate prices in rubles), I decided that the ability to indicate various base currencies for goods would probably be relevant, but so that everything would be in rubles on the site. The main thing here is that you can indicate the currency of the goods (for example, euros or dollars), and on the site the price would be displayed in rubles at the exchange rate (automatic updating of rates from the central bank website is possible). This is far from a full-fledged multicurrency store, but prices will always be less relevant given the current exchange rate.

    Not much about what changes have been over this year +
    For this year, we ourselves have made more than one store based on ShopModxBox (most of which are the transfer of existing stores from other engines to this one with preservation of structure and content. A report on one of such projects can be read here ), and there were third-party developers not a few have been created (according to my observations there are only a few dozen combat stores, but just for the experiment, no less than a hundred or two). And although we have released more than one updated version of the engine ( link to github), we did not make any fundamental changes to the original basis. This is mainly due to the fact that we did not try and will not try to create some kind of mega-universal engine. IMHO enough ready-made solutions. For us, this is the basis precisely for some individual projects. It happens that a customer needs some kind of special store, with their own non-standard chips. Having a modest but flexible foundation, you can quickly realize almost any conceivable chip. But nevertheless, we certainly add some basic things to the assembly, among which are payment through UnifiedCash and UnitPay .


    In the new version, emphasis was placed on updating courses and recalculating the cost of goods on the fly, so that the site itself still works in rubles. I admit that I would like to work more flexibly with currencies, but there are many pitfalls with which I have not started to fight, so I repeat again: this assembly is designed to work specifically with rubles, and although you can specify other currencies for the product, and there will be a recount everywhere, but all the same everything will be in rubles. But then, even Yandex.Market is unloading in rubles, even if the product has a price in a different currency.

    Consider a little more detailed technical side of the issue.

    1. Updating exchange rates on the site.
    A special processor has been written for this, which is called by a simple simple GET request: yoursite / assets / components / modxsite / connectors / connector.php? Pub_action = currencies / update_courses
    Run it on the crown once a day, and the courses on the site will be updated automatically, loading from the central bank website.

    I did not impose any special restrictions on access on him, because all he can do is just update exchange rates, nothing more.

    By the way, the question is in the studio: who knows the normal source for obtaining courses in relation to other currencies, and not just in relation to the ruble (or did I read the cbr.ru API documentation poorly and can I somehow indicate with respect to which currency the rates are needed? If so, who will tell you how to specify?). It’s just that now the courses only last for the ruble, and this is one of the reasons for the inferiority of the multicurrency mechanism on the site.

    2. How to add your own currency.
    Now the assembly includes currencies EUR and USD. If you need some other currency, create a new document with the Currency type and the Currency template in the spravochniki context in currencies and set a heading for it - the currency code. It is imperative that this is one of the codes available in the returned XML , otherwise this currency will not be automatically updated.

    Actually everything. Nothing extra to do. The processor that returns the goods data will automatically recalculate the value of the goods.

    Also popular now: