Reply To: Error on product page

Home Page Forums WooCommerce Custom Tabs Error on product page Reply To: Error on product page

#923

David

Participant

Hi Peter,

The issue I was having was in woocommerce-custom-tabs.php line 172. If one of the two arrays you are merging is empty it was throwing a fatal error. I managed to fix it with the following code (I’m sure it could be written a bit more concisely):


// line 172 woocommerce-custom-tabs.php
// REMOVE -> $product_tabpage_postslist = array_unique ( array_merge ( $product_tabpage_postslist_1, $product_tabpage_postslist_2 ), SORT_REGULAR);

// ADD
$product_tabpage_postslist = array();
if ( count($product_tabpage_postslist_1) > 0 && count($product_tabpage_postslist_2) > 0 ) {
   //array_unique works with an array of objects using SORT_REGULAR:
   $product_tabpage_postslist = array_unique ( array_merge ( $product_tabpage_postslist_1, $product_tabpage_postslist_2 ), SORT_REGULAR);
} else if ( count($product_tabpage_postslist_1) > 0 ) {
    $product_tabpage_postslist = $product_tabpage_postslist_1;
} else if ( count($product_tabpage_postslist_2) > 0 ) {
   $product_tabpage_postslist = $product_tabpage_postslist_2;
} 

Hope it helps

Cheers,
David