Plugin Directory

Changeset 1233812


Ignore:
Timestamp:
08/29/2015 06:06:29 PM (11 years ago)
Author:
belco
Message:

Version 0.3.7

Location:
belcoio/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • belcoio/trunk/api.php

    r1233109 r1233812  
    22class Belco_API {
    33
    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
    611        $protocol = BELCO_USE_SSL ? 'https://' : 'http://';
    712
  • belcoio/trunk/belco.php

    r1233112 r1233812  
    22/**
    33 * @package Belco
    4  * @version 0.3.6
     4 * @version 0.3.7
    55 *
    66 */
     
    99Plugin URI: http://www.belco.io
    1010Description: Telephony for webshops
    11 Version: 0.3.6
     11Version: 0.3.7
    1212Author: Forwarder B.V.
    1313Author URI: http://www.forwarder.nl
     
    104104      register_setting('wp_belco', 'belco_secret');
    105105
    106       add_action('pre_update_option_belco_shop_id', array(&$this, 'connect'));
     106      add_filter('pre_update_option_belco_secret', array(&$this, 'connect'));
    107107    }
    108108
     
    218218    }
    219219
    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) {
    224227        add_settings_error('belco_shop_id', 'shop-id', $result);
    225 
    226       return $shopId;
     228        return $oldSecret;
     229      }
     230
     231      return $secret;
    227232    }
    228233  }
  • belcoio/trunk/connectors/woocommerce.php

    r1168468 r1233812  
    33
    44class WooCommerceConnector {
    5  
     5
    66  public function __construct() {
    77    // init hooks etc
     
    1111    add_action('woocommerce_order_status_changed', array($this, 'sync_order'));
    1212  }
    13  
    14   public function connect($shop_id) {
     13
     14  public function connect($shop_id, $secret) {
    1515    return Belco_API::post('/shops/connect', array(
    1616      'id' => $shop_id,
    1717      'type' => 'woocommerce',
    1818      'url' => get_site_url()
    19     ));
     19    ), array('secret' => $secret));
    2020  }
    21  
     21
    2222  public function sync_order($id) {
    2323    $order = $this->get_order($id);
     
    2626    }
    2727  }
    28  
     28
    2929  public function get_customers() {
    3030    $users = get_users(array(
     
    3333      'orderby' => 'registered'
    3434    ));
    35    
     35
    3636    $customers = array();
    3737    foreach ($users as $user_id) {
     
    4141    return $customers;
    4242  }
    43  
     43
    4444  public function get_customer($id) {
    4545    $user = get_userdata($id);
    46    
     46
    4747    if (!$user) {
    4848      return null;
    4949    }
    50    
     50
    5151    $customer = array(
    5252      'id' => $user->ID,
     
    6060    return $customer;
    6161  }
    62  
     62
    6363  public function get_cart() {
    6464    $items = array();
     
    7777      }
    7878    }
    79    
     79
    8080    $cart = array(
    8181      'currency' => get_woocommerce_currency(),
     
    8484      'items' => $items
    8585    );
    86    
     86
    8787    return $cart;
    8888  }
    89  
     89
    9090  public function get_orders() {
    91    
     91
    9292  }
    9393
     
    117117    );
    118118  }
    119  
     119
    120120  public function get_order_products($order) {
    121121    return array_map(function($item) {
     
    127127    }, $order->get_items());
    128128  }
    129  
     129
    130130}
  • belcoio/trunk/readme.txt

    r1233109 r1233812  
    55Requires at least: 3.9.1
    66Tested up to: 4.3
    7 Stable tag: 0.3.6
     7Stable tag: 0.3.7
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4545== Changelog ==
    4646
     47= 0.3.7 =
     48- Improved shop setup verification
     49
    4750= 0.3.6 =
    4851- Compatibility with WP 4.3
Note: See TracChangeset for help on using the changeset viewer.