I was getting the following error when using {exp:cartthrob_multi_location:price entry_id=”{entry_id}”}
Fatal error: Call to undefined method Api_cartthrob_tax_plugins::get_tax() in ./expressionengine/third_party/cartthrob_multi_location/mod.cartthrob_multi_location.php on line 51
I could not find get_tax() in the ‘api/api_cartthrob_tax_plugins’ not sure if anyone else is having this issues but here is what I did to fix it
modify ./expressionengine/third_party/cartthrob_multi_location/mod.cartthrob_multi_location.php price() function (Starts at line 39)
First comment out the following, we will not be using the ‘api/api_cartthrob_tax_plugins’ (Line 43)
//$this->EE->load->library('api/api_cartthrob_tax_plugins');
Next at line 51 and line 66 comment out the following
//$price_plus_tax = $product['price'] + $this->EE->api_cartthrob_tax_plugins->get_tax($product['price']);
and underneath them add the following
$plugin = $this->EE->cartthrob->store->plugin($this->EE->cartthrob->store->config('tax_plugin'));
$price_plus_tax = $product['price'] + $plugin->get_tax($price);
all said and done your price function should look like this
public function price()
{
$this->EE->load->library('number');
$this->EE->load->model('product_model');
//$this->EE->load->library('api/api_cartthrob_tax_plugins');
$price = 0;
$price_plus_tax = 0;
if ($this->EE->TMPL->fetch_param('entry_id'))
{
$product = $this->EE->product_model->get_product($this->EE->TMPL->fetch_param('entry_id'));
$price = $this->EE->number->format( $product['price'] );
//$price_plus_tax = $product['price'] + $this->EE->api_cartthrob_tax_plugins->get_tax($product['price']);
$plugin = $this->EE->cartthrob->store->plugin($this->EE->cartthrob->store->config('tax_plugin'));
$price_plus_tax = $product['price'] + $plugin->get_tax($price);
if (isset($this->EE->TMPL->tagparts[2]) && $this->EE->TMPL->tagparts[2] === 'plus_tax')
{
return $this->EE->number->format( $price_plus_tax );
}
if (isset($this->EE->TMPL->tagparts[2]) && $this->EE->TMPL->tagparts[2] === 'plus_tax_numeric')
{
return $price_plus_tax;
}
}
if ($item = $this->EE->cartthrob->cart->item($this->EE->TMPL->fetch_param('row_id')))
{
$price =$item->price();
//$price_plus_tax = $price + $this->EE->api_cartthrob_tax_plugins->get_tax($price, $item);
$plugin = $this->EE->cartthrob->store->plugin($this->EE->cartthrob->store->config('tax_plugin'));
$price_plus_tax = $product['price'] + $plugin->get_tax($price);
if (isset($this->EE->TMPL->tagparts[2]) && $this->EE->TMPL->tagparts[2] === 'plus_tax')
{
return $this->EE->number->format( $price_plus_tax );
}
if (isset($this->EE->TMPL->tagparts[2]) && $this->EE->TMPL->tagparts[2] === 'plus_tax_numeric')
{
return $price_plus_tax;
}
}
if (isset($this->EE->TMPL->tagparts[2]) && $this->EE->TMPL->tagparts[2] === 'numeric')
{
return $price;
}
return $this->EE->number->format( $price);
}
NOTE: I do not use taxes so please make sure that this does not mess up your tax rates…