Skip to content

ProductOption

The ProductOption object represents a single option which can be used to specify the product.

classDiagram
  direction LR
  Product --> ProductOptionsList
  ProductOptionsList "1" --o "*" ProductOption
  ProductOption --> Price
  ProductOption --> ProductOptionValuesList
  ProductOption --> ProductOptionValuesWithColorList
  ProductOptionValuesList "1" --o "*" ProductOptionValue
  ProductOptionValuesWithColorList "1" --o "*" ProductOptionValueWithColor
  class Product{
  }
  class ProductOptionsList{
  }
  class ProductOptionValuesList{
  }
  class ProductOptionValuesWithColorList{
  }
  class ProductOptionValue{
  }
  class ProductOptionValueWithColor{
  }
  class ProductOption{
    int id
    int order
    string name
    ?ProductOptionValuesList values
    bool isRequired
    bool isStockOption
    bool isPriceModifier
    bool isPercentagePriceModifier
    ?Price priceModification
    float percentagePriceModification
    string formatPercentagePriceModification
    bool isSelect
    bool isColor
    bool isRadio
    bool isFile
    bool isCheckbox
    bool isText
  }
  class Price{
  }

Properties

Properties

Attribute name Type Description
id int The unique identifier of the option.
order int The order of the option.
name string The name of the option
values null|ProductOptionValuesList Optional reference to the list of possible values to choose from. If the option's type is select or radio it is a reference to the ProductOptionValuesList object that represents the list of ProductOptionValue objects. If the option's type is color it is a reference to the ProductOptionValuesWithColorList object that represents the list of ProductOptionValueWithColor objects. If the option's type is file or checkbox or text it is null.
isRequired bool Whether the option is required.
isStockOption bool Whether the option is used to determine the exact variant of the product.
isPriceModifier bool Whether the option is used to modify the price of the product.
isPercentagePriceModifier bool Whether the option is used to modify the price of the product by a percentage.
priceModification null|Price The price modification of the option represented by a Price Object. If the option is not a price modifier, this property is null.
percentagePriceModification float The percentage price modification of the option. If the option is not a percentage price modifier, this is set to zero (0.00).
formatPercentagePriceModification string The formatted percentage price modification of the option. If the option is not a percentage price modifier, this is set to zero (0.00).
isSelect bool Whether the option's type is select.
isColor bool Whether the option's type is color.
isPattern bool Whether the option's type is pattern.
isRadio bool Whether the option's type is radio.
isFile bool Whether the option's type is file.
isCheckbox bool Whether the option's type is checkbox.
isText bool Whether the option's type is text.

id property

{{ productOption.id }}
1

order property

{{ productOption.order }}
1

name property

{{ productOption.name }}
example name

values property

{{ option.name }}:

{% if option.isRadio %}
<div class="option_radio {% if option.isRequired %}option_required{% endif %}">
    {% for value in option.values %}
        <input type="radio" id="option_{{ option.id }}_{{ value.id }}" name="option_{{ option.id }}" value="{{ value.id }}" {% if option.isStockOption and not value.isAvailable %}data-unavailable{% endif %}/>
        <label for="option_{{ option.id }}_{{ value.id }}">{{ value.name }}</label>
    {% endfor %}
</div>
{% elseif option.isColor %}
<div class="option_color{% if option.isRequired %}option_required{% endif %}">
    <select id="option_{{ option.id }}" name="option_{{ option.id }}">
    {% for value in option.values %}
        <option value="{{ value.id }}" title="{{ value.color }}" {% if option.isStockOption and not value.isAvailable %}data-unavailable{% endif %}>{{ value.name }}</option>
    {% endfor %}
    </select>
</div>
{% elseif option.isSelect %}
<div class="option_select{% if option.isRequired %}option_required{% endif %}">
    <select id="option_{{ option.id }}" name="option_{{ option.id }}">
    {% for value in option.values %}
        <option value="{{ value.id }}" {% if option.isStockOption and not value.isAvailable %}data-unavailable{% endif %}>{{ value.name }}</option>
    {% endfor %}
    </select>
</div>
{% endif %}
example radio:

<div class="option_radio">
    <input type="radio" id="option_1_1" name="option_1" value="1" />
    <label for="option_1_2">example radio 1</label>

    <input type="radio" id="option_1_2" name="option_1" value="2" />
    <label for="option_1_2">example radio 2</label>

    <input type="radio" id="option_1_3" name="option_1" value="3" />
    <label for="option_1_3">example radio 3</label>
</div>

isRequired property

{{ productOption.isRequired }}
true

isStockOption property

{{ productOption.isStockOption }}
true

isPriceModifier property

{{ productOption.isPriceModifier }}
true

isPercentagePriceModifier property

{{ productOption.isPercentagePriceModifier }}
true

priceModification property

{{ productOption.priceModification.formatGross }}
$12.34

percentagePriceModification property

{{ productOption.percentagePriceModification }}
1.53

formatPercentagePriceModification property

{% if option.isPercentagePriceModifier %}
    {{ option.percentagePriceModification }} => {{ option.formatPercentagePriceModification }}
{% endif %} 
10 => 10%

isSelect property

{{ productOption.isSelect }}
true

isColor property

{{ productOption.isColor }}
true

isPattern property

{{ productOption.isPattern }}
true

isRadio property

{{ productOption.isRadio }}
true

isFile property

{{ productOption.isFile }}
true

isCheckbox property

{{ productOption.isCheckbox }}
true

isText property

{{ productOption.isText }}
true