I am trying to get the sku_id from the conditions in a chosen rule on a product.
$conditions = $rule->conditions();
foreach ($conditions as $condition) {
$rule_sku_ids = $condition->condition->sku_id;
}
I seem to get nothing returned from this, not even an error message. Has anyone done this with the API before and can show me if I have gone wrong where.
Finally solved after contacting BigCommerce Support.
There is a bug within the conditions function in Rule.php.
Find this function:
public function conditions()
{
$conditions = Client::getCollection($this->fields->conditions->resource, 'RuleCondition');
foreach ($conditions as $condition) {
$condition->product_id = $this->product_id;
}
return $conditions;
}
and change it to this:
public function conditions()
{
return $this->fields->conditions;
}
This solves the problem.