function wc_downloadable_product_permissions( $order_id ) {
if ( get_post_meta( $order_id, '_download_permissions_granted', true ) == 1 ) {
return; // Only do this once
}
$order = wc_get_order( $order_id );
if ( $order && $order->has_status( 'processing' ) && get_option( 'woocommerce_downloads_grant_access_after_payment' ) == 'no' ) {
return;
}
if ( sizeof( $order->get_items() ) > 0 ) {
foreach ( $order->get_items() as $item ) {
$_product = $order->get_product_from_item( $item );