Plugin Directory

Changeset 2705491


Ignore:
Timestamp:
04/06/2022 05:58:32 AM (4 years ago)
Author:
sokangroup
Message:

fix bugs

Location:
sokan-integration
Files:
18 added
5 edited

Legend:

Unmodified
Added
Removed
  • sokan-integration/trunk/Sokan-integration.php

    r2693190 r2705491  
    77 * Plugin Name: sokan Integration
    88 * Description:  افزونه ای برای استخراج تمامی اطلاعات ووکامرس مورد نیاز پلتفرم سکان
    9  * Version: 1.2.1
     9 * Version: 1.2.2
    1010 * Author: Sokan
    1111 * Author URI: https://Sokan.tech/
  • sokan-integration/trunk/admin.php

    r2693190 r2705491  
    66$login_error = '';
    77$last_date = 'همگام سازی نشده';
    8 
    98if (isset($_GET['item'])) {
    109
     
    2019
    2120    if (isset($_POST[SKNG_PLUGIN_NAME . '_username'])) {
    22 
    2321
    2422        $url = esc_url(sanitize_text_field($_POST['api_url']));
  • sokan-integration/trunk/include/classes/class-skng-db.php

    r2693175 r2705491  
    178178             GROUP BY ID
    179179             ORDER BY `{$this->db->prefix}posts`.post_modified
     180             LIMIT 500
    180181            "
    181182            , ARRAY_A
     
    283284           AND post_id  NOT IN (SELECT `object_id` FROM `$logTable` )
    284285           AND wp_posts.post_modified > '$date'
    285            GROUP BY post_id LIMIT 2000"
     286           GROUP BY post_id LIMIT 1000"
    286287            , ARRAY_A
    287288        );
     
    417418                   GROUP BY `{$this->db->prefix}posts`.ID
    418419                   ORDER BY `{$this->db->prefix}posts`.post_modified
    419                    LIMIT 400 ",
     420                   LIMIT 50 ",
    420421            ARRAY_A
    421422        );
     
    463464                }
    464465
    465 
    466466                $date = $value['modified_date'];
    467467                $qty = $value['_qty'] ?? 1;
     
    504504                foreach ($value as $key => $_value){
    505505
    506                     if (strpos("weight", $key) !== false
    507                         or strpos("وزن", $key) !== false
    508                         or strpos("جرم", $key) !== false
     506                    if (strpos($key, "weight") !== false
     507                        or strpos($key, "وزن") !== false
     508                        or strpos($key, "جرم") !== false
    509509                    ) {
    510510                        $weight = $_value;
     
    514514                }
    515515
    516                 if ($unit_price != 0) {
    517 
    518                     $order = [
    519                         'id' => (string)$value['order_id'],
    520                         'item_id' => (string)$value['order_item_id'],
    521                         'date' => (string)$value['post_date'],
    522                         'customer' => (string)$user_id,
    523                         'quantity' => (int)$qty,
    524                         'unit_price' => (int)$unit_price,
    525                         'product' => (string)$product_id,
    526                         'type' => "SALES",
    527                         'discount' => (int)$discount,
    528                         'tax' => (int)$tax,
    529                         'weight' => (int)$weight,
    530                     ];
    531 
    532                     if (!empty($region_id)) {
    533                         $order['region'] = (string) $region_id;
    534                     }
    535 
    536                     array_push($new_orders, $order);
    537 
    538                     if (in_array($value['order_id'], $refunded_ids)) {
    539                         $refund_order = $order;
    540                         $refund_order['item_id'] = $refund_order['item_id']."_refunded";
    541                         $refund_order['quantity'] = -$refund_order['quantity'];
    542                         $refund_order['discount'] = -$refund_order['discount'];
    543                         $refund_order['type'] = "RETURN";
    544                         array_push($new_orders , $refund_order);
    545                     }
    546 
     516                $order = [
     517                    'id' => (string)$value['order_id'],
     518                    'item_id' => (string)$value['order_item_id'],
     519                    'date' => (string)$value['post_date'],
     520                    'customer' => (string)$user_id,
     521                    'quantity' => (int)$qty,
     522                    'unit_price' => (int)$unit_price,
     523                    'product' => (string)$product_id,
     524                    'type' => "SALES",
     525                    'discount' => (int)$discount,
     526                    'tax' => (int)$tax,
     527                    'weight' => (int)$weight,
     528                ];
     529
     530                if (!empty($region_id)) {
     531                    $order['region'] = (string) $region_id;
     532                }
     533
     534                array_push($new_orders, $order);
     535
     536                if (in_array($value['order_id'], $refunded_ids)) {
     537                    $refund_order = $order;
     538                    $refund_order['item_id'] = $refund_order['item_id']."_refunded";
     539                    $refund_order['quantity'] = -$refund_order['quantity'];
     540                    $refund_order['discount'] = -$refund_order['discount'];
     541                    $refund_order['type'] = "RETURN";
     542                    array_push($new_orders , $refund_order);
    547543                }
    548544            }
  • sokan-integration/trunk/include/classes/class-skng-logger.php

    r2693190 r2705491  
    3333
    3434    /**
     35     * api token
     36     * @var string
     37     * @since 1.2.0
     38     */
     39    private string $token;
     40
     41    /**
    3542     * listy of endpoints
    3643     * @var array
     
    4653        $parse = parse_url(get_site_url());
    4754        $this->siteName =  $parse['host'];
     55        $this->token = get_option(SKNG_PLUGIN_NAME . '_token')??'';
    4856    }
    4957
     
    8290        $args = [
    8391            'headers' => [
    84                 'Content-Type' => 'application/json'
     92                'Content-Type' => 'application/json',
     93                'Token' => $this->token
    8594            ],
    8695            'body' => json_encode($post),
    87             'timeout' => 5,
     96            'timeout' => 2,
    8897            'method' => 'POST'
    8998        ];
     
    102111        add_filter( 'https_ssl_verify', '__return_false' );
    103112
    104         $response           = wp_remote_get(esc_url_raw( $this->endpoints['customCodeUrl']));
     113        $args = [
     114            'headers' => [
     115                'Content-Type' => 'application/json',
     116                'Token' => $this->token
     117            ]
     118        ];
     119
     120        $response           = wp_remote_get(esc_url_raw( $this->endpoints['customCodeUrl']) ,$args);
    105121        $http_response_code = wp_remote_retrieve_response_code( $response );
    106122        $res                = wp_remote_retrieve_body( $response );
  • sokan-integration/trunk/readme.txt

    r2693190 r2705491  
    33Tags: products, woocommerce, export, extract, sokan
    44Requires at least: 5.2
    5 Tested up to: 5.8
     5Tested up to: 5.9
    66Donate link: http://sokan.tech/
    7 Stable tag: 1.2.1
     7Stable tag: 1.2.2
    88Requires PHP: 7.0
    99License: GPLv2 or later
     
    7979== Changelog ==
    8080
     81= 1.2.2 =
     82* رفع اشکال های گزارش شده
     83
    8184= 1.2.1 =
    8285* بهبود عملکرد
     
    9497== Upgrade Notice ==
    9598
     99= 1.2.2 =
     100* رفع اشکال های گزارش شده
     101
    96102= 1.2.1 =
    97103* بهبود عملکرد
Note: See TracChangeset for help on using the changeset viewer.