This repository has been archived by the owner on Nov 30, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 374
Usage
Tyler King edited this page Oct 19, 2018
·
20 revisions
Here's some helpful tips on using this package's facade.
Using the facade:
// Returns instance of \OhMyBrew\ShopifyApp\Models\Shop
ShopifyApp::shop()
// Returns instance of \OhMyBrew\BasicShopifyAPI (ohmybrew/basic-shopify-api)
$shop = ShopifyApp::shop();
$shop->api()->rest(...);
Example:
$shop = ShopifyApp::shop();
$request = $shop->api()->rest('GET', '/admin/shop.json');
echo $request->body->shop->name;
For single/recurring/credit type charges, you can access them via the Charge model's retrieve
method for charges which exist in the database for a shop.
Example:
$shop = ShopifyApp::shop();
$charge = $shop->charges()->get()->last();
print_r($charge->retrieve()); // Returns an object of the API data for the charge
On the roadmap; this repo will allow for easier interaction with the API.
Examples:
$product = Product::find(1624265326631);
echo "Product: {$product->title}";
$product->title = 'New Title';
$product->save();
$variant = $product->variants->first();
echo $variant->id;
print_r($variant->image->src); // Gets the variant image (lazy loaded)
print_r($variant->product); // Gets product for variant (lazy loaded)
print_r($product->collections->first()->collects); // Gets collects for the collection (lazy loaded)
$count = Product::all()->count();
echo "There are {$count} products";
$variant = Variant::findThrough(12999209309, $product);
echo $variant->id;
$collection = CustomCollection::find(29889201111);
echo $collection->handle;
$collect = Collect::all(['collection_id' => $collection->id]);
$products = $collect->map(function ($c) { return $c->product; });
road map
Welcome to the wiki!
Please see the homepage for a list of relevant pages.