Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow nullable variant id in Product Complex Rule Conditions #210

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ class ComplexRuleConditions extends ResourceModel
public int $rule_id;
public int $modifier_id;
public int $modifier_value_id;
public array $variant_id;
public ?int $variant_id;
public int $combination_id;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,13 @@ class PriceAdjuster extends ResourceModel

public string $adjuster;
public float $adjuster_value;

protected function beforeBuildObject(): void
{
if (!is_null($this->optionObject)) {
if(is_null($this->optionObject->adjuster)){
$this->optionObject->adjuster = self::ADJUSTER_FIXED;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this to handle the case of BigCommerce not returning the adjuster property?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this will handle when BigCommerce is not returning adjuster property.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is usally not returning adjuster property when in store front we have fixed type of adjuster.

}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@

class WeightAdjuster extends ResourceModel
{
public const ADJUSTER_RELATIVE = 'relative';
public const ADJUSTER_FIXED = 'fixed';

public string $adjuster;
public float $adjuster_value;

protected function beforeBuildObject(): void
{
if (!is_null($this->optionObject)) {
if(is_null($this->optionObject->adjuster)){
$this->optionObject->adjuster = self::ADJUSTER_FIXED;
}
}
}
}
2 changes: 1 addition & 1 deletion src/BigCommerce/ResourceModels/ResourceModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

abstract class ResourceModel implements JsonSerializable
{
private ?stdClass $optionObject;
protected ?stdClass $optionObject;

public function __construct(?stdClass $optionObject = null)
{
Expand Down