Advertisement
Guest User

email-order-items.php (with %20 fix)

a guest
Jan 3rd, 2014
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.66 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Email Order Items
  4.  *
  5.  * @author      WooThemes
  6.  * @package     WooCommerce/Templates/Emails
  7.  * @version     2.0.3
  8.  */
  9.  
  10. if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  11.  
  12. global $woocommerce;
  13.  
  14. foreach ( $items as $item ) :
  15.  
  16.     // Get/prep product data
  17.     $_product = $order->get_product_from_item( $item );
  18.     $item_meta = new WC_Order_Item_Meta( $item['item_meta'] );
  19.  
  20.     // Handle products that was removed from store
  21.     if ( ! is_object( $_product ) ) :
  22.         ?>
  23.         <tr>
  24.             <td style="text-align:left; vertical-align:middle; border: 1px solid #eee; word-wrap:break-word;">
  25.             <?php
  26.  
  27.                 // Show title/image etc
  28.                 echo    apply_filters( 'woocommerce_order_product_image', '', null, $show_image);
  29.  
  30.                 // Product name
  31.                 echo    apply_filters( 'woocommerce_order_product_title', $item['name'], $_product );
  32.  
  33.                 // Product not available anymore message
  34.                 echo '<br/><small>(' . __( 'This product is no longer available', 'woocommerce' ) . ')</small>';
  35.  
  36.                 // Variation
  37.                 echo    ($item_meta->meta) ? '<br/><small>' . nl2br( $item_meta->display( true, true ) ) . '</small>' : '';
  38.  
  39.             ?>
  40.             </td>
  41.             <td style="text-align:left; vertical-align:middle; border: 1px solid #eee;"><?php echo $item['qty'] ;?></td>
  42.             <td style="text-align:left; vertical-align:middle; border: 1px solid #eee;"><?php echo $order->get_formatted_line_subtotal( $item ); ?></td>
  43.         </tr>
  44.         <?php
  45.     else :
  46.         $attachment_image_src = wp_get_attachment_image_src( get_post_thumbnail_id( $_product->id ), 'thumbnail' );
  47.         $image = ( $show_image ) ? '<img src="' . current( $attachment_image_src ) . '" alt="Product Image" height="' . $image_size[1] . '" width="' . $image_size[0] . '" style="vertical-align:middle; margin-right: 10px;" />' : '';
  48.  
  49.         ?>
  50.         <tr>
  51.             <td style="text-align:left; vertical-align:middle; border: 1px solid #eee; word-wrap:break-word;"><?php
  52.  
  53.                 // Show title/image etc
  54.                 echo    apply_filters( 'woocommerce_order_product_image', $image, $_product, $show_image);
  55.  
  56.                 // Product name
  57.                 echo    apply_filters( 'woocommerce_order_product_title', $item['name'], $_product );
  58.  
  59.  
  60.                 // SKU
  61.                 echo    ($show_sku && $_product->get_sku()) ? ' (#' . $_product->get_sku() . ')' : '';
  62.  
  63.                 // File URLs
  64.                 if ( $show_download_links && $_product->exists() && $_product->is_downloadable() ) {
  65.  
  66.                     $download_file_urls = $order->get_downloadable_file_urls( $item['product_id'], $item['variation_id'], $item );
  67.  
  68.                     $i = 0;
  69.  
  70.                     foreach ( $download_file_urls as $file_url => $download_file_url ) {
  71.                         echo '<br/><small>';
  72.  
  73.                         $filename = woocommerce_get_filename_from_url( $file_url );
  74.  
  75.                         if ( count( $download_file_urls ) > 1 ) {
  76.                             echo sprintf( __('Download %d:', 'woocommerce' ), $i + 1 );
  77.                         } elseif ( $i == 0 )
  78.                             echo __( 'Download:', 'woocommerce' );
  79.  
  80.                         echo ' <a href="' . $download_file_url . '" target="_blank">' . "\n" . $filename . '</a></small>';
  81.  
  82.                         $i++;
  83.                     }
  84.                 }
  85.  
  86.                 // Variation
  87.                 echo    ($item_meta->meta) ? '<br/><small>' . nl2br( $item_meta->display( true, true ) ) . '</small>' : '';
  88.  
  89.             ?></td>
  90.             <td style="text-align:left; vertical-align:middle; border: 1px solid #eee;"><?php echo $item['qty'] ;?></td>
  91.             <td style="text-align:left; vertical-align:middle; border: 1px solid #eee;"><?php echo $order->get_formatted_line_subtotal( $item ); ?></td>
  92.         </tr>
  93.  
  94.         <?php if ($show_purchase_note && $purchase_note = get_post_meta( $_product->id, '_purchase_note', true)) : ?>
  95.             <tr>
  96.                 <td colspan="3" style="text-align:left; vertical-align:middle; border: 1px solid #eee;"><?php echo apply_filters('the_content', $purchase_note); ?></td>
  97.             </tr>
  98.         <?php endif; ?>
  99.     <?php endif; ?>
  100. <?php endforeach; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement