Changeset 2402257
- Timestamp:
- 10/19/2020 02:06:29 AM (5 years ago)
- Location:
- doshii
- Files:
-
- 2 added
- 10 edited
-
tags/2.3.0 (added)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/doshii_function.php (modified) (3 diffs)
-
trunk/include/settings.php (modified) (6 diffs)
-
trunk/include/woo-doshii-ajax.php (modified) (1 diff)
-
trunk/include/woo-doshii-dbtable.php (modified) (1 diff)
-
trunk/include/woo-doshii-initialise.php (modified) (2 diffs)
-
trunk/include/woo-doshii-item-dropdown.php (modified) (1 diff)
-
trunk/include/woo-doshii-product-sync.php (modified) (2 diffs)
-
trunk/include/woo-doshii-webhooks.php (added)
-
trunk/include/woo-order-api.php (modified) (1 diff)
-
trunk/include/woo-order-status.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
doshii/trunk/README.txt
r2399878 r2402257 5 5 Requires at least: 4.7 6 6 Tested up to: 5.5.1 7 Stable tag: 2. 2.07 Stable tag: 2.3.0 8 8 Requires PHP: 7.0 9 9 License: GPLv2 or later … … 60 60 == Changelog == 61 61 62 = 2.3.0 = 63 64 Added support for real-time item availability updates from your Point of Sale (POS) 65 62 66 = 2.2.0 = 63 67 -
doshii/trunk/doshii_function.php
r2399878 r2402257 7 7 Author URI: 8 8 Contributors: 9 Version: 2. 2.09 Version: 2.3.0 10 10 */ 11 11 … … 30 30 31 31 register_activation_hook( __FILE__, 'doshii_on_activation' ); 32 wp_enqueue_style( 'doshiistyle', DOSHII_BASE_URL . 'include/assets/css/doshii-style.css',false,'2. 2.0','all');32 wp_enqueue_style( 'doshiistyle', DOSHII_BASE_URL . 'include/assets/css/doshii-style.css',false,'2.3.0','all'); 33 33 include(DOSHII_BASE_DIR . '/include/woo-doshii-dbtable.php'); 34 34 include(DOSHII_BASE_DIR . '/include/woo-checkout-fields.php'); … … 43 43 include(DOSHII_BASE_DIR . '/include/woo-order-status.php'); 44 44 include(DOSHII_BASE_DIR . '/include/woo-doshii-product-sync.php'); 45 include(DOSHII_BASE_DIR . '/include/woo-doshii-webhooks.php'); 45 46 } 46 47 ?> -
doshii/trunk/include/settings.php
r2397826 r2402257 19 19 $default_tab = null; 20 20 $tab = isset($_GET['tab']) ? $_GET['tab'] : $default_tab; 21 22 $token = $doshii_api_key['token']; 21 23 ?> 22 24 … … 34 36 <?php switch($tab) : 35 37 case 'initialisation': 36 $token = $doshii_api_key['token']; 38 $message = '* Doshii Integration already initialised.'; 39 if (empty($token)) { 40 $message = '* Doshii initialisation has not been performed.'; 41 } 42 $locationId = $doshii_options['location_id']; 43 if (empty($locationId)) { 44 $message = 'Doshii location ID has not been configured on the Settings tab.'; 45 } else { 46 $table = $wpdb->prefix . 'doshii_menu'; 47 $doshii_menu_sql = "SELECT doshii_monitor_stock, doshii_filtered_menu FROM $table WHERE location_id = '$locationId'"; 48 $doshiiResults = $wpdb->get_row($doshii_menu_sql) or array(); 49 $monitorStock = empty($doshiiResults->doshii_monitor_stock) ? 'no' : $doshiiResults->doshii_monitor_stock; 50 $isMonitoring = empty($doshii_options['stock_availability']) ? 'no' : $doshii_options['stock_availability']; 51 if ($isMonitoring !== $monitorStock) { 52 $message = '* Re-initialisation is required as Stock Availability monitoring has changed.'; 53 } else if ($isMonitoring === 'yes') { 54 $filtered = empty($doshiiResults->doshii_filtered_menu) ? 'no' : $doshiiResults->doshii_filtered_menu; 55 $nowFiltered = empty($doshii_options['use_menu_management']) ? 'no' : $doshii_options['use_menu_management']; 56 if ($filtered !== $nowFiltered) { 57 $message = '* Re-initialisation is required as Menu Management setting has changed.'; 58 } 59 } 60 } 61 37 62 ?> 38 63 <h2> … … 50 75 </tr> 51 76 <?php 52 if (!empty($ token)) {77 if (!empty($message)) { 53 78 ?> 54 79 <tr valign="top"> 55 80 <th scope="row" valign="top"></th> 56 <td> * Doshii Integration already initialised</td>81 <td><?php echo $message ?></td> 57 82 </tr> 58 83 <?php … … 106 131 break; 107 132 case 'menu': 133 $message = ''; 134 if (empty($token)) { 135 $message = '* Doshii initialisation has not been performed.'; 136 } 137 $locationId = $doshii_options['location_id']; 138 if (empty($locationId)) { 139 $message = 'Doshii location ID has not been configured on the Settings tab.'; 140 } else { 141 $table = $wpdb->prefix . 'doshii_menu'; 142 $doshii_menu_sql = "SELECT doshii_filtered_menu FROM $table WHERE location_id = '$locationId'"; 143 $doshiiResults = $wpdb->get_row($doshii_menu_sql) or array(); 144 $filtered = empty($doshiiResults->doshii_filtered_menu) ? 'no' : $doshiiResults->doshii_filtered_menu; 145 $nowFiltered = empty($doshii_options['use_menu_management']) ? 'no' : $doshii_options['use_menu_management']; 146 if ($filtered !== $nowFiltered) { 147 $message = '* Re-synchronisation is required as Menu Management setting has changed.'; 148 } 149 } 150 108 151 $doshii_product_table = $wpdb->prefix . 'doshii_product'; 109 152 $productCount = $wpdb->get_var( "SELECT COUNT(*) FROM $doshii_product_table" ); … … 129 172 plugins_url( '/assets/images/loading.gif', __FILE__ ) 130 173 ); ?> 131 <p class="message"></p>132 174 </td> 175 </tr> 176 <tr valign="top"> 177 <th scope="row" valign="top"></th> 178 <td class="message"><?php echo $message ?></td> 133 179 </tr> 134 180 </tbody> … … 215 261 </td> 216 262 </tr> 263 264 <tr valign="top"> 265 <th scope="row" valign="top"> 266 <?php _e('Manage Stock Availability', 'doshii'); ?> 267 </th> 268 <td> 269 <div> 270 <input id="doshiiapi_settings[stock_availability]" name="doshiiapi_settings[stock_availability]" type="checkbox" value="yes" <?php checked('yes', $doshii_options['stock_availability'], true) ?>/> 271 <p style="display:inline;"> (will require re-initialisation if changed)</p> 272 </div> 273 </td> 274 </tr> 217 275 </tbody> 218 276 </table> -
doshii/trunk/include/woo-doshii-ajax.php
r2386799 r2402257 61 61 62 62 63 function variation_build_option_list(sel,variationid){ 64 //alert(sel.value); 63 function variation_build_option_list(sel,variationid) { 65 64 jQuery('.overlay_section').addClass('overlay'); 66 65 var doshii_parentId = sel.value; -
doshii/trunk/include/woo-doshii-dbtable.php
r2386799 r2402257 16 16 location_id varchar(100) NOT NULL, 17 17 doshii_filtered_menu varchar(10) NOT NULL, 18 doshii_monitor_stock varchar(10) NOT NULL, 18 19 doshii_menu_version varchar(2000) NOT NULL, 19 20 doshii_menu_updated varchar(100) NOT NULL, -
doshii/trunk/include/woo-doshii-initialise.php
r2399878 r2402257 33 33 } 34 34 35 $url = $doshii_options['server_url'].'/registration'; 35 $filtered = $doshii_options['use_menu_management']; 36 $filteredParam = (empty($filtered) || $filtered !== 'yes') ? '' : '?filtered=true'; 37 $url = $doshii_options['server_url'].'/registration'.$filteredParam; 38 $headers = array( 39 'Authorization' => 'Bearer '.$key.'', 40 'x-doshii-location-id' => $locationId.'', 41 'content-Type' => 'application/json', 42 'x-doshii-writeout' => 'WooCommerce 2.3.0', 43 ); 44 45 // Request webhook registration if stock availability is enabled 46 $monitorStock = empty($doshii_options['stock_availability']) ? 'no' : $doshii_options['stock_availability']; 47 if ($monitorStock === 'yes') { 48 $webhookKey = uniqid('doshii_'); 49 $headers['x-doshii-webhook-key'] = $webhookKey.''; 50 51 $adminUrl = admin_url( 'admin-post.php' ); 52 $headers['x-doshii-webhook-url'] = $adminUrl.'?action=doshii'; 53 } 54 36 55 $result = wp_remote_get($url, array( 37 'headers' => array( 38 'Authorization' => 'Bearer '.$key.'', 39 'x-doshii-location-id' => $locationId.'', 40 'content-Type' => 'application/json', 41 'x-doshii-writeout' => 'WooCommerce 2.2.0', 42 ) 56 'headers' => $headers 43 57 )); 44 58 if( is_wp_error( $result ) ) { … … 53 67 if ($response->token) { 54 68 $doshii_api_key['token'] = $response->token; 69 $doshii_api_key['webhook'] = $webhookKey; 55 70 update_option('doshiiapi_key', $doshii_api_key); 71 72 $table = $wpdb->prefix . 'doshii_menu'; 73 $delete = $wpdb->query("TRUNCATE TABLE $table"); 74 75 $table_name = $wpdb->prefix."doshii_menu"; 76 $filtered = empty($doshii_options['use_menu_management']) ? 'no' : $doshii_options['use_menu_management']; 77 $wpdb->query("INSERT INTO $table_name (location_id, doshii_menu_version, doshii_menu_updated, doshii_filtered_menu, doshii_monitor_stock) VALUES ('$locationId', '', '', '$filtered', '$monitorStock')"); 78 56 79 $sync_result = array( 57 80 'message' => 'The Doshii integration has been successfully initialised' -
doshii/trunk/include/woo-doshii-item-dropdown.php
r2399878 r2402257 110 110 //add column 111 111 $updatedColumns = array_slice($columns, 0, count($columns) - 1, true) + 112 array('doshii_product_map' => __('Doshii ProductID', 'doshii')) +112 array('doshii_product_map' => __('Doshii ID', 'doshii')) + 113 113 array_slice($columns, count($columns) - 1, NULL, true); 114 114 -
doshii/trunk/include/woo-doshii-product-sync.php
r2399878 r2402257 41 41 'x-doshii-location-id' => $locationId.'', 42 42 'content-Type' => 'application/json', 43 'x-doshii-writeout' => 'WooCommerce 2. 2.0',43 'x-doshii-writeout' => 'WooCommerce 2.3.0', 44 44 ) 45 45 )); … … 71 71 72 72 $table_name = $wpdb->prefix."doshii_menu"; 73 $wpdb->query("INSERT INTO $table_name (location_id, doshii_menu_version, doshii_menu_updated, doshii_filtered_menu) VALUES ('$locationId', '$response->version', '$response->updatedAt', '$nowFiltered')"); 73 $monitorStock = empty($doshii_options['stock_availability']) ? 'no' : $doshii_options['stock_availability']; 74 $wpdb->query("INSERT INTO $table_name (location_id, doshii_menu_version, doshii_menu_updated, doshii_filtered_menu, doshii_monitor_stock) VALUES ('$locationId', '$response->version', '$response->updatedAt', '$nowFiltered', '$monitorStock')"); 74 75 75 76 $table = $wpdb->prefix . 'doshii_product'; -
doshii/trunk/include/woo-order-api.php
r2399878 r2402257 486 486 'accept' => 'application/json', 487 487 'Accept-encoding' => 'gzip', 488 'x-doshii-writeout' => 'WooCommerce 2. 2.0',488 'x-doshii-writeout' => 'WooCommerce 2.3.0', 489 489 ), 490 490 'body' => json_encode($doshiiOrderPayload) -
doshii/trunk/include/woo-order-status.php
r2399878 r2402257 39 39 'x-doshii-location-id' => $doshii_options['location_id'].'', 40 40 'content-Type' => 'application/json', 41 'x-doshii-writeout' => 'WooCommerce 2. 2.0',41 'x-doshii-writeout' => 'WooCommerce 2.3.0', 42 42 ) 43 43 ));
Note: See TracChangeset
for help on using the changeset viewer.