Changeset 1472568
- Timestamp:
- 08/11/2016 08:03:47 PM (10 years ago)
- Location:
- cue-connect/trunk
- Files:
-
- 1 added
- 5 edited
-
cue-connect.php (modified) (1 diff)
-
inc/class.cue-api.php (modified) (6 diffs)
-
inc/class.cue-connect.php (modified) (1 diff)
-
inc/class.cue-endpoint.php (added)
-
inc/class.cue-options.php (modified) (5 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cue-connect/trunk/cue-connect.php
r1468663 r1472568 3 3 * Plugin Name: Cue Connect 4 4 * Description: Meet Cue, your customers’ personal shopping assistant that feeds you actionable data. 5 * Version: 1.0. 35 * Version: 1.0.4 6 6 * Author: Cue Connect 7 7 * Author URI: http://business.cueconnect.com/ -
cue-connect/trunk/inc/class.cue-api.php
r1468907 r1472568 37 37 ), 38 38 39 'select_vers tion' => array(39 'select_version' => array( 40 40 'action' => 'selectVersion', 41 41 'key' => 'a2645def81375a4f88475acc6b4b0639fd87bfaef715b828e1704f79bac6262ef0e85876dd7047765360678b3372812b5f1741b3abfe9159a3d50fe01e05d757' … … 160 160 $params = array( 161 161 'storeId' => $place_id, 162 'id' => 4,163 'email' => ' sasha.anpilov@gmail.com',162 'id' => 6, 163 'email' => 'aanpilov@cueconnect.com', 164 164 'fullName' => "sasha", 165 165 'firstName' => "sasha", … … 170 170 ); 171 171 $response = $this->do_webhook($url, $auth_key, $params); 172 print_r($response); 172 var_dump($response); 173 die(); 173 174 return $response; 174 175 } 175 176 176 public function select_version() { 177 177 public function select_version($value) { 178 179 $options = cue_options::get(); 180 181 $url = $this->get_webhook_url() . 'selectVersion'; 182 $version = $value; 183 184 $str = 185 "v$version" 186 . $this->webhook_actions['select_version']['key'] 187 . $this->get_webhook_url() . "selectVersion" 188 . $options['api_key']; 189 190 $key = sha1($str) . "$" . $options['api_key']; 191 192 $params = array( 193 'version' => $version 194 ); 195 196 197 $response = (int)$this->do_webhook($url, $key, $params); 198 if ($response == $options['place_id']) { 199 return true; 200 } else { 201 return false; 202 } 203 return false; 178 204 } 179 205 … … 183 209 184 210 // do POST - use curl 185 if (function_exists('curl_version') && 1==0) {211 if (function_exists('curl_version')) { 186 212 try { 213 187 214 $ch = curl_init(); 188 215 curl_setopt($ch, CURLOPT_URL, $url); 189 curl_setopt($ch, CURLOPT_HEADER);216 // curl_setopt($ch, CURLOPT_HEADER); 190 217 curl_setopt($ch, CURLOPT_POSTFIELDS, $params); 191 218 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); … … 195 222 $response = curl_exec($ch); 196 223 $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 197 198 224 curl_close($ch); 225 199 226 } catch (Exception $e) { 200 // Mage::log($e->getMessage());227 // TODO: Log errors 201 228 } 202 229 } … … 206 233 $queryString = '?' . http_build_query($params); 207 234 try { 208 // $response = file_get_contents($url . $queryString); 209 210 print_r($url . $queryString); 211 235 $response = file_get_contents($url . $queryString); 212 236 } catch (Exception $e) { 213 // Mage::log($e->getMessage());237 // TODO: Log errors 214 238 } 215 239 } -
cue-connect/trunk/inc/class.cue-connect.php
r1468658 r1472568 29 29 if (is_admin()) { 30 30 add_action('init', array('cue_options','init')); 31 } 32 33 // add /apps/mylist endpoint if needed 34 if (2 == self::$_options['version']) { 35 require_once CUE_PLUGIN_DIR . 'inc/class.cue-endpoint.php'; 36 new Cue_Endpoint; 31 37 } 32 38 -
cue-connect/trunk/inc/class.cue-options.php
r1468907 r1472568 94 94 */ 95 95 $connected = false; 96 97 $new = $options; 98 $old = self::get(); 99 96 100 if ( 97 101 $options['username'] !== self::$options['username'] 98 102 || $options['password'] !== self::$options['password'] 99 || empty(self::$options['api_key'])100 || empty(self::$options['place_id'])101 103 ) { 102 104 $connected = self::connect_cue_account( … … 110 112 ); 111 113 } else { 114 if (!empty(self::$options['username']) && !empty(self::$options['password'])) { 115 self::$_notices['credentials'] = array( 116 'type' => 'error', 117 'message' => "Error. Please check credentials and try again." 118 ); 119 } 120 } 121 } 122 123 /** 124 * Check if PB/CP version has changed and send webhook if true 125 */ 126 127 if (!empty($new['version']) && $new['version'] !== $old['version']) { 128 $version_changed = self::cue_select_version($new['version']); 129 if ($version_changed) { 130 if (2 == $new['version']) { 131 update_option('cue_flush_rewrite', 1); 132 } 112 133 self::$_notices['credentials'] = array( 113 'type' => ' error',114 'message' => " Error. Please check credentials and try again."134 'type' => 'success', 135 'message' => "My-List version changed successfully" 115 136 ); 116 137 } … … 157 178 158 179 return true; 180 } 181 182 /** 183 * Call to magento webhook, asking to change CP/PB 184 * 185 * @param int $value 1:PB, 2:CP 186 * @return bool true on success 187 */ 188 private static function cue_select_version($value) 189 { 190 $api = new Cue_Api; 191 $response = $api->select_version($value); 192 return $response; 159 193 } 160 194 … … 282 316 </form> 283 317 318 <?php /* 284 319 <?php if (isset($_GET['dev'])) : ?> 285 320 <pre> … … 289 324 </pre> 290 325 <?php endif; ?> 326 */ ?> 291 327 292 328 <?php if (isset($_GET['start_sync']) && $_GET['start_sync'] == $options['api_key']) { -
cue-connect/trunk/readme.txt
r1468667 r1472568 6 6 WC requires at least: 1.6 7 7 WC tested up to: 2.6 8 Stable tag: 1.0. 38 Stable tag: 1.0.4 9 9 License: GPLv3 or later License 10 10 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 93 93 == Changelog == 94 94 95 = 1.0.4 = 96 * Stability improvements 97 95 98 = 1.0.3 = 96 99 * Added conversion tracking
Note: See TracChangeset
for help on using the changeset viewer.