I have the barn2 product tables plugin as well as b2bking wholesale - I have the product tables working as I need them for normal shop/category pages, but I would like to apply the same format to the b2bking offers (using real products)...I just need to know how to query whether there is an offer(s) available for the logged in user and list these in the same format
I understand that you'd like to display B2BKing offers using the Barn2 Product Table display.
I'm afraid I don't really see a simple / straightforward way to achieve that - the main issue is that these offers are not actual WooCommerce Products, instead they are just information saved in a database. Therefore to make this work I think we need a PHP code snippet to pull the data from the database, and then somehow display it using the Barn2 table.
We are happy to send some PHP code for pulling our plugin's offers information if it would help, but generally I believe you would need to work with a developer on a custom project in order to be able to display that info using the Barn2 table. I think their table might need some changes as well because I'm guessing their table is built to display products, but in this case the offers are not actual products.
Hi Stefan, thank you for your reply...in the b2bking settings, I have the option "Offers use actual products" selected, so I assume that means there is a link between the two somewhere...
If you could help in any way with a php code snippet to help me with the barn2 integration, and a little more guidance on how the frontend layouts are generated in b2bking, that would be fantastic!
I bought the barn2 plugin because of it's compatibility with your plugin because I needed customers to have a very quick shopping experience and (as they are chefs) are very particular. So, for them, it would make a lot more sense if all shopping tables (shop, offers, bulk order form etc) looked the same layout and styling wise.
Regarding the "Offers use actual products" setting: What this does is that it also adds the real products to the cart, as in this image:
There is the offer being purchased (at the top, 'sweater package'), and then the products inside the offer below. This helps to make sure that for example if the site has an ERP integration, this links correctly with that, as the real products are also in the actual order (although we give them the price of 0, so only the offer is being paid for).
The issue is with the main "offer" package product, as that is a 'helper / dynamic' product, that changes its price and name for each offer (rather than being an actual product that is distinct).
To make an integration with the Barn2 tables plugin, maybe we could do it based on the URL that B2BKing uses when clicking 'add to cart' on an offer - to take that same URL and add it to the Barn2 table.
This code gets all offers of the current user, displays them, and displays an "add to cart" button.
It results in this kind of output:
Now I am not sure if the Barn2 table has any way to display their table programmatically / with PHP, in a way that would allow us to integrate the above. If you have access to their support, it would be great if you could ask them about that.
I have a meat product where I have the minimum quantity set to zero and increments of 0.1 (we're selling by weight with this product, but that's not important). I had to set the minimum to 0 because when I put 0.1, om the front end it defaulted to 1.1. However, if you try to add 0.5 of the product to basket, for example, it says "Please enter a quantity greater than 0. "
I'd like to make sure I'm understanding it correctly: Are you looking to set this in B2BKing offers, or the B2BKing order form, or just generally for the site?
WooCommerce by default does not support quantities such as 0.1 so you would need a larger code snippet to enable that on your site in general. Do you already have something like a plugin or custom code for that, or is this what you're looking to implement right now?
I think we have some snippets we can share to help implement it in general on the site, but it would be great if you can let us know where you're at with it so far.
Generally for the site really...with the B2BKing plugin, it will allow me to enter a decimal quantity, but trying to add to cart, it doesn't like it...
It does several things to set the minimum / step to 0.1 (instead of 1 which is the default). It can also be changed to a lower value like 0.01 in the snippet if needed.
Do you still see any issues with that? If so, it would help if you can share details / screenshots. We can also work on this directly if you can help share a site or staging site login.
Thank you for this...it's now allowing me to add those decimal quantities, however, the mini cart and checkout seems to round the values to a whole number
Regarding rounding in the mini-cart/checkout, this is a bit hard to say. I am not quite sure if it's a theme behaviour, or related to the specific checkout used (e.g. blocks vs classic, or perhaps a theme checkout like the Divi ones).
Would it be possible to share a backend access to the site, or a staging clone site with us? It would be great if we could look at it on the site directly and try to tweak the snippet to get this to work perfectly.
At the moment there is an error in cart regardless of quantity:
The error is coming from line 24 here:
specifically related to this $product object not working (it has a 'false' value) here:
I see you have some custom code there using ACF. I am not sure what the goal there is.
For testing purposes, I did the following:
-> I activated the main theme instead of the child theme, to get around that error.
-> I added this snippet here (now deactivated): https://rjchefs2024.sagraphicswebproofs.co.uk/wp-admin/admin.php?page=wpcode-snippet-manager&snippet_id=5535
When testing that way, I can set decimal quantities, and I see they do not get rounded in cart or checkout:
Your response is appreciated, but it came a little late. I had resolved my issue with a workaround, however, I now have issues adding a particular item to cart which I didn't have before...it took 3 attempts to add Hickory Smoked Pork to the cart...no error messages on the frontend...just disappeared until "third time lucky"
I have the barn2 product tables plugin as well as b2bking wholesale - I have the product tables working as I need them for normal shop/category pages, but I would like to apply the same format to the b2bking offers (using real products)...I just need to know how to query whether there is an offer(s) available for the logged in user and list these in the same format
Hi Sarah,
I understand that you'd like to display B2BKing offers using the Barn2 Product Table display.
I'm afraid I don't really see a simple / straightforward way to achieve that - the main issue is that these offers are not actual WooCommerce Products, instead they are just information saved in a database. Therefore to make this work I think we need a PHP code snippet to pull the data from the database, and then somehow display it using the Barn2 table.
We are happy to send some PHP code for pulling our plugin's offers information if it would help, but generally I believe you would need to work with a developer on a custom project in order to be able to display that info using the Barn2 table. I think their table might need some changes as well because I'm guessing their table is built to display products, but in this case the offers are not actual products.
Kind regards,
Stefan
Hi Stefan, thank you for your reply...in the b2bking settings, I have the option "Offers use actual products" selected, so I assume that means there is a link between the two somewhere...
If you could help in any way with a php code snippet to help me with the barn2 integration, and a little more guidance on how the frontend layouts are generated in b2bking, that would be fantastic!
I bought the barn2 plugin because of it's compatibility with your plugin because I needed customers to have a very quick shopping experience and (as they are chefs) are very particular. So, for them, it would make a lot more sense if all shopping tables (shop, offers, bulk order form etc) looked the same layout and styling wise.
Regarding the "Offers use actual products" setting: What this does is that it also adds the real products to the cart, as in this image:
There is the offer being purchased (at the top, 'sweater package'), and then the products inside the offer below. This helps to make sure that for example if the site has an ERP integration, this links correctly with that, as the real products are also in the actual order (although we give them the price of 0, so only the offer is being paid for).
The issue is with the main "offer" package product, as that is a 'helper / dynamic' product, that changes its price and name for each offer (rather than being an actual product that is distinct).
To make an integration with the Barn2 tables plugin, maybe we could do it based on the URL that B2BKing uses when clicking 'add to cart' on an offer - to take that same URL and add it to the Barn2 table.
I think we could start with the following code:
This code gets all offers of the current user, displays them, and displays an "add to cart" button.
It results in this kind of output:
Now I am not sure if the Barn2 table has any way to display their table programmatically / with PHP, in a way that would allow us to integrate the above. If you have access to their support, it would be great if you could ask them about that.
I have a meat product where I have the minimum quantity set to zero and increments of 0.1 (we're selling by weight with this product, but that's not important). I had to set the minimum to 0 because when I put 0.1, om the front end it defaulted to 1.1. However, if you try to add 0.5 of the product to basket, for example, it says "Please enter a quantity greater than 0. "
Hi Sarah,
Glad to assist,
I'd like to make sure I'm understanding it correctly: Are you looking to set this in B2BKing offers, or the B2BKing order form, or just generally for the site?
WooCommerce by default does not support quantities such as 0.1 so you would need a larger code snippet to enable that on your site in general. Do you already have something like a plugin or custom code for that, or is this what you're looking to implement right now?
I think we have some snippets we can share to help implement it in general on the site, but it would be great if you can let us know where you're at with it so far.
Kind regards,
Stefan
Generally for the site really...with the B2BKing plugin, it will allow me to enter a decimal quantity, but trying to add to cart, it doesn't like it...
Please try adding this PHP snippet to your site:
https://pastecode.io/s/ug1w2xdu
It does several things to set the minimum / step to 0.1 (instead of 1 which is the default). It can also be changed to a lower value like 0.01 in the snippet if needed.
Do you still see any issues with that? If so, it would help if you can share details / screenshots. We can also work on this directly if you can help share a site or staging site login.
Thank you for this...it's now allowing me to add those decimal quantities, however, the mini cart and checkout seems to round the values to a whole number
Regarding rounding in the mini-cart/checkout, this is a bit hard to say. I am not quite sure if it's a theme behaviour, or related to the specific checkout used (e.g. blocks vs classic, or perhaps a theme checkout like the Divi ones).
Would it be possible to share a backend access to the site, or a staging clone site with us? It would be great if we could look at it on the site directly and try to tweak the snippet to get this to work perfectly.
Kind regards,
Stefan
Thank you for the access details,
At the moment there is an error in cart regardless of quantity:
The error is coming from line 24 here:
specifically related to this $product object not working (it has a 'false' value) here:
I see you have some custom code there using ACF. I am not sure what the goal there is.
For testing purposes, I did the following:
-> I activated the main theme instead of the child theme, to get around that error.
-> I added this snippet here (now deactivated): https://rjchefs2024.sagraphicswebproofs.co.uk/wp-admin/admin.php?page=wpcode-snippet-manager&snippet_id=5535
When testing that way, I can set decimal quantities, and I see they do not get rounded in cart or checkout:
https://www.loom.com/share/474bd0b5305c4457954121de4fa6ff33?sid=30055bc7-5ed5-4fd1-aa84-84e6851f5e6f
Your response is appreciated, but it came a little late. I had resolved my issue with a workaround, however, I now have issues adding a particular item to cart which I didn't have before...it took 3 attempts to add Hickory Smoked Pork to the cart...no error messages on the frontend...just disappeared until "third time lucky"
Hi again,
Is this on a general shop page or product page? B2BKing does not control the add to cart process on these pages.
I would suggest to check your browser console for any errors during the add to cart.
It may also help to enable or disable AJAX add to cart: https://prnt.sc/Iy8KHRVtOhM6