Diwali

Wishing you joy this Diwali and Halloween! Enjoy up to 20% OFF on all addons!

Claim Offer
03Day 15Hr 05Min 09Sec
Diwali

Check the selected category

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Viewing 1 reply thread
  • Author
    Posts
    • #44865
      Jovica
      Guest

      Hello, I apologize in my bad English. Can you help me get the category id when adding the product. I would like to see the attributes only for the selected category, but I do not know how to get it when I create a categoryhttps://imgur.com/a/r2E39da

    • #44918
      WCFM Forum
      Member

      Hi,

      Here is a sample code to get product associated categories –

      $pcategories = get_the_terms( $product_id, 'product_cat' );
      		if( !empty($pcategories) ) {
      			foreach($pcategories as $pkey => $pcategory) {
      				$categories[] = $pcategory->term_id;
      			}
      		}

      Here “$pcategory->term_id” is category ID.

      Thank You

Viewing 1 reply thread
  • The topic ‘Check the selected category’ is closed to new replies.