/** * [getRemoveProductCart description] * @return [type] [description] */ public function getRemoveProductCart() { if ($_GET['count'] == 1) { $count = $_GET['count'] - 1; $old_price = str_replace(".", "", $_GET['old_price']); $new_price = (int) $old_price - (int) $_GET['price']; $new_slug = array_diff(Session::get('array_slug'), array($_GET['slug'])); Session::forget('price_cart'); Session::forget('count_product'); Session::forget('array_slug'); $data = array('title' => 'Thông Báo', 'body' => 'Xóa thành công !', 'count' => $count, 'price' => adddotstring($new_price)); return json_encode($data); } else { $count = $_GET['count'] - 1; $old_price = str_replace(".", "", $_GET['old_price']); $new_price = (int) $old_price - (int) $_GET['price']; Session::put('price_cart', adddotstring($new_price)); Session::put('count_product', $count); $new_slug = array_diff(Session::get('array_slug'), array($_GET['slug'])); Session::put('array_slug', $new_slug); $data = array('title' => 'Thông Báo', 'body' => 'Xóa thành công !', 'count' => $count, 'price' => adddotstring($new_price)); return json_encode($data); } }
function renderViewCart($product) { $html = ''; foreach ($product as $product) { $html .= '<div class="row no-margin cart-item">'; $html .= '<div class="col-xs-12 col-sm-2 no-margin">'; $html .= '<a href="#" class="thumb-holder">'; $html .= HTML::image($product["image_small"], null, array("class" => "lazy")); $html .= '</a>'; $html .= '</div>'; $html .= '<div class="col-xs-12 col-sm-5 ">'; $html .= '<div class="title">'; $html .= '<a href="">' . $product["name"] . '</a>'; $html .= '</div>'; $html .= '<div class="brand">sony</div>'; $html .= '</div>'; $html .= '<div class="col-xs-12 col-sm-3 no-margin">'; $html .= '</div>'; $html .= '<div class="col-xs-12 col-sm-2 no-margin">'; $html .= '<div class="price">'; $html .= adddotstring($product["price"]) . '<sup>VND</sup>'; $html .= '</div>'; $html .= '<a class="close-btn" href="javascript: removecart(' . "'" . $product['slug'] . "'" . ',' . $product['price'] . ')"></a>'; $html .= '</div>'; $html .= '</div>'; } return $html; }