Exemplo n.º 1
0
 /**
  * Turned off ssl_verify, you could
  * turn this on if you want.
  *
  * @param string $shop
  * @param string $key
  * @param string $secret
  * @param array $options
  */
 public function __construct($shop, $key, $secret, $options = ['ssl_verify' => false])
 {
     /*
      * Feed the parent construct
      * so the WC_CLIENT is Loaded
      */
     parent::__construct($shop, $key, $secret, $options);
 }
Exemplo n.º 2
0
<?php

// Include the client library
//require_once 'class-wc-api-client.php';
$consumer_key = 'ck_1f2b2b4019b854e6b346585931af6ea7';
// Add your own Consumer Key here
$consumer_secret = 'cs_8936e72aefea92c979f81306f4a23662';
// Add your own Consumer Secret here
$store_url = 'http://localhost:8888/woocommerce';
$table_prefix = 'wp_';
require dirname(__FILE__) . '/wp-blog-header.php';
if (isset($_GET["endpoint"])) {
    $endpoint = $_GET["endpoint"];
    $wc_api = new WC_API_Client($consumer_key, $consumer_secret, $store_url);
    $wc_api->set_return_as_object(false);
    switch ($endpoint) {
        case "products":
            echo $wc_api->get_products();
            break;
        case 'product':
            echo $wc_api->get_product($_GET["id"]);
            break;
        case "orders":
            echo "orders!";
            break;
        case "custom":
            echo $wc_api->make_custom_endpoint_call('products');
            break;
        case "categories":
            echo $wc_api->get_categories();
            break;
Exemplo n.º 3
-1
<?php

require_once '../lib/woocommerce-api.php';
$options = array('debug' => true, 'return_as_array' => false, 'validate_url' => false, 'timeout' => 30, 'ssl_verify' => false);
try {
    $client = new WC_API_Client('http://localhost', 'ck_257dea7df7c3f546767a74ea83a3f460a2256fe0', 'cs_8e8e22436d23276de42d826b194037f52f283c1e', $options);
    // coupons
    //print_r( $client->coupons->get() );
    //print_r( $client->coupons->get( $coupon_id ) );
    //print_r( $client->coupons->get_by_code( 'coupon-code' ) );
    //print_r( $client->coupons->create( array( 'code' => 'test-coupon', 'type' => 'fixed_cart', 'amount' => 10 ) ) );
    //print_r( $client->coupons->update( $coupon_id, array( 'description' => 'new description' ) ) );
    //print_r( $client->coupons->delete( $coupon_id ) );
    //print_r( $client->coupons->get_count() );
    // custom
    //$client->custom->setup( 'webhooks', 'webhook' );
    //print_r( $client->custom->get( $params ) );
    // customers
    //print_r( $client->customers->get() );
    //print_r( $client->customers->get( $customer_id ) );
    //print_r( $client->customers->get_by_email( '*****@*****.**' ) );
    //print_r( $client->customers->create( array( 'email' => '*****@*****.**' ) ) );
    //print_r( $client->customers->update( $customer_id, array( 'first_name' => 'John', 'last_name' => 'Galt' ) ) );
    //print_r( $client->customers->delete( $customer_id ) );
    //print_r( $client->customers->get_count( array( 'filter[limit]' => '-1' ) ) );
    //print_r( $client->customers->get_orders( $customer_id ) );
    //print_r( $client->customers->get_downloads( $customer_id ) );
    //$customer = $client->customers->get( $customer_id );
    //$customer->customer->last_name = 'New Last Name';
    //print_r( $client->customers->update( $customer_id, (array) $customer ) );
    // index
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
require_once 'src/WC_API_Client.php';
require_once 'src/WC_API_Client_Customer.php';
require_once 'src/WC_API_Client_Product.php';
require_once 'src/WC_API_Client_Response.php';
// $consumer_key = 'ck_250a148201c18c65deb2437d1fa46308';
// $consumer_secret = 'cs_56afec57ff650d51bea14c9e26773599';
// $store_url = 'http://helpforfitness.com/';
$consumer_key = 'ck_250a148201c18c65deb2437d1fa46308';
$consumer_secret = 'cs_56afec57ff650d51bea14c9e26773599';
$store_url = 'http://dev.helpforfitness.com/';
$wc_api = new WC_API_Client($consumer_key, $consumer_secret, $store_url);
//$rs = $wc_api->Product()->getAll(array('filter[in]' => "1516,1174"))->toArray();
$rs = $wc_api->Customer()->byEmail('*****@*****.**')->toJson();
print_r($rs);