Hi!
That message is definitely coming from one of your snippets – one of the ones which is activated. I can’t give you the name of the one causing the problem, but I can tell you it’ll be the one with array_merge on line 28 of its code.
To narrow the list down, you can search for the text array_merge in the snippet search box.
Thread Starter
geoj
(@georgjoutras)
Figured it out. Bad array_merge funtion in one of the code snippets I added.
Good to hear that it’s sorted!
Thread Starter
geoj
(@georgjoutras)
Thanks for the quick reply. I have figured out it is the code to add a new report to the ORDERS tab.
Here is the code that is causing the issue.
add_filter( ‘woocommerce_admin_reports’, ‘bbloomer_admin_add_report_orders_tab’ );
function bbloomer_admin_add_report_orders_tab( $reports )
{
$tab_array = array(
‘sales_by_state’ => array(
‘title’ => ‘Sales by State via snippet’,
‘description’ => ”,
‘hide_title’ => true,
‘callback’ => ‘bbloomer_yearly_sales_by_state’),
);
$reports[‘orders’][‘reports’] = array_merge($reports[‘orders’][‘reports’],$tab_array);
return $reports;
}
For the life on me, I can’t figure out why the array_merge is failing…any thoughts would be greatly appreciated!
-Georg
It’s possible that sometimes the $reports['orders'] variable is empty, or $reports['orders']['reports'] is set to a different value.
You should be able to fix this by adding a line to check whether that element is set and an array near the top of the function, and exit the function if so:
if ( ! isset( $reports['orders']['reports'] ) || ! is_array( $reports['orders']['reports'] ) return;
Thread Starter
geoj
(@georgjoutras)
Thank you, Shea! That did the trick.