Hier ist der Prozess, um diese Informationen zu erhalten, die Sie in jeder Funktion oder Hooked-Funktion in Ihren PHP-Dateien verwenden können. Hier
ist der Code:
// Get all current customer orders
$customer_orders = wc_get_orders($args = array(
'numberposts' => -1,
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),// for current user id
'post_status' => array_keys(wc_get_order_statuses()),
));
// The different loops to get the downloadable products bought by this user
foreach ($customer_orders as $customer_order){
if (!empty($customer_orders)){
foreach ($customer_orders as $customer_order){
if(!$customer_order->has_downloadable_item() && $customer_order->is_paid()){
foreach($customer_order->get_items() as $item){
$item_id = $item['product_id']; // product ID
// Just the downloadable items Below
if($item->is_download_permitted()) {
// do something because the download is permitted
// you can use different methods on the $customer_product object:
// Get the downloadbles files (array):
$downloadable_files_array = get_item_downloads($item);
// Display download links for an order item.
$display_item_downloads = display_item_downloads($item);
// Get the Download URL of a given $download_id
// $download_url = get_download_url($item_id, $download_id)
} else {
// do something because the download is NOT permitted
}
}
}
}
}
}
-Code geht in beliebiger PHP-Datei Ihres aktiven Kind Thema (oder Thema) oder auch in beliebiger Plugin PHP-Dateien.
Dies ist getestet und voll funktionsfähig.
Referenz: WC_Abstract_Order class - Methods
Ich habe https://github.com/woocommerce/woocommerce/issues/12275#issuecomment-259122914 diesen Link von WooCommerce Unterstützung, kann jemand helfen? –