This is the documentation for LemonStand V1, which has been discontinued. You can learn more and upgrade your store here.

LemonStand Version 1 Has Been Discontinued

This documentation is for LemonStand Version 1. LemonStand is now offered as a cloud-based eCommerce platform.
You can try the new LemonStand and learn about upgrading here.

Creating the giveaway page

You should create a page for running your giveaways. There are two options - use a single (shared) page for running multiple giveaways, or create a custom page for a specific giveaway. With the single page approach the giveaway page URL has the following format:

http://example.com/giveaway-page-url/giveaway-code (for example: http://example.com/giveaways/bicycle)

With this approach the giveaway code should be specified in the URL. With the single page approach all giveaway pages look similarly, with different giveaway name and description.

With the individual custom page approach the giveaway code is not required (it is specified in the page code) and the URL looks like follows:

http://example.com/giveaway-page-url (for example http://example.com/bicycle)

Implementing the giveaway page for the both approaches is similar, and the only difference is the way how the giveaway code value is set - from the URL or loaded from a hardcoded value.

Creating the giveaway page

Go to the CMS/Pages page and click Add page button. Enter the page title and URL. On the Action tab select the giveaway:landing action.

Setting the giveaway code for individual giveaway pages

If you are developing a page for a specific giveaway (as opposed to developing a shared page), specify the giveaway code in the Pre Action Code field with the following line:

$this->data['giveaway_code'] = 'bicycle'; // Use your real giveaway code here

If you are developing a shared giveaway page, skip this step.

Outputting the Open Graph tags

Some social networks require Open Graph tags to be added to the page HEAD element. You can output those tags with printing the $giveaway_meta_tags variable value. If you use the page Head Declarations feature in your templates, you can add the following line to the Head Declarations field:

<?= $giveaway_meta_tags ?>

Otherwise you should output the variable in the page's layout (or page HEAD block if you don't use a layout for this page). But make sure that the variable is set before accessing it:

<?
	if (isset($giveaway_meta_tags))
 		echo $giveaway_meta_tags;
?>

Coding the page

This section contains the instruction of coding the signup page. You can find the full list of generated PHP variables on the Giveaway API documentation page.

Below us the full code of the Giveaway page. You can paste it to the Content field and customize.

<? if ($fatal_error): ?>
	<p><?= $fatal_error ?></p>
<? else: ?>
	<? if (!$giveaway):	?>
		<p>Giveaway not found</p>
	<? else: ?>
		<?= $giveaway->description ?>

		<? if ($giveaway_image): ?><img src="<?= $giveaway_image ?>" alt=""/><? endif ?>
		
		<? if ($mode == 'signup'): ?>
			<!-- Signup page -->
			<? if (!$is_ended): ?>
				<? if ($is_started): ?>
					<? if (!$signup_success): ?>
						<? if ($signup_error): ?><p>Error. <?= h($signup_error) ?></p><? endif ?>
						
						<?= open_form() ?>
							<? if ($show_terms): ?>
								<h3>Terms and Conditions</h3>
								<?= $giveaway->terms ?>
								<p>
									<input type="checkbox" name="agree" value="1" id="agree" <?= $terms_status ?>/>
									<label for="agree">I agree to the Tems and Conditions</label>
								</p>
							<? endif ?>
					
							Email address: <input type="text" value="<?= h(post('email')) ?>" name="email"/>
							
							<?= $captcha ?>
							<input type="submit" value="Signup" name="signup"/>
						</form>
					<? else: ?>
						<p>Thank you! Please check your email to validate the registration.</p>
					<? endif ?>
				<? else: ?>
					<p>The giveaway is not started yet. It will start on <?= $giveaway->start_date->format('%x') ?></p>
				<? endif ?>
			<? else: ?>
				<?= $giveaway->ended_message ?>
			<? endif ?>
		<? else: ?>
			<!-- Dashboard page -->
			<? if ($just_confirmed): ?><?= $confirmation_message ?><? endif ?>
			
			<p>Number of your entries: <?= $entry_count ?></p>

			<? if ($is_ended): ?>
				<?= $giveaway->ended_message ?>
			<? else: ?>
				<p>Your share link: <?= $share_link_short  ? $share_link_short : $share_link ?></p>

				<?= $twitter_button ?>
				<?= $facebook_button ?>
				<?= $linkedin_button ?>
				<?= $googleplus_button ?>
			<? endif ?>
		<? endif ?>
	<? endif ?>
<? endif ?>

The giveaway page can work in two modes - sign up and dashboard. The sign up mode displays the entrant signup form for new entrants. The dashboard mode displays the number of entries, Share URL and social network buttons for existing entrants. The current page mode can be obtained from the $mode variable.

Social network share button codes are contained in the $twitter_button, $facebook_button, $linkedin_button, and $googleplus_button variables. All buttons have URLs pointing to the entrant's Share URL. You can add more social network buttons or replace existing with a custom implementation of you need.

Next: Managing entrants and entries
Previous: Creating a giveaway
Return to Giveaway module