Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

cart.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: cart.php 9407 2002-04-10 11:49:02Z br $
5 //
6 // Created on: <27-Sep-2000 11:57:49 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 // common includes
28 // include_once( "classes/INIFile.php" );
29 // include_once( "classes/eztemplate.php" );
30 // include_once( "classes/ezhttptool.php" );
31
32 // specific includes
33 // include_once( "classes/ezcurrency.php" );
34 // include_once( "eztrade/classes/ezcart.php" );
35
36 // Load settings
37 $ini =& eZINI::instance( 'site.ini' );
38
39 $Language = $ini->variable( "eZTradeMain", "Language" );
40 $ShowQuantity = $ini->variable( "eZTradeMain", "ShowQuantity" ) == "true";
41 $ShowNamedQuantity = $ini->variable( "eZTradeMain", "ShowNamedQuantity" ) == "true";
42 $ShowPriceGroups = $ini->variable( "eZTradeMain", "PriceGroupsEnabled" ) == "true" ? true : false;
43 $RequireQuantity = $ini->variable( "eZTradeMain", "RequireQuantity" ) == "true";
44 $ShowOptionQuantity = $ini->variable( "eZTradeMain", "ShowOptionQuantity" ) == "true";
45 $PricesIncludeVAT = $ini->variable( "eZTradeMain", "PricesIncludeVAT" ) == "enabled" ? true : false;
46 $ShowExTaxColumn = $ini->variable( "eZTradeMain", "ShowExTaxColumn" ) == "enabled" ? true : false;
47 $ShowIncTaxColumn = $ini->variable( "eZTradeMain", "ShowIncTaxColumn" ) == "enabled" ? true : false;
48 $ShowExTaxTotal = $ini->variable( "eZTradeMain", "ShowExTaxTotal" ) == "enabled" ? true : false;
49 $ShowTaxBasis = $ini->variable( "eZTradeMain", "ShowTaxBasis" ) == "enabled" ? true : false;
50 $ColSpanSizeTotals = $ini->variable( "eZTradeMain", "ColSpanSizeTotals" );
51
52 //$checkups = $ini->variable( "eZTradeMain", "UPSOFF" );
53
54
55 if ( isset( $ShopMore ) )
56 {
57 eZHTTPTool::header( "Location: /trade/productlist/0" );
58 // eZHTTPTool::header( "Location: ".$_SERVER['HTTP_REFERRER'] );
59 exit();
60 }
61
62 // These are the common objects regardless of Action
63 $session =& eZSession::globalSession();
64
65 if(eZHTTPTool::getVar( "ShippingTypeID" )){
66 $currentTypeID = eZHTTPTool::getVar( "ShippingTypeID" );
67 }else{
68 $currentTypeID[0] = "03";
69 }
70
71 // Set some variables to defaults.
72 $ShowCart = false;
73 $ShowSavingsColumn = false;
74
75 if ( isset( $DeleteSelected ) )
76 {
77 if ( isset( $CartSelectArray ) && count( $CartSelectArray ) > 0 )
78 foreach ( $CartSelectArray as $cartID )
79 {
80 $cartItem = new eZCartItem( $cartID );
81 $optionValues =& $cartItem->optionValues();
82
83 foreach( $optionValues as $optionValue )
84 {
85 $optionValue->delete();
86 }
87
88 $cartItem->delete();
89 }
90
91 eZHTTPTool::header( "Location: /trade/cart/" );
92 exit();
93 }
94
95 if ( ( isset( $Action ) && $Action == "Refresh" ) || isset( $DoCheckOut ) )
96 {
97 $i = 0;
98 $delete = false;
99 if ( isset( $CartCountArray ) && count( $CartIDArray ) > 0 )
100 foreach ( $CartIDArray as $cartID )
101 {
102 if ( $CartCountArray[$i] < 1 )
103 {
104 $cartItem = new eZCartItem( $cartID );
105 $optionValues =& $cartItem->optionValues();
106
107 foreach( $optionValues as $optionValue )
108 {
109 $optionValue->delete();
110 }
111
112 $cartItem->delete();
113 }
114 else
115 {
116 $cartItem = new eZCartItem( $cartID );
117 $product =& $cartItem->product();
118
119 $optionValues =& $cartItem->optionValues();
120 $j = 0;
121
122 // First we track the maximum number of items available in stock.
123 $maxInStock = false;
124
125 foreach( $optionValues as $optionValue )
126 {
127 $value = $optionValue->optionValue();
128
129 $totalQuantity = $value->totalQuantity();
130
131 if ( $totalQuantity != false and
132 $totalQuantity < $CartCountArray[$i] )
133 {
134 if ( $maxInStock == false or $totalQuantity < $maxInStock )
135 {
136 $maxInStock = $totalQuantity;
137 }
138 }
139 }
140
141 $totalQuantity = $product->totalQuantity();
142
143 if ( $totalQuantity != false and
144 $totalQuantity < $CartCountArray[$i] )
145 {
146 if ( $maxInStock == false or $totalQuantity < $maxInStock )
147 {
148 $maxInStock = $totalQuantity;
149 }
150 }
151
152 // Next step is to actually set the info.
153 foreach( $optionValues as $optionValue )
154 {
155 $value = $optionValue->optionValue();
156
157 if ( ( $CartCountArray[$i] > $maxInStock ) and ( $value->totalQuantity() != false ) and ( $maxInStock != false ) )
158 {
159 $optionValue->setCount( $maxInStock );
160 }
161 else
162 {
163 $optionValue->setCount( $CartCountArray[$i] );
164 }
165
166 $optionValue->store();
167 }
168
169 if ( ( $CartCountArray[$i] > $maxInStock ) and ( $product->totalQuantity() != false ) and ( $maxInStock != false ) )
170 {
171 $cartItem->setCount( $maxInStock );
172 }
173 else
174 {
175 $cartItem->setCount( $CartCountArray[$i] );
176 }
177
178 $cartItem->store();
179 }
180 $i++;
181 }
182 }
183
184 // checkout
185 if ( isset( $DoCheckOut ) )
186 {
187 eZHTTPTool::header( "Location: /trade/customerlogin/" );
188 exit();
189 }
190
191 $user =& eZUser::currentUser();
192
193 $cart = new eZCart();
194 $cartBySession = $cart->getBySession( $session );
195
196 if( $cartBySession )
197 $cart = $cartBySession;
198
199 // echo "<hr>";
200 // var_dump( $cartBySession );
201
202 if ( !$cartBySession )
203 {
204 $cart = new eZCart();
205 $cart->setSession( $session );
206 // echo "<hr>";
207 $cart->store();
208 }
209
210 // var_dump( $cart );
211 // echo "<hr>";
212
213 $items = $cart->items( );
214
215
216 if ( isset( $Action ) && $Action == "AddToBasket" )
217 {
218 $product = new eZProduct();
219 if ( !$product->get( $ProductID ) )
220 {
221 eZHTTPTool::header( "Location: /error/404/" );
222 exit();
223 }
224
225 // check if a product like this is already in the basket.
226 // if so-> add the count value.
227 $Quantity = $product->totalQuantity();
228 if ( $product->hasQuantity( $RequireQuantity ) )
229 {
230 $productAddedToBasket = false;
231 {
232 // fetch the cart items
233 $items = $cart->items( );
234
235 foreach ( $items as $item )
236 {
237 $productItem = $item->product();
238 // the same product
239 if ( ( $ProductID == $productItem->id() ) && ( $productAddedToBasket == false ) )
240 {
241 $optionValues =& $item->optionValues();
242
243 if ( count( $optionValues ) > 0 )
244 { // product with options
245 $hasTheSameOptions = true;
246
247 foreach ( $optionValues as $optionValue )
248 {
249 $option =& $optionValue->option();
250 $value =& $optionValue->optionValue();
251
252 $optionValueFound = false;
253
254 if ( count( $OptionValueArray ) > 0 )
255 {
256 $i=0;
257 foreach ( $OptionValueArray as $valueItem )
258 {
259 if ( ( $OptionIDArray[$i] == $option->id() )
260 && ( $valueItem == $value->id() ) )
261 {
262 $optionValueFound = true;
263 }
264 $i++;
265 }
266 }
267
268 if ( $optionValueFound == false )
269 {
270 $hasTheSameOptions = false;
271 }
272 }
273
274 if ( $hasTheSameOptions == true )
275 {
276 $item->setCount( $item->count() + 1 );
277 $item->store();
278 $productAddedToBasket = true;
279 }
280 }
281 else
282 { // product without options
283 if ( isset( $OptionValueArray ) && count( $OptionValueArray ) == 0 )
284 {
285 $item->setCount( $item->count() + 1 );
286 $item->store();
287 $productAddedToBasket = true;
288 }
289 }
290 }
291 }
292 }
293
294 if ( $productAddedToBasket == false )
295 {
296 $can_add = true;
297 if ( !$product->hasQuantity( $RequireQuantity ) )
298 $can_add = false;
299
300 if ( isset( $OptionValueArray ) && count( $OptionValueArray ) > 0 )
301 {
302 foreach ( $OptionValueArray as $value )
303 {
304 $optionValue = new eZOptionValue( $value );
305 if ( !$optionValue->hasQuantity( $RequireQuantity ) )
306 {
307 $can_add = false;
308 }
309 }
310 }
311
312 if ( $can_add )
313 {
314 $cartItem = new eZCartItem();
315
316 $cartItem->setProduct( $product );
317 $cartItem->setCart( $cart );
318
319 $voucherInformationID = $session->variable( "VoucherInformationID" );
320 $session->setVariable( "VoucherInformationID", 0 );
321 $cartItem->setVoucherInformation( $voucherInformationID );
322
323 $cartItem->store();
324
325 if ( isset( $OptionValueArray ) && count( $OptionValueArray ) > 0 )
326 {
327 $i = 0;
328 foreach ( $OptionValueArray as $value )
329 {
330 $option = new eZOption( $OptionIDArray[$i] );
331 $optionValue = new eZOptionValue( $value );
332 if ( $optionValue->hasQuantity( $RequireQuantity ) )
333 {
334 $cartOption = new eZCartOptionValue();
335 $cartOption->setCartItem( $cartItem );
336 $cartOption->setOption( $option );
337 $cartOption->setRemoteID( $optionValue->remoteID() );
338 $cartOption->setOptionValue( $optionValue );
339
340 $cartOption->store();
341 }
342 $i++;
343 }
344 }
345 }
346 }
347 }
348 eZHTTPTool::header( "Location: /trade/cart/" );
349 exit();
350 }
351
352 // Load the template
353 global $t;
354 $t = new eZTemplate( "kernel/eztrade/user/" . $ini->variable( "eZTradeMain", "TemplateDir" ),
355 "kernel/eztrade/user/intl/", $Language, "cart.php" );
356
357 $t->set_file( "cart_page_tpl", "cart.tpl" );
358
359 $t->set_block( "cart_page_tpl", "empty_cart_tpl", "empty_cart" );
360
361 $t->set_block( "cart_page_tpl", "full_cart_tpl", "full_cart" );
362 $t->set_block( "full_cart_tpl", "cart_item_list_tpl", "cart_item_list" );
363 $t->set_block( "cart_item_list_tpl", "header_savings_item_tpl", "header_savings_item" );
364 $t->set_block( "cart_item_list_tpl", "header_inc_tax_item_tpl", "header_inc_tax_item" );
365 $t->set_block( "cart_item_list_tpl", "header_ex_tax_item_tpl", "header_ex_tax_item" );
366
367 $t->set_block( "full_cart_tpl", "total_ex_tax_item_tpl", "total_ex_tax_item" );
368 $t->set_block( "full_cart_tpl", "total_inc_tax_item_tpl", "total_inc_tax_item" );
369 $t->set_block( "full_cart_tpl", "subtotal_ex_tax_item_tpl", "subtotal_ex_tax_item" );
370 $t->set_block( "full_cart_tpl", "subtotal_inc_tax_item_tpl", "subtotal_inc_tax_item" );
371 $t->set_block( "full_cart_tpl", "shipping_ex_tax_item_tpl", "shipping_ex_tax_item" );
372 $t->set_block( "full_cart_tpl", "shipping_inc_tax_item_tpl", "shipping_inc_tax_item" );
373 $t->set_block( "full_cart_tpl", "anon_shipping_notification_tpl", "anon_shipping_notification" );
374 $t->set_block( "full_cart_tpl", "shipping_notification_tpl", "shipping_notification" );
375 $t->set_block( "full_cart_tpl", "shipping_noaddress_tpl", "shipping_noaddress" );
376
377 $t->set_block( "cart_item_list_tpl", "cart_item_tpl", "cart_item" );
378 $t->set_block( "cart_item_tpl", "cart_savings_item_tpl", "cart_savings_item" );
379 $t->set_block( "cart_item_tpl", "cart_inc_tax_item_tpl", "cart_inc_tax_item" );
380 $t->set_block( "cart_item_tpl", "cart_ex_tax_item_tpl", "cart_ex_tax_item" );
381
382 $t->set_block( "cart_item_tpl", "cart_item_option_tpl", "cart_item_option" );
383 $t->set_block( "cart_item_option_tpl", "option_savings_item_tpl", "option_savings_item" );
384 $t->set_block( "cart_item_option_tpl", "option_inc_tax_item_tpl", "option_inc_tax_item" );
385 $t->set_block( "cart_item_option_tpl", "option_ex_tax_item_tpl", "option_ex_tax_item" );
386
387 $t->set_block( "cart_item_tpl", "cart_item_basis_tpl", "cart_item_basis" );
388 $t->set_block( "cart_item_basis_tpl", "basis_savings_item_tpl", "basis_savings_item" );
389 $t->set_block( "cart_item_basis_tpl", "basis_inc_tax_item_tpl", "basis_inc_tax_item" );
390 $t->set_block( "cart_item_basis_tpl", "basis_ex_tax_item_tpl", "basis_ex_tax_item" );
391
392 $t->set_block( "full_cart_tpl", "tax_specification_tpl", "tax_specification" );
393 $t->set_block( "full_cart_tpl", "tax_total_tpl", "tax_total" );
394 $t->set_block( "tax_specification_tpl", "tax_item_tpl", "tax_item" );
395
396 $t->set_block( "cart_page_tpl", "cart_checkout_tpl", "cart_checkout" );
397 $t->set_block( "cart_checkout_tpl", "cart_checkout_button_tpl", "cart_checkout_button" );
398
399 global $ShowSavingsColumn, $ShowExTaxColumn, $ShowIncTaxColumn;
400
401 function turnColumnsOnOff( $rowName )
402 {
403 global $t, $ShowSavingsColumn, $ShowExTaxColumn, $ShowIncTaxColumn;
404 if ( $ShowSavingsColumn == true )
405 {
406 $t->parse( $rowName . "_savings_item", $rowName . "_savings_item_tpl" );
407 }
408 else
409 {
410 $t->set_var( $rowName . "_savings_item", "" );
411 }
412
413 if ( $ShowExTaxColumn == true )
414 {
415 $t->parse( $rowName . "_ex_tax_item", $rowName . "_ex_tax_item_tpl" );
416 }
417 else
418 {
419 $t->set_var( $rowName . "_ex_tax_item", "" );
420 }
421
422 if ( $ShowIncTaxColumn == true )
423 {
424 $t->parse( $rowName . "_inc_tax_item", $rowName . "_inc_tax_item_tpl" );
425 }
426 else
427 {
428 $t->set_var( $rowName . "_inc_tax_item", "" );
429 }
430 }
431
432 if($user){
433 $mainAddress = $user->mainAddress();
434 if($mainAddress){
435 // Check above - otherwise below will error for non-address members
436 $region = $mainAddress->region();
437 }
438 }
439
440 /*
441 $mainAddress = $user->mainAddress();
442 $region = $mainAddress->region();
443 if ( $region->hasVAT() )
444 */
445
446 $locale = new eZLocale( $Language );
447 $currency = new eZCurrency();
448
449 $numberOfItems = 0;
450 $i = 0;
451
452 foreach ( $items as $item )
453 {
454 if ( $item->correctSavings( false, true, $PricesIncludeVAT ) > 0 )
455 {
456 $ShowSavingsColumn = true;
457 }
458 }
459
460 foreach ( $items as $item )
461 {
462 $t->set_var( "td_class", ( $i % 2 ) == 0 ? "bglight" : "bgdark" );
463 $i++;
464 $t->set_var( "cart_item_id", $item->id() );
465 $product =& $item->product();
466
467 $t->set_var( "product_name", $product->name() );
468 $t->set_var( "product_id", $product->id() );
469 $t->set_var( "category_id", $product->categories()[0]->id() );
470 $t->set_var( "product_number", $product->productNumber() );
471 $t->set_var( "product_price", $item->localePrice( false, true, $PricesIncludeVAT ) );
472
473 $currency = new eZCurrency();
474 $productPrice = $item->localePrice( false, true, $PricesIncludeVAT, false );
475 $currency->setValue( $productPrice );
476 $t->set_var( "product_price", $item->localePrice( false, true, $PricesIncludeVAT, false ) );
477
478 $t->set_var( "product_count", $item->count() );
479 $t->set_var( "product_total_ex_tax", $item->localePrice( true, true, false ) );
480 $t->set_var( "product_total_inc_tax", $item->localePrice( true, true, true ) );
481
482 $numberOfItems++;
483
484 $numberOfOptions = 0;
485
486 $optionValues =& $item->optionValues();
487
488 $t->set_var( "cart_item_option", "" );
489 $t->set_var( "cart_item_basis", "" );
490
491 foreach ( $optionValues as $optionValue )
492 {
493 turnColumnsOnOff( "option" );
494
495 $option =& $optionValue->option();
496 $value =& $optionValue->optionValue();
497 $value_quantity = $value->totalQuantity();
498 $descriptions = $value->descriptions();
499
500 // $t->set_var( "option_id", $option->id() );
501 $t->set_var( "option_name", $option->name() );
502 if ( count( $descriptions ) > 0 )
503 {
504 $t->set_var( "option_value", $descriptions[0] );
505 }
506 else
507 {
508 $t->set_var( "option_value", $value->option()->name() );
509 }
510 $t->set_var( "option_price", $value->localePrice( $PricesIncludeVAT, $product ) );
511
512 $t->parse( "cart_item_option", "cart_item_option_tpl", true );
513
514 $numberOfOptions++;
515 }
516 turnColumnsOnOff( "cart" );
517 turnColumnsOnOff( "basis" );
518
519 if ( $ShowSavingsColumn == true )
520 {
521 if ( $item->correctSavings( true, true, $PricesIncludeVAT ) > 0 )
522 {
523 $t->set_var( "product_savings", $item->localeSavings( true, true, $PricesIncludeVAT ) );
524 }
525 else
526 {
527 $t->set_var( "product_savings", "&nbsp;" );
528 }
529 $t->parse( "cart_savings_item", "cart_savings_item_tpl" );
530 }
531 else
532 {
533 $t->set_var( "cart_savings_item", "" );
534 }
535
536 if ( $numberOfOptions == 0 )
537 {
538 $t->set_var( "cart_item_option", "" );
539 $t->set_var( "cart_item_basis", "" );
540 }
541 else
542 {
543 if( $product->price() > 0 )
544 {
545 $t->set_var( "basis_price", $item->localePrice( false, false, $PricesIncludeVAT ) );
546 $t->parse( "cart_item_basis", "cart_item_basis_tpl", true );
547 }
548 else
549 {
550 $t->set_var( "cart_item_basis", "" );
551 }
552 }
553
554 $t->parse( "cart_item", "cart_item_tpl", true );
555 }
556
557 if ( $numberOfItems > 0 )
558 {
559 $ShowCart = true;
560 }
561
562 $t->setAllStrings();
563
564 turnColumnsOnOff( "header" );
565
566 $user =& eZUser::currentUser();
567 $vat=false;
568
569 if ($user)
570 {
571 $address = new eZAddress();
572 if (isset( $cart->AddressID ) ){
573 $taxaddressID = $cart->AddressID;
574 }elseif( eZHTTPTool::getVar( "ShippingAddressID") ){
575 $taxaddressID = eZHTTPTool::getVar( "ShippingAddressID");
576 }else {
577 $taxaddressObj = $address->mainAddress($user);
578 if($taxaddressObj){
579 // Check above - otherwise will error for no address members
580 $taxaddressID = $taxaddressObj->ID();
581 }
582 }
583 $shippingAddress = new eZAddress( $taxaddressID );
584 $shippingRegion = $shippingAddress->region();
585
586 if ( $shippingRegion )
587 {
588 if ( $shippingRegion->hasVAT() )
589 $vat = false; // set to true to enable sales tax
590 }
591 }
592
593 $upscheck = $ini->variable( "eZTradeMain", "UPSXMLShipping" ) == 'enabled'?1:0;
594 $uspscheck = $ini->variable( "eZTradeMain", "USPSXMLShipping" ) == 'enabled'?1:0;
595
596 if ( $ShowCart == true )
597 {
598 $shipaddID = eZHTTPTool::getVar( "ShippingAddressID" );
599
600 if( !$cart->ShipServiceCode )
601 {
602 $cart->AddressID=$shipaddID;
603 $cart->ShipServiceCode=$currentTypeID[0];
604 $cart->storeshipoptions($currentTypeID[0],$shipaddID);
605 }
606 else
607 {
608 $cart->AddressID=$shipaddID;
609 }
610 $cart->cartTotals( $tax, $total );
611
612 $locale = new eZLocale( $Language );
613 $currency = new eZCurrency();
614 $shipServiceCode=false;
615 $upsNames =array (
616 '01' => 'UPS Next Day Air',
617 '02' => 'UPS 2nd Day Air',
618 '03' => 'UPS Ground',
619 '07' => 'UPS Worldwide Express',
620 '08' => 'UPS Worldwide Expedited',
621 '11' => 'UPS Standard',
622 '12' => 'UPS 3 Day Select',
623 '13' => 'UPS Next Day Air Saver',
624 '14' => 'UPS Next Day Air Early A.M.',
625 '54' => 'UPS Worldwide Express Plus',
626 '59' => 'UPS 2nd Day Air A.M.',
627 '64' => '',
628 '65' => 'UPS Express Saver',
629 );
630
631 $t->set_var( "empty_cart", "" );
632
633 $currency->setValue( $total["subinctax"] );
634 $t->set_var( "subtotal_inc_tax", $locale->format( $currency ) );
635
636 $currency->setValue( $total["subextax"] );
637 $t->set_var( "subtotal_ex_tax", $locale->format( $currency ) );
638
639 $currency->setValue( $total["inctax"] );
640 $t->set_var( "total_inc_tax", $locale->format( $currency ) );
641
642 // $currency->setValue( $total["extax"] );
643 // $t->set_var( "total_ex_tax", $locale->format( $currency ) );
644
645 if ( isset( $upsNames[$shipServiceCode] ) && $upsNames[$shipServiceCode] != "" )
646 {
647 $shippingName = $upsNames[$shipServiceCode];
648 }
649 else
650 $shippingName = $cart->ShipServiceCode; //$shipServiceCode;
651
652 // ser =& eZUser::currentUser();
653
654 if ( $shippingName != "" && $user )
655 $t->set_var( "shipping_name", " (" . $shippingName . ")" );
656 else
657 $t->set_var( "shipping_name", "" );
658
659 $currency->setValue( $total["shipinctax"] );
660 $t->set_var( "shipping_inc_tax", $locale->format( $currency ) );
661
662 $currency->setValue( $total["shipextax"] );
663 $t->set_var( "shipping_ex_tax", $locale->format( $currency ) );
664
665 // print("here4 <br />");
666
667 // If the user has no main address, set the display of shipping calculation to N/A
668 if ( !$user || !$user->mainAddress() )
669 {
670 // print("here6 <br />");
671
672 $t->set_var( "shipping_inc_tax", 'N/A');
673 $t->set_var( "shipping_ex_tax", 'N/A');
674 $t->parse( "shipping_noaddress", "shipping_noaddress_tpl" );
675 } else {
676 $t->set_var( "shipping_noaddress", "" );
677 // print("here7 <br />");
678 }
679
680 /*
681 if ( !$address->mainAddress($user) ) {
682 $t->set_var( "shipping_inc_tax", 'N/A');
683 $t->set_var( "shipping_ex_tax", 'N/A');
684 $t->parse( "shipping_noaddress", "shipping_noaddress_tpl" );
685 } else {
686 $t->set_var( "shipping_noaddress", "" );
687 }
688 */
689 // die("here5");
690 if (!empty($total['subextax'])) {
691 $taxPercentage = round(($total['tax'] / $total['subextax']) * 100, 2);
692 } else {
693 $taxPercentage = 0; // or null, or whatever default makes sense in your case
694 }
695 $t->set_var("tax_percentage", $taxPercentage);
696
697 $currency->setValue( $total["tax"] );
698 $t->set_var( "total_cart_tax", $locale->format( $currency ) );
699
700 $t->set_var( "tax_total", "" );
701 if ( !$ShowIncTaxColumn && $vat==true )
702 {
703 $currency->setValue( $total["inctax"] );
704 $t->set_var( "total_ex_tax", $locale->format( $currency ) );
705 if ( $total["tax"]>0 )
706 $t->parse( "tax_total", "tax_total_tpl" );
707 else
708 $t->set_var( "tax_total", "" );
709 }
710 else
711 {
712 $currency->setValue( $total["extax"] );
713 $t->set_var( "total_ex_tax", $locale->format( $currency ) );
714 $t->set_var( "tax_total", "" );
715 }
716
717 if ( $ShowSavingsColumn == false )
718 {
719 $ColSpanSizeTotals--;
720 }
721
722 $SubTotalsColumns = $ColSpanSizeTotals;
723
724 if ( $ShowExTaxColumn == true )
725 {
726 if ( $ShowExTaxTotal == true or $ShowIncTaxColumn == false )
727 {
728 $t->parse( "total_ex_tax_item", "total_ex_tax_item_tpl" );
729 $t->parse( "subtotal_ex_tax_item", "subtotal_ex_tax_item_tpl" );
730 $t->parse( "shipping_ex_tax_item", "shipping_ex_tax_item_tpl" );
731 }
732 else
733 {
734 $t->set_var( "total_ex_tax_item", "" );
735 $t->set_var( "subtotal_ex_tax_item", "" );
736 $t->set_var( "shipping_ex_tax_item", "" );
737 }
738 }
739 else
740 {
741 $ColSpanSizeTotals--;
742 $t->set_var( "total_ex_tax_item", "" );
743 $t->set_var( "subtotal_ex_tax_item", "" );
744 $t->set_var( "shipping_ex_tax_item", "" );
745 }
746
747 if ( $ShowIncTaxColumn == true )
748 {
749 $t->parse( "total_inc_tax_item", "total_inc_tax_item_tpl" );
750 $t->parse( "subtotal_inc_tax_item", "subtotal_inc_tax_item_tpl" );
751 $t->parse( "shipping_inc_tax_item", "shipping_inc_tax_item_tpl" );
752 }
753 else
754 {
755 $ColSpanSizeTotals--;
756 $t->set_var( "total_inc_tax_item", "" );
757 $t->set_var( "subtotal_inc_tax_item", "" );
758 $t->set_var( "shipping_inc_tax_item", "" );
759 }
760
761 if ( $ShowIncTaxColumn and $ShowExTaxColumn and $ShowExTaxTotal )
762 {
763 $t->set_var( "subtotals_span_size", $SubTotalsColumns - 1 );
764 }
765 else
766 {
767 $t->set_var( "subtotals_span_size", $ColSpanSizeTotals );
768 }
769
770 $t->set_var( "totals_span_size", $ColSpanSizeTotals );
771
772 $t->set_var( "shipping_notification", "" );
773 $t->set_var( "anon_shipping_notification", "" );
774
775 // if ($user && $shippingName!="" )
776 if ($user)
777 $t->parse( "shipping_notification", "shipping_notification_tpl" );
778
779 // if (!$user || $shippingName == "" || !$shippingName)
780 if (!$user)
781 $t->parse( "anon_shipping_notification", "anon_shipping_notification_tpl" );
782
783 $t->parse( "cart_item_list", "cart_item_list_tpl" );
784 $t->parse( "full_cart", "full_cart_tpl" );
785
786 $currency->setValue( $total["tax"] );
787 $t->set_var( "tax", $locale->format( $currency ) );
788
789 $j = 0;
790
791 if ($ShowTaxBasis)
792 {
793 foreach( $tax as $taxGroup )
794 {
795 $t->set_var( "td_class", ( $i % 2 ) == 0 ? "bglight" : "bgdark" );
796 $j++;
797 $currency->setValue( $taxGroup["basis"] );
798 $t->set_var( "sub_tax_basis", $locale->format( $currency ) );
799
800 $currency->setValue( $taxGroup["tax"] );
801 $t->set_var( "sub_tax", $locale->format( $currency ) );
802
803 $t->set_var( "sub_tax_percentage", $taxGroup["percentage"] );
804 $t->parse( "tax_item", "tax_item_tpl", true );
805 }
806 $t->parse( "tax_specification", "tax_specification_tpl" );
807
808 // add switch if default country does not have tax to dissable tax display
809 // $t->parse( "tax_specification", "tax_specification_tpl" );
810
811 }
812 else
813 $t->set_var( "tax_specification", "" );
814 $t->set_var( "tax_item", "" );
815 $t->parse( "cart_checkout_button", "cart_checkout_button_tpl" );
816 $t->parse( "cart_checkout", "cart_checkout_tpl" );
817 }
818 else
819 {
820 $t->parse( "empty_cart", "empty_cart_tpl" );
821 $t->parse( "cart_checkout", "cart_checkout_tpl" );
822 $t->set_var( "cart_checkout_button", "" );
823 $t->set_var( "cart_item_list", "" );
824 $t->set_var( "full_cart", "" );
825 $t->set_var( "tax_specification", "" );
826 $t->set_var( "tax_item", "" );
827 }
828
829 $t->pparse( "output", "cart_page_tpl" );
830
831
832 /*
833 print "debug: $ShowTaxBasis, $ShowIncTaxColumn, ".$region->hasVAT();
834 print "debug test: $test";
835 print_r($cart);
836 print_r($taxaddressID);
837 */
838 //print "here: $shipServiceCode";
839 //print_r($taxaddressID);
840 //print_r($taxaddressObj);
841 //if($user->Login() == 'ptully'){
842 // print_r($shippingCost);
843 //}
844
845 ?>
846
$ColSpanSizeTotals
$ColSpanSizeTotals
Definition: cart.php:50
$upscheck
if($user) $upscheck
Definition: cart.php:593
$ShowOptionQuantity
$ShowOptionQuantity
Definition: cart.php:44
$numberOfItems
$numberOfItems
Definition: cart.php:449
$cartBySession
$cartBySession
Definition: cart.php:194
$ShowExTaxColumn
$ShowExTaxColumn
Definition: cart.php:46
$currency
$currency
Definition: cart.php:447
$t
if(isset( $Action) && $Action=="AddToBasket") global $t
Definition: cart.php:216
$ShowTaxBasis
$ShowTaxBasis
Definition: cart.php:49
$user
if(isset( $DeleteSelected)) if((isset( $Action) && $Action=="Refresh")||isset( $DoCheckOut)) if(isset( $DoCheckOut)) $user
Definition: cart.php:191
$ShowIncTaxColumn
$ShowIncTaxColumn
Definition: cart.php:47
$session
if(isset( $ShopMore)) $session
Definition: cart.php:63
$PricesIncludeVAT
$PricesIncludeVAT
Definition: cart.php:45
$cart
$cart
Definition: cart.php:193
$vat
$vat
Definition: cart.php:567
$i
$i
Definition: cart.php:450
$Language
$Language
Definition: cart.php:39
$ini
$ini
Definition: cart.php:37
turnColumnsOnOff
turnColumnsOnOff( $rowName)
Definition: cart.php:401
$ShowPriceGroups
$ShowPriceGroups
Definition: cart.php:42
$locale
if($user) $locale
Definition: cart.php:446
$ShowCart
$ShowCart
Definition: cart.php:72
$ShowNamedQuantity
$ShowNamedQuantity
Definition: cart.php:41
$items
if(! $cartBySession) $items
Definition: cart.php:213
$ShowQuantity
$ShowQuantity
Definition: cart.php:40
$ShowExTaxTotal
$ShowExTaxTotal
Definition: cart.php:48
$RequireQuantity
$RequireQuantity
Definition: cart.php:43
$ShowSavingsColumn
$ShowSavingsColumn
Definition: cart.php:73
$uspscheck
$uspscheck
Definition: cart.php:594
$taxaddressID
$taxaddressID
Definition: checkout.php:606
$shippingRegion
$shippingRegion
Definition: checkout.php:616
$total
else $total["inctax"]
Definition: checkout.php:1359
$shippingAddress
$shippingAddress
Definition: checkout.php:615
$address
$address
Definition: checkout.php:588
eZAddress
Definition: ezaddress.php:42
eZCartItem
Definition: ezcartitem.php:56
eZCartOptionValue
Definition: ezcartoptionvalue.php:43
eZCart
Definition: ezcart.php:71
eZCurrency
Definition: ezcurrency.php:46
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZHTTPTool\getVar
static getVar( $name, $onlyCheckPost=false)
Definition: ezhttptool.php:55
eZLocale
Definition: ezlocale.php:119
eZOptionValue
Definition: ezoptionvalue.php:54
eZOption
Definition: ezoption.php:82
eZProduct
Definition: ezproduct.php:71
eZSession\globalSession
static & globalSession( $id="", $fetch=true)
Definition: kernel/ezsession/classes/ezsession.php:614
eZTemplate
Definition: eztemplate.php:107
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$item
$item
Definition: classes/admin/linklist.php:228
$Action
$Action
Definition: companysearch.php:80
$j
$j
Definition: ezimagecatalogue/admin/imagelist.php:345
exit
exit
Definition: folder.php:81
$product
$product
Definition: homepage.php:202
$region
$region
Definition: paypal.php:45
$Quantity
if( $product->catalogNumber() !="") $Quantity
Definition: productpreview.php:491
$mainAddress
$mainAddress
Definition: step2.php:32
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.