本文整理汇总了PHP中WishList类的典型用法代码示例。如果您正苦于以下问题:PHP WishList类的具体用法?PHP WishList怎么用?PHP WishList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WishList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_for_user
/**
* @param Member $member [optional] - defaults to current user
* @return DataList
*/
public static function get_for_user(Member $member = null)
{
if (!$member) {
$member = Member::currentUser();
}
if (!$member) {
return null;
}
return WishList::get()->filter('OwnerID', $member->ID);
}
示例2: updateGroupWishListResponse
/**
* @param SS_HTTPRequest $request
* @param AjaxHTTPResponse $response
* @param GroupedProduct $groupedProduct
* @param array $data
* @param GroupedCartForm $form [optional]
*/
public function updateGroupWishListResponse(&$request, &$response, $groupedProduct, $data, $form = null)
{
if ($request->isAjax() && $this->owner->getController()->hasExtension('AjaxControllerExtension')) {
if (!$response) {
$response = $this->owner->getController()->getAjaxResponse();
}
$this->setupRenderContexts($response, $groupedProduct, $form);
$response->triggerEvent('wishlistadd');
$response->triggerEvent('wishlistchange', array('action' => 'add'));
$n = 0;
foreach ($data['Product'] as $info) {
if ($info['Quantity'] > 0) {
$n++;
}
}
$s = $n == 1 ? '' : 's';
$response->triggerEvent('statusmessage', "{$n} item{$s} added to " . WishList::current()->getTitle());
}
}
示例3: uninstall
function uninstall()
{
global $application;
$query = new DB_Table_Delete(WishList::getTables());
$application->db->getDB_Result($query);
}
示例4: addProduct
/**
* Add product to ID wishlist
*
* @return boolean succeed
*/
public static function addProduct($id_wishlist, $id_customer, $id_product, $id_product_attribute, $quantity)
{
if (!Validate::isUnsignedId($id_wishlist) or !Validate::isUnsignedId($id_customer) or !Validate::isUnsignedId($id_product) or !Validate::isUnsignedId($quantity)) {
die(Tools::displayError());
}
$result = Db::getInstance()->getRow('
SELECT wp.`quantity`
FROM `' . _DB_PREFIX_ . 'wishlist_product` wp
JOIN `' . _DB_PREFIX_ . 'wishlist` w ON (w.`id_wishlist` = wp.`id_wishlist`)
WHERE wp.`id_wishlist` = ' . (int) $id_wishlist . '
AND w.`id_customer` = ' . (int) $id_customer . '
AND wp.`id_product` = ' . (int) $id_product . '
AND wp.`id_product_attribute` = ' . (int) $id_product_attribute);
if (empty($result) === false and sizeof($result)) {
if ($result['quantity'] + $quantity <= 0) {
return WishList::removeProduct($id_wishlist, $id_customer, $id_product, $id_product_attribute);
} else {
return Db::getInstance()->Execute('
UPDATE `' . _DB_PREFIX_ . 'wishlist_product` SET
`quantity` = ' . (int) ($quantity + $result['quantity']) . '
WHERE `id_wishlist` = ' . (int) $id_wishlist . '
AND `id_product` = ' . (int) $id_product . '
AND `id_product_attribute` = ' . (int) $id_product_attribute);
}
} else {
return Db::getInstance()->Execute('
INSERT INTO `' . _DB_PREFIX_ . 'wishlist_product` (`id_wishlist`, `id_product`, `id_product_attribute`, `quantity`, `priority`) VALUES(
' . (int) $id_wishlist . ',
' . (int) $id_product . ',
' . (int) $id_product_attribute . ',
' . (int) $quantity . ', 1)');
}
}
示例5: foreach
continue;
} else {
if ($products[$i]['id_product_attribute'] != 0 && isset($combination_imgs[$products[$i]['id_product_attribute']][0])) {
$combination_imgs = $obj->getCombinationImages((int) $cookie->id_lang);
$products[$i]['cover'] = $obj->id . '-' . $combination_imgs[$products[$i]['id_product_attribute']][0]['id_image'];
} else {
$images = $obj->getImages((int) $cookie->id_lang);
foreach ($images as $k => $image) {
if ($image['cover']) {
$products[$i]['cover'] = $obj->id . '-' . $image['id_image'];
break;
}
}
if (!isset($products[$i]['cover'])) {
$products[$i]['cover'] = Language::getIsoById((int) $cookie->id_lang) . '-default';
}
}
}
}
WishList::incCounter((int) $wishlist['id_wishlist']);
$ajax = Configuration::get('PS_BLOCK_CART_AJAX');
$smarty->assign(array('current_wishlist' => $wishlist, 'token' => $token, 'ajax' => (isset($ajax) and (int) $ajax == 1) ? '1' : '0', 'wishlists' => WishList::getByIdCustomer((int) $wishlist['id_customer']), 'products' => $products));
}
if (Tools::file_exists_cache(_PS_THEME_DIR_ . 'modules/blockwishlist/view.tpl')) {
$smarty->display(_PS_THEME_DIR_ . 'modules/blockwishlist/view.tpl');
} elseif (Tools::file_exists_cache(dirname(__FILE__) . '/view.tpl')) {
$smarty->display(dirname(__FILE__) . '/view.tpl');
} else {
echo Tools::displayError('No template found');
}
require dirname(__FILE__) . '/../../footer.php';
示例6: array
Mail::Send($context->language->id, 'wishlink', Mail::l('Your wishlist\'s link', $context->language->id), array('{wishlist}' => $wishlist->name, '{message}' => Tools::getProtocol() . htmlentities($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/blockwishlist/view.php?token=' . $wishlist->token), $context->customer->email, $context->customer->firstname . ' ' . $context->customer->lastname, NULL, strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__) . '/mails/');
}
}
} else {
if ($add) {
WishList::addCardToWishlist($context->customer->id, Tools::getValue('id_wishlist'), $context->language->id);
} else {
if ($delete and empty($id_wishlist) === false) {
$wishlist = new WishList((int) $id_wishlist);
if (Validate::isLoadedObject($wishlist)) {
$wishlist->delete();
} else {
$errors[] = $module->l('Cannot delete this wishlist', 'mywishlist');
}
}
}
}
$context->smarty->assign('wishlists', WishList::getByIdCustomer($context->customer->id));
$context->smarty->assign('nbProducts', WishList::getInfosByIdCustomer($context->customer->id));
} else {
Tools::redirect('index.php?controller=authentication&back=modules/blockwishlist/mywishlist.php');
}
$context->smarty->assign(array('id_customer' => (int) $context->customer->id, 'errors' => $errors));
if (Tools::file_exists_cache(_PS_THEME_DIR_ . 'modules/blockwishlist/mywishlist.tpl')) {
$context->smarty->display(_PS_THEME_DIR_ . 'modules/blockwishlist/mywishlist.tpl');
} elseif (Tools::file_exists_cache(dirname(__FILE__) . '/views/templates/front/mywishlist.tpl')) {
$context->smarty->display(dirname(__FILE__) . '/views/templates/front/mywishlist.tpl');
} else {
echo $module->l('No template found', 'mywishlist');
}
include dirname(__FILE__) . '/../../footer.php';
示例7: hookAdminCustomers
public function hookAdminCustomers($params)
{
require_once dirname(__FILE__) . '/WishList.php';
$customer = new Customer((int) $params['id_customer']);
if (!Validate::isLoadedObject($customer)) {
die(Tools::displayError());
}
$this->_html = '<h2>' . $this->l('Wishlists') . '</h2>';
$wishlists = WishList::getByIdCustomer((int) $customer->id);
if (!sizeof($wishlists)) {
$this->_html .= $customer->lastname . ' ' . $customer->firstname . ' ' . $this->l('No wishlist.');
} else {
$this->_html .= '<form action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" method="post" id="listing">';
$id_wishlist = (int) Tools::getValue('id_wishlist');
if (!$id_wishlist) {
$id_wishlist = $wishlists[0]['id_wishlist'];
}
$this->_html .= '<span>' . $this->l('Wishlist') . ': </span> <select name="id_wishlist" onchange="$(\'#listing\').submit();">';
foreach ($wishlists as $wishlist) {
$this->_html .= '<option value="' . (int) $wishlist['id_wishlist'] . '"';
if ($wishlist['id_wishlist'] == $id_wishlist) {
$this->_html .= ' selected="selected"';
$counter = $wishlist['counter'];
}
$this->_html .= '>' . htmlentities($wishlist['name'], ENT_COMPAT, 'UTF-8') . '</option>';
}
$this->_html .= '</select>';
$this->_displayProducts((int) $id_wishlist);
$this->_html .= '</form><br />';
return $this->_html;
}
}
示例8: findProductByName
{
return $this->items;
}
public function findProductByName($name)
{
$itemKey = null;
foreach ($this->items as $key => $item) {
if ($name == $item->getName()) {
$itemKey = $key + 1;
echo "{$name} is number {$itemKey} in the array";
break;
}
}
if ($itemKey == null) {
throw new Exception("Item was not found in cart");
}
}
}
$describer = new ItemDescriber();
$kramericaTV = new Television("Giant TV", "Kramerica", 3900.9, "LED", "100in");
$shirt = new Clothing("Button Down Shirt", "J Peterman", '29.88', "shirt", "medium", "red", "male");
$Wishlist = new WishList();
$Wishlist->addProduct($kramericaTV);
$Wishlist->addProduct($shirt);
$ShoppingCart = $Wishlist->createCartFromContainer($Wishlist);
$Wishlist->provideDescription();
$ShoppingCart->provideDescription();
?>
</p>
</body>
</html>
示例9: getHashFromCart
Tools::redirect('modules/wishlist/display.php?id=' . getHashFromCart($wishlist_cart));
} else {
if (Tools::isSubmit("addAllToCart")) {
copyQty($wishlist_cart, $cart);
Tools::redirect('modules/wishlist/display.php?id=' . getHashFromCart($wishlist_cart));
}
}
}
$errors = array();
$smarty->assign('errors', $errors);
$smarty->assign('mdl_dir', dirname(__FILE__) . '/');
$smarty->assign("currency_iso_code", $currency->iso_code);
$smarty->assign("currency_name", $currency->name);
$smarty->assign('cart_hash_id', $_GET['id']);
if (!$wishlist_cart->nbProducts()) {
$smarty->assign('empty', 1);
}
if (file_exists(_PS_SHIP_IMG_DIR_ . intval($wishlist_cart->id_carrier) . '.jpg')) {
$smarty->assign('carrierPicture', 1);
}
$summary = $wishlist_cart->getSummaryDetails();
$customizedDatas = Product::getAllCustomizedDatas(intval($wishlist_cart->id));
Product::addCustomizationPrice($summary['products'], $customizedDatas);
$smarty->assign($summary);
$smarty->assign(array('customizedDatas' => $customizedDatas, 'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_, 'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_, 'lastProductAdded' => $wishlist_cart->getLastProduct()));
$smarty->assign('cart', $wishlist_cart);
Tools::safePostVars();
include_once dirname(__FILE__) . '/../../header.php';
$lst = new WishList();
echo $lst->display(dirname(__FILE__) . '/wishlist.php', 'wishlist.tpl');
include dirname(__FILE__) . '/../../footer.php';
示例10: testMultipleLists
public function testMultipleLists()
{
WishList::set_current(null);
$m1 = $this->objFromFixture('Member', 'm1');
$m2 = $this->objFromFixture('Member', 'm2');
$m1->logIn();
$p1 = $this->objFromFixture('Product', 'p1');
$p2 = $this->objFromFixture('Product', 'p2');
$p3 = $this->objFromFixture('Product', 'p3');
// should be able to retrieve a list of lists
$allLists = WishList::get_for_user();
$this->assertNotNull($allLists);
$this->assertTrue($allLists instanceof DataList);
// should initially be 0 lists
$this->assertEquals(0, WishList::get_for_user()->count());
$this->assertEquals(0, WishList::get_for_user($m2)->count());
// current method should create one list
$l1 = WishList::current();
$l1->write();
$l1->addBuyable($p1);
//Debug::dump(array($l1, WishList::get_for_user()->sql(), WishList::get_for_user()->count(), WishList::get_for_user()->getIDList()));
$this->assertEquals(1, WishList::get_for_user()->count());
$this->assertEquals(0, WishList::get_for_user($m2)->count());
// after manually creating a list there should be two lists
$l2 = new WishList(array('OwnerID' => $m1->ID, 'Title' => 'Christmas'));
$l2->write();
$this->assertEquals(2, WishList::get_for_user()->count());
// after adding a product to one list, it should not be present in the other one
// but should still report that it is in a list
$l2->addBuyable($p2);
$this->assertTrue($p1->IsInWishList());
$this->assertTrue($l1->hasBuyable($p1));
$this->assertFalse($l2->hasBuyable($p1));
$this->assertTrue($p2->IsInWishList());
$this->assertFalse($l1->hasBuyable($p2));
$this->assertTrue($l2->hasBuyable($p2));
$this->assertFalse($p3->IsInWishList());
$this->assertFalse($l1->hasBuyable($p3));
$this->assertFalse($l2->hasBuyable($p3));
// after creating a list for the a different user and adding
// an item to that list, the item should not report that it is
// in a list and should not be present in any of the other lists
$l3 = new WishList(array('OwnerID' => $m2->ID, 'Title' => 'Christmas for someone else'));
$l3->write();
$l3->addBuyable($p3);
$this->assertEquals(2, WishList::get_for_user()->count());
$this->assertEquals(1, WishList::get_for_user($m2)->count());
$this->assertFalse($p3->IsInWishList());
$this->assertFalse($l1->hasBuyable($p3));
$this->assertFalse($l2->hasBuyable($p3));
// Buyable should be able to exist in two lists at once
$l2->addBuyable($p1);
$this->assertTrue($p1->IsInWishList());
$this->assertTrue($l1->hasBuyable($p1));
$this->assertTrue($l2->hasBuyable($p1));
// removing an item from one list should not remove it from the other
$l1->removeBuyable($p1);
$this->assertTrue($p1->IsInWishList());
$this->assertFalse($l1->hasBuyable($p1));
$this->assertTrue($l2->hasBuyable($p1));
// after removing item from both lists it should report as not being in a list
$l2->removeBuyable($p1);
$this->assertFalse($p1->IsInWishList());
$this->assertFalse($l1->hasBuyable($p1));
$this->assertFalse($l2->hasBuyable($p1));
}
示例11: createNewWishListForUser
public function createNewWishListForUser(User $user, $name = 'New Wish List', $type = WishList::TYPE_PRIVATE)
{
if (!$user || !$user->loaded()) {
throw new \InvalidArgumentException('User is not valid.');
}
$wishList = new WishList($this->pixie);
if (!$wishList->isValidType($type)) {
$type = WishList::TYPE_PRIVATE;
}
$wishList->type = $type;
$wishList->name = $name;
$wishList->created = date('Y-m-d H:i:s');
$wishList->addToUser($user);
$wishList->save();
return $wishList;
}
示例12: WishList
$errors[] = Tools::displayError('invalid token');
}
if (!sizeof($errors)) {
$name = Tools::getValue('name');
$wishlist = new WishList();
$wishlist->name = $name;
$wishlist->id_customer = $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();
}
} else {
if ($add) {
WishList::addCardToWishlist(intval($cookie->id_customer), intval(Tools::getValue('id_wishlist')), intval($cookie->id_lang));
} else {
if ($delete and empty($id_wishlist) === false) {
$wishlist = new WishList(intval($id_wishlist));
$wishlist->delete();
}
}
}
$smarty->assign('wishlists', WishList::getByIdCustomer(intval($cookie->id_customer)));
$smarty->assign('nbProducts', WishList::getInfosByIdCustomer(intval($cookie->id_customer)));
} else {
$errors[] = Tools::displayError('You need to be logged to manage your wishlist');
}
$smarty->assign('id_customer', intval($cookie->id_customer));
$smarty->assign('errors', $errors);
$smarty->display(dirname(__FILE__) . '/mywishlist.tpl');
include dirname(__FILE__) . '/../../footer.php';
示例13: AllLists
/**
* @return DataList
*/
public function AllLists()
{
return WishList::get_for_user();
}
示例14: initContent
public function initContent()
{
parent::initContent();
$token = Tools::getValue('token');
$module = new BlockWishList();
if ($token) {
$wishlist = WishList::getByToken($token);
WishList::refreshWishList($wishlist['id_wishlist']);
$products = WishList::getProductByIdCustomer((int) $wishlist['id_wishlist'], (int) $wishlist['id_customer'], $this->context->language->id, null, true);
$nb_products = count($products);
$priority_names = array(0 => $module->l('High'), 1 => $module->l('Medium'), 2 => $module->l('Low'));
for ($i = 0; $i < $nb_products; ++$i) {
$obj = new Product((int) $products[$i]['id_product'], true, $this->context->language->id);
if (!Validate::isLoadedObject($obj)) {
continue;
} else {
$products[$i]['priority_name'] = $priority_names[$products[$i]['priority']];
$quantity = Product::getQuantity((int) $products[$i]['id_product'], $products[$i]['id_product_attribute']);
$products[$i]['attribute_quantity'] = $quantity;
$products[$i]['product_quantity'] = $quantity;
$products[$i]['allow_oosp'] = $obj->isAvailableWhenOutOfStock((int) $obj->out_of_stock);
if ($products[$i]['id_product_attribute'] != 0) {
$combination_imgs = $obj->getCombinationImages($this->context->language->id);
if (isset($combination_imgs[$products[$i]['id_product_attribute']][0])) {
$products[$i]['cover'] = $obj->id . '-' . $combination_imgs[$products[$i]['id_product_attribute']][0]['id_image'];
} else {
$cover = Product::getCover($obj->id);
$products[$i]['cover'] = $obj->id . '-' . $cover['id_image'];
}
} else {
$images = $obj->getImages($this->context->language->id);
foreach ($images as $image) {
if ($image['cover']) {
$products[$i]['cover'] = $obj->id . '-' . $image['id_image'];
break;
}
}
}
if (!isset($products[$i]['cover'])) {
$products[$i]['cover'] = $this->context->language->iso_code . '-default';
}
}
$products[$i]['bought'] = false;
/*
for ($j = 0, $k = 0; $j < sizeof($bought); ++$j)
{
if ($bought[$j]['id_product'] == $products[$i]['id_product'] AND
$bought[$j]['id_product_attribute'] == $products[$i]['id_product_attribute']
)
$products[$i]['bought'][$k++] = $bought[$j];
}*/
}
WishList::incCounter((int) $wishlist['id_wishlist']);
$ajax = Configuration::get('PS_BLOCK_CART_AJAX');
$wishlists = WishList::getByIdCustomer((int) $wishlist['id_customer']);
foreach ($wishlists as $key => $item) {
if ($item['id_wishlist'] == $wishlist['id_wishlist']) {
unset($wishlists[$key]);
break;
}
}
$this->context->smarty->assign(array('current_wishlist' => $wishlist, 'token' => $token, 'ajax' => isset($ajax) && (int) $ajax == 1 ? '1' : '0', 'wishlists' => $wishlists, 'products' => $products));
}
$this->setTemplate('view.tpl');
}
示例15: array
$products[$i]['cover'] = $context->language->iso_code . '-default';
}
}
$products[$i]['bought'] = false;
for ($j = 0, $k = 0; $j < sizeof($bought); ++$j) {
if ($bought[$j]['id_product'] == $products[$i]['id_product'] and $bought[$j]['id_product_attribute'] == $products[$i]['id_product_attribute']) {
$products[$i]['bought'][$k++] = $bought[$j];
}
}
}
$productBoughts = array();
foreach ($products as $product) {
if (sizeof($product['bought'])) {
$productBoughts[] = $product;
}
}
$context->smarty->assign(array('products' => $products, 'productsBoughts' => $productBoughts, 'id_wishlist' => $id_wishlist, 'refresh' => $refresh, 'token_wish' => $wishlist->token, 'wishlists' => WishList::getByIdCustomer($cookie->id_customer)));
// Instance of module class for translations
$module = new BlockWishList();
if (Tools::file_exists_cache(_PS_THEME_DIR_ . 'modules/blockwishlist/views/templates/front/managewishlist.tpl')) {
$context->smarty->display(_PS_THEME_DIR_ . 'modules/blockwishlist/views/templates/front/managewishlist.tpl');
} elseif (Tools::file_exists_cache(dirname(__FILE__) . '/views/templates/front/managewishlist.tpl')) {
$context->smarty->display(dirname(__FILE__) . '/views/templates/front/managewishlist.tpl');
} elseif (Tools::file_exists_cache(dirname(__FILE__) . '/managewishlist.tpl')) {
$context->smarty->display(dirname(__FILE__) . '/managewishlist.tpl');
} else {
echo $module->l('No template found', 'managewishlist');
}
}
}
}