wc_downloadable_product_permissions()
Order Status completed - give downloadable product access to customer.
Хуки из функции
Возвращает
null
. Ничего (null).
Использование
wc_downloadable_product_permissions( $order_id, $force );
- $order_id(int) (обязательный)
- Order ID.
- $force(true|false)
- Force downloadable permissions.
По умолчанию: false
Код wc_downloadable_product_permissions() wc downloadable product permissions WC 9.3.3
function wc_downloadable_product_permissions( $order_id, $force = false ) { $order = wc_get_order( $order_id ); if ( ! $order || ( $order->get_data_store()->get_download_permissions_granted( $order ) && ! $force ) ) { return; } if ( $order->has_status( 'processing' ) && 'no' === get_option( 'woocommerce_downloads_grant_access_after_payment' ) ) { return; } if ( count( $order->get_items() ) > 0 ) { foreach ( $order->get_items() as $item ) { $product = $item->get_product(); if ( $product && $product->exists() && $product->is_downloadable() ) { $downloads = $product->get_downloads(); foreach ( array_keys( $downloads ) as $download_id ) { wc_downloadable_file_permission( $download_id, $product, $order, $item->get_quantity(), $item ); } } } } $order->get_data_store()->set_download_permissions_granted( $order, true ); do_action( 'woocommerce_grant_product_download_permissions', $order_id ); }