Issues on Drupal 11

Created on 14 March 2025, 24 days ago

This module claims to be compatible with Drupal 11. There are issues with adding the item to the cart. I also cannot seem to edit the twig template for the cart as the changes are not reflected. Has anyone had success with this on D11 and if so how do you properly install it?

Installing Basic Cart on Drupal 11. I had to manually install easy_install from a patch. Then manually install Basic Cart, as composer will not allow it without the easy_install dependency. When doing this the module activates fine. When I try and add a product to the cart, I get directed to a json response. If I go to the cart manually, /cart, the item appears there. If I try and add the same item again I get an error on my website.

Here are some of the php errors being produced:
Warning: Trying to access array offset on null in Drupal\basic_cart\Plugin\Field\FieldFormatter\AddToCartFormatter->viewElements() (line 42 of /var/www/html/d11/web/modules/contrib/basic_cart/src/Plugin/Field/FieldFormatter/AddToCartFormatter.php)

Warning: Undefined array key 0 in Drupal\basic_cart\Plugin\Field\FieldFormatter\AddToCartFormatter->viewElements() (line 42 of /var/www/html/d11/web/modules/contrib/basic_cart/src/Plugin/Field/FieldFormatter/AddToCartFormatter.php)

Warning: Undefined property: Drupal\Core\Database\IntegrityConstraintViolationException::$query_string in Drupal\basic_cart\CartStorage::insert() (line 38 of /var/www/html/d11/web/modules/contrib/basic_cart/src/CartStorage.php)

🐛 Bug report
Status

Active

Version

8.0

Component

Code

Created by

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

Comments & Activities

  • Issue created by @blogchef12
  • As the admin who build this underlying system, note that it is running PHP 8.4.4 and Apache 2.4.37 on RedHat8.

  • We have discovered that this appears to be due to accessing Drupal across or firewall which is translating https to http (which is what Drupal is running on the server). Basic Cart appears to be hard-coded to offer the http:// path for the "add to cart" button, and this results in the error on the client site browser of "The page at was loaded over HTTPS, but requested an insecure XMLHttpRequest This request has been blocked; the content must be served over HTTPS".

    Ironically, this same setup is flawless with the Drupal 7 deployment that we are trying to update to D11.

    Any suggestions?

  • We have determined that this issue is due to our firewall handling certificates (https) and forwarding http to Drupal.

    This worked flawlessly for years in Drupal 7, but it seems like Basic Cart will not run this way in Drupal 11.

    I have changed forwarding to be https (firewall still handles certs) to https with self-signed on the Drupal 11 node, and this is resolved.

Production build 0.71.5 2024