Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eventcart: on EventInfo, show checkout/viewcart buttons #31625

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ext/eventcart/CRM/Event/Cart/PageCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ public static function alterEventInfo($event) {

$event->page->assign('registerText', $registerText);
$event->page->assign('registerURL', $url);

// For the "View Cart" and "Checkout" buttons
$cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session();
$cart->load_associations();
$events = $cart->get_main_events_in_carts();
$event->page->assign('eventcart_has_events', !empty($events));

CRM_Core_Region::instance('event-page-eventinfo-actionlinks-top')
->add(['template' => 'CRM/Event/Cart/eventinfo.tpl']);
}

public static function alterEventList($event) {
Expand Down
13 changes: 13 additions & 0 deletions ext/eventcart/templates/CRM/Event/Cart/eventinfo.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class="pull-right float-right crm-eventcart-eventinfo-buttons">
<div class="action-link align-right crm-eventcart-eventinfo-addtocart"></div>
<div class="action-link align-right crm-eventcart-eventinfo-viewcart"><a href="{crmURL p='civicrm/event/view_cart'}" class="button crm-shoppingcart-button"><i class="crm-i fa-shopping-cart" aria-hidden="true"></i> {ts}View Cart{/ts}</a></div>
{if $eventcart_has_events}
<div class="action-link align-right crm-eventcart-eventinfo-checkout"><a href="{crmURL p='civicrm/event/cart_checkout'}" class="button crm-check-out-button"><i class="crm-i fa-credit-card" aria-hidden="true"></i> {ts}Checkout{/ts}</a></div>
{/if}
</div>
{literal}
<script>
CRM.$('.register_link-top > a').prependTo('.crm-eventcart-eventinfo-addtocart');
CRM.$('.register_link-top').hide();
</script>
{/literal}