The Scratch Cards add-on allows you to create your own virtual scratch cards that your users can purchase using myCRED points. It is important to remember that this plugin is not a design tool! While the plugin provides you with a few pre designed sets, it is up to you to design your cards if none of the built-in ones is to your liking!
Scratch Cards consists of two sets of images. First you have the “Background” image which is what shows what, if anything, a user wins, and a “Cover Image” which is what the user “scratches”.
Scratching is done via the mouse or on mobile devices using your finger. As you “scratch”, part of the cover image is deleted, which in turn reveals the background image. Once a minimum percentage of the image is “scratched” the entire cover image is removed, revealing the result. Once this occurs, the plugin will check if the card is a “winner” and if it is, request myCRED to pay the user the winning amount. At the same time the scratch card is deleted in your database, which prevents the user from scratching it again.
Scratch Cards come in a set. In fact, when you create a scratch card you are essentially creating a set of cards. Each set has it’s own design, size, name and winning cards.
For each set, you can select to charge and/or payout using different point types (if you have more than one) and you can set unique messages / log templates for each one.
Once a set is “Activated” it is available for purchase immediately. You can however select to put a set “On Hold” in case you want to stop sales temporarily or destroy a set (trashing it). Once all cards in the set has been sold, the set becomes “Sold Out” and will no longer offer any purchases. However, if a user has bought a card and not yet scratched it, they will still be able to do so, until you destroy the set. Once a set is destroyed, all cards in the database are deleted, including unscratched ones.
Each set can be set to enforce a maximum number of purchases a user can make per day. This will only limit purchases. If user has unplayed cards, they will still be able to play these cards. They will however not be able to make a new purchase if they hit their limit.
If a user hits their limit and don’t have any cards to play, the “Limit Message” will be shown to them.
You can also set this to zero, in which case a user can buy as many cards as they can afford.
When you view the mycred_scratch_cards or mycred_all_scratch_cards shortcode, the plugin will check if you have any purchased but not yet scratched cards. If you do, you will be shown the option to “Play” these cards. If you can afford to buy a card you also are given this option.
When you push “Play” or “Buy”, the plugin will request a new card from the database. If you have no cards already, one is selected randomly from the available cards. The card is marked as belonging to you (so no one else gets the same card) and then the card design is put together, before showing it to you.
Once you finish scratching the minimum required percentage of the card, the card is marked as “scratched” in the database and if the card is a winner, you get paid out. If this attempt to get a card marked as “scratched” fails, (for example lost internet connection or the site is down) the user will be asked to scratch the card again when the website / internet connection is back again and try marking it “scratched” again. The plugin will only payout a win maximum once per card. So there is no risk of a user getting paid twice.
When a user buys a card, one is selected at random from the database. This random process is done by default using the MySQL rand() function. This function can on large installation cause a heavy load on your database, and some web hosts have selected to disable this function to save on server performance.
If this function is disabled, cards will not be drawn at random but in order they were inserted. This means that users will always start buying “No Win” cards!
It is for this reason very important that you check with your host if the MySQL rand() function is blocked on your server. If it is, or if you prefer not to use this functions, you can select to use a PHP random script instead. To do this, go to the “Scratch Cards” > “Settings” page in your admin area and check the first checkbox. Remember to save!
The PHP random script uses the mt_rand() function to randomly select an id from an array of ids. At no time during this selection does the script know what card is selected besides the cards unique ID.