WooCommerce Lottery – Give ticket for free when client purchase another item

We had couple of inquries if it is possible to give ticket for free and allow clients to participate in prize draw when they purchase regular items sold on websites. This is possible and relatively easy to setup using our plugin. If you want to give users ticket number you will need Pick Number Mod addon for WooCommerce Lottery.

Easiest and fastest solution, would be that you create new lottery product and treat it as regular simple product so when someone purchase it you will ship actual item, (or give user access for download, etc) but also state that user will participate in lottery and could win a prize after purchase.

It is possible to change text from “Participate now for” via translations to anything you like and thing might be more suitable.

That lottery product was setup like this (here we use only WooCommerce Lottery without Pick Number Mod addon in this example):

If you want more complex solution then you will need 3rd party plugin which implements Buy One, Get One Free option / feature for WooCommerce.

In this tutorial I used PW WooCommerce BOGO Free plugin which is really trivial to setup and use. After installation you need to publish promotion and for each purchase of regular product you can add lottery ticket for free if price is lower or equal to product you purchased. There are plenty of similar plugins which you can use for this purpose – all should work just fine.

Here are couple of screenshots to see how this looks like on website during checkout:

Please note that you need to manually add lottery ticket to cart, plugin does not add it automatically. This implementation is handy if you want to use question / answers.

On last screenshot you can see how sample lottery / prize draw was setup. Please note WooCommerce Lottery and Pick Number Mod addon are enabled in this test setup.

Important thing to setup is minimum number of tickets for draw to be done, max number of tickets can be increased or decreased whole time during lottery active phase but make sure you don’t set max tickets below number of sold tickets since that can result with unexpected behaviour.

Keep on your mind that with this solution users would be able to participate by buying lottery ticket directly since we have not implemented anything that would prevent purchasing ticket directly by going to lottery product single page. If you need lottery to be restricted only for those who purchase something else you might need to get different plugin for “Buy One, Get One Free” or get pro version for this plugin.

Now here you can see screenshots of implementation without Pick Number Mod addon. Key difference is that there is no ticket number and that draw will be automatically done once lottery ends (no manual pick winner option – plugin will do that automatically using mt_rand function from all participants – there will always be 1 winner if there is at least 1 participant).

WooCommerce Simple Auctions now with Elementor support

WooCommerce Simple Auctions supports Elementor fully from version v2.0. You can create single auction page and auction base page with Elementor using Elementor widgets that are specific for auctions.

Screenshots below show Elementor widgets you can use for designing your templates.

Easiest way to create your single auction page with Elementor is to create new template for single product. There you can now add, rearrange and style Simple Auction elements like countdown, auction history, auction dates, auction max bid (for proxy), auction reserve price, sealed bid auction elements and auction bid form.

Auction product type will be recognized automatically and there is no need to add conditional for template. To create auction base page you will need to create new template type “Auctions Archive”:

To create auction base page you will need to create new template type “Auctions Archive”

Once template is designed you need to add condition as per screenshot below:

Add condition for “Auctions Archive” template

In Elementor Settings -> Experiments make sure that beta option “Landing Pages” is set to “inactive” otherwise you will have issues with lottery base page. See screenshot below:

Adding lottery countdown timer and progress bar to product archive / loop

We got quite a few inquries to display countdown timer and progress bar not only on single lottery page but in product archive / loop. This is covered in our documentation, FAQ item no 12 but we also made handy little plugin which enables those two code snippets with just few clicks and no need to edit functions.php file. You can download it here.

End result is shown on screenshot below. Plugin can be your base for further customizations.

WooCommerce Lottery resource and ticket limits – can user purchase 30 000 tickets at once?

Our plugin is basically limited with hosting solution that your WordPress installation runs on. There is no limit how many tickets can be sold at once or how many numbers can you list for lottery but usually on lower spec hosting (especially on cheaper shared hosting) you will hit limit around couple thousands ticket purchases – orders (around 3 000 to 5 000 orders). This would be same as if you would run regular WooCommerce web shop and problem is easily resolved by upgrading your hosting (you can contact us for suggestion).

There are couple of limits you can hit (for this example we will consider WordPress has only WooCommerce and our plugin installed and nothing else) – how many different users (orders) have purchased tickets in your store, more orders mean you need more resources for order data and its custom fields. Another is having a lot of tickets for a lottery say 1 million – this is not problem unless you want pick number table displayed which becomes cumbersome and we strongly suggest agains that (just use randomly assign ticket number instead). Sometimes lot of tickets cause JS issue in backend for auction history export table – for that we have option in Lottery Settings to disable this feature.

Cronjob that we suggest you install is lightweight and is used to finish lottery on time in case WordPress does not have enough traffic to run its internal cronjob. For busier websites this can be skipped, everything will work fine and in most cases lotteries will be ended on time.

When planning big lottery site with many orders you need to keep on your mind that except orders we log data to two log tables used by our plugins called wc_lottery_log and wc_lottery_pn_log which should not be big problem since only integer values are logged to those tables.

In general cheapest dedicated server (quad core cpu and 8GB – 16GB memory, normal disk drive no need for SSD) should enable site owner to run big lottery website with hundreds daily orders without performance issues. If you go for cloud solution you will need to get some mid priced solution since from our experience cheap cloud / vps proved to be problematic (probably due to heavy resource throttling done by their service providers). Further scaling can be done by separating app and db and have them on separate servers / vps or cloud instances.

We strongly suggest that before going to production you test all of these cases, for example try to purchase 1 million tickets or do some stress testing and see what is happening in your particular setup. You do not want to end up migrating website to new setup during marketing campaign and fixing things while orders are coming in.

Other than that we can suggest keeping number of active plugins to minimum, do some WordPress / WooCommerce optimization and use 3rd party / external SMTP server for mail notifications (offload main app server and better inboxing rates).

Icons missing in product list for auctions, lotteries and group buy / deals

We had a lot of inquries about missing icons in product type column WooCommerce product list. Users were asking why icons vanished in WooCommerce product list and how can they get it back. From WooCommerce 3.4.0 update, WooCommerce developers removed that column in product list (as a result of users’ feedback).

There is way to restore it back using this plugin https://wordpress.org/plugins/woocommerce-product-type-column/ so in case you are too missing this feature, download and activate this plugin and icons will be back in product list.

Using code snippets and template customizations in child theme

Every now and then you need to modify plugin or theme’s templates, add some code snippet or change couple things using CSS. Best way to include your changes and make them update proof is to do it via child theme. Child theme is special theme that loads parent theme files from parent theme folder and your customized files from child theme folder like templates and styles.

You need to have base (parent) theme like StoreFront (or Avada, Divi, any WooCommerce compatible theme will do just fine) and then you create new folder wp-content\themes\mycustomtheme\ with its own style.css and functions.php

Here is how to create child theme in 4 easy steps:

Step 1: create child theme folder for example /wp-content/themes/my-first-child-theme

Step 2: in that folder create style.css and functions.php filse, in style.css add code below:

Theme Name: My Sample WordPress Child Theme
Theme URI: https://wpgenie.org
Description: StoreFront theme based child theme
Author: wpgenie
Author URI: https://wpgenie.org
Template: storefront
Version: 1.0

Step 3: go to Appearance -> Themes and activate your newly created child theme.

Step 4: you can now add your modified templates to child theme folder, code snippets to your functions.php and custom CSS to your child theme’s style.css

Once you have customizations in your child theme you can now update plugin or theme without worries that your modifications will be lost during an update (theme or plugin update). ZIP with child theme described in this tutorial can be downloaded here (it will work only if you have installed StoreFront theme).

Detailed tutorial is here How to Create a Child Theme an article by WordPress about child themes.

For example you want to edit Simple Auction template from folder \woocommerce-simple-auctions\templates\single-product\bid.php – copy it to wp-content\themes\yourchildtheme\woocommerce\single-product\bid.php and make changes there. You will need some kind of file manager best is to use FTP client (for example FileZilla or file managed included in your hosting control panel).

Illustration from https://zenwp.co/child-theme/
How child theme templating works from https://zenwp.co/child-theme/

We have extensive archive of code snippets and modified plugin templates on our Pastebin archive.

WooCommerce Lottery and Pick Number addon now with Elementor support

Today we have released version 2.0.0 for WooCommerce Lottery and Pick Number Mod addon which include full Elementor support. In today’s update there were few minor changes and fixes too and version has been bumped to v2.0.0 for both plugin and addon. To edit lottery template with Elementor you need Elementor (free) plus Elementor Pro (paid) or PRO Elements (free).

Couple of screenshots how it looks like Elementor support:

WooCommerce Lottery and Pick Number addon natively supported in Elementor

Easiest way to create your single lottery page with Elementor is to create new template for single product. There you can now add, rearrange and style Woo Lottery elements like countdown, progress bar, lottery winner, lottery info and Pick Number Mod elements like ticket numbers, lucky dip and question / answers. Get WooCommerce Lottery here and Pick Number Mod addon here. In order not to have template applied to all single products, you need to tag or categorize lotteries and then apply template only to tag or category your lotteries are tagged / categorized with.

In Elementor Settings -> Experiments make sure that beta option “Landing Pages” is set to “inactive” otherwise you will have issues with lottery base page. See screenshot below:

elementor landing pages experiment should be set to inactive