public function displayMain() { global $smarty, $link, $cookie; if (!$cookie->logged) { Tools::redirect($link->getPage('LoginView')); } $smarty->assign(array('products' => Wish::getWishProductWithUser($cookie->id_user), 'DISPLAY_LEFT' => Module::hookBlock(array('myaccount')))); return $smarty->fetch('my-wish.tpl'); }
public function requestAction() { global $smarty, $cart; $cart_info = array('cart_total' => 0, 'cart_quantity' => 0, 'cart_products' => 0); if (isset($cart) && Validate::isLoadedObject($cart)) { $cart_info = $cart->getCartInfo(); } $wishs = Wish::getWishSumByUser(); $alerts = Alert::getAlertSumByUser(); $smarty->assign(array('wish_total' => $wishs['count'], 'wish_array' => $wishs['array'], 'alert_total' => $alerts['count'], 'cart_products' => $cart_info['cart_products'], 'cart_total' => $cart_info['cart_total'], 'cart_quantity' => $cart_info['cart_quantity'])); }
private function SendWishlist() { // prepare the email message $subject = "Some Gift Ideas"; $headers = 'From: My CBDB Admin admin@mycbdb.com' . "\r\n" . 'Reply-To: My CBDB Admin admin@mycbdb.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $email = "Here are a few of my gift wishes:\n"; // build the body of the email $wishes = Wish::model()->findAll(); foreach ($wishes as $w) { $email .= "\t" . $w->title . "\n"; } $email .= "Please come to my website to see more about " . "my collection and play some games."; Yii::log("My wishlist email message is [" . $email . "]", 'info', 'jobprocessor'); $wishgivers = User::model()->not_admin()->findAll(); foreach ($wishgivers as $wg) { Yii::log("Sending wishlist to " . $wg->username, 'info', 'jobprocessor'); //mail($email, $subject, $body, $headers); } }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Wish::model()->with('type')->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function getMyWishList() { $title = 'Mis articulos | Nia Boutique.com'; $wish = Wish::join('item', 'item.id', '=', 'wish_list.item_id')->join('miscelanias', 'item.id', '=', 'miscelanias.item_id')->leftJoin('images', 'miscelanias.id', '=', 'images.misc_id')->groupBy('item.id')->where('user_id', '=', Auth::user()->id)->where('item.deleted', '=', 0)->where('wish_list.deleted', '=', 0)->get(array('images.image', 'item.*')); return View::make('user.wishlist')->with('title', $title)->with('wish', $wish); }
public function displayMain() { global $cookie; /* when user add or change address,from addressView or joinView */ if (isset($_GET['ajaxStates']) and isset($_GET['id_country'])) { $states = Db::getInstance()->getAll(' SELECT s.id_state, s.name FROM ' . DB_PREFIX . 'state s LEFT JOIN ' . DB_PREFIX . 'country c ON (s.`id_country` = c.`id_country`) WHERE s.id_country = ' . (int) Tools::G('id_country') . ' AND s.active = 1 AND c.`need_state` = 1 ORDER BY s.`name` ASC'); if (is_array($states) and !empty($states)) { $list = ''; if (Tools::G('no_empty') != true) { $list = '<option value="0">-----------</option>' . "\n"; } foreach ($states as $state) { $list .= '<option value="' . (int) $state['id_state'] . '"' . (Tools::G('id_state') == $state['id_state'] ? ' selected="selected"' : '') . '>' . $state['name'] . '</option>' . "\n"; } } else { $list = 'false'; } die($list); } //end get states /* from cartView get total */ if (isset($_GET['getTotal']) and isset($_GET['id_cart']) and isset($_GET['id_carrier'])) { $carrier = new Carrier((int) $_GET['id_carrier']); $cart = new Cart((int) $_GET['id_cart']); $shipping = $carrier->shipping; $p_total = $cart->getProductTotal(); $total = $shipping + $p_total - $cart->discount; $arr = array('name' => $carrier->name, 'shipping' => Tools::displayPrice($shipping), 'total' => Tools::displayPrice($total)); echo json_encode($arr); exit; } //end use gettotal /* start use promo code,from CartView */ if (isset($_GET['validatedPromocode']) && isset($_GET['code'])) { if (!isset($cookie->id_cart)) { $arr = array('status' => "NO", 'msg' => "cart is not init!"); echo json_encode($arr); exit; } $row = Db::getInstance()->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'coupon WHERE code="' . pSQL($_GET['code']) . '" AND active=1'); if ($row) { if ($row['id_user'] == 0 || $row['id_user'] == @$cookie->id_user) { $cart = new Cart($cookie->id_cart); $total = $cart->getProductTotal(); $quantity = $cart->getProductQantity(); $discount = 0; if ($total > $row['total_over'] || $row['quantity_over'] > 0 && $quantity > $row['quantity_over']) { if ($row['off'] > 0) { $discount = (double) $total * $row['off'] / 100; } else { $discount = (double) $row['amount']; } $cart->discount = $discount; if ($cart->update()) { $arr = array('status' => "YES", 'discount' => "-" . Tools::displayPrice($discount), 'total' => Tools::displayPrice($cart->getOrderTotal())); echo json_encode($arr); exit; } } } } $arr = array('status' => "NO", 'msg' => "the code don't found!"); echo json_encode($arr); exit; } //end use promo code /** * 购物车 */ if (Tools::G('c') == 'Cart') { global $cart; switch (Tools::G('m')) { case 'removeItem': if ($cart->deleteProduct(Tools::G('id'))) { $cart_info = $cart->getCartInfo(); $result = array('status' => 'yes', 'cart_total' => Tools::displayPrice($cart_info['cart_total']), 'cart_quantity' => $cart_info['cart_quantity']); die(json_encode($result)); } die(json_encode(array("status" => "no"))); break; case 'plusItem': if ($row = $cart->plusProduct(Tools::G('id'))) { $cart_info = $cart->getCartInfo(); $result = array('status' => 'yes', 'cart_total' => Tools::displayPrice($cart_info['cart_total']), 'cart_quantity' => $cart_info['cart_quantity'], 'item' => array('quantity' => $row['quantity'], 'total' => Tools::displayPrice($row['total']))); die(json_encode($result)); } die(json_encode(array("status" => "no"))); break; case 'minusItem': if ($row = $cart->minusProduct(Tools::G('id'))) { $cart_info = $cart->getCartInfo(); $result = array('status' => 'yes', 'cart_total' => Tools::displayPrice($cart_info['cart_total']), 'cart_quantity' => $cart_info['cart_quantity'], 'item' => array('quantity' => $row['quantity'], 'total' => Tools::displayPrice($row['total']))); die(json_encode($result)); } die(json_encode(array("status" => "no"))); break; case 'deleteMultiItem': if ($cart->deleteMultiProduct(explode(',', Tools::G('id')))) { $cart_info = $cart->getCartInfo(); $result = array('status' => 'yes', 'cart_total' => Tools::displayPrice($cart_info['cart_total']), 'cart_quantity' => $cart_info['cart_quantity']); die(json_encode($result)); } die(json_encode(array("status" => "no"))); break; default: break; } } /** * 商品收藏 */ if (Tools::G('c') == 'Wish') { if (!isset($cookie->id_user)) { die(json_encode(array("status" => "no", "msg" => "d'not login!"))); } $user = new User((int) $cookie->id_user); if (!Validate::isLoadedObject($user)) { die(json_encode(array("status" => "no", "msg" => "user load fail!"))); } switch (Tools::G('m')) { case 'addItem': if ($status = $user->addToWish(Tools::G('id'))) { if ($status === 1) { $result = array("m" => "add", 'status' => 'yes'); } else { if ($status === -1) { $result = array("m" => "delete", 'status' => 'yes'); } } die(json_encode($result)); } die(json_encode(array("status" => "no"))); break; default: break; } } /* start use add wish,from ProductView or CategoryView */ if (isset($_GET['action']) && $_GET['action'] == 'add_wish' && isset($_GET['id_product'])) { if ($action = Wish::userAddWishProduct($_GET['id_product'])) { $wishs = Wish::getWishSumByUser(); $count_html = ""; if ($wishs['count'] > 0) { $count_html = "<i>{$wishs['count']}</i>"; } $arr = array('action' => $action, 'count' => $count_html, 'status' => "YES"); echo json_encode($arr); } else { $arr = array('status' => "NO"); echo json_encode($arr); } exit; } //end use add wish /** * 邮箱是否已被注册 */ if (Tools::P('existsEmail')) { $valid = true; if (User::userExists(Tools::P('existsEmail'))) { $valid = false; } echo json_encode(array('valid' => $valid)); } }
public function addToWish($id_product) { if ((int) $id_product == 0) { return false; } $id_wish = Db::getInstance()->getValue('SELECT id_wish FROM ' . DB_PREFIX . 'wish WHERE id_user='******' AND id_product=' . (int) $id_product); if ($id_wish > 0) { $wish = new Wish($id_wish); $wish->delete(); return -1; } else { $wish = new Wish(); $wish->copyFromPost(); $wish->id_user = (int) $this->id; $wish->id_product = (int) $id_product; if ($wish->add()) { return 1; } return false; } }
public function postMyWishList() { if (Request::ajax()) { $id = Input::get('id'); $wish = Wish::where('item_id', '=', $id)->where('deleted', '=', 0)->count(); if ($wish > 0) { return Response::json(array('type' => 'warning')); } $wish = new Wish(); $wish->item_id = $id; $wish->user_id = Auth::user()->id; if ($wish->save()) { return Response::json(array('type' => 'success')); } else { return Response::json(array('type' => 'danger')); } } }