Skip to content

Price list and user group feature#24

Closed
JustShah wants to merge 15 commits into
mainfrom
price-list-and-user-group-feature
Closed

Price list and user group feature#24
JustShah wants to merge 15 commits into
mainfrom
price-list-and-user-group-feature

Conversation

@JustShah

@JustShah JustShah commented Apr 9, 2025

Copy link
Copy Markdown

This is a combined PR for Price list and user group feature

contains the changes from:

  1. Add user groups and automatically associate users to groups upon signup: Add user groups and automatically associate users to groups upon signup #20
  2. Add price list and price list items: Add price list and price list items  #21
  3. Restrict pricelist price update from product page: Restrict pricelist price update from product page #22
  4. Implement User Group Pricing with Price Selector: Introduce User Group Pricing to the price selector Price Selector #23

JustShah added 14 commits April 9, 2025 15:35
Added associations in Spree::User model for user groups to support grouping users for targeted pricing and management.
Created Spree::UserGroup model with associations to users and stores to enable flexible user group management.
Updated locale files to include translations for user groups.
Added migrations to create spree_user_groups table and add user group references to users and stores.
- Added UserGroupsController to manage user groups.
- Created views for user group management, including:
  - New user group form (`new.html.erb`)
  - User group edit form (`edit.html.erb`)
  - User group index view (`index.html.erb`)
  - Partial view for user group form fields.
- Enhanced user management by allowing assignment of user groups to users in the user form.
- Updated store form to include a selection for the default cart user group.
- Added breadcrumb navigation for improved user experience in the admin panel.

This feature allows administrators to create, edit, and manage user groups, facilitating better organization and access control for users within the Spree application.
- Created a new users sub-menu partial to manage user-related navigation, including links to users and user groups.

These enhancements improve the organization of the admin interface, making it easier for administrators to manage user groups effectively.
- Updated UsersController to assign the default user group to new users if the current store has the `enforce_group_upon_signup` setting enabled.
- Added a checkbox in the store settings form to allow administrators to enable or disable the `enforce_group_upon_signup` feature.
- Included a new translation key for the `enforce_group_upon_signup` label in the English locale file.

This feature ensures that all new users are automatically added to a specified user group, improving user management and organization within the Spree application.
- Introduced `Spree::PriceList` model to manage collections of prices associated with specific user groups and countries.
- Added optional association for `price_list` on `user_group`
- Created `Spree::PriceListItem` model to establish a many-to-many relationship between prices and price lists.
- Updated `Spree::Price` model to include associations with price lists through price list items.
- Added `contain_taxes` attribute to the `Spree::Price` model to indicate whether prices include taxes.
- Implemented validations for the new models to ensure data integrity.
- Added necessary database migrations to create price lists and price list items tables.

These changes enhance the pricing structure by allowing for more flexible pricing strategies based on user groups and geographical considerations.
- Introduced PriceListsController to handle price list operations.
- Created views for managing price lists, including:
  - New price list form (`new.html.erb`)
  - Price list edit form (`edit.html.erb`)
  - Price list index view (`index.html.erb`)
  - Partial views for price list form fields and price list information.
- Implemented form fields for name, country, currency, and tax inclusion.
- Added functionality to display price details associated with each price list.
- Included breadcrumb navigation for better user experience in the admin panel.

This feature allows administrators to create, edit, and manage price lists effectively, enhancing the overall product pricing strategy.
- Introduced PriceListItemsController to handle price list item operations.
- Created views for managing price list items, including:
  - New price list item form (`new.html.erb`)
  - Price list item edit form (`edit.html.erb`)
  - Partial view for price list item form fields.
- Implemented functionality to associate price list items with specific price lists and variants.
- Added support for entering price details, including amount, currency and taxes.
- Enhanced breadcrumb navigation for better user experience in the admin panel.

This feature allows administrators to create, edit, and manage price list items, facilitating more flexible pricing strategies for products within the Spree application.
- Updated product sub-menu to include a link to price lists if the user has admin permissions.
- Added routes for managing price lists and their associated price list items.
- Updated backend configuration to include price lists in the admin menu, ensuring proper access control based on user permissions.

These enhancements improve the organization of the admin interface, making it easier for administrators to manage price lists effectively.
This commits adds column on user group to display and select the associated price list
for a user group.
This commit adds a boolean is_pricelist_price to spree price model,
which can be used to identify whether the price has been created for price lists or
the price has been created from products section.
Implemented `check_pricelist_price` in variant API and price admin controllers to prevent the user from updating prices which are associated to a price list.
- Added a new localization key for the error message indicating that a price belongs to a price list and cannot be edited or deleted.
- Updated the master variant price table and the general price table in the admin interface to:
  - Prevent editing and deleting of prices that belong to a price list.
  - Display a message indicating the associated price lists for prices that are part of a price list.
- Added hidden field for is_pricelist_price to price list item form.
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.
@JustShah JustShah force-pushed the price-list-and-user-group-feature branch from f2dfdd5 to 31c6106 Compare April 10, 2025 10:15
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 price-list-and-user-group-feature branch from 31c6106 to 53d2201 Compare April 10, 2025 10:19
@JustShah

Copy link
Copy Markdown
Author

Created New PR #28

@JustShah JustShah closed this Apr 11, 2025
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