wtricks Posted November 30, 2020 Share Posted November 30, 2020 I have a cms hosting product. I'm asking my customers (using custom fields) to fill some data (script, username, password, language) of course this is pointless if they are transferring their domain, as there is no need to install the script (and ask for those data) if the client will need to transfer the website. I have this code: add_hook('ClientAreaPageCart', 1, function($vars) { $pids = Array(17085, 17087); if( !empty($vars['customfields']) ) { $key = array_search($vars['domain'], array_column($_SESSION['domain_cart']['domains'], 'domain')); $key2 = array_search($vars['domain'], array_column($_SESSION['domain_cart']['products'], 'domain')); $type = $_SESSION['domain_cart']['domains'][$key]['type']; if ( $type == 'transfer' && in_array($vars['productinfo']['pid'], $pids) ) { foreach ( $vars['customfields'] as $key => $value ) { unset($vars['customfields'][$key]); } } } return $vars; }); it actually works well but has a problem, since the fields are required, you get an error as they are required. At least I got half the job done, I made them disappear ;) I tried this: $vars['customfields'][$key]['required'] = ''; with no success. also set the fileds as not required and then if the domain is not transfer set this: $vars['customfields'][$key]['required'] = '*'; bus seems like the validation is ignoring my hook what can you recommend to hide custom fields if the domain is a transfer? 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.