Assign a specific tax rate to a category

  • Posts: 44
  • Thank you received: 2
7 years 10 months ago #242667

-- url of the page with the problem -- : www.koffiematters.nl
-- HikaShop version -- : 2.6.3

Hi people,

I can't figure it out .. I hope you guys can help me out here :)
What I'd like to achieve is this:
- Assign a taxrate to a category (including the existing products)
- Show "Marge product" under the productprice (instead of incl. VAT)

Thank you very much for thinking with me :)

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
7 years 10 months ago #242684

Hello,
The solution will be to :
- Create another tax category via "Hikashop->System->Taxes->'Manage tax categories'"
- Create a new tax with that tax category and a specific rate via "Hikashop->System->Taxes"
- Edit all the products of your category and set the "Tax category" option of the "Prices and Taxes" tab to the tax category you created.

The following user(s) said Thank You: hielkio

Please Log in or Create an account to join the conversation.

  • Posts: 44
  • Thank you received: 2
7 years 10 months ago #242943

I think I wasn't clear enough, sorry :huh:
The right tax-rate / category was assigned to the products, but ...
I'd like to show the tax description (Incl. TAX or No TAX) under the productprice.



I added a static text "Incl. TAX" in listing_price.php before, but now we've got products that don't have any TAX on it.
Maybe a stupid or simple question / solution, is there a way to echo the TAX description or TAX category what assigned is to the product?

Hope you can help me out :)

Please Log in or Create an account to join the conversation.

  • Posts: 4519
  • Thank you received: 611
  • MODERATOR
7 years 10 months ago #242953

Hello,

You have to add a check in order to only apply your "custom code" on required category product listing.
More precisely, you can get the category Id and only display your required value if this is the wanted categorie Id.
See this code sample :

$YourPrice="YourValue";
        // Check if the categories is setted :
		if (isset($this->row->categories) ) {
				// Read all categories IF the product have several categories setted
                foreach ($this->row->categories as $key => $value) {
					// Required category found, display your price :
					if ($value->category_id == '12' ) 
					$YourPrice="YourValue";
					echo '<span class="hikashop_product_price_with_YOUR_TAX">' . $YourPrice . "</span>";
			}
		}

Hope this will help you.

Regards

Last edit: 7 years 10 months ago by Philip.

Please Log in or Create an account to join the conversation.

  • Posts: 44
  • Thank you received: 2
7 years 6 months ago #250961

It was working before, but now it isn't anymore :unsure:

This is the code I used:

$displayValue = "";
        // Check if the categories is setted :
    if (isset($this->row->categories) ) {
        // Read all categories IF the product have several categories setted
                foreach ($this->row->categories as $key => $value) 
				{
          // Required category found, display your price :
          if ($value->category_id == '13' ) 
          $YourPrice="Marge product";
          else $YourPrice="Incl. BTW";
          $displayValue = '<span>' . $YourPrice . "</span>";
		  }
echo $displayValue;

The 'problem' is, that the products are assigned to 2 categories, in this case "Jura Occasions" AND the parent category "Coffeemachines".

For the php folks among us, it's very simple to solve I think :silly:
In my code, it's checking if there's another category, if it is, he uses the ELSE value (or am I wrong?)
Wouldn't it be simpler to just check 1 category and if the product is member of it, it will apply the condition.

Please Log in or Create an account to join the conversation.

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
7 years 6 months ago #250966

Hi,

How about doing instead:

$displayValue = "";
          // Required category found, display your price :
          if ($this->element->category_id == '13' ) 
          $YourPrice="Marge product";
          else $YourPrice="Incl. BTW";
          $displayValue = '<span>' . $YourPrice . "</span>";
echo $displayValue;
That way, it will use the curent category of the listing instead of checking in the categories of each product.

The following user(s) said Thank You: hielkio

Please Log in or Create an account to join the conversation.

  • Posts: 44
  • Thank you received: 2
7 years 6 months ago #251044

Wow! You're my hero :)
Thank you very much .. it works like a charm!

Please Log in or Create an account to join the conversation.

Time to create page: 0.090 seconds
Powered by Kunena Forum