Problem/Motivation

Module does not work with D10

Steps to reproduce

* Install Drupal 10
* Try and install Commerce Cart Advanced

Proposed resolution

Add ^10 to core_version_requirement

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jofitz created an issue. See original summary.

jofitz’s picture

Assigned: jofitz » Unassigned
Status: Active » Needs review
StatusFileSize
new491 bytes

Create patch

krystalcode’s picture

Thanks for the patch.

I will not merge this until it is actually tested and found to work with Drupal 10, I do not want to mark it as Drupal 10-compatible if it actually still has incompatibilities. To install on Drupal 10 and test it, create a fork and install the forked version via composer.

I do not right now have an application that has already upgraded to Drupal 10 that uses this module so it may take me a while until I test it myself. Let us know how it works for you.

michelle’s picture

Status: Needs review » Needs work

I attempted to port this for a client but ran into issues and haven't gotten it working, yet. This is what Upgrade Status reports is needed:

Commerce Cart Advanced
Scanned on Sun, 09/03/2023 - 18:36.

1 error found. 3 warnings found. Avoid some manual work by using drupal-rector
for fixing issues automatically or Upgrade Rector to generate patches.

web/modules/contrib/commerce_cart_advanced/src/Event/CartsSplitEvent.php:
┌──────────┬──────┬─────────────────────────────────────────────────────────────┐
│  STATUS  │ LINE │                           MESSAGE                           │
├──────────┼──────┼─────────────────────────────────────────────────────────────┤
│ Check    │ 12   │ Class Drupal\commerce_cart_advanced\Event\CartsSplitEvent   │
│ manually │      │ extends deprecated class                                    │
│          │      │ Symfony\Component\EventDispatcher\Event: since Symfony 4.3, │
│          │      │ use "Symfony\Contracts\EventDispatcher\Event" instead       │
│          │      │                                                             │
└──────────┴──────┴─────────────────────────────────────────────────────────────┘

web/modules/contrib/commerce_cart_advanced/src/Hook/CartItemFormAlter.php:
┌──────────┬──────┬──────────────────────────────────────────────────────────────┐
│  STATUS  │ LINE │                           MESSAGE                            │
├──────────┼──────┼──────────────────────────────────────────────────────────────┤
│ Check    │ 77   │ Parameter $number_formatter_factory of method                │
│ manually │      │ Drupal\commerce_cart_advanced\Hook\CartItemFormAlter::__cons │
│          │      │ truct() has typehint with deprecated interface               │
│          │      │ Drupal\commerce_price\NumberFormatterFactoryInterface:       │
│          │      │ Replaced by CurrencyFormatterInterface.                      │
│          │      │                                                              │
└──────────┴──────┴──────────────────────────────────────────────────────────────┘

web/modules/contrib/commerce_cart_advanced/src/Plugin/Block/CurrentCartBlock.php:
┌──────────┬──────┬──────────────────────────────────────────────────────────────┐
│  STATUS  │ LINE │                           MESSAGE                            │
├──────────┼──────┼──────────────────────────────────────────────────────────────┤
│ Fix with │ 67   │ Call to deprecated function drupal_get_path(). Deprecated in │
│ rector   │      │ drupal:9.3.0 and is removed from drupal:10.0.0. Use          │
│          │      │ Drupal\Core\Extension\ExtensionPathResolver::getPath()       │
│          │      │ instead.                                                     │
│          │      │                                                              │
└──────────┴──────┴──────────────────────────────────────────────────────────────┘

web/modules/contrib/commerce_cart_advanced/commerce_cart_advanced.info.yml:
┌──────────┬──────┬────────────────────────────────────────────────────────────┐
│  STATUS  │ LINE │                          MESSAGE                           │
├──────────┼──────┼────────────────────────────────────────────────────────────┤
│ Check    │ 0    │ Value of core_version_requirement: ^8.7.7 || ^9 is not     │
│ manually │      │ compatible with the next major version of Drupal core. See │
│          │      │ https://drupal.org/node/3070687.                           │
│          │      │                                                            │
└──────────┴──────┴────────────────────────────────────────────────────────────┘
alexis_mc’s picture

StatusFileSize
new3.82 KB

Here I leave an updated patch.

damienmckenna’s picture

Status: Needs work » Needs review
krystalcode’s picture

Status: Needs review » Needs work

@alexis_mc Before I test this further myself, can you confirm whether you actually tested your patch on a working website? Or is it automatically generated patch?

-    $this->eventDispatcher->dispatch(CartEvents::CARTS_SPLIT, $event);
+    $this->eventDispatcher->dispatch($event, CartEvents::CARTS_SPLIT);
-use Symfony\Component\EventDispatcher\Event;
+use Symfony\Contracts\EventDispatcher\Event;

This means dropping Drupal 8 support, which is fine at this point. The composer/info files need to be updated accordingly. I will create a new branch 1.x for Drupal 9/10 which will be the main branch moving forward, and keep the current 8.x-1.x in a deprecated case for the rare sites that still use Drupal 8.

+        '#uri' => \Drupal::service('extension.list.module')->getPath('commerce') . '/icons/ffffff/cart.png',

We'll need to inject this as a service in the constructor.

keshavv’s picture

Status: Needs work » Needs review
StatusFileSize
new6.71 KB
new2.67 KB

Thank you alexis_mc
Your #5 patch fixed almost all issues. But I found a few more.
Rerolled patch with more changes. It works for me.

keshavv’s picture

StatusFileSize
new6.71 KB
keshavv’s picture

Status: Needs review » Reviewed & tested by the community

Confirmed that the patch added in #9 works perfectly.
Thank you.

  • krystalcode committed 0137bde7 on 2.x
    Issue #3387284 Made current cart block Drupal 10-compatible
    
    Upgraded to...

  • krystalcode committed d70fddd2 on 2.x
    Issue #3387284 Dispatch events as per symfony/event-dispatcher v4+
    

krystalcode’s picture

Status: Reviewed & tested by the community » Fixed
  • New branch 2.x that is compatible Drupal 9.3+/10.0+ and Commerce 2.33+. Commerce 2.33 is the first release that is really compatible with Drupal 10, so we have to set that as minimum version requirement.
  • The Save for Later functionality does not seem to work, and it might be a Drupal 10 incompatibility. We have a separate issue for this (#3402287: Error when "Save for later" is clicked) and will resolve this there, but I will not make a release before that is resolved. Until then, applications that do not make use of the Save for Later functionality can use the 2.x development branch.
  • Compared to the last patch, I removed the return type declarations; When we move to PHP 8 i.e. Drupal 10 as minimum version requirement, we'll update all code to use PHP 8 features and use strict types wherever possible.
  • Compared to the last patch, I removed the change to use the currency formatter. This is still a deprecation until Commerce 3.0, and I want to review this a bit more. We'll work on it on #3410936: Use currency formatter service.
krystalcode’s picture

krystalcode’s picture

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

Status: Fixed » Closed (fixed)

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