WooCommerce Lottery – Pick Number Mod addon features explained

Pick Number Mod is addon for WooCommerce Lottery. In order to activate Pick Number Mod you need to have WooCommerce Lottery installed. We have discount coupon code for Pick Number Mod purchase on our home page (covers costs of WooCommerce Lottery).

Pick Ticket Number

This feature enables users to select their ticket number. Feature is implemented as table or you can enable “randomly assign ticket number” option where number is randomly assigned on order creation. Tickets can be partitioned using alphabet so you can have (A1…A100, B1…B100, etc). If you have many tickets they can be sorted in tabs for better user experience:

Pick Number table with tickets sorted in tabs – 30 tickets per tab

We have implemented ticket reservation which is useful when user take some time (too much time) to complete checkout (and payment). This is to prevent another user to do checkout faster with same ticket numbers (since previous user would get error message that checkout cannot be completed since someone else purchased that same ticket). Good values for ticket reservation is 3-5 minutes while Hold Stock should be 1 minute lower than ticket reservation time (after Hold Stock time passed order will be canceled). Hold Stock can be set in WooCommerce Settings > Products > Inventory and ticket reservation can be set in WooCommerce Settings > Lottery section.

Lucky Dip Button

Lucky dip button is useful when you have a lot of tickets but you do not use “randomly assign ticket number” option and you want to make users ticket selection easier but still retain option that user can select their own numbers manually. Feature has to be enabled in WooCommerce Settings > Lottery > Show lucky dip button – there is also option to enter quantity “Use qty with lucky dip button”.

Pick Number table with Lucky Dip

You can also use shortcode shortcode for lucky dip with quantity – [lottery_lucky_dip_buton qty=”5″ label=”buy 5 tickets”] and check this useful code snippet https://pastebin.com/0itq7wU8 which adds buy 5 tickets button next to the lucky dip form.

In WooCommerce Settings > Lottery Tab

you need to enable Lucky Dip button feature

Manual Winning Number Picking

Manual winner pick is useful when you use 3rd party for generating winning numbers like national lottery or service like random.org. Once lottery is finished winners will not be announced until you enter winning number in backend. Main difference between automatic winner selection by plugin itself and manual winner picking is that plugin will always determine winner in case min tickets limit is reached and lottery will have winner. With manual picking winner it is possible that lottery will not have winner if no one purchased number that is winning number.

Backend form to manually enter winning numbers for lottery (useful when you use national lottery number or service like random.org)

Question / Answers

When you want to have skill based competitions you can use this feature to set question and provide range of answers which users can select. You can allow only correct answers or let user answer anything they want but in case of incorrect answer remove that particular ticket from draw. You can have question in form of image, see FAQ item no 39. If you do not allow wrong answers when having manual pick winner enabled you will need to make sure that winning number has selected correct answer.

Backend form on Edit Lottery page to enter Question / Answers
Question / Answers frontend – answers can be also displayed as dropdown menu

Export participants CSV / Excel

Lottery history block has option to export data in CSV / Excel. With button “Column visibility” you can select user details like phone number, address, etc (if user has entered that info during checkout).

Export lottery ticket and order data to CSV / Excel

Instant Win Numbers

Instant Win is option to give away some smaller prizes before lottery finishes. Basically if someone picks right number that user becomes entitled to instant win prize defined by website owner. User with correct number will find out about instant win only when order has completed or processing status which means that order has been paid for. We have also tutorial with some explanations regarding instant win numbers here. Instant winners will receive email notification about the instant win prize once payment clears for order (and numbers are right ofcourse). See screenshot here how we display instant win numbers in frontend for clients.

Instant Win feature – Edit Lottery (backend form)
Lottery info section in frontend with information about instant wins

Basically you can announce that you have 10 instant win prizes and not display numbers in frontend if you enabled users to pick their number or you can announce prizes and numbers and set “randomly assign ticket number” so user gets random number in which case numbers displayed in frontend will not be a problem since everyone will get random number for lottery. Instant winner is published only when order is completed. There are also email notifications for admin and winner:

Instant winner info can be shown in product TAB or using [lottery_instant_winners_tab] shortcode. If you use shortcode you can disable TAB in Woo Settings > Lottery. More about instant win option and security considerations – click here.

Entry Lists

This is page where you list all lotteries and its participants. To enable entry lists create one new page called for example “Entry Lists”, go to WooCommerce Settings > Lottery and scroll down to dropdown labeled “WC Lottery Entry Page” then in dropdown select newly created page. This feature is WooCommerce Lottery feature but we are mentioning it here because it could be useful and many clients asked for it. You can see entry list page here.

Automatic Relist

This is implemented as section in edit lottery page. You can set relist conditions (relist if lottery fails or even if it is success), time after which lottery will be relisted and duration of relist. To make things more convenient old lottery data can be saved as CSV file for later access. For relist to work you will need to setup cronjob https://domain.com/?lottery-relist=true

Automatic relist section in Edit Lottery page

More info about auto relisting is in FAQ item no 40. For failed lotteries there is Extend option which will retain all particinapts but will extend end date for lottery, please consult documentation for more info.

Instant Win feature for WooCommerce Lottery with Pick Number Mod addon – security considerations

update 3rd October 2024 – Please make sure to use latest version of Pick Number (which is v2.4.6.2) two important security fixes were made in order to prevent potential arbitrary number selection based on published numbers in frontend.

Since version v2.3.0 of Pick Number Mod addon we have introduced instant win feature as per requests from our clients. After that introduction we also received some inquires where clients ask of possible flaw where users who have pending order can see ticket number. Fact is that user indeed can see ticket number but cannot know until order is in processing or completed status that those numbers are instant win numbers unless you published that information.

We have also setting in WooCommerce Settings > Lottery tab called “Hide ticket numbers until order has been paid” (this setting is useful for lotteries that have instant win numbers, for example when you use randomly assign number and publish instant win tickets on your single lottery page – setting is enabled by default) which is useful if you use randomly assigned number option and you publish info about instant win numbers in frontend.

If someone is getting too much instant wins it could mean that they used exploit for dated WordPress version you use or for some plugin / theme. This means user can get administrator access to wp-admin and it means your security is breached. You need to get someone from your hosting support to check and clean your site, update everything to latest versions and install security software and use application firewall (easiest way to do that is via CloudFlare web app firewall.

In our opinion malicious requests should be filtered out prior reaching WordPress (CloudFlare firewall, mod_security, etc). Most trivial thing you can do is to implement password protection for /wp-admin/ directory.

We have introduced encryption for ticket numbers in database so they are not in plain text format but anyone who can access your wp-admin as administrator user can access those data.

Black Friday / Cyber Monday 2022 coupon code

We are running Black Friday / Cyber Monday promo until 1st Dec 2022 – all items in our store are 25% off. You can use coupon code cyber2022 to get the discount applied once you are on checkout page.

Our current versions for plugins: WooCommerce Lottery v2.1.9, Woo Lottery Pick Number Mod addon v2.3.0, Woo Simple Auctions v2.0.18, WooCommerce Group Buy & Deals v1.1.26, WooCommerce Simple Storewide Sale v1.18. If you don’t have those versions we recommend you to update.

Using WooCommerce REST API with our plugins

WooCommerce REST API is useful for creating headless shops and automating processes . Here we will show couple of examples where you can see how our plugins can be managed via Woo REST api like how to retrieve product data and how to create new auction product using WooCommerce REST API v3.

First you will need to go to WooCommerce Settings -> Advanced and enable REST API then create client key and secret, then assign permissions you need for your use case.

Once this is completed go to https://github.com/Automattic/wp-rest-php-lib and download their PHP lib. Extract so you have folder structrue something like https://www.yourwebsite.com\api\WooCommerce and in \api\ create test_api.php file. Their lib is intented to be used with Composer and we advise that but in the example we will not use Composer in order to have as less prerequisites as possible.

Code example for WooCommerce REST API – listing auctions and creating new auction product

Since WooCommerce REST API can retrieve custom product types we will use type parameter to retrieve all auction products available in our Woo product list. Copy paste into your test_api.php file following code:

<?php

include_once(__DIR__ . '/WooCommerce/HttpClient/BasicAuth.php');
include_once(__DIR__ . '/WooCommerce/HttpClient/HttpClient.php');
include_once(__DIR__ . '/WooCommerce/HttpClient/HttpClientException.php');
include_once(__DIR__ . '/WooCommerce/HttpClient/OAuth.php');
include_once(__DIR__ . '/WooCommerce/HttpClient/Options.php');
include_once(__DIR__ . '/WooCommerce/HttpClient/Request.php');
include_once(__DIR__ . '/WooCommerce/HttpClient/Response.php');
include_once(__DIR__ . '/WooCommerce/Client.php');

use Automattic\WooCommerce\Client;

$woocommerce = new Client(
	'https://www.yourwebsite.com',
	'your_client_key',
	'your_client_secret',
	[
	   'wp_api'  => true,
	   'version' => 'wc/v3',           
	]
);
$data = [
    'type' => 'auction' // get all auction products
];
print_r( $woocommerce->get( 'products', $data) );

Examples how to get and create auction products (for WooCommerce Simple Auctions) using WooCommerce API:

$data = [
    'name' => 'New Auction',
    'type' => 'auction',
    'status' => 'draft', // status can be: draft, published, pending

    'meta_data' => array(
        [ 'key' => '_auction_start_price', 'value' => '7.99' ],             // starting bid
        [ 'key' => '_auction_bid_increment', 'value' => '1.5' ],            // min bid increment
        [ 'key' => '_regular_price', 'value' => '2900' ],                   // buy now price
        [ 'key' => '_auction_reserved_price', 'value' => '2000.0' ],       // reserve price
        [ 'key' => '_auction_dates_from', 'value' => '2022-02-11 00:00' ],  // start date
        [ 'key' => '_auction_dates_to', 'value' => '2022-02-27 00:00' ],    // end date
        [ 'key' => '_auction_proxy', 'value' => 'no' ], // proxy auction, yes | no   
        [ 'key' => '_auction_sealed', 'value' => 'no' ], // sealed auction, yes | no        
    ),

    'description' => 'This is sample auction added via WooCommerce API',
    'short_description' => 'Sample api auction.',    
];


print_r( $woocommerce->post( 'products', $data ) );

Examples how to get and create lottery products (for plugin WooCommerce Lottery) using WooCommerce API:

$data = [
    'type' => 'lottery' // get all lottery products
];
print_r( $woocommerce->get( 'products', $data) );
$data = [
    'name' => 'New Lottery',
    'type' => 'lottery',
    'status' => 'draft',    // status can be: draft, published, pending

    'meta_data' => array(       
        
        [ 'key' => '_min_tickets', 'value' => '30' ], // min number of tickets needed
        [ 'key' => '_max_tickets', 'value' => '100' ], // max number of tickets
        [ 'key' => '_max_tickets_per_user', 'value' => '100' ], // max per user (optional)
        [ 'key' => '_lottery_num_winners', 'value' => '1' ], // number of winners        
        [ 'key' => '_lottery_price', 'value' => '20.99' ], // ticket price
        [ 'key' => '_lottery_sale_price', 'value' => '15.99' ], // sale price (optional)
        [ 'key' => '_lottery_dates_from', 'value' => '2022-02-11 00:00' ], // start date
        [ 'key' => '_lottery_dates_to', 'value' => '2022-02-27 00:00' ], // end date        
    ),
    'description' => 'This is sample lottery added via WooCommerce API',
    'short_description' => 'Sample api lottery.',
    
];


print_r( $woocommerce->post( 'products', $data ) );

Examples how to get and create group buy / deal products (for plugin WooCommerce Lottery) using WooCommerce API:

$data = [
    'type' => 'groupbuy' // get all group buy / deal products
];


print_r( $woocommerce->get( 'products', $data) );
$data = [
    'name' => 'New Group Buy',
    'type' => 'groupbuy',
    'status' => 'draft',    // status can be: draft, published, pending
    
    'meta_data' => array(       
        
        [ 'key' => '_groupbuy_min_deals', 'value' => '30' ], // min deals sold needed
        [ 'key' => '_groupbuy_max_deals', 'value' => '100' ], // max deals sold
        [ 'key' => '_groupbuy_max_deals_per_user', 'value' => '100' ], // max per user (optional)
        [ 'key' => '_groupbuy_price', 'value' => '10.99' ], // deal price
        [ 'key' => '_groupbuy_regular_price', 'value' => '21.99' ], // regular price
        [ 'key' => '_groupbuy_dates_from', 'value' => '2022-02-11 00:00' ], // start date
        [ 'key' => '_groupbuy_dates_to', 'value' => '2022-02-27 00:00' ], // end date
        
    ),
    'description' => 'This is sample group buy added via WooCommerce API',
    'short_description' => 'Sample api group buy.',
    
];


print_r( $woocommerce->post( 'products', $data ) );

How can you limit number of produtcs retrieved? You can use per_page attribute in $data like below (search, offset, order, order by etc options are available useful for paging and filtering) – all available parameters are listed here https://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-products:

$data = [
    'per_page' => 1,    // api will return only 1 auction product
    'type' => 'auction'
];


print_r( $woocommerce->get( 'products', $data) );

Complete REST API documentation can be found on https://woocommerce.github.io/woocommerce-rest-api-docs/. If you have additional questions on how WooCommerce REST API works with WooCommerce Simple Auctions, WooCommerce Lottery and WooCommerce Group Buy please open ticket here or contact us.