View Categories

How to include SKU in item name

Use the below code snippet to display the SKU next to the item name when the order is scheduled inside Google Calendar:

function sl_cc_chwazi_gcalendar_alter_order_items($replacements, $order){
		$order_items = $order->get_items();

		$order_items_array = array();
		foreach ( $order_items as $item_id => $item ) {
			$product = $item->get_product();
			$sku = $product ? "(" . $product->get_sku() . ")" : '';
			$order_items_array[] = $item->get_name() . " $sku x " . $item->get_quantity();
		}

	$replacements['{order_items}'] = implode( "\n", $order_items_array );
	
	return $replacements;
}
add_filter('chwazi_gcalendar_event_replacement_tags', 'sl_cc_chwazi_gcalendar_alter_order_items', 10, 2);

Checkout our Google Calendar Add-on

Track Your WooCommerce Orders inside Google Calendar

Learn More