Jump to content


Replying to Product Category And Tags


Post Options

  or Cancel


Topic Summary

Ronald

Posted 02 July 2014 - 04:14 PM

Hi,

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

srumery

Posted 02 July 2014 - 02:52 PM

Looks like for tags it is actually 'it_exchange_tag'.

srumery

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.

Ronald

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

srumery

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?

Review the complete topic (launches new window)