Jump to content

After Direct Shopping Cart Link - domain lookup WITHOUT TLD dropdown list?


onliner

Recommended Posts

Hello,

When I use Direct Shopping Cart Link to a product in the cart, ie.  

 

https://www.domainx.nets/cart.php?a=add&pid=1&billingcycle=annually&skipconfig=1¤cy=2&language=Spanish

 

then WHMCS works as it should, no problem with that.

But after clicking on such link, I want the user to be presented with a domain lookup WITHOUT TLD drop-down list. Just the one as presented at WHMCS 'Home - index.php'

In other words, the same one you're getting when clicking on:

 

https://www.somedomainxxx.nets/cart.php?a=add&domain=register

 

The problem is that there's' several hundred of TLD extensions, so using the TLD drop down confuses customers, especially if they are not sorted alphabetically. Therefore I need the plain domain lookup form. 

Possible with some hook or similar?

Any help will be highly appreciated!

Thanks.

 

 

 

dlookup.PNG

Link to comment
Share on other sites

4 hours ago, onliner said:

But after clicking on such link, I want the user to be presented with a domain lookup WITHOUT TLD drop-down list. Just the one as presented at WHMCS 'Home - index.php'

The problem is that there's' several hundred of TLD extensions, so using the TLD drop down confuses customers, especially if they are not sorted alphabetically.

then sort them if that helps...

... though i've never a big fan of alphabetical sorting of TLDs, not least because from a British point of view, .co.uk and .uk would be at opposite ends of the list.

4 hours ago, onliner said:

Possible with some hook or similar?

it definitely won't be a hook, at least not primarily, because you're altering the design and you can't alter a design with just hooks (unless the template has been designed in such a way to allow it).

the problem you have is that the form is expecting SLD & TLD separately (I think it always has done since i've been using WHMCS)... not least because that's what the .js now wants... I suppose you could rewrite that in the .js and alter the form accordingly (e.g just one text box) and that might work... but that's likely going to mean editing both the template(s) and the scripts.min.js file.

perhaps a simpler way (can you tell it's Friday and i've got a lot to do! lol) is to still have two fields, but just replace the dropdown with another text field, e.g change...

<div class="col-xs-3">
	<select id="registertld" class="form-control">
	{foreach from=$registertlds item=listtld}
		<option value="{$listtld}"{if $listtld eq $tld} selected="selected"{/if}>{$listtld}</option>
	{/foreach}
	</select>
</div>

to...

<div class="col-xs-3">
	<input type="text" id="registertld" value="{$tld}" class="form-control" autocapitalize="none" />
</div>

IrcEgMK.png

quickly tested as working in v7.4.2 - it should probably work for transfers too.

HiezHqc.png

I think there are potentially valid reasons for keeping it as a dropdown, but I guess if there are hundreds of TLDs in a seemingly random order, then it might get confusing for the user.

Link to comment
Share on other sites

6 hours ago, brian! said:

it definitely won't be a hook, at least not primarily, because you're altering the design and you can't alter a design with just hooks (unless the template has been designed in such a way to allow it).

Yes, sure, the wrong assumption from my side, unnecessary to complicate things.

 

6 hours ago, brian! said:

perhaps a simpler way (can you tell it's Friday and i've got a lot to do! lol) is to still have two fields, but just replace the dropdown with another text field, e.g change...


<div class="col-xs-3">
	<select id="registertld" class="form-control">
	{foreach from=$registertlds item=listtld}
		<option value="{$listtld}"{if $listtld eq $tld} selected="selected"{/if}>{$listtld}</option>
	{/foreach}
	</select>
</div>

to...


<div class="col-xs-3">
	<input type="text" id="registertld" value="{$tld}" class="form-control" autocapitalize="none" />
</div>

Work like a charm! You've nailed it at first attempt. Just wondering IF it will be possible to make it appear without 2 fields? At least for domain registrations if nothing else.

Thanks again for helping me out, hope that some other user will found this topic helpful as well.

 

Link to comment
Share on other sites

13 hours ago, onliner said:

Just wondering IF it will be possible to make it appear without 2 fields? At least for domain registrations if nothing else.

anything is possible...

vwiBWLe.png

                    {if $registerdomainenabled}
                        <div class="option">
                            <label>
                                <input type="radio" name="domainoption" value="register" id="selregister"{if $domainoption eq "register"} checked{/if} />{$LANG.cartregisterdomainchoice|sprintf2:$companyname}
                            </label>
                            <div class="domain-input-group clearfix" id="domainregister">
                                <div class="row">
                                    <div class="col-sm-8 col-sm-offset-1">
                                        <div class="row domains-row">
                                            <div class="col-xs-12">
                                                <div class="input-group">
                                                    <span class="input-group-addon">{$LANG.orderForm.www}</span>
                                                    <input type="text" id="registersld" value="{$sld}" class="form-control" autocapitalize="none" data-toggle="tooltip" data-placement="top" data-trigger="manual" title="{lang key='orderForm.enterDomain'}" />
                                                    <input type="hidden" id="registertld" value="com" class="form-control" />
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-2">
                                        <button type="submit" class="btn btn-primary btn-block">
                                            {$LANG.orderForm.check}
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    {/if}

that's the configureproductdomain.tpl template changed, but it isn't enough.... you need to alter the js - i'll tell you how to do it, and i'll include a modified /templates/orderforms/standard_cart/js/scripts.min.js to download... but you're probably going to have to do this after every WHMCS update.

so in scripts.js (not used by WHMCS, but easier to read), you just change domain: sld + tld to just domain: sld (~line 1388)...

        if (domainoption == 'register') {
            jQuery('.suggested-domains').hide().removeClass('hidden').fadeIn('fast');
            spotlightTlds.hide().removeClass('hidden').fadeIn('fast');
            jQuery('#resultDomainOption').val(domainoption);
            var lookup = jQuery.post(
                    'cart.php',
                    {
                        token: csrfToken,
                        a: 'checkDomain',
                        type: 'domain',
                        domain: sld
                    },
                    'json'
                ),
                spotlight = jQuery.post(
                    'cart.php',
                    {
                        token: csrfToken,
                        a: 'checkDomain',
                        type: 'spotlight',
                        domain: sld
                    },
                    'json'
                ),
                suggestion = jQuery.post(
                    'cart.php',
                    {
                        token: csrfToken,
                        a: 'checkDomain',
                        type: 'suggestions',
                        domain: sld
                    },
                    'json'
                );

and then you minify it and replace the existing /templates/orderforms/standard_cart/js/scripts.min.js with it.

as you can see from the template code, i'm passing the TLD as a hidden field (currently com, but could be anything - it won't be used)... if a user doesn't enter a TLD, then it won't use com (necessarily), it will just try the first TLD in your domain pricing with pricing set (in the case of my v7.4.2 dev, it's .co.uk)...

uK60Vxf.png

 

 

scripts.min.js

Link to comment
Share on other sites

  • 1 month later...
On 2018-03-24 at 1:17 PM, brian! said:

anything is possible...

vwiBWLe.png


                    {if $registerdomainenabled}
                        <div class="option">
                            <label>
                                <input type="radio" name="domainoption" value="register" id="selregister"{if $domainoption eq "register"} checked{/if} />{$LANG.cartregisterdomainchoice|sprintf2:$companyname}
                            </label>
                            <div class="domain-input-group clearfix" id="domainregister">
                                <div class="row">
                                    <div class="col-sm-8 col-sm-offset-1">
                                        <div class="row domains-row">
                                            <div class="col-xs-12">
                                                <div class="input-group">
                                                    <span class="input-group-addon">{$LANG.orderForm.www}</span>
                                                    <input type="text" id="registersld" value="{$sld}" class="form-control" autocapitalize="none" data-toggle="tooltip" data-placement="top" data-trigger="manual" title="{lang key='orderForm.enterDomain'}" />
                                                    <input type="hidden" id="registertld" value="com" class="form-control" />
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-2">
                                        <button type="submit" class="btn btn-primary btn-block">
                                            {$LANG.orderForm.check}
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    {/if}

that's the configureproductdomain.tpl template changed, but it isn't enough.... you need to alter the js - i'll tell you how to do it, and i'll include a modified /templates/orderforms/standard_cart/js/scripts.min.js to download... but you're probably going to have to do this after every WHMCS update.

so in scripts.js (not used by WHMCS, but easier to read), you just change domain: sld + tld to just domain: sld (~line 1388)...


        if (domainoption == 'register') {
            jQuery('.suggested-domains').hide().removeClass('hidden').fadeIn('fast');
            spotlightTlds.hide().removeClass('hidden').fadeIn('fast');
            jQuery('#resultDomainOption').val(domainoption);
            var lookup = jQuery.post(
                    'cart.php',
                    {
                        token: csrfToken,
                        a: 'checkDomain',
                        type: 'domain',
                        domain: sld
                    },
                    'json'
                ),
                spotlight = jQuery.post(
                    'cart.php',
                    {
                        token: csrfToken,
                        a: 'checkDomain',
                        type: 'spotlight',
                        domain: sld
                    },
                    'json'
                ),
                suggestion = jQuery.post(
                    'cart.php',
                    {
                        token: csrfToken,
                        a: 'checkDomain',
                        type: 'suggestions',
                        domain: sld
                    },
                    'json'
                );

and then you minify it and replace the existing /templates/orderforms/standard_cart/js/scripts.min.js with it.

as you can see from the template code, i'm passing the TLD as a hidden field (currently com, but could be anything - it won't be used)... if a user doesn't enter a TLD, then it won't use com (necessarily), it will just try the first TLD in your domain pricing with pricing set (in the case of my v7.4.2 dev, it's .co.uk)...

uK60Vxf.png

 

 

scripts.min.js

This works only if NOT adding .TLD extension during the domain search. If adding a domain with TLD, as briansupertest.info - it returns error. Check the attached image.

 

 

notld.PNG

Link to comment
Share on other sites

22 minutes ago, onliner said:

This works only if NOT adding .TLD extension during the domain search. If adding a domain with TLD, as briansupertest.info - it returns error. Check the attached image.

have you updated WHMCS? because my assumption is that scripts.min.js has been updated and my suggested changes to it have been removed...

this is what i'm seeing on v7.5.1 when I make both changes above to the template and the minified .js file...

9B1RiwJ.png

Link to comment
Share on other sites

2 hours ago, brian! said:

have you updated WHMCS? because my assumption is that scripts.min.js has been updated and my suggested changes to it have been removed...

Yes, I have updated to 7.5.1. Are you willing to share your scripts.min.js file please? Btw, I'm using the premium comparison orderform template.

Link to comment
Share on other sites

14 hours ago, onliner said:

Yes, I've updated to 7.5.1, but I've also updated the scripts.min.js to the latest version. There's a several instances of 'domain:' to be replaced, maybe I've missed something.

there's only one block of code that looks like the one I posted previously... if (domainoption == 'register') { ...in /templates/orderforms/standard_cart/js/scripts.js - and in that, there are only 3 lines to change at lines 1473, 1483 & 1492.

14 hours ago, onliner said:

Btw, I'm using the premium comparison orderform template.

that doesn't matter - by the time you get to this stage, you'll be using standard_cart. :idea:

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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