Skip to content

Commit

Permalink
fix: add failed order in order listing page is fixed #632 (#633)
Browse files Browse the repository at this point in the history
  • Loading branch information
saimonh3 authored and sabbir1991 committed Jun 10, 2019
1 parent c32e41d commit 84ec330
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
11 changes: 10 additions & 1 deletion includes/order-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,16 @@ function dokan_count_orders( $user_id ) {
$counts = wp_cache_get( $cache_key, $cache_group );

if ( $counts === false ) {
$counts = array('wc-pending' => 0, 'wc-completed' => 0, 'wc-on-hold' => 0, 'wc-processing' => 0, 'wc-refunded' => 0, 'wc-cancelled' => 0, 'total' => 0);
$counts = [
'wc-pending' => 0,
'wc-completed' => 0,
'wc-on-hold' => 0,
'wc-processing' => 0,
'wc-refunded' => 0,
'wc-cancelled' => 0,
'wc-failed' => 0,
'total' => 0
];

$results = $wpdb->get_results( $wpdb->prepare( "SELECT do.order_status
FROM {$wpdb->prefix}dokan_orders AS do
Expand Down
16 changes: 16 additions & 0 deletions includes/template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ function dokan_order_listing_status_filter() {
$on_hold_order_url = array();
$canceled_order_url = array();
$refund_order_url = array();
$failed_order_url = array();
?>

<ul class="list-inline order-statuses-filter">
Expand Down Expand Up @@ -281,6 +282,21 @@ function dokan_order_listing_status_filter() {
<?php printf( esc_html__( 'Refunded (%d)', 'dokan-lite' ), esc_attr( $orders_counts->{'wc-refunded'} ) ); ?></span>
</a>
</li>
<li<?php echo $status_class == 'wc-failed' ? ' class="active"' : ''; ?>>
<?php
if ( $order_date ) {
$date_filter = array(
'order_date' => $order_date,
'dokan_order_filter' => 'Filter',
);
}

$failed_order_url = array_merge( $date_filter, array( 'order_status' => 'wc-failed' ) );
?>
<a href="<?php echo esc_url( add_query_arg( $failed_order_url, $orders_url ) ); ?>">
<?php printf( esc_html__( 'Failed (%d)', 'dokan-lite' ), esc_attr( $orders_counts->{'wc-failed'} ) ); ?></span>
</a>
</li>

<?php do_action( 'dokan_status_listing_item', $orders_counts ); ?>
</ul>
Expand Down

0 comments on commit 84ec330

Please sign in to comment.