Guest User

Untitled

a guest
Feb 25th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. add_filter( 'sliced_invoice_line_items_output', 'sliced_display_woocommerce_line_items_20180213', 9, 1 );
  2. function sliced_display_woocommerce_line_items_20180213( $output ) {
  3.  
  4. $order = sliced_woocommerce_get_order();
  5.  
  6. if( ! isset( $order ) || $order == false || empty( $order ) )
  7. return $output;
  8.  
  9. $output = null;
  10. $output = '<table class="table table-sm table-bordered table-striped">
  11. <thead>
  12. <tr>
  13. <th class="qty"><strong>' . __( "Hrs/Qty", "sliced-invoices" ) . '</strong></th>
  14. <th class="service"><strong>' . __( "Service", "sliced-invoices" ) . '</strong></th>
  15. <th class="sku"><strong>' . __( "SKU", "sliced-invoices" ) . '</strong></th>
  16. <th class="rate"><strong>' . __( "Rate/Price", "sliced-invoices" ) . '</strong></th>';
  17. $output .= '<th class="total"><strong>' . __( "Sub Total", "sliced-invoices" ) . '</strong></th>
  18. </tr>
  19. </thead>
  20. <tbody>';
  21.  
  22. foreach( $order->get_items() as $item_id => $item ) {
  23.  
  24. $class = ($count % 2 == 0) ? "even" : "odd";
  25.  
  26. $product = apply_filters( 'woocommerce_order_item_product', $order->get_product_from_item( $item ), $item );
  27. $purchase_note = get_post_meta( $product->get_id(), '_purchase_note', true );
  28.  
  29. $is_visible = $product && $product->is_visible();
  30.  
  31. $output .= '<tr class="row_' . esc_attr( $class ) . ' sliced-item">';
  32.  
  33. $output .= '<td class="qty">' . apply_filters( 'woocommerce_order_item_quantity_html', ' <strong class="product-quantity">' . sprintf( '%s', wp_kses_post( $item['qty'] ) ) . '</strong>', $item ) . '</td>';
  34.  
  35. $output .= '<td class="service">' . apply_filters( 'woocommerce_order_item_name', $is_visible ? sprintf( '<a href="%s">%s</a>', get_permalink( $item['product_id'] ), $item['name'] ) : $item['name'], $item, $is_visible ) . '</td>';
  36.  
  37. $output .= '<td class="sku">' . $product->get_sku() . '</td>';
  38.  
  39. $output .= '<td class="rate">' . wp_kses_post( wc_price( $order->get_item_subtotal( $item ) ) ) . '</td>';
  40.  
  41. $output .= '<td class="total">' . wp_kses_post( $order->get_formatted_line_subtotal( $item ) ) . '</td>';
  42.  
  43. $output .= '</tr>';
  44.  
  45. $count++;
  46. }
  47.  
  48. $output .= '</tbody></table>';
  49.  
  50. return $output;
  51. }
Add Comment
Please, Sign In to add comment