An updated build an online store on MODX Revolution. Multiple currencies

More than a year ago I wrote about our ready build an online store on the basis of MODX Revolution. Given the current situation with exchange rates in Russia (the need to specify the prices in roubles), I decided that will probably be the actual ability to specify different base currency for goods, but that on the website as if it was still in rubles. The main thing here is to be able to specify the currency of the goods (for example euros or dollars) and the price would be output in rubles at the exchange rate (perhaps an automatic update of the courses from the website of the Central Bank). It is not a multi-currency store, but the prices are always more or less current will be based on the current exchange rate.

not much about what the changes were for this year+
this year we have made more than one store on the basis of ShopModxBox (most of whom migrate existing stores from other engines on this with conservation of structure and content. A report on one of these projects can be read here), and third-party developers have created is not enough (in my experience only fighting a few dozen stores, but just for the experiment no less than a hundred or two). And although we have released one updated version of the engine (link to github), no major changes, we in the original basis was not made. Largely this is due to the fact that we have not tried and will not try to create some megauniversity engine. IMHO that is simply ready-made solutions. For us is the basis for some individual projects. It happens that the customer required some special shop, with their non-standard chips. Having at least a modest, but flexible framework, you can quickly implement almost any imaginable chips. But still some basic things we of course added to the Assembly, including the payment via EVouchers and UnitPay.


In the new version the emphasis was placed precisely on the update of courses and recalculation of the cost of goods on the fly to the website itself still worked in rubles. I admit that it would be more flexible currencies, but there are many pitfalls that I will not fight, so once again: this build is designed to work with rubles, and though you can specify for the item in other currencies, and will recount everywhere, but still everything is in rubles. But even Google.The market is unloading in rubles, even if the item has a price in another currency.

Let us consider in more detail the technical side of the question.

1. Currency update on the website.
Written for this special processor, which is a simple simple GET request wassit/assets/components/modxsite/connectors/connector.php?pub_action=currencies/update_courses
Start the challenge it for the crown once a day, and courses on the website will be updated automatically, podgruzhat from the website of the Central Bank.

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

By the way, a question to the Studio: who knows the normal source to get the courses relative to other currencies and not only against the ruble (or I have not read the API documentation cbr.ru and is there any way to specify relative to what currency you need courses? If so, someone tell me how to specify?). Just now, courses are drawn only against the ruble, and it's one of the reasons for the inferiority of the FCC mechanism on the website.

2. How to add your currency.
Now the Assembly includes currency EUR and USD. If you need any other currency, created in the context of spravochniki in currencies new document of type Currency and the currency of the template and ask him to header — currency code. Be sure that it was one of the codes available in the returned XML, otherwise there will be automatic updates of the currency.
Actually all. Nothing further to do. The processor, the output of goods will automatically recalculate the value of the goods.
Article based on information from habrahabr.ru

Популярные сообщения из этого блога

Approval of WSUS updates: import, export, copy

The Hilbert curve vs. Z-order

Configuring a C++ project in Eclipse for example SFML application