By In Magento

Fixing currency rates in Magento 1.x

While Magento 1.x is slowly fading into history, still there are lot of stores that still use it and therefore need to be maintained on regular bases.

If you have multi currency store, than you are familiar with built-in service Webservicex, which was responsible to update currency rates. Webservicex service stopped working a year ago and to make things even worst it will return 1 for all currency rates. That can cause lot of issues, for example it will allow customers to order items with price of base currency but without conversion.

As alternative many stores switched to ‘Payserv GoogleFinance’ module, which use Google Finance API to retrieve currency rates. Module was free to use and can be found on GitHub (thanks Magento for removing old marketplace – thumb down):

https://github.com/ausger/GoogleCurrency

Recently I noticed that a notice in Magento admin:

WARNING: Cannot retrieve rate from http://www.google.com/finance/converter?a=1&from={{CURRENCY_FROM}}&to={{CURRENCY_TO}}

Message came from ‘Payserv GoogleFinance’ module and was outputted when module tries to update currency rates. This happen because Google Finance changed URL for API service that should return rates. To make module functional small modification is needed and we will make it in Model file:

app/code/local/Payserv/GoogleFinance/Model/Google.php

at line #32 we will replace existing code with this one:

protected $_url = ‘https://finance.google.com/finance/converter?a=1&from={{CURRENCY_FROM}}&to={{CURRENCY_TO}}’;

As you may notice, comparing URL from notice and new URL that we set everything is same except domain name so now it is: https://finance.google.com/finance/

After you made change in file and upload it back, please try to import rates to be sure that module works now properly. As additional check you may open a Google Finance in browser and compare rates, for example USD to EUR: https://finance.google.com/finance/converter?a=1&from=USD&to=EUR

If you have issues to make this small change you can contact me and I can send you version of module with fix applied:
http://magehelperblog.com/contact-me/

 

Read more

By In Magento 2

White page issue – Magento 2

Another very common issue in Magento 2 are white pages in back end, error that I resolved was related to Credit Memo functionality but similar method can be applied to similar issues as well.

To describe issue a bit more, I went to Sales > Order Management > Orders and selected order that should be refunded. Issue was found on several orders and they were made using Authorize.net or PayPal payment), so I excluded possibility that custom payment method could cause issue.

In order screen I clicked Credit Memo button and landed on white page without any error message or notification. Since there were no errors in browser console (wanted to check for java script errors), I checked var/log/systemlog file and found error log:

main.CRITICAL: Broken reference: No element found with ID ‘before.body.end’.

After checking few topics about issue and suggested solutions I decided to try simplest one, to update XML file and add missing layout parameter.

For the sake of test I deiced to edit core file at line #8:

html/vendor/magento/module-sales/view/adminhtml/layout/sales_creditmemo_index.xml

and changed original code:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

to:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
After that change I was able to open all test orders and perform Credit Memo without any issues, also there were no errors in log files.
To prevent change to be deleted on next Magento update I suggest that you overwrite core layout file with your own.
Magento 2 devdocs provide solid guide how to do that:

Read more

By In Magento 2

Limit free shipping by total weight – Magento 2

Magento 2 basic installation have three ‘offline’ shipping methods included: free shipping, flat rate and table rates.

They are called ‘offline’ because all shipping rates will be calculated using offline resources, basically only ‘table rates’ use advanced math and calculate fee according to provided CSV file.

Magento 2 also comes with four more shipping methods, dimensional weight methods (DHL, FedEx, UPS, USPS), that use external data to calculate how much customers have to pay for shipping.

 

Most popular  ‘offline’ shipping method among customers is ‘free shipping’, everybody loves free shipping, they will pay just for products and there is no extra fee – great right 🙂

Now comes tricky part, free shipping has only one condition which is

One of our customers that have store based on Magento 2 platform noticed that among all stuff that they sell there are products that are heavy or bulky to be sent via regular shipping, however price of those products was high enough to enable free shipping. So his request was quite simple, to limit free shipping option to 120 lbs. of total cart weight, if items in cart go above that value ‘free shipping’ shouldn’t be available.

So we made small module that extend Magento ‘free shipping’ module by adding more field in Shipping Methods > Free Shipping tab, where admin can enter maximal weight for free shipping.

Here is the screen shot of admin section after we deployed our mini module:

Magento 2 - Free shipping method settings

Magento 2 – Free shipping method settings

Module simply extend condition that is located in Carrier file (notice that we added Rewrite folder to remeber that module overwrites core module):

app\code\Smdesign\FreeShipping\Model\Rewrite\Carrier\Freeshipping.php

so we now have too conditions that need to be fulfilled: Minimum Order Amount and 

Instead copying parts of code and explaining every  line I decided to provide module as package (please backup everything before deploy it) and I am quite sure that you will manage to grasp code in it.

 

Unpack archive into your Magento 2 installation root folder, navigate to /bin folder or use path in command line (as you like) and run commands in console:

magento module:enable Smdesign_FreeShipping

magento setup:upgrade

Please don’t hesitate to post comments I appreciate your feedback, any idea, improvement or reported bug/issue are more than welcome.

I am new to Magento 2 but eager to learn it and hope that will be able to post about it often.

Cheers 🙂



 

 

Read more