0

The website is working with two currencies - GBP (base currency) and EUR. For countries in the UK the shipping should be 5 GBP, for the rest it should be exactly 6 EUR (for example 4.71 GBP in base currency).

I've created an observer which detects the country and changes the shipping rate but there are problems with it for the orders placed from the backend.

My idea is to dispatch a custom event when the currency rates are changed (after_save). This is easy. To recalculate the value for the other countries to be 6 EUR is easy too - it would be 6/currentlySavedGbpToEurCrrencyRate. For example 4.71 GBP.

But how can I edit the currently saved shipping rates which were imported with the CSV file? I have to update them. Can I somehow create a new csv file programatically and call Mage_Shipping_Model_Resource_Carrier_Tablerate::uploadAndImport? Another option is to edit the values in the DB directly - table shipping_tablerate. Is it safe?

Note: I know that the best solution would be creating a second website with base currency EUR but this is not possible at the moment, so I'm searching a workaround.

1

This table is not hooked into any other tables in magento (apart from using countries/states tables), so if you mess it up it will have no adverse effect.

You can truncate the table with no issue, thats what the csv import does anyhow, it will wipe all values for the specific condition (weight/price/qty), but if its emptied thats fine.

Id go for straight sql in this scenario, we have many customers who do just this. Far simpler than trying to mess around with calling into the codebase in this instance.

I generally wouldnt recommend this elsewhere in magento btw. Obviously you need to be careful, and you are breaking some rules around coding, but this does get the job done fast.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.