2

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?

Thanks in advance Miguel

  • Maybe try WooCommerce support? – Chip Bennett May 3 '13 at 19:05
6

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' );
  • Hello Helga, Tks for your help. – Miguel Barros May 7 '13 at 8:54
  • Hello Helga, Tks for your help. Let me see if I understand. The simplest way is to override. I did, and know I think I have to edit the file. The question is what do I need to do to have what I want? Can you give me something more? Thanks in advance, Miguel – Miguel Barros May 7 '13 at 9:28
  • Check my edit. Otherwise, clarify your question. – helgatheviking May 7 '13 at 23:31
  • Hello Helga. I'm back to this issue, because I was in another project. Thanks for your support so far. What I need is to have the short description like the normal woocommerce theme (I would like not to have the "Entre em contacto connosco para saber preços Aqui"). In the product page I would like to have the normal short description plus "Entre em contacto connosco para saber preços Aqui" instead of the prices that I have already deleted. I'm not sure if I was clear enough... Thanks in advance. Miguel – Miguel Barros May 15 '13 at 10:56
  • 1
    After all that, don't forget to accept my solution as the answer. – helgatheviking May 24 '13 at 13:15
0

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 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.