1

A customer has reported that they are receiving an error when they try to check out in our Magento 2.3.2 site. The message is as follows:

Recoverable Error: Object of Class Magento\Customer\Model\Data\Region could not be converted to string in /var/www/vhosts/mywebsite.com/httpdocs/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php on line 3101

And there is also a message in shipping which states

Sorry, no quotes are available for the order at this time

This is happening intermittently for a few customers and I would like to know what is causing it and, if possible, how to fix it.

1

OK. Apparently this is a bug which occurs when the region field is empty.

Found a workaround on Github here: https://github.com/magento/magento2/issues/7387#issuecomment-263586330

In

vendor/magento/framework/DB/Adapter/Pdo/Mysql.php

Search for the line in the error (in this case 3101) the text there should be as below

        case 'varchar':
        case 'mediumtext':
        case 'text':
        case 'longtext':
            $value  = (string)$value;
            if ($column['NULLABLE'] && $value == '') {
                $value = null;
            }
            break;

Replace this with:

        case 'varchar':
        case 'mediumtext':
        case 'text':
        case 'longtext':
            if ($column['COLUMN_NAME'] == 'region' AND !is_string($value)) {
                $value = '';
            }
            $value  = (string)$value;
            if ($column['NULLABLE'] && $value == '') {
                $value = null;
            }
            break;

Obviously I'm not happy with replacing info in the core files but until a better solution presents itself this will have to do.

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.