Support

Home Forums Event Espresso Premium Ticketing + S2member Levels + Custom

Ticketing + S2member Levels + Custom

Posted: February 11, 2013 at 5:31 pm


Secretary CTS

February 11, 2013 at 5:31 pm

I have S2Member set up with 2 levels, Single and Family. Each gets a discount on tickets off the General Admission Price, differeing per events.

I am trying to customize the Registration Page so that the Ticket Price Dropdown will show only the Tickets for that Logged-in User’s Level.

Currently, EE handles Members (Logged In), but I need this to go another level. I created 2 member tickets, named “member family” and “member single”.

So using Files, I added a custom function that checks if the ticket name begins with “member” and then the next word “family” or “single” matches the user’s role. If so, it gets added to the dropdown, if not, move on to the next ticket.

In the Default column, I added a General Admission Ticket and a Meal Ticket.

The standard Registration shows “Member Single” and “Family Single” in the dropdown. My slightly modified version shows “General Admission” and “Meal Ticket”. Not good.

I looked in the data, and was not happy to see 2 records, General Admission and Meal Ticket, the 1st linked to Member Single ticket, the Meal ticket linked to Member Family.

I hadn’t realized your Ticket form was a “lazy row”. Now I have to figure out how to accommodate both single and family tickets. Also, I still don’t know why my modified page is showing only Standard Tickets – I added below to custom functions. I created a new action that I call from the Register_event_display.php template. I added debugging text too.

`
/*
Creates dropdowns if multiple prices are associated with an event
* @source plugins/espresso/includes/pricing.php
* @params int $event_id
* @params int $atts
* – bool multi_reg If this is a mutliple regsitration, then it cahnges the registration proerties
* – bool show_label Show the label above the dropdown
* – var current_value pass the price id to show a selected price by default
*/
function nanba_event_espresso_price_dropdown($event_id, $atts) {
do_action(‘action_hook_espresso_log’, FILE, FUNCTION, ”);
//Attention:
//If changes to this function are not appearing, you may have the members addon installed and will need to update the function there.
//echo “”.print_r($atts,true).””;
extract($atts);
global $wpdb, $org_options;

<code>    $html = '';

    $label = $label == '' ? ''.__('Choose an Option: ', 'event_espresso').'' : $label;

    //Will make the name an array and put the time id as a key so we know which event this belongs to
    $multi_name_adjust = isset($multi_reg) &amp;amp;&amp;amp; $multi_reg == true ? "[$event_id]" : '';

    $surcharge_text = isset($org_options['surcharge_text']) ? $org_options['surcharge_text'] : __('Surcharge', 'event_espresso');

    $results = $wpdb-&amp;gt;get_results("SELECT id, event_cost, surcharge, surcharge_type, price_type FROM " . EVENTS_PRICES_TABLE . " WHERE event_id='" . $event_id . "' ORDER BY id ASC");

    if ($wpdb-&amp;gt;num_rows &amp;gt; 1) {
       //Create the label for the drop down
        $html .= $show_label == 1 ? '' . $label . '' : '';

        //Create a dropdown of prices
        $html .= '';

        foreach ($results as $result) {
</code>

echo “RESULT>>”.print_r($result,true).”< “;
$selected = isset($current_value) && $current_value == $result->id ? ‘ selected=”selected” ‘ : ”;

<code>            // Addition for Early Registration discount
            if ($early_price_data = early_discount_amount($event_id, $result-&amp;gt;event_cost)) {
                $result-&amp;gt;event_cost = $early_price_data['event_price'];
                $message = __(' Early Pricing', 'event_espresso');
            } else $message = '';

            $surcharge = '';

            if ($result-&amp;gt;surcharge &amp;gt; 0 &amp;amp;&amp;amp; $result-&amp;gt;event_cost &amp;gt; 0.00) {
                $surcharge = " + {$org_options['currency_symbol']}{$result-&amp;gt;surcharge} " . $surcharge_text;
                if ($result-&amp;gt;surcharge_type == 'pct') {
                    $surcharge = " + {$result-&amp;gt;surcharge}% " . $surcharge_text;
                }
            }

            // NANBA - examine price type, is it appropriate for this users membership?
            $tixNameStr = strtolower(stripslashes_deep(trim($result-&amp;gt;price_type)));
            $tixNameStr = str_replace("-"," ",$tixNameStr);
            $tixNameArr = array();
            $tixNameArr = explode(" ",$tixNameStr);
            $proceed = true;
</code>

echo “tixnamearr>>”.print_r($tixNameArr,true).”< “;

<code>            if ( $tixNameArr[0]=="member" ) {
                $tixNameMembershipLevel = $tixNameArr[1];
</code>

echo “LEVEL>>”.$tixNameMembershipLevel.”>”.nanba_check_user_role($tixNameMembershipLevel).”< “;

<code>                if ( !nanba_check_user_role($tixNameMembershipLevel) ) {
                    $proceed = false;
                }
            }
            if ($proceed) {

                //Using price ID
                $html .= 'id . '|' . stripslashes_deep($result-&amp;gt;price_type) . '"&amp;gt;' . stripslashes_deep($result-&amp;gt;price_type) . ' (' . $org_options['currency_symbol'] . number_format($result-&amp;gt;event_cost, 2) . $message . ') ' . $surcharge . ' ';
            }
        }
        $html .= '';
    } else if ($wpdb-&amp;gt;num_rows == 1) {
        foreach ($results as $result) {

            // Addition for Early Registration discount
            if ($early_price_data = early_discount_amount($event_id, $result-&amp;gt;event_cost)) {
                $result-&amp;gt;event_cost = $early_price_data['event_price'];
                $message = sprintf(__(' (including %s early discount) ', 'event_espresso'), $early_price_data['early_disc']);
            }

            $surcharge = '';

            if ($result-&amp;gt;surcharge &amp;gt; 0 &amp;amp;&amp;amp; $result-&amp;gt;event_cost &amp;gt; 0.00) {
                $surcharge = " + {$org_options['currency_symbol']}{$result-&amp;gt;surcharge} " . $surcharge_text;
                if ($result-&amp;gt;surcharge_type == 'pct') {
                    $surcharge = " + {$result-&amp;gt;surcharge}% " . $surcharge_text;
                }
            }
            $message = isset($message) ? $message : '';

            if ( $result-&amp;gt;event_cost != '0.00' ) {
                $html .= '' . __('Price:', 'event_espresso') . ' ' . $org_options['currency_symbol'] . number_format($result-&amp;gt;event_cost, 2) . $message . $surcharge . '';
                $html .= 'id . '" value="' . $result-&amp;gt;id . '" /&amp;gt;';
            } else {
                $html .= '' . __('Free Event', 'event_espresso') . '';
                $html .= '';
                $html .= 'id . '" value="free" /&amp;gt;';
            }
        }
    }
    echo $html;
    return;
}
add_action('espresso_price_select_nanba', 'nanba_event_espresso_price_dropdown', 20, 2);
</code>

`


Secretary CTS

February 12, 2013 at 1:14 am

I got it working, for now.

First off, if you activate member, you want to use wp-content/plugins/espresso-members/member_functions.php::event_espresso_price_dropdown. I copied it into /wp-content/uploads/espresso/custom_functions.php, adding code that inspects all member tickets, named “member <>”. If the 2nd word matches the logged in user’s role, it gets added to the dropdown, otherwise not.

I had to create 2 General Admission Tickets to accommodate the 2 member levels. FEATURE REQUEST: Add 1-to-m ticket ‘classes’ with multiple Public (not default prices) as well as multiple member prices. UI: First, create the classes (or category) of tickets, then tickets you assign to 1 or more classes. You can then have Public Adult, Public Kid, Public Senior Tix as well as multiple Members, as well as Food Tickets.

1 more thing: s2member assigns s2member_level[n] to users, not the label names like single or family. I hardcoded an array to translate single or family to that format when checking roles.


Jonathan Wilson

February 13, 2013 at 12:23 pm

Hello there,

Wow. Thank you for the explanation of what you are wanting. I am definitely going to add this to our feature request list so our developers will be aware of your suggestion. I will link back to this post so they can see your explanation.

Thanks again.


Dean

June 5, 2014 at 6:54 am

Re-opened this thread – please see here https://eventespresso.com/topic/using-s2-to-set-ticket-levels/#post-100754


pmitriadnc

June 5, 2014 at 7:02 am

Secretary CTS,

I am interested in seeing your full solution as it is a feature we have been wanting to implement. Would you share your solution or let me know how to contact you.

Thank you

The support post ‘Ticketing + S2member Levels + Custom’ 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