Plugin Directory

Changeset 2389057


Ignore:
Timestamp:
09/27/2020 07:34:57 AM (6 years ago)
Author:
roberarec
Message:

check the order item

Location:
robera/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • robera/trunk/core/background_order_item_copy.php

    r2387003 r2389057  
    6969            $order->get_date_modified(), $anonymous_id, "order_item_id_".$order_id, $properties
    7070        );
    71         if (!get_option('recommender_progress_completed_' . $this->action, 0)) {
    72             $order_arr = get_option('recommender_api_orders_sent', []);
    73             if (!in_array($order->get_id(), $order_arr)) {
    74                 $order_arr[] = $order->get_id();
    75                 update_option('recommender_api_orders_sent', $order_arr);
    76                 update_option(
    77                     'recommender_api_progress_' . $this->action,
    78                     get_option('recommender_api_progress_' . $this->action, 0) + 1
    79                 );
    80                 update_option(
    81                     'recommender_progress_completed_' . $this->action,
    82                     get_option('recommender_api_progress_' . $this->action) == get_option('recommender_api_target_orders')
    83                 );
    84             }
    85         }
    8671
    8772        return $this->checkResponse($item, $response);
  • robera/trunk/core/background_product_copy.php

    r2387003 r2389057  
    9494            $properties
    9595        );
    96         if (!get_option('recommender_progress_completed_' . $this->action, 0)) {
    97             update_option(
    98                 'recommender_api_progress_' . $this->action,
    99                 get_option('recommender_api_progress_' . $this->action, 0) + 1
    100             );
    101             update_option(
    102                 'recommender_progress_completed_' . $this->action,
    103                 get_option('recommender_api_progress_' . $this->action) == get_option('recommender_api_target_products')
    104             );
    105         }
    10696        return $this->checkResponse($item, $response);
    10797    }
  • robera/trunk/core/background_user_copy.php

    r2387003 r2389057  
    4444            $properties
    4545        );
    46         if (!get_option('recommender_progress_completed_' . $this->action, 0)) {
    47             update_option(
    48                 'recommender_api_progress_' . $this->action,
    49                 get_option('recommender_api_progress_' . $this->action, 0) + 1
    50             );
    51             update_option(
    52                 'recommender_progress_completed_' . $this->action,
    53                 get_option('recommender_api_progress_' . $this->action) == get_option('recommender_api_target_users')
    54             );
    55         }
    5646        return $this->checkResponse($item, $response);
    5747    }
  • robera/trunk/core/recommender-admin.php

    r2387003 r2389057  
    5252    public function progressPercent($request)
    5353    {
     54        if (!get_option('recommender_api_target_order_items', 0)){
     55            $query = new \WC_Order_Query(array(
     56                'limit' => -1,
     57                'offset' => 0,
     58            ));
     59            $count=0;
     60            foreach (array_values($query->get_orders()) as $i => $order) {
     61                $count+=count($order->get_items());
     62            }
     63            update_option('recommender_api_target_order_items', $count);
     64        }
    5465        $library_actions = ['order_item_copy', 'product_copy', 'user_copy'];
    55         $target_actions = ['orders', 'products', 'users'];
     66        $target_actions = ['order_items', 'products', 'users'];
    5667        $result = 0;
    5768        $total = 0;
    5869        foreach ($library_actions as $i => $action) {
    59             $sent_option_key = 'recommender_api_progress_' . $library_actions[$i];
    60             $target_key = 'recommender_api_target_' . $target_actions[$i];
    61             $result += get_option($sent_option_key, 0);
    62             $total += get_option($target_key, 0);
     70            $target = get_option('recommender_api_target_' . $target_actions[$i], 0);
     71            $sent = get_option('recommender_api_progress_' . $library_actions[$i], 0);
     72            $result += min($target, $sent);
     73            $total += $target;
    6374        }
    6475        $total = ($total == 0) ? 1 : $total;
  • robera/trunk/libraries/recommender-background-process.php

    r2387003 r2389057  
    288288                    } else {
    289289                        unset($batch->data[$key]);
     290                        if (!get_option($this->first_data_transfer_option)) {
     291                            $val = get_option('recommender_api_progress_' . $this->action, 0)+1;
     292                            update_option('recommender_api_progress_' . $this->action, $val);
     293                        }
    290294                    }
    291295                    if ($this->timeExceeded() || $this->memoryExceeded()) {
     
    376380                $this->client->changeState($this->action.'_done');
    377381                update_option($this->first_data_transfer_option, true);
    378                 update_option('recommender_progress_completed_' . $this->action, true);
    379                 update_option(
    380                     'recommender_api_progress_' . $this->action,
    381                     get_option('recommender_api_target_'. $this->parent_tag, 0)
    382                 );
    383382            }
    384383            // clear schedule of the cron healthCheck.
  • robera/trunk/readme.txt

    r2387003 r2389057  
    44License: GPLv2 or later
    55License URI: https://www.gnu.org/licenses/gpl-2.0.html
    6 Stable tag: 1.0.12
     6Stable tag: 1.0.13
    77Tested up to: 5.4.2
    88
  • robera/trunk/recommender.php

    r2387003 r2389057  
    1212 * Description:       This Plugins help you interact with your WooCommerce users smarter by recommend products and related-products to them according to their preferences.
    1313 * Text Domain:       robera-recommender
    14  * Version:           1.0.12
     14 * Version:           1.0.13
    1515 */
    1616
Note: See TracChangeset for help on using the changeset viewer.