Skip to content

Cart doesn't always recalculate when the underlying data changesΒ #6206

@fthobe

Description

@fthobe

The cart does not recalculate automatically when the underlying data such prices changes or the cart is particularly old.

Solidus Version:
All

To Reproduce

  1. insert a product in the basket
  2. modify the price of a product in the admin interface or via API
  3. try to complete an order that was initiated

Current behavior
The cart is not recalculated and therefore the cart still contains the product with the old price.

Expected behavior
Credits for expected behaviour: @forkata
The general idea would be to re-assign the price on line item from the variant on the line item and call order.recalculate.

Clearing the LineItem#price and calling LineItem#set_pricing_attributes would do it as well -

def set_pricing_attributes
self.cost_price ||= variant.cost_price
self.money_price = variant.price_for_options(pricing_options)&.money if price.nil?
true
end

Additional context

@mickenorlen would you be up to make a PR related to this?

Slack Discussion

User Story:
The client updated the product price a couple of months back. Many orders have bought the product at new price. But all of a sudden there is a customer that buys the product with the old price. This has been reported twice now. What could be the issue here? Are old prices stored somewhere in the application or is it something to do with client specific caching who maybe loaded the product before the price change?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions