• Anyone know of a plugin that will generate a unique coupon automatically everyday?

    I have installed WPS Coupons as well as Coupon Creator.

    Neither plugin has the ability to create a unique coupon automatically every day.

    I need to offer people a coupon when they complete a quiz but the coupon has to be good for that day only.

    I don’t want to create a coupon for each day of the year as that would be cumbersome.

    Please help me with some direction!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Marius L. J.

    (@clorith)

    Is this intended for use in combination with some other plugin (since it’s a coupon I’m thinking e-commerce systems, wooCommerce for example)?

    Knowing what it’ll be used with might help narrow it down since one solution might not work with the system you have in mind.

    Thread Starter nolaandy

    (@nolaandy)

    I’m going to use it in conjunction with Achievements and WP-Pro-Quiz.

    When someone gets a 100% on a quiz they get a coupon for free entry for that day only.

    So I need to set up one coupon that gets randomly generated everyday to expire on that day.

    I need the link to the coupon to stay the same but I need the coupon’s expiration to increase one day, everyday, automatically.

    Moderator bcworkz

    (@bcworkz)

    You could create a custom page template that contains the coupon where an URL parameter defines the expiration date if security isn’t a big concern. If it is, the expiration would need encryption so no one could URL hack themselves a coupon. You could also add a fake serial number containing a very simple checksum to provide some protection from someone photoshopping for their friends some later expiring coupons. Adding a nonce check would ensure only those provided the link could use the link and it would only be valid for a couple days and then the page throws an error. This is independent of the expiration date.

    As a more obfuscation than encryption measure, you could provide a hexadecimal timestamp, reversing the hex string would make it appear like a fairly random ID string. Here’s a simple template example. You could add content as needed and add custom CSS such as a background image and dashed border to make more official looking.

    <?php /* Template Name: Coupon */
    get_header(); ?>
      <div id="primary"><div id="content" role="main">
          <div id="coupon">
            <h2>FREE ADMITTANCE</h2>
            This coupon entitles the bearer to free admittance to<br>
            MY AWESOME VENUE<br>
            Expires: <?php
              //try adding "?id=0X52C08741" to this page's permalink
              if(array_key_exists('id', $_GET)) {
                echo date("Y-m-d H:i", $_GET['id'] ) . '<br>';
                $day = date('d', $_GET['id'] ); $ck = $day + 11;
                echo "YHK5DX{$ck}X9UC45";
              } else echo 'Invalid ID - Cheatin' huh?'; ?>
          </div>
      </div></div>
    <?php get_footer(); ?>

    Place the contents in a .php file in your theme’s folder. Create a new page based on the “Coupon” template. Give it a title to establish a permalink. No content needs to be added in the page editor, it’s all on the template.

    If you gave it a title of “Coupon”, the permalink would be something like http://www.example.com/coupon/. Add the suggested URL parameter “?id=0X52C08741” to this in your browser’s address bar and see the result. Notice the “serial number” has the date + 11 between the X’s.

    Assuming the WordPress page ID is 1011, the date stamped coupon link could be generated with:
    <?php echo get_permalink(1011) . '?id=0X' . strtoupper( base_convert( time() + (3600*24), 10, 16 ));?>

    This surely isn’t exactly what you had in mind, but that’s the beauty of a custom solution, you can adjust it to anything you want.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Plugin that Generates Unique Coupons Daily’ is closed to new replies.