diff --git a/src/BigCommerce/ResourceModels/Catalog/Product/PriceAdjuster.php b/src/BigCommerce/ResourceModels/Catalog/Product/PriceAdjuster.php index c97ed1b..0bc6d9b 100644 --- a/src/BigCommerce/ResourceModels/Catalog/Product/PriceAdjuster.php +++ b/src/BigCommerce/ResourceModels/Catalog/Product/PriceAdjuster.php @@ -9,6 +9,6 @@ class PriceAdjuster extends ResourceModel public const ADJUSTER_RELATIVE = 'relative'; public const ADJUSTER_FIXED = 'fixed'; - public string $adjuster; + public string $adjuster = self::ADJUSTER_FIXED; public float $adjuster_value; } diff --git a/src/BigCommerce/ResourceModels/Catalog/Product/WeightAdjuster.php b/src/BigCommerce/ResourceModels/Catalog/Product/WeightAdjuster.php index 26a2112..6f98ad1 100644 --- a/src/BigCommerce/ResourceModels/Catalog/Product/WeightAdjuster.php +++ b/src/BigCommerce/ResourceModels/Catalog/Product/WeightAdjuster.php @@ -6,6 +6,9 @@ class WeightAdjuster extends ResourceModel { - public string $adjuster; + public const ADJUSTER_RELATIVE = 'relative'; + public const ADJUSTER_FIXED = 'fixed'; + + public string $adjuster = self::ADJUSTER_FIXED; public float $adjuster_value; } diff --git a/tests/BigCommerce/Api/Catalog/Products/ProductModifier/ProductModifierValuesApiTest.php b/tests/BigCommerce/Api/Catalog/Products/ProductModifier/ProductModifierValuesApiTest.php index b98e09c..5cd3b49 100644 --- a/tests/BigCommerce/Api/Catalog/Products/ProductModifier/ProductModifierValuesApiTest.php +++ b/tests/BigCommerce/Api/Catalog/Products/ProductModifier/ProductModifierValuesApiTest.php @@ -2,6 +2,8 @@ namespace BigCommerce\Tests\Api\Catalog\Products\ProductModifier; +use BigCommerce\ApiV3\ResourceModels\Catalog\Product\PriceAdjuster; +use BigCommerce\ApiV3\ResourceModels\Catalog\Product\ProductModifier; use BigCommerce\ApiV3\ResourceModels\Catalog\Product\ProductModifierValueData; use BigCommerce\Tests\BigCommerceApiTest; @@ -68,4 +70,24 @@ public function testCanUpdateModifierValue() $this->assertJsonStringEqualsJsonString($expectedJson, json_encode($modifierValue)); } + + public function testCanSetDefaultAdjusterType() + { + $adjuster = new PriceAdjuster(); + $this->assertEquals(PriceAdjuster::ADJUSTER_FIXED, $adjuster->adjuster); + + $this->setReturnData('catalog__products__modifiers__222__values__190__get.json'); + + $modifierValue = $this->getApi() + ->catalog()->product(1)->modifier(222)->value(190)->get()->getModifierValue(); + + $this->assertEquals(PriceAdjuster::ADJUSTER_RELATIVE, $modifierValue->adjusters->price->adjuster); + + $this->setReturnData('catalog__products__modifiers__222__values__190__get-no-adjuster.json'); + + $modifierValue = $this->getApi() + ->catalog()->product(1)->modifier(222)->value(190)->get()->getModifierValue(); + + $this->assertEquals(PriceAdjuster::ADJUSTER_FIXED, $modifierValue->adjusters->price->adjuster); + } }