Product Likes

Allow users to like products in your WooCommerce store and view previous likes in their account.

Add like buttons with total likes to all products within your WooCommerce store – just like on social networks. Users can then click to like a product from the product page, category page and more. Users can view their previous likes when browsing your store and through their account, you can enable likes for users who aren’t logged in too.

Getting Started ↑ Back to top

  1. Install the extension
  2. Go to WooCommerce > Settings > Products > General > Product Likes
  3. Amend any of the settings required, we recommend keeping the settings as default
  4. View your store, you’ll see product like buttons on product pages and/or product archive pages
  5. Total likes show once a product has 1 or more likes

Settings ↑ Back to top

You can access the settings at WooCommerce > Settings > Products > General > Product Likes

  • Enable Product Likes (Enables product likes across your store, ensure you also enable at least one of the display options below to see the buttons)
  • Enable If Not Logged In (Allows users without an account to like products, user will see their likes on products for 30 days or until cookies cleared. After this period likes by a not logged in user will still count towards the total number of product likes)
  • Enable In Account (Adds a section within the user’s account listing the products the customer has previously liked)
  • Show On Product Pages (Shows a product like button on individual product pages)
  • Show On Product Archive Pages (Shows a product like button on each product in an archive page e.g. shop page, product categories, etc)
  • Show Total Likes (Shows the total number of likes if a product has been liked)
  • Icon (Icon type used for product likes, Heart/Thumb/None)
  • Enable Styles (Adds styles to product likes, if disabled this will remove all styles from product likes including the icon chosen, this option should only be disabled if you wish to style product likes yourself with CSS)

Display ↑ Back to top

Product like buttons and total likes are shown on the product page and on each product in an archive page (e.g. product category), you can disable the display on either of these areas if needed. You can select the icon type (heart, thumb or none) or choose to remove all styling and style yourself with CSS.

Not Logged In Users ↑ Back to top

For users who aren’t logged in their likes will count towards the product’s like total and their likes will remain visible when they visit your store until their cookie expires or is deleted. You can disable this option if needed.

Dashboard ↑ Back to top

Within your dashboard you can go to WooCommerce > Products and you will see a likes column on each product showing the total number of likes. You can sort this ascending or descending using the column header. In the screen options tab you will find the likes option if you wish to enable/disable the column from display.

Post Meta ↑ Back to top

You may notice that this extension uses post meta attached to products with the key “_wcpl_product_likes_likes”. This is the total number of likes.

This post meta should not be manually updated through the database or via import/export or custom development functionality.

It should not be updated to a different value as it relates to data stored outside post meta in a database table for each individual like and those 2 data points should remain in sync. If the post meta is changed you may see inconsistencies when users try to like or unlike products in future.

If you have attempting to amend this and have issues you can resync the post meta with the individual like database data by logging into your dashboard as an administrator and adding the query string wcpl_product_likes_meta_debug=1 to the admin URL and pressing enter e.g. https://yourdomain.com/wp-admin/?wcpl_product_likes_meta_debug=1

Cookies ↑ Back to top

The extension sets one cookie called wcpl_product_likes which is used to give a unique ID to a user who isn’t logged in so their likes are remembered until the cookie is removed.

Filters ↑ Back to top

We have included the following filters which you can use to manipulate the extension’s output as shown below.

You can use these filters within your theme’s functions.php file, see the examples below.

FilterDescription
wcpl_product_likes_like_text( $text )Change “Like” text
wcpl_product_likes_likes_text( $text )Change “Likes” text
wcpl_product_likes_likes_none_text( $text )Change text in my account when no products yet liked
wcpl_product_likes_unlike_text( $text )Change “Unlike” text
wcpl_product_likes_total_before_text( $text )Change text which appears before total likes
wcpl_product_likes_total_after_text( $text )Change text which appears after total likes

Examples ↑ Back to top

Here are some examples of how you could use some of the filters above on your website to change references to “likes” to “loves”, remember to change the prefix and text domain to your own:

function your_prefix_like_text( $text ) {
	return __( 'Love', 'your-text-domain' );
}
add_filter( 'wcpl_product_likes_like_text', 'your_prefix_like_text' );

function your_prefix_likes_text( $text ) {
	return __( 'Loves', 'your-text-domain' );
}
add_filter( 'wcpl_product_likes_likes_text', 'your_prefix_likes_text' );

function your_prefix_likes_none_text( $text ) {
	return __( 'You have not loved any products yet.', 'your-text-domain' );
}
add_filter( 'wcpl_product_likes_likes_none_text', 'your_prefix_likes_none_text' );

function your_prefix_unlike_text( $text ) {
	return __( 'Unlove', 'your-text-domain' );
}
add_filter( 'wcpl_product_likes_unlike_text', 'your_prefix_unlike_text' );

function your_prefix_likes_total_before_text( $text ) {
	return __( 'Loved by', 'your-text-domain' );
}
add_filter( 'wcpl_product_likes_total_before_text', 'your_prefix_likes_total_before_text' );
	

function your_prefix_likes_total_after_text( $text ) {
	return __( 'people', 'your-text-domain' );
}
add_filter( 'wcpl_product_likes_total_after_text', 'your_prefix_likes_total_after_text' );

WooCommerce - the most customizable eCommerce platform for building your online business.

Back to the top