Plugin Directory

Changeset 2720219


Ignore:
Timestamp:
05/08/2022 05:27:35 PM (4 years ago)
Author:
ascendedcrow
Message:

1.0.11

1) Added Order Service to Sync up your orders from Bol.com to WooCommerce.
2) Fix small bugs on the koopblok service.

Location:
shop-2-api/trunk
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • shop-2-api/trunk/assets/bol2api_dashboard.js

    r2702844 r2720219  
    219219            let json_data = JSON.parse(data.data.body);
    220220            for (let i in json_data) {
    221                 debugger;
    222221                if (typeof(json_data[i].counter) === 'undefined') continue;
    223222                if (json_data[i].status == null) {
  • shop-2-api/trunk/assets/shop2api_koopblock.js

    r2642569 r2720219  
    8282
    8383    function retrieve_from_shop2api() {
    84         debugger;
    8584        let json_data = settings.koopblok_data;
    8685        if (json_data.length !== 0) {
  • shop-2-api/trunk/includes/Api/Shop2ApiConnect.php

    r2664416 r2720219  
    3535
    3636        $response = wp_remote_get(
    37             $this->shop_2_api_url . '/api/orders/', $args = ['headers' => $this->header]
     37            $this->shop_2_api_url . '/api/orders/', ['headers' => $this->header]
    3838        );
    3939
     
    4646    {
    4747        $response = wp_remote_get(
    48             $this->shop_2_api_url . '/bol/test-connection/', $args = ['headers' => $this->header]
     48            $this->shop_2_api_url . '/bol/test-connection/', ['headers' => $this->header]
    4949        );
    5050        $response_data = json_decode(wp_remote_retrieve_body($response), true);
     
    5858    {
    5959        $response = wp_remote_get(
    60             $this->shop_2_api_url . '/woocommerce/test-connection/', $args = ['headers' => $this->header]
     60            $this->shop_2_api_url . '/woocommerce/test-connection/', ['headers' => $this->header]
    6161        );
    6262        $response_data = json_decode(wp_remote_retrieve_body($response), true);
     
    6969    {
    7070        return wp_remote_get(
    71             $this->shop_2_api_url . '/api/orders/', $args = ['headers' => $this->header]
     71            $this->shop_2_api_url . '/api/orders/', ['headers' => $this->header]
    7272        );
    7373    }
     
    9797    {
    9898        return wp_remote_get(
    99             $this->shop_2_api_url . '/bol/api/connection/?dropdown=True', $args = ['headers' => $this->header]
     99            $this->shop_2_api_url . '/bol/api/connection/?dropdown=True', ['headers' => $this->header]
    100100        );
    101101    }
     
    112112        $url = add_query_arg($parameters, $url);
    113113
    114         return wp_remote_get($url, $args = ['headers' => $this->header]);
    115     }
    116 
    117     public function get_wc_product_data_report($search = '', $order = '', $page = 1, $size = 10)
     114        return wp_remote_get($url, ['headers' => $this->header]);
     115    }
     116
     117    public function get_wc_order_data_report($search = '', $order = '', $page = 1, $size = 10)
    118118    {
    119119        $parameters = array(
     
    123123            'search' => $search
    124124        );
     125        $url = $this->shop_2_api_url . '/bol/api/connection/order-report/';
     126        $url = add_query_arg($parameters, $url);
     127
     128        return wp_remote_get($url, ['headers' => $this->header]);
     129    }
     130
     131    public function get_wc_product_data_report($search = '', $order = '', $page = 1, $size = 10)
     132    {
     133        $parameters = array(
     134            'page' => $page,
     135            'page_size' => strval($size),
     136            'ordering' => $order,
     137            'search' => $search
     138        );
    125139        $url = $this->shop_2_api_url . '/woocommerce/api/product-data/0/';
    126140        $url = add_query_arg($parameters, $url);
    127141
    128         return wp_remote_get($url, $args = ['headers' => $this->header]);
     142        return wp_remote_get($url, ['headers' => $this->header]);
    129143    }
    130144
     
    132146    {
    133147        return wp_remote_get(
    134             $this->shop_2_api_url . '/bol/get-content/?dropdown=True', $args = ['headers' => $this->header]
     148            $this->shop_2_api_url . '/bol/get-content/?dropdown=True', ['headers' => $this->header]
    135149        );
    136150    }
     
    139153    {
    140154        return wp_remote_get(
    141             $this->shop_2_api_url . '/bol/get-offer-content/', $args = ['headers' => $this->header]
     155            $this->shop_2_api_url . '/bol/get-offer-content/', ['headers' => $this->header]
    142156        );
    143157    }
     
    146160    {
    147161        return wp_remote_get(
    148             $this->shop_2_api_url . '/bol/get-content/?id=' . $value, $args = ['headers' => $this->header]
     162            $this->shop_2_api_url . '/bol/get-content/?id=' . $value, ['headers' => $this->header]
    149163        );
    150164    }
     
    153167    {
    154168        return wp_remote_get(
    155             $this->shop_2_api_url . '/woocommerce/api/connection/', $args = ['headers' => $this->header]
     169            $this->shop_2_api_url . '/woocommerce/api/connection/', ['headers' => $this->header]
    156170        );
    157171    }
     
    160174    {
    161175        return wp_remote_get(
    162             $this->shop_2_api_url . '/woocommerce/api/grouped-summary-offer/', $args = ['headers' => $this->header]
     176            $this->shop_2_api_url . '/woocommerce/api/grouped-summary-offer/', ['headers' => $this->header]
    163177        );
    164178    }
     
    167181    {
    168182        return wp_remote_get(
    169             $this->shop_2_api_url . '/woocommerce/api/grouped-summary-product/', $args = ['headers' => $this->header]
     183            $this->shop_2_api_url . '/woocommerce/api/grouped-summary-product/', ['headers' => $this->header]
    170184        );
    171185    }
     
    194208        return wp_remote_post(
    195209            $this->shop_2_api_url . $conn_url,
    196             $args = [
     210            [
    197211                'headers' => $this->header,
    198212                'body' => $data,
     
    227241        return wp_remote_post(
    228242            $this->shop_2_api_url . $conn_url,
    229             $args = [
     243            [
    230244                'headers' => $this->header,
    231245                'body' => $data,
     
    238252    {
    239253        return wp_remote_get(
    240             $this->shop_2_api_url . '/map/api/wc-bol-map/', $args = ['headers' => $this->header]
     254            $this->shop_2_api_url . '/map/api/wc-bol-map/', ['headers' => $this->header]
    241255        );
    242256    }
     
    250264        return wp_remote_get(
    251265            $this->shop_2_api_url . '/woocommerce/options/' . $json_connections[0]["id"] . '/',
    252             $args = ['headers' => $this->header]
     266            ['headers' => $this->header]
    253267        );
    254268    }
     
    262276        return wp_remote_post(
    263277            $this->shop_2_api_url . '/woocommerce/product_values/' . $json_connections[0]["id"] . '/',
    264             $args = [
     278            [
    265279                'headers' => $this->header,
    266280                'body' => ["value" => $value]
     
    273287        return wp_remote_post(
    274288            $this->shop_2_api_url . '/woocommerce/start_product_sync/',
    275             $args = [
     289            [
    276290                'headers' => $this->header
    277291            ]
     
    283297        return wp_remote_post(
    284298            $this->shop_2_api_url . '/woocommerce/start_product_sync/' . $woocommerce_id . '/',
    285             $args = [
     299            [
    286300                'headers' => $this->header
    287301            ]
     
    312326        return wp_remote_post(
    313327            $this->shop_2_api_url . $mapping_url,
    314             $args = [
     328            [
    315329                'headers' => $this->header,
    316330                'body' => $data,
     
    325339        return wp_remote_post(
    326340            $this->shop_2_api_url . '/woocommerce/handle-tag-web-hook/',
    327             $args = [
     341            [
    328342                'headers' => $this->header
    329343            ]
     
    336350        return wp_remote_post(
    337351            $this->shop_2_api_url . '/woocommerce/handle-cat-web-hook/',
    338             $args = [
     352            [
    339353                'headers' => $this->header
    340354            ]
     
    347361        return wp_remote_post(
    348362            $this->shop_2_api_url . '/woocommerce/handle-attr-web-hook/',
    349             $args = [
     363            [
    350364                'headers' => $this->header
    351365            ]
     
    358372        return wp_remote_post(
    359373            $this->shop_2_api_url . '/woocommerce/handle-metadata-web-hook/',
    360             $args = [
     374            [
    361375                'headers' => $this->header
    362376            ]
     
    369383        return wp_remote_get(
    370384            $this->shop_2_api_url . '/woocommerce/api/product-data/' . $product_id . '/',
    371             $args = [
     385            [
    372386                'headers' => $this->header
    373387            ]
     
    380394        return wp_remote_post(
    381395            $this->shop_2_api_url . '/register-free-account/',
    382             $args = [
     396            [
    383397                'headers' => $this->header,
    384398                'body' => ["email" => $email],
     
    388402    }
    389403
     404    // Get Order data
     405    public function get_order_data()
     406    {
     407        return wp_remote_get(
     408            $this->shop_2_api_url . '/map/api/wc-order/', ['headers' => $this->header]
     409        );
     410    }
     411
     412    // Set Order data
     413    public function set_order_data($active)
     414    {
     415        $order = $this->get_order();
     416        $request_url = '/map/api/wc-order/';
     417        $method = 'POST';
     418
     419        $order_data = wp_remote_retrieve_body($this->get_order_data());
     420        $json_data = json_decode($order_data, true);
     421
     422        if (count($json_data) != 0) {
     423            $request_url = $request_url . $json_data[0]["id"] . '/';
     424            $method = 'PATCH';
     425        }
     426
     427        $data = [
     428            'active' => ($active != ''),
     429            "product" => $order["id"]
     430        ];
     431
     432        return wp_remote_post(
     433            $this->shop_2_api_url . $request_url,
     434            [
     435                'headers' => $this->header,
     436                'body' => $data,
     437                'method' => $method
     438            ]
     439        );
     440    }
     441
    390442    // Get koopblok data
    391443    public function get_koopblok_data()
    392444    {
    393445        return wp_remote_get(
    394             $this->shop_2_api_url . '/map/api/wc-koopblok/', $args = ['headers' => $this->header]
     446            $this->shop_2_api_url . '/map/api/wc-koopblok/', ['headers' => $this->header]
    395447        );
    396448    }
     
    415467
    416468        $data = [
    417             'active' => $active,
     469            'active' => ($active != ''),
    418470            'woocommerce_price_field' => $woocommerce_price_field,
    419471            'price_increments' => $price_increments,
     
    428480        return wp_remote_post(
    429481            $this->shop_2_api_url . $request_url,
    430             $args = [
     482            [
    431483                'headers' => $this->header,
    432484                'body' => $data,
  • shop-2-api/trunk/includes/Base/AjaxButtonActions.php

    r2642569 r2720219  
    5656        add_action('wp_ajax_get_koopblok_data', array($this, 'get_koopblok_data'));
    5757        add_action('wp_ajax_set_koopblok_data', array($this, 'set_koopblok_data'));
     58
     59        //Koopblock Get and Submit functions
     60        add_action('wp_ajax_get_order_data', array($this, 'get_order_data'));
     61        add_action('wp_ajax_set_order_data', array($this, 'set_order_data'));
    5862
    5963        // Remove Ean From Bol
     
    249253    public function set_koopblok_data()
    250254    {
    251 
    252         $arr = [];
    253255        $this->check_nonce();
    254256        $shop_2_api_response = $this->shop_2_api_connections->set_koopblok_data(
     
    266268    }
    267269
     270    public function get_order_data()
     271    {
     272        $shop_2_api_response = $this->shop_2_api_connections->get_order_data();
     273        $this->handle_api_response($shop_2_api_response);
     274    }
     275
     276    public function set_order_data()
     277    {
     278        $this->check_nonce();
     279        $shop_2_api_response = $this->shop_2_api_connections->set_order_data(
     280            $_POST['orders-active']
     281        );
     282
     283        $this->handle_api_response($shop_2_api_response);
     284    }
     285
    268286    private static function handle_api_response($shop_2_api_response)
    269287    {
  • shop-2-api/trunk/includes/Base/Enqueue.php

    r2700299 r2720219  
    9898            wp_enqueue_style( 'jquery-modal-min-css', SHOP2API_PLUGIN_URL . '/assets/external/jquery/jquery.modal.min.css', [], $this->version_id());
    9999            wp_enqueue_script( 'bol2api_scripts', SHOP2API_PLUGIN_URL . '/assets/bol2api_report_scripts.js', [], $this->version_id());
    100         } elseif ($hook == 'admin_page_shop2api_wc_to_bol_reports_detail') {
     100        } elseif ($hook == 'shop-2-api_page_shop2api_wc_to_bol_reports') {
    101101            $this -> add_other_localize();
    102102            wp_enqueue_script( 'jquery-modal-min', SHOP2API_PLUGIN_URL . '/assets/external/jquery/jquery.modal.min.js', [], $this->version_id());
    103103            wp_enqueue_style( 'jquery-modal-min-css', SHOP2API_PLUGIN_URL . '/assets/external/jquery/jquery.modal.min.css', [], $this->version_id());
    104104            wp_enqueue_script( 'bol2api_scripts', SHOP2API_PLUGIN_URL . '/assets/bol2api_report_scripts.js', [], $this->version_id());
     105        } elseif ($hook == 'shop-2-api_page_shop2api_wc_to_bol_reports_order_page') {
     106            $this -> add_other_localize();
     107            wp_enqueue_script( 'jquery-modal-min', SHOP2API_PLUGIN_URL . '/assets/external/jquery/jquery.modal.min.js', [], $this->version_id());
     108            wp_enqueue_style( 'jquery-modal-min-css', SHOP2API_PLUGIN_URL . '/assets/external/jquery/jquery.modal.min.css', [], $this->version_id());
     109            wp_enqueue_script( 'bol2api_scripts', SHOP2API_PLUGIN_URL . '/assets/bol2api_order_report_scripts.js', [], $this->version_id());
    105110        } elseif ($hook == 'shop-2-api_page_shop2api_bol_koopblok_service') {
    106111            $this -> add_koopblock_localize();
     
    111116                [], $this->version_id()
    112117            );
    113         }
     118        } elseif ($hook == 'shop-2-api_page_shop2api_bol_order_service') {
     119            $this -> add_orders_localize();
     120            wp_enqueue_script( 'shop2api_koopblock', SHOP2API_PLUGIN_URL . '/assets/shop2api_order.js', [], $this->version_id());
     121            wp_enqueue_script(
     122                'bol2api_jquery-mask-min',
     123                SHOP2API_PLUGIN_URL . '/assets/external/jquery_mask/jquery.mask.min.js', array( 'jquery' ),
     124                [], $this->version_id()
     125            );
     126        }
    114127    }
    115128
     
    184197    }
    185198
     199     private function add_orders_localize() {
     200         require_once SHOP2API_PLUGIN_PATH . '/includes/Api/Shop2ApiConnect.php';
     201
     202         $shop_2_api_connection = new Shop2ApiConnect();
     203         // Get Field Options
     204         $wc_field_options = $this->handle_api_response($shop_2_api_connection->get_wc_field_options());
     205         //Get Product Data
     206         $offer_data = $this->handle_api_response($shop_2_api_connection->get_bol_offer_info());
     207         $orders_data = $this->handle_api_response($shop_2_api_connection->get_order_data());
     208
     209         wp_localize_script( 'bol2api_scripts_common', 'settings', array(
     210             'ajaxurl'   => admin_url( 'admin-ajax.php' ),
     211             'nonce'    => wp_create_nonce('ajax-nonce'),
     212             'wc_field_options' => $wc_field_options,
     213             'offer_data' => $offer_data,
     214             'orders_data' => $orders_data
     215         ));
     216     }
     217
    186218    private function add_koopblock_localize() {
    187219        require_once SHOP2API_PLUGIN_PATH . '/includes/Api/Shop2ApiConnect.php';
  • shop-2-api/trunk/includes/Pages/Admin.php

    r2642569 r2720219  
    8383                    'manage_options', // Capability
    8484                    'shop2api_woocommerce_category', // Menu Slug
    85                     $function = array($this, 'wc_category_selection_page'), // Function
     85                    array($this, 'wc_category_selection_page'), // Function
    8686                );
    8787
     
    9292                    'manage_options', // Capability
    9393                    'shop2api_bol_mapping', // Menu Slug
    94                     $function = array($this, 'wc_to_bol_mapping_page'), // Function
     94                    array($this, 'wc_to_bol_mapping_page'), // Function
    9595                );
    9696
     
    101101                    'manage_options', // Capability
    102102                    'shop2api_bol_koopblok_service', // Menu Slug
    103                     $function = array($this, 'bol_koopblok_service'), // Function
    104                 );
     103                    array($this, 'bol_koopblok_service'), // Function
     104                );
     105
     106                add_submenu_page(
     107                    'shop2api_plugin', //Parent Slug
     108                    'Bol Order Sync Service', // Page Title
     109                    'Bol Order Sync Service', // Menu Title
     110                    'manage_options', // Capability
     111                    'shop2api_bol_order_service', // Menu Slug
     112                    array($this, 'bol_order_service'), // Function
     113                );
    105114
    106115                $hook = add_submenu_page(
     
    110119                    'manage_options', // Capability
    111120                    'shop2api_wc_to_bol_reports', // Menu Slug
    112                     $function = array($this, 'wc_to_bol_reports_page'), // Function
     121                    array($this, 'wc_to_bol_reports_page'), // Function
    113122                );
    114123                add_action("load-".$hook, array($this,'mp_add_product_screen_options'));
     
    120129                    'manage_options', // Capability
    121130                    'shop2api_wc_to_bol_reports_detail', // Menu Slug
    122                     $function = array($this, 'wc_to_bol_reports_detail_page'), // Function
     131                    array($this, 'wc_to_bol_reports_detail_page'), // Function
     132                );
     133                add_action("load-".$hook, array($this,'mp_add_product_screen_options'));
     134
     135                $hook = add_submenu_page(
     136                    'shop2api_plugin', //Parent Slug
     137                    'Sync Order Report', // Page Title
     138                    'Sync Order Report', // Menu Title
     139                    'manage_options', // Capability
     140                    'shop2api_wc_to_bol_reports_order_page', // Menu Slug
     141                    array($this, 'wc_to_bol_reports_order_page'), // Function
    123142                );
    124143                add_action("load-".$hook, array($this,'mp_add_product_screen_options'));
     
    156175        }
    157176
     177        public function wc_to_bol_reports_order_page()
     178        {
     179            require_once SHOP2API_PLUGIN_PATH . '/includes/Tables/Bol2WcOrderReport.php';
     180            $ListTable = new Shop2Api_Bol2WcOrderReport();
     181
     182            echo wp_kses('<div class="wrap">', $this->allowed_html);
     183            // Common Header to be included everywhere and js should also be in the common.js
     184            $shop2api_header = "Bol to Woocommerce Order Report";
     185            require_once SHOP2API_PLUGIN_PATH . 'templates/common-header.php';
     186
     187            $ListTable->prepare_items();
     188            // Searching
     189            echo wp_kses('<form method="GET">', $this->allowed_html);
     190            echo wp_kses('<input type="hidden" name="page" value="shop2api_wc_to_bol_reports" />', $this->allowed_html);
     191            $ListTable->search_box('search', 'search_id');
     192            echo wp_kses('</form>', $this->allowed_html);
     193            $ListTable->display();
     194            echo wp_kses('</div>', $this->allowed_html);
     195        }
     196
    158197        public function wc_to_bol_reports_page()
    159198        {
     
    207246            require_once SHOP2API_PLUGIN_PATH . 'templates/bol-get-best-price.php';
    208247        }
     248
     249        public function bol_order_service()
     250        {
     251            require_once SHOP2API_PLUGIN_PATH . 'templates/bol-order-sync.php';
     252        }
    209253    }
    210254endif;
  • shop-2-api/trunk/includes/Tables/Bol2WcStatusReport.php

    r2642569 r2720219  
    150150        echo(wp_kses('<div id="openModal" class="modalDialog">'.$empty_table.'<div id="report-modal-data"></div></div>', $allowed_html));
    151151    }
    152 
    153     function echo_debug_button($request_data, $response_data): string
    154     {
    155         $data_req_str = ' data-req_info="' . urlencode(wp_json_encode($request_data)) . '" ';
    156         $data_res_str = ' data-res_info="' . urlencode(wp_json_encode($response_data)) . '" ';
    157 
    158         return '<button  class="show-more" ' . $data_req_str . $data_res_str . '>Debug Info</button>';
    159     }
    160152}
  • shop-2-api/trunk/readme.txt

    r2700299 r2720219  
    83832) Removed popup to say sync started as it interfere with the quick edit.
    8484
     85= 1.0.11 =
     861) Added Order Service to Sync up your orders from Bol.com to WooCommerce.
     872) Fix small bugs on the koopblok service.
     88
    8589== Instructions ==
    86901) After installing Shop2Api, a new menu item will be available in your WordPress installation, you can continue and click on it and enter you token which was mailed to you.
  • shop-2-api/trunk/shop-2-api.php

    r2700299 r2720219  
    55Plugin URI: https://wordpress.org/plugins/shop-2-api/
    66Description: The plugin Shop2Api will sync products between e-Commerce platforms. The current supported e-Commerce platforms are WooCommerce to Bol.com, and we are working on Amazon, Shopify and others.  We added a koopblok service so that you can check if you lower your price can you get koopblok.
    7 Version: 1.0.10
     7Version: 1.0.11
    88Requires at least: 5.0
    99Requires PHP:      7.2
     
    3434define('SHOP2API_PLUGIN_URL', plugin_dir_url( __FILE__ ));
    3535define('SHOP2API_PLUGIN', plugin_basename( __FILE__ ));
    36 define ('VERSION', '1.0.10');
     36define ('VERSION', '1.0.11');
    3737
    3838// Register items in the project.
Note: See TracChangeset for help on using the changeset viewer.