Developer forum

Forum » Development » B2B and B2C prices

B2B and B2C prices

Tomas Gomez
Reply

Hi,

we have a requirement for sale agents. They want to have an option (e.g. checkbox) to switch between "Business mode" (to see the website as sale agents, with B2B prices) and "Shop mode" (to show the website to their clients, with B2C prices). The prices will be different all along the website: in the product info, in the orders, quotes, etc.

Which is the best/simple way to achieve this feature? We consider to use a session cookie to store the mode (and to read it every time that is needed), or to use impersonation to get the different prices. 

Do you have any suggestions?

Regards,
Tomas


Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Tomas,

 

If there is no checkout, there are a number of ways you can do this.

  • Custom field for B2B or B2C and then add the logic on the template based on the checkbox/sessionStorage value
  • Impersonation is another way to do it, but more complex if this is all you have to do

 

If you need Checkout:

  • Impersonation has some advantages, but requires all users in B2C.
    If it's just for display purposes, don't use impersonation
  • You can use Prices (used to be called Price Matrix)
    • Set the default price to B2C and the B2B price in Prices for the B2B/logged in users
    • In the template you can get the regular price with the DBPrice tag
    • Then use some template logic to show/hide the appropriate price
    • When you add the product to the cart, DW should honour the amount in Prices (assuming it's lower than the default price)

 

We also use this techique to display old price with a strikethrough in some projects.

 

Best Regards,

Nuno Aguiar

 
Tomas Gomez
Reply

Thanks, Nuno !

Yes, we need checkout, so impersonation is the best option, thanks to point it.

About prices, AFAIK the Price Matrix is defined per product, while a PriceProvider could handle all the products at once. This way, a PriceProvider seems a better option for large catalogues of products. Do you think so?

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply
This post has been marked as an answer

Hi Tomas,

 

I just wanted to make sure you understood that you don't have to use impersonation. If you don't have a complex set of data or users and/or no need to track orders associated with the B2C user, then you don't need the extra layer of complexity, you can just use Prices.

 

As for the Price Matrix and PriceProvider, I guess it really depends on how you the data and how seemless you want that data to look in DW. Assuming there's no Live Integration to get the B2B prices, I am a fan of seeing the data in the UI for a number of reasons. That being the case, having batch integration to populate the Price Matrix has a ton of benefits:

  • No custom code - (no Price Provider)
  • Visual data - Price Matrix UI
  • DW handles the prices and all of the logic

 

If you need to programatically get the prices (Live Integration or otherwise) a PriceProvider is the way to handle it. I am not an expert doing that though, so I can't speak a lot more into it, sorry.

 

Best Regards,

Nuno Aguiar

Votes for this answer: 1
 
Tomas Gomez
Reply

Thanks for the clarifications!

So, to put all together, the steps could be:

  • Create a frontend checkbox that stores the "B2C mode" in a session cookie.
  • Extend the Price Matrix with a new field "B2C mode" (i.e. a new column in EcomPrices table), to store the B2C price for when in B2C mode.
  • Create a PriceProvider that, in case the cookie=TRUE and the Price Matrix has a B2C price, return the B2C price.

I think this should do it, don't you?

Regards,
Tomas

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply
This post has been marked as an answer

HI Tomas,

 

No it's much simpler than that:

  1. Create a frontend checkbox that stores the "B2C mode" in a session cookie.
  2. In the Price Matrix store the B2B price associated with the user group all B2B users belong to
  3. The products price field (https://doc.dynamicweb.com/documentation-9/ecommerce/product-catalog/products#2781 - field #5) stores the B2C price

 

You can use the regular Ecom:Product.Price tag that will give you the B2B price when the B2B user is logged in, and the B2C if anonymous. To consistely ge tthe B2C price you can use the Ecom:Product.DBPrice tag.

In the template (Razor or JS) just determine to show either one or the other depending on your session cookie/storage/variable. Something like this pseudo-code:

 

var mode = GetStoreMode(); /* The logic to get the session value */

If (mode == "B2CStore" && GetString("Ecom:Product.DBPrice") != GetString("Ecom:Product.Price")) {

    <<strike>GetString("Ecom:Product.DBPrice")</strike>

}

GetString("Ecom:Product.Price")

 

Best Regards,

Nuno Aguiar

Votes for this answer: 1
 
Tomas Gomez
Reply

Yes, that's much simplier! It's better to use the Price Matrix just to store the prices and let the logic be done externally (by a template or by a PriceProvider, upon the case).

Thanks again... and happy xmas!!
Tomas

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

You're welcome

Have a merry christmas too

 

You must be logged in to post in the forum