| 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 |
$orderImagePostions = isset( $yaymail_settings['image_position'] ) && ! empty( $yaymail_settings['image_position'] ) ? $yaymail_settings['image_position'] : 'Top'; |
| 9 |
$orderImage = isset( $yaymail_settings['product_image'] ) && '0' != $yaymail_settings['product_image'] ? $yaymail_settings['product_image'] : '0'; |
| 10 |
|
| 11 |
if ( ! function_exists( 'yaymail_get_global_taxonomy_attribute_data' ) ) : |
| 12 |
function yaymail_get_global_taxonomy_attribute_data( $name, $product, $single_product = null ) { |
| 13 |
$out = array(); |
| 14 |
|
| 15 |
$product_id = is_numeric( $product ) ? $product : $product->get_id(); |
| 16 |
$terms = wp_get_post_terms( $product_id, $name, 'all' ); |
| 17 |
|
| 18 |
if ( ! empty( $terms ) ) { |
| 19 |
if ( ! is_wp_error( $terms ) ) { |
| 20 |
$tax = $terms[0]->taxonomy; |
| 21 |
$tax_object = get_taxonomy( $tax ); |
| 22 |
if ( isset( $tax_object->labels->singular_name ) ) { |
| 23 |
$out['label'] = $tax_object->labels->singular_name; |
| 24 |
} elseif ( isset( $tax_object->label ) ) { |
| 25 |
$out['label'] = $tax_object->label; |
| 26 |
$label_prefix = __( 'Product', 'woocommerce-show-attributes' ) . ' '; |
| 27 |
if ( 0 === strpos( $out['label'], $label_prefix ) ) { |
| 28 |
$out['label'] = substr( $out['label'], strlen( $label_prefix ) ); |
| 29 |
} |
| 30 |
} |
| 31 |
$tax_terms = array(); |
| 32 |
foreach ( $terms as $term ) { |
| 33 |
$single_term = esc_html( $term->name ); |
| 34 |
|
| 35 |
// Show terms as links? |
| 36 |
if ( $single_product ) { |
| 37 |
if ( get_option( 'wcsa_terms_as_links' ) == 'yes' ) { |
| 38 |
$term_link = get_term_link( $term ); |
| 39 |
if ( ! is_wp_error( $term_link ) ) { |
| 40 |
$single_term = '<a href="' . esc_url( $term_link ) . '">' . esc_html( $term->name ) . '</a>'; |
| 41 |
} |
| 42 |
} |
| 43 |
} |
| 44 |
array_push( $tax_terms, $single_term ); |
| 45 |
} |
| 46 |
$out['value'] = implode( ', ', $tax_terms ); |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
return $out; |
| 51 |
} |
| 52 |
endif; |
| 53 |
|
| 54 |
foreach ( $items as $item_id => $item ) : |
| 55 |
if ( apply_filters( 'woocommerce_order_item_visible', true, $item ) ) { |
| 56 |
$product = $item->get_product(); |
| 57 |
$result_attributes = array(); |
| 58 |
?> |
| 59 |
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_order_item_class', 'order_item', $item, $order ) ); ?>"> |
| 60 |
<th 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'] : '' ); ?>;"> |
| 61 |
<?php |
| 62 |
|
| 63 |
if ( 'Bottom' == $orderImagePostions && '1' == $orderImage ) { |
| 64 |
echo ( '<div class="yaymail-product-text" style="padding: 5px 0;">' ); |
| 65 |
// Product name |
| 66 |
echo wp_kses_post( '<span class="yaymail-product-name" data-sku=' . $product->get_sku() . '>' . $item->get_name() . '</span>' ); |
| 67 |
|
| 68 |
// SKU |
| 69 |
if ( $args['show_sku'] && is_object( $product ) && $product->get_sku() ) { |
| 70 |
echo wp_kses_post( '<span class="yaymail-product-sku"> (#' . $product->get_sku() . ')</span>' ); |
| 71 |
} |
| 72 |
// allow other plugins to add additional product information here |
| 73 |
do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $args['plain_text'] ); |
| 74 |
|
| 75 |
// Display item meta data. |
| 76 |
wc_display_item_meta( $item ); |
| 77 |
|
| 78 |
echo ( '</div>' ); |
| 79 |
// Show title/image etc |
| 80 |
if ( $args['show_image'] && is_object( $product ) ) { |
| 81 |
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() ? current( wp_get_attachment_image_src( $product->get_image_id(), $args['image_size'][2] ) ) : 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 ) ); |
| 82 |
} |
| 83 |
} else { |
| 84 |
// Show title/image etc |
| 85 |
if ( $args['show_image'] && is_object( $product ) ) { |
| 86 |
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() ? current( wp_get_attachment_image_src( $product->get_image_id(), $args['image_size'][2] ) ) : 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 ) ); |
| 87 |
} |
| 88 |
echo ( '<div style="padding: 5px 0;">' ); |
| 89 |
// Product name |
| 90 |
echo wp_kses_post( '<span class="yaymail-product-name" data-sku=' . $product->get_sku() . '>' . $item->get_name() . '</span>' ); |
| 91 |
|
| 92 |
// SKU |
| 93 |
if ( $args['show_sku'] && is_object( $product ) && $product->get_sku() ) { |
| 94 |
echo wp_kses_post( '<span class="yaymail-product-sku"> (#' . $product->get_sku() . ')</span>' ); |
| 95 |
} |
| 96 |
// allow other plugins to add additional product information here |
| 97 |
do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $args['plain_text'] ); |
| 98 |
|
| 99 |
// Display item meta data. |
| 100 |
wc_display_item_meta( $item ); |
| 101 |
|
| 102 |
echo ( '</div>' ); |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
// Display item download links. |
| 107 |
if ( $args['show_download_links'] ) { |
| 108 |
wc_display_item_downloads( $item ); |
| 109 |
} |
| 110 |
|
| 111 |
// allow other plugins to add additional product information here |
| 112 |
do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $args['plain_text'] ); |
| 113 |
?> |
| 114 |
|
| 115 |
</th> |
| 116 |
<th class="td" 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'] : '' ); ?>;"> |
| 117 |
<?php echo wp_kses_post( apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item ) ); ?> |
| 118 |
</th> |
| 119 |
<th class="td" 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;"> |
| 120 |
<?php echo wp_kses_post( $order->get_formatted_line_subtotal( $item ) ); ?> |
| 121 |
</th> |
| 122 |
</tr> |
| 123 |
<?php |
| 124 |
} |
| 125 |
|
| 126 |
// Show purchase note |
| 127 |
$purchase_note = $product->get_purchase_note(); |
| 128 |
if ( ( 'customer_on_hold_order' === $this->template |
| 129 |
|| 'customer_processing_order' === $this->template |
| 130 |
|| 'customer_completed_order' === $this->template |
| 131 |
|| 'customer_refunded_order' === $this->template |
| 132 |
|| 'customer_invoice' === $this->template |
| 133 |
|| 'customer_note' === $this->template ) |
| 134 |
&& isset( $args['show_purchase_note'] ) |
| 135 |
&& is_object( $product ) |
| 136 |
&& ! empty( $purchase_note ) |
| 137 |
) { |
| 138 |
?> |
| 139 |
|
| 140 |
<tr> |
| 141 |
<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'] : '' ); ?>;"> |
| 142 |
<?php echo wp_kses_post( wpautop( do_shortcode( $purchase_note ) ) ); ?> |
| 143 |
</th> |
| 144 |
</tr> |
| 145 |
|
| 146 |
<?php } ?> |
| 147 |
|
| 148 |
<?php endforeach; ?> |
| 149 |
|