Support

Home Forums Event Espresso Premium EE4 "Add to Cart" Button for Espresso Toggle Tables

EE4 "Add to Cart" Button for Espresso Toggle Tables

Posted: September 1, 2016 at 6:55 am

Viewing 4 reply threads


nathan.yerxa

September 1, 2016 at 6:55 am

To whom can help:

In EE4 s there a way to change the Register link in the eea-events-table-view-template from a link which takes you to the event page, to an Add to Cart button which adds the event directly to the cart with no intermediary steps?

I’m working with the eea-multi-event-registration<s/strong> and eea-events-table-view-template plugins for my site’s registration process. Specifically, I’m making use of the espresso-events-table-template-toggle.template.php file for displaying a list of events on my site and using the MER mini-cart widget in the sidebar. I would like to create an Add to Cart button/action to replace the Register link in the table so the event which the person is viewing would be added directly to the Event cart or in this case show up in the sidebar EE4 MER mini-cart widget.

My initial attempts were to install this code (from a post in the support forums)
if (event_espresso_get_status($event->id) == 'ACTIVE') {
$params = array(
'event_id' => $event->id,
'anchor' => __("Add to Cart", 'event_espresso'),
'event_name' => $event->event_name,
);
$cart_link = event_espresso_cart_link($params);
} else {
$cart_link = false;
}

in the espresso-events-table-template-toggle.template.php file and use the
$cart_link
to call the item in the table, but it doesn’t seem to be working correctly.

Any suggestions or help is greatly appreciated. Thank you.


Josh

  • Support Staff

September 1, 2016 at 8:00 am

The code that you tried was for Event Espresso 3.
For Event Espresso 4 you’ll need to embed the ticket selector into the the table cell to replace the link. The following code will embed a ticket selector:

<?php if ( espresso_display_ticket_selector( $post->ID ) && ( is_single() || ( is_archive() && espresso_display_ticket_selector_in_event_list() ))) :
?>
<div class="event-tickets" style="clear: both;">
	<?php espresso_ticket_selector( $post ); ?>
</div>

<?php endif; ?>


nathan.yerxa

September 1, 2016 at 8:38 am

Thank you for the help. For my understanding would it still be located after the start of the foreach loop in the template?


Josh

  • Support Staff

September 1, 2016 at 8:52 am

There’s more than one foreach loop in that template. To be clear, the register link code is a few lines before the endwhile;.

So you’ll be replacing this:

<?php echo $live_button; ?>


nathan.yerxa

September 1, 2016 at 9:11 am

Thank you for the help.

Viewing 4 reply threads

The support post ‘EE4 "Add to Cart" Button for Espresso Toggle Tables’ 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