Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

smallcart.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: smallcart.php 7248 2001-09-15 12:37:19Z pkej $
5 //
6 // Created on: <12-Dec-2000 15:21:10 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
36 $Language = $ini->variable( "eZTradeMain", "Language" );
37 $RequireQuantity = $ini->variable( "eZTradeMain", "RequireQuantity" ) == "true";
38 $ShowQuantity = $ini->variable( "eZTradeMain", "ShowQuantity" ) == "true";
39 $ShowPriceGroups = $ini->variable( "eZTradeMain", "PriceGroupsEnabled" ) == "true";
40 $ShowNamedQuantity = $ini->variable( "eZTradeMain", "ShowNamedQuantity" ) == "true";
41 $ShowOptionQuantity = $ini->variable( "eZTradeMain", "ShowOptionQuantity" ) == "true";
42 $PricesIncludeVAT = $ini->variable( "eZTradeMain", "PricesIncludeVAT" ) == "enabled" ? true : false;
43 $hotDealImageWidth = $ini->variable( "eZTradeMain", "HotDealImageWidth" );
44 $hotDealImageHeight = $ini->variable( "eZTradeMain", "HotDealImageHeight" );
45 $upscheck = $ini->variable( "eZTradeMain", "UPSXMLShipping" ) == "enabled" ? 1 : 0;
46 $uspscheck = $ini->variable( "eZTradeMain", "USPSXMLShipping" ) == "enabled" ? 1 : 0;
47
48 if(($upscheck==0)&&($uspscheck==0))
49 $checkups=0;
50 else
51 $checkups=1;
52
53 // include_once( "eztrade/classes/ezproduct.php" );
54 // include_once( "eztrade/classes/ezoption.php" );
55 // include_once( "eztrade/classes/ezoptionvalue.php" );
56 // include_once( "eztrade/classes/ezproductcategory.php" );
57 // include_once( "eztrade/classes/ezcart.php" );
58 // include_once( "eztrade/classes/ezshippingtype.php" );
59 // include_once( "eztrade/classes/ezcartitem.php" );
60 // include_once( "eztrade/classes/ezcartoptionvalue.php" );
61 // include_once( "ezsession/classes/ezsession.php" );
62
63 $cart = new eZCart();
64 $session = new eZSession();
65
66 // if no session exist create one.
67 if ( !$session->fetch() )
68 {
69 $session->store();
70 }
71
72 $user =& eZUser::currentUser();
73
74 $cart = $cart->getBySession( $session );
75
76 if ( !$cart )
77 {
78 $cart = new eZCart();
79 $cart->setSession( $session );
80
81 $cart->store();
82 }
83
84
85 $t = new eZTemplate( "kernel/eztrade/user/" . $ini->variable( "eZTradeMain", "TemplateDir" ),
86 "kernel/eztrade/user/intl/", $Language, "smallcart.php" );
87
88
89 $t->setAllStrings( true );
90
91 $t->set_file( "cart_page_tpl", "smallcart.tpl" );
92
93 $t->set_block( "cart_page_tpl", "cart_checkout_tpl", "cart_checkout" );
94 $t->set_block( "cart_page_tpl", "empty_cart_tpl", "empty_cart" );
95
96
97 $t->set_block( "cart_page_tpl", "cart_item_list_tpl", "cart_item_list" );
98 $t->set_block( "cart_item_list_tpl", "cart_item_tpl", "cart_item" );
99 $t->set_block( "cart_item_tpl", "product_image_tpl", "product_image" );
100 $t->set_block( "cart_item_list_tpl", "cart_item_prelist_tpl", "cart_item_prelist" );
101 // fetch the cart items
102 $items =& $cart->items( );
103
104 $locale = new eZLocale( $Language );
105 $currency = new eZCurrency();
106
107
108 $i = 0;
109 $sum = 0.0;
110 $totalVAT = 0.0;
111 $can_checkout = true;
112 $t->set_var( "cart_item", "" );
113
114
115 foreach ( $items as $item )
116 {
117 $t->set_var( "td_class", ( $i % 2 ) == 0 ? "bglight" : "bgdark" );
118 $t->set_var( "cart_item_id", $item->id() );
119
120 $product = $item->product();
121 if ( $product )
122 {
123
124 $t->set_var( "product_id", $product->id() );
125 $t->set_var( "product_name", $product->name() );
126
127 $image = $product->thumbnailImage();
128
129 if ( $image )
130 {
131 $thumbnail =& $image->requestImageVariation( $hotDealImageWidth, $hotDealImageHeight );
132 // $thumbnail =& $image->requestImageVariation( 109, 109 );
133
134 if ( $thumbnail )
135 {
136 if ( !isset( $HotDealsPage ) )
137 {
138 $t->set_var( "product_image_path", "/" . $thumbnail->imagePath() );
139 $t->set_var( "product_image_width", $thumbnail->width() );
140 $t->set_var( "product_image_height", $thumbnail->height() );
141 // $t->set_var( "product_image_caption", $image->caption() );
142 }
143 else
144 {
145 $t->set_var( "thumbnail_image_uri", "/" . $thumbnail->imagePath() );
146 $t->set_var( "thumbnail_image_width", $thumbnail->width() );
147 $t->set_var( "thumbnail_image_height", $thumbnail->height() );
148 // $t->set_var( "thumbnail_image_caption", $image->caption() );
149 }
150 $t->parse( "product_image", "product_image_tpl" );
151 }
152 else
153 {
154 $t->set_var( "product_image", "" );
155 }
156
157
158 }
159 else
160 {
161 $t->set_var( "product_image", "" );
162 }
163
164 $price = $product->price() * $item->count();
165
166 $currency->setValue( $price );
167
168 $priceobj = new eZCurrency();
169
170 if ( ( isset( $RequireUserLogin ) && !$RequireUserLogin or is_a( $user, "eZUser" ) ) and
171 $ShowPrice and $product->showPrice() == true and $product->hasPrice() )
172 {
173 $t->set_var( "product_price", $item->localePrice( true, true, $PricesIncludeVAT ) );
174 }
175 else
176 {
177 $t->set_var( "product_price", $item->localePrice( true, true, $PricesIncludeVAT ) );
178 }
179
180 $t->set_var( "product_intro_text", $product->brief() );
181
182 // product price
183 $currency->setValue( $price );
184
185 $sum += $price;
186
187
188 $t->set_var( "product_id", $product->id() );
189 $t->set_var( "product_name", $product->name() );
190
191 $t->set_var( "cart_item_count", $item->count() );
192
193 $optionValues =& $item->optionValues();
194 $Quantity = $product->totalQuantity();
195
196 $min_quantity = false;
197 if ( !$product->hasPrice() )
198 {
199 foreach ( $optionValues as $optionValue )
200 {
201 $option =& $optionValue->option();
202 $value =& $optionValue->optionValue();
203 $value_quantity = $value->totalQuantity();
204 if ( !(is_bool( $value_quantity ) and !$value_quantity) )
205 {
206 if ( is_bool( $min_quantity ) )
207 $min_quantity = $value_quantity;
208 else
209 $min_quantity = min( $min_quantity , $value_quantity );
210 }
211 }
212 }
213 if ( !(is_bool( $min_quantity ) and !$min_quantity) and
214 $RequireQuantity and $min_quantity == 0 )
215 $can_checkout = false;
216
217 if ( $product->discontinued() )
218 $can_checkout = false;
219
220 $t->parse( "cart_item", "cart_item_tpl", true );
221 }
222
223 $i++;
224 }
225
226
227 // shipping cost and VAT
228 $cart->cartTotals( $tax, $total );
229
230 $locale = new eZLocale( $Language );
231 $currency = new eZCurrency();
232
233 $user = eZUser::currentUser();
234
235 if($checkups==1)
236 {
237 if ($user)
238 {
239 $currency->setValue( $total["shipinctax"] );
240 $t->set_var( "shipping_sum", $locale->format( $currency ) );
241
242 $currency->setValue( $total["inctax"] );
243 $t->set_var( "cart_sum", $locale->format( $currency ) );
244 $t->set_var( "subtotal_sum", $locale->format( $currency ) );
245
246 $currency->setValue( $total["tax"] );
247 $t->set_var( "cart_vat_sum", $locale->format( $currency ) );
248 $t->parse( "cart_item_prelist", "cart_item_prelist_tpl", true );
249 }
250 else
251 {
252 $t->set_var( "cart_item", "" );
253 $t->set_var( "cart_item_prelist", "" );
254 $t->set_var( "shipping_sum","");
255 $t->set_var( "cart_sum","");
256 $t->set_var( "subtotal_sum","");
257 $t->set_var( "cart_vat_sum","");
258 }
259
260 }
261 else
262 {
263 $currency->setValue( $total["shipinctax"] );
264 $t->set_var( "shipping_sum", $locale->format( $currency ) );
265
266 $currency->setValue( $total["inctax"] );
267 $t->set_var( "cart_sum", $locale->format( $currency ) );
268
269 $currency->setValue( $total["subinctax"] );
270 $t->set_var( "subtotal_sum", $locale->format( $currency ) );
271
272 $currency->setValue( $total["tax"] );
273 $t->set_var( "cart_vat_sum", $locale->format( $currency ) );
274
275 $t->parse( "cart_item_prelist", "cart_item_prelist_tpl", true );
276 }
277
278 if ( count( $items ) > 0 and $can_checkout )
279 {
280 $t->parse( "cart_checkout", "cart_checkout_tpl" );
281 }
282 else
283 {
284 $t->set_var( "cart_checkout", "" );
285 }
286
287 if ( count( $items ) > 0 )
288 {
289 $t->parse( "cart_item_list", "cart_item_list_tpl" );
290 $t->set_var( "empty_cart", "" );
291 }
292 else
293 {
294 $t->parse( "empty_cart", "empty_cart_tpl" );
295 $t->set_var( "cart_item_list", "" );
296 }
297
298 $t->set_var( "sitedesign", $GlobalSiteDesign );
299
300 $t->pparse( "output", "cart_page_tpl" );
301
302 ?>
$total
else $total["inctax"]
Definition: checkout.php:1359
eZCart
Definition: ezcart.php:71
eZCurrency
Definition: ezcurrency.php:46
eZLocale
Definition: ezlocale.php:119
eZSession
Definition: lib/ezsession/classes/ezsession.php:65
eZTemplate
Definition: eztemplate.php:107
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$item
$item
Definition: classes/admin/linklist.php:228
$thumbnail
$thumbnail
Definition: ezarticle/admin/imagelist.php:59
$product
$product
Definition: homepage.php:202
$GlobalSiteDesign
global $GlobalSiteDesign
Definition: latestmessages.php:52
$price
$price
Definition: pricegroupedit.php:39
$Quantity
if( $product->catalogNumber() !="") $Quantity
Definition: productpreview.php:491
$ShowPrice
$ShowPrice
Definition: productpreview.php:48
$RequireUserLogin
$RequireUserLogin
Definition: productpreview.php:51
$t
if(! $cart) $t
Definition: smallcart.php:85
$ShowOptionQuantity
$ShowOptionQuantity
Definition: smallcart.php:41
$checkups
else $checkups
Definition: smallcart.php:51
$totalVAT
$totalVAT
Definition: smallcart.php:110
$currency
$currency
Definition: smallcart.php:105
$locale
$locale
Definition: smallcart.php:104
$can_checkout
$can_checkout
Definition: smallcart.php:111
$user
if(! $session->fetch()) $user
Definition: smallcart.php:72
$PricesIncludeVAT
$PricesIncludeVAT
Definition: smallcart.php:42
$cart
$cart
Definition: smallcart.php:63
$items
$items
Definition: smallcart.php:102
$i
$i
Definition: smallcart.php:108
$Language
$Language
Definition: smallcart.php:36
$ini
$ini
Definition: smallcart.php:34
$hotDealImageHeight
$hotDealImageHeight
Definition: smallcart.php:44
$sum
$sum
Definition: smallcart.php:109
$ShowPriceGroups
$ShowPriceGroups
Definition: smallcart.php:39
$ShowNamedQuantity
$ShowNamedQuantity
Definition: smallcart.php:40
$session
$session
Definition: smallcart.php:64
$upscheck
$upscheck
Definition: smallcart.php:45
$hotDealImageWidth
$hotDealImageWidth
Definition: smallcart.php:43
$ShowQuantity
$ShowQuantity
Definition: smallcart.php:38
$RequireQuantity
$RequireQuantity
Definition: smallcart.php:37
$uspscheck
$uspscheck
Definition: smallcart.php:46
$image
$image
Definition: user/articlelist.php:242
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.