Jump to content
gusman126

Problem with taxes, does not associate country. Bug prestashop? V. 1.7.4.2

Recommended Posts

Problem with taxes, does not associate country

Prestashop version 1.7.4.2


Hello everyone, I am developing a module.

This module reads the product taxes

$product = new Product($id_product);
$id_group= $product->id_tax_rules_group;
$taxes = TaxRule::getTaxRulesByGroupId($id_lang, $id_group);



Check the country and choose the tax for that country

foreach($taxes as $taxs){
	if($taxs["country_name"] == 'spain' or $taxs["country_name"] == 'españa'){
		$tax = ($taxs['rate'] /100) + 1;
	}else{
		$tax = 1;
	}
}

The problem is that in the information read, it is always null in the country field

var_dump($taxes);

[0]=>
  array(10) {
    ["id_tax_rule"]=>
    string(3) "270"
    ["country_name"]=>
    NULL
    ["state_name"]=>
    NULL
    ["rate"]=>
    string(6) "21.000"
    ["zipcode_from"]=>
    string(1) "0"
    ["zipcode_to"]=>
    string(1) "0"
    ["description"]=>
    string(0) ""
    ["behavior"]=>
    string(1) "0"
    ["id_country"]=>
    string(2) "36"
    ["id_state"]=>
    string(1) "0"
  }
  [1]=>
  array(10) {
    ["id_tax_rule"]=>
    string(3) "249"
    ["country_name"]=>
    NULL
    ["state_name"]=>
    NULL
    ["rate"]=>
    string(6) "21.000"
    ["zipcode_from"]=>
    string(1) "0"
    ["zipcode_to"]=>
    string(1) "0"
    ["description"]=>
    string(0) ""
    ["behavior"]=>
    string(1) "0"
    ["id_country"]=>
    string(1) "3"
    ["id_state"]=>
    string(1) "0"
  }
......

 

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More