How to display cross sells inside Woocommerce tabs

  php, woocommerce, wordpress

I’m trying to display Woocommerce cross sells inside tabs (same tabs of reviews and additional information).

woocommerce_cross_sell_display();

This is the function I used to display, but it didn’t worked. I receive no error and no visual result.

Here is what I tried so far:

//Add custom tabs filter
add_filter('woocommerce_product_tabs', 'add_new_default_product_tab' );
function add_new_default_product_tab( $tabs ) {

    global $product;

    // set the new priority to the "reviews" tab
    $tabs['reviews']['priority'] = 20;

    // gets the value to use as the title and slug of the new tab
    $custom_tab_title = "אביזרים";
    $custom_tab_title2 = "אביזרים משלימים";

    // if the custom field is set, it adds the new tab
    if ( ! empty($custom_tab_title) ) {
        $tabs['awp-' . sanitize_title('props')] = array(
            'title' => 'אביזרים',
            'callback' => 'awp_custom_woocommerce_tabs',
            'priority' => 5
        );
    }
    if ( ! empty($custom_tab_title) ) {
        $tabs['awp-' . sanitize_title('additional-props')] = array(
            'title' => 'אביזרים משלימים',
            'callback' => 'awp_custom_woocommerce_tabs2',
            'priority' => 10
        );
    }
    return $tabs;
}
 
    //Callback to display upsells (WORKS)
    
    function awp_custom_woocommerce_tabs($key, $tab) {
         woocommerce_upsell_display( 3,3 );
    }
    
    
    //Callback to display cross sells (Doesn't work)
    
    function awp_custom_woocommerce_tabs2($key, $tab) {
        woocommerce_cross_sell_display();
    }

Its wired because upsells working fine, but cross sells (which basically is the same) doesn’t work.

How to display cross sells inside Woocommerce tabs in single product page?

Link to my website

Source: Ask PHP

LEAVE A COMMENT