Skip to content

Instantly share code, notes, and snippets.

@sidharrell
Created December 13, 2013 17:15
Show Gist options
  • Select an option

  • Save sidharrell/7947711 to your computer and use it in GitHub Desktop.

Select an option

Save sidharrell/7947711 to your computer and use it in GitHub Desktop.
show cart widget if empty
//replaces lines 24-43 of plugins/espresso-multiple/cart-widget.php
public function widget($args, $instance) {
//if (empty($_SESSION['espresso_session']['events_in_session'])){return;}
extract($args);
global $org_options;
$grand_total = !empty($_SESSION['espresso_session']['grand_total']) ? $_SESSION['espresso_session']['grand_total'] : 0.00;
$title = apply_filters('widget_title', $instance['title']);
echo $before_widget;
echo $before_title . $title . $after_title;
//Debug
//echo '<h4>$VARIABLE : <pre>' . print_r($_SESSION['espresso_session']) . '</pre> <span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
//echo '<p><strong>Events in cart:</strong> '.count($_SESSION['espresso_session']['events_in_session']).'</p><br />';
echo '<ol>';
if (!empty($_SESSION['espresso_session']['events_in_session'])) {
foreach ($_SESSION['espresso_session']['events_in_session'] as $event){
echo '<li>'.$event['event_name'].'</li>';
}
} else {
echo '<li>' . __('No events in cart', 'event_espresso') . '</li>';
}
echo '</ol>';
echo '<br /><p class="widget_cart_total"><strong>'.__('Total:', 'event_espresso').'</strong> '.$org_options['currency_symbol'].'<span id="event_total_price_widget">'.number_format( $grand_total, 2, '.', '' ).'</span></p>';
echo '<p class="widget_cart_link"><a href="'.get_permalink($org_options['event_page_id']).'?regevent_action=show_shopping_cart">'.__('View Cart', 'event_espresso').'</a> | <a href="'.get_permalink($org_options['cancel_return']).'">'.__('Clear Cart', 'event_espresso').'</a></p>';
echo $after_widget;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment