Can't Install: Unmet dependencies

Created on 8 February 2025, 5 months ago

Problem/Motivation

I have a very strong use case for this functionality! Would really like to make it work!

Steps to reproduce

Install module via Composer
Visit /admin/modules to activate
Error message: Unable to install Commerce Cart Webform due to unmet dependencies: views.view.product_webform_submissions (field.storage.commerce_product_variation.field_event_variation_title, su_events)

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ’¬ Support request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States lhubbert

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

Comments & Activities

  • Issue created by @lhubbert
  • It seems like this module has a dependency on another module named su_events, but after searching around I could not find a module with this name. Is that a custom module that is only used internally within Students' Union UCL?

  • It is, apologies. That should have been removed before it was published. I'll release a fix in the next few days.

  • @maxwellkeeble after further testing, there is also an unnecessary dependency on commerce_stock which prevents installation on fresh instances of Drupal Commerce sites;
    The class \Drupal\commerce_cart_webform\EventSubscriber\OrderEventSubscriber uses the trait \Drupal\commerce_stock\ContextCreatorTrait but never calls any methods implemented by the trait.

    All the phpdoc of the methods also imply that they are doing something with the product stock, even though they don't.

    I also found that the ::validateForm() and ::submitForm() methods of \Drupal\commerce_cart_webform\Form\AddToCartForm assume that the form display has the variation selection field visible, but since the form display is user-configurable, this may not be the case:
        if ($this->variation_webform == NULL) {
          // $purchased_entity_id may be null causing null ID error when trying to load the webform.
          $purchased_entity_id = $form_state->getValue('purchased_entity')[0]['variation'];
          $variation = ProductVariation::load($purchased_entity_id);
          $variation_webform = $this->getVariationCartWebform($variation);
          $this->variation_webform = $variation_webform;
        }
    

    Suggestion

    Add a check for existence of the purchased_entity submitted value and use the order item's default purchased entity as a fallback.

        if ($this->variation_webform == NULL) {
          if ($form_state->hasValue('purchased_entity')) {
            $purchased_entity_id = $form_state->getValue('purchased_entity')[0]['variation'];
            $variation = ProductVariation::load($purchased_entity_id);
          }
          else {
            $order_item = $this->entity;
            $variation = $order_item->getPurchasedEntity();
          }
          $variation_webform = $this->getVariationCartWebform($variation);
          $this->variation_webform = $variation_webform;
        }
    
Production build 0.71.5 2024