Support

Home Forums Event Espresso Premium Display Event cart ICON only when not empty Reply To: Display Event cart ICON only when not empty

Reply To: Display Event cart ICON only when not empty

Author Replies
Josh # Posted on May 11, 2018 at 8:39 pm

The code in Tony’s example is missing a closing </style> tag, this:
echo '<style type="text/css">#cart-row{display:none}';
should be changed to:
echo '<style type="text/css">#cart-row{display:none}</style>';

Another approach to this that you could take would be to hide the cart element (#cart-row) with CSS in your stylesheet, then reverse the conditional so when the cart isn’t empty it sets a style to display block when the cart isn’t empty:


function tw_ee_add_custom_styles() {

  $cart = EE_Registry::instance()->SSN->cart();

  if( $cart instanceof EE_Cart && $cart->all_ticket_quantity_count() != 0 ) {
      echo '<style type="text/css">#cart-row{display:block}</style>';
  }

}
add_action( 'wp_head', 'tw_ee_add_custom_styles', 99 );
Do NOT follow this link or you will be banned from the site!