Unknown column 'cart'

Created on 3 January 2024, 6 months ago
Updated 29 February 2024, 4 months ago

Describe your bug or feature request.

/admin/commerce crashes due to missing dependency.

If a bug, provide steps to reproduce it from a clean install.

1. drush en commerce
2. drush en commerce_store commerce_promotion
3. visit /admin/commerce

you have an error saying

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'cart' in 'where clause': SELECT COUNT(*) AS "expression" FROM (SELECT 1 AS "expression" FROM "commerce_order" "commerce_order" WHERE (("cart" = :db_condition_placeholder_0) AND ("created" >= :db_condition_placeholder_1)) OR (("cart" = :db_condition_placeholder_2) AND ("placed" >= :db_condition_placeholder_3))) "subquery"; Array ( [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => 1704236400 [:db_condition_placeholder_2] => 0 [:db_condition_placeholder_3] => 1704236400 ) in Drupal\commerce_order\Form\DashboardMetricsForm->getCartsCountForPeriod() (line 491 of /home/a/Public/d10/web/modules/contrib/commerce/modules/order/src/Form/DashboardMetricsForm.php).

4. drush en commerce_cart
3. visit /admin/commerce

you have no error now

🐛 Bug report
Status

Fixed

Version

2.0

Component

Cart

Created by

🇮🇹Italy afagioli Rome

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @afagioli
  • 🇮🇱Israel jsacksick

    Oh... that affects 2.x as well... We should check that the cart module exists... Or even alter the form from commerce_cart.

  • 🇮🇹Italy afagioli Rome

    Oh, well...
    Not being asked. I didn't suggest a solution.
    It would be adding a the cart dependency into commerce_promotion.info.yml

    Tested, it works.

    name: Commerce Promotion
    type: module
    description: 'Provides a UI for managing promotions.'
    package: Commerce
    core_version_requirement: ^9.3 || ^10
    configure: entity.commerce_promotion.collection
    dependencies:
      - commerce:commerce
      - commerce:commerce_order
      - commerce:commerce_cart
      - drupal:options
    
  • Status changed to Needs review 6 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 6 months ago
    790 pass
  • 🇮🇱Israel jsacksick

    The attached patch should do the trick.

    • jsacksick committed 987b6123 on 8.x-2.x
      Issue #3412057 by jsacksick, afagioli: Check if the cart module is...
    • jsacksick committed 56ee3eba on 3.0.x
      Issue #3412057 by jsacksick, afagioli: Check if the cart module is...
  • Status changed to Fixed 6 months ago
  • 🇮🇱Israel jsacksick

    Went ahead and committed the fix, thank you for this report :).

  • 🇮🇹Italy afagioli Rome

    Thanks for being so prompt :)
    Best!

  • 🇮🇱Israel jsacksick

    Did this fix the issue for you?

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • I had similar issue post installation on existing site.
    While the patch is not able to solve the problem!

  • 🇮🇱Israel jsacksick

    @rishabjasrotia: Did you try updating to the latest version? 2.38?

  • @jsacksick
    Yes I am using the latest version.
    "drupal/commerce": "^2.38"

  • Also there is no `cart` column in database table also.
    I have verified it

    See below:

    MySQL [drupal]> DESC commerce_order;
    +-------------------------------------+---------------+------+-----+---------+----------------+
    | Field                               | Type          | Null | Key | Default | Extra          |
    +-------------------------------------+---------------+------+-----+---------+----------------+
    | order_id                            | int unsigned  | NO   | PRI | NULL    | auto_increment |
    | type                                | varchar(32)   | NO   | MUL | NULL    |                |
    | uuid                                | varchar(128)  | NO   | UNI | NULL    |                |
    | order_number                        | varchar(255)  | YES  | MUL | NULL    |                |
    | version                             | int unsigned  | YES  |     | NULL    |                |
    | store_id                            | int unsigned  | YES  | MUL | NULL    |                |
    | uid                                 | int unsigned  | YES  | MUL | NULL    |                |
    | mail                                | varchar(254)  | YES  |     | NULL    |                |
    | ip_address                          | varchar(128)  | YES  |     | NULL    |                |
    | billing_profile__target_id          | int unsigned  | YES  | MUL | NULL    |                |
    | billing_profile__target_revision_id | int unsigned  | YES  | MUL | NULL    |                |
    | total_price__number                 | decimal(19,6) | YES  |     | NULL    |                |
    | total_price__currency_code          | varchar(3)    | YES  |     | NULL    |                |
    | total_paid__number                  | decimal(19,6) | YES  |     | NULL    |                |
    | total_paid__currency_code           | varchar(3)    | YES  |     | NULL    |                |
    | state                               | varchar(255)  | YES  | MUL | NULL    |                |
    | data                                | longblob      | YES  |     | NULL    |                |
    | locked                              | tinyint       | YES  |     | NULL    |                |
    | created                             | int           | YES  |     | NULL    |                |
    | changed                             | int           | YES  |     | NULL    |                |
    | placed                              | int           | YES  |     | NULL    |                |
    | completed                           | int           | YES  |     | NULL    |                |
    +-------------------------------------+---------------+------+-----+---------+----------------+
    22 rows in set (0.006 sec)
    
Production build 0.69.0 2024