Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Anders Brohus 194 posts 475 karma points
    Sep 24, 2020 @ 12:35
    Anders Brohus
    0

    Same product - Difference prices

    Hi guys :)

    We are in the process where we are looking after a shop system which supports changing prices after which user is logged in :)

    So if we have Customer A, B, C they are showed three different prices

    Customer A sees a price of 10€ because he is a standard user Customer B sees a price of 5€ because he is in a "Big customer" group Customer C sees a price of 7,5 because he is in a "No tax" group :)

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Sep 24, 2020 @ 13:25
    Matt Brailsford
    100

    Hey Anders,

    I think this might be achievable by overriding the default IProductAdapter https://vendr.net/docs/core/1-3-0/key-concepts/product-adapters/ This is what is used to extract product information from Umbraco and convert it into a format Vendr can handle.

    I think you could override this, and more specifically the Price property on the ProductSnapshot such that it returns the price relative to the current member. For this to work you'd probably store multiple prices on the product node and then in your overridden product adapter return the price relevant to the current logged in member.

    I think the only potential downfall here would be this wouldn't affect prices of items already in their basket so say Anonymous person A goes to the site and adds an item to the cart at Price A, but then proceeds to log in and now is able to have that product at Price B, the price of the item in the cart wouldn't update. I think you could get around this though by "Thawing" the frozen prices for an active order when this happens https://vendr.net/docs/core/1-3-0/key-concepts/price-freezing/

    Hope this helps

    Matt

  • Rune Grønkjær 1371 posts 3102 karma points
    Jan 27, 2022 @ 15:05
    Rune Grønkjær
    0

    Hi Matt,

    I know this is a really old post, but it fits my scenario perfectly. My question is: How do you know which member is logged in in the custom ProductAdapter?

    As I see it the ProductAdapter is not context aware, and we don't have the order available, so we cannot use any stored information on that. I save the customer number on the order, but how do I get it here?

    /Rune

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jan 27, 2022 @ 15:18
    Matt Brailsford
    0

    Hi Rune,

    I guess in this context you would get the current member from the web session.

    The ProductAdapter is called when adding a product to the cart or when creating a snapshot to display prices on the front end (it's also used in a couple of places behind the scenes, but this is never to do with prices) so it should be fine to check the current web session to decide what prices to return. If it's being used in the back end, away from a web context, it should be safe to just return the regular price.

    Once a product is added to the cart, it's price is frozen in the cart, so there isn't a need for Vendr to keep recalculating the price and so when we show the order later, we don't need to continue to choose the right price.

    Hope this helps

    Matt

  • Rune Grønkjær 1371 posts 3102 karma points
    Jan 27, 2022 @ 15:45
    Rune Grønkjær
    0

    Thanks a bunch. I'll give it a go and see if it works.

    Have a great evening. /Rune

Please Sign in or register to post replies

Write your reply to:

Draft