Thanks Bro,
your new function is recognizing a single item being purchased from a parent bundle now, but as i show the download links inside the product page your new function makes my download links broke. i’m not sure if it’s a problem with your new function or my way of generating download links inside product page.
but can i ask you for a favor to take a look at this too ?
here is the code i’m using to show the download links inside product page:
<?php
if ( __edd_has_user_purchased( $CurrentUser, $CurrentItem, $variable_price_id = null ) ) {
$user_purchases = edd_get_users_purchases( $CurrentUser, -1, false, 'complete' );
foreach ( $user_purchases as $purchase ) {
$cart_items = edd_get_payment_meta_cart_details( $purchase->ID );
$item_ids = wp_list_pluck( $cart_items, 'id' );
if ( in_array( $CurrentItem, $item_ids ) ) {
$email = edd_get_payment_user_email( $purchase->ID );
$payment_key = edd_get_payment_key( $purchase->ID );
}
}
// Attempt to get the file data associated with this download
$download_data = edd_get_download_files( $CurrentItem, null );
if ( $download_data ) {
$new_purchase_form = '';
foreach ( $download_data as $filekey => $file ) {
$FileURL = edd_get_download_file_url( $payment_key, $email, $filekey, $download['id'], null );
echo $FileURL . '<br>';
}
} else {
echo "No Download file added yet!";
}
}
?>
when i use your function __edd_has_user_purchased instead of edd_has_user_purchased, in a purchased single product with no parent bundle download links are shown perfectly but in a purchased product from it’s parent bundle page the product download links are not being generated and i see this Error and notices instead:
Notice
: Undefined variable: payment_key in
/home/user/public_html/wp-content/themes/.../Single/Product.php
on line
280
Notice
: Undefined variable: email in
/home/user/public_html/wp-content/themes/.../Single/Product.php
on line
280
Warning
: Illegal string offset 'id' in
/home/user/public_html/wp-content/themes/.../Single/Product.php
on line
280
Notice
: Undefined variable: payment_key in
/home/user/public_html/wp-content/themes/.../Single/Product.php
on line
280
Notice
: Undefined variable: email in
/home/user/public_html/wp-content/themes/.../Single/Product.php
on line
280
Warning
: Illegal string offset 'id' in
/home/user/public_html/wp-content/themes/.../Single/Product.php
on line
by the way can i ask you if EDD is not detecting a purchase from parent bundle
by default? i mean is this a bug from EDD or they want user to purchase single item separately although he/she may purchased a bundle containing it ?!
Thanks man.
-
This reply was modified 4 years, 5 months ago by
Erfan MHDi.
-
This reply was modified 4 years, 5 months ago by
Erfan MHDi.