Plugin Directory

Changeset 3448792


Ignore:
Timestamp:
01/28/2026 02:47:26 PM (2 months ago)
Author:
arture
Message:

Version 2.3.5

Location:
order-picking-app/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • order-picking-app/trunk/admin/partials/orderpickingapp-settings-page.php

    r3444011 r3448792  
    251251                            <div class="form-check">
    252252                                <input type="checkbox" class="form-check-input" name="orderpickingapp_order_status" value="<?php echo $key;?>" <?php echo ( isset($app_settings['orderpickingapp_order_status']) && in_array($key, $app_settings['orderpickingapp_order_status']) )? 'checked' : ''; ?>>
    253                                 <label class="form-check-label" for="<?php echo $key;?>"><?php echo $name;?></label>
     253                                <label class="form-check-label" for="<?php echo $key;?>"><?php echo $name;?> <?php echo ( $key == 'wc-completed' )? '(and picking status is not "Completed")' : ''; ?></label>
    254254                            </div>
    255255                        <?php endforeach; ?>
  • order-picking-app/trunk/includes/class-orderpickingapp.php

    r3447103 r3448792  
    270270                    global $wpdb;
    271271
    272                     $order_statussen = array('wc-processing');
     272                    $order_statuses = array('wc-processing');
    273273                    $orderpickingapp_order_status = get_option('orderpickingapp_order_status');
    274274                    if (isset($orderpickingapp_order_status) && !empty($orderpickingapp_order_status)) {
    275                         $order_statussen = (array)$orderpickingapp_order_status;
    276                     }
    277                     $statusPlaceholders = implode(',', array_fill(0, count($order_statussen), '%s'));
     275                        $order_statuses = (array)$orderpickingapp_order_status;
     276                    }
     277                    $statusPlaceholders = implode(',', array_fill(0, count($order_statuses), '%s'));
    278278
    279279                    $date_filter = '';
     
    292292                    }
    293293
    294                     // 1. Haal alle order-IDs op met de gewenste status en datumfilter
    295                     if ($this->is_hpos_enabled()) {
    296                         // Query voor HPOS
    297                         $order_ids_query = $wpdb->prepare("
    298                             SELECT id
    299                             FROM {$wpdb->prefix}wc_orders
    300                             WHERE type = 'shop_order'
    301                             AND status IN ($statusPlaceholders)
    302                             {$date_filter}
    303                             LIMIT 1000
    304                         ", ...$order_statussen);
    305                     } else {
    306                         // Query voor traditionele opslag
    307                         $order_ids_query = $wpdb->prepare("
    308                             SELECT ID
    309                             FROM {$wpdb->posts}
    310                             WHERE post_type = 'shop_order'
    311                             AND post_status IN ($statusPlaceholders)
    312                             {$date_filter}
    313                             LIMIT 1000
    314                         ", ...$order_statussen);
    315                     }
    316 
    317                     $order_ids = $wpdb->get_col($order_ids_query);
     294                    $has_completed = in_array('wc-completed', $order_statuses, true);
     295                    $non_completed_statuses = array_values(array_diff($order_statuses, array('wc-completed')));
     296
     297                    $order_ids = array();
     298
     299                    // 1) NIET-completed statussen (zoals je al deed)
     300                    if (!empty($non_completed_statuses)) {
     301                        $statusPlaceholders = implode(',', array_fill(0, count($non_completed_statuses), '%s'));
     302
     303                        if ($this->is_hpos_enabled()) {
     304                            $order_ids_query = $wpdb->prepare("
     305                                SELECT id
     306                                FROM {$wpdb->prefix}wc_orders
     307                                WHERE type = 'shop_order'
     308                                  AND status IN ($statusPlaceholders)
     309                                  {$date_filter}
     310                                LIMIT 1000
     311                            ", ...$non_completed_statuses);
     312                        } else {
     313                            $order_ids_query = $wpdb->prepare("
     314                                SELECT ID
     315                                FROM {$wpdb->posts}
     316                                WHERE post_type = 'shop_order'
     317                                  AND post_status IN ($statusPlaceholders)
     318                                  {$date_filter}
     319                                LIMIT 1000
     320                            ", ...$non_completed_statuses);
     321                        }
     322
     323                        $order_ids = $wpdb->get_col($order_ids_query);
     324                    }
     325
     326                    // 2) wc-completed mét meta picking_status != 'completed' (meta MOET bestaan)
     327                    if ($has_completed) {
     328                        if ($this->is_hpos_enabled()) {
     329                            // HPOS: wc_orders + wc_orders_meta
     330                            $completed_ids_query = $wpdb->prepare("
     331                                                    SELECT o.id
     332                                                    FROM {$wpdb->prefix}wc_orders o
     333                                                    LEFT JOIN {$wpdb->prefix}wc_orders_meta m
     334                                                           ON o.id = m.order_id
     335                                                          AND m.meta_key = 'picking_status'
     336                                                    WHERE o.type = 'shop_order'
     337                                                      AND o.status = %s
     338                                                      {$date_filter}
     339                                                      AND (m.meta_value IS NULL OR m.meta_value != 'completed')
     340                                                    LIMIT 1000
     341                                                ", 'wc-completed');
     342                        } else {
     343                            // Legacy: posts + postmeta
     344                            $completed_ids_query = $wpdb->prepare("
     345                                                    SELECT p.ID
     346                                                    FROM {$wpdb->posts} p
     347                                                    LEFT JOIN {$wpdb->postmeta} pm
     348                                                           ON p.ID = pm.post_id
     349                                                          AND pm.meta_key = 'picking_status'
     350                                                    WHERE p.post_type = 'shop_order'
     351                                                      AND p.post_status = %s
     352                                                      {$date_filter}
     353                                                      AND (pm.meta_value IS NULL OR pm.meta_value != 'completed')
     354                                                    LIMIT 1000
     355                                                ", 'wc-completed');
     356                        }
     357
     358                        $completed_ids = $wpdb->get_col($completed_ids_query);
     359
     360                        if (!empty($completed_ids)) {
     361                            $order_ids = array_merge($order_ids, $completed_ids);
     362                        }
     363                    }
     364
     365                    // Uniek + totale safety limit (max 1000 totaal)
     366                    $order_ids = array_values(array_unique(array_map('intval', $order_ids)));
     367                    $order_ids = array_slice($order_ids, 0, 1000);
    318368
    319369                    $all_open_orders = array();
     
    591641                    global $wpdb;
    592642
    593                     $order_statussen = array('wc-processing');
     643                    $order_statuses = array('wc-processing');
    594644                    $orderpickingapp_order_status = get_option('orderpickingapp_order_status');
    595645                    if (isset($orderpickingapp_order_status) && !empty($orderpickingapp_order_status)) {
    596                         $order_statussen = (array)$orderpickingapp_order_status;
    597                     }
    598                     $statusPlaceholders = implode(',', array_fill(0, count($order_statussen), '%s'));
     646                        $order_statuses = (array)$orderpickingapp_order_status;
     647                    }
     648                    $statusPlaceholders = implode(',', array_fill(0, count($order_statuses), '%s'));
    599649
    600650                    $date_filter = '';
     
    613663                    }
    614664
    615                     // 1. Haal alle order-IDs op met de gewenste status en datumfilter
    616                     if ($this->is_hpos_enabled()) {
    617                         // Query voor HPOS
    618                         $order_ids_query = $wpdb->prepare("
    619                             SELECT id
    620                             FROM {$wpdb->prefix}wc_orders
    621                             WHERE type = 'shop_order'
    622                             AND status IN ($statusPlaceholders)
    623                             {$date_filter}
    624                             LIMIT 1000
    625                         ", ...$order_statussen);
    626                     } else {
    627                         // Query voor traditionele opslag
    628                         $order_ids_query = $wpdb->prepare("
    629                             SELECT ID
    630                             FROM {$wpdb->posts}
    631                             WHERE post_type = 'shop_order'
    632                             AND post_status IN ($statusPlaceholders)
    633                             {$date_filter}
    634                             LIMIT 1000
    635                         ", ...$order_statussen);
    636                     }
    637 
    638                     $order_ids = $wpdb->get_col($order_ids_query);
     665                    $has_completed = in_array('wc-completed', $order_statuses, true);
     666                    $non_completed_statuses = array_values(array_diff($order_statuses, array('wc-completed')));
     667
     668                    $order_ids = array();
     669
     670                    // 1) NIET-completed statussen (zoals je al deed)
     671                    if (!empty($non_completed_statuses)) {
     672                        $statusPlaceholders = implode(',', array_fill(0, count($non_completed_statuses), '%s'));
     673
     674                        if ($this->is_hpos_enabled()) {
     675                            $order_ids_query = $wpdb->prepare("
     676                                SELECT id
     677                                FROM {$wpdb->prefix}wc_orders
     678                                WHERE type = 'shop_order'
     679                                  AND status IN ($statusPlaceholders)
     680                                  {$date_filter}
     681                                LIMIT 1000
     682                            ", ...$non_completed_statuses);
     683                        } else {
     684                            $order_ids_query = $wpdb->prepare("
     685                                SELECT ID
     686                                FROM {$wpdb->posts}
     687                                WHERE post_type = 'shop_order'
     688                                  AND post_status IN ($statusPlaceholders)
     689                                  {$date_filter}
     690                                LIMIT 1000
     691                            ", ...$non_completed_statuses);
     692                        }
     693
     694                        $order_ids = $wpdb->get_col($order_ids_query);
     695                    }
     696
     697                    // 2) wc-completed mét meta picking_status != 'completed' (meta MOET bestaan)
     698                    if ($has_completed) {
     699                        if ($this->is_hpos_enabled()) {
     700                            // HPOS: wc_orders + wc_orders_meta
     701                            $completed_ids_query = $wpdb->prepare("
     702                                                    SELECT o.id
     703                                                    FROM {$wpdb->prefix}wc_orders o
     704                                                    LEFT JOIN {$wpdb->prefix}wc_orders_meta m
     705                                                           ON o.id = m.order_id
     706                                                          AND m.meta_key = 'picking_status'
     707                                                    WHERE o.type = 'shop_order'
     708                                                      AND o.status = %s
     709                                                      {$date_filter}
     710                                                      AND (m.meta_value IS NULL OR m.meta_value != 'completed')
     711                                                    LIMIT 1000
     712                                                ", 'wc-completed');
     713                        } else {
     714                            // Legacy: posts + postmeta
     715                            $completed_ids_query = $wpdb->prepare("
     716                                                    SELECT p.ID
     717                                                    FROM {$wpdb->posts} p
     718                                                    LEFT JOIN {$wpdb->postmeta} pm
     719                                                           ON p.ID = pm.post_id
     720                                                          AND pm.meta_key = 'picking_status'
     721                                                    WHERE p.post_type = 'shop_order'
     722                                                      AND p.post_status = %s
     723                                                      {$date_filter}
     724                                                      AND (pm.meta_value IS NULL OR pm.meta_value != 'completed')
     725                                                    LIMIT 1000
     726                                                ", 'wc-completed');
     727                        }
     728
     729                        $completed_ids = $wpdb->get_col($completed_ids_query);
     730
     731                        if (!empty($completed_ids)) {
     732                            $order_ids = array_merge($order_ids, $completed_ids);
     733                        }
     734                    }
     735
     736                    // Uniek + totale safety limit (max 1000 totaal)
     737                    $order_ids = array_values(array_unique(array_map('intval', $order_ids)));
     738                    $order_ids = array_slice($order_ids, 0, 1000);
    639739
    640740                    $all_open_orders = array();
     
    792892                    global $wpdb;
    793893
    794                     $order_statussen = array('wc-processing');
     894                    $order_statuses = array('wc-processing');
    795895                    $orderpickingapp_order_status = get_option('orderpickingapp_order_status');
    796896                    if (isset($orderpickingapp_order_status) && !empty($orderpickingapp_order_status)) {
    797                         $order_statussen = (array)$orderpickingapp_order_status;
    798                     }
    799                     $statusPlaceholders = implode(',', array_fill(0, count($order_statussen), '%s'));
     897                        $order_statuses = (array)$orderpickingapp_order_status;
     898                    }
     899                    $statusPlaceholders = implode(',', array_fill(0, count($order_statuses), '%s'));
    800900
    801901                    $date_filter = '';
     
    814914                    }
    815915
    816                     // 1. Haal alle order-IDs op met de gewenste status en datumfilter
    817                     if ($this->is_hpos_enabled()) {
    818                         // Query voor HPOS
    819                         $order_ids_query = $wpdb->prepare("
    820                             SELECT id
    821                             FROM {$wpdb->prefix}wc_orders
    822                             WHERE type = 'shop_order'
    823                             AND status IN ($statusPlaceholders)
    824                             {$date_filter}
    825                             LIMIT 1000
    826                         ", ...$order_statussen);
    827                     } else {
    828                         // Query voor traditionele opslag
    829                         $order_ids_query = $wpdb->prepare("
    830                             SELECT ID
    831                             FROM {$wpdb->posts}
    832                             WHERE post_type = 'shop_order'
    833                             AND post_status IN ($statusPlaceholders)
    834                             {$date_filter}
    835                             LIMIT 1000
    836                         ", ...$order_statussen);
    837                     }
    838 
    839                     $order_ids = $wpdb->get_col($order_ids_query);
     916                    $has_completed = in_array('wc-completed', $order_statuses, true);
     917                    $non_completed_statuses = array_values(array_diff($order_statuses, array('wc-completed')));
     918
     919                    $order_ids = array();
     920
     921                    // 1) NIET-completed statussen (zoals je al deed)
     922                    if (!empty($non_completed_statuses)) {
     923                        $statusPlaceholders = implode(',', array_fill(0, count($non_completed_statuses), '%s'));
     924
     925                        if ($this->is_hpos_enabled()) {
     926                            $order_ids_query = $wpdb->prepare("
     927                                SELECT id
     928                                FROM {$wpdb->prefix}wc_orders
     929                                WHERE type = 'shop_order'
     930                                  AND status IN ($statusPlaceholders)
     931                                  {$date_filter}
     932                                LIMIT 1000
     933                            ", ...$non_completed_statuses);
     934                        } else {
     935                            $order_ids_query = $wpdb->prepare("
     936                                SELECT ID
     937                                FROM {$wpdb->posts}
     938                                WHERE post_type = 'shop_order'
     939                                  AND post_status IN ($statusPlaceholders)
     940                                  {$date_filter}
     941                                LIMIT 1000
     942                            ", ...$non_completed_statuses);
     943                        }
     944
     945                        $order_ids = $wpdb->get_col($order_ids_query);
     946                    }
     947
     948                    // 2) wc-completed mét meta picking_status != 'completed' (meta MOET bestaan)
     949                    if ($has_completed) {
     950                        if ($this->is_hpos_enabled()) {
     951                            // HPOS: wc_orders + wc_orders_meta
     952                            $completed_ids_query = $wpdb->prepare("
     953                                                    SELECT o.id
     954                                                    FROM {$wpdb->prefix}wc_orders o
     955                                                    LEFT JOIN {$wpdb->prefix}wc_orders_meta m
     956                                                           ON o.id = m.order_id
     957                                                          AND m.meta_key = 'picking_status'
     958                                                    WHERE o.type = 'shop_order'
     959                                                      AND o.status = %s
     960                                                      {$date_filter}
     961                                                      AND (m.meta_value IS NULL OR m.meta_value != 'completed')
     962                                                    LIMIT 1000
     963                                                ", 'wc-completed');
     964                        } else {
     965                            // Legacy: posts + postmeta
     966                            $completed_ids_query = $wpdb->prepare("
     967                                                    SELECT p.ID
     968                                                    FROM {$wpdb->posts} p
     969                                                    LEFT JOIN {$wpdb->postmeta} pm
     970                                                           ON p.ID = pm.post_id
     971                                                          AND pm.meta_key = 'picking_status'
     972                                                    WHERE p.post_type = 'shop_order'
     973                                                      AND p.post_status = %s
     974                                                      {$date_filter}
     975                                                      AND (pm.meta_value IS NULL OR pm.meta_value != 'completed')
     976                                                    LIMIT 1000
     977                                                ", 'wc-completed');
     978                        }
     979
     980                        $completed_ids = $wpdb->get_col($completed_ids_query);
     981
     982                        if (!empty($completed_ids)) {
     983                            $order_ids = array_merge($order_ids, $completed_ids);
     984                        }
     985                    }
     986
     987                    // Uniek + totale safety limit (max 1000 totaal)
     988                    $order_ids = array_values(array_unique(array_map('intval', $order_ids)));
     989                    $order_ids = array_slice($order_ids, 0, 1000);
    840990
    841991                    $all_open_orders = array();
     
    9211071                    global $wpdb;
    9221072
    923                     $order_statussen = array('wc-processing');
     1073                    $order_statuses = array('wc-processing');
    9241074                    $orderpickingapp_order_status = get_option('orderpickingapp_order_status');
    9251075                    if (isset($orderpickingapp_order_status) && !empty($orderpickingapp_order_status)) {
    926                         $order_statussen = (array)$orderpickingapp_order_status;
    927                     }
    928                     $statusPlaceholders = implode(',', array_fill(0, count($order_statussen), '%s'));
     1076                        $order_statuses = (array)$orderpickingapp_order_status;
     1077                    }
     1078                    $statusPlaceholders = implode(',', array_fill(0, count($order_statuses), '%s'));
    9291079
    9301080                    $date_filter = '';
     
    9431093                    }
    9441094
    945                     // 1. Haal alle order-IDs op met de gewenste status en datumfilter
    946                     if ($this->is_hpos_enabled()) {
    947                         // Query voor HPOS
    948                         $order_ids_query = $wpdb->prepare("
    949                             SELECT id
    950                             FROM {$wpdb->prefix}wc_orders
    951                             WHERE type = 'shop_order'
    952                             AND status IN ($statusPlaceholders)
    953                             {$date_filter}
    954                             LIMIT 1000
    955                         ", ...$order_statussen);
    956                     } else {
    957                         // Query voor traditionele opslag
    958                         $order_ids_query = $wpdb->prepare("
    959                             SELECT ID
    960                             FROM {$wpdb->posts}
    961                             WHERE post_type = 'shop_order'
    962                             AND post_status IN ($statusPlaceholders)
    963                             {$date_filter}
    964                             LIMIT 1000
    965                         ", ...$order_statussen);
    966                     }
    967 
    968                     $order_ids = $wpdb->get_col($order_ids_query);
     1095                    $has_completed = in_array('wc-completed', $order_statuses, true);
     1096                    $non_completed_statuses = array_values(array_diff($order_statuses, array('wc-completed')));
     1097
     1098                    $order_ids = array();
     1099
     1100                    // 1) NIET-completed statussen (zoals je al deed)
     1101                    if (!empty($non_completed_statuses)) {
     1102                        $statusPlaceholders = implode(',', array_fill(0, count($non_completed_statuses), '%s'));
     1103
     1104                        if ($this->is_hpos_enabled()) {
     1105                            $order_ids_query = $wpdb->prepare("
     1106                                SELECT id
     1107                                FROM {$wpdb->prefix}wc_orders
     1108                                WHERE type = 'shop_order'
     1109                                  AND status IN ($statusPlaceholders)
     1110                                  {$date_filter}
     1111                                LIMIT 1000
     1112                            ", ...$non_completed_statuses);
     1113                        } else {
     1114                            $order_ids_query = $wpdb->prepare("
     1115                                SELECT ID
     1116                                FROM {$wpdb->posts}
     1117                                WHERE post_type = 'shop_order'
     1118                                  AND post_status IN ($statusPlaceholders)
     1119                                  {$date_filter}
     1120                                LIMIT 1000
     1121                            ", ...$non_completed_statuses);
     1122                        }
     1123
     1124                        $order_ids = $wpdb->get_col($order_ids_query);
     1125                    }
     1126
     1127                    // 2) wc-completed mét meta picking_status != 'completed' (meta MOET bestaan)
     1128                    if ($has_completed) {
     1129                        if ($this->is_hpos_enabled()) {
     1130                            // HPOS: wc_orders + wc_orders_meta
     1131                            $completed_ids_query = $wpdb->prepare("
     1132                                                    SELECT o.id
     1133                                                    FROM {$wpdb->prefix}wc_orders o
     1134                                                    LEFT JOIN {$wpdb->prefix}wc_orders_meta m
     1135                                                           ON o.id = m.order_id
     1136                                                          AND m.meta_key = 'picking_status'
     1137                                                    WHERE o.type = 'shop_order'
     1138                                                      AND o.status = %s
     1139                                                      {$date_filter}
     1140                                                      AND (m.meta_value IS NULL OR m.meta_value != 'completed')
     1141                                                    LIMIT 1000
     1142                                                ", 'wc-completed');
     1143                        } else {
     1144                            // Legacy: posts + postmeta
     1145                            $completed_ids_query = $wpdb->prepare("
     1146                                                    SELECT p.ID
     1147                                                    FROM {$wpdb->posts} p
     1148                                                    LEFT JOIN {$wpdb->postmeta} pm
     1149                                                           ON p.ID = pm.post_id
     1150                                                          AND pm.meta_key = 'picking_status'
     1151                                                    WHERE p.post_type = 'shop_order'
     1152                                                      AND p.post_status = %s
     1153                                                      {$date_filter}
     1154                                                      AND (pm.meta_value IS NULL OR pm.meta_value != 'completed')
     1155                                                    LIMIT 1000
     1156                                                ", 'wc-completed');
     1157                        }
     1158
     1159                        $completed_ids = $wpdb->get_col($completed_ids_query);
     1160
     1161                        if (!empty($completed_ids)) {
     1162                            $order_ids = array_merge($order_ids, $completed_ids);
     1163                        }
     1164                    }
     1165
     1166                    // Uniek + totale safety limit (max 1000 totaal)
     1167                    $order_ids = array_values(array_unique(array_map('intval', $order_ids)));
     1168                    $order_ids = array_slice($order_ids, 0, 1000);
    9691169
    9701170                    $all_open_orders = array();
     
    11801380                            global $wpdb;
    11811381
    1182                             $order_statussen = array('wc-processing');
     1382                            $order_statuses = array('wc-processing');
    11831383                            $orderpickingapp_order_status = get_option('orderpickingapp_order_status');
    11841384                            if (isset($orderpickingapp_order_status) && !empty($orderpickingapp_order_status)) {
    1185                                 $order_statussen = (array)$orderpickingapp_order_status;
    1186                             }
    1187                             $statusPlaceholders = implode(',', array_fill(0, count($order_statussen), '%s'));
     1385                                $order_statuses = (array)$orderpickingapp_order_status;
     1386                            }
     1387                            $statusPlaceholders = implode(',', array_fill(0, count($order_statuses), '%s'));
    11881388
    11891389                            $date_filter = '';
     
    12121412                                    {$date_filter}
    12131413                                    LIMIT 1000
    1214                                 ", ...$order_statussen);
     1414                                ", ...$order_statuses);
    12151415                            } else {
    12161416                                // Query voor traditionele opslag
     
    12221422                                    {$date_filter}
    12231423                                    LIMIT 1000
    1224                                 ", ...$order_statussen);
     1424                                ", ...$order_statuses);
    12251425                            }
    12261426
     
    18342034                    global $wpdb;
    18352035
    1836                     $order_statussen = array('wc-processing');
     2036                    $order_statuses = array('wc-processing');
    18372037                    $orderpickingapp_order_status = get_option('orderpickingapp_order_status');
    18382038                    if (isset($orderpickingapp_order_status) && !empty($orderpickingapp_order_status)) {
    1839                         $order_statussen = (array)$orderpickingapp_order_status;
    1840                     }
    1841                     $statusPlaceholders = implode(',', array_fill(0, count($order_statussen), '%s'));
     2039                        $order_statuses = (array) $orderpickingapp_order_status;
     2040                    }
    18422041
    18432042                    $date_filter = '';
     
    18562055                    }
    18572056
    1858                     // 1. Haal alle order-IDs op met de gewenste status en datumfilter
    1859                     if ($this->is_hpos_enabled()) {
    1860                         // Query voor HPOS
    1861                         $order_ids_query = $wpdb->prepare("
    1862                             SELECT id
    1863                             FROM {$wpdb->prefix}wc_orders
    1864                             WHERE type = 'shop_order'
    1865                             AND status IN ($statusPlaceholders)
    1866                             {$date_filter}
    1867                             LIMIT 1000
    1868                         ", ...$order_statussen);
    1869                     } else {
    1870                         // Query voor traditionele opslag
    1871                         $order_ids_query = $wpdb->prepare("
    1872                             SELECT ID
    1873                             FROM {$wpdb->posts}
    1874                             WHERE post_type = 'shop_order'
    1875                             AND post_status IN ($statusPlaceholders)
    1876                             {$date_filter}
    1877                             LIMIT 1000
    1878                         ", ...$order_statussen);
    1879                     }
    1880 
    1881                     $order_ids = $wpdb->get_col($order_ids_query);
     2057                    $has_completed = in_array('wc-completed', $order_statuses, true);
     2058                    $non_completed_statuses = array_values(array_diff($order_statuses, array('wc-completed')));
     2059
     2060                    $order_ids = array();
     2061
     2062                    // 1) NIET-completed statussen (zoals je al deed)
     2063                    if (!empty($non_completed_statuses)) {
     2064                        $statusPlaceholders = implode(',', array_fill(0, count($non_completed_statuses), '%s'));
     2065
     2066                        if ($this->is_hpos_enabled()) {
     2067                            $order_ids_query = $wpdb->prepare("
     2068                                SELECT id
     2069                                FROM {$wpdb->prefix}wc_orders
     2070                                WHERE type = 'shop_order'
     2071                                  AND status IN ($statusPlaceholders)
     2072                                  {$date_filter}
     2073                                LIMIT 1000
     2074                            ", ...$non_completed_statuses);
     2075                        } else {
     2076                            $order_ids_query = $wpdb->prepare("
     2077                                SELECT ID
     2078                                FROM {$wpdb->posts}
     2079                                WHERE post_type = 'shop_order'
     2080                                  AND post_status IN ($statusPlaceholders)
     2081                                  {$date_filter}
     2082                                LIMIT 1000
     2083                            ", ...$non_completed_statuses);
     2084                        }
     2085
     2086                        $order_ids = $wpdb->get_col($order_ids_query);
     2087                    }
     2088
     2089                    // 2) wc-completed mét meta picking_status != 'completed' (meta MOET bestaan)
     2090                    if ($has_completed) {
     2091                        if ($this->is_hpos_enabled()) {
     2092                            // HPOS: wc_orders + wc_orders_meta
     2093                            $completed_ids_query = $wpdb->prepare("
     2094                                                    SELECT o.id
     2095                                                    FROM {$wpdb->prefix}wc_orders o
     2096                                                    LEFT JOIN {$wpdb->prefix}wc_orders_meta m
     2097                                                           ON o.id = m.order_id
     2098                                                          AND m.meta_key = 'picking_status'
     2099                                                    WHERE o.type = 'shop_order'
     2100                                                      AND o.status = %s
     2101                                                      {$date_filter}
     2102                                                      AND (m.meta_value IS NULL OR m.meta_value != 'completed')
     2103                                                    LIMIT 1000
     2104                                                ", 'wc-completed');
     2105                        } else {
     2106                            // Legacy: posts + postmeta
     2107                            $completed_ids_query = $wpdb->prepare("
     2108                                                    SELECT p.ID
     2109                                                    FROM {$wpdb->posts} p
     2110                                                    LEFT JOIN {$wpdb->postmeta} pm
     2111                                                           ON p.ID = pm.post_id
     2112                                                          AND pm.meta_key = 'picking_status'
     2113                                                    WHERE p.post_type = 'shop_order'
     2114                                                      AND p.post_status = %s
     2115                                                      {$date_filter}
     2116                                                      AND (pm.meta_value IS NULL OR pm.meta_value != 'completed')
     2117                                                    LIMIT 1000
     2118                                                ", 'wc-completed');
     2119                        }
     2120
     2121                        $completed_ids = $wpdb->get_col($completed_ids_query);
     2122
     2123                        if (!empty($completed_ids)) {
     2124                            $order_ids = array_merge($order_ids, $completed_ids);
     2125                        }
     2126                    }
     2127
     2128                    // Uniek + totale safety limit (max 1000 totaal)
     2129                    $order_ids = array_values(array_unique(array_map('intval', $order_ids)));
     2130                    $order_ids = array_slice($order_ids, 0, 1000);
    18822131
    18832132                    $all_open_orders = array();
    1884                     if( !empty($order_ids) ) {
     2133                    if (!empty($order_ids)) {
    18852134                        $args = array(
    18862135                            'post__in'  => $order_ids,
     
    25772826                    global $wpdb;
    25782827
    2579                     $order_statussen = array('wc-processing');
     2828                    $order_statuses = array('wc-processing');
    25802829                    $orderpickingapp_order_status = get_option('orderpickingapp_order_status');
    25812830                    if (isset($orderpickingapp_order_status) && !empty($orderpickingapp_order_status)) {
    2582                         $order_statussen = (array)$orderpickingapp_order_status;
    2583                     }
    2584                     $statusPlaceholders = implode(',', array_fill(0, count($order_statussen), '%s'));
     2831                        $order_statuses = (array)$orderpickingapp_order_status;
     2832                    }
     2833                    $statusPlaceholders = implode(',', array_fill(0, count($order_statuses), '%s'));
    25852834
    25862835                    $date_filter = '';
     
    25992848                    }
    26002849
    2601                     // 1. Haal alle order-IDs op met de gewenste status en datumfilter
    2602                     if ($this->is_hpos_enabled()) {
    2603                         // Query voor HPOS
    2604                         $order_ids_query = $wpdb->prepare("
    2605                             SELECT id
    2606                             FROM {$wpdb->prefix}wc_orders
    2607                             WHERE type = 'shop_order'
    2608                             AND status IN ($statusPlaceholders)
    2609                             {$date_filter}
    2610                             LIMIT 1000
    2611                         ", ...$order_statussen);
    2612                     } else {
    2613                         // Query voor traditionele opslag
    2614                         $order_ids_query = $wpdb->prepare("
    2615                             SELECT ID
    2616                             FROM {$wpdb->posts}
    2617                             WHERE post_type = 'shop_order'
    2618                             AND post_status IN ($statusPlaceholders)
    2619                             {$date_filter}
    2620                             LIMIT 1000
    2621                         ", ...$order_statussen);
    2622                     }
    2623 
    2624                     $order_ids = $wpdb->get_col($order_ids_query);
     2850                    $has_completed = in_array('wc-completed', $order_statuses, true);
     2851                    $non_completed_statuses = array_values(array_diff($order_statuses, array('wc-completed')));
     2852
     2853                    $order_ids = array();
     2854
     2855                    // 1) NIET-completed statussen (zoals je al deed)
     2856                    if (!empty($non_completed_statuses)) {
     2857                        $statusPlaceholders = implode(',', array_fill(0, count($non_completed_statuses), '%s'));
     2858
     2859                        if ($this->is_hpos_enabled()) {
     2860                            $order_ids_query = $wpdb->prepare("
     2861                                SELECT id
     2862                                FROM {$wpdb->prefix}wc_orders
     2863                                WHERE type = 'shop_order'
     2864                                  AND status IN ($statusPlaceholders)
     2865                                  {$date_filter}
     2866                                LIMIT 1000
     2867                            ", ...$non_completed_statuses);
     2868                        } else {
     2869                            $order_ids_query = $wpdb->prepare("
     2870                                SELECT ID
     2871                                FROM {$wpdb->posts}
     2872                                WHERE post_type = 'shop_order'
     2873                                  AND post_status IN ($statusPlaceholders)
     2874                                  {$date_filter}
     2875                                LIMIT 1000
     2876                            ", ...$non_completed_statuses);
     2877                        }
     2878
     2879                        $order_ids = $wpdb->get_col($order_ids_query);
     2880                    }
     2881
     2882                    // 2) wc-completed mét meta picking_status != 'completed' (meta MOET bestaan)
     2883                    if ($has_completed) {
     2884                        if ($this->is_hpos_enabled()) {
     2885                            // HPOS: wc_orders + wc_orders_meta
     2886                            $completed_ids_query = $wpdb->prepare("
     2887                                                    SELECT o.id
     2888                                                    FROM {$wpdb->prefix}wc_orders o
     2889                                                    LEFT JOIN {$wpdb->prefix}wc_orders_meta m
     2890                                                           ON o.id = m.order_id
     2891                                                          AND m.meta_key = 'picking_status'
     2892                                                    WHERE o.type = 'shop_order'
     2893                                                      AND o.status = %s
     2894                                                      {$date_filter}
     2895                                                      AND (m.meta_value IS NULL OR m.meta_value != 'completed')
     2896                                                    LIMIT 1000
     2897                                                ", 'wc-completed');
     2898                        } else {
     2899                            // Legacy: posts + postmeta
     2900                            $completed_ids_query = $wpdb->prepare("
     2901                                                    SELECT p.ID
     2902                                                    FROM {$wpdb->posts} p
     2903                                                    LEFT JOIN {$wpdb->postmeta} pm
     2904                                                           ON p.ID = pm.post_id
     2905                                                          AND pm.meta_key = 'picking_status'
     2906                                                    WHERE p.post_type = 'shop_order'
     2907                                                      AND p.post_status = %s
     2908                                                      {$date_filter}
     2909                                                      AND (pm.meta_value IS NULL OR pm.meta_value != 'completed')
     2910                                                    LIMIT 1000
     2911                                                ", 'wc-completed');
     2912                        }
     2913
     2914                        $completed_ids = $wpdb->get_col($completed_ids_query);
     2915
     2916                        if (!empty($completed_ids)) {
     2917                            $order_ids = array_merge($order_ids, $completed_ids);
     2918                        }
     2919                    }
     2920
     2921                    // Uniek + totale safety limit (max 1000 totaal)
     2922                    $order_ids = array_values(array_unique(array_map('intval', $order_ids)));
     2923                    $order_ids = array_slice($order_ids, 0, 1000);
    26252924
    26262925                    $all_open_orders = array();
     
    30053304        global $wpdb;
    30063305
    3007         $order_statussen = array('wc-processing');
     3306        $order_statuses = array('wc-processing');
    30083307        $orderpickingapp_order_status = get_option('orderpickingapp_order_status');
    30093308        if (isset($orderpickingapp_order_status) && !empty($orderpickingapp_order_status)) {
    3010             $order_statussen = (array)$orderpickingapp_order_status;
     3309            $order_statuses = (array)$orderpickingapp_order_status;
    30113310        }
    3012         $statusPlaceholders = implode(',', array_fill(0, count($order_statussen), '%s'));
     3311        $statusPlaceholders = implode(',', array_fill(0, count($order_statuses), '%s'));
    30133312
    30143313        $date_filter = '';
     
    30373336                {$date_filter}
    30383337                LIMIT 1000
    3039             ", ...$order_statussen);
     3338            ", ...$order_statuses);
    30403339        } else {
    30413340            // Query voor traditionele opslag
     
    30473346                {$date_filter}
    30483347                LIMIT 1000
    3049             ", ...$order_statussen);
     3348            ", ...$order_statuses);
    30503349        }
    30513350
     
    39184217        $allocated = 0;
    39194218
    3920         $order_statussen = array('wc-processing');
     4219        $order_statuses = array('wc-processing');
    39214220        $orderpickingapp_order_status = get_option('orderpickingapp_order_status');
    39224221        if (isset($orderpickingapp_order_status) && !empty($orderpickingapp_order_status)) {
    3923             $order_statussen = (array)$orderpickingapp_order_status;
    3924             $order_statussen = apply_filters('orderpickingapp_order_statussen_for_allocated_qty', $order_statussen);
     4222            $order_statuses = (array)$orderpickingapp_order_status;
     4223            $order_statuses = apply_filters('orderpickingapp_order_statussen_for_allocated_qty', $order_statuses);
    39254224        }
    3926         $statusPlaceholders = implode(',', array_fill(0, count($order_statussen), '%s'));
     4225        $statusPlaceholders = implode(',', array_fill(0, count($order_statuses), '%s'));
    39274226
    39284227        // 1. Haal alle order-IDs op met de gewenste status en datumfilter
     
    39354234                AND status IN ($statusPlaceholders)
    39364235                LIMIT 1000
    3937             ", ...$order_statussen);
     4236            ", ...$order_statuses);
    39384237        } else {
    39394238            // Query voor traditionele opslag
     
    39444243                AND post_status IN ($statusPlaceholders)
    39454244                LIMIT 1000
    3946             ", ...$order_statussen);
     4245            ", ...$order_statuses);
    39474246        }
    39484247
  • order-picking-app/trunk/orderpickingapp.php

    r3447103 r3448792  
    33 * Plugin Name:       Order Picking App
    44 * Description:       Make your life easier by using the Orderpicking App. You'll never be inefficient if the Orderpicking App is installed in your store. We assist you in all aspects of your webshop. From intelligent selecting to order packing, we have you covered. Connecting the Orderpicking App to your Woocommerce webshop is simple and quick. Within an hour, you'll be online with the Orderpicking App. You're able to pick and pack your orders three times faster and with greater accuracy.
    5  * Version:           2.3.4
     5 * Version:           2.3.5
    66 * Author:            Arture | PHP Professionals
    77 * Author URI:        http://arture.nl
  • order-picking-app/trunk/readme.txt

    r3447103 r3448792  
    55Requires at least: 6.0
    66Tested up to: 6.9
    7 Stable tag: 2.3.4
     7Stable tag: 2.3.5
    88Requires PHP: 8.0
    99License: GPLv2 or later
     
    5959== Changelog ==
    6060
     61= 2.3.5 =
     62* Compatibility for loading order with WC status "completed" but without any picking status
     63
    6164= 2.3.4 =
    6265* NEW compatibility with "WooCommerce Shipment Tracking" and order search by tracking number.
Note: See TracChangeset for help on using the changeset viewer.