Example #1
0
 /**
  * The daily "sync", this is more of a one-directional sync from LightSpeed.
  * LightSpeed will always win and overwrite the WooCommerce products.
  */
 public static function wclsi_daily_sync()
 {
     $args = array('post_type' => 'product', 'orderby' => 'meta_value_num', 'meta_query' => array(array('key' => '_wclsi_sync', 'value' => true, 'compare' => '=')));
     $query = new WP_Query($args);
     if (count($query->posts) > 0) {
         $wclsi_cat_cache = get_option('wclsi_cat_cache');
         foreach ($query->posts as $prod_key => $prod) {
             $old_ls_obj = get_post_meta($prod->ID, '_wclsi_ls_obj', true);
             WC_LS_Import_Table::process_single_manual_sync($old_ls_obj, $wclsi_cat_cache);
         }
     }
 }
Example #2
0
 /**
  * Manually sync a product via the "Manual Sync" button in the LightSpeed metabox
  * @see self::render_meta_box()
  */
 public function manual_prod_update_ajax()
 {
     $nonce = $_POST['wclsi_admin_nonce'];
     if (!wp_verify_nonce($nonce, 'wclsi_load_ls_prods')) {
         header("HTTP/1.0 409 Security Check.");
         exit;
     }
     if (!isset($_POST['prod_id'])) {
         header("HTTP/1.0 409 " . __('Could not find product ID.', 'woocommerce-lightspeed-pos'));
         exit;
     }
     $prod_id = (int) $_POST['prod_id'];
     $LSI_Import_Table = new WC_LS_Import_Table();
     $old_lsi_prod = get_post_meta($prod_id, '_wclsi_ls_obj', true);
     if (false !== $old_lsi_prod) {
         $msg = $LSI_Import_Table->process_single_manual_sync($old_lsi_prod);
         if ($msg['type'] == 'error') {
             header("HTTP/1.0 409 " . $msg['msg']);
             exit;
         } else {
             wp_send_json(array('success' => true));
         }
     } else {
         header("HTTP/1.0 409 " . __('Could not find a product ID to update!', 'woocommerce-lightspeed-pos'));
         exit;
     }
     exit;
 }