WooCommerce - excelling eCommerce
[resolved] The description is not prominent by default, however som (9 posts)

  1. daledude
    Posted 3 years ago #

    This line in the topic title is at the bottom left of many pages, including the Attributes page for WooCommerce when creating a new Attribute. WHAT, for the love of everything, is the code necessary to get this code to show in a theme? I have spent hours browsing Google now, trying different codes in different posts I've found, and changing them up a bit, but I can't find any code that will let me show this Description in my product page for the attribute. I assume it has to do with taxonomy somehow.

    I have created an attribute in WooCommerce called "Manufacturer", and in the various manufacturers I have created in this attribute I have typed a description of said manufacturer. I cannot get this description to show up on the frontend for the products associated with that manufacturer.

    I can find no other, better way to handle manufacturers/suppliers in WooCommerce, either. I need to be able to link a product to a manufacturer, and include said manufacturers contact info, description, and website. Using this attribute is the best I've found, but I cannot get it to show on the front end.

    Any idea?


  2. daledude
    Posted 3 years ago #

    I have discovered that the item is called "pa_manufacturer", I believe, but I still don't know how to show the attribute's description. I've gone through searching through the files for "pa_" prefix, for "description", and other things, and tried various bits of code to try but nothing will ever show the attribute's description I've entered. Starting to think this isn't possible in WooCommerce, though if it isn't possible, then those description fields should not be there in the Add Attribute page.

  3. daledude
    Posted 3 years ago #

    Basically I am trying to do what is talked of in this post: http://wordpress.org/support/topic/how-to-make-categorie-descriptions-visbile?replies=2 but with attributes instead of categories....

  4. Mike Jolley
    Plugin Author

    Posted 3 years ago #

    You need this function http://codex.wordpress.org/Function_Reference/term_description

    You can override WC templates if you need to output it in a specific place

    Get the products terms with this

  5. daledude
    Posted 3 years ago #

    Hi Mike,

    Thanks for the response. I have found posts that mention all of those things, and I've tried putting them into the description.php template file for the Description Tab, but they still won't show.

    Here are the code snippets I've tried, messed a bit from various sources:

    1. <?php $wp_term_taxonomy = description( $term_id, $taxonomy, $description ); ?>

    2.<?php $post_terms = wp_get_post_terms( $post->ID, $attribute['name'] ); ?>

    3.<?php echo term_description($term_id, pa_manufacturer, $description); ?>

    4. `<?php $my_taxonomy = 'pa_manufacturer'; // set this to whatever your custom taxonomy is called

    $terms = wp_get_post_terms( $post->ID, $my_taxonomy ); // this gets all the terms attached to the post for your custom taxonomy

    echo term_description($terms[0]->term_id, $my_taxonomy); // this displays the description for the first term in the $terms array ?>
    So far none of them show anything. Not sure if I'm supposed to manually enter the pa_manufacturer into one of them, or if it's supposed to automatically know, or what. :\

  6. daledude
    Posted 3 years ago #

    Actually, I got it to work! I used #4 in my list above, but I moved it up further in the source. Apparently where it was positioned within the

    <div class="panel" id="tab-description">

    makes a difference for some reason. I moved it directly below the H2 containing the $heading, and the description appeared. No idea why.

    So there it is, for someone else's future reference. Now I just have to figure out how to output the name of the attribute itself.

  7. mydog8it
    Posted 2 years ago #


    I'm trying to show the term description for an attribute that's used as a product variable. I'm having some trouble pulling that attribute description, too. I can't seem to find a reference to it in the woocommerce docs.

    Using your code:

    <?php $my_taxonomy = 'pa_custom';
    $terms = wp_get_post_terms( $post->ID, $my_taxonomy );
    echo term_description($terms[0]->term_id, $my_taxonomy); ?>

    I was able to get a description to show up by placing this in meta.php, but it's showing a static description for one of the variables. I can't get it to change descriptions to show the correct one for the selected variable.

    I'm pretty sure I need to place the code (or some other code) in the variable.php file, but I'm not sure where to add it. I was thinking it needs to go in here somewhere?

    							if ( is_array( $options ) ) {
    								if ( empty( $_POST ) )
    									$selected_value = ( isset( $selected_attributes[ sanitize_title( $name ) ] ) ) ? $selected_attributes[ sanitize_title( $name ) ] : '';
    									$selected_value = isset( $_POST[ 'attribute_' . sanitize_title( $name ) ] ) ? $_POST[ 'attribute_' . sanitize_title( $name ) ] : '';
    								// Get terms if this is a taxonomy - ordered
    								if ( taxonomy_exists( sanitize_title( $name ) ) ) {
    									$terms = get_terms( sanitize_title($name), array('menu_order' => 'ASC') );
    									foreach ( $terms as $term ) {
    										if ( ! in_array( $term->slug, $options ) ) continue;
    										echo '<option value="' . $term->slug . '" ' . selected( $selected_value, $term->slug, false ) . '>' . apply_filters( 'woocommerce_variation_option_name', $term->name ) . '</option>';
    								} else {
    									foreach ( $options as $option )
    										echo '<option value="' . $option . '" ' . selected( $selected_value, $option, false ) . '>' . apply_filters( 'woocommerce_variation_option_name', $option ) . '</option>';

    Anyone have any ideas?

  8. rhristova
    Posted 2 years ago #

    @mydog8it , I have the exact same problem and I was wondering if you resolved it.

  9. hollyann22
    Posted 2 years ago #

    I too am having this problem. Any luck?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic