Jump to content


Welcome to the forum:

Welcome to the iThemes, PluginBuddy and WebDesign.com forum. We've created several tutorial video's to help you get you started with using the forum, please check them out!

Also take note of the forum guidelines.


Support hours:

Our moderators actively respond to forum support requests during normal business hours which are Monday-Friday, 8am - 5pm Central Standard Time, typically within one business day. Although some moderators choose to work during the weekends, we can not guarantee immediate attention to your requests. Thanks for understanding.

What is included with support:

Premium support includes theme/plugin issues such as: bugs encountered under normal operation, how to use basic features, basic WordPress help, and basic help with customization (meaning we point you to resources and will help in more depth as time allows). More information.

information

Product Category And Tags

category tags shortcode

9 replies to this topic

#1 srumery

srumery

    Member

  • Members
  • Others: BackupBuddy, Exchange - Stripe, Sync
  • PipPip
  • 11 posts

Posted 27 June 2014 - 06:02 AM

Is there shortcode that we can use to write out the product category or product tags? Something like this?

[exchange-product-cat product-id=123]


If not, I can create it but I need to know how to retrieve the product category and tags. I am using a similar function, it_exchange_set_product, to get product details and writing them on my page. Here is what I am using.

// run iThemes Exchange function to return an array with product details
it_exchange_set_product( $id );

// write the product title
it_exchange( 'product', 'get-title' )


From the array that is returned, I am not seeing the product category or product tag information. It's easy to enter it into the product using Exchange but I can't seen to get that data back out. How can I get to this data?

#2 Ronald

Ronald

    Forum Admin

  • Administrators
  • Others: All Plugins, All Themes, Moderators, Webdesign
  • 31,369 posts

Posted 27 June 2014 - 07:58 AM

Hi,

how exactly do you want to use the info? As part of you product template?

Here is a function that will return a space separated list of product categories wrapped in a div class:

function get_product_categories() {

	$all_prod_cats = "";

	if ( ! empty( $GLOBALS['it_exchange']['product']->ID ) ) :

		$terms = get_the_terms( $GLOBALS['it_exchange']['product']->ID, 'it_exchange_category' );

		if ( $terms && !is_wp_error( $terms ) ) :

			$prod_cats = array();

				foreach ( $terms as $term ) {
					$prod_cats[] = $term->name;
				}

			$all_prod_cats = join( " ", $prod_cats );

		endif;

	endif;

	return "<div class='my-exchange-product-categories" . $all_prod_cats . "'>";

}

that might be a start,

Ronald

Join the iThemes Builder Community on Google+.



To ensure that we can process your support request efficiently, ALWAYS include a link to your site, and/or the page your request is related to. Please also read the forum guidelines.



When asking your question/posting your request on the forum, please be as concise and specific as possible. The shorter your request, the more to the point, the more specific, the easier it will be for us to try and help out.


#3 srumery

srumery

    Member

  • Members
  • Others: BackupBuddy, Exchange - Stripe, Sync
  • PipPip
  • 11 posts

Posted 02 July 2014 - 02:49 PM

Yo Ronald,

That is exactly what I am looking for! Thank you.

For one site I am working on, each product is in one category and that category needs to be printed on top of the product title in a custom product grid I wrote. It needs different styling from the title so I can't just put the text there. The category is a perfect place to store this information, now I can retrive the information and put it where I want it. Thank you.

Another use in this site is to use tags to manage product icons. A tag of "pdf" will print out a icon. Multiple icons are possible but this is still a 1-to-1 relationship for now. I'm sure there is an equal 'it_exchange_tags' attribute like 'it_exchange_category' in your example. I'll create a new function for that and see how it works.

Thanks again, Ronald.

#4 srumery

srumery

    Member

  • Members
  • Others: BackupBuddy, Exchange - Stripe, Sync
  • PipPip
  • 11 posts

Posted 02 July 2014 - 02:52 PM

Looks like for tags it is actually 'it_exchange_tag'.

#5 Ronald

Ronald

    Forum Admin

  • Administrators
  • Others: All Plugins, All Themes, Moderators, Webdesign
  • 31,369 posts

Posted 02 July 2014 - 04:14 PM

Hi,

yes it is. Glad it's working for you, I will mark this resolved

Join the iThemes Builder Community on Google+.



To ensure that we can process your support request efficiently, ALWAYS include a link to your site, and/or the page your request is related to. Please also read the forum guidelines.



When asking your question/posting your request on the forum, please be as concise and specific as possible. The shorter your request, the more to the point, the more specific, the easier it will be for us to try and help out.


#6 dweuste

dweuste

    Advanced Member

  • Members
  • Others: Toolkit
  • PipPipPip
  • 215 posts

Posted 05 November 2014 - 04:02 PM

Sorry if chiming in here isn't kosher, but I'm trying to use the above answer in order to list categories in a "footer" kind of area on the product page (much like a category list would appear on a standard blog post), and I'm getting lost somewhere. What I initially tried was simply doing a copy-paste of your code into the functions.php of the theme, and then calling get_product_categories(); in the content-product.php page, but it doesn't seem to be working. Any suggestions or am I way off track in order to accomplish what I'm trying?

#7 Ronald

Ronald

    Forum Admin

  • Administrators
  • Others: All Plugins, All Themes, Moderators, Webdesign
  • 31,369 posts

Posted 07 November 2014 - 10:03 AM

Hi,

the function returns a value. In order to make that visible, you need to echo (http://php.net/manual/en/function.echo.php) it

does that help?
Ronald

Join the iThemes Builder Community on Google+.



To ensure that we can process your support request efficiently, ALWAYS include a link to your site, and/or the page your request is related to. Please also read the forum guidelines.



When asking your question/posting your request on the forum, please be as concise and specific as possible. The shorter your request, the more to the point, the more specific, the easier it will be for us to try and help out.


#8 dweuste

dweuste

    Advanced Member

  • Members
  • Others: Toolkit
  • PipPipPip
  • 215 posts

Posted 07 November 2014 - 10:15 AM

In the function in my functions.php or in the content-product.php template part?

--Update--

Nevermind. Figured that part out. Any way you could point me to how to make them links?

#9 Ronald

Ronald

    Forum Admin

  • Administrators
  • Others: All Plugins, All Themes, Moderators, Webdesign
  • 31,369 posts

Posted 07 November 2014 - 10:42 AM

Hi,

you might want to look into this instead: https://wordpress.org/support/topic/list-categories-for-custom-post-type

Ronald

Join the iThemes Builder Community on Google+.



To ensure that we can process your support request efficiently, ALWAYS include a link to your site, and/or the page your request is related to. Please also read the forum guidelines.



When asking your question/posting your request on the forum, please be as concise and specific as possible. The shorter your request, the more to the point, the more specific, the easier it will be for us to try and help out.


#10 dweuste

dweuste

    Advanced Member

  • Members
  • Others: Toolkit
  • PipPipPip
  • 215 posts

Posted 07 November 2014 - 11:53 AM

Well, that at least got me on to the right track! That thread showed me how to list all of my exchange categories, which isn't what I wanted, but that at least gave me a function to look up in the WP Codex, where I found the code I needed to list only the categories for the post. In case anyone else needs this answer, I'll put it here.

In the content-product.php template file in my child theme I added the following code:

<div class="product-categories">Related:
<?php
$taxonomy = 'it_exchange_category';
$post_terms = wp_get_object_terms( $post->ID, $taxonomy, array('fields' => 'ids'));
$separator = '; ';

if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) {
$term_ids = implode( ',' , $post_terms );
$terms = wp_list_categories( 'title_li=&style=none&echo=0&taxonomy=' . $taxonomy . '&include=' . $term_ids );
$terms = rtrim( trim( str_replace( '<br />', $separator, $terms ) ), $separator );

// display post categories
echo $terms;
}
?>
</div>

Nice thing about it working with core WordPress is that I didn't even need to add a function in functions.php.

Thanks for pointing me in the right direction!



Reply to this Topic


ATTENTION
If this topic is marked RESOLVED or INFORMATION, or if you are NOT experiencing EXACTLY the same issue, please start a new topic to provide the details of your problem. If the solution provided doesn't work for you, you should start a new topic. If you feel this thread contains relevant information, you may include a link to it in your new topic. To ensure that we can process your support request efficiently, ALWAYS include a link to your site, and/or the page your request is related to. When posting your question or request on the forum, please be as concise and specific as possible. The shorter and more to the point you can make your request, the better.

For BackupBuddy related issues, be sure to include the status log from your most recent backup.

CLICK HERE to start a new topic in the Exchange ecommerce plugin forum.


  



Also tagged with one or more of these keywords: information, category, tags, shortcode

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users