| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
$text_align = is_rtl() ? 'right' : 'left'; |
| 7 |
$yaymail_settings = get_option( 'yaymail_settings' ); |
| 8 |
$yaymail_template = get_post_meta( $postID, '_yaymail_template', true ); |
| 9 |
$orderImagePostions = isset( $yaymail_settings['image_position'] ) && ! empty( $yaymail_settings['image_position'] ) ? $yaymail_settings['image_position'] : 'Top'; |
| 10 |
$orderImage = isset( $yaymail_settings['product_image'] ) && '0' != $yaymail_settings['product_image'] ? $yaymail_settings['product_image'] : '0'; |
| 11 |
$productHyperLinks = isset( $yaymail_settings['product_hyper_links'] ) ? $yaymail_settings['product_hyper_links'] : 0; |
| 12 |
$productRegularPrice = isset( $yaymail_settings['product_regular_price'] ) ? $yaymail_settings['product_regular_price'] : 0; |
| 13 |
$productItemCost = isset( $yaymail_settings['product_item_cost'] ) ? $yaymail_settings['product_item_cost'] : 0; |
| 14 |
|
| 15 |
if ( ! function_exists( 'yaymail_get_global_taxonomy_attribute_data' ) ) : |
| 16 |
function yaymail_get_global_taxonomy_attribute_data( $name, $product, $single_product = null ) { |
| 17 |
$out = array(); |
| 18 |
|
| 19 |
$product_id = is_numeric( $product ) ? $product : $product->get_id(); |
| 20 |
$terms = wp_get_post_terms( $product_id, $name, 'all' ); |
| 21 |
|
| 22 |
if ( ! empty( $terms ) ) { |
| 23 |
if ( ! is_wp_error( $terms ) ) { |
| 24 |
$tax = $terms[0]->taxonomy; |
| 25 |
$tax_object = get_taxonomy( $tax ); |
| 26 |
if ( isset( $tax_object->labels->singular_name ) ) { |
| 27 |
$out['label'] = $tax_object->labels->singular_name; |
| 28 |
} elseif ( isset( $tax_object->label ) ) { |
| 29 |
$out['label'] = $tax_object->label; |
| 30 |
$label_prefix = __( 'Product', 'woocommerce-show-attributes' ) . ' '; |
| 31 |
if ( 0 === strpos( $out['label'], $label_prefix ) ) { |
| 32 |
$out['label'] = substr( $out['label'], strlen( $label_prefix ) ); |
| 33 |
} |
| 34 |
} |
| 35 |
$tax_terms = array(); |
| 36 |
foreach ( $terms as $term ) { |
| 37 |
$single_term = esc_html( $term->name ); |
| 38 |
|
| 39 |
// Show terms as links? |
| 40 |
if ( $single_product ) { |
| 41 |
if ( get_option( 'wcsa_terms_as_links' ) == 'yes' ) { |
| 42 |
$term_link = get_term_link( $term ); |
| 43 |
if ( ! is_wp_error( $term_link ) ) { |
| 44 |
$single_term = '<a href="' . esc_url( $term_link ) . '">' . esc_html( $term->name ) . '</a>'; |
| 45 |
} |
| 46 |
} |
| 47 |
} |
| 48 |
array_push( $tax_terms, $single_term ); |
| 49 |
} |
| 50 |
$out['value'] = implode( ', ', $tax_terms ); |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
return $out; |
| 55 |
} |
| 56 |
endif; |
| 57 |
|
| 58 |
foreach ( $items as $item_id => $item ) : |
| 59 |
if ( apply_filters( 'woocommerce_order_item_visible', true, $item ) ) { |
| 60 |
$product = $item->get_product(); |
| 61 |
$result_attributes = array(); |
| 62 |
?> |
| 63 |
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_order_item_class', 'order_item', $item, $order ) ); ?>"> |
| 64 |
<th colspan="<?php echo wp_kses_post( apply_filters( 'yaymail_order_item_product_title_colspan', 1, $yaymail_template ) ); ?>" class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>;font-weight: normal;word-wrap:break-word;vertical-align: middle;padding: 12px;font-size: 14px;border-width: 1px;border-style: solid;<?php echo esc_attr( isset( $default_args['border_color'] ) ? $default_args['border_color'] : '' ); ?>;"> |
| 65 |
<?php |
| 66 |
|
| 67 |
if ( 'Bottom' == $orderImagePostions && '1' == $orderImage ) { |
| 68 |
echo ( '<div class="yaymail-product-texts" style="padding: 5px 0;">' ); |
| 69 |
// Product name |
| 70 |
if ( $productHyperLinks ) { |
| 71 |
if ( method_exists( $product, 'get_permalink' ) ) { |
| 72 |
echo wp_kses_post( ' <a style="color:' . $text_link_color . '" target="_blank" href="' . $product->get_permalink() . '"><span class="yaymail-product-name">' . wp_kses_post( apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ) ) . '</span></a>' ); |
| 73 |
} else { |
| 74 |
echo wp_kses_post( '<span class="yaymail-product-name">' . wp_kses_post( apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ) ) . '</span>' ); |
| 75 |
} |
| 76 |
} else { |
| 77 |
echo wp_kses_post( '<span class="yaymail-product-name">' . wp_kses_post( apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ) ) . '</span>' ); |
| 78 |
} |
| 79 |
// SKU |
| 80 |
if ( $args['show_sku'] && is_object( $product ) && $product->get_sku() && $product ) { |
| 81 |
echo wp_kses_post( '<span class="yaymail-product-sku"> (#' . $product->get_sku() . ')</span>' ); |
| 82 |
} |
| 83 |
|
| 84 |
if ( $args['show_des'] && is_object( $product ) && $product->get_short_description() && $product ) { |
| 85 |
echo wp_kses_post( '<div class="yaymail-product-short-descript"> (#' . $product->get_short_description() . ')</div>' ); |
| 86 |
} |
| 87 |
if ( $args['show_des'] && is_object( $product ) && 'variation' === $product->get_type() ) { |
| 88 |
echo wp_kses_post( '<div class="yaymail-product-description"> (#' . $product->get_description() . ')</div>' ); |
| 89 |
} |
| 90 |
// allow other plugins to add additional product information here |
| 91 |
do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $args['plain_text'] ); |
| 92 |
|
| 93 |
// Display item meta data. |
| 94 |
wc_display_item_meta( $item ); |
| 95 |
|
| 96 |
echo ( '</div>' ); |
| 97 |
// Show title/image etc |
| 98 |
if ( $args['show_image'] && is_object( $product ) ) { |
| 99 |
echo wp_kses_post( apply_filters( 'woocommerce_order_item_thumbnail', '<div class="yaymail-product-image" style="margin-bottom: 5px"><img src="' . ( $product->get_image_id() ? ( false !== wp_get_attachment_image_src( $product->get_image_id(), $args['image_size'][2] ) ? wp_get_attachment_image_src( $product->get_image_id(), $args['image_size'][2] )[0] : wc_placeholder_img_src() ) : wc_placeholder_img_src() ) . '" alt="' . esc_attr__( 'Product image', 'woocommerce' ) . '" height="' . esc_attr( str_replace( 'px', '', $args['image_size'][1] ) ) . '" width="' . esc_attr( str_replace( 'px', '', $args['image_size'][0] ) ) . '" style="vertical-align:middle; margin-' . ( is_rtl() ? 'left' : 'right' ) . ': 10px;" /></div>', $item ) ); |
| 100 |
} |
| 101 |
} else { |
| 102 |
// Show title/image etc |
| 103 |
if ( $args['show_image'] && is_object( $product ) ) { |
| 104 |
echo wp_kses_post( apply_filters( 'woocommerce_order_item_thumbnail', '<div class="yaymail-product-image" style="margin-bottom: 5px"><img src="' . ( $product->get_image_id() ? ( false !== wp_get_attachment_image_src( $product->get_image_id(), $args['image_size'][2] ) ? wp_get_attachment_image_src( $product->get_image_id(), $args['image_size'][2] )[0] : wc_placeholder_img_src() ) : wc_placeholder_img_src() ) . '" alt="' . esc_attr__( 'Product image', 'woocommerce' ) . '" height="' . esc_attr( str_replace( 'px', '', $args['image_size'][1] ) ) . '" width="' . esc_attr( str_replace( 'px', '', $args['image_size'][0] ) ) . '" style="vertical-align:middle; margin-' . ( is_rtl() ? 'left' : 'right' ) . ': 10px;" /></div>', $item ) ); |
| 105 |
} |
| 106 |
echo ( '<div class="yaymail-product-texts" style="padding: 5px 0;">' ); |
| 107 |
// Product name |
| 108 |
if ( $productHyperLinks ) { |
| 109 |
if ( method_exists( $product, 'get_permalink' ) ) { |
| 110 |
echo wp_kses_post( ' <a style="color:' . $text_link_color . '" target="_blank" href="' . $product->get_permalink() . '"><span class="yaymail-product-name">' . wp_kses_post( apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ) ) . '</span></a>' ); |
| 111 |
} else { |
| 112 |
echo wp_kses_post( '<span class="yaymail-product-name">' . wp_kses_post( apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ) ) . '</span>' ); |
| 113 |
} |
| 114 |
} else { |
| 115 |
echo wp_kses_post( '<span class="yaymail-product-name">' . wp_kses_post( apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ) ) . '</span>' ); |
| 116 |
} |
| 117 |
// SKU |
| 118 |
if ( $args['show_sku'] && is_object( $product ) && $product->get_sku() && $product ) { |
| 119 |
echo wp_kses_post( '<span class="yaymail-product-sku"> (#' . $product->get_sku() . ')</span>' ); |
| 120 |
} |
| 121 |
|
| 122 |
if ( $args['show_des'] && is_object( $product ) && $product->get_short_description() && $product ) { |
| 123 |
echo wp_kses_post( '<div class="yaymail-product-short-descript"> (#' . $product->get_short_description() . ')</div>' ); |
| 124 |
} |
| 125 |
if ( $args['show_des'] && is_object( $product ) && 'variation' === $product->get_type() ) { |
| 126 |
echo wp_kses_post( '<div class="yaymail-product-description"> (#' . $product->get_description() . ')</div>' ); |
| 127 |
} |
| 128 |
// allow other plugins to add additional product information here |
| 129 |
do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $args['plain_text'] ); |
| 130 |
|
| 131 |
// Display item meta data. |
| 132 |
wc_display_item_meta( $item ); |
| 133 |
|
| 134 |
echo ( '</div>' ); |
| 135 |
} |
| 136 |
|
| 137 |
|
| 138 |
// Display item download links. |
| 139 |
if ( $args['show_download_links'] ) { |
| 140 |
wc_display_item_downloads( $item ); |
| 141 |
} |
| 142 |
|
| 143 |
// allow other plugins to add additional product information here |
| 144 |
do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $args['plain_text'] ); |
| 145 |
?> |
| 146 |
|
| 147 |
</th> |
| 148 |
<?php if ( $productItemCost && is_object( $product ) ) { ?> |
| 149 |
<th colspan="<?php echo wp_kses_post( apply_filters( 'yaymail_order_item_cost_colspan', 1, $yaymail_template ) ); ?>" class="td yaymail_item_cost_content" style="text-align:<?php echo esc_attr( $text_align ); ?>;font-weight: normal; vertical-align:middle;padding: 12px;font-size: 14px;border-width: 1px;border-style: solid;<?php echo esc_attr( isset( $default_args['border_color'] ) ? $default_args['border_color'] : '' ); ?>;"> |
| 150 |
<?php echo wp_kses_post( wc_price( $order->get_item_subtotal( $item, false, true ), array( 'currency' => $order->get_currency() ) ) ); ?> |
| 151 |
</th> |
| 152 |
<?php } ?> |
| 153 |
<th colspan="<?php echo wp_kses_post( apply_filters( 'yaymail_order_item_quantity_colspan', 1, $yaymail_template ) ); ?>" class="td yaymail_item_quantity_content" style="text-align:<?php echo esc_attr( $text_align ); ?>;font-weight: normal; vertical-align:middle;padding: 12px;font-size: 14px;border-width: 1px;border-style: solid;<?php echo esc_attr( isset( $default_args['border_color'] ) ? $default_args['border_color'] : '' ); ?>;"> |
| 154 |
<?php |
| 155 |
$qty = $item->get_quantity(); |
| 156 |
$refunded_qty = $order->get_qty_refunded_for_item( $item_id ); |
| 157 |
|
| 158 |
if ( $refunded_qty ) { |
| 159 |
$qty_display = '<del>' . esc_html( $qty ) . '</del> <ins>' . esc_html( $qty - ( $refunded_qty * -1 ) ) . '</ins>'; |
| 160 |
} else { |
| 161 |
$qty_display = esc_html( $qty ); |
| 162 |
} |
| 163 |
echo wp_kses_post( apply_filters( 'woocommerce_email_order_item_quantity', $qty_display, $item ) ); |
| 164 |
?> |
| 165 |
</th> |
| 166 |
<th colspan="<?php echo wp_kses_post( apply_filters( 'yaymail_order_item_price_colspan', 1, $yaymail_template ) ); ?>" class="td yaymail_item_price_content" style="text-align:<?php echo esc_attr( $text_align ); ?>;font-weight: normal;vertical-align: middle;padding: 12px;font-size: 14px;border-width: 1px;border-style: solid;<?php echo esc_attr( isset( $default_args['border_color'] ) ? $default_args['border_color'] : '' ); ?>; word-break: break-all;"> |
| 167 |
<?php |
| 168 |
if ( $productRegularPrice && is_object( $product ) ) { |
| 169 |
$product_regular_price = isset( $product->get_data()['regular_price'] ) ? (float) $product->get_data()['regular_price'] : null; |
| 170 |
if ( $order->get_currency() !== get_option( 'woocommerce_currency' ) ) { |
| 171 |
foreach ( $item->get_meta_data() as $product_meta ) { |
| 172 |
if ( '_wcpdf_regular_price' !== $product_meta->key ) { |
| 173 |
continue; |
| 174 |
} |
| 175 |
$product_regular_price = $product_meta->value[ get_option( 'woocommerce_tax_display_cart' ) ? get_option( 'woocommerce_tax_display_cart' ) : 'excl' ]; |
| 176 |
break; |
| 177 |
} |
| 178 |
} |
| 179 |
if ( (float) $product_regular_price !== $order->get_line_subtotal( $item, true ) ) { |
| 180 |
echo wp_kses_post( '<del>' . wc_price( $product_regular_price, array( 'currency' => $order->get_currency() ) ) . '</del> ' ); |
| 181 |
} |
| 182 |
} echo wp_kses_post( $order->get_formatted_line_subtotal( $item ) ); |
| 183 |
?> |
| 184 |
</th> |
| 185 |
</tr> |
| 186 |
<?php |
| 187 |
} |
| 188 |
|
| 189 |
// Show purchase note |
| 190 |
$purchase_note = ''; |
| 191 |
if ( $product && is_object( $product ) && $product->get_purchase_note() ) { |
| 192 |
$purchase_note = $product->get_purchase_note(); |
| 193 |
} |
| 194 |
|
| 195 |
if ( ( 'customer_on_hold_order' === $this->template |
| 196 |
|| 'customer_processing_order' === $this->template |
| 197 |
|| 'customer_completed_order' === $this->template |
| 198 |
|| 'customer_refunded_order' === $this->template |
| 199 |
|| 'customer_invoice' === $this->template |
| 200 |
|| 'customer_note' === $this->template |
| 201 |
|| 'new_order' === $this->template ) |
| 202 |
&& isset( $args['show_purchase_note'] ) |
| 203 |
&& is_object( $product ) |
| 204 |
&& ! empty( $purchase_note ) |
| 205 |
) { |
| 206 |
?> |
| 207 |
|
| 208 |
<tr class="yaymail-purchase-note"> |
| 209 |
<th colspan="3" style="text-align:<?php echo esc_attr( $text_align ); ?>;font-weight: normal;vertical-align: middle;padding: 12px;font-size: 14px;border-width: 1px;border-style: solid;<?php echo esc_attr( isset( $default_args['border_color'] ) ? $default_args['border_color'] : '' ); ?>;"> |
| 210 |
<?php echo wp_kses_post( wpautop( do_shortcode( $purchase_note ) ) ); ?> |
| 211 |
</th> |
| 212 |
</tr> |
| 213 |
|
| 214 |
<?php } ?> |
| 215 |
|
| 216 |
<?php endforeach; ?> |
| 217 |
|