When using our custom product tabs for WooCommerce plugin you can add custom tabs yourself, but you can also use WP All Import for importing multiple tab content data. In this guide we show how you can use an import job of WPAI to update custom tabs with ease.

Inside custom Fields settings of your import job create anew entry with

  • Name: woocommerce_ultimate_tabs_custom
  • Value -> click on field options > serialized
    • Key: 1, 2, 3, 4 etc.
    • Value: custom callback function: 
[we_serialize_tab( {dataTabTitle[1]}, {dataTabDescription[1]}, "50")]
wp all import custom fields for woocommerce product tabs

The above custom callback function needs to be added to the importer functions. Open the fucntion editor and add the function code (see below).

function we_serialize_tab($title, $content, $priority = 20)
{
	if(empty($title)) {
		return '';
	}

	if(empty($content)) {
		return '';
	}

	$priority = intval($priority);

	$data = array(
		'id' => uniqid(),
		'title' => $title,
		'content' => $content,
		'priority' => $priority,
	);

	return serialize($data);
}

This code will create a serialized object of custom product tab data containing:

  1. unique id (you can also make that static if you want)
  2. title (the tab title)
  3. content (the text that will show in this tab)
  4. priority (default 20)
custom function to import product tabs

Now you can run your WP All Import job and custom product tabs for your products will be created automatically. 

Leave a Reply

Your email address will not be published. Required fields are marked *