/**
  * AJAX Call for Remove Product from Cart
  * 
  * Handles to removing product from cart
  * 
  * @package Social Deals Engine
  * @since 1.0.0
  */
 public function wps_deals_remove_to_cart_product()
 {
     $dealid = $_POST['dealid'];
     $resultdata = array();
     if (isset($dealid) && !empty($dealid)) {
         //remove item from cart
         $result = $this->cart->remove($dealid);
         //do action for change cart via ajax
         do_action('wps_deals_cart_ajax');
         $undo_url = wps_deals_get_undo_url($dealid);
         $resultdata['message'] = '<span> ' . sprintf(__('%s removed. %sUndo?%s', 'wpsdeals'), get_the_title($dealid), '<a href="' . esc_url($undo_url) . '">', '</a>') . '</span>';
         $this->message->add('undo', 'true');
         //get cart details
         ob_start();
         //do action for refreshing div via ajax
         do_action('wps_deals_checkout_header_content_ajax');
         $resultdata['detail'] = ob_get_clean();
         $resultdata['success'] = '1';
         $cart = $this->cart->get();
         $resultdata['total'] = $this->currency->wps_deals_formatted_value($cart['total']);
         $cartdata = $this->cart->getproduct();
         if (empty($cartdata)) {
             $resultdata['empty'] = '1';
         }
     } else {
         $resultdata['message'] = '<span>' . __('Error while removing item from cart.', 'wpsdeals') . '</span>';
     }
     echo json_encode($resultdata);
     exit;
 }
 /**
  * Loads the empty cart message template.
  * 
  * @package Social Deals Engine
  * @since 1.0.0
  */
 function wps_deals_empty_cart_message()
 {
     global $wps_deals_message, $wps_deals_session, $wps_deals_options;
     $undo = false;
     $undo_url = '';
     $dealid = '';
     // check if undo is set in messages
     if ($wps_deals_message->size('undo') > 0) {
         $undo = true;
         $removed_cart_item = $wps_deals_session->get('wps_deals_removed_cart_contents');
         $dealid = $removed_cart_item['dealid'];
         $undo_url = wps_deals_get_undo_url($dealid);
     }
     $deals_shop_page = isset($wps_deals_options['shop_page']) ? $wps_deals_options['shop_page'] : '';
     $deals_shop_url = get_permalink($deals_shop_page);
     $args = array('undo' => $undo, 'dealid' => $dealid, 'undo_url' => $undo_url, 'deals_shop_url' => $deals_shop_url);
     // get the template
     wps_deals_get_template('notices/empty-cart.php', $args);
 }