1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ShopifyClient\Resource; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* https://help.shopify.com/api/reference/product_variant |
7
|
|
|
* |
8
|
|
|
* @method create(float $parentId, array $parameters = []) |
9
|
|
|
* @method get(float $childId) |
10
|
|
|
* @method all(float $parentId, array $parameters = []) |
11
|
|
|
* @method count(float $parentId) |
12
|
|
|
* @method update(float $childId, array $parameters = []) |
13
|
|
|
* @method delete(float $parentId, float $childId) |
14
|
|
|
* |
15
|
|
|
* @property ProductVariantMetaField $metafields |
16
|
|
|
*/ |
17
|
|
|
class ProductVariant extends AbstractResource implements Resource |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var array |
21
|
|
|
*/ |
22
|
|
|
protected $actions = [ |
23
|
|
|
'create' => [ |
24
|
|
|
'method' => 'POST', |
25
|
|
|
'endpoint' => 'products/%s/variants.json', |
26
|
|
|
'resourceKey' => 'variant', |
27
|
|
|
'responseKey' => 'variant', |
28
|
|
|
], |
29
|
|
|
'get' => [ |
30
|
|
|
'method' => 'GET', |
31
|
|
|
'endpoint' => 'variants/%s.json', |
32
|
|
|
'resourceKey' => 'variant', |
33
|
|
|
'responseKey' => 'variant', |
34
|
|
|
], |
35
|
|
|
'all' => [ |
36
|
|
|
'method' => 'GET', |
37
|
|
|
'endpoint' => 'products/%s/variants.json', |
38
|
|
|
'resourceKey' => 'variants', |
39
|
|
|
'responseKey' => 'variants', |
40
|
|
|
], |
41
|
|
|
'count' => [ |
42
|
|
|
'method' => 'GET', |
43
|
|
|
'endpoint' => 'products/%s/variants/count.json', |
44
|
|
|
'resourceKey' => 'count', |
45
|
|
|
'responseKey' => 'count', |
46
|
|
|
], |
47
|
|
|
'update' => [ |
48
|
|
|
'method' => 'PUT', |
49
|
|
|
'endpoint' => 'variants/%s.json', |
50
|
|
|
'resourceKey' => 'variant', |
51
|
|
|
'responseKey' => 'variant', |
52
|
|
|
], |
53
|
|
|
'delete' => [ |
54
|
|
|
'method' => 'DELETE', |
55
|
|
|
'endpoint' => 'products/%s/variants/%s.json', |
56
|
|
|
], |
57
|
|
|
]; |
58
|
|
|
|
59
|
|
|
protected $childResources = [ |
60
|
|
|
'metafields' => ProductVariantMetaField::class, |
61
|
|
|
]; |
62
|
|
|
} |
63
|
|
|
|