Support

Home Forums Event Espresso Premium Pre-populate promo codes in embedded URL

Pre-populate promo codes in embedded URL

Posted: May 15, 2014 at 3:10 am

Viewing 3 reply threads


masteryasia

May 15, 2014 at 3:10 am

Hi, i would like to know if I can pre-populate / pre-apply the promotional codes using embedded URL or any other method.

Lets say I created codes : dis50
Example : http://www.example.com/event-registration/?ee=2&promo=dis50
If people click this url, they will automatically got the discounted price

Event Espresso version : 3.1.36.5.P
WordPress version : WP 3.9.1
New installation.


Dean

May 15, 2014 at 4:10 am

Hi,

Pre applying will be quite hard, but pre-populating is fairly easy.

Add the following function to wp-content/uploads/espresso/custom_functions.php (you may need to create this if it does not already exist, or use a custom plugin).

<?php //delete this if it already exists at the top of the custom_functions.php file

   function event_espresso_coupon_registration_page( $use_coupon_code = 'N', $event_id, $class =' ee-reg-page-text-input ', $multi_reg = FALSE ) {
	
        global $espresso_premium;
        if ( ! $espresso_premium ) {
			return;
		}
     
     $x = $_GET['promo'];
    if( !isset($x) ) { $x = ''; }

        if ( in_array($use_coupon_code,array("Y", "G", "A")) ) {

            $multi_reg_adjust = $multi_reg ? "[$event_id]" : '';	 

            $output ='
	<p class="event_form_field coupon_code" id="coupon_code-' . $event_id . '">
		<label for="coupon_code" class="inline">' . __('Promo Code', 'event_espresso') . ':</label>
					<input type="text" class="espresso-coupon-code ' . $class . '" name="event_espresso_coupon_code'. $multi_reg_adjust . '" id="coupon_code-' . $event_id . '" value="' . $x . '">
	</p>';
			
        } else {
			$output = '';
		}
		
        return $output;
		
    }

Now if you add &promo=promocode to the end of the URL it will grab that code and insert it into the promo field.


masteryasia

May 15, 2014 at 4:35 am

Wow thanks. Its works. so…

1. is this file will be affected when new updates is release? is it will be overwritten and i need to re do the steps?
2. any chance for pre-apply?


Lorenzo Orlando Caum

  • Support Staff

May 15, 2014 at 9:16 pm

Hello,

This should be added to a site specific plugin:

http://ottopress.com/2011/creating-a-site-specific-snippets-plugin/

This will ensure that it is not lost on a software or theme update.


Lorenzo

Viewing 3 reply threads

The support post ‘Pre-populate promo codes in embedded URL’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso