/[drupal]/contributions/modules/ubercart/uc_cart/uc_cart_checkout_pane.inc
ViewVC logotype

Contents of /contributions/modules/ubercart/uc_cart/uc_cart_checkout_pane.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download) (as text)
Thu Jul 10 12:41:00 2008 UTC (16 months, 2 weeks ago) by islandusurper
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--2
Changes since 1.4: +88 -50 lines
File MIME type: text/x-php
Begin the Ubercart 6.x-2.x branch.
1 <?php
2 // $Id$
3
4 /**
5 * @file
6 * This file contains the callbacks for the default checkout panes supplied with
7 * Ubercart and their corresponding helper functions.
8 *
9 * Checkout panes are defined using hook_checkout_pane() and use a callback to
10 * handle the different processes involved in completing the checkout form. The
11 * default checkout panes are defined in uc_cart_checkout_pane() in
12 * uc_cart.module.
13 */
14
15 /**
16 * Display the cart contents for review during checkout.
17 */
18 function uc_checkout_pane_cart($op) {
19 switch ($op) {
20 case 'view':
21 $contents['cart_review_table'] = array(
22 '#value' => theme('cart_review_table'),
23 '#weight' => variable_get('uc_pane_cart_field_cart_weight', 2),
24 );
25 return array('contents' => $contents, 'next-button' => FALSE);
26
27 case 'review':
28 $items = uc_cart_get_contents();
29 $output = '<table>';
30 foreach ($items as $item) {
31 $rows = array();
32 foreach ($item->options as $option) {
33 $rows[] = t('@attribute: @option', array('@attribute' => $option['attribute'], '@option' => $option['name']));
34 }
35 $desc = check_plain($item->title) . theme('item_list', $rows, NULL, 'ul', array('class' => 'product-options'));
36 $output .= '<tr valign="top"><td>'. $item->qty .'x</td><td width="100%">'. $desc
37 .'</td><td nowrap="nowrap">'. uc_currency_format($item->price * $item->qty) .'</td></tr>';
38 }
39 $output .= '</table>';
40 $review[] = $output;
41 return $review;
42 }
43 }
44
45 /**
46 * Get the user's email address for login.
47 */
48 function uc_checkout_pane_customer($op, &$arg1, $arg2) {
49 global $user;
50
51 switch ($op) {
52 case 'view':
53 $email = (is_null($arg1) || empty($arg1->primary_email)) ? $user->mail : $arg1->primary_email;
54
55 if ($user->uid) {
56 $description = t('Order information will be sent to your account e-mail listed below.');// .'<br />'
57 $contents['primary_email'] = array('#type' => 'hidden', '#value' => check_plain($email));
58 $contents['email_text'] = array(
59 '#value' => '<div>'. t('<b>E-mail address:</b> @email (<a href="!url">edit</a>)', array('@email' => $email, '!url' => url('user/'. $user->uid .'/edit', array('query' => 'destination=cart/checkout')))) .'</div>',
60 );
61 }
62 else {
63 $description = t('Enter a valid email address for this order or <a href="!url">click here</a> to login with an existing account and return to checkout.', array('!url' => url('user/login')));
64 $contents['primary_email'] = uc_textfield(t('E-mail address'), $email, TRUE, NULL, 64);
65 }
66
67 if (variable_get('uc_cart_email_validation', FALSE) && !$user->uid) {
68 $contents['primary_email_confirm'] = uc_textfield(t('Confirm e-mail address'), $_SESSION['email_match'] === FALSE ? '' : $email, TRUE, NULL, 64);
69 if ($_SESSION['email_match'] === FALSE) {
70 $contents['primary_email_confirm']['#attributes'] = array('class' => 'error');
71 unset($_SESSION['email_match']);
72 }
73 }
74
75 if ($user->uid == 0) {
76 $contents['new_account'] = array();
77
78 if (variable_get('uc_cart_new_account_name', FALSE)) {
79 $contents['new_account']['name'] = array(
80 '#type' => 'textfield',
81 '#title' => t('Username'),
82 '#default_value' => $arg1->data['new_user']['name'],
83 '#maxlength' => 60,
84 '#size' => 32,
85 );
86 }
87 if (variable_get('uc_cart_new_account_password', FALSE)) {
88 $contents['new_account']['pass'] = array(
89 '#type' => 'password',
90 '#title' => t('Password'),
91 '#maxlength' => 32,
92 '#size' => 32,
93 );
94 $contents['new_account']['pass_confirm'] = array(
95 '#type' => 'password',
96 '#title' => t('Confirm password'),
97 '#description' => t('Passwords must match to proceed.'),
98 '#maxlength' => 32,
99 '#size' => 32,
100 );
101 }
102
103 if (!empty($contents['new_account'])) {
104 $array = array(
105 '#type' => 'fieldset',
106 '#title' => t('New account details'),
107 '#description' => variable_get('uc_cart_new_account_details', t('<b>Optional.</b> New customers may supply custom account details.<br />We will create these for you if no values are entered.')),
108 '#collapsible' => FALSE,
109 );
110 $contents['new_account'] = array_merge($array, $contents['new_account']);
111 }
112
113 /**
114 * This code adds profile fields required for registration to the
115 * customer checkout pane. However, I don't have the time to fool with
116 * validation/submission stuff, so I'm postponing this feature. -RS
117 $null = NULL;
118 $extra = _user_forms($null, NULL, NULL, 'register');
119 if (!empty($extra)) {
120 $contents = array_merge($contents, $extra);
121 }*/
122 }
123
124 return array('description' => $description, 'contents' => $contents);
125
126 case 'process':
127 if (!valid_email_address($arg2['primary_email'])) {
128 drupal_set_message(t('You must enter a valid e-mail address.'), 'error');
129 return FALSE;
130 }
131
132 $arg1->primary_email = $arg2['primary_email'];
133
134 if (variable_get('uc_cart_email_validation', FALSE) && !$user->uid &&
135 $arg2['primary_email'] !== $arg2['primary_email_confirm']) {
136 drupal_set_message(t('The e-mail address did not match.'), 'error');
137 $_SESSION['email_match'] = FALSE;
138 return FALSE;
139 }
140 unset($_SESSION['email_match']);
141
142 // If new users can specify names or passwords then...
143 if ((variable_get('uc_cart_new_account_name', FALSE) ||
144 variable_get('uc_cart_new_account_password', FALSE)) &&
145 $user->uid == 0) {
146 // Skip if an account already exists for this e-mail address.
147 if (db_fetch_object(db_query("SELECT uid FROM {users} WHERE LOWER(mail) = LOWER('%s')", $arg2['primary_email'])) > 0) {
148 drupal_set_message(t('An account already exists for your e-mail address. The new account details you entered will be disregarded.'));
149 }
150 else {
151 // Validate the username.
152 if (variable_get('uc_cart_new_account_name', FALSE) && !empty($arg2['new_account']['name'])) {
153 $message = user_validate_name($arg2['new_account']['name']);
154 if (!empty($message)) {
155 drupal_set_message($message, 'error');
156 return FALSE;
157 }
158 if (db_fetch_object(db_query("SELECT uid FROM {users} WHERE LOWER(name) = LOWER('%s')", $arg2['new_account']['name'])) > 0) {
159 drupal_set_message(t('The username %name is already taken. Please enter a different name or leave the field blank for your username to be your e-mail address.', array('%name' => $arg2['new_account']['name'])), 'error');
160 return FALSE;
161 }
162 $arg1->data['new_user']['name'] = $arg2['new_account']['name'];
163 }
164 // Validate the password.
165 if (variable_get('uc_cart_new_account_password', FALSE)) {
166 if ($arg2['new_account']['pass'] != $arg2['new_account']['pass_confirm']) {
167 drupal_set_message(t('The passwords you entered did not match. Please try again.'), 'error');
168 return FALSE;
169 }
170 $arg1->data['new_user']['pass'] = $arg2['new_account']['pass'];
171 }
172 }
173 }
174
175 if ($user->uid) {
176 $arg1->uid = $user->uid;
177 }
178 return TRUE;
179
180 case 'review':
181 $review[] = array('title' => t('E-mail'), 'data' => check_plain($arg1->primary_email));
182 return $review;
183
184 case 'settings':
185 $form['uc_cart_email_validation'] = array(
186 '#type' => 'checkbox',
187 '#title' => t('Require e-mail validation for anonymous customers.'),
188 '#default_value' => variable_get('uc_cart_email_validation', FALSE),
189 );
190 $form['uc_cart_new_account_name'] = array(
191 '#type' => 'checkbox',
192 '#title' => t('Allow anonymous customers to specify a new user account name.'),
193 '#default_value' => variable_get('uc_cart_new_account_name', FALSE),
194 );
195 $form['uc_cart_new_account_password'] = array(
196 '#type' => 'checkbox',
197 '#title' => t('Allow anonymous customers to specify a new user account password.'),
198 '#default_value' => variable_get('uc_cart_new_account_password', FALSE),
199 );
200 $form['uc_cart_new_account_details'] = array(
201 '#type' => 'textarea',
202 '#title' => t('New account details help message'),
203 '#description' => t('Enter the help message displayed in the new account details fieldset when shown.'),
204 '#default_value' => variable_get('uc_cart_new_account_details', t('<b>Optional.</b> New customers may supply custom account details.<br />We will create these for you if no values are entered.')),
205 );
206 return $form;
207 }
208 }
209
210 /**
211 * Get the delivery information.
212 */
213 function uc_checkout_pane_delivery($op, &$arg1, $arg2) {
214 global $user;
215
216 switch ($op) {
217 case 'view':
218 $description = t('Enter your delivery address and information here.');
219
220 if ((uc_cart_is_shippable() || !variable_get('uc_cart_delivery_not_shippable', TRUE)) &&
221 _checkout_pane_data('billing', 'weight') < _checkout_pane_data('delivery', 'weight') &&
222 _checkout_pane_data('billing', 'enabled')) {
223 $contents['copy_address'] = array(
224 '#type' => 'checkbox',
225 '#title' => t('My delivery information is the same as my billing information.'),
226 '#attributes' => array('onclick' => "uc_cart_copy_address(this.checked, 'billing', 'delivery');"),
227 );
228 }
229
230 if ($user->uid) {
231 $addresses = uc_select_address($user->uid, 'delivery', 'apply_address(\'delivery\', this.value);', t('Saved addresses'), TRUE);
232 if (!empty($addresses)) {
233 $contents['delivery_address_select'] = $addresses;
234 }
235 }
236
237 if (uc_address_field_enabled('first_name')) {
238 $contents['delivery_first_name'] = uc_textfield(uc_get_field_name('first_name'), $arg1->delivery_first_name, uc_address_field_required('first_name'));
239 }
240 if (uc_address_field_enabled('last_name')) {
241 $contents['delivery_last_name'] = uc_textfield(uc_get_field_name('last_name'), $arg1->delivery_last_name, uc_address_field_required('last_name'));
242 }
243 if (uc_address_field_enabled('company')) {
244 $contents['delivery_company'] = uc_textfield(uc_get_field_name('company'), $arg1->delivery_company, uc_address_field_required('company'), NULL, 64);
245 }
246 if (uc_address_field_enabled('street1')) {
247 $contents['delivery_street1'] = uc_textfield(uc_get_field_name('street1'), $arg1->delivery_street1, uc_address_field_required('street1'), NULL, 64);
248 }
249 if (uc_address_field_enabled('street2')) {
250 $contents['delivery_street2'] = uc_textfield(uc_get_field_name('street2'), $arg1->delivery_street2, uc_address_field_required('street2'), NULL, 64);
251 }
252 if (uc_address_field_enabled('city')) {
253 $contents['delivery_city'] = uc_textfield(uc_get_field_name('city'), $arg1->delivery_city, uc_address_field_required('city'));
254 }
255 if (uc_address_field_enabled('country')) {
256 $contents['delivery_country'] = uc_country_select(uc_get_field_name('country'), $arg1->delivery_country, NULL, 'name', uc_address_field_required('country'));
257 }
258 if (uc_address_field_enabled('zone')) {
259 if (isset($_POST['panes']['delivery']['delivery_country'])) {
260 $country_id = intval($_POST['panes']['delivery']['delivery_country']);
261 }
262 else {
263 $country_id = $arg1->delivery_country;
264 }
265 $contents['delivery_zone'] = uc_zone_select(uc_get_field_name('zone'), $arg1->delivery_zone, NULL, $country_id, 'name', uc_address_field_required('zone'));
266 if (isset($_POST['panes']) && count($contents['delivery_zone']['#options']) == 1) {
267 $contents['delivery_zone']['#required'] = FALSE;
268 }
269 }
270 if (uc_address_field_enabled('postal_code')) {
271 $contents['delivery_postal_code'] = uc_textfield(uc_get_field_name('postal_code'), $arg1->delivery_postal_code, uc_address_field_required('postal_code'), NULL, 10, 10);
272 }
273 if (uc_address_field_enabled('phone')) {
274 $contents['delivery_phone'] = uc_textfield(uc_get_field_name('phone'), $arg1->delivery_phone, uc_address_field_required('phone'), NULL, 32, 16);
275 }
276
277 return array('description' => $description, 'contents' => $contents, 'theme' => 'address_pane');
278
279 case 'process':
280 $arg1->delivery_first_name = $arg2['delivery_first_name'];
281 $arg1->delivery_last_name = $arg2['delivery_last_name'];
282 $arg1->delivery_company = $arg2['delivery_company'];
283 $arg1->delivery_street1 = $arg2['delivery_street1'];
284 $arg1->delivery_street2 = $arg2['delivery_street2'];
285 $arg1->delivery_city = $arg2['delivery_city'];
286 $arg1->delivery_zone = $arg2['delivery_zone'];
287 $arg1->delivery_postal_code = $arg2['delivery_postal_code'];
288 $arg1->delivery_country = $arg2['delivery_country'];
289 $arg1->delivery_phone = $arg2['delivery_phone'];
290 return TRUE;
291
292 case 'review':
293 $review[] = array('title' => t('Address'), 'data' => uc_order_address($arg1, 'delivery', FALSE));
294 if (uc_address_field_enabled('phone') && !empty($arg1->delivery_phone)) {
295 $review[] = array('title' => t('Phone'), 'data' => check_plain($arg1->delivery_phone));
296 }
297 return $review;
298 }
299 }
300
301 /**
302 * Get the billing information.
303 */
304 function uc_checkout_pane_billing($op, &$arg1, $arg2) {
305 global $user;
306
307 switch ($op) {
308 case 'view':
309 $description = t('Enter your billing address and information here.');
310
311 if ((uc_cart_is_shippable() || !variable_get('uc_cart_delivery_not_shippable', TRUE)) &&
312 _checkout_pane_data('delivery', 'weight') < _checkout_pane_data('billing', 'weight') &&
313 _checkout_pane_data('delivery', 'enabled')) {
314 $contents['copy_address'] = array(
315 '#type' => 'checkbox',
316 '#title' => t('My billing information is the same as my delivery information.'),
317 '#attributes' => array('onclick' => "uc_cart_copy_address(this.checked, 'delivery', 'billing');"),
318 );
319 }
320
321 if ($user->uid) {
322 $addresses = uc_select_address($user->uid, 'billing', 'apply_address(\'billing\', this.value);', t('Saved addresses'), TRUE);
323 if (!empty($addresses)) {
324 $contents['billing_address_select'] = $addresses;
325 }
326 }
327 if (uc_address_field_enabled('first_name')) {
328 $contents['billing_first_name'] = uc_textfield(uc_get_field_name('first_name'), $arg1->billing_first_name, uc_address_field_required('first_name'));
329 }
330 if (uc_address_field_enabled('last_name')) {
331 $contents['billing_last_name'] = uc_textfield(uc_get_field_name('last_name'), $arg1->billing_last_name, uc_address_field_required('last_name'));
332 }
333 if (uc_address_field_enabled('company')) {
334 $contents['billing_company'] = uc_textfield(uc_get_field_name('company'), $arg1->billing_company, uc_address_field_required('company'), NULL, 64);
335 }
336 if (uc_address_field_enabled('street1')) {
337 $contents['billing_street1'] = uc_textfield(uc_get_field_name('street1'), $arg1->billing_street1, uc_address_field_required('street1'), NULL, 64);
338 }
339 if (uc_address_field_enabled('street2')) {
340 $contents['billing_street2'] = uc_textfield(uc_get_field_name('street2'), $arg1->billing_street2, uc_address_field_required('street2'), NULL, 64);
341 }
342 if (uc_address_field_enabled('city')) {
343 $contents['billing_city'] = uc_textfield(uc_get_field_name('city'), $arg1->billing_city, uc_address_field_required('city'));
344 }
345 if (uc_address_field_enabled('country')) {
346 $contents['billing_country'] = uc_country_select(uc_get_field_name('country'), $arg1->billing_country, NULL, 'name', uc_address_field_required('country'));
347 }
348 if (uc_address_field_enabled('zone')) {
349 if (isset($_POST['panes']['billing']['billing_country'])) {
350 $country_id = intval($_POST['panes']['billing']['billing_country']);
351 }
352 else {
353 $country_id = $arg1->billing_country;
354 }
355 $contents['billing_zone'] = uc_zone_select(uc_get_field_name('zone'), $arg1->billing_zone, NULL, $country_id, 'name', uc_address_field_required('zone'));
356 if (isset($_POST['panes']) && count($contents['billing_zone']['#options']) == 1) {
357 $contents['billing_zone']['#required'] = FALSE;
358 }
359 }
360 if (uc_address_field_enabled('postal_code')) {
361 $contents['billing_postal_code'] = uc_textfield(uc_get_field_name('postal_code'), $arg1->billing_postal_code, uc_address_field_required('postal_code'), NULL, 10, 10);
362 }
363 if (uc_address_field_enabled('phone')) {
364 $contents['billing_phone'] = uc_textfield(uc_get_field_name('phone'), $arg1->billing_phone, uc_address_field_required('phone'), NULL, 32, 16);
365 }
366
367 return array('description' => $description, 'contents' => $contents, 'theme' => 'address_pane');
368
369 case 'process':
370 $arg1->billing_first_name = $arg2['billing_first_name'];
371 $arg1->billing_last_name = $arg2['billing_last_name'];
372 $arg1->billing_company = $arg2['billing_company'];
373 $arg1->billing_street1 = $arg2['billing_street1'];
374 $arg1->billing_street2 = $arg2['billing_street2'];
375 $arg1->billing_city = $arg2['billing_city'];
376 $arg1->billing_zone = $arg2['billing_zone'];
377 $arg1->billing_postal_code = $arg2['billing_postal_code'];
378 $arg1->billing_country = $arg2['billing_country'];
379 $arg1->billing_phone = $arg2['billing_phone'];
380 return TRUE;
381
382 case 'review':
383 $review[] = array('title' => t('Address'), 'data' => uc_order_address($arg1, 'billing', FALSE));
384 if (uc_address_field_enabled('phone') && !empty($arg1->billing_phone)) {
385 $review[] = array('title' => t('Phone'), 'data' => check_plain($arg1->billing_phone));
386 }
387 return $review;
388 }
389 }
390
391 /**
392 * Allow a customer to make comments on the order.
393 */
394 function uc_checkout_pane_comments($op, &$arg1, $arg2) {
395 switch ($op) {
396 case 'view':
397 $description = t('Use this area for special instructions or questions regarding your order.');
398
399 if (!empty($arg1->order_id)) {
400 $default = db_result(db_query("SELECT message FROM {uc_order_comments} WHERE order_id = %d", $arg1->order_id));
401 }
402 $contents['comments'] = array(
403 '#type' => 'textarea',
404 '#title' => t('Order comments'),
405 '#default_value' => $default,
406 );
407
408 return array('description' => $description, 'contents' => $contents);
409
410 case 'process':
411 if (strlen($arg2['comments']) > 0) {
412 db_query("DELETE FROM {uc_order_comments} WHERE order_id = %d", $arg1->order_id);
413 uc_order_comment_save($arg1->order_id, 0, $arg2['comments'], 'order', uc_order_state_default('post_checkout'), TRUE);
414 }
415 return TRUE;
416
417 case 'review':
418 $result = db_query("SELECT message FROM {uc_order_comments} WHERE order_id = %d", $arg1->order_id);
419 if ($comment = db_fetch_object($result)) {
420 $review[] = array('title' => t('Comment'), 'data' => check_plain($comment->message));
421 }
422 return $review;
423 }
424 }
425
426 // Theme the delivery/billing address forms in tables.
427 function theme_address_pane($form) {
428 $req = '<span class="form-required">*</span>';
429
430 if (isset($form['copy_address'])) {
431 $output = drupal_render($form['copy_address']);
432 }
433
434 $output .= '<div class="address-pane-table"><table>';
435
436 foreach (element_children($form) as $field) {
437 if (substr($field, 0, 9) == 'delivery_' || substr($field, 0, 8) == 'billing_') {
438 $title = $form[$field]['#title'] .':';
439 unset($form[$field]['#title']);
440 if (substr($field, -7) == 'street1') {
441 $title = uc_get_field_name('street') .':';
442 }
443 elseif (substr($field, -7) == 'street2') {
444 $title = ' ';
445 }
446 $output .= '<tr><td class="field-label">';
447 if ($form[$field]['#required']) {
448 $output .= $req;
449 }
450 $output .= $title .'</td><td>'. drupal_render($form[$field]) .'</td></tr>';
451 }
452 }
453 $output .= '</table></div>';
454
455 foreach (element_children($form) as $element) {
456 $output .= drupal_render($form[$element]);
457 }
458
459 return $output;
460 }
461
462 /**
463 * Find the collapsible pane displayed above the pane with an ID of $pane_id.
464 */
465 function _uc_cart_checkout_prev_pane($panes, $pane_id = NULL) {
466 if (is_null($pane_id)) {
467 return FALSE;
468 }
469
470 $prev = FALSE;
471 foreach ($panes as $target) {
472 if ($target['id'] == $pane_id) {
473 return $prev;
474 }
475 if ($target['collapsible'] && variable_get('uc_pane_'. $target['id'] .'_enabled', TRUE)) {
476 $prev = $target['id'];
477 }
478 }
479
480 return FALSE;
481 }
482
483 /**
484 * Find the pane that displays below the pane with an ID of $pane_id.
485 */
486 function _uc_cart_checkout_next_pane($panes, $pane_id = NULL) {
487 if (is_null($pane_id)) {
488 return FALSE;
489 }
490
491 $next = FALSE;
492 foreach ($panes as $target) {
493 if ($next) {
494 if ($target['collapsible'] && variable_get('uc_pane_'. $target['id'] .'_enabled', TRUE)) {
495 return $target['id'];
496 }
497 }
498 if ($target['id'] == $pane_id) {
499 $next = TRUE;
500 }
501 }
502
503 return FALSE;
504 }
505
506 /**
507 * Build a list of checkout panes defined in the enabled modules.
508 */
509 function _checkout_pane_list($action = NULL) {
510 static $panes;
511
512 if (count($panes) > 0 && $action !== 'rebuild') {
513 return $panes;
514 }
515
516 $panes = module_invoke_all('checkout_pane', NULL);
517 foreach ($panes as $i => $value) {
518 $panes[$i]['enabled'] = variable_get('uc_pane_'. $panes[$i]['id'] .'_enabled', (!isset($panes[$i]['enabled']) ? TRUE : $panes[$i]['enabled']));
519 $panes[$i]['weight'] = variable_get('uc_pane_'. $panes[$i]['id'] .'_weight', (!isset($panes[$i]['weight']) ? 0 : $panes[$i]['weight']));
520 $panes[$i]['review'] = !isset($panes[$i]['review']) ? TRUE : $panes[$i]['review'];
521 $panes[$i]['process'] = !isset($panes[$i]['process']) ? TRUE : $panes[$i]['process'];
522 $panes[$i]['collapsible'] = !isset($panes[$i]['collapsible']) ? TRUE : $panes[$i]['collapsible'];
523 }
524 usort($panes, 'uc_weight_sort');
525
526 return $panes;
527 }
528
529 /**
530 * Return data from a checkout pane by pane ID and the array key.
531 */
532 function _checkout_pane_data($pane_id, $key) {
533 $panes = _checkout_pane_list();
534 foreach ($panes as $pane) {
535 if ($pane['id'] == $pane_id) {
536 return $pane[$key];
537 }
538 }
539 }
540
541 function theme_cart_review_table($show_subtotal = TRUE) {
542 $items = uc_cart_get_contents();
543 $subtotal = 0;
544
545 $output = '<table class="cart-review"><thead>'
546 .'<tr class="first last odd"><td class="first odd qty">'. t('Qty')
547 .'</td><td class="even products">'. t('Products')
548 .'</td><td class="last odd price">'. t('Price')
549 .'</td></tr></thead><tbody>';
550
551 $row = 1;
552 for ($i = 0; $i < count($items); $i++) {
553 $item = $items[$i];
554
555 $rows = array();
556 foreach ($item->options as $option) {
557 // $rows[] = $option['attribute'] .': '. $option['name'];
558 $rows[] = t('@attribute: @option', array('@attribute' => $option['attribute'], '@option' => $option['name']));
559 }
560 $desc = check_plain($item->title) . theme('item_list', $rows, NULL, 'ul', array('class' => 'product-options'));
561
562 $total = ($item->qty) ? $item->qty * $item->price : $item->price;
563 $subtotal += $total;
564 $qty = ($item->qty) ? $item->qty : '';
565 $tr_class = ($i % 2 == 0) ? 'even' : 'odd';
566 if ($show_subtotal && $i == count($items)) {
567 $tr_class .= ' last';
568 }
569
570 $output .= '<tr class="'. $tr_class .'"><td class="qty">'
571 . t('!qtyx', array('!qty' => $qty)) .'</td><td class="products">'
572 . $desc .'</td><td class="price">'. uc_currency_format($total)
573 .'</td></tr>';
574 }
575 if ($show_subtotal) {
576 $tr_class = ($tr_class == 'even') ? 'odd' : 'even';
577 $output .= '<tr class="'. $tr_class .' last"><td class="subtotal" '
578 .'colspan="4"><span id="subtotal-title">'. t('Subtotal:')
579 .'</span> '. uc_currency_format($subtotal) .'</td></tr>';
580 }
581 $output .= '</tbody></table>';
582
583 return $output;
584 }
585

  ViewVC Help
Powered by ViewVC 1.1.2