Newsletters – WooCommerce Products in Newsletters
WooCommerce products can be displayed in newsletters using a simple yet flexible shortcode. You’ll insert
newsletters_woocommerce_products shortcode into any newsletter or newsletter template to display products as needed. The shortcode has options/attributes to customize it according to your needs.
Follow these steps to display products in your newsletter:
1. Insert Shortcode Into Newsletter
In order to show Woocommerce products in your newsletter, you need to insert the appropriate shortcode in WordPress editor. The shortcode can be found when creating a new newsletter in Newsletters > Create Newsletter, under Variables & Custom Fields option, as shown in the image bellow.
Output of The Shortcode
This is what the output of the shortcode will look like:
2. Customize the Display of WooCommerce Products
The shortcode supports several attributes to customize the WooCommerce products display. You can change the order, show featured products, best selling products, specify the number of products, the number per row and more.
An example of the shortcode with all options/attributes and their default values:
newsletters_woocommerce_products perrow=3 number=9 order=DESC orderby=post_date featured=0 bestselling=0 showimage=1 imagesize="thumbnail" showtitle=1 showprice=1 showbutton=1 buttontext="Buy Now"
All the attributes work in conjunction with one another to give you the necessary flexibility.
All Available Shortcode Attributes
perrow= Number of products to display per row.
number= Total number of products to display.
order= Set to ‘DESC’ to order the products in a descending order and ‘ASC’ to order the slides in a ascending order.
orderby= Sort displayed products. Defaults to ‘date (post_date)’. Any WordPress post fields can be used.
featured= Set to 1 to display featured products. The default is 0 which displays any products.
bestselling= Set to 1 to display best selling products. The default is 0 which displays all prdoucts.
showimage= Set to 0 to hide the product image. Set to 1 to show the product image.
imagesize= The size of the product image. Use any WordPress image size, eg. thumbnail, medium, etc. or a width, comma and height, eg. 300,200
showtitle= Set to 0 to hide the product title. Set to 1 to show the product title.
showprice= Set to 0 to hide the product price. Set to 1 to show the product price.
showbutton= Set to 0 to hide the add to cart button. Set to 1 to show the add to cart button.
buttontext= Text to display on add to cart button. The default is “Buy Now”
3. Example of WooCommerce Products in Newsletters
Let’s have a look at an example:
Regular Latest Products
By default, the shortcode displays WooCommerce products in a descending manner by
post_date so essentially your latest products.
You can add
featured=1 attribute to the shortcode to specifically display your featured products only.
Best Selling Products
bestselling=1 attribute in the shortcode to display best selling products based on total price of purchases.
Number of Products and Products Per Row
number=2 to display only 2 products or
perrow=2 to display 2 products per row.
orderby attributes on the shortcode to sort/order your products as needed. The
order attribute takes either ASC or DESC as a value while
orderby takes any WordPress orderby value.