Jump to content

Get additional field value - domain


Nordicway

Recommended Posts

Hi

I use additionalfields.php to retrieve the VAT ID value that is required for danish domains. This adds an extra step in the order proces. That is fine. I need to be able to retrieve the value from this additional field in the checkout.tpl. Is that possible?

I need the value of this field on checkout.tpl:

$additionaldomainfields[".dk"][] = array(
        "Name" => "Virksomhedens CVR nummer",
        "Type" => "text",
        "Required" => false,
        "Ispapi-Name" => "X-REGISTRANT-VATID",
);

Reason: When a customer chooses not to fill out field above they are considered as a private client (not business client). However, on the checkout page  there is a "Company" field and at VAT ID field. If the company field is filled out Hexonet will consider it to be a business client and then fails the registration as they are missing the VAT ID number from our additional fields.

With the value on checkout.tpl I have the possibility to disable those fields if VAT ID have not been filled out in the earlier step. And by that avoid registrations that fails at Hexonet.

Please help - hope for some knowledge on this area.

{debug} on the checkout.tpl does not provide information from additional fields.

Kind regards,

Michael

 

Link to comment
Share on other sites

20 hours ago, Nordicway said:

I use additionalfields.php to retrieve the VAT ID value that is required for danish domains. This adds an extra step in the order proces. That is fine. I need to be able to retrieve the value from this additional field in the checkout.tpl. Is that possible?

yes.

20 hours ago, Nordicway said:

{debug} on the checkout.tpl does not provide information from additional fields.

+1 plaudits for even looking in the debug window to see if the value is easily available.

by the time you reach checkout, nothing will have been written to the database yet (so that's not an option); your use of the debug window has ruled out the value being available to you in Smarty... so third option is to check the session - and you should find that if the field has been completed, it's value will be available in there.

for example, {$smarty.session.cart.domains} should contain an array of domains in the cart...

Array
(
    [0] => Array
        (
            [type] => register
            [domain] => hgfghfhgfghff.dk
            [regperiod] => 1
            [isPremium] => 
            [dnsmanagement] => 
            [emailforwarding] => 
            [idprotection] => 
            [eppcode] => 
            [fields] => Array
                (
                    [0] => 123456
                    [1] => 
                    [2] => 
                    [3] => 
                )

        )

    [1] => Array
        (
            [type] => register
            [domain] => hgjhgjhgjhg.dk
            [regperiod] => 1
            [isPremium] => 
            [dnsmanagement] => 
            [emailforwarding] => 
            [idprotection] => 
            [eppcode] => 
            [fields] => Array
                (
                    [0] => 654321
                    [1] => 
                    [2] => 
                    [3] => 
                )

        )

)

inside each, should be a "fields" array - if additional fields where shown during ordering, then the array should exist - it will exist but the subvalues will be empty if nothing was entered (e.g no required fields); if it were a TLD with no additional fields, then the fields key will exist, but it won't be an array.... their order in the fields array will be determined by the order they are shown in during the configure domains stage of ordering.

so for example, if the cart only contained one domain and you wanted to see if it was a .dk domain and this VAT ID field was completed (and you were doing this in the template)...

{if ($smarty.session.cart.domains.0.domain|substr:-3 == ".dk") && !empty($smarty.session.cart.domains.0.fields.0)}VAT ID Field Completed{/if}

in practice, you will have to assume that there is more than one domain in the cart and loop through this session domains array to see if there are any .dk domains with field X completed... if so, then you hide/disable VAT fields or whatever.

looking at your site, I see you have a dropdown additional field for private/business - that value should be available to you in the session domains array at the checkout stage too.

Link to comment
Share on other sites

Fantastic. Thanks for a very good reply. This solved my problem.

The final solution was this:

{if empty($smarty.session.cart.domains.0.fields.1)}
<style>
{literal}
#inputCompanyName, #inputTaxId, label[for=inputCompanyName], label[for=inputTaxId] {display:none !important;}
{/literal}
</style>
{/if}

Now customers can not fill out the VAT ID og Company Name fields on checkout if they did not fill out a VAT ID in the earlier stage.

Thanks again!

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • 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