Support » Plugin: StageShow » Rules for discount codes

  • Resolved Graham Mandeno

    (@grahammandeno)


    Hi Malcolm

    I have a problem with the way discount codes work. At the moment I have only two foreseeable uses for discount codes:

    1. To apply a group discount (for example, 10% off if you buy six or more qualifying tickets)

    2. To supply certain individuals (e.g. cast, sponsors, etc) with a unique, one-show-only code to book a limited number of complimentary tickets.

    Currently I can kind of implement #1 by making a discount code “GROUP” and applying a reduced price to it for each ticket class. However, there is no way to enforce the “six or more” rule. Some cheeky individual can book a single ticket, and enter GROUP for the discount code, thus saving 10%. Also, there is no way to enforce the “qualifying tickets” rule. Family tickets and comps are already discounted, so should not contribute to the “six or more” total.

    And I can see no way to implement #1. Ideally I would like to email someone: “In recognition of your generous support we would like to offer you up to four complimentary tickets to Les Miserables. Simply book your tickets online as usual and enter this unique discount code to redeem your free tickets”. At the moment I have to ask them to phone or email me so that I can enter their bookings manually.

    How difficult would it be to enable these two features? I’m sure they would be a very popular addition to a really great plug-in!

    Kind regards,
    Graham

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi Graham,

    This is something that I was playing around with. I never got it to production on our website since we didn’t fully require it at the time but if you come up with a better solution than what I could come up with then I would love to hear it. I dont mind sharing what I have done. Give me half an hour and I’ll post it. Just not near a PC just now.

    Thanks,
    Chris

    Hi again Graham,

    So… I added the following to the bottom of the stageshow-wp-config.php file in the uploads folder. This is basically a buy one get one cheaper/free (can’t remember what it was) for another production. Not quite what you are looking for but you can change to suit your needs.

    I’ve put in comments to help you follow what is going on. Any questions just ask.

    As I said in my previous post. This was never used in production so please test fully before you use it.

    function StageshowFilterDiscount($unused, $cartContents)
    {
    	$show1 = 0;
    	$show2 = 0;
    	
    	// Loop round all Trolley Entries	
    	foreach ($cartContents->rows as $cartEntry)
    	{
    		$showName = $cartEntry->showName;		// Show Name
    		$qty = $cartEntry->qty;				// Number of tickets
    		
    		
    		if ($showName == 'Sister Act') // Count Qty of Tickets for Sister Act
    		{
    		    $show1 += + $qty;
    		}
    		
    		if ($showName == 'Titanic') // Count Qty of Tickets for Titanic
    		{
    		    $show2 += + $qty;
    		}
    	}
    
    //Uncomment the line below to show the count of tickets for show1
    //echo "Show1: $showSisterAct <br>\n";
    //Uncomment the line below to show the count of tickets for show2
    //echo "Show2: $showTitanic <br>\n";
    
    	
    		if ($show1 > 0 && $show2 > 0) 
    		//If there are Sister Act and Titanic tix in the basket then
    		{
    		    $discount += 2 * min($show1, $show2);
    		    //Get min of either show1 or show2 and apply discount to that number of tickets only
    		   
    		   define('STAGESHOWLIB_TROLLEYHTML_ABOVEBUTTONS', '<tr><td><br></td></tr><tr>
                <td colspan=6 style="text-align:left"><h2>A DISCOUNT HAS BEEN APPLIED TO YOUR ORDER!</h2></td>
                </tr>
                <tr>
                <td colspan=6 style="text-align:left">By purchasing your tickets for Sister Act at the same time as tickets for Titanic your Titanic tickets now only cost £14 each. <br><br>A discount has been applied to your order to automatically to reflect this.</td>
                </tr>
                <tr><td><br></td></tr>');
                //Report to user by an entry to the trolley
    		   
    		} else {
    		    define('STAGESHOWLIB_TROLLEYHTML_ABOVEBUTTONS', '<tr><td><br></td></tr><tr>
                <td colspan=6 style="text-align:left"><h2>DISCOUNTS AVAILABLE</h2></td>
                </tr>
                <tr>
                <td colspan=6 style="text-align:left">By purchasing your tickets for Sister Act at the same time as tickets for Titanic, Titanic tickets cost only £14 each.</td>
                </tr>
                <tr><td><br></td></tr>');
    		}
    
    //Uncomment the line below to show the discount amount in the trolly
    //echo "Discount: $discount <br>\n";
    	return $discount;
    }
    
    add_filter('stageshow_filter_discount', 'StageshowFilterDiscount', 1, 2);
    • This reply was modified 2 years, 5 months ago by weazel91.

    Just had a look again at your requirement.

    Dont think the above will suit requirement 2 as it doesn’t allow you to ensure a valid discount code has been used first. Perhaps you can modify it to check that first? Not sure.

    Hope it may help anyway.

    Thanks,
    C

    • This reply was modified 2 years, 5 months ago by weazel91.

    Just chiming in as being able to apply rules to discount codes would be really useful for me too. I specifically need to be able to give people a discount code that only applies to up to four tickets, and any additional tickets bought as part of the same transaction are charged at full price. Also, if the code could only be used once per user for a particular show that would be great too, so someone can’t come back and do a second transaction with the discount applied too – perhaps the user would be identified by email address.

    Malcolm, I realise all these things take time to do – personally I’d be happy to buy extensions to the plugin for the extra functionality, if that’s any encouragement for you to invest the time into it!

    Graeme,

    This should help you. Just spent a bit of time modifying.

    Thanks,
    Chris

    function StageshowFilterDiscount($unused, $cartContents)
    {
    	$showtkts = 0;
    	
    	// Loop round all Trolley Entries	
    	foreach ($cartContents->rows as $cartEntry)
    	{
    		$showName = $cartEntry->showName;		// Show Name
    		$qty = $cartEntry->qty;				// Number of tickets
    		$cost = $cartEntry->price;				// Number of tickets
    		
    		
    		if ($showName == 'The Addams Family') // ENTER SHOW NAME HERE
    		{
    		    $showtkts += + $qty;
    			$cost += + $price;
    		}
    	}
    
    //echo "$showName: $showtkts <br>\n";
    //echo "$showName Individual Ticket Price: $cost <br>\n";
    
    	
    		if ($showtkts > 5) 
    		//If there are greater than 6 tix in the basket then
    		{
    		    $discount += ($showtkts * $cost)/10;
    		    //Get min and apply discount to that number of tickets - so amount of tickets * Ticket price / 10 to get 10%
    		   
    		   define('STAGESHOWLIB_TROLLEYHTML_ABOVEBUTTONS', '<tr><td><br></td></tr><tr>
                <td colspan=6 style="text-align:left"><h2>A DISCOUNT HAS BEEN APPLIED TO YOUR ORDER!</h2></td>
                </tr>
                <tr>
                <td colspan=6 style="text-align:left">By purchasing 6+ tickets you are eligable for 10% off.<br><br>A discount has been applied to your order to automatically to reflect this.</td>
                </tr>
                <tr><td><br></td></tr>');
                //Report to user by an entry to the trolley
    		   
    		} else {
    		    define('STAGESHOWLIB_TROLLEYHTML_ABOVEBUTTONS', '<tr><td><br></td></tr><tr>
                <td colspan=6 style="text-align:left"><h2>DISCOUNTS AVAILABLE</h2></td>
                </tr>
                <tr>
                <td colspan=6 style="text-align:left">By purchasing 6+ tickets you can get up to 10% off your order.</td>
                </tr>
                <tr><td><br></td></tr>');
    		}
    
    //echo "discount: $discount <br>\n";
    	return $discount;
    }
    
    add_filter('stageshow_filter_discount', 'StageshowFilterDiscount', 1, 2);
    Thread Starter Graham Mandeno

    (@grahammandeno)

    Hi Chris

    That will be a great help – thank you!

    I think that to implement this properly, one or more tables would need extra columns- for example, wp_sshow_discodes would need columns for:
    – showID of the show to which this discount applies (where applicable)
    – maximum number of tickets that can be purchased with this disCode (where applicable)
    – minimum number of qualifying tickets to purchase in one order for the code to be valid

    There would also need to be a field in wp_sshow_tickets to store the disCode that has been used for that ticket (to keep track of the number of times it has been used). Actually, it would be simpler and more normalised if wp_sshow_tickets had one row per ticket, rather that including a multiplier field. With the current structure, it would be difficult to record the fact that four “Adult” tickets had been ordered, where the discount code had been applied to two of them.

    I like the way your code automatically applies the 10% discount without needing a discount code, once the required number of tickets have been ordered. However, each theatre would likely have different rules for discounts, and there may also be different rules for different shows, so it would be great for these rules to be table-driven.

    @malcolm-oph, I’m clearly not nearly as well versed in PHP as you and Chris, but I do have a lifetime of database design and other programming behind me, so I’d be willing to help in whatever way I can.

    Cheers,
    Graham

    Hi Graeme,

    Oh believe me I’m not. I’m self taught all the way and the above was from an lot of tinkering and trial and error. Malcolm has helped me more than I care to disclose.

    Malcolm has taken a large step back for unknown reasons. He has helped me out so much in the past and implemented so many things. He has been a fantastic help.

    There are so many things that this plugin could have implemented such as the above, some customer database to store details (GDPR Allowed) and recall them, having a sale record whether it was web/telephone/in person, etc etc. But it takes time, money and the will to do it and I’m not in what position Malcolm is in unfortunately. I wish I knew more to help whether it be more experienced developers, money, time or just someone to carry it further.

    @malcolm-oph Just want to commend you for your plugin so far, its truely amazing and for us as a youth charity has brought us hundreds of thousands of pounds through the door. It would be good to know what’s next? Are you still plodding away in the background, are things tied up with development due to resources I.e. time, money, people. Or is development of this plugin nearing its end. I did see someone suggesting the option to purchase additional plugins. Would this be an option?

    Again, many thanks for all the hard work. It truely is wonderful!

    Chris

    Thread Starter Graham Mandeno

    (@grahammandeno)

    @malcolm-oph: I would like to wholeheartedly echo what Chris has said. I really appreciate the way you were so willing to rapidly implement some of my ideas when I first started using StageShow nearly four years ago. It has been a real boon to our small theatre to be able to take bookings and receive payments online.

    Like Chris, I am somewhat concerned that you appear to have withdrawn from the picture regarding StageShow, and have discontinued the two premium paid-for versions. Does this mean that you are stopping further development and scaling down support to a minimum? If so, then I hope this is because you are far too busy running the Old Pumphouse, or drinking good red wine and watching the Wye Rapids, and not because of ill health or some other misfortune!

    In any event, I agree with Chris that it’s a wonderful plugin, but there are still many useful features that could be added, and it would be a great pity for it to languish.

    All the best,
    Graham

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Rules for discount codes’ is closed to new replies.