Nordicway Posted September 27, 2019 Share Posted September 27, 2019 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 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 28, 2019 Share Posted September 28, 2019 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. 0 Quote Link to comment Share on other sites More sharing options...
Nordicway Posted September 28, 2019 Author Share Posted September 28, 2019 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! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.