how to display category of product?

  • Posts: 485
  • Thank you received: 2
  • Hikashop Business
5 years 2 months ago #244039

-- HikaShop version -- : 2.6.3
-- Joomla version -- : 3.4.3
-- PHP version -- : 5.5
-- Error-message(debug-mod must be tuned on) -- : none

hi guys

how can i display the product category on the product page?

thanks

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

  • Posts: 12855
  • Thank you received: 1763
  • MODERATOR
5 years 2 months ago #244047

Hello,

If you want to display a listing of categories, you can use an Hikashop category listing menu / module :
www.hikashop.com/support/documentation/3...splay-front-end.html

Else if you want to display it through your product page, you can actually add it through your product description.

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

  • Posts: 485
  • Thank you received: 2
  • Hikashop Business
5 years 2 months ago #244127

how do i add it to the product description?

what is the code?

thanks

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

  • Posts: 1119
  • Thank you received: 114
5 years 2 months ago #244153

Hi,

If you want to show product categories/category name on product page you can add something like this to product ->show_default view file.

<?php

							$q = 'SELECT c.* '.
								' FROM ' . hikashop_table('product_category').' as pc '.
								' INNER JOIN '.hikashop_table('category').' AS c ON pc.category_id = c.category_id '.
								' WHERE pc.product_id = '.hikashop_getCID('product_id');
								$database->setQuery($q);
								$product_categories = $database->loadObjectList();
								$categories = array();
								if($product_categories) { ?>
                                <div class=" gray-italic">
									<span class=" margin-reset"><?php echo JText::_('CUSTOM_ITEM_PRODUCT_CATEGORIES'); ?> :</span>
                           		 <?php 
									foreach ($product_categories as $category) $categories[] = $category->category_name;
                                    foreach($categories as $c) $c = '<span class="pull-left margin-reset">'.$c.'</span>';
                                    echo implode(', ', $categories);
								?>


Please note that you should modify this code to your needs.

I hope this is what you are looking for?

Thanks

Last edit: 5 years 2 months ago by kyratn.
The following user(s) said Thank You: ronron

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

  • Posts: 3310
  • Thank you received: 441
  • MODERATOR
5 years 2 months ago #244150

Hello,

I think Mohamed speak about add in your product description part, more precisely here :




In order to go more far your custom your product/show.php, view and add where needed this code in order to display your product category.
foreach ($this->categories as $key => $value) { 
?>
		<div id="hikashop_product_category_<?php echo $value->category_id ?>">
			<?php echo $value->category_name ?>
		</div>
<?php
	}

Hope this will help you.

Regards

Attachments:
Last edit: 5 years 2 months ago by Philip.
The following user(s) said Thank You: ronron

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

  • Posts: 75
  • Thank you received: 6
  • Hikamarket Multivendor Hikashop Business
1 week 8 hours ago #335683

What if I want to see ONLY categories with the same category_parent_id ??

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

  • Posts: 73730
  • Thank you received: 11306
  • MODERATOR
1 week 2 hours ago #335691

Hi,

We're talking here about displaying the categories directly linked to the current product, on the product details page.
A product doesn't have a category_parent_id so I don't see what you mean ?
Or are you talking about displaying a listing of the categories with the same parent as the categories linked to the product ? There is no easy way to do that. That would require some development to be able to do that. However, I don't see the point of doing that, so maybe you're talking about something else entirely ?

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

  • Posts: 75
  • Thank you received: 6
  • Hikamarket Multivendor Hikashop Business
1 week 11 minutes ago #335708
Attachments:

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

  • Posts: 73730
  • Thank you received: 11306
  • MODERATOR
6 days 11 hours ago #335725

Hi,

Ok, that's much more clear.
So what you could do is add the code:

if($value->category_parent_id != xx) continue;
before the first ?> in your custom code. Make sure you replace xx with the id of the "Badges & discounts" category.
That way, your code won't display the children categories of that "Badges & discounts" category.

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

  • Posts: 75
  • Thank you received: 6
  • Hikamarket Multivendor Hikashop Business
6 days 9 hours ago #335728

Thank you Nicolas for creating HikaShop and thank you for the assistance you give us :)

The following user(s) said Thank You: Philip

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

Time to create page: 0.096 seconds
Powered by Kunena Forum