Using ShopifyEASDK
The EASDK class is a collection of helper methods and API wrappers which make it easier to implement Shopify's Embedded App SDK.
Remember: to use EASDK you must already have a working Shopify app which can be hosted on a server with SSL support.
Getting an instance
use Esc\Shopify\API as ShopifyAPI;
use Esc\Shopify\EASDK as ShopifyEASDK;
// You can get an API instance via the IoC container
public function index(ShopifyEASDK $easdk) {
$api = $easdk->getAPI();
}
public function index() {
// Or via the the app helper function
$easdk = app('ShopifyEASDK');
$api = $easdk->getAPI();
}
Getting / Setting the API instance
You can get an API instance from the EASDK at any time:
$api = $easdk->getAPI();
By default, this API object's credentials will be set from the config.
You can change which shop the EASDK is set to simply by changing out it's API instance:
$api2 = app('ShopifyAPI', [
'SHOP_DOMAIN' => 'secondshop.myshopify.com',
'ACCESS_TOKEN' => '1111111111111111111111111'
]);
$easdk->setApi($api2);
Or by calling setup()
on the current instance:
$easdk->getAPI()->setup([
'SHOP_DOMAIN' => 'secondshop.myshopify.com',
'ACCESS_TOKEN' => '1111111111111111111111111'
]);