=== modified file 'payment/uc_payment/uc_payment.admin.inc' --- payment/uc_payment/uc_payment.admin.inc 2009-02-10 21:51:13 +0000 +++ payment/uc_payment/uc_payment.admin.inc 2009-04-12 00:31:19 +0000 @@ -297,10 +297,21 @@ $total = $order->order_total; $payments = uc_payment_load_payments($order->order_id); - $form['order_total'] = array('#value' => uc_currency_format($total)); + $context = array( + 'location' => 'order-payments-admin', + 'subject' => array( + 'order' => $order, + 'total' => $total, + ), + ); + $form['order_total'] = array('#value' => uc_price($total, $context, array(), 'formatted')); $form['payments'] = tapir_get_table('uc_payments_table'); + $context = array( + + ); if ($payments !== FALSE) { foreach ($payments as $payment) { + $context['subject']['payment'] = $payment; $form['payments'][$payment->receipt_id]['#attributes'] = array('valign' => 'top'); $form['payments'][$payment->receipt_id]['received'] = array( '#value' => format_date($payment->received, 'custom', variable_get('uc_date_format_default', 'm/d/Y') .'H:i:s'), @@ -312,11 +323,13 @@ '#value' => ($payment->method == '') ? t('Unknown') : $payment->method, ); $form['payments'][$payment->receipt_id]['amount'] = array( - '#value' => uc_currency_format($payment->amount), + '#value' => uc_price($payment->amount, $context), ); $total -= $payment->amount; + unset($context['subject']['payment']); + $context['subject']['total'] = $total; $form['payments'][$payment->receipt_id]['balance'] = array( - '#value' => uc_currency_format($total), + '#value' => uc_price($total, $context, array('cache' => FALSE)), ); $form['payments'][$payment->receipt_id]['comment'] = array( '#value' => ($payment->comment == '') ? '-' : filter_xss_admin($payment->comment), @@ -333,7 +346,7 @@ ); } } - $form['balance'] = array('#value' => uc_currency_format($total)); + $form['balance'] = array('#value' => uc_price($total, $context, array(), 'formatted')); $form['order_id'] = array( '#type' => 'hidden', '#value' => $order->order_id, === modified file 'payment/uc_payment/uc_payment.module' --- payment/uc_payment/uc_payment.module 2008-12-08 17:05:35 +0000 +++ payment/uc_payment/uc_payment.module 2009-04-11 22:40:25 +0000 @@ -326,18 +326,28 @@ .' '; $grand_total = 0; + $context = array( + 'location' => 'checkout-order-total-preview', + ); + foreach ($totals as $line) { if (!empty($line[2])) { + $context['subject'] = array( + 'line_item' => $line, + ); $output .= '' - .''; + .''; if ($line[3]) { $grand_total += round($line[1], 2); } } } + $context['subject'] = array( + 'grand_total' => $grand_total, + ); $output .= '' - .'
'. $line[2] .':'. uc_currency_format($line[1]) .'
'. uc_price($line[1]) .'
'. t('Order total:') .''. uc_currency_format($grand_total) + .''. uc_price($grand_total, $context) .'
'; } === modified file 'payment/uc_payment/uc_payment_order_pane.inc' --- payment/uc_payment/uc_payment_order_pane.inc 2008-11-07 20:19:07 +0000 +++ payment/uc_payment/uc_payment_order_pane.inc 2009-04-11 23:07:49 +0000 @@ -18,7 +18,13 @@ switch ($op) { case 'view': if (variable_get('uc_payment_tracking', TRUE)) { - $output = t('Balance: @balance', array('@balance' => uc_currency_format(uc_payment_balance($arg1)))); + $context = array( + 'location' => 'payment-balance', + 'subject' => array( + 'order' => $arg1, + ), + ); + $output = t('Balance: @balance', array('@balance' => uc_price(uc_payment_balance($arg1), $context, array(), 'formatted'))); $output .= ' ('. l(t('View'), 'admin/store/orders/'. $arg1->order_id .'/payments') .')
'; } $method_name = _payment_method_data($arg1->payment_method, 'review'); === modified file 'uc_cart/uc_cart.module' --- uc_cart/uc_cart.module 2009-04-01 16:39:58 +0000 +++ uc_cart/uc_cart.module 2009-04-12 01:32:07 +0000 @@ -459,7 +459,7 @@ } $item_count += $item->qty; - $total += $item->price * $item->qty; + $total += $display_item['#total']; } } @@ -660,12 +660,16 @@ $output = ''; $row_class = 'odd'; + $context = array( + 'location' => 'cart-block-item', + ); + // Loop through each item. foreach ($items as $item) { // Add the basic row with quantity, title, and price. $output .= '' .'' - .''; + .''; // Add a row of description if necessary. if ($item['desc']) { @@ -704,7 +708,7 @@ $output = '
'. $item['qty'] .''. $item['title'] .''. uc_currency_format($item['price']) .'
'. uc_price($item['price'], $context) .'
' .'' .''; + .' '. uc_price($total, array('location' => 'cart-block-total'), array(), 'formatted') .''; // If there are products in the cart... if ($item_count > 0) { @@ -875,8 +879,12 @@ '#value' => '', ); } + + $context = array( + 'location' => 'cart-subtotal', + ); $form['items'][$i]['total'] = array( - '#value' => $display_item['#total'], + '#value' => uc_price($display_item['#total'], $context), '#theme' => 'uc_cart_view_price', ); $i++; @@ -992,7 +1000,7 @@ } function theme_uc_cart_view_price($form) { - return uc_currency_format($form['#value']); + return $form['#value']; } function uc_cart_view_table($table) { @@ -1031,9 +1039,13 @@ $table[$i]['total']['#cell_attributes'] = array('nowrap' => 'nowrap', 'class' => 'price'); $table[$i]['#attributes'] = array('valign' => 'top'); } + + $context = array( + 'location' => 'cart-table-subtotal', + ); $table[] = array( 'total' => array( - '#value' => ''. t('Subtotal:') .' '. uc_currency_format($subtotal), + '#value' => ''. t('Subtotal:') .' '. uc_price($subtotal, $context, array(), 'formatted'), '#cell_attributes' => array( 'colspan' => 'full', 'align' => 'right', === modified file 'uc_cart/uc_cart.pages.inc' --- uc_cart/uc_cart.pages.inc 2009-02-27 16:06:16 +0000 +++ uc_cart/uc_cart.pages.inc 2009-04-11 18:38:40 +0000 @@ -191,9 +191,29 @@ } unset($_SESSION['expanded_panes']); + $context = array( + 'location' => 'cart-checkout-item', + ); + $contents = uc_cart_get_contents(); + foreach ($contents as $key => $item) { + $price_info = array( + 'price' => $item->price, + 'qty' => $item->qty, + ); + $context['subject'] = array( + 'cart_item' => $item, + 'node' => node_load($item->nid), + ); + + // Get the altered price per unit, as ordered products have a locked-in + // price. Price altering rules may change over time, but the amount paid + // by the customer does not after the fact. + $contents[$key]->price = uc_price($price_info, $context, array(), 'altered') / $item->qty; + } + $form['cart_contents'] = array( '#type' => 'hidden', - '#value' => serialize(uc_cart_get_contents()), + '#value' => serialize($contents), ); $form['cancel'] = array( === modified file 'uc_cart/uc_cart_block.css' --- uc_cart/uc_cart_block.css 2009-03-31 18:08:43 +0000 +++ uc_cart/uc_cart_block.css 2009-04-11 21:54:38 +0000 @@ -115,6 +115,10 @@ font-weight: bold; } +.cart-block-summary-total .uc-price { + display: inline; +} + .cart-block-summary-links { text-align: right; } === modified file 'uc_cart/uc_cart_checkout_pane.inc' --- uc_cart/uc_cart_checkout_pane.inc 2008-12-31 13:50:42 +0000 +++ uc_cart/uc_cart_checkout_pane.inc 2009-04-12 01:30:54 +0000 @@ -27,13 +27,26 @@ case 'review': $items = uc_cart_get_contents(); $output = '
'. $item_text .' '. uc_currency_format($total) .'
'; + $context = array( + 'location' => 'cart-review-item', + 'subject' => array(), + ); foreach ($items as $item) { $desc = check_plain($item->title); foreach (module_implements('cart_item_description') as $module) { $desc .= module_invoke($module, 'cart_item_description', $item); } + + $price_info = array( + 'price' => $item->price, + 'qty' => $item->qty, + ); + $context['subject'] = array( + 'cart_item' => $item, + 'node' => node_load($item->nid), + ); $output .= ''; + .''; } $output .= '
'. $item->qty .'x'. $desc - .''. uc_currency_format($item->price * $item->qty) .'
'. uc_price($price_info, $context) .'
'; $review[] = $output; @@ -557,9 +570,22 @@ array('data' => t('Price'), 'class' => 'price'), ); + $context = array( + 'location' => 'cart-checkout-item', + ); + // Set up table rows. foreach (uc_cart_get_contents() as $item) { - $total = ($item->qty) ? $item->qty * $item->price : $item->price; + $price_info = array( + 'price' => $item->price, + 'qty' => $item->qty, + ); + $context['subject'] = array( + 'cart_item' => $item, + 'node' => node_load($item->nid), + ); + + $total = uc_price($price_info, $context, array(), 'altered'); $subtotal += $total; $description = check_plain($item->title); @@ -567,17 +593,22 @@ $description .= module_invoke($module, 'cart_item_description', $item); } + // Remove node from context to prevent the price from being altered. + unset($context['subject']); $rows[] = array( array('data' => t('@qtyx', array('@qty' => $item->qty)), 'class' => 'qty'), array('data' => $description, 'class' => 'products'), - array('data' => check_plain(uc_currency_format($total)), 'class' => 'price'), + array('data' => uc_price($total, $context), 'class' => 'price'), ); } // Add the subtotal as the final row. if ($show_subtotal) { + $context = array( + 'location' => 'cart-checkout-subtotal', + ); $rows[] = array( - 'data' => array(array('data' => '' . t('Subtotal:') . ' ' . check_plain(uc_currency_format($subtotal)), 'colspan' => 4, 'class' => 'subtotal')), + 'data' => array(array('data' => '' . t('Subtotal:') . ' ' . uc_price($subtotal, $context, array(), 'formatted'), 'colspan' => 4, 'class' => 'subtotal')), 'class' => 'subtotal', ); } === modified file 'uc_order/templates/admin.itpl.php' --- uc_order/templates/admin.itpl.php 2009-01-02 16:03:40 +0000 +++ uc_order/templates/admin.itpl.php 2009-04-11 23:30:50 +0000 @@ -15,8 +15,20 @@


- -- qty; ?> x title .' - '. uc_currency_format($product->price * $product->qty); ?>
+ 'order-invoice-admin', +); +foreach ($products as $product) { + $price_info = array( + 'price' => $product->price, + 'qty' => $product->qty, + ); + $context['subject'] = array( + 'order_product' => $product, + ); +?> +- qty; ?> x title .' - '. uc_price($price_info, $context); ?>
  model; ?>
data['attributes']) && count($product->data['attributes']) > 0) {?> data['attributes'] as $key => $value) { === modified file 'uc_order/templates/customer.itpl.php' --- uc_order/templates/customer.itpl.php 2009-04-04 00:03:04 +0000 +++ uc_order/templates/customer.itpl.php 2009-04-11 23:35:00 +0000 @@ -154,7 +154,14 @@ - 'order-invoice-line-item', + 'subject' => array( + 'order' => $order, + ), + ); + foreach ($line_items as $item) { if ($item['line_item_id'] == 'subtotal' || $item['line_item_id'] == 'total') { continue; }?> @@ -164,7 +171,10 @@ : - + @@ -191,13 +201,25 @@ products)) { - foreach ($order->products as $product) { ?> + $context = array( + 'location' => 'order-invoice-product', + 'subject' => array( + 'order' => $order, + ), + ); + foreach ($order->products as $product) { + $price_info = array( + 'price' => $product->price, + 'qty' => $product->qty, + ); + $context['subject']['order_product'] = $product; + ?>
qty; ?> x - title .' - '. uc_currency_format($product->price * $product->qty); ?> + title .' - '. uc_price($price_info, $context, array(), 'formatted'); ?> qty > 1) { echo t('(!price each)', array('!price' => uc_currency_format($product->price))); } ?> === modified file 'uc_order/uc_order.admin.inc' --- uc_order/uc_order.admin.inc 2009-04-01 17:14:08 +0000 +++ uc_order/uc_order.admin.inc 2009-04-11 22:51:32 +0000 @@ -451,6 +451,13 @@ $address = 'billing'; } + $context = array( + 'location' => 'orders-admin', + 'subject' => array( + 'field' => 'order_total', + ), + ); + $result = pager_query($sql, variable_get('uc_order_number_displayed', 30), 0, NULL, $args); while ($order = db_fetch_object($result)) { if ($address == 'shipping') { @@ -470,12 +477,14 @@ $order_name = t('User: !name', array('!name' => $account)); } } + + $context['subject']['order'] = $order; $rows[] = array( 'data' => array( array('data' => uc_order_actions($order, TRUE), 'nowrap' => 'nowrap'), array('data' => $order->order_id), array('data' => check_plain($order_name), 'nowrap' => 'nowrap'), - array('data' => uc_currency_format($order->order_total, TRUE), 'align' => 'right', 'nowrap' => 'true'), + array('data' => uc_price($order->order_total, $context), 'align' => 'right', 'nowrap' => 'true'), array('data' => format_date($order->created, 'custom', variable_get('uc_date_format_default', 'm/d/Y')), 'align' => 'center'), array('data' => $order->title), ), === modified file 'uc_order/uc_order.ca.inc' --- uc_order/uc_order.ca.inc 2009-04-06 16:37:54 +0000 +++ uc_order/uc_order.ca.inc 2009-04-11 22:19:24 +0000 @@ -728,13 +728,13 @@ // Check an user name function uc_order_condition_user_name($order, $settings) { - if ($account = uc_order_user_load($order)) { - return $account->name == $settings['name']; - } - else { + if (empty($order->uid)) { // Anonymous users have no names. return empty($settings['name']); } + else { + return uc_order_user_load($order)->name == $settings['name']; + } } function uc_order_condition_user_name_form($form_state, $settings = array()) { === modified file 'uc_order/uc_order.line_item.inc' --- uc_order/uc_order.line_item.inc 2009-02-27 15:32:25 +0000 +++ uc_order/uc_order.line_item.inc 2009-04-11 18:53:47 +0000 @@ -24,9 +24,20 @@ ); return $lines; case 'cart-preview': + $context = array( + 'location' => 'cart-preview-subtotal-item', + ); $subtotal = 0; foreach ($arg1 as $item) { - $total = ($item->qty) ? $item->qty * $item->price : $item->price; + $price_info = array( + 'price' => $item->price, + 'qty' => ($item->qty) ? $item->qty : 1, + ); + $context['subject'] = array( + 'cart_item' => $item, + 'node' => node_load($item->nid), + ); + $total = uc_price($price_info, $context, array(), 'altered'); $subtotal += $total; } if (module_exists('uc_payment') && variable_get('uc_pane_payment_enabled', TRUE)) { === modified file 'uc_order/uc_order.module' --- uc_order/uc_order.module 2009-04-06 18:31:41 +0000 +++ uc_order/uc_order.module 2009-04-11 23:39:53 +0000 @@ -369,7 +369,14 @@ if (is_array($order->line_items)) { foreach ($order->line_items as $key => $value) { if ($value['type'] == 'subtotal') { - $subtotal = uc_currency_format($order->line_items[$key]['amount']); + $context = array( + 'location' => 'order-subtotal-token', + 'subject' => array( + 'order' => $order, + 'line_item' => $order->line_items[$key], + ), + ); + $subtotal = uc_price($order->line_items[$key]['amount'], $context, array(), 'formatted'); } if ($value['type'] == 'shipping' && is_null($ship_method)) { $ship_method = $value['title']; @@ -377,7 +384,14 @@ } } $values['order-subtotal'] = $subtotal; - $values['order-total'] = uc_currency_format($order->order_total); + $context = array( + 'location' => 'order-total-token', + 'subject' => array( + 'order' => $order, + 'field' => 'order_total', + ), + ); + $values['order-total'] = uc_price($order->order_total, $context, array(), 'formatted'); $values['order-email'] = check_plain($order->primary_email); $values['order-shipping-address'] = uc_order_address($order, 'delivery'); $values['order-shipping-phone'] = check_plain($order->delivery_phone); === modified file 'uc_order/uc_order.order_pane.inc' --- uc_order/uc_order.order_pane.inc 2009-02-05 22:19:50 +0000 +++ uc_order/uc_order.order_pane.inc 2009-04-11 23:20:56 +0000 @@ -331,11 +331,18 @@ } usort($line_items, 'uc_weight_sort'); + $context = array( + 'location' => 'order-line-items', + 'subject' => array( + 'order' => $arg1, + ), + ); $output = ''; foreach ($line_items as $item) { + $context['subject']['line_item'] = $item; $output .= '' .''; + . uc_price($item['amount'], $context) .''; } $output .= '
'. check_plain($item['title']) .':' - . uc_currency_format($item['amount']) .'
'; return $output; @@ -394,6 +401,13 @@ '#collapsed' => FALSE, '#tree' => TRUE, ); + + $context = array( + 'location' => 'order-edit-line-items', + 'subject' => array( + 'order' => $arg1, + ), + ); foreach ($line_items as $item) { $form['line_items'][$item['line_item_id']]['li_id'] = array( '#type' => 'hidden', @@ -425,11 +439,12 @@ ); } else { + $context['subject']['line_item'] = $item; $form['line_items'][$item['line_item_id']]['title'] = array( '#value' => check_plain($item['title']), ); $form['line_items'][$item['line_item_id']]['amount'] = array( - '#value' => uc_currency_format($item['amount']), + '#value' => uc_price($item['amount'], $context), ); } } @@ -659,13 +674,13 @@ if (!is_null($form_state['values']['admin_comment']) && strlen(trim($form_state['values']['admin_comment'])) > 0) { uc_order_comment_save($form_state['values']['order_id'], $user->uid, $form_state['values']['admin_comment']); } - + // Let conditional actions send email if requested. if ($form_state['values']['notify']) { $order = uc_order_load($form_state['values']['order_id']); ca_pull_trigger('uc_order_status_email_update', $order); } - + drupal_set_message(t('Order updated.')); } @@ -724,6 +739,10 @@ 'weight' => 5, ); + $context = array( + 'location' => 'order-view-products', + ); + if (is_array($products)) { foreach ($products as $product) { $data = array(); @@ -751,12 +770,20 @@ '#cell_attributes' => array('align' => 'right', 'nowrap' => 'nowrap'), ); } + + $price_info = array( + 'price' => $product->price, + 'qty' => $product->qty, + ); + $context['subject'] = array( + 'order_product' => $product, + ); $data['price'] = array( - '#value' => uc_currency_format($product->price), + '#value' => uc_price($product->price, $context), '#cell_attributes' => array('align' => 'right', 'nowrap' => 'nowrap'), ); $data['total'] = array( - '#value' => uc_currency_format($product->qty * $product->price), + '#value' => uc_price($price_info, $context), '#cell_attributes' => array('align' => 'right', 'nowrap' => 'nowrap'), ); $data['#attributes'] = array('valign' => 'top'); @@ -825,6 +852,10 @@ 'weight' => 5, ); + $context = array( + 'location' => 'order-customer-products', + ); + if (is_array($products)) { foreach ($products as $product) { $data = array(); @@ -852,12 +883,20 @@ '#cell_attributes' => array('align' => 'right', 'nowrap' => 'nowrap'), ); } + + $price_info = array( + 'price' => $product->price, + 'qty' => $product->qty, + ); + $context['subject'] = array( + 'order_product' => $product, + ); $data['price'] = array( - '#value' => uc_currency_format($product->price), + '#value' => uc_price($product->price, $context), '#cell_attributes' => array('align' => 'right', 'nowrap' => 'nowrap'), ); $data['total'] = array( - '#value' => uc_currency_format($product->qty * $product->price), + '#value' => uc_price($price_info, $context), '#cell_attributes' => array('align' => 'right', 'nowrap' => 'nowrap'), ); $data['#attributes'] = array('valign' => 'top'); === modified file 'uc_product/uc_product.css' --- uc_product/uc_product.css 2009-01-07 15:08:16 +0000 +++ uc_product/uc_product.css 2009-04-09 16:55:50 +0000 @@ -9,6 +9,17 @@ margin-left: 4px; } +.uc-price-display { + float: right; + clear: right; + width: 100px; + text-align: center; + font-size: 1.3em; + font-weight: bold; + padding-bottom: 4px; + padding-left: 4px; +} + .display-price { float: right; clear: right; === modified file 'uc_product/uc_product.module' --- uc_product/uc_product.module 2009-04-07 18:50:58 +0000 +++ uc_product/uc_product.module 2009-04-11 21:01:09 +0000 @@ -695,27 +695,47 @@ 'add_to_cart' => 10, )); + $context = array( + 'location' => 'product-view', + 'class' => array( + 'product', + ), + 'subject' => array( + 'node' => $node, + ), + ); + if (module_exists('imagecache') && ($field = variable_get('uc_image_'. $node->type, '')) && isset($node->$field) && file_exists($node->{$field}[0]['filepath'])) { $node->content['image'] = array('#value' => theme('uc_product_image', $node->$field, $teaser, $page), '#access' => $enabled['image'], '#weight' => $weight['image'], ); } - $node->content['display_price'] = array('#value' => theme('uc_product_price', $node->sell_price, 'display-price', TRUE), + + $context['class'][1] = 'display'; + $context['subject']['field'] = 'sell_price'; + $node->content['display_price'] = array('#value' => uc_price($node->sell_price, $context), '#access' => $enabled['display_price'], '#weight' => $weight['display_price'], ); + if (!$teaser) { $node->content['model'] = array('#value' => theme('uc_product_model', $node->model, $teaser, $page), '#access' => $enabled['model'], '#weight' => $weight['model'], ); $node->content['body']['#weight'] = 1; - $node->content['list_price'] = array('#value' => theme('uc_product_price', $node->list_price, 'list-price'), + + $context['class'][1] = 'list'; + $context['subject']['field'] = 'list_price'; + $node->content['list_price'] = array('#value' => uc_price($node->list_price, $context), '#access' => $enabled['list_price'], '#weight' => $weight['list_price'], ); - $node->content['cost'] = array('#value' => theme('uc_product_price', $node->cost, 'cost'), + + $context['class'][1] = 'cost'; + $context['subject']['field'] = 'cost'; + $node->content['cost'] = array('#value' => uc_price($node->cost, $context), '#access' => $enabled['cost'] && user_access('administer products'), '#weight' => $weight['cost'], ); @@ -724,7 +744,9 @@ $node->content['#attributes'] = array('style' => 'display: inline'); } - $node->content['sell_price'] = array('#value' => theme('uc_product_price', $node->sell_price, 'sell-price', $teaser), + $context['class'][1] = 'sell'; + $context['subject']['field'] = 'sell_price'; + $node->content['sell_price'] = array('#value' => uc_price($node->sell_price, $context, array('label' => !$teaser)), '#access' => $enabled['sell_price'], '#weight' => $weight['sell_price'], ); @@ -1076,7 +1098,20 @@ $element['title'] = array( '#value' => node_access('view', $node) ? l($item->title, 'node/'. $node->nid) : check_plain($item->title), ); - $element['#total'] = $item->price * $item->qty; + + $context = array( + 'location' => 'cart-item', + 'subject' => array( + 'cart_item' => $item, + 'node' => $node, + ), + ); + $price_info = array( + 'price' => $item->price, + 'qty' => $item->qty, + ); + + $element['#total'] = uc_price($price_info, $context, array(), 'altered'); $element['data'] = array('#type' => 'hidden', '#value' => serialize($item->data)); $element['qty'] = array( '#type' => 'textfield',