Created on 25 April 2025, 4 months ago

Description :
The AJAX Cart Update module enhances the Drupal Commerce cart form by providing AJAX-based functionality to dynamically update item quantities and order totals without requiring a full page reload. This improves the user experience by making cart interactions faster and more seamless.

The module supports two update methods:

Selectors: Updates cart elements using predefined CSS selectors extracted from the Views render array.
Endpoint: Uses an AJAX endpoint to fetch and update cart summary HTML.
...

Full description: attached README.md

Please review for project approval. Repository: https://github.com/aevfly/AJAX-Cart-Update.git

📌 Task
Status

Active

Component

module

Created by

🇺🇦Ukraine aev_fly

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

Comments & Activities

  • Issue created by @aev_fly
  • 🇮🇳India vishal.kadam Mumbai
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Thank you for applying! For these applications, we need a link to a project hosted on drupal.org.

  • 🇺🇦Ukraine aev_fly
  • 🇺🇦Ukraine aev_fly
  • 🇺🇦Ukraine aev_fly
  • 🇺🇦Ukraine aev_fly
  • 🇮🇳India vishal.kadam Mumbai

    You need to commit the code to a branch at https://git.drupalcode.org/project/ajax_cart_update.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇺🇦Ukraine aev_fly

    thx, code is committed to the 10.x-1.x branch git@git.drupal.org:project/ajax_cart_update.git

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇳India vishal.kadam Mumbai

    Thank you for applying!

    Please read Review process for security advisory coverage: What to expect → for more details and Security advisory coverage application checklist → to understand what reviewers look for. Tips for ensuring a smooth review → gives some hints for a smoother review.

    The important notes are the following.

    • If you have not done it yet, you should enable GitLab CI for the project and fix the PHP_CodeSniffer errors/warnings it reports.
    • For the time this application is open, only your commits are allowed.
    • The purpose of this application is giving you a new drupal.org role that allows you to opt projects into security advisory coverage, either projects you already created, or projects you will create. The project status will not be changed by this application; once this application is closed, you will be able to change the project status from Not covered to Opt into security advisory coverage. This is possible only 14 days after the project is created.

      Keep in mind that once the project is opted into security advisory coverage, only Security Team members may change coverage.
    • Only the person who created the application will get the permission to opt projects into security advisory coverage. No other person will get the same permission from the same application; that applies also to co-maintainers/maintainers of the project used for the application.
    • We only accept an application per user. If you change your mind about the project to use for this application, or it is necessary to use a different project for the application, please update the issue summary with the link to the correct project and the issue title with the project name and the branch to review.

    To the reviewers

    Please read How to review security advisory coverage applications → , Application workflow → , What to cover in an application review → , and Tools to use for reviews → .

    The important notes are the following.

    • It is preferable to wait for a project moderator before posting the first comment on newly created applications. Project moderators will do some preliminary checks that are necessary before any change on the project files is suggested.
    • Reviewers should show the output of a CLI tool → only once per application.
    • It may be best to have the applicant fix things before further review.

    For new reviewers, I would also suggest to first read In which way the issue queue for coverage applications is different from other project queues → .

  • 🇮🇳India vishal.kadam Mumbai

    FILE: ajax_cart_update.info.yml

    core_version_requirement: ^9 || ^10

    A new project should not declare itself compatible with a Drupal release that is no longer supported. No site should be using Drupal 8 nor Drupal 9, and people should not be encouraged to use those Drupal releases.

  • 🇺🇦Ukraine aev_fly

    updated

  • 🇺🇦Ukraine aev_fly
  • Issue was unassigned.
  • Status changed to Needs review about 1 month ago
  • 🇷🇴Romania bbu23

    Updating priority according to issue priorities → .

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    • The following points are just a start and don't necessarily encompass all of the changes that may be necessary
    • A specific point may just be an example and may apply in other places
    • A review is about code that does not follow the coding standards, contains possible security issue, or does not correctly use the Drupal API
    • The single review points are not ordered, not even by importance

    src/Controller/AjaxCartUpdateController.php

    Since that class does not use methods from the parent class, it does not need to use ControllerBase as parent class. Controllers do not need to have a parent class; as long as they implement \Drupal\Core\DependencyInjection\ContainerInjectionInterface, they are fine.

              $response['cart_block_quantity'][] = $order_item->getQuantity() . ' ' . t('x');
              $response['cart_block_title'][] = $order_item->getTitle();
    

    The translatable string should use placeholders, which would avoid concatenating a translatable string with a string. It would also give to translator people more context.
    The code should also use $this->t(), since it is not in a static method.

    src/Form/AjaxCartUpdateSettingsForm.php

      /**
       * The typed config manager.
       *
       * @var \Drupal\Core\Config\TypedConfigManagerInterface
       */
      protected $typedConfigManager;
    
      /**
       * Constructs a new AjaxCartUpdateSettingsForm.
       *
       * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
       *   The config factory.
       * @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config_manager
       *   The typed config manager.
       */
      public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config_manager) {
        parent::__construct($config_factory);
        $this->typedConfigManager = $typed_config_manager;
      }
    

    $typed_config_manager is passed to the parent class, which already has a property for that.

    ajax_cart_update.module

      // Attach translations to drupalSettings.
      $translations = [
        'items' => new TranslatableMarkup('items', [], ['context' => 'Cart block item count']),
        'x' => new TranslatableMarkup('x', [], ['context' => 'Cart block quantity separator']),
      ];
    
      $attachments['#attached']['drupalSettings']['ajaxCartUpdate']['translations'] = $translations;
    

    JavaScript code that needs translatable strings uses Drupal.t().

Production build 0.71.5 2024