1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Signifly\Shopify\REST\Actions; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Collection; |
6
|
|
|
use Signifly\Shopify\REST\Resources\MetafieldResource; |
7
|
|
|
use Signifly\Shopify\Shopify; |
8
|
|
|
|
9
|
|
|
/** @mixin Shopify */ |
10
|
|
|
trait ManagesMetafields |
11
|
|
|
{ |
12
|
|
|
public function createMetafield(array $data): MetafieldResource |
13
|
|
|
{ |
14
|
|
|
return $this->createResource('metafields', $data); |
|
|
|
|
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
public function getMetafieldsCount(array $params = []): int |
18
|
|
|
{ |
19
|
|
|
return $this->getResourceCount('metafields', $params); |
|
|
|
|
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function getMetafields(array $params = []): Collection |
23
|
|
|
{ |
24
|
|
|
return $this->getResources('metafields', $params); |
|
|
|
|
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function getMetafield($metafieldId): MetafieldResource |
28
|
|
|
{ |
29
|
|
|
return $this->getResource('metafields', $metafieldId); |
|
|
|
|
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function updateMetafield($metafieldId, array $data): MetafieldResource |
33
|
|
|
{ |
34
|
|
|
return $this->updateResource('metafields', $metafieldId, $data); |
|
|
|
|
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function deleteMetafield($metafieldId): void |
38
|
|
|
{ |
39
|
|
|
$this->deleteResource('metafields', $metafieldId); |
|
|
|
|
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function createCustomerMetafield($customerId, array $data): MetafieldResource |
43
|
|
|
{ |
44
|
|
|
return $this->createResource('metafields', $data, ['customers', $customerId]); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function getCustomerMetafieldsCount($customerId, array $params = []): int |
48
|
|
|
{ |
49
|
|
|
return $this->getResourceCount('metafields', $params, ['customers', $customerId]); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function getCustomerMetafields($customerId, array $params = []): Collection |
53
|
|
|
{ |
54
|
|
|
return $this->getResources('metafields', $params, ['customers', $customerId]); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function createProductMetafield($productId, array $data): MetafieldResource |
58
|
|
|
{ |
59
|
|
|
return $this->createResource('metafields', $data, ['products', $productId]); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getProductMetafieldsCount($productId, array $params = []): int |
63
|
|
|
{ |
64
|
|
|
return $this->getResourceCount('metafields', $params, ['products', $productId]); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function getProductMetafields($productId, array $params = []): Collection |
68
|
|
|
{ |
69
|
|
|
return $this->getResources('metafields', $params, ['products', $productId]); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function createVariantMetafield($variantId, array $data): MetafieldResource |
73
|
|
|
{ |
74
|
|
|
return $this->createResource('metafields', $data, ['variants', $variantId]); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function getVariantMetafieldsCount($variantId, array $params = []): int |
78
|
|
|
{ |
79
|
|
|
return $this->getResourceCount('metafields', $params, ['variants', $variantId]); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function getVariantMetafields($variantId, array $params = []): Collection |
83
|
|
|
{ |
84
|
|
|
return $this->getResources('metafields', $params, ['variants', $variantId]); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function createProductVariantMetafield($productId, $variantId, array $data): MetafieldResource |
88
|
|
|
{ |
89
|
|
|
return $this->createResource('metafields', $data, ['products', $productId, 'variants', $variantId]); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function getProductVariantMetafieldsCount($productId, $variantId, array $params = []): int |
93
|
|
|
{ |
94
|
|
|
return $this->getResourceCount('metafields', $params, ['products', $productId, 'variants', $variantId]); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function getProductVariantMetafields($productId, $variantId, array $params = []): Collection |
98
|
|
|
{ |
99
|
|
|
return $this->getResources('metafields', $params, ['products', $productId, 'variants', $variantId]); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function createDraftOrderMetafield($orderId, array $data): MetafieldResource |
103
|
|
|
{ |
104
|
|
|
return $this->createResource('metafields', $data, ['draft_orders', $orderId]); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function getDraftOrderMetafieldsCount($orderId, array $params = []): int |
108
|
|
|
{ |
109
|
|
|
return $this->getResourceCount('metafields', $params, ['draft_orders', $orderId]); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function getDraftOrderMetafields($orderId, array $params = []): Collection |
113
|
|
|
{ |
114
|
|
|
return $this->getResources('metafields', $params, ['draft_orders', $orderId]); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function createOrderMetafield($orderId, array $data): MetafieldResource |
118
|
|
|
{ |
119
|
|
|
return $this->createResource('metafields', $data, ['orders', $orderId]); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function getOrderMetafieldsCount($orderId, array $params = []): int |
123
|
|
|
{ |
124
|
|
|
return $this->getResourceCount('metafields', $params, ['orders', $orderId]); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
public function getOrderMetafields($orderId, array $params = []): Collection |
128
|
|
|
{ |
129
|
|
|
return $this->getResources('metafields', $params, ['orders', $orderId]); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
public function createCollectionMetafield($collectionId, array $data): MetafieldResource |
133
|
|
|
{ |
134
|
|
|
return $this->createResource('metafields', $data, ['collections', $collectionId]); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
public function getCollectionMetafieldsCount($collectionId, array $params = []): int |
138
|
|
|
{ |
139
|
|
|
return $this->getResourceCount('metafields', $params, ['collections', $collectionId]); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
public function getCollectionMetafields($collectionId, array $params = []): Collection |
143
|
|
|
{ |
144
|
|
|
return $this->getResources('metafields', $params, ['collections', $collectionId]); |
145
|
|
|
} |
146
|
|
|
} |
147
|
|
|
|