I need assistance to correctly configure the product query for our Bulk Order Form (Cream theme) on 'my account' page:
Our catalog has a specific architecture that is causing the form to filter out the wrong products. Here is the detailed breakdown of our logic:
1. Product Catalog Structure:
Simple Products (The "Children"): These are the only real products. They have stock and prices. However, their Catalog Visibility is set to "Hidden" because we do not want them to appear individually in the main shop.
Grouped Products (The "Parents"): These are merely "Containers". They have no price and no stock. They are "Visible" in the catalog only to serve as a landing page where users can buy the simple products.
Purchasability: In our store, a product is purchasable if it is a Simple Product with price and stock, regardless of its visibility settings. Currently, these simple products are purchasable from the Grouped product page without issues, but B2BKing is hiding them from the Bulk Order Form.
2. Required Behavior for B2BKing Forms:
We need the Bulk Order Form to perform a "switch" in its default logic:
EXCLUDE Grouped Products: Since they have no price or stock, they should not appear in the form as they confuse the user and cannot be added to the cart.
INCLUDE Simple Products: The form must show all Simple products, even if they are marked as "Hidden" in WooCommerce catalog visibility, as long as they have a price and are published.
Current Issue:
The form is currently doing the opposite: it shows the Grouped (parent) products and hides the Simple (child) products. When we try to force visibility via pre_get_posts or b2bking_allow_all_orderform, we either get no results or we see the Grouped products again, which results in "Add to cart" errors.
Question:
What is the correct way to hook into the B2BKing Bulk Order query to:
Force the inclusion of hidden Simple products?
Explicitly exclude all grouped products?
I am looking for a snippet or a specific filter (like b2bking_bulkorder_query_args) that can bypass the core visibility checks for this specific form. To resolve this, we have attempted several programmatic approaches without success. We tried modifying the query via pre_get_posts to explicitly exclude the 'grouped' product type and remove product_visibility restrictions from the tax_query. We also utilized the b2bking_bulkorder_query_args filter to force visibility => 'all' and clear any meta_query related to catalog visibility. Additionally, we enabled the b2bking_allow_all_orderform hook as suggested in your documentation. Despite these efforts, the form continues to prioritize WooCommerce's catalog visibility over the actual availability of the Simple products, either ignoring them in search results or only displaying the empty Grouped containers
I've looked into this and I believe I have a code snippet that can achieve it. Please try adding this snippet to your theme's functions.php or any code snippets plugin:
This should include the hidden simple products while excluding the grouped (parent) ones from the Bulk Order Form. Please give it a try and let me know how it goes.
Hi B2BKing Support Team,
I need assistance to correctly configure the product query for our Bulk Order Form (Cream theme) on 'my account' page:
Our catalog has a specific architecture that is causing the form to filter out the wrong products. Here is the detailed breakdown of our logic:
1. Product Catalog Structure:
2. Required Behavior for B2BKing Forms: We need the Bulk Order Form to perform a "switch" in its default logic:
Current Issue: The form is currently doing the opposite: it shows the Grouped (parent) products and hides the Simple (child) products. When we try to force visibility via pre_get_posts or b2bking_allow_all_orderform, we either get no results or we see the Grouped products again, which results in "Add to cart" errors.
Question: What is the correct way to hook into the B2BKing Bulk Order query to:
I am looking for a snippet or a specific filter (like b2bking_bulkorder_query_args) that can bypass the core visibility checks for this specific form.
To resolve this, we have attempted several programmatic approaches without success. We tried modifying the query via pre_get_posts to explicitly exclude the 'grouped' product type and remove product_visibility restrictions from the tax_query. We also utilized the b2bking_bulkorder_query_args filter to force visibility => 'all' and clear any meta_query related to catalog visibility. Additionally, we enabled the b2bking_allow_all_orderform hook as suggested in your documentation. Despite these efforts, the form continues to prioritize WooCommerce's catalog visibility over the actual availability of the Simple products, either ignoring them in search results or only displaying the empty Grouped containers
Thank you for your time and expertise.
Hi there,
Thanks for reaching out,
I've looked into this and I believe I have a code snippet that can achieve it. Please try adding this snippet to your theme's functions.php or any code snippets plugin:
add_filter( 'b2bking_hide_orderform_hidden_catalog_search', '__return_false', PHP_INT_MAX ); add_filter( 'b2bking_allow_all_orderform', '__return_false', PHP_INT_MAX ); add_filter( 'b2bking_orderform_product_ids_before_processing', function ( $product_ids ) { if ( empty( $product_ids ) || ! is_array( $product_ids ) ) { return $product_ids; } foreach ( $product_ids as $index => $product_id ) { $product = wc_get_product( $product_id ); if ( $product && $product->is_type( 'grouped' ) ) { unset( $product_ids[ $index ] ); } } return array_values( $product_ids ); }, PHP_INT_MAX );This should include the hidden simple products while excluding the grouped (parent) ones from the Bulk Order Form. Please give it a try and let me know how it goes.
Kind regards,
Stefan
Hi Stefan!
The snippet you gave me seems to have solved the problem!
Thank you for your excellent service!
Glad to hear that solved it! If we can help with anything else, please reach out anytime!
By the way, if you have a moment, we'd really appreciate it if you considered leaving a quick rating for the plugin - it's a big help.
Kind regards,
Stefan