php-shopify icon indicating copy to clipboard operation
php-shopify copied to clipboard

Can create two instances of Shopify SDK

Open vicn1222 opened this issue 4 years ago • 2 comments

Static is used in ShopifySDK.php. It is not reentry. Can't create two instances of ShopifySDK.

Can developers please remove static?

Thanks.

vicn1222 avatar May 01 '21 02:05 vicn1222

i thought yes , you can use two instance but you need to specify name space sperate for each instances

bavamca avatar Jun 01 '21 20:06 bavamca

I use a parent class and have a function in it

protected function resetConfig($config) { return PHPShopify\ShopifySDK::config($config); }

Then I have extending classes that have their own private config array

In each of these extending classes, I call the function resetConfig so the Shopify object has the correct configuration before I call any of the PHPShopify functions

Using this method, I have set up 4 different instances of the Shopify object for use with different clients and shops inside my web application

Hope this might help

marxolly avatar Jun 18 '21 02:06 marxolly