2
ユーザーがファイルをダウンロードする権限を持っているかどうかを確認します。私は製品IDとユーザーIDを持っていますので、どうすれば確認できますか?ユーザーがWooCommerceのファイルをダウンロードする権限を持っているかどうかを確認してください。
私はgoogleとwoocommerceのドキュメントで多くを試しましたが、解決策は見つかりませんでした。
助けが必要ですか?
ありがとうございます。
ユーザーがファイルをダウンロードする権限を持っているかどうかを確認します。私は製品IDとユーザーIDを持っていますので、どうすれば確認できますか?ユーザーがWooCommerceのファイルをダウンロードする権限を持っているかどうかを確認してください。
私はgoogleとwoocommerceのドキュメントで多くを試しましたが、解決策は見つかりませんでした。
助けが必要ですか?
ありがとうございます。
ここでは、この情報を取得して、PHPファイル内の任意の関数またはフック関数で使用できるプロセスを示します。ここで
はコードです:// 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
}
}
}
}
}
}
コードは、任意のプラグインのPHPファイルでも、あなたのアクティブな子テーマ(またはテーマ)の任意のPHPファイルになりますか。
これはテストされ、完全に機能します。
私はwoocommerceサポートからhttps://github.com/woocommerce/woocommerce/issues/12275#issuecomment-259122914このリンクを持って、誰でも助けることができますか? –