the website I'm working on has a custom cart (not the woocommerce cart but a cart written using wordpress & woocommerce shortcodes) so I need B2B shortcode to check if a logged-in user is a B2B user and the shortcodes to take the "B2B Users Regular Price" and the "B2B Users Sales Price" from the product page of a product. Could you send me these shortcodes?
The current custom cart of the website show to users a list of products (the user can add to the cart) and the cart summary. I would like to detect, with a php function/code that I can use in the php page code, if a user is a B2C user or a B2B user so I can show the right list of product to both. I also need a php code to take the price for B2B product from its Wordpress product page ("B2B Users Regular Price" and "B2B Users Sales Price"). Thank you :)
In terms of showing / getting B2B pricing: I guess you're currently seeing the wrong price in the cart?
If you can edit the code of the cart, it should work by simply using $product->get_price(); (our plugin filters such functions, so it should automatically show the correct price to the current user, depending on the current user's group).
Are you the developer of the site / cart?
I would like to detect, with a php function/code that I can use in the php page code, if a user is a B2C user or a B2B user so I can show the right list of product to both.
To detect if the current user is B2C or B2B, you can use this code:
$user_id = get_current_user_id();
$is_b2b = get_user_meta($user_id,'b2bking_b2buser', true);
if ($is_b2b === 'yes'){
// this user is B2B
} else {
// this user is B2C
}
thank you for your replies, the codes worked perfectly (the "product visibility" and the "category visibility" features work on "bulk order" section in "My Account" page but not in menu and cart pages, where I have successfully tested your codes). I work on the cart page that was originaly developed by the previous developer.
Another question: I would like to detect, with a php function/code that I can use in the php page code, the discount applied to the cart when a B2Bking "dynamic rule" is applied because I have a cart summary in the cart page and I would like to show to the B2B user the total of the cart included all the discount applied on it (like in the checkout page). Could you help me?
but not in menu and cart pages, where I have successfully tested your codes
Have you already enabled the 'Product Visibility Cache' setting? This setting enables the visibility at a deeper level - that's why I thought maybe it can make the visibility work in menu / cart as well,
Another question: I would like to detect, with a php function/code that I can use in the php page code, the discount applied to the cart when a B2Bking "dynamic rule" is applied because I have a cart summary in the cart page and I would like to show to the B2B user the total of the cart included all the discount applied on it (like in the checkout page). Could you help me?
If you are looking to get the total before and after the discount, I believe you can use:
I don't have a very good way to get the discount from the dynamic rule applied - this is calculated across hundreds of lines of code so I don't know how we could get it quickly.
I have enabled the 'Product Visibility Cache' setting but it didn't work in the cart page and in the menu page, maybe because of their customization, but I solve the problem with codes you gave me :)
I don't have a very good way to get the discount from the dynamic rule applied - this is calculated across hundreds of lines of code so I don't know how we could get it quickly.
Hi,
the website I'm working on has a custom cart (not the woocommerce cart but a cart written using wordpress & woocommerce shortcodes) so I need B2B shortcode to check if a logged-in user is a B2B user and the shortcodes to take the "B2B Users Regular Price" and the "B2B Users Sales Price" from the product page of a product. Could you send me these shortcodes?
Thank you & Kind regards.
Sorry, I would like to better explain my needs.
The current custom cart of the website show to users a list of products (the user can add to the cart) and the cart summary. I would like to detect, with a php function/code that I can use in the php page code, if a user is a B2C user or a B2B user so I can show the right list of product to both. I also need a php code to take the price for B2B product from its Wordpress product page ("B2B Users Regular Price" and "B2B Users Sales Price"). Thank you :)
Hi there,
Thank you for purchasing our plugin!
In terms of showing / getting B2B pricing: I guess you're currently seeing the wrong price in the cart?
If you can edit the code of the cart, it should work by simply using $product->get_price(); (our plugin filters such functions, so it should automatically show the correct price to the current user, depending on the current user's group).
Are you the developer of the site / cart?
I would like to detect, with a php function/code that I can use in the php page code, if a user is a B2C user or a B2B user so I can show the right list of product to both.
To detect if the current user is B2C or B2B, you can use this code:
I also want to let you know that you may be able to use the plugin's "product visibility" feature, to hide / show products depending on whether the user is B2C, B2B, etc. For more info on that: https://woocommerce-b2b-plugin.com/docs/faq-product-visibility-is-not-working-how-to-set-up-product-visibility/
If you do use that feature, you should go to B2BKing -> Settings -> Other and enable 'Product Visibility Cache'.
Kind regards,
Stefan
Hi :),
thank you for your replies, the codes worked perfectly (the "product visibility" and the "category visibility" features work on "bulk order" section in "My Account" page but not in menu and cart pages, where I have successfully tested your codes). I work on the cart page that was originaly developed by the previous developer.
Another question: I would like to detect, with a php function/code that I can use in the php page code, the discount applied to the cart when a B2Bking "dynamic rule" is applied because I have a cart summary in the cart page and I would like to show to the B2B user the total of the cart included all the discount applied on it (like in the checkout page). Could you help me?
Thank you & kind regards.
but not in menu and cart pages, where I have successfully tested your codes
Have you already enabled the 'Product Visibility Cache' setting? This setting enables the visibility at a deeper level - that's why I thought maybe it can make the visibility work in menu / cart as well,
Another question: I would like to detect, with a php function/code that I can use in the php page code, the discount applied to the cart when a B2Bking "dynamic rule" is applied because I have a cart summary in the cart page and I would like to show to the B2B user the total of the cart included all the discount applied on it (like in the checkout page). Could you help me?
If you are looking to get the total before and after the discount, I believe you can use:
I don't have a very good way to get the discount from the dynamic rule applied - this is calculated across hundreds of lines of code so I don't know how we could get it quickly.
I have enabled the 'Product Visibility Cache' setting but it didn't work in the cart page and in the menu page, maybe because of their customization, but I solve the problem with codes you gave me :)
I don't have a very good way to get the discount from the dynamic rule applied - this is calculated across hundreds of lines of code so I don't know how we could get it quickly.
I will use the functions you recommended. :)
Thank you, Kind regards.
Have a great Day.