WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: WooCommerce – excelling eCommerce] The description is not prominent by default, however som

[Resolved] [Plugin: WooCommerce – excelling eCommerce] The description is not prominent by default, however som

  • 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?

    http://wordpress.org/extend/plugins/woocommerce/

Viewing 8 replies - 1 through 8 (of 8 total)
  • 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.

    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….

    Plugin Author Mike Jolley
    Participant

    @mikejolley

    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
    http://wcdocs.woothemes.com/codex/template-structure/

    Get the products terms with this
    http://codex.wordpress.org/Function_Reference/wp_get_post_terms

    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. :\

    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">
    </div>

    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.

    mydog8it
    Participant

    @mydog8it

    Hey,

    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?

    <?php
    							if ( is_array( $options ) ) {
    
    								if ( empty( $_POST ) )
    									$selected_value = ( isset( $selected_attributes[ sanitize_title( $name ) ] ) ) ? $selected_attributes[ sanitize_title( $name ) ] : '';
    								else
    									$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?

    rhristova
    Member

    @rhristova

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

    hollyann22
    Member

    @hollyann22

    I too am having this problem. Any luck?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Resolved] [Plugin: WooCommerce – excelling eCommerce] The description is not prominent by default, however som’ is closed to new replies.