You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a feature to differentiate line items beyond only variant_id, useful if you add additional attributes to a line item that you want to make the same variant_id into a distinctive line item. However, that functionality is not extended into Spree::Stock::Coordinator.
Context
When using Spree::Order.register_line_item_comparison_hook to differentiate line items, on the delivery page of checkout, one of the line items will not be visible on the page because it won't be in the shipment. It isn't in the shipment because Spree::Stock::Coordinator "de-dupes" its InventoryUnits by index_by(&:variant_id), without taking into account additional comparators provided to spree via Spree::Order.register_line_item_comparison_hook.
Expected Behavior
When using Spree::Order.register_line_item_comparison_hook, line items are separate when those comparison hooks say they are separate, and are always treated as such. The checkout flow would always show 2+ items even for the same variant id on all pages when any hook has differentiated them.
Actual Behavior
The delivery page is missing items which have the same variant_id but which were treated as separate line items.
Possible Fix
All hooks provided to Spree::Order.register_line_item_comparison_hook should be taken into account in the Spree::Stock::Coordinator, so instead of simply doing index_of(&:variant_id) we should use the variant_id and use those comparators as well.
Additionally, Spree::Stock::Adjuster also will eliminate one of the line items with the same variant_id, because @adjusters is retained between InventoryUnits in Spree::Stock::Prioritizer, hashing by the result of hash_item(item) and again not taking into account things registered via Spree::Order.register_line_item_comparison_hook.
Steps to Reproduce
Add a line item comparator using Spree::Order.register_line_item_comparison_hook
Add two of the same variant_id to the cart, where the variants are differentiated based on a comparison hook you provided (for example, add my_custom_id to spree_line_items then add Spree::Order.register_line_item_comparison_hook(:same_custom_ids?)
Go through checkout to delivery page
Observe only one of the two line items you added listed
Your Environment
Version used: 3.4.4
The text was updated successfully, but these errors were encountered:
There is a feature to differentiate line items beyond only variant_id, useful if you add additional attributes to a line item that you want to make the same variant_id into a distinctive line item. However, that functionality is not extended into
Spree::Stock::Coordinator
.Context
When using
Spree::Order.register_line_item_comparison_hook
to differentiate line items, on the delivery page of checkout, one of the line items will not be visible on the page because it won't be in the shipment. It isn't in the shipment becauseSpree::Stock::Coordinator
"de-dupes" itsInventoryUnit
s byindex_by(&:variant_id)
, without taking into account additional comparators provided to spree viaSpree::Order.register_line_item_comparison_hook
.Expected Behavior
When using
Spree::Order.register_line_item_comparison_hook
, line items are separate when those comparison hooks say they are separate, and are always treated as such. The checkout flow would always show 2+ items even for the same variant id on all pages when any hook has differentiated them.Actual Behavior
The delivery page is missing items which have the same variant_id but which were treated as separate line items.
Possible Fix
All hooks provided to
Spree::Order.register_line_item_comparison_hook
should be taken into account in theSpree::Stock::Coordinator
, so instead of simply doingindex_of(&:variant_id)
we should use the variant_id and use those comparators as well.Additionally,
Spree::Stock::Adjuster
also will eliminate one of the line items with the same variant_id, because @adjusters is retained betweenInventoryUnit
s inSpree::Stock::Prioritizer
, hashing by the result of hash_item(item) and again not taking into account things registered viaSpree::Order.register_line_item_comparison_hook
.Steps to Reproduce
Spree::Order.register_line_item_comparison_hook
Spree::Order.register_line_item_comparison_hook(:same_custom_ids?)
Your Environment
The text was updated successfully, but these errors were encountered: