Changeset 2720219
- Timestamp:
- 05/08/2022 05:27:35 PM (4 years ago)
- Location:
- shop-2-api/trunk
- Files:
-
- 4 added
- 9 edited
-
assets/bol2api_dashboard.js (modified) (1 diff)
-
assets/bol2api_order_report_scripts.js (added)
-
assets/shop2api_koopblock.js (modified) (1 diff)
-
assets/shop2api_order.js (added)
-
includes/Api/Shop2ApiConnect.php (modified) (30 diffs)
-
includes/Base/AjaxButtonActions.php (modified) (3 diffs)
-
includes/Base/Enqueue.php (modified) (3 diffs)
-
includes/Pages/Admin.php (modified) (7 diffs)
-
includes/Tables/Bol2WcOrderReport.php (added)
-
includes/Tables/Bol2WcStatusReport.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
shop-2-api.php (modified) (2 diffs)
-
templates/bol-order-sync.php (added)
Legend:
- Unmodified
- Added
- Removed
-
shop-2-api/trunk/assets/bol2api_dashboard.js
r2702844 r2720219 219 219 let json_data = JSON.parse(data.data.body); 220 220 for (let i in json_data) { 221 debugger;222 221 if (typeof(json_data[i].counter) === 'undefined') continue; 223 222 if (json_data[i].status == null) { -
shop-2-api/trunk/assets/shop2api_koopblock.js
r2642569 r2720219 82 82 83 83 function retrieve_from_shop2api() { 84 debugger;85 84 let json_data = settings.koopblok_data; 86 85 if (json_data.length !== 0) { -
shop-2-api/trunk/includes/Api/Shop2ApiConnect.php
r2664416 r2720219 35 35 36 36 $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] 38 38 ); 39 39 … … 46 46 { 47 47 $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] 49 49 ); 50 50 $response_data = json_decode(wp_remote_retrieve_body($response), true); … … 58 58 { 59 59 $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] 61 61 ); 62 62 $response_data = json_decode(wp_remote_retrieve_body($response), true); … … 69 69 { 70 70 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] 72 72 ); 73 73 } … … 97 97 { 98 98 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] 100 100 ); 101 101 } … … 112 112 $url = add_query_arg($parameters, $url); 113 113 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) 118 118 { 119 119 $parameters = array( … … 123 123 'search' => $search 124 124 ); 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 ); 125 139 $url = $this->shop_2_api_url . '/woocommerce/api/product-data/0/'; 126 140 $url = add_query_arg($parameters, $url); 127 141 128 return wp_remote_get($url, $args =['headers' => $this->header]);142 return wp_remote_get($url, ['headers' => $this->header]); 129 143 } 130 144 … … 132 146 { 133 147 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] 135 149 ); 136 150 } … … 139 153 { 140 154 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] 142 156 ); 143 157 } … … 146 160 { 147 161 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] 149 163 ); 150 164 } … … 153 167 { 154 168 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] 156 170 ); 157 171 } … … 160 174 { 161 175 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] 163 177 ); 164 178 } … … 167 181 { 168 182 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] 170 184 ); 171 185 } … … 194 208 return wp_remote_post( 195 209 $this->shop_2_api_url . $conn_url, 196 $args =[210 [ 197 211 'headers' => $this->header, 198 212 'body' => $data, … … 227 241 return wp_remote_post( 228 242 $this->shop_2_api_url . $conn_url, 229 $args =[243 [ 230 244 'headers' => $this->header, 231 245 'body' => $data, … … 238 252 { 239 253 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] 241 255 ); 242 256 } … … 250 264 return wp_remote_get( 251 265 $this->shop_2_api_url . '/woocommerce/options/' . $json_connections[0]["id"] . '/', 252 $args =['headers' => $this->header]266 ['headers' => $this->header] 253 267 ); 254 268 } … … 262 276 return wp_remote_post( 263 277 $this->shop_2_api_url . '/woocommerce/product_values/' . $json_connections[0]["id"] . '/', 264 $args =[278 [ 265 279 'headers' => $this->header, 266 280 'body' => ["value" => $value] … … 273 287 return wp_remote_post( 274 288 $this->shop_2_api_url . '/woocommerce/start_product_sync/', 275 $args =[289 [ 276 290 'headers' => $this->header 277 291 ] … … 283 297 return wp_remote_post( 284 298 $this->shop_2_api_url . '/woocommerce/start_product_sync/' . $woocommerce_id . '/', 285 $args =[299 [ 286 300 'headers' => $this->header 287 301 ] … … 312 326 return wp_remote_post( 313 327 $this->shop_2_api_url . $mapping_url, 314 $args =[328 [ 315 329 'headers' => $this->header, 316 330 'body' => $data, … … 325 339 return wp_remote_post( 326 340 $this->shop_2_api_url . '/woocommerce/handle-tag-web-hook/', 327 $args =[341 [ 328 342 'headers' => $this->header 329 343 ] … … 336 350 return wp_remote_post( 337 351 $this->shop_2_api_url . '/woocommerce/handle-cat-web-hook/', 338 $args =[352 [ 339 353 'headers' => $this->header 340 354 ] … … 347 361 return wp_remote_post( 348 362 $this->shop_2_api_url . '/woocommerce/handle-attr-web-hook/', 349 $args =[363 [ 350 364 'headers' => $this->header 351 365 ] … … 358 372 return wp_remote_post( 359 373 $this->shop_2_api_url . '/woocommerce/handle-metadata-web-hook/', 360 $args =[374 [ 361 375 'headers' => $this->header 362 376 ] … … 369 383 return wp_remote_get( 370 384 $this->shop_2_api_url . '/woocommerce/api/product-data/' . $product_id . '/', 371 $args =[385 [ 372 386 'headers' => $this->header 373 387 ] … … 380 394 return wp_remote_post( 381 395 $this->shop_2_api_url . '/register-free-account/', 382 $args =[396 [ 383 397 'headers' => $this->header, 384 398 'body' => ["email" => $email], … … 388 402 } 389 403 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 390 442 // Get koopblok data 391 443 public function get_koopblok_data() 392 444 { 393 445 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] 395 447 ); 396 448 } … … 415 467 416 468 $data = [ 417 'active' => $active,469 'active' => ($active != ''), 418 470 'woocommerce_price_field' => $woocommerce_price_field, 419 471 'price_increments' => $price_increments, … … 428 480 return wp_remote_post( 429 481 $this->shop_2_api_url . $request_url, 430 $args =[482 [ 431 483 'headers' => $this->header, 432 484 'body' => $data, -
shop-2-api/trunk/includes/Base/AjaxButtonActions.php
r2642569 r2720219 56 56 add_action('wp_ajax_get_koopblok_data', array($this, 'get_koopblok_data')); 57 57 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')); 58 62 59 63 // Remove Ean From Bol … … 249 253 public function set_koopblok_data() 250 254 { 251 252 $arr = [];253 255 $this->check_nonce(); 254 256 $shop_2_api_response = $this->shop_2_api_connections->set_koopblok_data( … … 266 268 } 267 269 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 268 286 private static function handle_api_response($shop_2_api_response) 269 287 { -
shop-2-api/trunk/includes/Base/Enqueue.php
r2700299 r2720219 98 98 wp_enqueue_style( 'jquery-modal-min-css', SHOP2API_PLUGIN_URL . '/assets/external/jquery/jquery.modal.min.css', [], $this->version_id()); 99 99 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') { 101 101 $this -> add_other_localize(); 102 102 wp_enqueue_script( 'jquery-modal-min', SHOP2API_PLUGIN_URL . '/assets/external/jquery/jquery.modal.min.js', [], $this->version_id()); 103 103 wp_enqueue_style( 'jquery-modal-min-css', SHOP2API_PLUGIN_URL . '/assets/external/jquery/jquery.modal.min.css', [], $this->version_id()); 104 104 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()); 105 110 } elseif ($hook == 'shop-2-api_page_shop2api_bol_koopblok_service') { 106 111 $this -> add_koopblock_localize(); … … 111 116 [], $this->version_id() 112 117 ); 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 } 114 127 } 115 128 … … 184 197 } 185 198 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 186 218 private function add_koopblock_localize() { 187 219 require_once SHOP2API_PLUGIN_PATH . '/includes/Api/Shop2ApiConnect.php'; -
shop-2-api/trunk/includes/Pages/Admin.php
r2642569 r2720219 83 83 'manage_options', // Capability 84 84 'shop2api_woocommerce_category', // Menu Slug 85 $function =array($this, 'wc_category_selection_page'), // Function85 array($this, 'wc_category_selection_page'), // Function 86 86 ); 87 87 … … 92 92 'manage_options', // Capability 93 93 'shop2api_bol_mapping', // Menu Slug 94 $function =array($this, 'wc_to_bol_mapping_page'), // Function94 array($this, 'wc_to_bol_mapping_page'), // Function 95 95 ); 96 96 … … 101 101 'manage_options', // Capability 102 102 '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 ); 105 114 106 115 $hook = add_submenu_page( … … 110 119 'manage_options', // Capability 111 120 'shop2api_wc_to_bol_reports', // Menu Slug 112 $function =array($this, 'wc_to_bol_reports_page'), // Function121 array($this, 'wc_to_bol_reports_page'), // Function 113 122 ); 114 123 add_action("load-".$hook, array($this,'mp_add_product_screen_options')); … … 120 129 'manage_options', // Capability 121 130 '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 123 142 ); 124 143 add_action("load-".$hook, array($this,'mp_add_product_screen_options')); … … 156 175 } 157 176 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 158 197 public function wc_to_bol_reports_page() 159 198 { … … 207 246 require_once SHOP2API_PLUGIN_PATH . 'templates/bol-get-best-price.php'; 208 247 } 248 249 public function bol_order_service() 250 { 251 require_once SHOP2API_PLUGIN_PATH . 'templates/bol-order-sync.php'; 252 } 209 253 } 210 254 endif; -
shop-2-api/trunk/includes/Tables/Bol2WcStatusReport.php
r2642569 r2720219 150 150 echo(wp_kses('<div id="openModal" class="modalDialog">'.$empty_table.'<div id="report-modal-data"></div></div>', $allowed_html)); 151 151 } 152 153 function echo_debug_button($request_data, $response_data): string154 {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 }160 152 } -
shop-2-api/trunk/readme.txt
r2700299 r2720219 83 83 2) Removed popup to say sync started as it interfere with the quick edit. 84 84 85 = 1.0.11 = 86 1) Added Order Service to Sync up your orders from Bol.com to WooCommerce. 87 2) Fix small bugs on the koopblok service. 88 85 89 == Instructions == 86 90 1) 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 5 5 Plugin URI: https://wordpress.org/plugins/shop-2-api/ 6 6 Description: 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.1 07 Version: 1.0.11 8 8 Requires at least: 5.0 9 9 Requires PHP: 7.2 … … 34 34 define('SHOP2API_PLUGIN_URL', plugin_dir_url( __FILE__ )); 35 35 define('SHOP2API_PLUGIN', plugin_basename( __FILE__ )); 36 define ('VERSION', '1.0.1 0');36 define ('VERSION', '1.0.11'); 37 37 38 38 // Register items in the project.
Note: See TracChangeset
for help on using the changeset viewer.