For some products it is preferable to hide everything about shipping. When I disable the shipping field on the form display (remove it from the create/edit node form), I run into a EntityStorageException when saving a new node.
Steps to reproduce:
- Create a product node type
- Hide the shippable field
- Create a new node
I get this message:
Drupal\Core\Entity\EntityStorageException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'shippable' at row 1: INSERT INTO {uc_products} (vid, nid, model, cost, price, weight, weight_units, length, width, height, length_units, pkg_qty, default_qty, shippable) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13); Array ( [:db_insert_placeholder_0] => 4864 [:db_insert_placeholder_1] => 4867 [:db_insert_placeholder_2] => KK [:db_insert_placeholder_3] => 0.00 [:db_insert_placeholder_4] => 0.00 [:db_insert_placeholder_5] => 0 [:db_insert_placeholder_6] => lb [:db_insert_placeholder_7] => 0 [:db_insert_placeholder_8] => 0 [:db_insert_placeholder_9] => 0 [:db_insert_placeholder_10] => in [:db_insert_placeholder_11] => 1 [:db_insert_placeholder_12] => 1 [:db_insert_placeholder_13] => ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 756 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Apparently, my MySQL database cannot translate the empty value for the shippable column into 'false'.
It is pretty easy to solve by just typecasting the value to integer. See patch.
Comment | File | Size | Author |
---|---|---|---|
#2 | hidden_shippable_field-2720069-2.patch | 506 bytes | bjaxelsen |
|
Comments
Comment #2
bjaxelsen CreditAttribution: bjaxelsen commentedComment #3
longwaveComment #5
longwaveCommitted, thanks for the patch.