无法在 SFCC Demandware 中保存用户选择的选项列表值

问题描述 投票:0回答:2

我在标准“个人资料”对象中创建了一个新属性(favouriteStore - 字符串数据类型的枚举),并将其添加到店面的帐户创建页面。现在,我无法将用户选择的选项列表值从 ISML 获取到 js。我尝试了下面的代码,它返回未定义。你能帮我解决这个问题吗?

以下是 isml 代码:registerForm.isml

 <div class="form-group
        <isif condition=" ${!!pdict.profileForm.customer.favouriteStore.mandatory === true}">required</isif>">

        <label class="form-control-label" for="registration-form-favouriteStore">
            <isprint value="${pdict.profileForm.customer.favouriteStore.label}" encoding="htmlcontent" />
        </label>
        <div class="info-icon">
            <span><i class="fa fa-info-circle beet-color" aria-hidden="true"></i></span>
            <span class="tooltip account-tooltip d-none">Pick your favourite store</span>
        </div>
        <select class="custom-select form-control" id="favouriteStore" onchange="getSelected(this)" name="favouriteStore">
        <isloop items=${pdict.profileForm.customer.favouriteStore.options} var="store">
            <option id="${store.id}" value="${store.htmlValue}" 
            <isif condition="${store.selected}">selected</isif> >${store.label}</option>
        </isloop>
        </select>
    </div>

Js代码:Account.js

var registrationFormObj = {
            firstName: registrationForm.customer.firstname.value,
            lastName: registrationForm.customer.lastname.value,
            phone: registrationForm.customer.phone.value,
            email: registrationForm.customer.email.value,
            emailConfirm: registrationForm.customer.emailconfirm.value,
            password: registrationForm.login.password.value,
            passwordConfirm: registrationForm.login.passwordconfirm.value,
            customerPostcode: registrationForm.customer.customerPostcode.value,
            favouriteStore: registrationForm.customer.favouriteStore.value,
            marketingPreferences: registrationForm.customer.marketingPreferences.value,
            validForm: registrationForm.valid,
            form: registrationForm
        };

配置文件.xml:

<field formid="favouriteStore" label="Favourite Store" type="string" mandatory="true" binding="favouriteStore">
            <options>
                <option optionid="" label="" value=""/>
                <option optionid="1" label="Shell Kingsburn, Borough of Royal Kensington, London EC2 3AH" value="Shell Kingsburn Borough of Royal Kensington, London EC2 3AH"/>
                <option optionid="2" label="Chealsea, City Road, London EC2 9AW" value="Chealsea, City Road, London EC2 9AW"/>
                <option optionid="3" label="London Store, 2nd Street, London  EC2 9AW" value="London Store, 2nd Street, London  EC2 9AW"/>
            </options>
            </field>

所有其他字符串字段都已保存,只有这个 favouriteStore 选择列表字段返回未定义。你能指导我哪里出错了吗?

提前致谢!

salesforce picklist demandware isml
2个回答
0
投票

正如AlBlue提到的,问题似乎是你在ISML和DWScript中没有以同样的方式拼写

favouriteStore
。 (JavaScript)

也就是说,您应该确保还为该字段定义了表单 XML。例如,您应该将其添加到店面墨盒的

cartridge/forms/default/profile.xml
文件中。 (或覆盖
app_storefront_base
中的那个)


0
投票

你好,Sri @Pavithra Chellamuthu,我面临着和你一样的问题。您能告诉我您对 isml 文件到底做了什么吗?谢谢你的帮助

© www.soinside.com 2019 - 2024. All rights reserved.