pixelpeter / laravel5-woocommerce-api-client

Laravel 5 wrapper for the Woocommerce REST API
MIT License
126 stars 48 forks source link

Allow for multiple sites #11

Closed BHEADRICK closed 7 years ago

BHEADRICK commented 7 years ago

I'd like to be able to manage multiple wc sites from a single laravel app.

This seems like it should be feasible, but with the current setup, it seems it's only possible to access one.

pixelpeter commented 7 years ago

The laravel5-woocommerce-api-client is just a simple wrapper around the Woocommerce API sp you can use the power and beauty of Laravel facades.

If you want to manage multiple sites use the Woocommerce API directly. It should be something like this (not tested):

use Automattic\WooCommerce\Client;

$storeOne = new Client(
    'https://example-store-one.com',
    'ck_****store-one****',
    'cs_****store-one****',
    [
        'wp_api' => true,
        'version' => 'wc/v1',
        'verify_ssl' => false,
        'debug' => true,
        'validate_url' => false,
        ...
    ]
);

$storeTwo = new Client(
    'https://example-store-two.com',
    'ck_****store-two****',
    'cs_****store-two****',
    [
        'wp_api' => true,
        ...
    ]
);

$storeOne->get('products'),
$storeTwo->get('products')
jonathan-bird commented 7 years ago

@pixelpeter Would this then mean I can't use the normal facade way? Doesn't seem to be any point to this library if I were to use two stores?.