WooCommerce how to display new items on the product card

There is another task for promoting an online store on WooCommerce that is useful for your customers. Very often I receive orders to display new products inside the product card next to similar products. I think this is a common problem, not only for me., but in standard themes for WooCommerce this is not provided. Therefore, today I decided to slightly open the veil and describe the process of creating a block with new products in the product card..

You may also be interested in my previous article in the WooCommerce tutorial series. “WooCommerce how to display an auction product with a discount in the product card“.

As in the previous lesson, to develop this block, we will take an existing block with the output of similar articles. We will do everything in order.

  1. Finding the template file for the product card, it is usually located in the /wp-content/themes/ folder{your theme name}/woocommerce/content-single-product.php.
  2. At the bottom of it you will find a connection of a file of similar products, it looks like this:
    right below this line we write the connection of a new file in which we will add the code for displaying new products (new products).
  3. Now, when we set the path for connecting the file, you need to create the file. Create a file along the path /wp-content/themes/{your theme name}/woocommerce/single-product/product-new.php
  4. In the created product-new.php file, copy the contents of the related.php file, which is located along the path /wp-content/themes/{your theme name}/woocommerce/single-product/related.php.
  5. Check how products are displayed in the product card. If done right, then you will have 2 block of similar products.
  6. In the product-new.php file, change the name of the block to “Novelties in the online store”.
  7. Next, to display new products, we will need to change the array with parameters for the apply_filters function( ‘woocommerce_related_products_args’, array( … ).
  8. Below I will give an example of how I did it.
The code can be modified and new products can be displayed from the parent category for the product, for this you need to modify the code a little.
If you didn't succeed, write questions in the comments, I will try to answer them.

This auction code has been tested with WooCommerc 3.0, in a smaller or older version, the code may change slightly.


Купить хостинг WordPress
WordPress tutor
Online tutoring services. List of courses I teach
  • Basic web design course;
  • Site layout;
  • General course on CMS WordPress and continuation of the course on template development;
  • Website development in PHP.
Read more on the page WordPress tutor
*/

Nikolaenko Maxim

Director of web studies ProGrafika. I am developing, website design and promotion. Always glad to new blog readers and good clients.


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Templates for WordPress
The best hosting in Ukraine
Stable hosting for Drupal