How to display the parent product SKU below the product description?

If you are using product variations and you would only like to show the parent product SKU instead of the variation SKU's, make sure to disable the setting "Show SKU as meta data" and add below filter to your themes functions.php file.

/**
 * Add parent product SKU below product description.
 *
 * @param string                $description Description.
 * @param int                   $item_id     Item ID.
 * @param WC_Order_Item_Product $item        Product.
 *
 * @return string
 */
function add_parent_product_sku( $description, $item_id, $item ) {
	$product = $item->get_product();

	if ( $product ) {
		$parent_product = wc_get_product( $product->get_parent_id() );
		$description   .= '<br><ul><li><strong>' . esc_html__( 'SKU:', 'woocommerce-pdf-invoices' ) . '</strong>' . esc_html( $parent_product->get_sku() ) . '</li></ul>';
	}

	return $description;
}
add_filter( 'wpi_item_description_data', 'add_parent_product_sku', 10, 3, 98 );

Still need help? Contact Us Contact Us