Get product SKU by product ID in WooCommerce

/**
 * Get product SKU by product ID in WooCommerce.
 *
 * @see https://wpcodebook.com/snippets/get-product-sku-by-product-id-in-woocommerce/
 */
function wpcb_get_product_sku( $product_id ) {
	return ( ( $product = wc_get_product( $product_id ) ) ? $product->get_sku() : false );
}

No comments yet.

Leave a Reply