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

CommentFileSizeAuthor
#4 3412057-4.patch3.59 KBjsacksick

Comments

afagioli created an issue. See original summary.

jsacksick’s picture

Version: 3.0.x-dev » 8.x-2.x-dev

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

afagioli’s picture

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
jsacksick’s picture

Status: Active » Needs review
StatusFileSize
new3.59 KB

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...
jsacksick’s picture

Status: Needs review » Fixed

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

afagioli’s picture

Thanks for being so prompt :)
Best!

jsacksick’s picture

Did this fix the issue for you?

Status: Fixed » Closed (fixed)

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

rishabjasrotia’s picture

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

jsacksick’s picture

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

rishabjasrotia’s picture

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

I also notice that this patch solution is present in latest version.

Strange even the commerce_cart module is enabled.

rishabjasrotia’s picture

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)