-
Notifications
You must be signed in to change notification settings - Fork 182
Expand file tree
/
Copy pathRule.php
More file actions
44 lines (37 loc) · 1002 Bytes
/
Rule.php
File metadata and controls
44 lines (37 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace Bigcommerce\Api\Resources;
use Bigcommerce\Api\Resource;
use Bigcommerce\Api\Client;
/**
* A product option rule.
*/
class Rule extends Resource
{
protected $ignoreOnCreate = array(
'id',
'product_id',
);
protected $ignoreOnUpdate = array(
'id',
'product_id',
);
public function conditions()
{
$conditions = array();
if (!isset($this->fields->conditions)) {
return $conditions;
}
foreach ($this->fields->conditions as $condition) {
$conditions[] = new RuleCondition((object)$condition);
}
return $conditions;
}
public function create()
{
return Client::createResource('/products/' . $this->fields->product_id . '/rules', $this->getCreateFields());
}
public function update()
{
Client::updateResource('/products/' . $this->fields->product_id . '/rules/' . $this->fields->id, $this->getUpdateFields());
}
}