The Order processor caches calculated bundle prices

Created on 22 February 2025, about 2 months ago

Problem/Motivation

The order processor that calculates the price, caches the price so that when prices are changed, or variations are removed, the caches must be cleared to show the correct calculated price.

Steps to reproduce

Change the price on a variation that is a child variation or group item, and refresh the page. The price stays the same until the caches are cleared.

Proposed resolution

Look into it, and fix it if possible.

📌 Task
Status

Active

Version

3.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 @tonytheferg
  • Invalidating the cache tags on the $parent_variation at the beginning of the calculateBundlePrice function in VadoOrderProcessor seems to help:

      /**
       * Calculates the bundle price for the calculated price formatter.
       *
       * @param \Drupal\commerce_order\Entity\OrderItemInterface $order_item
       *   The order item.
       */
      protected function calculateBundlePrice(OrderItemInterface $order_item) {
        $parent_variation = $order_item->getPurchasedEntity();
        if (!$parent_variation) {
          return;
        }
        Cache::invalidateTags($parent_variation->getCacheTags());

    Then when loading a new page you see the change, but not on refreshing the same page.

Production build 0.71.5 2024