evolve_woocommerce_before_account_orders

The evolve evolve woocommerce before account orders function.

Description

evolve_woocommerce_before_account_orders( $args ); 

Parameters (1)

0. $args
The args.

Usage

  1. if ( !function_exists( 'evolve_woocommerce_before_account_orders' ) ) { 
  2. require_once '/library/woo-config.php'; 
  3.  
  4. // The args. 
  5. $args = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = evolve_woocommerce_before_account_orders($args); 
  9.  

Defined (1)

The function is defined in the following location(s).

/library/woo-config.php  
  1. function evolve_woocommerce_before_account_orders($args) { 
  2. $order_count = ""; 
  3. $my_orders_columns = apply_filters('woocommerce_my_account_my_orders_columns', array( 
  4. 'order-number' => __('Order', 'evolve'),  
  5. 'order-date' => __('Date', 'evolve'),  
  6. 'order-status' => __('Status', 'evolve'),  
  7. 'order-total' => __('Total', 'evolve'),  
  8. 'order-actions' => ' ',  
  9. )); 
  10.  
  11. $customer_orders = get_posts(apply_filters('woocommerce_my_account_my_orders_query', array( 
  12. 'numberposts' => $order_count,  
  13. 'meta_key' => '_customer_user',  
  14. 'meta_value' => get_current_user_id(),  
  15. 'post_type' => wc_get_order_types('view-orders'),  
  16. 'post_status' => array_keys(wc_get_order_statuses()) 
  17. ))); 
  18.  
  19. if ($customer_orders) : 
  20. ?> 
  21.  
  22. <h2><?php echo apply_filters('woocommerce_my_account_my_orders_title', __('Recent Orders', 'evolve')); ?></h2> 
  23.  
  24. <table class="shop_table shop_table_responsive my_account_orders"> 
  25.  
  26. <thead> 
  27. <tr> 
  28. <?php foreach ($my_orders_columns as $column_id => $column_name) : ?> 
  29. <th class="<?php echo esc_attr($column_id); ?>"><span class="nobr"><?php echo esc_html($column_name); ?></span></th> 
  30. <?php endforeach; ?> 
  31. </tr> 
  32. </thead> 
  33.  
  34. <tbody> 
  35. <?php 
  36. foreach ($customer_orders as $customer_order) : 
  37. $order = wc_get_order($customer_order); 
  38. $item_count = $order->get_item_count(); 
  39. ?> 
  40. <tr class="order"> 
  41. <?php foreach ($my_orders_columns as $column_id => $column_name) : ?> 
  42. <td class="<?php echo esc_attr($column_id); ?>" data-title="<?php echo esc_attr($column_name); ?>"> 
  43. <?php if (has_action('woocommerce_my_account_my_orders_column_' . $column_id)) : ?> 
  44.  
  45. <?php elseif ('order-number' === $column_id) : ?> 
  46. <a href="<?php echo esc_url($order->get_view_order_url()); ?>"> 
  47. <?php echo _x('#', 'hash before order number', 'evolve') . $order->get_order_number(); ?> 
  48. </a> 
  49.  
  50. <?php elseif ('order-date' === $column_id) : ?> 
  51. <?php echo wc_format_datetime( $order->get_date_created() ); ?> 
  52.  
  53. <?php elseif ('order-status' === $column_id) : ?> 
  54. <?php echo wc_get_order_status_name($order->get_status()); ?> 
  55.  
  56. <?php elseif ('order-total' === $column_id) : ?> 
  57. <?php echo sprintf(_n('%s for %s item', '%s for %s items', $item_count, 'evolve'), $order->get_formatted_order_total(), $item_count); ?> 
  58.  
  59. <?php elseif ('order-actions' === $column_id) : ?> 
  60. <?php 
  61. $actions = array( 
  62. 'pay' => array( 
  63. 'url' => $order->get_checkout_payment_url(),  
  64. 'name' => __('Pay', 'evolve') 
  65. ),  
  66. 'view' => array( 
  67. 'url' => $order->get_view_order_url(),  
  68. 'name' => __('View', 'evolve') 
  69. ),  
  70. 'cancel' => array( 
  71. 'url' => $order->get_cancel_order_url(wc_get_page_permalink('myaccount')),  
  72. 'name' => __('Cancel', 'evolve') 
  73. ); 
  74.  
  75. if (!$order->needs_payment()) { 
  76. unset($actions['pay']); 
  77.  
  78. if (!in_array($order->get_status(), apply_filters('woocommerce_valid_order_statuses_for_cancel', array('pending', 'failed'), $order))) { 
  79. unset($actions['cancel']); 
  80.  
  81. if ($actions = apply_filters('woocommerce_my_account_my_orders_actions', $actions, $order)) { 
  82. foreach ($actions as $key => $action) { 
  83. echo '<a href="' . esc_url($action['url']) . '" class="button ' . sanitize_html_class($key) . '">' . esc_html($action['name']) . '</a>'; 
  84. ?> 
  85. <?php endif; ?> 
  86. </td> 
  87. <?php endforeach; ?> 
  88. </tr> 
  89. <?php endforeach; ?> 
  90. </tbody> 
  91. </table> 
  92. <?php else : ?> 
  93. <div class="woocommerce-Message woocommerce-Message--info woocommerce-info my_account_orders"> 
  94. <a class="woocommerce-Button button" href="<?php echo esc_url(apply_filters('woocommerce_return_to_shop_redirect', wc_get_page_permalink('shop'))); ?>"> 
  95. <?php _e('Go Shop', 'evolve') ?> 
  96. </a> 
  97. <?php _e('No order has been made yet.', 'evolve'); ?> 
  98. </div> 
  99. <?php 
  100. endif;