Jump to content

Unable to force default invoicing currency on checkout page


Recommended Posts

Hi,

On our platform we have the pricing in a certain currency, but on the checkout page, if the client is not registered yet in our system, we want to force the currency to be changed to another one in which we normally invoice products and we did that in older versions of WHMCS by only letting the client select the invoicing currency from the dropdown on the registration form by hiding the other currency. In the earlier versions of WHMCS I used a similar code like the one below from a post from the WHMCS community on the register and the checkout page (if the client would register on that page) to hide a currency and only let the clients choose a certain currency for invoicing, but in the 21 version in the child theme I can't seem to get it to work (I also tried in the parent theme and it didn't show up there either), but only in the checkout.tpl. In the normal register.tpl page it works with the first code below, which I used in the earlier versions of WHMCS. I tried putting the code where the custom fields show up on the page, at the top of the page, outside "if's" etc. but to no avail... The field won't show up whatever I try. I also cleared the template cache multiple times, but I don't know what I'm doing wrong. For example I'd want EUR as the only available option on the checkout registration page and these are two versions of the code that I used:

{if $currencies}
	<div class="col-sm-6">
		<label for="inputCurrency">Choose currency</label>
		<div class="form-group prepend-icon">
			<label for="inputCurrency" class="field-icon">
				<i class="far fa-money-bill-alt"></i>
			</label>
			<select id="inputCurrency" name="currency" class="field form-control">
				{foreach $currencies as $curr}
					{if $curr.code eq 'EUR'}
						<option value="{$curr.id}"{if !$smarty.post.currency && $curr.default || $smarty.post.currency eq $curr.id } selected{/if}>{$curr.code}</option>
					{/if}
				{/foreach}
			</select>
		</div>
	</div>
{/if}

 

 

                                {if !$loggedin && $currencies}  // I also tried without !@loggedin
                                <div class="pull-right form-inline float-right">
                                    <label for="inputCurrency" class="field-icon">
                                        <i class="far fa-money-bill-alt"></i>
                                    </label>
                                    <select name="currency" id="inputCurrency" class="field form-control">
                                        <option value="">{$LANG.choosecurrency}</option>
                                        {foreach from=$currencies item=listcurr}
                                            {if $listcurr.code eq 'EUR'}
                                                <option value="{$listcurr.id}"{if $listcurr.id == $currency.id} selected{/if}>{$listcurr.code}</option>
                                            {/if}
                                        {/foreach}
                                    </select>
                                </div>
                                {/if}

 

Any ideas what I'm doing wrong/why it isn't working?

Thank you

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated