/wp-content/themes/khallaghiatkadeh/profile/parent/shop/index.php

https://gitlab.com/nasservb/khalagh · PHP · 102 lines · 87 code · 15 blank · 0 comment · 5 complexity · f459415d745b55f12ad9140bc6416ea0 MD5 · raw file

  1. <?php
  2. $my_orders_columns = apply_filters( 'woocommerce_my_account_my_orders_columns', array(
  3. 'order-number' => __( 'Order', 'woocommerce' ),
  4. 'order-date' => __( 'Date', 'woocommerce' ),
  5. 'order-status' => __( 'Status', 'woocommerce' ),
  6. 'order-total' => __( 'Total', 'woocommerce' ),
  7. 'order-actions' => '&nbsp;',
  8. ) );
  9. $customer_orders = get_posts( apply_filters( 'woocommerce_my_account_my_orders_query', array(
  10. 'numberposts' => 40,
  11. 'meta_key' => '_customer_user',
  12. 'meta_value' => get_current_user_id(),
  13. 'post_type' => wc_get_order_types( 'view-orders' ),
  14. 'post_status' => array_keys( wc_get_order_statuses() )
  15. ) ) );
  16. if ( $customer_orders ) : ?>
  17. <h2><?php echo apply_filters( 'woocommerce_my_account_my_orders_title', __( 'Recent Orders', 'woocommerce' ) ); ?></h2>
  18. <table class="table table-bordered table-striped table-hovered shop_table shop_table_responsive my_account_orders">
  19. <thead>
  20. <tr>
  21. <?php foreach ( $my_orders_columns as $column_id => $column_name ) : ?>
  22. <th class="<?php echo esc_attr( $column_id ); ?>"><span class="nobr"><?php echo esc_html( $column_name ); ?></span></th>
  23. <?php endforeach; ?>
  24. </tr>
  25. </thead>
  26. <tbody>
  27. <?php foreach ( $customer_orders as $customer_order ) :
  28. $order = wc_get_order( $customer_order );
  29. $item_count = $order->get_item_count();
  30. ?>
  31. <tr class="order">
  32. <?php foreach ( $my_orders_columns as $column_id => $column_name ) : ?>
  33. <td class="<?php echo esc_attr( $column_id ); ?>" data-title="<?php echo esc_attr( $column_name ); ?>">
  34. <?php if ( has_action( 'woocommerce_my_account_my_orders_column_' . $column_id ) ) : ?>
  35. <?php do_action( 'woocommerce_my_account_my_orders_column_' . $column_id, $order ); ?>
  36. <?php elseif ( 'order-number' === $column_id ) : ?>
  37. <a href="<?php echo '?dir=shop&p=view-order&order='.$order->get_order_number(); ?>">
  38. <?php echo _x( '#', 'hash before order number', 'woocommerce' ) . $order->get_order_number(); ?>
  39. </a>
  40. <?php elseif ( 'order-date' === $column_id ) : ?>
  41. <time datetime="<?php echo date( 'Y-m-d', strtotime( $order->order_date ) ); ?>" title="<?php echo esc_attr( strtotime( $order->order_date ) ); ?>"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ); ?></time>
  42. <?php elseif ( 'order-status' === $column_id ) : ?>
  43. <?php echo wc_get_order_status_name( $order->get_status() ); ?>
  44. <?php elseif ( 'order-total' === $column_id ) : ?>
  45. <?php echo sprintf( _n( '%s for %s item', '%s for %s items', $item_count, 'woocommerce' ), $order->get_formatted_order_total(), $item_count ); ?>
  46. <?php elseif ( 'order-actions' === $column_id ) : ?>
  47. <?php
  48. $actions = array(
  49. 'pay' => array(
  50. 'url' => $order->get_checkout_payment_url(),
  51. 'name' => __( 'Pay', 'woocommerce' ),
  52. 'class'=> 'btn-success'
  53. ),
  54. 'view' => array(
  55. 'url' => '?dir=shop&p=view-order&order='.$order->get_order_number(),
  56. 'name' => __( 'View', 'woocommerce' ),
  57. 'class'=> 'btn-primary'
  58. ),
  59. 'cancel' => array(
  60. 'url' => $order->get_cancel_order_url( $_SERVER['REQUEST_URI']),
  61. 'name' => __( 'Cancel', 'woocommerce' ),
  62. 'class'=> 'btn-warning'
  63. )
  64. );
  65. if ( ! $order->needs_payment() ) {
  66. unset( $actions['pay'] );
  67. }
  68. if ( ! in_array( $order->get_status(), apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) ) ) {
  69. unset( $actions['cancel'] );
  70. }
  71. if ( $actions = apply_filters( 'woocommerce_my_account_my_orders_actions', $actions, $order ) ) {
  72. foreach ( $actions as $key => $action ) {
  73. echo '<a href="' . esc_url( $action['url'] ) . '" class="button btn ' . $action['class'].' '.sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>'."\t";
  74. }
  75. }
  76. ?>
  77. <?php endif; ?>
  78. </td>
  79. <?php endforeach; ?>
  80. </tr>
  81. <?php endforeach; ?>
  82. </tbody>
  83. </table>
  84. <?php
  85. else:
  86. echo '<div class="alert alert-info">سفارشی یافت نشد . </div>';
  87. endif; ?>