How to use different short description in shop page and in product page in woocommerce

What I would like to have is the sentence “Entre em contacto connosco para saber preços Aqui” just in product page, not in shop page. Please take a look in this page: http://www.kepaweleurope.com/shop/soutien-mamoplastia-85/

Does anybody can help me?

Read More

Thanks in advance
Miguel

Related posts

2 comments

  1. The short description template is /templates/single-product/short-description.php :

    <?php
    /**
     * Single product short description
     *
     * @author      WooThemes
     * @package     WooCommerce/Templates
     * @version     1.6.4
     */
    
    if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
    
    global $post;
    
    if ( ! $post->post_excerpt ) return;
    ?>
    <div itemprop="description">
        <?php echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ) ?>
    </div>
    

    You can override this (or any woo template) : http://docs.woothemes.com/document/template-structure/ by copying the file into your theme… so woocommerce/single-product/short-description.php. Then you can edit it as you like.

    EDIT: If I understand your question you would do this:

    <?php
    /**
     * Single product short description
     *
     * @author      WooThemes
     * @package     WooCommerce/Templates
     * @version     1.6.4
     */
    
    if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
    
    global $post;
    
    ?>
    <div itemprop="description">
        Entre em contacto connosco para saber preços Aqui
    </div>
    

    Or you could filter woocommerce_short_description. Or you could define your own woocommerce_template_single_excerpt() function which is pluggable, or remove it entirely from its hook. There really are many ways to do this, but the template override tends to be the simplest to understand.

    EDIT: Here’s a very basic example of how to filter the short description (and in general filtering anything is always the same process)

    Edit again: this goes in your theme’s functions.php

    function wpa_98244_filter_short_description( $desc ){
        global $product;
    
        if ( is_single( $product->id ) )
            $desc .= ' add some extra text to the short description';
    
        return $desc;
    }
    add_filter( 'woocommerce_short_description', 'wpa_98244_filter_short_description' );
    
  2. You can also use this thing with WordPress database for the product page.
    in this code, you can put your own short description. I have also used condition. you can change it as per your requirement. this code you need to put in function.php file of your theme.

    function My_short_description(){
            global $post,$wpdb,$woocommerce;
            $your_short_description = "My Description";
            $id = get_the_id();
            $prefix = $wpdb->prefix;
            $query = $wpdb->get_row("SELECT post_excerpt FROM {$prefix}posts WHERE ID={$id}");
            if($query)
            {
                $woocommerce_page_short_description = $query->post_excerpt;
                if($woocommerce_page_short_description=="" && $woocommerce_page_short_description==null)
                {
                    echo $your_short_description;
                }
            }
        }
        add_action( 'woocommerce_before_add_to_cart_form', 'My_short_description', 40 );
    

Comments are closed.