📜 ⬆️ ⬇️

Updated build online store for MODX Revolution. Multiple currencies

Over a year ago, I wrote about our ready-made assembly of an online store based on MODX Revolution. Given the current situation with currency rates in Russia (with the need to specify prices in rubles), I decided that it would certainly be possible to specify different base currencies for goods, but that everything on the site should be in rubles. The main thing here is so that you can specify the currency of the goods (for example, euro or dollars), and on the website the price would be displayed in rubles at the exchange rate (it is possible to automatically update the rates from the central bank website). This is far from a full-fledged multi-currency store, but prices will always be less relevant given the current exchange rate.

Not much at all about what changes were made this year. +
This year we ourselves have done more than one store on the basis of ShopModxBox (most of which are the transfer of existing stores from other engines to this with preservation of structure and content. A report on one of these projects can be read here ), and third-party developers were not a few were 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 the github ), we did not make any fundamental changes to the original basis. For the most part this is due to the fact that we have not tried and will not try to create some kind of mega-universal engine. IMHO this is enough ready-made solutions. For us, this is the basis for any individual projects. It happens that the customer needs some special store, with its not standard chips. With a modest but flexible basis, you can quickly implement almost any conceivable pieces. But, of course, we add some basic things to the assembly, including payment via the Unified Cashier and UnitPay .


In the new version, the emphasis was placed on updating the courses and recalculating the cost of goods on the fly, so that the site itself still worked in rubles. I admit that I would like more flexible work with currencies, but there are many pitfalls that I haven’t struggled with now, so I’ll repeat once again: this assembly is designed to work with rubles, and although you can specify other currencies for a product, and there will be a recount everywhere, but still everything will be in rubles. But even in Yandex.Market there is an unloading in rubles, even if the goods have a price in a different currency.
')
Consider a little more technical side of the issue.

1. Update exchange rates on the site.
To do this, a special processor was written, which is called by a simple simple GET request your_site / assets / components / modxsite / connectors / connector.php? Pub_action = currencies / update_courses
You start a call on krone once a day, and the courses on the site will be updated automatically, loading from the site of the central bank.

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

By the way, the question to the studio is: who knows the normal source for getting rates relative to other currencies, and not just about the ruble (or did I read the API documentation cbr.ru badly and can there be any indication as to what currency courses are needed? If so, who tell me how to specify?). Just now the courses are drawn only in relation to 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 in the context of spravochniki in currencies a new document with the type Currency and the Currency template and set the title for it - the currency code. It is imperative that this be one of the codes available in the returned XML , otherwise there will be no automatic updating of this currency.

Actually everything. Nothing extra to do. The processor, the returned goods data, will automatically recalculate the cost of goods.

Source: https://habr.com/ru/post/246635/


All Articles