nopSolutions / nopCommerce

ASP.NET Core eCommerce software. nopCommerce is a free and open-source shopping cart.
https://www.nopcommerce.com
Other
9.22k stars 5.29k forks source link

Discount requirement #7178

Closed mhmd7776 closed 4 months ago

mhmd7776 commented 5 months ago

nopCommerce version: 4.70

Steps to reproduce the problem: Discount requirement does not save and display correctly.

AndreiMaz commented 5 months ago

@mhmd7776 What exactly discount requirement are you testing? It works fine on our demo website - https://admin-demo.nopcommerce.com/

mhmd7776 commented 5 months ago

@AndreiMaz For example (Must be assigned to customer role) I created a sample discount in demo site like this

1

when i select discount requirement type on (Must be assigned to customer role) and choose vendors option, it say (Discount requirement saved) and every thing must be fine but the selected requirement is empty and actually not saved.

2

mhmd7776 commented 5 months ago

@AndreiMaz I checked the problem further. The discount requirement is saved correctly, but it is not displayed because it's cached. We have to clear the cache manually every time

danFbach commented 4 months ago

Do you have prices cached in Catalog Settings? image

I can confirm that having this enabled with Customer Role based discount rules that the prices become inaccurate. As stated in the hint - "Check to cache product prices. It can significantly improve performance. But you not should enable it if you use some complex discounts, discount requirement rules, or coupon codes." @AndreiMaz (this text should probably be rewritten as it contains typos.) maybe to "Check to cache product prices. It can significantly improve performance, but you should not enable it if you use some complex discounts, discount requirement rules, or coupon codes."

I personally live with the occasionally wrong prices because my site becomes really slow with it disabled and then have my Cache clearing task set to run hourly to try and mitigate it better. I have many compounding factors. Lots of grouped products, so when a category page is loaded, it is loading sometimes 200+ product prices to get the grouped product "From" price.

I started refactoring the Pricing cache service so that the cache key included any applied discounts ids, and if someone has a coupon applied to their cart then just ignore the cache and load prices fresh, but never finished the work.

skoshelev commented 4 months ago

Hi @mhmd7776. By default, the discount edit page does not apply any caching to requirements. I can't reproduce the problem either locally or on the demo site. Perhaps you have some kind of plugin that changes the caching behavior or have made some custom edits to the code