Skip to content

Introduce User Group Pricing to the price selector Price Selector#23

Open
JustShah wants to merge 3 commits into
restrict-pricelist-price-edit-on-productfrom
16-consider-price-lists-in-the-price-selector
Open

Introduce User Group Pricing to the price selector Price Selector#23
JustShah wants to merge 3 commits into
restrict-pricelist-price-edit-on-productfrom
16-consider-price-lists-in-the-price-selector

Conversation

@JustShah

@JustShah JustShah commented Apr 9, 2025

Copy link
Copy Markdown

Summary

Overview:

This pull request introduces enhancements to the pricing system in the Spree application by implementing user group-specific pricing. The changes allow for dynamic price selection based on user groups, enabling more flexible and differentiated pricing strategies for various customer segments.

Key Changes:

  1. Price Selector by User Group:

    • Added the Spree::Variant::PriceSelectorByUser Group class, which is responsible for selecting the appropriate price for a product variant based on user group pricing options.
    • This class allows for user group-specific pricing by incorporating user group information along with other pricing factors such as country and currency.
    • The price selector can be configured in the Spree initializer:
      Spree.config do |config|
        config.variant_price_selector_class = 'Spree::Variant::PriceSelectorByUser Group'
      end
  2. Pricing Options with User Group:

    • Introduced the Spree::Variant::PricingOptionsWithUser Group class to define the necessary pricing attributes (currency, country, user group) for selecting prices.
    • This class provides a flexible way to manage pricing options that consider user groups, allowing for complex pricing models where different user groups may receive different pricing for the same product variant.
  3. New Scope in Price Model:

    • Added the without_pricelist scope to the Spree::Price model, enabling filtering of prices that are not associated with any price list.
    • This scope allows the system to differentiate between prices managed by price lists and standalone prices, facilitating more precise querying and filtering.

Benefits:

  • Enhances the pricing flexibility of the Spree application by allowing for user group-specific pricing.
  • Supports more complex pricing strategies tailored to different customer segments.
  • Improves the ability to manage and query prices effectively within the system.

@fthobe fthobe changed the title Implement User Group Pricing with Price Selector Introduce User Group Pricing to the price selector Price Selector Apr 9, 2025
@JustShah JustShah force-pushed the restrict-pricelist-price-edit-on-product branch from aaff3a6 to 5920ded Compare April 10, 2025 10:02
@JustShah JustShah force-pushed the 16-consider-price-lists-in-the-price-selector branch from f2dfdd5 to 7fd98de Compare April 10, 2025 10:05
@JustShah JustShah force-pushed the restrict-pricelist-price-edit-on-product branch from 5920ded to d98c8f2 Compare April 10, 2025 13:27
@JustShah JustShah force-pushed the 16-consider-price-lists-in-the-price-selector branch from 7fd98de to 913a236 Compare April 10, 2025 13:28
@JustShah JustShah force-pushed the restrict-pricelist-price-edit-on-product branch from d98c8f2 to fd0982d Compare April 10, 2025 14:38
@JustShah JustShah force-pushed the 16-consider-price-lists-in-the-price-selector branch from 913a236 to 241ef35 Compare April 10, 2025 14:39
@JustShah JustShah force-pushed the restrict-pricelist-price-edit-on-product branch from fd0982d to cb53a85 Compare April 11, 2025 05:07
@JustShah JustShah force-pushed the 16-consider-price-lists-in-the-price-selector branch from 241ef35 to bd89891 Compare April 11, 2025 05:08
@JustShah JustShah force-pushed the restrict-pricelist-price-edit-on-product branch from cb53a85 to 9a2d49a Compare April 11, 2025 10:38
@JustShah JustShah force-pushed the 16-consider-price-lists-in-the-price-selector branch from bd89891 to 4f039e0 Compare April 11, 2025 10:39
@JustShah JustShah force-pushed the restrict-pricelist-price-edit-on-product branch from 9a2d49a to b422769 Compare April 15, 2025 06:42
A new scope `without_pricelist` in the `Spree::Price` model to allow filtering of prices that are not associated with any price list.
The purpose of this change is to allow the system to differentiate between prices that are managed by price lists and those that are not.
This scope is useful for filtering and querying prices that should be treated as standalone (i.e., not tied to a price list).
…ptions

Introduced Spree::Variant::PricingOptionsWithUserGroup, a class that defines the
necessary pricing attributes (currency, country, user group) for selecting prices.
The reason for adding this class is to provide a flexible way
of defining pricing options that consider user groups,
alongside other factors such as country and currency.
By incorporating user group information into pricing options,
we can manage more complex pricing models where different user groups may receive different pricing for the same product variant.
The class Spree::Variant::PriceSelectorByUserGroup, which selects the appropriate price for a product variant
based on user group pricing options. The primary reason for this change is to allow for user group-specific pricing
by incorporating a class that can dynamically select the correct price based on user group and other pricing options
(such as country and currency). This facilitates the implementation of price differentiation for various customer segments.

The class can be used by setting
```
Spree.config do |config|
 config.variant_price_selector_class = 'Spree::Variant::PriceSelectorByUserGroup
end
```
in `config/initializers/spree.rb`
@JustShah JustShah force-pushed the 16-consider-price-lists-in-the-price-selector branch from 4f039e0 to e741a9d Compare April 15, 2025 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant