Support

Home Forums Event Espresso Premium Member prices for some events in the pricing table

Member prices for some events in the pricing table

Posted: May 16, 2019 at 9:17 am

Viewing 7 reply threads


Oguzhan Altun

May 16, 2019 at 9:17 am

Hello,

For all our events, we have 2 types of tickets:
Normal ticket
Member ticket (price modifier, 15% discount, WP User Capability required for purchasing this ticket: um_member

The strange thing is for some events (not all), the member price shows in the pricing table even when browsing at incognito window. E.g.:

https://zurich.swissphotoclub.com/en/courses/beginners-intensive-photography-course/

Normal price 390, member price 331.5

When the user enters the event, then the user sees the correct price 390.

I’m assuming something is wrong with the tableview code, so I copy pasted it here:

**Removed **

  • This topic was modified 5 years, 6 months ago by Tony. Reason: Removed code


Oguzhan Altun

May 16, 2019 at 9:21 am

sorry for the long code, here you can see it on github:
https://gist.github.com/altuno/9673c11cbe87be2d1f8c32dc90937df2


Tony

  • Support Staff

May 17, 2019 at 2:43 am

Hi there,

I’ve removed the code from your opening post as its much easier to read on the gist, so no need for both.

The reason your getting different ticket prices is this code:

$tickets = EEH_Event_View::event_tickets_available( $post->ID );
// grab first ticket from array
$ticket = reset( $tickets );`

Pulls all of the tickets from the event and then you use the ‘first’ ticket from the array, but that won’t necessarily be the ticket you want. IIRC the ticket will be pulled based on the ticket ID ordered ASC.

EE doesn’t include a price in the table by default, so this is custom and not something we can support, but I can point you in the direction I would go. When you pull $tickets loop over them to find your non member ticket (how you do this is up to you) and then set $ticket to the current ticket in the loop and break out of it.

Side note, anywhere you have this:

if ( ! ($event->is_sold_out() || $event->is_sold_out( TRUE ) ) ) {

Will be using a fair amount of resources as the second condition is recalulating if the sold values have changed, you can generally swap that out for:

if ( ! ($event->is_sold_out() ) {

Which will reduce the load on the server when loading that page.


Oguzhan Altun

May 17, 2019 at 1:24 pm

Hi Tony,

For the pricing question, would it be possible for you to suggest the code to replace? The ticket should be easily identifiable – the one that doesn’t have any wp-user capability condition or the one without a discount.
The original code to show prices was kindly provided by you guys, as I’m not a coder at all, I have no idea how to proceed.

Thank you for the tip for the server, it’s indeed very slow loading. However when I did swap the code with yours, it broke the site:
https://1drv.ms/u/s!Aq-UF27GAGdjgrh3HNJpDVz9FHQ_Yw

The site is experiencing technical difficulties.

Any idea why?

Thanks a lot in advance.


Tony

  • Support Staff

May 17, 2019 at 1:37 pm

Any idea why?

Yeah, my apologies, its my bad. This:

if ( ! ($event->is_sold_out() ) {

Needs to be:

if ( ! $event->is_sold_out() ) {

I missed removing the additional bracket.

For the pricing question, would it be possible for you to suggest the code to replace? The ticket should be easily identifiable – the one that doesn’t have any wp-user capability condition or the one without a discount.

That sounds like 2 conditions? The second isn’t as easy to detemine as the first.

Using a ticket that doesn’t have a capability set on it:

foreach($tickets as $temp_ticket) {
    if($temp_ticket instanceof EE_Ticket) {
        $cap_required = $temp_ticket->get_extra_meta('ee_ticket_cap_required', true);
        if(!$cap_required) {
            $ticket = $temp_ticket;
            break;
        }
    }
}

The loops over the tickets and the first it find that does not have a capability set on it will be the ticket the template uses, put that in place of:

// grab first ticket from array
$ticket = reset( $tickets );


Oguzhan Altun

May 17, 2019 at 2:26 pm

Hi Tony,

for the server code – it worked, thank you.

For the ticket code, didn’t work, I got N/A or empty prices for all events?


Tony

  • Support Staff

May 17, 2019 at 2:55 pm

Not my day today!

Please try again with the code above (I’ve updated the post)


Oguzhan Altun

May 18, 2019 at 9:22 am

it worked perfectly now, thank you Tony 🙂

Viewing 7 reply threads

The support post ‘Member prices for some events in the pricing table’ 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