Skip to content

Commit

Permalink
Fix: WCFM withdraw plugin select switch case (#14)
Browse files Browse the repository at this point in the history
* Fix: wcvendors withdraw plugin select switch case

* Fix: wcvendors withdraw plugin select switch case

* Fix: wcvendors withdraw plugin select switch case

* ⚡️Fix: exclude dokan orders, migrate wcfm orders only.

* ⚡️Fix: exclude dokan orders, migrate wcfm orders only.

* ⚡️Fix: exclude dokan orders, migrate wcfm orders only.

* ⚡️Fix: exclude dokan orders, migrate wcfm orders only.

* ⚡️Fix: exclude dokan orders, migrate wcfm orders only.

* ⚡️Fix: exclude dokan orders, migrate wcfm orders only.

* ⚡️HPOS support

* add paged parameter in get_items in processor and in other classes that extended it.
  • Loading branch information
Aunshon authored Nov 30, 2023
1 parent e8e218c commit b32e964
Showing 1 changed file with 36 additions and 9 deletions.
45 changes: 36 additions & 9 deletions includes/Processors/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,18 @@ class Order extends Processor {
* @return integer
*/
public static function get_total( $plugin ) {
return (int) dokan()->order->all( [ 'return' => 'count', 'parent' => 0, ] );
global $wpdb;

switch ( $plugin ) {
case 'wcfmmarketplace':
$total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT order_id ) FROM {$wpdb->prefix}wcfm_marketplace_orders" );
break;

default:
$total = 0;
}

return $total;
}

/**
Expand All @@ -41,14 +52,30 @@ public static function get_total( $plugin ) {
*/
public static function get_items( $plugin, $number, $offset, $paged ) {
global $wpdb;
$args = array(
'order' => 'ASC',
'paged' => $paged,
'limit' => $number,
'parent' => 0,
);

$orders = dokan()->order->all( $args );

switch ( $plugin ) {
case 'wcfmmarketplace':
$orders = [];
$wcfm_orders = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT order_id FROM {$wpdb->prefix}wcfm_marketplace_orders LIMIT %d OFFSET %d", $number, $offset ), ARRAY_A );
$wcfm_orders = array_map(
function ( $item ) {
return $item['order_id'];
},
$wcfm_orders
);

if ( ! empty( $wcfm_orders ) ) {
$orders = dokan()->order->all(
[
'include' => $wcfm_orders,
]
);
}
break;

default:
$orders = [];
}

if ( empty( $orders ) ) {
self::throw_error();
Expand Down

0 comments on commit b32e964

Please sign in to comment.