0
votes

I'm using WooCommerce with Flatsome Theme.
I want to add a subtitle to my products.
I installed the WooCommerce Product Subtitle plugin and I see the subtitles only at the shop page, but NOT in the single product page.

I was looking much around the internet but not success.
In the plugin area, I see this help offer:

F.A.Q.s
1.Subtitle not visible in single product page?

This issue might be with the theme which you are using
Please do make sure that your theme has woocommerce_single_product_summary filter in the below files

woocommerce_single_product_summary filter file list :

  1. your-theme/woocommerce/content-product.php

What do I have to do? Here is the page:

<?php
/**
 * The template for displaying product content within loops
 */

defined( 'ABSPATH' ) || exit;

global $product;

// Ensure visibility.
if ( empty( $product ) || ! $product->is_visible() ) {
    return;
}

// Check stock status.
$out_of_stock = get_post_meta( $post->ID, '_stock_status', true ) == 'outofstock';

// Extra post classes.
$classes   = array();
$classes[] = 'product-small';
$classes[] = 'col';
$classes[] = 'has-hover';

if ( $out_of_stock ) $classes[] = 'out-of-stock';

?>

<div <?php fl_woocommerce_version_check( '3.4.0' ) ? wc_product_class( $classes ) : post_class( $classes ); ?>>
    <div class="col-inner">
    <?php do_action( 'woocommerce_before_shop_loop_item' ); ?>
    <div class="product-small box <?php echo flatsome_product_box_class(); ?>">
        <div class="box-image">
            <div class="<?php echo flatsome_product_box_image_class(); ?>">
                <a href="<?php echo get_the_permalink(); ?>">
                    <?php

                        /**
                         *
                         * @hooked woocommerce_get_alt_product_thumbnail - 11
                         * @hooked woocommerce_template_loop_product_thumbnail - 10
                         */
                        do_action( 'flatsome_woocommerce_shop_loop_images' );
                    ?>
                </a>
            </div>
            <div class="image-tools is-small top right show-on-hover">
                <?php do_action( 'flatsome_product_box_tools_top' ); ?>
            </div>
            <div class="image-tools is-small hide-for-small bottom left show-on-hover">
                <?php do_action( 'flatsome_product_box_tools_bottom' ); ?>
            </div>
            <div class="image-tools <?php echo flatsome_product_box_actions_class(); ?>">
                <?php do_action( 'flatsome_product_box_actions' ); ?>
            </div>
            <?php if ( $out_of_stock ) { ?><div class="out-of-stock-label"><?php _e( 'Out of stock', 'woocommerce' ); ?></div><?php } ?>
        </div><!-- box-image -->

        <div class="box-text <?php echo flatsome_product_box_text_class(); ?>">
            <?php
                do_action( 'woocommerce_before_shop_loop_item_title' );

                echo '<div class="title-wrapper">';
                do_action( 'woocommerce_shop_loop_item_title' );
                echo '</div>';


                echo '<div class="price-wrapper">';
                do_action( 'woocommerce_after_shop_loop_item_title' );
                echo '</div>';

                do_action( 'flatsome_product_box_after' );

            ?>
        </div><!-- box-text -->
    </div><!-- box -->
    <?php do_action( 'woocommerce_after_shop_loop_item' ); ?>
    </div><!-- .col-inner -->
</div><!-- col -->
2

2 Answers

0
votes

maybe the subtitle is not hooked anywhere in the single product page.

Can you try to add this snippet to your theme's functions.php file?

add_action('woocommerce_shop_loop_item_title', 'fc_single_product_subtitle');
function fc_single_product_subtitle() {

    $subtitle = get_product_subtitle( get_the_ID() );

    if( ! empty( $subtitle ) ) echo $subtitle;
}

Let me know and good luck!

0
votes

finelly, after lot of hours...

my site using with Elementor pro, so i just edit the tamplate of single page product from the plugin:

  1. Dashboard > Elementor Tamplates (can show diffrent on some versions).

  2. click edit to my producte page tamplate.

  3. when the elementor builder load my tamplate producte page i just insert shortcode widget and use shortcode [wc-ps] to use with my subtitles data.