Advertisement
Guest User

Untitled

a guest
Oct 28th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.81 KB | None | 0 0
  1. //ADD {rockitdownloads} TAG FOR USE IN EDD PURCHASE EMAILS
  2. edd_add_email_tag( 'rockitdownloads', __( 'A linked list of downloads purchased', 'edd' ), 'rockit_edd_email_tag_downloads' );
  3. function rockit_edd_email_tag_downloads( $payment_id ) {
  4.  
  5.     $payment_data  = edd_get_payment_meta( $payment_id );
  6.     $download_list = '<div>';
  7.     $cart_items    = edd_get_payment_meta_cart_details( $payment_id );
  8.     $email         = edd_get_payment_user_email( $payment_id );
  9.    
  10.     if ( $cart_items ) {
  11.         $show_names = apply_filters( 'edd_email_show_names', true );
  12.  
  13.         foreach ( $cart_items as $item ) {
  14.             if ( edd_use_skus() ) {
  15.                 $sku = edd_get_download_sku( $item['id'] );
  16.             }
  17.             $price_id = edd_get_cart_item_price_id( $item );
  18.  
  19.             if ( $show_names ) {
  20.  
  21.                 $title = get_the_title( $item['id'] );
  22.  
  23.                 if ( ! empty( $sku ) ) {
  24.                     $title .= "&nbsp;&ndash;&nbsp;" . __( 'SKU', 'edd' ) . ': ' . $sku;
  25.                 }
  26.                 if ( $price_id !== false ) {
  27.                     $title .= "" . edd_get_price_option_name( $item['id'], $price_id );
  28.                 }
  29.                 $download_list .= '<div>' . apply_filters( 'edd_email_receipt_download_title', $title, $item, $price_id, $payment_id ) . '</div>';
  30.                 $download_list .= '';
  31.             }
  32.             $files = edd_get_download_files( $item['id'], $price_id );
  33.  
  34.             if ( $files ) {
  35.                 foreach ( $files as $filekey => $file ) {
  36.                     $download_list .= '<div style="display:inline-block;padding-bottom:20px;">';
  37.                     $file_url = edd_get_download_file_url( $payment_data['key'], $email, $filekey, $item['id'], $price_id );
  38.                     $download_list .= '<a style="color:#FFF;background:#1784CB;display:inline-block;padding:4px 10px 4px 10px;border-radius:3px;text-decoration:none;" href="' . esc_url( $file_url ) . '">' . edd_get_file_name( $file ) . '</a>';
  39.                     $download_list .= '</div>';
  40.                 }
  41.             }
  42.             elseif ( edd_is_bundled_product( $item['id'] ) ) {
  43.  
  44.                 $bundled_products = edd_get_bundled_products( $item['id'] );
  45.  
  46.                 foreach ( $bundled_products as $bundle_item ) {
  47.  
  48.                     $download_list .= '<li class="edd_bundled_product"><strong>' . get_the_title( $bundle_item ) . '</strong></li>';
  49.  
  50.                     $files = edd_get_download_files( $bundle_item );
  51.                    
  52.                     foreach ( $files as $filekey => $file ) {
  53.                         $download_list .= '<div>';
  54.                         $file_url = edd_get_download_file_url( $payment_data['key'], $email, $filekey, $bundle_item, $price_id );
  55.                         $download_list .= '<a href="' . esc_url( $file_url ) . '">' . $file['name'] . '</a>';
  56.                         $download_list .= '</div>';
  57.                     }
  58.                 }
  59.             }
  60.             if ( $show_names ) {
  61.                 $download_list .= '';
  62.             }
  63.             if ( '' != edd_get_product_notes( $item['id'] ) ) {
  64.                 $download_list .= '<div style="padding-bottom:20px;"><small>' . edd_get_product_notes( $item['id'] ) . '</small></div>';
  65.             }
  66.             if ( $show_names ) {
  67.                 $download_list .= '';
  68.             }
  69.         }
  70.     }
  71.     $download_list .= '</div>';
  72.     return $download_list;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement