Jump to content

Change an Address Alias Field From Text Input to Checkbox


Recommended Posts

Hi there,

 

I was wondering if someone with more technical knowledge can help me out. I'd like to switch the following field in the address page:

 

 

Please assign an address title for future reference. *

 

 

I'd like to change it from a text input field to a checkbox field with two unchecked boxes, whereby the customer can only choose "home" or "business" (obviously not both). I was altering address.tpl in my theme but I couldn't quite get it working correctly so I was hoping someone with experience could share their knowledge. 

 

Thank you in advance!

Link to comment
Share on other sites

Completely untested.

This should give the options Home and Business. With both label and value translatable.

<!--<label for="alias">{l s='Please assign an address title for future reference.'} <sup>*</sup></label>-->
<!--<input type="text" id="alias" class="is_required validate form-control" data-validate="{$address_validation.alias.validate}" name="alias" value="{if isset($smarty.post.alias)}{$smarty.post.alias}{elseif isset($address->alias)}{$address->alias|escape:'html':'UTF-8'}{elseif !$select_address}{l s='My address'}{/if}" />-->
<span>{l s='Please assign an address title for future reference.'} <sup>*</sup></span>
<label for="alias_home"> {l s='Home'}</label>
<input type="radio" id="alias_home" class="is_required validate form-control" data-validate="{$address_validation.alias.validate}" name="alias" value="{l s='Home'}" />
<label for="alias_business"> {l s='Business'}</label>
<input type="radio" id="alias_business" class="is_required validate form-control" data-validate="{$address_validation.alias.validate}" name="alias" value="{l s='Business'}" />
Edited by PhpMadman (see edit history)
  • Like 1
Link to comment
Share on other sites

Slightly more tested then the other code.

Old code did not select Home / Business when modifying an address.

Tested on English only, don't know if translated works.

            <!--<label for="alias">{l s='Please assign an address title for future reference.'} <sup>*</sup></label>-->
            <!--<input type="text" id="alias" class="is_required validate form-control" data-validate="{$address_validation.alias.validate}" name="alias" value="{if isset($smarty.post.alias)}{$smarty.post.alias}{elseif isset($address->alias)}{$address->alias|escape:'html':'UTF-8'}{elseif !$select_address}{l s='My address'}{/if}" />-->
            {if isset($smarty.post.alias)} {assign var="alias_var" value=$smarty.post.alias}
            {elseif isset($address->alias)} {assign var="alias_var" value={$address->alias|escape:'html':'UTF-8'[spam-filter]
            {/if}
            {assign var="alias_home" value={l s='Home'[spam-filter]
            {assign var="alias_business" value={l s='Business'[spam-filter]
            <span>{l s='Please assign an address title for future reference.'} <sup>*</sup></span><br>
            <label for="alias_home"> {l s='Home'}</label>
            <input type="radio" id="alias_home" class="is_required validate form-control" data-validate="{$address_validation.alias.validate}" name="alias" {if $alias_var == $alias_home} checked="checked" {/if} value="{l s='Home'}" />
            <label for="alias_business"> {l s='Business'}</label>
            <input type="radio" id="alias_business" class="is_required validate form-control" data-validate="{$address_validation.alias.validate}" name="alias" {if $alias_var == $alias_business} checked="checked" {/if} value="{l s='Business'}" />

If modifying an old address, saved under an alternate name. Customer's might still save it without setting Home / Business

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...