For some reason, certain products in both of my test stores come back missing some config values. I have to cast these three values as bool in order to ensure that null values are interpreted as false.
public function __construct(?stdClass $optionObject = null)
{
if (
!is_null($optionObject) && !empty($optionObject->config)
&& get_class($optionObject->config) !== ProductModifierConfig::class
) {
error_log('config='.json_encode($optionObject->config));
$this->config = new ProductModifierConfig(
(bool)$optionObject->config->product_list_adjusts_inventory,
(bool)$optionObject->config->product_list_adjusts_pricing,
(bool)$optionObject->config->product_list_shipping_calc
);
}
if (!is_null($optionObject) && isset($optionObject->config)) {
unset($optionObject->config);
}
if (!is_null($optionObject) && isset($optionObject->option_values)) {
$this->option_values = array_map(function ($v) {
return ProductModifierValue::buildFromResponse($v);
}, $optionObject->option_values);
unset($optionObject->option_values);
}
parent::__construct($optionObject);
}
Here are a few examples of the configs I get back:
For some reason, certain products in both of my test stores come back missing some config values. I have to cast these three values as bool in order to ensure that null values are interpreted as false.
Here are a few examples of the configs I get back: