Discount Applying to One Ticket
-
Hi all, just wondering if anyone would know how to make it so discount codes only work on one ticket per order, rather than every ticket?
I’ve tried many different routes, including inserting this code within stageshow-wp-config.php file, as well as various other files, but can’t seem to find where to edit the trolley’s code:function StageshowFilterDiscount($unused, $cartContents)
{
$discount = 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; // Price per ticket
// Apply discount only to the first ticket of each show
if ($qty > 0) {
// Calculate 33.36% discount for the first ticket
$discountAmount = $cost * 0.3336;
$discount += $discountAmount;
// Display the discount details for the user (optional)
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">You have received a 33.36% discount on the first ticket for each show in your order.</td>
</tr>
<tr><td><br></td></tr>');
}
}
// Uncomment the line below to show the discount amount in the trolley
// echo "Total Discount: $discount <br>\n";
return $discount;
}
add_filter('stageshow_filter_discount', 'StageshowFilterDiscount', 1, 2);This code works, but applies to the cart regardless of whether a discount code has been used (and when a discount code is submitted, it removes this anyway).
Any help would be greatly appreciated! Thankyou.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.