Jump to content


information

Product Category And Tags

category tags shortcode

4 replies to this topic

#1 srumery

srumery

    Member

  • Members
  • Others: BackupBuddy, BackupBuddy, Exchange - Stripe
  • 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
  • 30,393 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, BackupBuddy, Exchange - Stripe
  • 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, BackupBuddy, Exchange - Stripe
  • 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
  • 30,393 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.




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