Site icon Hip-Hop Website Design and Development

Remove product description from product archive page

The shop page of WooCommerce is based on the archive-product.php file. In this file, a loop is called:

    <?php woocommerce_product_loop_start(); ?>

            <?php woocommerce_product_subcategories(); ?>

            <?php while ( have_posts() ) : the_post(); ?>

                <?php
                    /**
                     * woocommerce_shop_loop hook.
                     *
                     * @hooked WC_Structured_Data::generate_product_data() - 10
                     */
                    do_action( 'woocommerce_shop_loop' );
                ?>

                <?php wc_get_template_part( 'content', 'product' ); ?>

            <?php endwhile; // end of the loop. ?>

In this loop, product data is generated:

public function generate_product_data( $product = null ) {
        if ( ! is_object( $product ) ) {
            global $product;
        }

        if ( ! is_a( $product, 'WC_Product' ) ) {
            return;
        }

        $shop_name       = get_bloginfo( 'name' );
        $shop_url        = home_url();
        $currency        = get_woocommerce_currency();
        $markup          = array();
        $markup['@type'] = 'Product';
        $markup['@id']   = get_permalink( $product->get_id() );
        $markup['url']   = $markup['@id'];
        $markup['name']  = $product->get_name();

        if ( apply_filters( 'woocommerce_structured_data_product_limit', is_product_taxonomy() || is_shop() ) ) {
            $this->set_data( apply_filters( 'woocommerce_structured_data_product_limited', $markup, $product ) );
            return;
        }

        if ( '' !== $product->get_price() ) {
            $markup_offer = array(
                '@type'         => 'Offer',
                'priceCurrency' => $currency,
                'availability'  => 'https://schema.org/' . $stock = ( $product->is_in_stock() ? 'InStock' : 'OutOfStock' ),
                'sku'           => $product->get_sku(),
                'image'         => wp_get_attachment_url( $product->get_image_id() ),
                'description'   => $product->get_description(),
                'seller'        => array(
                    '@type' => 'Organization',
                    'name'  => $shop_name,
                    'url'   => $shop_url,
                ),
            );
...

There is a line in the generate_product_data function calling for the product description.

I’d like to adapt my template or add a function in my functions.php file so the description is no longer added to my product archive page. However, it should be added to my single product page. Product archive page & single product page use the same woocommerce_shop_loop however.

How should I adapt the template or add code to my functions file to remove this product description? I have long descriptions for my products & don’t want these to be added to the product archive pages.