Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

viewwishlist.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: viewwishlist.php 8850 2002-01-02 21:42:12Z kaid $
5 //
6 // Created on: <21-Oct-2000 18:09:45 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // include_once( "classes/INIFile.php" );
28 // include_once( "classes/eztemplate.php" );
29 // include_once( "classes/ezlocale.php" );
30 // include_once( "classes/ezcurrency.php" );
31
32 // include_once( "ezuser/classes/ezuser.php" );
33
34 $ini =& eZINI::instance( 'site.ini' );
35 $Language = $ini->variable( "eZTradeMain", "Language" );
36 $ShowQuantity = $ini->variable( "eZTradeMain", "ShowQuantity" ) == "true";
37 $ShowNamedQuantity = $ini->variable( "eZTradeMain", "ShowNamedQuantity" ) == "true";
38 $RequireQuantity = $ini->variable( "eZTradeMain", "RequireQuantity" ) == "true";
39 $ShowOptionQuantity = $ini->variable( "eZTradeMain", "ShowOptionQuantity" ) == "true";
40
41 // include_once( "eztrade/classes/ezproduct.php" );
42 // include_once( "eztrade/classes/ezoption.php" );
43 // include_once( "eztrade/classes/ezoptionvalue.php" );
44 // include_once( "eztrade/classes/ezproductcategory.php" );
45 // include_once( "eztrade/classes/ezwishlist.php" );
46 // include_once( "eztrade/classes/ezwishlistitem.php" );
47 // include_once( "eztrade/classes/ezwishlistoptionvalue.php" );
48 // include_once( "ezsession/classes/ezsession.php" );
49 // include_once( "ezimagecatalogue/classes/ezimage.php" );
50
51
52 // move to item to cart and delete item if the user owns it
53 // if not just "copy" to cart
54 if ( $Action == "MoveToCart" )
55 {
56 $wishListItem = new eZWishListItem( );
57 if ( $wishListItem->get( $WishListItemID ) )
58 {
59 $wishListItem->moveToCart();
60
61 // only delete if the user owns the wishlist
62 $tmpWishlist = $wishListItem->wishlist();
63 $tmpUser = $tmpWishlist->user();
64 $curUser =& eZUser::currentUser();
65
66 if ( $curUser && ( $tmpUser->id() == $curUser->id() ) )
67 {
68 $wishListItem->delete();
69 }
70 }
71
72 eZHTTPTool::header( "Location: /trade/cart/" );
73 exit();
74 }
75
76 $wishlist = new eZWishList();
77 $session = new eZSession();
78
79 // if no session exist create one.
80 if ( !$session->fetch() )
81 {
82 $session->store();
83 }
84
85
86 if ( is_numeric( $url_array[3] ) )
87 {
88 $userID = $url_array[3];
89 }
90 else
91 {
92 eZHTTPTool::header( "Location: /trade/customerlogin/?RedirectURL=/trade/wishlist/" );
93 exit();
94 }
95
96 {
97 // others wishlist
98 $user = new eZUser( $userID );
99 $wishlist = $wishlist->getByUser( $user );
100
101 if ( $wishlist )
102 {
103 // do not show non public wish lists (unless owned by one)
104 if ( $wishlist->isPublic() == false )
105 {
106 eZHTTPTool::header( "Location: /" );
107 exit();
108 }
109 }
110 else
111 {
112 eZHTTPTool::header( "Location: /" );
113 exit();
114 }
115 }
116
117
118 $t = new eZTemplate( "kernel/eztrade/user/" . $ini->variable( "eZTradeMain", "TemplateDir" ),
119 "kernel/eztrade/user/intl/", $Language, "viewwishlist.php" );
120
121 $t->setAllStrings();
122
123 $t->set_file( array(
124 "wishlist_page_tpl" => "viewwishlist.tpl"
125 ) );
126
127
128 $t->set_block( "wishlist_page_tpl", "empty_wishlist_tpl", "empty_wishlist" );
129
130 $t->set_block( "wishlist_page_tpl", "wishlist_image_tpl", "wishlist_image" );
131
132
133 $t->set_block( "wishlist_page_tpl", "wishlist_item_list_tpl", "wishlist_item_list" );
134 $t->set_block( "wishlist_item_list_tpl", "product_available_header_tpl", "product_available_header" );
135 $t->set_block( "wishlist_item_list_tpl", "wishlist_item_tpl", "wishlist_item" );
136 $t->set_block( "wishlist_item_tpl", "product_available_item_tpl", "product_available_item" );
137 $t->set_block( "wishlist_item_tpl", "move_to_cart_item_tpl", "move_to_cart_item" );
138 $t->set_block( "wishlist_item_tpl", "no_move_to_cart_item_tpl", "no_move_to_cart_item" );
139 $t->set_block( "wishlist_item_tpl", "wishlist_item_option_tpl", "wishlist_item_option" );
140 $t->set_block( "wishlist_item_option_tpl", "wishlist_item_option_availability_tpl", "wishlist_item_option_availability" );
141
142 $t->set_block( "wishlist_item_tpl", "is_bought_tpl", "is_bought" );
143 $t->set_block( "wishlist_item_tpl", "is_not_bought_tpl", "is_not_bought" );
144
145
146 if ( $wishlist->isPublic() == true )
147 {
148 $t->set_var( "is_public_checked", "checked" );
149 }
150 else
151 {
152 $t->set_var( "is_public_checked", "" );
153 }
154
155 // fetch the wishlist items
156 $items = $wishlist->items( );
157
158 $t->set_var( "product_available_header", "" );
159 if ( $ShowQuantity )
160 $t->parse( "product_available_header", "product_available_header_tpl" );
161
162 $locale = new eZLocale( $Language );
163 $currency = new eZCurrency();
164
165 $i = 0;
166 $sum = 0.0;
167 foreach ( $items as $item )
168 {
169 $t->set_var( "td_class", ( $i % 2 ) == 0 ? "bglight" : "bgdark" );
170 $product = $item->product();
171
172 $t->set_var( "wishlist_item_id", $item->id() );
173
174 $image = $product->thumbnailImage();
175
176 if ( $image )
177 {
178 $thumbnail =& $image->requestImageVariation( 35, 35 );
179
180 $t->set_var( "product_image_path", "/" . $thumbnail->imagePath() );
181 $t->set_var( "product_image_width", $thumbnail->width() );
182 $t->set_var( "product_image_height", $thumbnail->height() );
183 $t->set_var( "product_image_caption", $image->caption() );
184 $t->parse( "wishlist_image", "wishlist_image_tpl" );
185 }
186 else
187 {
188 $t->set_var( "wishlist_image", "&nbsp;" );
189 }
190
191 if ( $item->isBought() == true )
192 {
193 $t->set_var( "is_not_bought", "" );
194 $t->parse( "is_bought", "is_bought_tpl" );
195 }
196 else
197 {
198 $t->set_var( "is_bought", "" );
199 $t->parse( "is_not_bought", "is_not_bought_tpl" );
200 }
201
202 $currency->setValue( $product->price() * $item->count() );
203
204 $sum += $product->price();
205 $t->set_var( "product_id", $product->id() );
206 $t->set_var( "product_name", $product->name() );
207
208 $Quantity = $product->totalQuantity();
209 if ( !$product->hasPrice() )
210 {
211 $Quantity = 0;
212 foreach ( $optionValues as $optionValue )
213 {
214 $option =& $optionValue->option();
215 $value =& $optionValue->optionValue();
216 $value_quantity = $value->totalQuantity();
217 if ( $value_quantity > 0 )
218 $Quantity = $value_quantity;
219 }
220 }
221 $t->set_var( "product_available_item", "" );
222 if ( $ShowQuantity )
223 {
224 $NamedQuantity = $Quantity;
225 if ( $ShowNamedQuantity )
226 $NamedQuantity = eZProduct::namedQuantity( $Quantity );
227 $t->set_var( "product_availability", $NamedQuantity );
228 $t->parse( "product_available_item", "product_available_item_tpl" );
229 }
230 $t->set_var( "wishlist_item_count", $item->count() );
231
232 $t->set_var( "product_price", $locale->format( $currency ) );
233
234 $optionValues =& $item->optionValues();
235
236 $t->set_var( "wishlist_item_option", "" );
237 $min_quantity = $Quantity;
238 foreach ( $optionValues as $optionValue )
239 {
240 $option =& $optionValue->option();
241 $value =& $optionValue->optionValue();
242 $value_quantity = $value->totalQuantity();
243
244 $t->set_var( "option_name", $option->name() );
245
246 $descriptions =& $value->descriptions();
247 $t->set_var( "option_value", $descriptions[0] );
248
249 $t->set_var( "wishlist_item_option_availability", "" );
250 if ( !(is_bool( $value_quantity ) and !$value_quantity) )
251 {
252 if ( is_bool( $min_quantity ) )
253 $min_quantity = $value_quantity;
254 else
255 $min_quantity = min( $min_quantity , $value_quantity );
256 $named_quantity = $value_quantity;
257 if ( $ShowNamedQuantity )
258 $named_quantity = eZProduct::namedQuantity( $value_quantity );
259 if ( $ShowOptionQuantity )
260 {
261 $t->set_var( "option_availability", $named_quantity );
262 $t->parse( "wishlist_item_option_availability", "wishlist_item_option_availability_tpl" );
263 }
264 }
265
266 $t->parse( "wishlist_item_option", "wishlist_item_option_tpl", true );
267 }
268
269 $t->set_var( "move_to_cart_item", "" );
270 $t->set_var( "no_move_to_cart_item", "" );
271 if ( (is_bool( $min_quantity ) and !$min_quantity) or
272 !$RequireQuantity or ( $RequireQuantity and $min_quantity > 0 ) )
273 {
274 $t->parse( "move_to_cart_item", "move_to_cart_item_tpl" );
275 }
276 else
277 {
278 $t->parse( "no_move_to_cart_item", "no_move_to_cart_item_tpl" );
279 }
280
281 $t->parse( "wishlist_item", "wishlist_item_tpl", true );
282
283 $i++;
284 }
285
286 // $shippingCost = $ini->variable( "eZTradeMain", "ShippingCost" );
287 $shippingCost = 0;
288
289 $currency->setValue( $shippingCost );
290 $t->set_var( "shipping_cost", $locale->format( $currency ) );
291
292 $sum += $shippingCost;
293 $currency->setValue( $sum );
294 $t->set_var( "wishlist_sum", $locale->format( $currency ) );
295
296
297 if ( count( $items ) > 0 )
298 {
299 $t->parse( "wishlist_item_list", "wishlist_item_list_tpl" );
300 $t->set_var( "empty_wishlist", "" );
301 }
302 else
303 {
304 $t->parse( "empty_wishlist", "empty_wishlist_tpl" );
305 $t->set_var( "wishlist_item_list", "" );
306 }
307
308 $t->pparse( "output", "wishlist_page_tpl" );
309
310 ?>
$userID
else $userID
Definition: appointmentedit.php:121
$tmpUser
if(isset( $GetByUserID) && $GetByUserID==false) if(( $session->variable("ShowOtherCalendarUsers")==false)||(isset( $GetByUser))) $tmpUser
Definition: appointmentview.php:78
eZCurrency
Definition: ezcurrency.php:46
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZLocale
Definition: ezlocale.php:119
eZProduct\namedQuantity
static namedQuantity( $quantity)
Definition: ezproduct.php:1037
eZSession
Definition: lib/ezsession/classes/ezsession.php:65
eZTemplate
Definition: eztemplate.php:107
eZUser
Definition: ezuser.php:76
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
eZWishListItem
Definition: ezwishlistitem.php:55
eZWishList
Definition: ezwishlist.php:63
$item
$item
Definition: classes/admin/linklist.php:228
$Action
$Action
Definition: companysearch.php:80
$url_array
$url_array
Definition: ezaddress/admin/datasupplier.php:34
$thumbnail
$thumbnail
Definition: ezarticle/admin/imagelist.php:59
exit
exit
Definition: folder.php:81
$product
$product
Definition: homepage.php:202
$Quantity
if( $product->catalogNumber() !="") $Quantity
Definition: productpreview.php:491
$user
$user
Definition: user/adlist.php:39
$image
$image
Definition: user/articlelist.php:242
$shippingCost
foreach( $items as $item) $shippingCost
Definition: viewwishlist.php:287
$ShowOptionQuantity
$ShowOptionQuantity
Definition: viewwishlist.php:39
$currency
$currency
Definition: viewwishlist.php:163
$locale
$locale
Definition: viewwishlist.php:162
$t
$t
Definition: viewwishlist.php:118
$items
$items
Definition: viewwishlist.php:156
$i
$i
Definition: viewwishlist.php:165
$Language
$Language
Definition: viewwishlist.php:35
$ini
$ini
Definition: viewwishlist.php:34
$sum
$sum
Definition: viewwishlist.php:166
$ShowNamedQuantity
$ShowNamedQuantity
Definition: viewwishlist.php:37
$session
$session
Definition: viewwishlist.php:77
$ShowQuantity
$ShowQuantity
Definition: viewwishlist.php:36
$RequireQuantity
$RequireQuantity
Definition: viewwishlist.php:38
$wishlist
if( $Action=="MoveToCart") $wishlist
Definition: viewwishlist.php:76
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.