WC_Order_Item_Product_Data_Store::get_download_ids()publicWC 3.0.0

Get a list of download IDs for a specific item from an order.

Method of the class: WC_Order_Item_Product_Data_Store{}

No Hooks.

Return

Array.

Usage

$WC_Order_Item_Product_Data_Store = new WC_Order_Item_Product_Data_Store();
$WC_Order_Item_Product_Data_Store->get_download_ids( $item, $order );
$item(WC_Order_Item_Product) (required)
Product order item object.
$order(WC_Order) (required)
Order object.

Changelog

Since 3.0.0 Introduced.

WC_Order_Item_Product_Data_Store::get_download_ids() code WC 9.4.2

public function get_download_ids( $item, $order ) {
	global $wpdb;
	return $wpdb->get_col(
		$wpdb->prepare(
			"SELECT download_id FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE user_email = %s AND order_key = %s AND product_id = %d ORDER BY permission_id",
			$order->get_billing_email(),
			$order->get_order_key(),
			$item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id()
		)
	);
}