magento2: Error on checkout page when empty region field

Error message: Recoverable Error: Object of class Magento\Customer\Model\Data\Region could not be converted to string in /vendor/magento/framework/DB/Adapter/Pdo/Mysql.php

The checkout page halts after this error.

Originally reported issue - https://github.com/magento/magento2/issues/4187

Steps to reproduce: https://github.com/magento/magento2/issues/4187#issuecomment-255110528

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (5 by maintainers)

Most upvoted comments

I temporarily bypassed this bug:

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

Search line 2920

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

Replace by

            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;