Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}