WooCommerce Lottery

Last updated: 29th Mar 2023.

Thank you for purchasing our plugin. If you have any questions that are beyond the scope of this help file, please feel free to email via contact form here. Have fun!

Change Log

Warning:

Always backup WordPress database and files before updating to latest version, just in case!

Note:

If you override default and use custom templates in your_theme/woocommerce/ you need to make sure that templates are updated with those in plugin_dir/templates/ - otherwise some new features might not show up on the site.

** Version 2.1.10 **
- Fix: sleep() check
- Fix: datetime format for lottery_winners shortcode
- Fix: warnings
	
** Version 2.1.9 **
- Add: filter woocommerce_lottery_max_purchase_quantity
	
** Version 2.1.8 **
- Fix: cache
- Fix: small bugs

** Version 2.1.7 **
- Fix: Dokan double ticket problem
- Add: filter woocommerce_lottery_entry_list_perpage
- Fix: entry list compatibility with Yoast SEO
- Fix: entry list compatibility with RankMath SEO
	
** Version 2.1.6 **
- Fix: cache problem

** Version 2.1.5 **
- Fix: duplicate queries
- Fix: JS quantity bug
- Add: login at later stage of checkout
	
** Version 2.1.4 **
- Fix: lottery stuck if there is on hold order for lottery
- Fix: template bug with future lotteries
- Fix: show additional custom content in email notifications
- Fix: caching and future lotteries
	
** Version 2.1.3 **
- Fix: translations
- Fix: lottery winners shortcode problem
- Add: lottery winners shortcode paging
	
** Version 2.1.2 **
- Fix: potential performance issue
- Fix: meta fields caching fix
- Fix: fatal error
	
** Version 2.1.1 **
- Fix: potential cache issue
	
** Version 2.1.0 **
- Add: entry lists
- Fix: lost password redirect
- Fix: checkout redirect
- Fix: stock decimals when cancelling order
	
** Version 2.0.6 **
- Fix: problem if MySQL auto_increment_increment variable has value bigger than 1
- Fix: show tickets available above progress bar
- Fix: performance

** Version 2.0.5 **
- Fix: performance
- Fix: stock input
	
** Version 2.0.4 **
- Add: show SKU
- Add: tickets sold label above progress bar (or tickets available)
- Fix: don't show future lotteries if this option is enabled in lottery settings

** Version 2.0.3 **
- Fix: participate button tax display issue
- Fix: sourceMappingURL not found 
- Add: fully tested with PHP8 and WooCommerce 5.0

** Version 2.0.2 **
- Fix: small bug
- Fix: countdown timer JS issue

** Version 2.0.1 **
- Add: [vendor] tag for email notifications recipients
- Fix: small bugs
	
** Version 2.0.0 **
- Add: Elementor support
- Add: updated POT translation file
- Fix: lotteries winners shortcode problem

** Version 1.1.27 **
- Fix: updating ticket quantity in cart
- Fix: max tickets number setting cannot be 0
- Fix: typos
- Add: lotteries shortcode now with paging and attributes like products WooCommerce shortcode
- Add: winner link in edit lottery leads now to user profile instead refreshing current page

** Version 1.1.26 **
- Fix: showing time left when it was disabled (in widgets)
- Fix: performance
- Fix: fatal error sometimes when Elementor is enabled
	
** Version 1.1.25 **
- Fix: reset stock when enabled "Remove ticket numbers from orders with wrong answer."
- Fix: wrong directory name
- Fix: version numbers

** Version 1.1.24 **
- Fix: decimal separator bug
- Fix: tickets per user limit in frontend
- Fix: tax ignored in display price
- Fix: required fields when publishing lottery
- Fix: wrong message for future lotteries in widget
- Add: do not mix lotteries with regular products disabled by default
	
** Version 1.1.23 **
- Fix: Add class variables for removing hooks
- Fix: Button change price with qty
- Add: Add hook lottery_product_save_data
- Fix: Added failed message with reason for user on single lottery page
- Fix: Changing order status after relist and delete log bug

** Version 1.1.22 **
- Add: extend lottery end date with all previously sold tickets (ticket rollover for failed lotteries)
- Add: delete logs on lottery relist
- Add: lottery failed notification for participants
- Fix: sold individually option problem

** Version 1.1.21 **
- Fix: Updating product lookup table
- Fix: Small bug when cancelling order
- Add: Added WPMU support

** Version 1.1.20 **
- Fix: stock problem with free lotteries
- Add: Added argument for future lotteries to ending_soon_lotteries shortcode [ending_soon_lotteries per_page='12' columns='4' order='asc' future='yes' ]
- Fix: Automatic partial refund
	
** Version 1.1.19 **
- Fix: Future lottery shortcode
- Fix: Dateformat fix for widgets and shortcodes
- Fix: Datetime format taken from WP settings for timestamp in lottery history tab
- Fix: Plain email template lottery_finish.php

** Version 1.1.18 **
- Fix: Adding lotteries to my lotteries field
- Fix: Changed ajax function call for deliting logs
- Add: New action on ajax deleting log 'wc_lottery_delete_participate_entry'
	
** Version 1.1.17 **
- Fix: Max ticket per user bug

** Version 1.1.16 **
- Fix: Removing lottery from users my lotteries list when deleting log in admin
- Fix: Sending emails after lottery is closed bug for manually picked winners
- Fix: Enable login at checkout for lottery with no max ticket per user

** Version 1.1.15 **
- Fix: my_lotteries shortcode problem with relisted lotteries
- Fix: Problem with old meta when duplicating lottery product
- Fix: Critical error on refund for php > 7
- Fix: Refund notice for payment that does not support automatic refund
								
** Version 1.1.14 **
- Fix: Admin relist info in lottery history metabox
- Fix: Price is not set to 0 if price input is left blank
- Add: Redirection to previous page after login
									
** Version 1.1.13 **
- Fix: Added message for nonlogged users on my_lotteries shortcode
- Add: finished_lotteries shortcode
- Fix: Replaced woocommerce_get_page_id with wc_get_page_id
								
** Version 1.1.12 **
- Fix: Translation bug with "You have bought %d tickets for this lottery!" string
- Fix: Shortcode bug when option "Show finished lotteries" is false 
- Fix: lang domain fix
								
** Version 1.1.11 **
- Fix: Relist future lotteries bug
- Fix: plural translation problems in message "you have bought..."
- Add: ability to clear on hold orders that are preventing lottery to end
- Add: Filters woocomerce_lottery_history, woocommerce_lottery_winners, woocommerce_lottery_participants
	
** Version 1.1.10 **
- Fix: WPML compatibility bug
- Fix: Problem when 3rd party plugin removes product object
- Fix: Plural translation problems

** Version 1.1.9 **
- Fix: removed lottery column from WooCommerce orders view
- Fix: bug with multiple winners

** Version 1.1.8 **
- Fix: shortcodes problem when "do not mix" enabled in settings

** Version 1.1.7 **
- Add: Limit ticket by lottery in the quantity selector
- Fix: Change name of js function from countdown to wc_lottery_countdown
- Fix: Countdown format bug
- Fix: Changed admin dashboard widget
- Fix: Php notice in backend WooCommerce email settings
- Fix: Progress bar on firefox
- Add: Compact countdown option
- Fix: Bug with filtering lotteries from shop page
- Fix: Bug with title on lotteries base page

** Version 1.1.6 **
- Fix: Bugs in admin backend filter product on PHP v7.1.x
- Fix: Future lottery not showing once it starts

** Version 1.1.5 **
- Fix: Sending multiple "no luck" emails to same user
- Fix: Stock status not changing after lottery relist

** Version 1.1.4 **
- Add: Added sale price for lottery products
- Fix: Bug not creating log table on activation

** Version 1.1.3 **
- Fix: Filtering lotteries in admin area
- Fix: Featured lotteries shortcode bug
- Fix: Lotteries shortcode bug
- Fix: WooCommerce Recently Viewed lotteries widget bug
- Fix: Virtual and downloadable chackbox bug

** Version 1.1.2 **
- Fix: Featured widget bug
- Fix: Typos
- Fix: Check for minimal PHP and WordPress versions to avoid fatal errors on activating plugin in unsupported environment

** Version 1.1.1 **
- Fix: query problems with WooCommerce >= 3.0.0
- Fix: WPML bug when using secondary language without main language

** Version 1.1 **
- Fix: WooCommerce >= 3.0.0 compatibility
- Fix: Delete entry when order is cancelled
- Fix: Multiple failed emails to same user
+ Add: manual lottery relist feature
+ Add: Added [vendor] tag for sending mail to lottery author/vendor on lottery_fail, lottery_finished -
useful with multivendor plugins like WC Vendors or if you want to send email to lottery author or owner in case of multivendor site

** Version 1.0.8 **
- Fix: Shortcode lotteries_winners not showing winners when item is out of stock

** Version 1.0.7 **
- Fix: Add to cart button text

** Version 1.0.6 **
- Fix: JS bug in frontend

** Version 1.0.5 **
+ Add: Shortcode for displaying lottery winners [lotteries_winners]
- Fix: Issue with wpml language switcher

** Version 1.0.4 **
- Fix: Bug with Wp_Meta_Query

** Version 1.0.3 **
- Fix: Check if user is logged only for lottery products
- Fix: Small language changes
- Fix: Problem with language data

** Version 1.0.2 **
- Fix: Problem with translating counter labels
+ Add: option to instantly finish lottery when maximum number  of tickets was sold

** Version 1.0.1 **
- Fix: Small bugs
+ Add: Refund feature for lotteries that failed due minimum participants limit

** Version 1.0.0 **
- Initial release

Overview and Features

WooCommerce Lottery

WooCommerce Lottery is a extension for popular WooCommerce plugin and extends it with lottery features. We tried to make it easy to use but also to include all lottery features. With this plugin you will get a powerful lottery solution for WordPress which is easily setup and customized.

With WooCommerce Lottery plugin you can setup WordPress lottery website and start lotteries in less than 30 minutes (assuming you have payment processor account ready). WooCommerce Lottery plugin integrates seamlessly with WooCommerce and no special knowledge is needed (same level like for standard WooCommerce usage).

Overview and Features

  • Works with latest WordPress and latest WooCommerce and previous versions
  • Seamless integration into WooCommerce via its hooks
  • Elementor support from v2.0 - view our tutorial
  • You get new type of WooCommerce product type – lottery
  • Define number of lottery winners – 1 or more
  • Lottery ticket price can be zero, works with TeraWallet / Credit payment gateways
  • Winners / users can win single prize or multiple prizes
  • Option for refund tickets with single click if lottery has failed
  • Option for instantly finish lottery if max number of tickets was sold
  • Option for extending lottery end date with all previously sold tickets (ticket rollover for failed lotteries)
  • Manually relist lottery and option to delete previous lottery data after relist
  • Manually extend lottery end date for failed lotteries (keeps lottery participants)
  • Define minimum and maximum number of tickets available
  • Define max tickets per user, number of winners and multiple wins per user
  • Set start and end time for lottery
  • Entry lists (see demo) for lotteries, tutorial
  • Easily control how you want to display lotteries – along with other items or on separate page
  • Widgets with ending soon, future, latest / recent, featured, recently viewed, my lotteries and random lotteries
  • Email notifications (with editable templates) for lottery win, fail, finish, no luck, lottery fail for customers, lottery extended
  • Lottery product has lottery icon (label) on thumbnail
  • Product single page has new tab “Lottery History”
  • User has “My lotteries” page where one can see active lotteries and won lotteries – page with shortcode [my_lotteries]
  • Lottery filtering in product list (wp-admin)
  • Lottery product has icon which describes different lottery status: active, finished, finished and paid, failed (wp-admin)
  • Plenty of shortcodes including shortcode to show my lotteries for logged in user
  • Make lottery from any type of WooCommerce product – simple, virtual or downloadable products
  • Manually delete any ticket via WooCommerce order management – deleting order deletes ticket
  • Login at later stage of checkout (guest checkout)
  • WPML compatible, translation files
  • works with WooCommerce API - read tutorial
  • Enable users to create and submit their lotteries / competitions / lucky draws and you as site owner can charge a fee (via multivendor plugin like Product Vendors or Dokan)
  • Cronjobs required – if your host does not support 1 minute cronjobs you can use 3rd party cron service like easycron - plugin works with WP cron too
  • Pick ticket numbers addon / extension avaliable (additional fee) - check demo and admin screenshot - purchase it here - features included: ticket number pick (ticket number grouping in tabs) with option to randomly assign numbers without picking each number, instant wins (with CSV import for easy setup lot of instant win numbers), question / answers, manually pick winning number(s) - when you want to use 3rd party lottery drawing option like national lottery numbers, service like https://www.random.org/ or your own random number generator, manually add ticket numbers for user (postal entries)

Installation

Source: https://codex.wordpress.org/Managing_Plugins#Installing_Plugins

You can install plugin via WordPress "Add New" plugin - to do that download zip with plugin only (installable WordPress files), click add new and that's it. In case you do not have permissions to upload to plugins/ directory you will need FTP login info and upload plugin via FTP. Make sure to install WooCommerce before you activate WooCommerce Lottery plugin.

screenshot

Alternative setup. After downloading WooCommerce lottery plugin, extract plugin zip and upload it to your plugins directory - wp-content/plugins/ folder of your Wordpress installation. Since this is extension for WooCommerce you need to install WooCommerce before activating the plugin. WooCommerce plugin which can be downloaded here.

If you need help installing Wordpress see the link here

Note:

Once you installed and activated WooCommerce go to WooCommerce > System Status and make sure that you don't have red colored errors (specially for WP memory limit). Make sure to enable inventory management in WooCommerce!

WooCommerce Lottery plugin uses cronjobs and you have to setup one cronjob:

  • every minute: /usr/local/bin/curl --silent http://www.your-domain.com/?lottery-cron=check

Here is screenshot of cronjobs page and setup in DirectAdmin control panel

screenshot

More details about cronjobs can be found by googling "how to add cronjob in cPanel / DirectAdmin". If you don't know how to add cronjob the best and the easiest way is to email your hosting support to do it for you (purpose of hosting support are tasks like helping you with cronjobs, our support helps you with plugin issues - cronjobs are hosting related task / issue).

Why do we use and suggest real server cronjobs? Plugin will work with WP cron but disadvantage of WP Cron is that it will trigger only when someone visits your website, if there is no site activity for say 3 days, the cron will not be triggered for 3 days but next time you have visit on your website. Real server cronjobs do not depend on website activity and are run in fixed defined intervals as set in cronjob config.

Note:

If your hosting company does not support one minute cronjobs we suggest that you move your website to more serious hosting company or use service like EasyCronOur plugin is meant to be used as ecommerce solution which will / should earn money so we suggest you to invest in proper hosting (which at least supports one minute cronjobs).

Why do we use cronjobs? - WordPress cronjob is run on every visit (page load), it's fine for small and not so busy websites. But sometimes you do not have enough hits (visitors) and lottery will be finished when visitor loads page (and cronjob) instead on its end timestamp. User visit which triggers cron will be taking some time to process everything so it is better that cron does that in background than leave user waiting cron tasks to finish. That's why we use real cronjobs - to make sure your lotteries will end on time. Also on busy websites you need to turn off WordPress cron and create cronjob for it to avoid cron being loaded on every hit and generating performance penalty.

Install WooCommerce Sample Data:

Source: https://woocommerce.com/document/importing-woocommerce-sample-data/

WooCommerce comes with sample data which you can import, dummy data file is /wp-content/plugins/woocommerce/dummy_data.xml Sample data does not include lottery products, it provides data to populate WooCommerce store with some demo products, ratings, comments, etc. Steps to import demo data to your WordPress WooCommerce site:

  1. Go to Tools > Import
  2. Select XML dummy content file from /wp-content/plugins/woocommerce/dummy_data.xml
  3. Click Upload file and import
  4. Assign posts to an exitsting account
  5. Check Download and import file attachments
  6. Click Submit and wait until WordPress finish downloading attachments and importing content

Warning:

Importing dummy data can take some time, specially on slow Internet connections. Be patient and do not close or refresh browser tab until import operation is completed.

Quick Lottery Setup

Setting up new lottery is easy:

  • make sure all steps from Installation are done (WooCommerce installed, plugin enabled, cronjobs set)
  • go to Products => Add Products
  • add title, description, images, featured image, select category - all things you do when adding regular product
  • in Product Data dropdown menu select Lottery
  • you will see new tab in left menu named Lottery, see screenshot:
    screenshot
  • fill all details (they are self explainable)
  • set lottery duration by setting start and end date
  • publish product (lottery)

In WooCommerce Settings -> lottery you can set lottery base page where you display a list of all lotteries (archive page). Please see note if you want to set your lottery page as home page. If you have lottery only website there is no need to setup lottery base page, you can use WooCommerce shop page.

When creating new lottery make sure to create it via add new product rather than cloning product or existing lottery. If you clone / copy existing lottery all custom meta will be cloned. That means if lottery has finished, meta field that defines finished lotteries will also be cloned and lottery will always look like it is finished. To create new lottery from existing one use relist feature.

If you need to trash / cancel order please go to edit order, cancel it by changing order status and then trash it. That is proper way to do order cancellation for lotteries, otherwise (if you just trash order) log data can be left in lottery log tables.

Note:

Make sure that when setting up lottery site your lottery base page is different than your home page. If you need lotteries on home page use shortcodes or widgets to display them on your home page.

Changes in WooCommerce

After you activate WooCommerce Lottery plugin couple new options will appear:

  1. WooCommerce product has new tab in Product data block called Lottery
  2. Product list has column with lottery status icons
  3. Product list filter has lottery filtering
  4. Single product page in wp-admin has new block named "lottery" where you can see lottery history
  5. Orders list has column with lottery icon to easily see which order is from lottery
  6. WooCommerce settings - new tab called Lottery
  7. WooCommerce settings - Emails - new items: lottery win, lottery fail, lottery finish, lottery no luck email templates
  8. New widgets: future lotteries, ending soon lotteries, featured lotteries, latest lotteries, recently viewed lotteries, my lotteries, random lotteries
  9. New shortcodes

New WooCommerce product type lottery:

screenshot

Lottery edit product screenshot (with Pick Number Mod addon for WooCommerce Lottery):

screenshot

Plugin Options

Settings are mostly self explainable, please see screenshot below. You can enable or disable showing past and future lotteries, another useful setting is whether to mix regular products with lotteries or just show lotteries on separate page (defined via WC Lottery Base Page dropdown option, see screenshot).

WooCommerce lottery settings without pick number mod addon

Screenshot above includes available settings for Pick Number Mod addon for WooCommerce Lottery (options listed under title "Lottery pick number and answer" are related to Pick Number Mod addon).

On screenshot below you can see how product list with lotteries looks like. Lottery status icon colors: red - active lottery, orange - finished, red - failed. Column “product type” (with icons) on the products admin screen in WooCommerce was removed in version 3.4.0 and in order to see icons you need to install WooCommerce Product Type Column plugin. See FAQ item no 30.

screenshot

If lottery has failed, in product / lottery details you will see option to "Refund" or buttons to "Relist" or "Extend" lottery. "Refund" enables you to refund all tickets to participants if your lottery rules require that and your payment gateway supports refunds. "Extend" allows extension of end date keeping all current participants (and their orders) while "Relist" resets lottery and it starts with 0 participants. Only failed lotteries can be extended (or refunded) while all finished lotteries can be relisted. See FAQ item no 32.

screenshot

Once lottery is finished you can view winners on single lottery page or in wp-admin edit product page. Below are screenshots.Beside that you can create my lotteries page for users where you can use this shortcode: show user's lotteries (active lotteries in which user participates and list of user's won lotteries) -[my_lotteries]

screenshot
screenshot

In lottery details block with lottery history entries enables you to view and delete ticket orders, export them to CSV or Excel and view history prior relisting. Check screenshot below. Failed lotteries can be relisted (restarted - meaning participants will be lost) or extended (end date will be changed) keeping all current participants.

screenshot

How does Lottery plugin pick winners (or winning numbers if you use Pick Number addon)?

Winner(s) is / are picked randomly once lottery is finished or you can manually enter winning numbers in case you have Pick Number Mod addon. Plugin uses mt_rand PHP function to randomly pick winners. PHP function mt_rand() which provides solid randomization for this purpose.

If you use WooCommerce Lottery (also with Pick Number Mod addon) and for example you have setup lottery with max 100 tickets and min 50 tickets, then if you sell 55 tickets winner(s) will be choosen between those 55 tickets not all 100 tickets.

With Pick Number Mod addon you can get also different behaviour with enabled checkbox option called "Manual winner picking", meaning that when lottery ends and after you generate randomly winning numbers (or use national lottery numbers or random.org) you will enter numbers in text input field. It is then possible that your lottery could end without winners (if none of participants picked right number(s)).

With Pick Number Mod and question / answers feature enabled winners will be choosen among those with correct answer only. In case you are manually entering winning numbers you will need to be sure that winning number has correct answer - this can be seen in lottery history table block (which you can export to Excel or CSV for easier management).

Shortcodes

Here is a list of all available plugin shortcodes. Some shortcodes accept optional orderby and order attributes.

  • show lottery winners - [lotteries_winners], [lotteries_winners paginate="true" per_page="12" order="desc"]
  • show featured lotteries -[featured_lotteries], [featured_lotteries paginate="true" per_page="12" columns="4" orderby="date" order="desc"]
  • show ending soon lotteries - [ending_soon_lotteries], [ending_soon_lotteries paginate="true" per_page="12" columns="4" order="desc" future="no"]
  • show recent lotteries - [recent_lotteries], [recent_lotteries paginate="true" per_page="12" columns="4" orderby="date" order="desc"]
  • show future lotteries - [future_lotteries], [future_lotteries paginate="true" per_page="12" columns="4" orderby="date" order="desc"]
  • show lotteries (with specific product ID) - [lotteries ids="1,2,3,4,5"] this shortcode supports attributes (pagination and sort) similar to WooCommerce [product] shortcode complete list of options is here
  • show user's lotteries (active lotteries in which user participates and list of user's won lotteries) - [my_lotteries], [my_lotteries paginate="true" per_page="1" show_buy_it_now="true"]
  • show past / ended lotteries - [finished_lotteries], [finished_lotteries paginate="true" per_page="12" columns="4" order="desc"]

Note:

From version 1.1.27 [lotteries] shortcode implements paging and attributes like [products] shortcode in WooCommerce - see list of all available options here. Other shortcodes do not implement those attributes.

FAQ

Here you can find answers to frequently asked questions. Feel free to contact us if you can't find answer to your question.

  1. Can users create their own lotteries? - Basically yes, only users who can add new products can create lotteries. You can use multiple vendor plugin which will allow you to add users who will be able to create products (lotteries). You can use multiple vendor plugin which will allow you to add users who will be able to create lotteries. You can use WooCommerce Product Vendors (there is no frontend submission for lotteries only backend).
  2. Do you use cronjobs? Why do we use cronjobs? - Yes. Please check installation instructions. WordPress cronjob is run on every visit (page load), it's fine for small and not so busy websites. But sometimes you do not have enough hits (visitors) and lottery will be finished when visitor loads page (and cronjob) instead on its end timestamp. That's why we use real cronjobs - to make sure your lotteries will end on time. Also on busy websites you need to turn off WordPress cron and create cronjob for it to avoid cron being loaded on every hit and generating performance penalty.
  3. Where can I edit email templates? - Go to WooCommerce > Settings and click on Emails tab.
  4. Does this plugin work with caching plugins? - Yes, W3TC and WP Super Cache work but we advise no caching for logged in users. For example if page cache is enabled widget recently viewed lotteries will not work. Once user is logged in and there is no caching anymore all widgets will work. You can use CDN and browser caching. Our plugin demo website uses WP Super Cache with page caching and browser caching. All of our plugins have same requirements for caching as WooCommerce - check it here https://docs.woocommerce.com/document/configuring-caching-plugins
  5. Can I make theme with WooCommerce Lottery and sell it on ThemeForest? - Sure, just purchase extended licence and you're good to go. Since the current licenses do not deal with re-selling Items, Envato lets authors to decide whether they grant permission for bundling Items or not. We have the following conditions, and you need to follow them:
    • You cannot redistribute the item "as-is", even if you modify it or you make a derivative version for another platform
    • You cannot offer the plugin as a stand-alone item
    • You cannot include the plugin separately from your theme in the download package
    • You cannot provide an Item Purchase Code for your customers - Since Envato doesn't have a "multi-use" or transferable license, your customers are not entitled to receive an Item Purchase Code with your theme and use the plugin separately from your work.
    • Updating the plugin is your own responsibility
    • Since your customers cannot receive updates from us, you need to handle this on your own
    • You need to handle related support requests after your customers or you can instruct them to buy regular licence and ask us for support directly via our CodeCanyon profile (we cannot provide free support for your customers)
  6. I can't do anything because I get "out of stock message"? - Lottery plugin needs inventory / stock to be enabled. If you have problems all issues should be fixed by upgrading to WooCommerce Lottery v1.1.6
  7. How can I update plugin with new version? Is auto updating possible? - We suggest you to install Envato Marketplace (installation instructions can be found on plugin's url) plugin for auto update plugin and themes purchased on Envato. Setup is easy. Manual updating can be done by downloading new version of plugin and overwrite old files with new ones or deleting old plugin and installing new one. If you have Pick Number Mod addon login to https://wpgenie.org/my-account/downloads download latest ZIP, then remove old plugin and upload new plugin (ZIP).

    Note:

    If you have modified plugin files (templates) then you need to be careful when updating so you don't overwrite changes you made and that templates are inside child theme or theme woocommerce/ template folder.

  8. Does WooCommerce Lottery work with WordPress import / export tools? - Yes, you can export and import lotteries with standard WordPress import / export tools that are located in Admin -> Tools menu.
  9. How can I enable user registration on login page? - You need to enable that feature in WooCommerce settings.
  10. I have installed your plugin but images are not aligned, buttons are too small / big, input fields needs to be smaller / bigger, can you help? - In short no.

    It's your duty to modify plugin template to matchyour style and theme. Themes can implement different ways how they customize pages and parts of WooCommerce. We cannot guarantee that our plugin will look same as in our demo for every possible theme out there. Web developing is more than getting a theme and couple plugins, enabling them and deliver web site. Our templates are coded by standards and they adhere to WordPress and WooCommerce template structure. That means that minimal intervention is needed from client side, but sometimes there is no way to avoid template changes. Some themes use similar structure and have minimal interventions in structure and our plugin looks good out of the box and some do not. It's your task as web developer and client who purchased plugin to modify and customize plugin templates to match your own (or client's) needs and styles. This is part of developing a web site. You cannot expect that everything will be perfect for every possible theme and plugin comibation out there or that we will do your job for you as part of support. We support plugin - we do not style and customize client's sites. Thanks for understanding.

    Note:

    Right way to customize plugin's templates is to copy contest of plugin_dir/woocommerce-simple-lotteries/templates/ directory to your_theme/woocommerce/ directory and do modifications there.

    When you ask us for support make sure it's not related to tasks we don't do as part of support:

    - style or customize your theme to do this or that
    - provide support for bugs caused by 3rd party plugins or themes (we can pinpoint that some plugin is problematic)
    - send you CSS or HTML code for modifying html elements

  11. Where can I see winners of the lottery? - Read text and check screenshots in paragraph "Plugin options".
  12. How can I add countdown timer / progress bar on all pages (product loop and product archive) not only on single product page? - You can download and install small plugin for that called WooCommere Lottery Progress Bar in Product Loop.

    We have also code snippets for that https://pastebin.com/gavzf7bz and https://pastebin.com/FBwvXp7N You can use code here or the code below:
    add_action( 'woocommerce_after_shop_loop_item_title', 'wpgenie_show_counter_in_loop', 50 );
    
    function wpgenie_show_counter_in_loop(){
    
    	global $product;
    
    	$time = '';
    
    	if(!isset ($product))
    		return;
    	if('lottery' != $product->get_type())
    		return;
    
    	$timetext = __('Time left', 'wc_lottery');
    
    	if(!$product->is_started()){
    		$timetext = __('Starting in', 'wc_lottery');
    		$counter_time = $product->get_seconds_to_lottery();
    	} else{
    		$counter_time = $product->get_seconds_remaining();
    	}
    
    	$time = ''.$timetext.'
    	
    '; if($product->is_closed()){ $time = ''.__('Lottery finished','wc_lottery').''; } echo $time; }
  13. How winner(s) is picked? How do you pick winners? - Detailed explanation is here
  14. Can users buy tickets for lotteries without signup / register first? - From Lottery version v2.1.5 login at later stage of checkout (guest checkout) is possible. It is enabled by default in settings and can be disabled.
  15. What are custom meta fields for lottery product type (useful for CSV Product Import)?
    
    _lottery_closed
    _lottery_dates_from
    _lottery_dates_to
    _lottery_multiple_winner_per_user
    _lottery_num_winners
    _lottery_participants_count
    _lottery_price
    _lottery_winners
    _lottery_fail_reason
    _max_tickets
    _max_tickets_per_user
    _min_tickets
    _participant_id
    _lottery_wpml_language
    
  16. 3rd party plugin is causing problems? Its developers tell you that we need to fix our plugin? - WooCommerce extensions should be transparent - meaning one extension should work with another without introduction of special code that makes them compatible. Imagine what would happen and how much time we would need to spend if we would have to add a bit of compatibility code for every WooCommerce extension that's out there - we would end up in huge plugin with tons of problems which would be problem to test and debug. That's why we think every plugin developer should stick to WooCommerce coding standards and APIs (they're there for that reason) and not require 3rd party developers to code something into their extensions / plugins so that it could work with theirs.
  17. How can I translate plugin to my language? Do you have translations? - We only maintain english translation. We do not have resources to quality maintain other translations. Here are steps which can help you to traslate plugin or change some strings yourself:
    • you will use file plugins/woocommerce-lottery/languages/wc_lottery.pot to create your translation
    • you need to download and install Poedit https://poedit.net/download
    • download wc_lottery.pot and open it with Poedit
    • do your translations with Poedit
    • when done save wc_lottery-en_GB.po, saving wc_lottery-en_GB.po will create wc_lottery-en_GB.mo
    • you need to upload both files to /wp-content/languages/plugins/ and not to plugin directory because translations will be lost if you update plugin by deleting old one

    In case you need to replace string lottery with competition please contact us to get PO/MO translation files with changed strings.

    Note:

    In filename wc_lottery-en_GB.po suffix en_GB must match your language settings in WordPress, otherwise language will not be loaded. So for example you can have wc_lottery-en_AU.mo, wc_lottery-af.mo or wc_lottery-en_CA.mo, complete list of available suffixes are here https://make.wordpress.org/polyglots/teams/

  18. I want to remove countdown timer on single lottery page, what should I do? To do that just create empty file called lottery-countdown.php in your_child_theme\woocommerce\global\ folder. If you want to modify or edit element from that template you need to copy its content from original template plugins\woocommerce-lottery\templates\global\lottery-countdown.php to modified one which should be also in your_child_theme\woocommerce\global\lottery-countdown.php folder.
  19. When client cancelled order stock is not restored? - Stock has to be restored, otherwise contact us and open support ticket.
  20. Can I manually add winning numbers? Can I enable users to pick ticket numbers? Can I have question - Yes, you will need Pick ticket numbers addon / extension avaliable (for a fee) - check demo and admin screenshot - please contact us for more details via ticket system or email [email protected] - features included: ticket pick option, question / answers, manually pick winning number(s) - when you want to use 3rd party lottery drawing option like national lottery numbers, service like random.org or your own random number generator
  21. What happens with tickets with wrong answer? - When you manually select winner you can select also winner with wrong answer. When winner is selected automatically then tickets with wrong answers will not be taken into draw process.
  22. List of actions and filters - Here is list of all actions:
    wc_lottery_close
    wc_lottery_fail
    wc_lottery_min_fail
    wc_lottery_won
    pre_get_lottery_search_form
    woocommerce_product_options_lottery
    lottery_product_save_data
    woocommerce_lottery_do_relist
    woocommerce_lottery_do_extend
    wc_lottery_participate_added
    wc_lottery_participate_not_added
    wc_lottery_participate
    wc_lottery_cancel_participation
    wc_lottery_cancel_participation_failed
    wc_lottery_delete_participate_entry
    woocommerce_refund_processed
    woocommerce_order_partially_refunded
    woocommerce_order_fully_refunded
    woocommerce_lottery_started
    woocommerce_before_shop_loop
    woocommerce_after_shop_loop	
    woocommerce_email_header
    woocommerce_email_footer
    woocommerce_lottery_before_participate
    woocommerce_lottery_ajax_change_participate
    woocommerce_lottery_participate_future
    woocommerce_before_add_to_cart_button
    woocommerce_after_add_to_cart_button
    

    Here is list of all filters:
    woocommerce__lottery_history_data
    woocommerce_lottery_history_heading
    lottery_history_started_text
    lottery_history_starting_text
    lotery_add_participants_from_order
    lotery_remove_participants_from_order
    woocommerce_order_fully_refunded_status
    woocommerce_lottery_participants
    woocommerce_lottery_winners
    woocommerce_lottery_history
    woocommerce_lottery_participating_message
    get_lottery_search_form	
    woocommerce_lottery_bage
    woocommerce_product_add_to_cart_text
    woocommerce_product_single_add_to_cart_text
    woocommerce_lottery_participating_message
    woocommerce_shortcode_lotteries_query
    woocommerce_shortcode_products_query_results
    widget_title
    time_text
    get_lottery_search_form
    woocommerce_email_footer_text
    woocommerce_quantity_input_min
    woocommerce_quantity_input_max
    
    Typos in actions and filters are ok and work.
  23. Refund feature does not work? How can I tell if my payment gateway supports refunds? If you got this error: "Payment does not support refund" your gateway just does not implement refund feature. Here is link for more infos about how to check if gateway supports refund feature. Keep on your mind that for issuing refund you need to click on refund button in product details, there are not automatic refunds.
  24. How can I create custom query for lotteries? You can use this code:
    // Return active lottery products.
    $args = array(
    	'fields' => 'ids',
    	'post_type'=> 'product',
    	'show_past_lottery' => FALSE,   
    	'tax_query' => array(array('taxonomy' => 'product_type' , 'field' => 'slug', 'terms' => 'lottery')),    
    );     
    	
    // Return past lottery products.
    $args = array(
    	'fields' => 'ids',
    	'post_type'=> 'product',
    	'show_past_lottery' => TRUE,    
    	'tax_query' => array(array('taxonomy' => 'product_type' , 'field' => 'slug', 'terms' => 'lottery')),            
    	'meta_query' => array(
    		array(
    				'key' => '_lottery_closed',
    				'operator' => 'EXISTS',             
    			),
    		),
    );          
    
    $the_query  = new WP_Query( $args );
    
    Also you can check this paste here.
  25. I want to export order(s) data. How can I do that? - There are plugins that allow exporting of various order data as CSV file which you can then import to some other software you use for order management. We can suggest you to use WooCommerce Customer / Order CSV Export or Advanced Order Export For WooCommerce. These plugins work with custom product types which are used in this plugin. There is also option to go to lottery details, scroll down to Lottery history block and literally copy / paste everything to excel or other table calc file.
  26. Can users create their own lotteries like for example on eBay? Can I charge fee for lottery ticket sales published by users? - Yes but you need 3rd party plugin for implementing WooCommerce multivendor / marketplace. Then your users will be able to post lotteries and you can charge fee for their sales. You can use Dokan multivendor plugin which has frontend lottery submissions (you need Business version or Free, Starter, Professional with Dokan WooCommerce Lottery Integration module) or Woo Product Vendors.
  27. Do you recommend any credit / wallet plugin for WooCommerce that works with this plugin? - Yes, you can use TeraWallet plugin which adds new credit payment gateway and works with our plugin just fine. Users or admins can top up wallet credit balance with regular payment gateways or manually.
  28. I'm using pick ticket number mod but do not use tickets only option to manually enter winners. What means number you enter in that case? - When you do not use ticket numbers, number you enter in manual pick is in fact position in array of tickets which is generated when order for ticket is created. Since it is array you can enter 0 which is 1st element from array. Position in participant array is defined by order completed timestamp so orders made earlier will be on the beginning of the array of participants. Base lottery number works same - it just uses mt_rand function to generate number which is then used to choose winner(s).
  29. I'm using pick ticket number mod and I want to know what happens with tickets who have wrong answers? - If you use automatic draw and allow false answers all tickets will get into the draw. If you select "allow only true answers" option then tickets with wrong ones will not get into the draw.
  30. Product type column vanished in Woo product list, how can I get it back? - From WooCommerce 3.4.0 update, Woo 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/
  31. How can I hide usernames in lottery history list? - You need to edit template. First copy template woocommerce-lottery\templates\single-product\tabs\lottery-history.php to your_theme\woocommerce\single-product\tabs\lottery-history.php and edit file in that directory so update doesn't override your changes. Then find and remove / edit lines (or comment them out) 28-39.
  32. I want to relist / extend lottery and keep all current participants? - You can do that using "Extend Lottery" button. Make sure to have latest version of Lottery plugin and once lottery fails (for any reason) you will have both options - to relist it (restart with no participants) and to extend end date keeping all current participants (and their orders). Only failed lotteries can be extended while all finished lotteries can be relisted.
  33. Is there a way when a participant buy the ticket(s) for lottery to make it automatically participate to another one? Is there option when a customer buys a product to make that customer also a participation for a lottery? - No, plugin does not support that feature. However you can issue customer coupon code which they can use to participate in lottery for free, you can use some more advanced coupon code manager like Smart Coupons
  34. How can manually add order and get ticket numbers assigned? Can I add free of charge order? - For ticket numbers you need Pick Number Mod addon for WooCommerce Lottery. You can add order manually from wp-admin like for regular products or you can use "login as user" plugin and go through checkout process as that particular user you want to add order for (if you want to add order for free you will need to create coupon code you can use to discount order).

    We have new tutorial how to manually add order from WooCommerce Orders > Add New - check it here.
  35. How "Use alphabet?" works in Pick Number mod addon? - When enabled your numbers will be partitioned with A-Z letters using parameter "tickets per tab". Example you have 1000 tickets and 500 tickets per tab results is parition A1 - A500, B1 - B500. If you do not set "tickets per tab" or enable "randomly assign ticket number" addon divide max number of tickets with 26 and you will have tickets with all 26 letters (for say 7800 tickets last ticket will be Z300, since 26 letters * 300 numbers give 7800 tickets total).
  36. I want to have orders marked as completed automatically, should I use plugin or? - If you set lottery to be virtual and downloadable it will be marked as completed upon successful payment. You don't need to set file download for downloadable product just leave that part empty. There are also plugins which automatically mark orders as completed.
  37. Can I clone or duplicate lottery product to create new one? - No, lotteries should not be cloned because all custom meta will be cloned too and that can cause issues. You can relist lottery instead. Best way to creatw new lottery is to go add new lottery product from scratch. If you need to automate this please use import tool and consult documentation about custom meta fields (FAQ item no 15).
  38. Lottery accidentally finished and I'm unable to extend it - is there anything I can do to retain all participants and extend lottery end date? - Best would be to refund all users or give them coupon code to enter new lottery for free. Brute force solution (you need to edit values in database!): you can change end date and then remove these custom postmeta for particular lottery product (search by post ID in table wp_postmeta!): _lottery_closed, _lottery_fail_reason, _lottery_winners. Custom postmeta value explanation:

    _lottery_closed values: 1 - fail, 2 - finished

    _lottery_fail_reason: 1 - There were no participants, 2 - The item did not make it to minimum participants
  39. I'm using Lottery Pick Number mod addon and I want to have picture with puzzle instead of question. Is that possible? - Yes it is. Upload picture with your puzzle, add it to question input box using HTML img tag and enter couple of answers marking right one with checkbox. See screeshot below with example code:
    screenshot
  40. I'm using Lottery Pick Number mod addon and I want to auto relist lottery. Is that possible? - Auto relisting is only possible with Pick Number Mod addon. You need to set auto relist parameters and setup cronjob https://domain.com/?lottery-relist=true
    screenshot
  41. How can I create Entry Lists page? - Please read this quick and easy tutorial.
  42. I'm using cache plugin in WordPress with option for object cache - how should I setup it? - If you use object cache you will need to add group wc_lottery to a list of non presistent groups, below is screenshot from W3 Total Cache object cache settings page:
    screenshot
    define( 'WP_REDIS_IGNORED_GROUPS', ['counts', 'plugins', 'wc_lottery'] );
    Other plugins have similar option like https://objectcache.pro/docs/ignoring-groups/ or https://github.com/rhubarbgroup/redis-cache/wiki/Configuration-Options. WP Rocket, WP Super Cache and WP Fastest Cache do not use object cache (only page caching and that should be disabled for logged in users). On some hosting providers it is possible that hosting has set up serverwide object cache (in order to have as much clients as possible on same hardware resources) and if you experience issues you might have to check with your hosting support if something like that is implemented in their hosting enviroment.
  43. How can I sort lotteries in My Account > My Tickets section? - You can use this code snippet https://pastebin.com/6iuzQ2bR
  44. I'm using Lottery Pick Number mod addon and I want to rename ticket numbers to be for example names of football teams: Arsenal, Man Utd, Man City... Can I do that? - Yes, ticket numbers can be renamed using filter. For details please open support ticket.
  45. Does Pick Number Mod addon support instant win number? - Yes, you can define ticket numbers that are instant win numbers (available in Pick Number Mod version v2.3.0). You can download latest version here.
  46. I'm getting fatal error on Edit Lottery > Lottery History block? - Make sure you don't use WooCommerce Upsell Popup pluign. For some strange reason this plugin destroys $product object Edit Lottery and then our plugin cannot access it anymore hence the error.
  47. List of actions and filters for Pick Number Mod addon - Here is list of all actions:
    
    woocommerce_lottery_duplicate_ticket_in_order_found
    woocommerce_after_adding_extra_info
    remove_participants_if_wrong_answer
    woocomerce_before_relist_lottery
    woocomerce_after_relist_lottery
    wc_delete_lottery_history_csv
    wc_lottery_instant_won
    wc_lottery_before_ticket_numbers
    	
    Here is list of all filters:
    
    woocommerce_lottery_participants
    woocommerce_lottery_get_lottery_participants
    woocommerce__lottery_history_data
    woocommerce_lottery_history_heading
    ticket_number_display_html
    ticket_number_tab_display_html
    lottery_history_started_text
    lottery_history_starting_text
    woocommerce_lottery_export_dir_path
    woocommerce_lottery_export_filename
    woocommerce_lottery_export_fields
    wc_lottery_generate_random_ticket_numbers
    lottery_numbers_to_alphabet_number_per_letter
    change_ticket_numbers_to_alphabet
    wrong_answer_display_item_meta
    woocommerce_lottery_my_tickets_endpoint_query_args
    woocommerce_lottery_my_tickets_past_endpoint_query_args
    woocommerce_lottery_entry_list_query_orderby
    woocommerce_lottery_start_ticket_number
    
    	

WooCommerce Lottery

wpgenie plugin

Love this plugin?

This plugin is created by wpgenie. Check out our Envato profile where you can support us by purchasing our plugins, give us feedback and post your ideas and feature requests, ask for support and rate our items. Check out our free stuff.

We do WordPress developing, plugins for WordPress & WooCommerce, eCommerce sites based on WooCommerce, WordPress performance optimization and managed WordPress hosting.