Home > database >  Woocommerce get the product title on image hover
Woocommerce get the product title on image hover

Time:06-27

I've been trying to edit a main theme file in order to show the product title on image hover. We have a similar function, but actually shows the categories of the product, not his title.

Here's the code I've been trying to edit in order to get the products title:

<div ></div>

           <a href="<?php the_permalink(); ?>" ></a>

           <div >

            <?php do_action( 'woocommerce_after_shop_loop_item_title' ); ?>

            <?php



            if ( $woocommerce && version_compare( $woocommerce->version, '3.0', '>=' ) ) {

                echo '<div >' . wc_get_product_category_list( $product->get_id() ) . '</div>';

            } else {

                echo '<div >' . $product->get_categories() . '</div>';

            }



            ?>

        </div> 

I just want to get the product title instead of the categories terms.

Print of the style: https://prnt.sc/WZIgbMQNAb_5

Any help would be grateful!

CodePudding user response:

You need to replace this code section.

    if ( $woocommerce && version_compare( $woocommerce->version, '3.0', '>=' ) ) {

        echo '<div >' . wc_get_product_category_list( $product->get_id() ) . '</div>';

    } else {

        echo '<div >' . $product->get_categories() . '</div>';

    }

to this.

echo '<div >' . $product->get_title() . '</div>';
  • Related