A common question that comes up is if we support restricting products based on an "availability group" or can show different pricing based on a "price group". The short answer is "yes". There are a few different ways we can do it and I will outline a couple of them below.
The easiest way is to introduce a new field to your feed to support availability and/or price groups. Each availability group the product is assigned to would be comma separated in one field. Then additional fields would be created for each price group.
- Item XK49 is only available to groups 1 and 3. It's price is 4.99 for group 1 and 5.49 for group 3.
- Item JB23 is only available to group 1 and it's price is 12.99.
- Item PQ42 is available to all three groups. It's price is 9.99 for groups 1 and 3, and 8.99 for group2.
When executing a query, a predetermined background filter can be set to determine the customers availability and/or price group.
It is also possible to use a callback function to support multiple pricing, but not availability groups.
Use the filterData callback available in the Searchspring.Catalog.init options you can adjust the price shown. This can be done by creating a flat percentage or dollar amount discount for the current group or by including all group prices in a single price field in your data feed and extracting the price for the current group. JSON would probably be the best format for the latter option.
You could also use the afterResultsChange callback available in the Searchspring.Catalog.init options to make an AJAX request to your server to get the current price for the current user. This is probably the best way to handle group pricing when you're not dealing with a limited number of pricing groups.