Global widget that changes product prices

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
1 year ago
Hi there,

how would you implement in nop this: I need a global widget with several input fields. When user filled the inputs (integer values) and  ready he presses the "search" button and products list gets displayed and prices are dynamically adjusted based on the inputs from the widget.

thanks!
1 year ago
A widget is usually injected on a current view - Is there a view where you want to add it ?
Or maybe you just need a new view with the fields your require
The new view could just be the normal plugin configure page or you can add a new menu item

Then you search the products based on the criteria
_productService.SearchProductsAsync(...);

Then make the change to the price and save
var associatedProduct = await GetProductByIdAsync(...);
UpdateProductAsync(product);

Start with one of the existing admin plugins as a template
1 year ago
thanks you for the answer!

what I am trying to achieve is I want to get this widget displayed when user picks a category and the fields are required to be filled before any product can be shown/picked. A good example is when you try to sell  electricity contracts. Let me give you an example.

user selects "Electricity" category, and then he need to provide his zip code and estimated consumption, let's say he provided 2000 kw/h, then he presses "find" and  based on this values I need to show products only available in his area (based on the zip code value) and prices adjusted based on his "estimated consumption" value. But these prices changes are not permanent, user can always go back to the widget and change the values and press find again.
1 year ago
relusion wrote:
thanks you for the answer!

user selects "Electricity" category, and then he need to provide his zip code and estimated consumption, let's say he provided 2000 kw/h, then he presses "find" and  based on this values I need to show products only available in his area (based on the zip code value) and prices adjusted based on his "estimated consumption" value. But these prices changes are not permanent, user can always go back to the widget and change the values and press find again.


You can use Tier prices and use the "estimated consumption" as a condition (replace with quantity), which will require some customization.
1 year ago
thank you all for helping with this :)

let me go one level deeper,  there are no thresholds and possibly even not a  linear price change when user enters his energy consumption. i.e  I would need a dynamic formula based pricing "callback" that would take into account all of these factors. I have no problem extending nop commerce. I am a looking for an advice how should I do this architecturally.

Questions:
1. how to create a piece of UI and inject into the NOP layout. Currently the answer is "Widgets"
2. How would I then apply the input parameters of this widget to products price calculation?
   meaning: I need the widgets values(global scoped?) in a pricing callback? I am not sure how to implement this.
2a) The inputs in widgets are required before ised can even navigate into the available products. Not sure how to implement that.

thanks in advance!
1 year ago
There maybe other ways but in your case because you want to interact with the other componenets on the page  then one way is to go up a level and add extra fields to the model.
You already need to change the search for the products to use the new fields
Rather than the widget maybe you are better to make a new View which is a copy of the Current Category View with a new model that has extra fields
Later you can keep it as a seperate function and add it to the menu or use a Custom View Engine to load this new category view instead of the old one.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.