Jump to content
REDOUANE

Default country Session

Recommended Posts

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 by REDOUANE

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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 ?

Capture d’écran 2021-05-05 à 16.31.28.png

Edited by REDOUANE
clarify

Share this post


Link to post
Share on other sites
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 ?

Share this post


Link to post
Share on other sites
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....

  1. 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.
  2. 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.

Share this post


Link to post
Share on other sites

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);
}
 

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
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