Advertisement
nshelper

Untitled

Aug 16th, 2022
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.11 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Email Order Items
  4.  *
  5.  * This template can be overridden by copying it to yourtheme/woocommerce/emails/email-order-items.php.
  6.  *
  7.  * HOWEVER, on occasion WooCommerce will need to update template files and you
  8.  * (the theme developer) will need to copy the new files to your theme to
  9.  * maintain compatibility. We try to do this as little as possible, but it does
  10.  * happen. When this occurs the version of the template file will be bumped and
  11.  * the readme will list any important changes.
  12.  *
  13.  * @see     https://docs.woocommerce.com/document/template-structure/
  14.  * @package WooCommerce\Templates\Emails
  15.  * @version 3.7.0
  16.  */
  17.  
  18. defined( 'ABSPATH' ) || exit;
  19.  
  20. $text_align  = is_rtl() ? 'right' : 'left';
  21. $margin_side = is_rtl() ? 'left' : 'right';
  22.  
  23. foreach ( $items as $item_id => $item ) :
  24.  
  25.     do_action( 'woocommerce/cart_loop/start', $item );
  26.  
  27.     if ( ! apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
  28.         continue;
  29.     }
  30.  
  31.     $product = $item->get_product();
  32.     $sku     = $purchase_note = '';
  33.  
  34.     if ( ! is_object( $product ) ) {
  35.         do_action( 'woocommerce/cart_loop/end', $item );
  36.         continue;
  37.     }
  38.  
  39.     $product       = $item->get_product();
  40.     $purchase_note = '';
  41.     $image         = '';
  42.  
  43.     if ( ! apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
  44.         do_action( 'woocommerce/cart_loop/end', $item );
  45.         continue;
  46.     }
  47.  
  48.     if ( is_object( $product ) ) {
  49.         $sku           = $product->get_sku();
  50.         $purchase_note = $product->get_purchase_note();
  51.         $image         = $product->get_image( $image_size );
  52.     }
  53.  
  54.     ?>
  55.     <tr class="<?php echo esc_attr( apply_filters( 'woocommerce_order_item_class', 'order_item', $item, $order ) ); ?>">
  56.         <td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>; vertical-align: middle; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; word-wrap:break-word;">
  57.         <?php
  58.  
  59.         // Show title/image etc.
  60.         if ( $show_image ) {
  61.             echo wp_kses_post( apply_filters( 'woocommerce_order_item_thumbnail', $image, $item ) );
  62.         }
  63.  
  64.         // Product name.
  65.         echo wp_kses_post( apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ) );
  66.  
  67.         // SKU.
  68.         if ( $show_sku && $sku ) {
  69.             echo wp_kses_post( ' (#' . $sku . ')' );
  70.         }
  71.  
  72.         // allow other plugins to add additional product information here.
  73.         do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $plain_text );
  74.  
  75.         wc_display_item_meta(
  76.             $item,
  77.             array(
  78.                 'label_before' => '<strong class="wc-item-meta-label" style="float: ' . esc_attr( $text_align ) . '; margin-' . esc_attr( $margin_side ) . ': .25em; clear: both">',
  79.             )
  80.         );
  81.  
  82.         // allow other plugins to add additional product information here.
  83.         do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );
  84.  
  85.         ?>
  86.         </td>
  87.         <td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>; vertical-align:middle; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;">
  88.             <?php
  89.             $qty          = $item->get_quantity();
  90.             $refunded_qty = $order->get_qty_refunded_for_item( $item_id );
  91.  
  92.             if ( $refunded_qty ) {
  93.                 $qty_display = '<del>' . esc_html( $qty ) . '</del> <ins>' . esc_html( $qty - ( $refunded_qty * -1 ) ) . '</ins>';
  94.             } else {
  95.                 $qty_display = esc_html( $qty );
  96.             }
  97.             echo wp_kses_post( apply_filters( 'woocommerce_email_order_item_quantity', $qty_display, $item ) );
  98.             ?>
  99.         </td>
  100.         <td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>; vertical-align:middle; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;">
  101.             <?php echo wp_kses_post( $order->get_formatted_line_subtotal( $item ) ); ?>
  102.         </td>
  103.     </tr>
  104.     <?php
  105.  
  106.     if ( $show_purchase_note && $purchase_note ) {
  107.         ?>
  108.         <tr>
  109.             <td colspan="3" style="text-align:<?php echo esc_attr( $text_align ); ?>; vertical-align:middle; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;">
  110.                 <?php
  111.                 echo wp_kses_post( wpautop( do_shortcode( $purchase_note ) ) );
  112.                 ?>
  113.             </td>
  114.         </tr>
  115.         <?php
  116.     }
  117.    
  118.    
  119.     do_action( 'woocommerce/cart_loop/end', $item );
  120.    
  121.     ?>
  122.  
  123. <?php endforeach; ?>
  124.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement