• Resolved alitoo.81

    (@alitoo81)


    Hi,

    We have different products that have the same short description and same category and subcategory. It’s not really a description, it’s a chart image. As all the products in the same category have the same chart in the short description, we would like to display the same Excerpts or short description for all the products in the same category and subcategory. is that posible?

    A php code in function.php will help but we don’t know about php.

    thanks

    https://www.ads-software.com/plugins/woocommerce/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Mike Jolley

    (@mikejolley)

    I suggest you post this on jobs.wordpress.net if you want someone to code something for you. There are action hooks that can be used to check category and output content. Just needs coding to meet you needs.

    Thread Starter alitoo.81

    (@alitoo81)

    Hi,

    I have seen by googling that some people have help here or I am wrong? Is it free in jobs.wordpress.net?

    thanks

    mother.of.code

    (@imazed)

    The Mother of Code

    Hey there,

    Yes, sometimes volunteers will be amazingly gracious and offer to provide code to you for free. If you need help fast, or need to be 100% certain that the code you’re getting works, it’s best to pay a developer to work for you. jobs.wordpress.net is not free, but it will get you what you want the fastest.

    Thread Starter alitoo.81

    (@alitoo81)

    Well I made this till know.

    add_action( ‘woocommerce_single_product_summary’, ‘coral_chart’, 20 );
    function coral_chart() {
    echo ‘<img src=”url of the image”>’;
    }

    the only thing is left is that I need it to display the image in all products inside one category. Maybe with the ID of the category but I dont no how to add this to the snippet. What I feel is needed it to add something before woocommerce_single_product_summary like product_cat but how do I add the ID of the category?

    thanks

    Thread Starter alitoo.81

    (@alitoo81)

    I am expert in html and CSS. I had to learn PHP in one night, but I made it lol

    This is a Snippet for adding any text or image or chart to the simple product short discription in the same category. (all products inside one certine category). You can simply add it to the function.php of your theme.

    add_action( 'woocommerce_single_product_summary', 'coral_chart', 20 );
    function coral_chart() {
    
    global $post;
    $terms = wp_get_post_terms( $post->ID, 'product_cat' );
    foreach ( $terms as $term ) $categories[] = $term->slug;
    
    if ( in_array( 'tridacna-clams', $categories ) ) {
      echo 'image, text or any thing.';
    } else {
      echo '';
    }
    }
    ?>

    Hi bro,
    i try the code you put here but where i need to write the category ID?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Adding defult Custom Short Description/Excerpts to single product page’ is closed to new replies.