/** * render user edit list page * * @param type $wish_list_id * @param type $userID */ public function editWL($wish_list_id, $userID) { $wishlist = new Wishlist(); if ($wishlist->renderUserWLEdit($wish_list_id, $userID)) { $user_id = $this->session->userdata('admin_edit_user_id'); \CMSFactory\assetManager::create()->registerScript('wishlist')->registerStyle('style')->setData('wishlists', $wishlist->dataModel)->setData('user_id', $user_id)->renderAdmin('wishlistEdit'); } else { redirect($_SERVER['HTTP_REFERER']); } }
/** * Default action is product display. This action requires the product id to be passed. * If we do not receive this id, redirect back to the home page since something * went wrong. */ public function actionView() { $id = Yii::app()->getRequest()->getQuery('id'); if (empty($id)) { _xls_404(); } //Load a product and display the information $model = $this->objProduct = Product::model()->findByPk($id); if (!$model || !$model->IsDisplayable) { _xls_404(); } //If our request_url (based on description) has changed, redirect properly if ($model->request_url != Yii::app()->getRequest()->getQuery('name')) { _xls_301($model->Link); } //Set breadcrumbs $this->breadcrumbs = $model->Breadcrumbs; $this->pageImageUrl = $model->SmallImageAbsolute; $objWishlistAddForm = new WishlistAddForm(); $objWishlistAddForm->id = $this->objProduct->id; $objWishlistAddForm->qty = 1; $objWishlistAddForm->lists = $objWishlistAddForm->getLists(); $objWishlistAddForm->gift_code = Wishlist::LoadFirstCode(); $this->setPageTitle($model->PageTitle); $this->pageDescription = $model->PageDescription; $this->canonicalUrl = $model->canonicalUrl; $this->returnUrl = $model->absoluteLink; $model->intQty = 1; //Raise any events first $objEvent = new CEventProduct(get_class($this), 'onActionProductView', $model); _xls_raise_events('CEventProduct', $objEvent); $this->widget('ext.wscartanimate.wscartanimate'); $this->widget('ext.wsproduct.wsproduct'); $this->render('index', array('model' => $model, 'WishlistAddForm' => $objWishlistAddForm)); }
public function getWishListForWeb($user_id) { $criteria = new CDbCriteria(); $criteria->condition = "user_id = {$user_id}"; $wishlists = Wishlist::model()->findAll($criteria); $wishlist_arr = array(); foreach ($wishlists as $wishlist) { $wishlist_arr[] = $wishlist->post_id; } //var_dump($wishlist_arr); die; $returnArr = array(); $criteria_post = new CDbCriteria(); $criteria_post->addInCondition('t.post_id', $wishlist_arr); $count = Posts::model()->count($criteria_post); $pages = new CPagination($count); $pages->validateCurrentPage = FALSE; $pages->pageSize = Yii::app()->params['RESULT_PER_PAGE']; $pages->applyLimit($criteria_post); $posts = Posts::model()->findAll($criteria_post); $is_followed = User::model()->isFollowedByUser(Yii::app()->session['user_id'], $user_id, 'USER'); $profile = User::model()->findByPk($user_id); foreach ($posts as $post) { $itemArr = Posts::model()->getPostById($post->post_id, Yii::app()->session['user_id']); $returnArr[] = $itemArr; } return array('data' => $returnArr, 'pages' => $pages, 'profile' => $profile, 'is_followed' => $is_followed); // return FALSE; }
public static function LoadFirstCode() { $objLists = Wishlist::LoadUserLists(); if (count($objLists) == 0) { return null; } return $objLists[0]->gift_code; }
public function afterUninstall() { $db = Yii::app()->db; $tablesArray = array(Wishlist::model()->tableName(), WishlistProducts::model()->tableName()); foreach ($tablesArray as $table) { $db->createCommand()->dropTable($table); } return parent::afterUninstall(); }
public function getLists() { $retValue = Wishlist::LoadUserLists(); if (!is_null($retValue)) { return CHtml::listData($retValue, 'gift_code', 'registry_name'); } else { return null; } }
/** * Runs any "cron" jobs necessary * @return void */ public function run() { // Garbage collection Log::garbageCollect(); Cart::garbageCollect(); Wishlist::garbageCollect(); // Check for new version _xls_check_version(); // Attemp to send pending emails $this->_sendQueueEmails(); }
public function testGetTimelineSuccess() { $this->setUpRating(); $this->setUpCountry(); $this->setUpWineNote(); $this->setUpProfile(); $_params = $this->_params; $_params['user_id'] = "user_id"; $response = $this->_getAuth($_params); $error_code = ApiResponse::OK; $user_timeline = array(); $user_timeline[] = $this->_user_id; $user_follow = Follow::where('from_id', $this->_user_id)->orderBy('updated_at', 'asc')->get(); if (isset($user_follow)) { foreach ($user_follow as $user) { $user_timeline[] = $user->to_id; } } $pagination = ApiResponse::pagination(); $page = $pagination['page']; $limit = $pagination['limit']; $wine = Wine::with('winery')->forPage($page, $limit)->get(); $ratings = Rating::whereIn('user_id', $user_timeline)->whereNotNull('wine_unique_id')->with('profile')->with('wine')->forPage($page, $limit)->get(); foreach ($ratings as $rating) { $winery = Winery::where('id', $rating->wine->winery_id)->first(); $rating->winery = $winery; $country = Country::where('id', $rating->winery->country_id)->first(); $rating->winery->country_name = $country->country_name; $like = Like::where('user_id', $this->_user_id)->where('rating_id', $rating->id)->first(); if ($like) { $rating->liked = true; } else { $rating->liked = false; } $wishlist = Wishlist::where('user_id', $this->_user_id)->where('wine_unique_id', $rating->wine_unique_id)->first(); if ($wishlist) { $rating->wishlist = true; } else { $rating->wishlist = false; } if ($rating->wine->image_url != null) { $rating->wine->image_url = URL::asset($rating->wine->image_url); } if ($rating->wine->wine_flag != null) { $rating->wine->wine_flag = URL::asset($rating->wine->wine_flag); } if ($rating->profile->image != null) { $rating->profile->image = URL::asset($rating->profile->image); } $rating->winery = $rating->winery->toArray(); } $data = $ratings; $this->assertEquals(array("code" => ApiResponse::OK, "data" => $ratings->toArray()), json_decode($response->getContent(), true)); }
/** * Create unique key to view orders * @param int $size * @return string */ public function createSecretKey($size = 10) { $result = ''; $chars = '1234567890qweasdzxcrtyfghvbnuioplkjnm'; while (mb_strlen($result, 'utf8') < $size) { $result .= mb_substr($chars, rand(0, mb_strlen($chars, 'utf8')), 1); } if (Wishlist::model()->cache(Yii::app()->controller->cacheTime)->countByAttributes(array('key' => $result)) > 0) { $this->createSecretKey($size); } return $result; }
public function validAccount($attribute, $param) { $objCustomer = Customer::LoadByEmail($this->email); if (!$objCustomer instanceof Customer) { $this->addError($attribute, Yii::t('global', 'Email address not found')); return; } $intQty = Yii::app()->db->createCommand("SELECT COUNT(*) from " . Wishlist::model()->tableName() . "\n\t\t\t\t\tWHERE\n\t\t\t\t\tcustomer_id=" . $objCustomer->id . " AND\n\t\t\t\t\tvisibility=" . Wishlist::PUBLICLIST . ";")->queryScalar(); if ($intQty == 0) { $this->addError($attribute, Yii::t('wishlist', 'No publicly searchable wish lists for this email address.')); return; } }
public static function deleteWishlist($wine_unique_id) { $user_id = Session::get('user_id'); $error_code = ApiResponse::OK; $wishlist = Wishlist::where('user_id', $user_id)->where('wine_unique_id', $wine_unique_id)->first(); if ($wishlist) { $wishlist->delete(); $data = 'wine in wishlist is deleted'; } else { $error_code = ApiResponse::NOT_EXISTED_WINE_WISHLIST; $data = ApiResponse::getErrorContent(ApiResponse::NOT_EXISTED_WINE_WISHLIST); } return array("code" => $error_code, "data" => $data); }
public function run() { DB::table('wishlists')->delete(); $user_id = User::where('email', '*****@*****.**')->first()->user_id; $user_1 = User::where('email', '*****@*****.**')->first()->user_id; $user_2 = User::where('email', '*****@*****.**')->first()->user_id; $wine_1 = Wine::where('wine_id', 1)->first()->wine_unique_id; $wine_2 = Wine::where('wine_id', 2)->first()->wine_unique_id; $wine_3 = Wine::where('wine_id', 3)->first()->wine_unique_id; Wishlist::create(array('id' => '1', 'wine_unique_id' => $wine_1, 'user_id' => $user_id)); Wishlist::create(array('id' => '2', 'wine_unique_id' => $wine_2, 'user_id' => $user_id)); Wishlist::create(array('id' => '3', 'wine_unique_id' => $wine_3, 'user_id' => $user_id)); Wishlist::create(array('id' => '4', 'wine_unique_id' => $wine_1, 'user_id' => $user_1)); Wishlist::create(array('id' => '5', 'wine_unique_id' => $wine_3, 'user_id' => $user_1)); Wishlist::create(array('id' => '6', 'wine_unique_id' => $wine_1, 'user_id' => $user_2)); Wishlist::create(array('id' => '7', 'wine_unique_id' => $wine_3, 'user_id' => $user_2)); }
public function postWishlist() { $rules = array('wishlist' => 'min:8|max:2048'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::route('dashboard.edit.wishlist', ['wishlist' => $this->user->wishlist()->get()])->withErrors($validator)->withInput(Input::all()); } else { $wishlist = Wishlist::whereUserId($this->user->id)->first(); if ($wishlist) { $wishlist->wishlist = Input::get('wishlist'); $wishlist->save(); } else { $wishlist = new Wishlist(); $wishlist->wishlist = Input::get('wishlist'); $this->user->wishlist()->save($wishlist); } return Redirect::route('dashboard'); } }
public function getWishListForWeb($user_id) { $returnArr = array(); $criteria = new CDbCriteria(); $criteria->condition = "user_id = {$user_id}"; $count = Posts::model()->count($criteria); $pages = new CPagination($count); $pages->pageSize = Yii::app()->params['RESULT_PER_PAGE']; $pages->applyLimit($criteria); $posts = Wishlist::model()->findAll($criteria); if ($posts) { foreach ($posts as $post) { $itemArr = Posts::model()->getPostById($post->post_id); $returnArr[] = $itemArr; } return array('data' => $returnArr, 'pages' => $pages); } return FALSE; }
/** * @param int|\Magento\Wishlist\Model\Item|\PHPUnit_Framework_MockObject_MockObject $itemId * @param \Magento\Framework\Object $buyRequest * @param null|array|\Magento\Framework\Object $param * @throws \Magento\Framework\Model\Exception * * @dataProvider updateItemDataProvider */ public function testUpdateItem($itemId, $buyRequest, $param) { $storeId = 1; $productId = 1; $stores = [(new \Magento\Framework\Object())->setId($storeId)]; $newItem = $this->getMockBuilder('Magento\\Wishlist\\Model\\Item')->disableOriginalConstructor()->getMock(); $newItem->expects($this->any())->method('setProductId')->will($this->returnSelf()); $newItem->expects($this->any())->method('setWishlistId')->will($this->returnSelf()); $newItem->expects($this->any())->method('setStoreId')->will($this->returnSelf()); $newItem->expects($this->any())->method('setOptions')->will($this->returnSelf()); $newItem->expects($this->any())->method('setProduct')->will($this->returnSelf()); $newItem->expects($this->any())->method('setQty')->will($this->returnSelf()); $newItem->expects($this->any())->method('getItem')->will($this->returnValue(2)); $this->itemFactory->expects($this->once())->method('create')->will($this->returnValue($newItem)); $this->storeManager->expects($this->any())->method('getStores')->will($this->returnValue($stores)); $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($stores[0])); $product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock(); $product->expects($this->any())->method('getId')->will($this->returnValue($productId)); $product->expects($this->any())->method('getStoreId')->will($this->returnValue($storeId)); $instanceType = $this->getMockBuilder('Magento\\Catalog\\Model\\Product\\Type\\AbstractType')->disableOriginalConstructor()->getMock(); $instanceType->expects($this->once())->method('processConfiguration')->will($this->returnValue($this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock())); $newProduct = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock(); $newProduct->expects($this->any())->method('setStoreId')->with($storeId)->will($this->returnSelf()); $newProduct->expects($this->once())->method('getTypeInstance')->will($this->returnValue($instanceType)); $item = $this->getMockBuilder('Magento\\Wishlist\\Model\\Item')->disableOriginalConstructor()->getMock(); $item->expects($this->once())->method('getProduct')->will($this->returnValue($product)); $items = $this->getMockBuilder('Magento\\Wishlist\\Model\\Resource\\Item\\Collection')->disableOriginalConstructor()->getMock(); $items->expects($this->once())->method('addWishlistFilter')->will($this->returnSelf()); $items->expects($this->once())->method('addStoreFilter')->will($this->returnSelf()); $items->expects($this->once())->method('setVisibilityFilter')->will($this->returnSelf()); $items->expects($this->once())->method('getItemById')->will($this->returnValue($item)); $items->expects($this->any())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$item]))); $this->itemsFactory->expects($this->any())->method('create')->will($this->returnValue($items)); $this->productRepository->expects($this->once())->method('getById')->with($productId, false, $storeId)->will($this->returnValue($newProduct)); $this->assertInstanceOf('Magento\\Wishlist\\Model\\Wishlist', $this->wishlist->updateItem($itemId, $buyRequest, $param)); }
/** * @return \yii\db\ActiveQuery */ public function getWishlists() { return $this->hasMany(Wishlist::className(), ['user_id' => 'id']); }
public static function getActivity() { $user_id = Session::get('user_id'); $error_code = ApiResponse::OK; $act = array(); $ratings = Rating::where('user_id', $user_id)->get(); foreach ($ratings as $rating) { $likes = Like::where('rating_id', $rating->id)->whereNotIn('user_id', [$user_id])->get(); if ($likes) { $title = 'like'; foreach ($likes as $like) { $act[] = Rating::getProfile($like->user_id, $title, $like->id, $rating->id, $like->updated_at); } } $comments = Comment::where('rating_id', $rating->id)->whereNotIn('user_id', [$user_id])->get(); if ($comments) { $title = 'comment'; foreach ($comments as $comment) { $act[] = Rating::getProfile($comment->user_id, $title, $comment->id, $rating->id, $comment->updated_at); } } $wishlists = Wishlist::where('wine_unique_id', $rating->wine_unique_id)->whereNotIn('user_id', [$user_id])->get(); if ($wishlists) { $title = 'wishlist'; foreach ($wishlists as $wishlist) { $act[] = Rating::getProfile($wishlist->user_id, $title, $wishlist->id, $rating->id, $wishlist->updated_at); } } } $user_follow = Follow::where('to_id', $user_id)->get(); if ($user_follow) { $title = 'follow'; foreach ($user_follow as $user) { $act[] = Rating::getProfile($user->from_id, $title, $user->id, null, $user->updated_at); } } $data = Rating::orderBy($act, 'updated_at'); return array("code" => $error_code, "data" => $data); }
public function hookRightColumn($params) { global $errors; require_once dirname(__FILE__) . '/WishList.php'; if ($this->context->customer->isLogged()) { $wishlists = Wishlist::getByIdCustomer($this->context->customer->id); if (empty($this->context->cookie->id_wishlist) === true || WishList::exists($this->context->cookie->id_wishlist, $this->context->customer->id) === false) { if (!sizeof($wishlists)) { $id_wishlist = false; } else { $id_wishlist = (int) $wishlists[0]['id_wishlist']; $this->context->cookie->id_wishlist = (int) $id_wishlist; } } else { $id_wishlist = $this->context->cookie->id_wishlist; } $this->smarty->assign(array('id_wishlist' => $id_wishlist, 'isLogged' => true, 'wishlist_products' => $id_wishlist == false ? false : WishList::getProductByIdCustomer($id_wishlist, $this->context->customer->id, $this->context->language->id, null, true), 'wishlists' => $wishlists, 'ptoken' => Tools::getToken(false))); } else { $this->smarty->assign(array('wishlist_products' => false, 'wishlists' => false)); } $this->smarty->assign(array('wishlist_link' => $this->context->link->getModuleLink('blockwishlist', 'mywishlist'))); return $this->display(__FILE__, 'blockwishlist.tpl'); }
public function hookRightColumn($params) { if ($this->context->customer->isLogged()) { $wishlists = Wishlist::getByIdCustomer($this->context->customer->id); if (empty($this->context->cookie->id_wishlist) === true || WishList::exists($this->context->cookie->id_wishlist, $this->context->customer->id) === false) { if (!count($wishlists)) { $id_wishlist = false; } else { $id_wishlist = (int) $wishlists[0]['id_wishlist']; $this->context->cookie->id_wishlist = (int) $id_wishlist; } } else { $id_wishlist = $this->context->cookie->id_wishlist; } $this->smarty->assign(array('id_wishlist' => $id_wishlist, 'isLogged' => true, 'wishlist_products' => $id_wishlist == false ? false : WishList::getProductByIdCustomer($id_wishlist, $this->context->customer->id, $this->context->language->id, null, true), 'wishlists' => $wishlists, 'ptoken' => Tools::getToken(false))); } else { $this->smarty->assign(array('wishlist_products' => false, 'wishlists' => false)); } return $this->display(__FILE__, 'blockwishlist.tpl'); }
public function hookRightColumn($params) { global $smarty; global $errors; if (Configuration::get('PS_BLOCK_WISHLIST_ACTIVATED') == 0) { return null; } require_once dirname(__FILE__) . '/WishList.php'; if ($params['cookie']->isLogged()) { $wishlists = Wishlist::getByIdCustomer($params['cookie']->id_customer); if (empty($params['cookie']->id_wishlist) === true || WishList::exists($params['cookie']->id_wishlist, $params['cookie']->id_customer) === false) { if (!sizeof($wishlists)) { $id_wishlist = false; } else { $id_wishlist = intval($wishlists[0]['id_wishlist']); $params['cookie']->id_wishlist = intval($id_wishlist); } } else { $id_wishlist = $params['cookie']->id_wishlist; } $smarty->assign(array('id_wishlist' => $id_wishlist, 'isLogged' => true, 'products' => $id_wishlist == false ? false : WishList::getProductByIdCustomer($id_wishlist, $params['cookie']->id_customer, $params['cookie']->id_lang, null, true), 'wishlists' => $wishlists, 'ptoken' => Tools::getToken(false))); } else { $smarty->assign(array('products' => false, 'wishlists' => false)); } return $this->display(__FILE__, 'blockwishlist.tpl'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($wine_unique_id) { $result = Wishlist::deleteWishlist($wine_unique_id); return Response::json($result); }
<div id="wish-lists" class="col-sm-12 clickbar" onclick="$('#WishList').slideToggle('fast');"><?php echo Yii::t('global', 'Wish Lists'); ?> </div> <div class="containers" id="WishList" style="display:hidden;"> <?php if (!Yii::app()->user->isGuest) { foreach (Wishlist::LoadUserLists() as $list) { ?> <a href="<?php echo Yii::app()->createUrl('wishlist/view', array('code' => $list->gift_code)); ?> "> <strong><?php echo $list->registry_name; ?> </strong></a><br /> <?php } ?> </br> <a id="wish-lists-view" href="<?php echo Yii::app()->createUrl('/wishlist'); ?> "><strong><?php echo Yii::t('global', 'View all my wish lists'); ?> </strong></a> <br /> <a id="wish-lists-view-create" href="<?php echo Yii::app()->createUrl('wishlist/create');
public function testDeleteWishlistErrorNoWishlist() { $wishlist = Wishlist::destroy(1); $response = $this->action('delete', 'WishlistController@destroy', array('wine_unique_id' => "1_2009")); $this->assertEquals(array("code" => ApiResponse::NOT_EXISTED_WINE_WISHLIST, "data" => ApiResponse::getErrorContent(ApiResponse::NOT_EXISTED_WINE_WISHLIST)), json_decode($response->getContent(), true)); }
/** * Display the logged in user's list of addresses * and handle them choosing one * * @return void */ public function actionShippingAddress() { $this->publishJS('shipping'); $this->publishJS('zippo'); $this->layout = '/layouts/checkout'; $error = null; $this->checkoutForm = MultiCheckoutForm::loadFromSessionOrNew(); $arrObjAddresses = CustomerAddress::getActiveAddresses(); // if the logged in customer has no addresses saved on file // take them to the page where they can enter an address if (count($arrObjAddresses) < 1) { $this->redirect($this->createAbsoluteUrl('/checkout/shipping')); } $arrFirst = array(); $objCart = Yii::app()->shoppingcart; // if the logged in user has a default shipping address // make it appear first foreach ($arrObjAddresses as $key => $address) { if ($address->id == $objCart->customer->default_shipping_id) { $arrFirst['first'] = $address; // assign an index to avoid accidental overwrite unset($arrObjAddresses[$key]); } } $this->checkoutForm->objAddresses = array_values($arrFirst + $arrObjAddresses); $this->checkoutForm->saveFormToSession(); // populate our form with some default values in case the user // was logged in already and bypassed checkout login if (isset($this->checkoutForm->contactEmail) === false) { $this->checkoutForm->contactEmail = $objCart->customer->email; } if (isset($this->checkoutForm->contactEmail_repeat) === false) { $this->checkoutForm->contactEmail_repeat = $objCart->customer->email; } if (isset($_POST['MultiCheckoutForm'])) { $this->checkoutForm->attributes = $_POST['MultiCheckoutForm']; } $hasErrors = false; $inStorePickupSelected = isset($_POST['storePickupCheckBox']) && $_POST['storePickupCheckBox'] == 1; // If in-store pickup was previously selected but has been deselected, make sure it's no longer used. if ($inStorePickupSelected === false && $this->checkoutForm->isStorePickupSelected()) { // TODO: Factor out this and the similar check in actionShipping. $this->checkoutForm->shippingProvider = null; $this->checkoutForm->shippingPriority = null; $this->checkoutForm->pickupFirstName = null; $this->checkoutForm->pickupLastName = null; } $addressId = Yii::app()->getRequest()->getPost('Address_id'); $wishlistId = Yii::app()->getRequest()->getPost('wishlistId'); // Store pickup. if ($inStorePickupSelected === true) { // store pickup is chosen $this->checkoutForm->fillFieldsForStorePickup(); $this->checkoutForm->setScenario('StorePickup'); $redirectUrl = $this->createUrl('/checkout/final'); if ($this->checkoutForm->validate() === false) { $hasErrors = true; } } elseif ($addressId || $wishlistId) { $customerId = null; if ($wishlistId) { $wishlist = Wishlist::model()->findByPk($wishlistId); $addressId = $wishlist->ship_option; $customerId = $wishlist->customer_id; } // An existing shipping address is chosen. $result = $this->checkoutForm->fetchCustomerShippingAddress($addressId, $customerId); if ($result === false) { $this->redirect($this->createAbsoluteUrl("/checkout/shippingaddress")); } $this->checkoutForm->setScenario('Shipping'); $redirectUrl = $this->createUrl('/checkout/shippingoptions'); if ($this->checkoutForm->validate() == false) { $hasErrors = true; } } else { $wishlist = null; $wishlistAddress = null; // If any of the cart items are on a wishlist, then we show the // wishlist address to the user. foreach ($objCart->cartItems as $item) { if ($item->wishlist_item !== null) { $wishlist = $item->wishlistItem()->registry(); $wishlistAddressId = $wishlist->ship_option; $wishlistAddress = CustomerAddress::model()->findByPk($wishlistAddressId); break; // Multiple wishlist addresses are not yet supported. } } // Nothing was posted, just render the shipping address page. $this->render('shippingaddress', array('model' => $this->checkoutForm, 'error' => $this->formatErrors(), 'wishlist' => $wishlist, 'wishlistAddress' => $wishlistAddress)); return; } // Update address ID if there are no errors. if ($hasErrors === false) { $this->checkoutForm->updateAddressId(); // An error occurred in updateAddressId. if (count($this->checkoutForm->getErrors())) { $hasErrors = true; } } // A validation error occurred. if ($hasErrors === true) { $this->render('shippingaddress', array('model' => $this->checkoutForm, 'error' => $this->formatErrors())); return; } // Update the shipping scenarios based on the new address. $this->checkoutForm->saveFormToSession(); Shipping::updateCartScenariosInSession(); // If in-store pickup was selected we need to update the cart now // before moving to checkout/final. Otherwise, the address will be // validated at the next step and the taxes updated. if ($inStorePickupSelected === true) { // Update the shopping cart taxes. Yii::app()->shoppingcart->setTaxCodeByCheckoutForm($this->checkoutForm); // Update shipping. If in-store pickup was chosen then we need to // ensure the cart shipping values are updated. // Update shipping. If in-store pickup was chosen then we need to // ensure the cart shipping values are updated. $objShipping = CartShipping::getOrCreateCartShipping(); if ($objShipping->hasErrors() === false) { $objShipping->updateShipping(); $this->checkoutForm->addErrors($objShipping->getErrors()); } else { $this->checkoutForm->addErrors($objShipping->getErrors()); } } // Save the passed scenario and redirect to the next stage. $this->checkoutForm->passedScenario = $this->checkoutForm->getScenario(); $this->redirect($redirectUrl); }
$quantity = (int) Tools::getValue('quantity'); $id_product_attribute = (int) Tools::getValue('id_product_attribute'); if (Configuration::get('PS_TOKEN_ENABLE') == 1 and strcmp(Tools::getToken(false), Tools::getValue('token')) and $cookie->isLogged() === true) { echo Tools::displayError('Invalid token'); } if ($cookie->isLogged()) { if ($id_wishlist and WishList::exists($id_wishlist, $cookie->id_customer) === true) { $cookie->id_wishlist = (int) $id_wishlist; } if (empty($cookie->id_wishlist) === true or $cookie->id_wishlist == false) { $smarty->assign('error', true); } if (($add or $delete) and empty($id_product) === false) { if (!isset($cookie->id_wishlist) or $cookie->id_wishlist == '') { // Try to get an existing wishlist before creating a new one (useful if there is no wishlist block hooked left or right) $wishlists = Wishlist::getByIdCustomer($cookie->id_customer); if (!empty($wishlists)) { $id_wishlist = (int) $wishlists[0]['id_wishlist']; $cookie->id_wishlist = (int) $id_wishlist; } else { $wishlist = new WishList(); $modWishlist = new BlockWishList(); $wishlist->name = $modWishlist->default_wishlist_name; $wishlist->id_customer = (int) $cookie->id_customer; list($us, $s) = explode(' ', microtime()); srand($s * $us); $wishlist->token = strtoupper(substr(sha1(uniqid(rand(), true) . _COOKIE_KEY_ . $cookie->id_customer), 0, 16)); $wishlist->add(); $cookie->id_wishlist = (int) $wishlist->id; } }
/** * 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 $id the ID of the model to be loaded * @return Wishlist the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Wishlist::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public static function searchWinefromMywine($input) { $error_code = ApiResponse::OK; $wine_unique_id = array(); $data = array(); $user_id = Session::get('user_id'); if (!empty($input['text'])) { $text = $input['text']; $ratings = Rating::where('user_id', $user_id)->where('is_my_wine', 1)->get(); if ($ratings) { foreach ($ratings as $rating) { $wine_unique_id[] = $rating->wine_unique_id; } if ($wine_unique_id != null) { $wishlists = Wishlist::where('user_id', $user_id)->whereNotIn('wine_unique_id', $wine_unique_id)->get(); } else { $wishlists = Wishlist::where('user_id', $user_id)->get(); } if ($wishlists) { foreach ($wishlists as $wishlist) { $wine_unique_id[] = $wishlist->wine_unique_id; } } } if ($wine_unique_id != null) { $wines = Wine::where('name', 'LIKE', '%' . $text . '%')->whereIn('wine_unique_id', $wine_unique_id)->with('winery')->get(); if ($wines) { foreach ($wines as $wine) { if ($wine->image_url != null) { $wine->image_url = URL::asset($wine->image_url); } if ($wine->wine_flag != null) { $wine->wine_flag = URL::asset($wine->wine_flag); } $data[] = $wine; } } } } else { $error_code = ApiResponse::MISSING_PARAMS; $data = $input; } return array("code" => $error_code, "data" => $data); }
public function actionEmail() { if (Yii::app()->user->isGuest) { _xls_404(); } $model = new ShareForm(); if (isset($_POST['ShareForm'])) { $model->attributes = $_POST['ShareForm']; if ($model->validate()) { $strCode = $model->code; //Make sure code we've been passed is valid $objWishlist = Wishlist::model()->findByAttributes(array('gift_code' => $strCode)); if (!$objWishlist->Visible) { _xls_404(); } if (!Yii::app()->user->isGuest) { $objCustomer = Customer::model()->findByPk(Yii::app()->user->Id); $model->fromEmail = $objCustomer->email; $model->fromName = $objCustomer->fullname; } $strHtmlBody = $this->renderPartial('/mail/_cart', array('model' => $model), true); $strSubject = _xls_format_email_subject('EMAIL_SUBJECT_WISHLIST', $objWishlist->customer->fullname, null); $objEmail = new EmailQueue(); $objEmail->customer_id = $objWishlist->customer_id; $objEmail->htmlbody = $strHtmlBody; $objEmail->subject = $strSubject; $objEmail->to = $model->toEmail; $objHtml = new HtmlToText(); //If we get back false, it means conversion failed which 99.9% of the time means improper HTML. $strPlain = $objHtml->convert_html_to_text($strHtmlBody); if ($strPlain !== false) { $objEmail->plainbody = $strPlain; } $objEmail->save(); $response_array = array('status' => "success", 'message' => Yii::t('wishlist', 'Your wish list has been sent'), 'url' => CController::createUrl('site/sendemail', array("id" => $objEmail->id)), 'reload' => true); } else { $response_array['status'] = 'error'; $response_array['errormsg'] = _xls_convert_errors($model->getErrors()); } echo json_encode($response_array); } }
public function checkIfPostIsBookmarked($post_id, $user_id) { $check = Wishlist::model()->findByAttributes(array('post_id' => $post_id, 'user_id' => $user_id)); if ($check) { return TRUE; } return FALSE; }
public static function getProfileWishlistUser($user_id) { $error_code = ApiResponse::OK; $pagination = ApiResponse::pagination(); if ($pagination == false) { $error_code = ApiResponse::URL_NOT_EXIST; $data = ApiResponse::getErrorContent(ApiResponse::URL_NOT_EXIST); } else { $page = $pagination['page']; $limit = $pagination['limit']; if (User::where('user_id', $user_id)->first()) { $profile = Profile::where('user_id', $user_id)->first(); if ($profile->image != null) { $profile->image = URL::asset($profile->image); } $wishlists = Wishlist::where('user_id', $user_id)->with('wine')->forPage($page, $limit)->get(); if (count($wishlists) == 0) { $data = array(); } else { foreach ($wishlists as $wishlist) { $wishlist->winery = Winery::where('id', $wishlist->wine->winery_id)->first(); if ($wishlist->wine->image_url != null) { $wishlist->wine->image_url = URL::asset($wishlist->wine->image_url); } if ($wishlist->wine->wine_flag != null) { $wishlist->wine->wine_flag = URL::asset($wishlist->wine->wine_flag); } } $data = $wishlists->toArray(); } } else { $error_code = ApiResponse::UNAVAILABLE_USER; $data = ApiResponse::getErrorContent(ApiResponse::UNAVAILABLE_USER); } } return array("code" => $error_code, "data" => $data); }