Using a tieredpricing user in the admin leads to wrong prices.

Issue #1282 resolved
Eric Bartels created an issue

If you're using tiredpricing module and you log into the admin with a User that is in a tiered pricing Group, then edit a Configurable Product or a Variation, you wind up with the discounted tier price stored in the ProductPriceLookup table.

This means the site displays the discounted price to all users viewing the product detail page, and a doubly discounted price for tieredpricing users.

This seems to be because ProductPriceLookup.create_for_* calls 'get_qty_price_list' which uses the 'dynamic_price', and sends the 'satchmo_price_query' signal. So the tiered price for the logged in user is erroneously added to the lookup table.

Comments (5)

  1. Eric Bartels reporter

    It looks to me like the 'dynamic_price' should not be used when saving prices to the lookup table. So the error stems from the ProductPriceLookup.create_for_* methods calling 'get_qty_price_list' which returns the adjusted 'dynamic_price'. I'm not familiar enough with the codebase to know if there is any reason why the adjusted price would need to be stored in the price lookup table, but so far I'm not seeing any. It looks like dynamic price adjustments are done again when displaying on the site or creating cart/order items.

    So if that's correct, a possible solution would be to add something like a "dynamic=True" argument to the 'get_qty_price_list' methods. If False, then they would return the list of qty/prices without any adjustments. This could then be used in the ProductPriceLookup.create_for_* methods. This should be backwards compatible with any other callers of those methods that are expecting the usual adjusted price. Does this sound like a reasonable solution?

  2. Chris Moffitt repo owner

    Sounds like a reasonable approach. Feel free to work on a patch if you're up to it.

  3. Hynek Cernoch

    Bruce wrote about tiered price:

    "IIRC, the tiered price *should not* apply to admin. Otherwise it could affect the prices you see in the admin pages."

    So, a patch is much more easier: To ignore tiered pricing if a user is superuser or staff and has been added by mistake to a group with a pricing tier and to note it in docs.

    It is easy to create other unprivileged user account for testing or shopping. Every admin usually has more then one web browser and user account.

    Test: 45b6240f0ed6

    Fix: aa4b6f571d83

    It fixes also a possible bug applying the same discount multiple times if the module is imported repeatedly. This probably requires some rare configuration. It can be intentionally reproduced if Satchmo is accessible by multiple paths e.g. by a symbolic link.

  4. Log in to comment