Okay
  Public Ticket #3705725
Custom Prices and WPML
Closed

Comments

  •  2
    Lasse started the conversation

    Hi,

    We have a shop that uses B2BKing to control custom prices for logged-in users. This works perfectly. However, they also run WPML, and when a custom price is set, WPML overrides the custom pricing set by B2BKing.

    How can I make it so that when a user is logged in, they get the B2BKing price, and when they are not logged in and are on the Swedish version of the site, they get the normal price? In short, I just need B2BKing to always apply and only show the custom price from WPML if a user is not logged in.

    Attached files:  Skærmbillede 2024-08-15 151133.png

  •   WebWizards replied privately
  •  2
    Lasse replied

    Hi, I just testet it and unfortunatly it does not work. I think WPML is causing some trouble. When the user is not loged in, the see the "standard" price and not the WPML price. We also need to think about b2c customers with at profile. 

    In the script as i read it, all logged in, does not need to se the wpml price, but it's possible to have a customer in another contry, with the price from wplm. 

    I hope i makes sense - I can provide you with a login to the site if that will be of help.

  •  2
    Lasse replied

    Also a side thing - after i updated to the version you send. I get a Critical Error on the site, when i try to log in

  •  2,281
    WebWizards replied

    Hi again,

    In the script as i read it, all logged in, does not need to se the wpml price, but it's possible to have a customer in another contry, with the price from wplm. 

    It would help if you can please give more details on this. Which price should users get in the following scenarios?

    - Logged in B2B user DK

    - Logged in B2B user SE

    - Logged in B2C user DK

    - Logged in B2C user SE

    - Logged out user DK

    - Logged out user SE



    I hope i makes sense - I can provide you with a login to the site if that will be of help.

    That would be great. I am also not sure whether there's any other plugin / code / setting affecting things, so it would help to check directly. 

    We could also work on a staging clone site if it's easier that way (many hosting companies offer a feature to create a staging / dev site).

    I can also check the login issue that way.


    Kind regards,

    Stefan


  •  2
    Lasse replied

    Hi Stefan,

    Sorry for the long response time. 

    - Logged in B2B user DK | The one defined by b2bking

    - Logged in B2B user SE | The one defined by b2bking

    - Logged in B2C user DK | Standard price

    - Logged in B2C user SE | Standard price

    - Logged out user DK | Standard price

    - Logged out user SE | WPML price


    Regarding user; what mail should i grant access?

  •  2,281
    WebWizards replied

    Thank you for clarifying,

    I will try to set this up as you described it, through a code snippet.

     

    Please use our email at [email protected] for the account

  •   WebWizards replied privately
  •  2,281
    WebWizards replied

    Hi again,

    I logged into the site now and looked into this. I made an update to B2BKing that allows the code snippet I shared previously to work correctly.

    Then I tested with the following product: https://mbtshop.dk/wp-admin/post.php?post=12516&action=edit&lang=da&admin_bar=1

    When testing I see the following:

    https://www.loom.com/share/9be6ecb876e1446483c3c83b8024790f?sid=3871cf74-5f57-499c-8760-cc74c3b08889

    As B2B:

    • DK price: 80 (ex vat)
    • SK price: 80 (ex vat) 

    These are the B2BKing group prices as set on the product page, so I believe this is correct. WPML prices are not applying.

    As B2C:

    • DK price: 100 ( = 80 + vat)
    • SK price: 150 ( = 120 wpml price + vat)

    So I believe this is also correct, as WPML prices are now applying for the B2C user.

     

     

    For these cases:

    - Logged in B2C user DK

    - Logged in B2C user SE

    - Logged out user DK 

    - Logged out user SE

    Here B2BKing is not affecting the price in any way, so it would just give the prices as DK 100 and SK 150. Not entirely sure if you need this different.

     

    Let me know your thoughts please,

     

  •  2
    Lasse replied

    Hi, 

    Sorry to reopen - but after a long wait, the customer returned. They say: 

    When I log in as a Swedish B2B customer and in Swedish, I still get the Danish B2C prices ex VAT.

  •  2,281
    WebWizards replied

    Hi again,

     

    -> I'm not completely sure if I understand it correctly, it would help if we could look at an example of the issue.

    Are they basically saying that for example they're viewing a product as follows as a B2B user, and expecting to see the B2B price (90), but instead they get the B2C price (80) ?

    5887089142.png

     

    I think the problem may have to do with caching. I would suggest to try clearing all Litespeed caches + also try saving the product / changing product prices which usually clears caches.
     
     
    I looked into it on the site but could not really reproduce the issue. It would help a lot if they can share a specific example / product where they see the issue, and an explanation of the price they expect to see vs. what they see.
  •  2
    Lasse replied

    Just disabled caching and it still does not work. As written by you earlyer: 

    https://mbtshop.dk/wp-admin/post.php?post=12516&action=edit&lang=da&admin_bar=1

    As B2B:

    • DK price: 80 (ex vat)
    • SK price: 80 (ex vat) 

    These are the B2BKing group prices as set on the product page, so I believe this is correct. WPML prices are not applying.

    As B2C:

    • DK price: 100 ( = 80 + vat)
    • SK price: 150 ( = 120 wpml price + vat)

    So I believe this is also correct, as WPML prices are now applying for the B2C user.


    For these cases:

    - Logged in B2C user DK

    - Logged in B2C user SE

    - Logged out user DK 

    - Logged out user SE


    The price is still not the one - 

    • SK price: 150 ( = 120 wpml price + vat)


  •  2,281
    WebWizards replied

    I did various tests but I cannot reproduce the issue: https://www.loom.com/share/79cb5429b89d49feade675651997c155?sid=d92fa0fb-9399-4ddd-be86-886ab0315e08 (in the video I try switching the user from B2B to B2C, and then back to B2B again, and then I also tried as a logged user in incognito. Prices always seem to be 80 for B2B and then 100 or 150 for B2C).

     

    If you see this kind of issue again, please try adding the product to cart, to see if the price is correct in cart or not. Even if the product page prices are showing a cached display, the cart should normally have the correct prices.

  •  2
    Lasse replied

     Customer send me this - and says it's still not correct

    User

    Language: Danish

    Language: Swedish

    B2C (not logged in)

    Danish B2C price incl VAT - Correct

    Swedish B2C price incl VAT - Correct

    B2C (logged in)

    Danish B2C price incl VAT - Correct

    Swedish B2C price incl VAT - Correct

    B2B SE/NO Forhandler (Swedish B2B customer)

    SE – Forhandler Price exl VAT - correct

    Danish B2C price exl VAT – Not correct – Should be same as with Danish language

    B2B DK Forhandler (Danish B2B customer)

    DK – Forhandler price exl VAT – Correct

    Swedish B2C price exl. VAT – Not correct – Should be same as with Danish Language

    B2B FIN Forhandler (Finish B2B customer)

    FIN – Forhandler price exl. VAT - Correct

    Swedish B2C price exl. VAT – Not correct – Should be same as with Danish Language

    B2B NO Forhandler (Norwegian B2B customer)

    NO – Forhandler price exl. VAT - Correct

    Swedish B2C price exl. VAT – Not correct – Should be same as with Danish Language

  •  2,281
    WebWizards replied

    I cannot reproduce the issue.

    I created a test product here (hidden from catalog): https://mbtshop.dk/wp-admin/post.php?post=14590&action=edit&lang=da with different prices for each level:

    5452456654.png

    When logged in as a B2B user I always see the same price in Danish as in Swedish, I tried with various B2B groups: https://www.loom.com/share/9fb3f593ef374d59ab06e6b249a33c44?sid=3b6a91b9-ac5b-43fe-96b2-71e8f95e5f41

     

    I am not sure why the client sees something else. Please ask the client, if / when they see this issue, please try adding the item to cart to see if the price in cart is also incorrect, or just the price on the product page is incorrect. It would at least give us some important information to understand if it's a kind of caching or display issue, or an actual calculation problem (as usually the price in cart is the real price).