There is a bug when taxes are disabled.
The bug is in this file:
Error:
An error of type E_ERROR was caused in line 2069 of the file /wp-content/plugins/woocommerce-product-bundles/includes/class-wc-pb-cart.php. Error message: Uncaught TypeError: array_merge(): Argument #1 must be of type array, null given in /wp-content/plugins/woocommerce-product-bundles/includes/class-wc-pb-cart.php:2069
Stack trace:
#0 /wp-content/plugins/woocommerce-product-bundles/includes/class-wc-pb-cart.php(2069): array_merge(NULL, NULL)
#1 /wp-includes/class-wp-hook.php(324): WC_PB_Cart->cart_shipping_packages(Array)
Function: cart_shipping_packages
Affected code:
$bundle_totals[ ‘line_tax_data’ ][ ‘total’ ] = array_merge( $bundle_totals[ ‘line_tax_data’ ][ ‘total’ ], $child_item_line_tax_data[ ‘total’ ] );
$bundle_totals[ ‘line_tax_data’ ][ ‘subtotal’ ] = array_merge( $bundle_totals[ ‘line_tax_data’ ][ ‘subtotal’ ], $child_item_line_tax_data[ ‘subtotal’ ] );
The issue is that when taxes are disabled, $bundle_totals[ ‘line_tax_data’ ][ ‘total’ ] is NULL and then array_merge throws the error.
A possible fix is to coalesce it with an empty array, like this:
$bundle_totals[ ‘line_tax_data’ ][ ‘total’ ] = array_merge( $bundle_totals[ ‘line_tax_data’ ][ ‘total’ ] ?? [], $child_item_line_tax_data[ ‘total’ ] ?? [] );
$bundle_totals[ ‘line_tax_data’ ][ ‘subtotal’ ] = array_merge( $bundle_totals[ ‘line_tax_data’ ][ ‘subtotal’ ] ?? [], $child_item_line_tax_data[ ‘subtotal’ ] ?? [] );
Closed
Last updated: January 2, 2024
Log in to comment on this feature request.
Hey there,
I tested this with the latest Product Bundles version (v8.0.1) and I couldn’t replicate this error when testing with both taxes enabled and disabled. Could you please check if you still see this error after updating to the latest version and only WooCommerce and Product Bundles are active in your store?
If you do, then we’d love to take a closer look at your configuration — I encourage you to get in touch with our support team at: https://woocommerce.com/my-account/contact-support/.
Hey Orhan. Thanks for the reply. I’m going to create a minimal testcase. I’ll get back to you shortly.
Hiya!
Orhan from Woo.com here, nice to be connecting. : )
Product Bundles has a suite of automated acceptance tests that validate most of the plugin’s main flows, such as adding a Bundle to the cart and viewing its totals, both with taxes enabled and disabled. Also, our team manually runs tests in our local sites almost daily both with taxes enabled and disabled and we haven’t seen any similar error.
It is very likely that this issue is coming from a plugin/theme conflict. Can you please conduct a conflict test using this guide: https://woocommerce.com/document/how-to-test-for-conflicts/
If the issue persists after the conflict test, do reach out to our support team and reference this feature request URL so we can look into the issue further. You can contact us from here: https://woocommerce.com/contact-us/
Cheers!