cocodeluxe Posted August 5, 2014 Share Posted August 5, 2014 Hi and thanks for the support I want to create a variable with the vat number so when a customer has validated vat number will appear a tax free message in his account I created the variable in FrontController $context = Context::getContext(); $customer = $context->customer; $id_customer = $customer->id; $vat_number = Db::getInstance()->executeS("SELECT " ._DB_PREFIX_. "address.vat_number FROM " ._DB_PREFIX_. "address WHERE " ._DB_PREFIX_. "address.id_customer = '$id_customer'"); $this->context->smarty->assign(array( 'vat_number' => $vat_number, )); Works ok but show an array with 2 results, the number an other empty Smarty_Variable Object (3) ->value = Array (2) 0 => Array (1) vat_number => "" 1 => Array (1) vat_number => "SE663000019501" ->nocache = false Why can I do to leave only the number result ? Thanks Link to comment Share on other sites More sharing options...
PascalVG Posted August 5, 2014 Share Posted August 5, 2014 Are there really two rows in your database table ps_address of that customer? You could just add a test to check if the vat_number not empty: AND vat_number != "" or so, My 2 cents, pascal. Link to comment Share on other sites More sharing options...
cocodeluxe Posted August 5, 2014 Author Share Posted August 5, 2014 Thanks Pascal Yes two rows in this query Smarty_Variable Object (3) ->value = Array (2) 0 => Array (1) vat_number => "" 1 => Array (1) vat_number => "SE663000019501" ->nocache = false one empty and other with the vat number How can I text it in the query in this way ¿? $context = Context::getContext(); $customer = $context->customer; $id_customer = $customer->id; $vat_number = Db::getInstance()->executeS("SELECT " ._DB_PREFIX_. "address.vat_number FROM " ._DB_PREFIX_. "address WHERE " ._DB_PREFIX_. "address.id_customer = '$id_customer' AND .vat_number != "" "); $this->context->smarty->assign(array( 'vat_number' => $vat_number, )); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now