Public Ticket #4582814

Guest price

Closed
Comments
3 Tickets
Ilya started the conversation 4 weeks ago on September 10, 2026 at 10:27am

Hello,

We would like to implement a pricing display for Guests (unauthenticated users) on our website, similar to how pricing is currently displayed for B2B users (retail price and wholesale price).

For Guests, however, we would like to display two prices:

  • Your price — showing the price as it is currently displayed.
  • Price for registered users — showing the price available to B2C users after logging in.

Could you please advise how this could be implemented?

2,762
KingsPlugins replied 3 weeks ago on September 13, 2026 at 10:54pm

Hi Ilya,

Thanks for reaching out.

Yes, I believe this can be done with a code snippet,

 

To write it correctly, I need a few details about your setup:

- Do you have variable products, or only simple products?
- - If you do have variable products, do the variations have different prices, or do all variations of a product share the same price?
- Are your prices entered inclusive or exclusive of tax, and do guests currently see prices inc or ex tax?

Alternatively, if you prefer, I can look into this directly on the site. For that, I would just need a backend login to the site or a staging clone.

 

Kind regards,
Stefan

3 Tickets
Ilya replied 3 weeks ago on September 14, 2026 at 6:40am

Hello,

  • The products are different: both simple products and variable products.
  • In general, the prices for product variations are also different, although for some products the variation prices are the same.
  • The prices currently include VAT.

At the moment, I don't have a test website, but I am planning to set one up in the near future.

Perhaps you could provide some ideas on how this could be implemented, or possibly a code snippet that I could use to implement it myself. I think it would be a bad idea to make these changes directly on the live website.

I've simply run out of ideas on how to implement this, but this functionality is something we really need.

2,762
KingsPlugins replied 3 weeks ago on September 17, 2026 at 5:29pm

Hi Ilya,

Thanks for the details,

The biggest challenge here is the variable products. For those, the code needs to go through each variation, get its B2B price, and build the min-max price range from that. If a page has many products with many variations each, this can get performance intensive, so the prices also need to be cached.

I've written a snippet for you that tries to do this. It displays both prices for guests, caches the variable product prices, and clears the cache whenever a product is saved:

https://pastecode.io/s/63gby4ik

One thing you'll need to change: at the very beginning of the snippet, replace 1234 with the ID of your B2B group (since B2BKing can have different prices per group). To find the ID, go to B2BKing -> Groups, edit your group and check the URL - for example, if it shows ?post=123, then the ID is 123.

The snippet can be added to the functions.php file of your theme or through any code snippets plugin.

 

Because of the complexities here, this should be thoroughly tested on a staging site before using it on a live site,

Let me know if you run into any issues with it.

Kind regards,
Stefan

Sign In