Changeset 1233812
- Timestamp:
- 08/29/2015 06:06:29 PM (11 years ago)
- Location:
- belcoio/trunk
- Files:
-
- 4 edited
-
api.php (modified) (1 diff)
-
belco.php (modified) (4 diffs)
-
connectors/woocommerce.php (modified) (10 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
belcoio/trunk/api.php
r1233109 r1233812 2 2 class Belco_API { 3 3 4 public static function post($path, $data) { 5 $secret = get_option('belco_secret'); 4 public static function post($path, $data, $options) { 5 if (!empty($options['secret'])) { 6 $secret = $options['secret']; 7 } else { 8 $secret = get_option('belco_secret'); 9 } 10 6 11 $protocol = BELCO_USE_SSL ? 'https://' : 'http://'; 7 12 -
belcoio/trunk/belco.php
r1233112 r1233812 2 2 /** 3 3 * @package Belco 4 * @version 0.3. 64 * @version 0.3.7 5 5 * 6 6 */ … … 9 9 Plugin URI: http://www.belco.io 10 10 Description: Telephony for webshops 11 Version: 0.3. 611 Version: 0.3.7 12 12 Author: Forwarder B.V. 13 13 Author URI: http://www.forwarder.nl … … 104 104 register_setting('wp_belco', 'belco_secret'); 105 105 106 add_ action('pre_update_option_belco_shop_id', array(&$this, 'connect'));106 add_filter('pre_update_option_belco_secret', array(&$this, 'connect')); 107 107 } 108 108 … … 218 218 } 219 219 220 public function connect($shopId) { 221 $result = $this->connector->connect($shopId); 222 223 if ($result !== true) 220 /** 221 * Connects the shop to Belco 222 */ 223 public function connect($secret, $oldSecret) { 224 $result = $this->connector->connect(get_option('belco_shop_id'), $secret); 225 226 if ($result !== true) { 224 227 add_settings_error('belco_shop_id', 'shop-id', $result); 225 226 return $shopId; 228 return $oldSecret; 229 } 230 231 return $secret; 227 232 } 228 233 } -
belcoio/trunk/connectors/woocommerce.php
r1168468 r1233812 3 3 4 4 class WooCommerceConnector { 5 5 6 6 public function __construct() { 7 7 // init hooks etc … … 11 11 add_action('woocommerce_order_status_changed', array($this, 'sync_order')); 12 12 } 13 14 public function connect($shop_id ) {13 14 public function connect($shop_id, $secret) { 15 15 return Belco_API::post('/shops/connect', array( 16 16 'id' => $shop_id, 17 17 'type' => 'woocommerce', 18 18 'url' => get_site_url() 19 ) );19 ), array('secret' => $secret)); 20 20 } 21 21 22 22 public function sync_order($id) { 23 23 $order = $this->get_order($id); … … 26 26 } 27 27 } 28 28 29 29 public function get_customers() { 30 30 $users = get_users(array( … … 33 33 'orderby' => 'registered' 34 34 )); 35 35 36 36 $customers = array(); 37 37 foreach ($users as $user_id) { … … 41 41 return $customers; 42 42 } 43 43 44 44 public function get_customer($id) { 45 45 $user = get_userdata($id); 46 46 47 47 if (!$user) { 48 48 return null; 49 49 } 50 50 51 51 $customer = array( 52 52 'id' => $user->ID, … … 60 60 return $customer; 61 61 } 62 62 63 63 public function get_cart() { 64 64 $items = array(); … … 77 77 } 78 78 } 79 79 80 80 $cart = array( 81 81 'currency' => get_woocommerce_currency(), … … 84 84 'items' => $items 85 85 ); 86 86 87 87 return $cart; 88 88 } 89 89 90 90 public function get_orders() { 91 91 92 92 } 93 93 … … 117 117 ); 118 118 } 119 119 120 120 public function get_order_products($order) { 121 121 return array_map(function($item) { … … 127 127 }, $order->get_items()); 128 128 } 129 129 130 130 } -
belcoio/trunk/readme.txt
r1233109 r1233812 5 5 Requires at least: 3.9.1 6 6 Tested up to: 4.3 7 Stable tag: 0.3. 67 Stable tag: 0.3.7 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 45 45 == Changelog == 46 46 47 = 0.3.7 = 48 - Improved shop setup verification 49 47 50 = 0.3.6 = 48 51 - Compatibility with WP 4.3
Note: See TracChangeset
for help on using the changeset viewer.