Skip to content

Commit 31171ef

Browse files
committed
fix(foxy-experimental-add-to-cart-builder): fix undefined appearing as custom option value when freeform input is enabled and no default value is provided
1 parent 66e211c commit 31171ef

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/elements/public/ExperimentalAddToCartBuilder/ExperimentalAddToCartBuilder.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ export class ExperimentalAddToCartBuilder extends Base<Data> {
759759
const optionIndex = product.custom_options.indexOf(group[0]);
760760
const itemCategory = this.__getItemCategoryLoader(productIndex, optionIndex)?.data;
761761
const modifiers = this.__getOptionModifiers(group[0], itemCategory ?? null, currencyCode);
762-
const value = `${group[0].value}${modifiers}`;
762+
const value = `${group[0].value ?? ''}${modifiers}`;
763763
const name = `${prefix}${optionName}`;
764764

765765
if (group[0].value_configurable) {
@@ -790,7 +790,10 @@ export class ExperimentalAddToCartBuilder extends Base<Data> {
790790
const optionIndex = product.custom_options.indexOf(option);
791791
const itemCategory = this.__getItemCategoryLoader(productIndex, optionIndex)?.data;
792792
const modifiers = this.__getOptionModifiers(option, itemCategory ?? null, currencyCode);
793-
const encodedValue = encodeAttributeValue(`${option.value}${modifiers}`, isHmacOn);
793+
const encodedValue = encodeAttributeValue(
794+
`${option.value ?? ''}${modifiers}`,
795+
isHmacOn
796+
);
794797
const encodedCaption = encode(option.value ?? '');
795798
output += `${newline()}<option value="${encodedValue}">${encodedCaption}</option>`;
796799
});

0 commit comments

Comments
 (0)