REDOUANE Posted May 4, 2021 Share Posted May 4, 2021 (edited) Hello Guys, I have a question, i am using Multibrand module, so i want to specify for each brand a taxe, so i want if i can set default country for each domain (brand) To clarify things : Default country configured is USA, i am in spain domain brand (using Multibrand module), so the default country doesn't change it still USA (thats make sens of course), so here i want to change the default country session in this brand (domain), can someone help to create a hook to change default country using domain name (brand). thank you Edited May 4, 2021 by REDOUANE 0 Quote Link to comment Share on other sites More sharing options...
REDOUANE Posted May 5, 2021 Author Share Posted May 5, 2021 Can someone pls help me out ? Thank you 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 5, 2021 Share Posted May 5, 2021 2 hours ago, REDOUANE said: Can someone pls help me out ? have you asked MG directly about this ? granted, you may have to sell the family silver to pay for it... 🤑 the default country value is stored in the database tblconfiguration table - so even if you modified the value in the client area / cart on the fly, I don't see that having an impact on the invoices (especially those generated by cron) - really, this will need someone familiar with how multibrand works (hence the obvious ones being MG themselves). 0 Quote Link to comment Share on other sites More sharing options...
REDOUANE Posted May 5, 2021 Author Share Posted May 5, 2021 (edited) 4 minutes ago, brian! said: have you asked MG directly about this ? granted, you may have to sell the family silver to pay for it... 🤑 the default country value is stored in the database tblconfiguration table - so even if you modified the value in the client area / cart on the fly, I don't see that having an impact on the invoices (especially those generated by cron) - really, this will need someone familiar with how multibrand works (hence the obvious ones being MG themselves). yes , so actually i dont need more to change the default country, i see this topic : i need like this one, i need a hook or something else so i can change the $country so the taxes can change is that possible ? Edited May 5, 2021 by REDOUANE clarify 0 Quote Link to comment Share on other sites More sharing options...
REDOUANE Posted May 5, 2021 Author Share Posted May 5, 2021 12 minutes ago, brian! said: have you asked MG directly about this ? granted, you may have to sell the family silver to pay for it... 🤑 the default country value is stored in the database tblconfiguration table - so even if you modified the value in the client area / cart on the fly, I don't see that having an impact on the invoices (especially those generated by cron) - really, this will need someone familiar with how multibrand works (hence the obvious ones being MG themselves). I really need this one pls, can someone help me out ? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 5, 2021 Share Posted May 5, 2021 11 minutes ago, REDOUANE said: i need like this one, i need a hook or something else so i can change the $country so the taxes can change is that possible ? well $defaultcountry is available on viewcart, so that would be a ClientAreaPageCart hook that changes the value of defaultcountry to US or ES - that part is simple, e.g to default it to Spain... <?php function cart_default_country_hook($vars) { if ($vars['templatefile'] == 'viewcart') { return array("defaultcountry" => "ES", "country" => "ES"); } } add_hook("ClientAreaPageCart", 1, "cart_default_country_hook"); that will probably need cleaning up and testing thoroughly but there are then two problems.... i'm not familiar with multibrand - so off-hand I don't know how MB assigns brands or how to detect if the current user is brand A or brand B... I guess it will almost certainly be in a client area variable, or failing that you could probably pull the value from the db. I don't know if the default country / country set in the client area is actually used to generate the invoice or whether it pulls that value from the database - @Kian might know more on that one. 0 Quote Link to comment Share on other sites More sharing options...
REDOUANE Posted May 5, 2021 Author Share Posted May 5, 2021 Hi brian, thanks for your feedback, its not working, it still showed US as default country 0 Quote Link to comment Share on other sites More sharing options...
MrGettingRatherFrustrated Posted May 6, 2021 Share Posted May 6, 2021 This is my hook to force the curency to a different one from the defaut, I dont know if it will do what you want for the country. I dont think the default will change though, but I guess its the active one rather the default that is relevant <?php use WHMCS\Session; // Provide your new default currency ID $currencyId = 9; if (!Session::get('uid') && !Session::get('currency')) { Session::set('currency', $currencyId); } 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 6, 2021 Share Posted May 6, 2021 16 hours ago, REDOUANE said: its not working, it still showed US as default country then it's possible, and I think likely, that because you're using a custom orderform template, the template isn't called viewcart and therefore the hook isn't being triggered - scrolling down that debug window and seeing what the $templatefile value is should tell you if that's the case... or by test switching to standard_cart (where the hook should work without issue)... or by removing the IF conditional statement and just letting it change those variables (I wouldn't do that permanently, just to see if it works). also, you may have to disregard my second point on invoicing - I suspect I was thinking of home countries with regards to VAT etc. 43 minutes ago, MrGettingRatherFrustrated said: This is my hook to force the currency to a different one from the default, I don't know if it will do what you want for the country. it wouldn't work - the session plays no part in this (unless the custom template is doing something unusual). 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted May 8, 2021 Share Posted May 8, 2021 Tax comes from WHMCS default settings on page load. You can't change that by switching country. You have different options. First. You could .click with jQuery the button that updates estimated tax. You will also need to display:none page body before .click fires to avoid visitors seeing the page loading twice. Second. Override tax name, rate and value in Smarty with ClientAreaPage action hook. You need to retrieve such values manually from database based on your brand. It's pretty boring. Third. This is a bit of overkill but you could replace default estimated tax logic with your custom one. It's super boring and depressing. 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.