Conversation
supportHello B2BKing Support, we found a compatibility issue between B2BKing and WooCommerce (latest version) when manually creating a new order in the WooCommerce admin. When opening this WooCommerce admin URL: /wp-admin/admin.php?page=wc-orders&action=new the request is incorrectly redirected to: /wp-admin/edit.php?post_type=b2bking_group We debugged the redirect using a wp_redirect backtrace. The redirect is triggered here: /wp-content/plugins/b2bking-wholesale-for-woocommerce/admin/class-b2bking-admin.php:1638 B2bkingcore_Admin->b2bking_save_groups_metaboxes() The backtrace shows that WooCommerce creates/saves the new order via HPOS, then WooCommerce creates a backup post via wp_insert_post(), and during that process the B2BKing group metabox save handler is executed. Relevant call chain: WooCommerce PageController->setup_action_new_order() WC_Order->save() OrdersTableDataStore->maybe_create_backup_post() wp_insert_post() do_action() B2bkingcore_Admin->b2bking_save_groups_metaboxes() wp_redirect() So it looks like the B2BKing group metabox save handler is running during WooCommerce order creation, although it should only run for the B2BKing group post type. As a temporary workaround, we solved the issue by blocking only this specific wrong redirect with the following snippet: add_filter('wp_redirect', function ($location, $status) { $request_uri = $_SERVER['REQUEST_URI'] ?? ''; $is_new_wc_order_screen = is_admin() && strpos($request_uri, 'admin.php?page=wc-orders') !== false && strpos($request_uri, 'action=new') !== false; $is_wrong_b2bking_redirect = strpos($location, 'edit.php?post_type=b2bking_group') !== false; if ($is_new_wc_order_screen && $is_wrong_b2bking_redirect) { return false; } return $location; }, 999999, 2); This workaround prevents the wrong redirect and allows the WooCommerce “new order” screen to load correctly. However, this is only a temporary workaround. The proper fix should be inside B2BKing: the function b2bking_save_groups_metaboxes() should return early unless the current saved post is actually a b2bking_group post type. For example, something like: if (get_post_type($post_id) !== 'b2bking_group') { return; } Please check why B2BKing performs a redirect to edit.php?post_type=b2bking_group during WooCommerce HPOS order creation and restrict this handler/redirect to the B2BKing group post type only. – All other plugins was disabled. – Default htacces – No caching enabled – Default wp theme – tested in private tab. Thank you. BR Tommy This topic was modified 1 month ago by thomas83at .
Hi Tommy, Thank you for using our plugin, This issue is related to one of the restrictions in our Core vs. Pro plugin. The Core (free) plugin enforces a limit of maximum 2 B2B groups and it does not allow creating more, by redirecting during group creation. This should not be interfering with orders, so that part of it is indeed a bug – we are looking at addressing this issue shortly and thank you for reporting it. However, the problem suggests you have more than 2 groups on Core, which should not be possible. Please check: if you are also using B2BKing Pro, it’s possible you may have accidentally deactivated it. We will look at releasing an update shortly addressing the orders conflict, I will update you once that’s released, Stefan
Hello, we only using B2B King free edition. Any cacne to get a quick fix? Its an absolute no go that your plugin cause a issue in one of the most important options of woocommerce: admin can not create an order when B2B King free edition is enabled. BR Tommy
Hi again, We’ve released an update now, version 5.2.30, with a fix. Let me know if you have any further issues after updating,
Hi Tommy, Thank you for using our plugin, This issue is related to one of the restrictions in our Core vs. Pro plugin. The Core (free) plugin enforces a limit of maximum 2 B2B groups and it does not allow creating more, by redirecting during group creation. This should not be interfering with orders, so that part of it is indeed a bug – we are looking at addressing this issue shortly and thank you for reporting it. However, the problem suggests you have more than 2 groups on Core, which should not be possible. Please check: if you are also using B2BKing Pro, it’s possible you may have accidentally deactivated it. We will look at releasing an update shortly addressing the orders conflict, I will update you once that’s released, Stefan
Hello, we only using B2B King free edition. Any cacne to get a quick fix? Its an absolute no go that your plugin cause a issue in one of the most important options of woocommerce: admin can not create an order when B2B King free edition is enabled. BR Tommy
Hi again, We’ve released an update now, version 5.2.30, with a fix. Let me know if you have any further issues after updating,