Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter filmreeves

    (@filmreeves)

    I managed to FINALLY find a solution with the code, so I’ll post it here to save anyone else in the same situation hours of suffering:

    <?php

    function StageshowFilterDiscount($unused, $cartContents)
    {
    $discount = 0;
    $discountedShows = []; // Array to track shows with discounted tickets

    // Check if a discount code has been applied
    if (!empty($cartContents->disCode)) { // Assuming 'disCode' contains the discount code entered by the user

    // Loop through 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

    // Check if this is the first ticket for this show
    if (!isset($discountedShows[$showName]) && $qty > 0) {
    // Calculate 33.36% discount for the first ticket
    $discountAmount = $cost * 0.3336;
    $discount += $discountAmount;

    // Mark this show as discounted
    $discountedShows[$showName] = true;
    }
    }

    // Display the discount details for the user
    if ($discount > 0) {
    define('STAGESHOWLIB_TROLLEYHTML_ABOVEBUTTONS', '<tr><td><br></td></tr><tr>
    <td colspan="6" style="text-align:left"><h4>THANKYOU FOR BEING A SUBSCRIBER!</h4></td>
    </tr>
    <tr>
    <td colspan="6" style="text-align:left">You have received a discount on the first ticket for each show in your order.</td>
    </tr>
    <tr><td><br></td></tr>');
    } 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>');
    }

    // 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);

    Add that to stageshow-wp-config.php, tailor the amounts used for the discount, then make a discount code that changes the price to the same value as the normal price.

    Phew!

    • This reply was modified 1 month, 1 week ago by filmreeves.
    Thread Starter filmreeves

    (@filmreeves)

    Thanks for your reply, can I ask how you did all of this?

    Thread Starter filmreeves

    (@filmreeves)

    No need to worry, fixed this myself rather quick by editing the plugins functions file. Changed user id = false to bp_displayed_user_id(),

    Thread Starter filmreeves

    (@filmreeves)

    I found the part of the code I needed to edit, no worries.

Viewing 4 replies - 1 through 4 (of 4 total)