=== modified file 'uc_attribute/uc_attribute.module'
--- uc_attribute/uc_attribute.module 2009-03-03 14:22:30 +0000
+++ uc_attribute/uc_attribute.module 2009-03-12 12:23:18 +0000
@@ -593,12 +593,12 @@
foreach ($attribute->options as $option) {
switch (variable_get('uc_attribute_option_price_format', 'adjustment')) {
case 'total':
- $display_price = in_array($attribute->aid, $priced_attributes) ? ', '. uc_currency_format(($product->sell_price + $option->price) * $qty) : '';
+ $display_price = in_array($attribute->aid, $priced_attributes) ? ', '. strip_tags(theme('uc_product_price', ($product->sell_price + $option->price) * $qty, 'uc-price-attribute-total', TRUE)) : '';
if (count($priced_attributes) == 1) {
break;
}
case 'adjustment':
- $display_price = ($option->price != 0 ? ', '. ($option->price > 0 ? '+' : '') . uc_currency_format($option->price * $qty) : '');
+ $display_price = ($option->price != 0 ? ', '. ($option->price > 0 ? '+' : '') . strip_tags(theme('uc_product_price', $option->price * $qty, 'uc-price-attribute-adjustment', TRUE)) : '');
break;
case 'none':
default:
=== modified file 'uc_cart/uc_cart.module'
--- uc_cart/uc_cart.module 2009-03-07 22:38:22 +0000
+++ uc_cart/uc_cart.module 2009-03-12 12:24:33 +0000
@@ -665,7 +665,7 @@
// Add the basic row with quantity, title, and price.
$output .= '
| '. $item['qty'] .' | '
.''. $item['title'] .' | '
- .''. uc_currency_format($item['price']) .' |
';
+ .''. theme('uc_product_price', $item['price'], 'uc-price-cart-item', TRUE) .' | ';
// Add a row of description if necessary.
if ($item['desc']) {
@@ -704,7 +704,7 @@
$output = ''
.'| '. $item_text .' | '
.' '. uc_currency_format($total) .' |
';
+ .' '. theme('uc_product_price', $total, 'uc-price-cart-summary', TRUE) .'';
// If there are products in the cart...
if ($item_count > 0) {
@@ -992,7 +992,7 @@
}
function theme_uc_cart_view_price($form) {
- return uc_currency_format($form['#value']);
+ return theme('uc_product_price', $form['#value'], 'uc-price-cart-view', TRUE);
}
function uc_cart_view_table($table) {
@@ -1033,7 +1033,7 @@
}
$table[] = array(
'total' => array(
- '#value' => ''. t('Subtotal:') .' '. uc_currency_format($subtotal),
+ '#value' => ''. t('Subtotal:') .' '. theme('uc_product_price', $subtotal, 'uc-cart-subtotal', TRUE),
'#cell_attributes' => array(
'colspan' => 'full',
'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-03-12 12:25:53 +0000
@@ -33,7 +33,7 @@
$desc .= module_invoke($module, 'cart_item_description', $item);
}
$output .= '| '. $item->qty .'x | '. $desc
- .' | '. uc_currency_format($item->price * $item->qty) .' |
';
+ .''. theme('uc_product_price', $item->price * $item->qty, 'uc-price-cart-review-item', TRUE) .' | ';
}
$output .= '
';
$review[] = $output;
@@ -570,14 +570,14 @@
$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' => check_plain(strip_tags(theme('uc_product_price', $total, 'uc-price-cart-pane-item', TRUE))), 'class' => 'price'),
);
}
// Add the subtotal as the final row.
if ($show_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:') . ' ' . check_plain(strip_tags(theme('uc_product_price', $subtotal, 'uc-price-cart-pane-subtotal', TRUE))), 'colspan' => 4, 'class' => 'subtotal')),
'class' => 'subtotal',
);
}
=== modified file 'uc_catalog/uc_catalog.module'
--- uc_catalog/uc_catalog.module 2009-02-16 19:25:34 +0000
+++ uc_catalog/uc_catalog.module 2009-03-12 12:26:18 +0000
@@ -713,7 +713,7 @@
}
$product_table .= ''. $imagelink .'';
if (variable_get('uc_catalog_grid_display_sell_price', TRUE)) {
- $product_table .= ''. uc_currency_format($product->sell_price) .'';
+ $product_table .= ''. theme('uc_product_price', $product->sell_price, 'uc-price-catalog', TRUE) .'';
}
if (variable_get('uc_catalog_grid_display_add_to_cart', TRUE)) {
if (variable_get('uc_catalog_grid_display_attributes', TRUE)) {
=== modified file 'uc_order/uc_order.admin.inc'
--- uc_order/uc_order.admin.inc 2009-02-20 18:39:24 +0000
+++ uc_order/uc_order.admin.inc 2009-03-12 11:40:54 +0000
@@ -475,7 +475,7 @@
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_currency_format($order->order_total), '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),
),
@@ -957,7 +957,7 @@
array('data' => $link, 'nowrap' => 'nowrap'),
array('data' => $order->title),
array('data' => (!is_null($order->products) ? $order->products : 0), 'align' => 'center'),
- array('data' => uc_currency_format($order->total, TRUE), 'align' => 'right'),
+ array('data' => uc_currency_format($order->total), 'align' => 'right'),
);
}
=== added directory 'uc_price_alter'
=== added file 'uc_price_alter/uc_price_alter.ca.inc'
--- uc_price_alter/uc_price_alter.ca.inc 1970-01-01 00:00:00 +0000
+++ uc_price_alter/uc_price_alter.ca.inc 2009-03-12 12:18:59 +0000
@@ -0,0 +1,276 @@
+ t('Ubercart price (to be altered)'),
+ '#type' => 'array',
+ );
+
+ return $entities;
+}
+
+/**
+ * Implementation of hook_ca_trigger().
+ */
+function uc_price_alter_ca_trigger() {
+ $triggers['uc_price_alter'] = array(
+ '#title' => t('A price is about to be altered'),
+ '#category' => t('Price'),
+ '#arguments' => array(
+ 'price' => array(
+ '#entity' => 'uc_price_to_alter',
+ '#title' => t('Price'),
+ ),
+ ),
+ );
+
+ return $triggers;
+}
+
+/**
+ * Implementation of hook_ca_condition().
+ */
+function uc_price_alter_ca_condition() {
+ $arg = array(
+ '#entity' => 'uc_price_to_alter',
+ );
+
+ $conditions['uc_price_alter_is_class'] = array(
+ '#title' => t('Check the price class'),
+ '#description' => t('Return TRUE if the conditions below are met.'),
+ '#category' => t('Price'),
+ '#callback' => 'uc_price_alter_condition_is_class',
+ '#arguments' => array(
+ 'price' => $arg,
+ ),
+ );
+
+ return $conditions;
+}
+
+/**
+ * Check the class against a white/blacklist, depending on the
+ * 'inclusive' setting. First XOR used in Ubercart! =p
+ */
+function uc_price_alter_condition_is_class($price_info, $settings) {
+ $classes = explode("\n", $settings['classes']);
+ foreach ($classes as &$class) {
+ $class = trim($class);
+ }
+
+ return !($settings['inclusive'] xor in_array($price_info['class'], $classes));
+}
+
+function uc_price_alter_condition_is_class_form($form_state, $settings = array()) {
+ $form['inclusive'] = array(
+ '#type' => 'radios',
+ '#options' => array(
+ TRUE => t('Only classes listed below.'),
+ FALSE => t('None of the classes listed below.'),
+ ),
+ '#default_value' => $settings['inclusive'],
+ );
+
+ $form['classes'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Price classes'),
+ '#description' => t('List the price classes this condition applies to. Separate links with a line break.'),
+ '#default_value' => $settings['classes'],
+ );
+
+ return $form;
+}
+
+/**
+ * Implementation of hook_ca_action().
+ */
+function uc_price_alter_ca_action() {
+ $arg = array(
+ '#entity' => 'uc_price_to_alter',
+ '#title' => t('Price'),
+ );
+
+ $actions['uc_price_alter'] = array(
+ '#title' => t('Alter a price'),
+ '#category' => t('Price'),
+ '#callback' => 'uc_price_alter_action_alter',
+ '#arguments' => array(
+ 'price' => $arg,
+ ),
+ );
+
+ $actions['uc_price_alter_action_apply_tax'] = array(
+ '#title' => t('Charge a tax'),
+ '#category' => t('Price'),
+ '#callback' => 'uc_price_alter_action_apply_tax',
+ '#arguments' => array(
+ 'price' => $arg,
+ ),
+ );
+
+ $actions['uc_price_alter_add_xfix'] = array(
+ '#title' => t('Add a prefix and/or a suffix to a price'),
+ '#category' => t('Price'),
+ '#callback' => 'uc_price_alter_action_xfix',
+ '#arguments' => array(
+ 'price' => $arg,
+ ),
+ );
+
+ return $actions;
+}
+
+/**
+ * Alter a price by a given amount, applying a given operator.
+ */
+function uc_price_alter_action_alter($price_info, $settings) {
+ $price = $price_info['price'];
+ $op = isset($settings['operator']) ? $settings['operator'] : '*';
+ $amount = isset($settings['amount']) ? $settings['amount'] : 0;
+ $price_info['result']['alterations'][] = eval("return $price $op $amount;");
+}
+
+function uc_price_alter_action_alter_form($form_state, $settings = array()) {
+ $form['amount'] = array(
+ '#type' => 'textfield',
+ '#title' => t('The amount of this alteration'),
+ '#default_value' => isset($settings['amount']) ? $settings['amount'] : '',
+ );
+ $form['operator'] = array(
+ '#type' => 'select',
+ '#title' => t('Operation'),
+ '#options' => drupal_map_assoc(array('*', '+', '-', '/')),
+ '#default_value' => isset($settings['operator']) ? $settings['operator'] : '*',
+ );
+
+ return $form;
+}
+
+/**
+ * Apply one or more taxes to a price.
+ */
+function uc_price_alter_action_apply_tax($price_info, $settings) {
+ $price = $price_info['price'];
+ $taxes = uc_taxes_rate_load();
+ foreach ($taxes as $id => $tax) {
+ if ($settings['taxes'][$id]) {
+ $price_info['result']['alterations'][] = $price * $tax->rate;
+ }
+ }
+}
+
+function uc_price_alter_action_apply_tax_form($form_state, $settings = array()) {
+ $taxes = uc_taxes_rate_load();
+ foreach ($taxes as $id => $tax) {
+ $options[$id] = $tax->name;
+ }
+ $form['taxes'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Taxes'),
+ '#options' => $options,
+ '#description' => t('Check all taxes that apply.'),
+ '#default_value' => isset($settings['taxes']) ? $settings['taxes'] : array(),
+ );
+
+ return $form;
+}
+
+/**
+ * Add a prefix or a suffix to a price.
+ */
+function uc_price_alter_action_xfix($price_info, $settings) {
+ global $uc_price_alter;
+ if ($settings['suffix']) {
+ $price_info['result']['suffixes'][] = $settings['suffix'];
+ }
+ if ($settings['prefix']) {
+ $price_info['result']['prefixes'][] = $settings['prefix'];
+ }
+}
+
+function uc_price_alter_action_xfix_form($form_state, $settings = array()) {
+ $form['prefix'] = array(
+ '#type' => 'textfield',
+ '#default_value' => $settings['prefix'],
+ '#size' => 16,
+ '#prefix' => '',
+ );
+ $form['test'] = array(
+ '#type' => 'markup',
+ '#value' => uc_currency_format(1000.1234),
+ );
+ $form['suffix'] = array(
+ '#type' => 'textfield',
+ '#default_value' => $settings['suffix'],
+ '#size' => 16,
+ '#suffix' => '
',
+ );
+ $form['description'] = array(
+ '#type' => 'markup',
+ '#value' => ''. t('Add a prefix/suffix around your price. Be sure to include trailing/leading space respectively, if necessary.') .'
',
+ );
+
+ return $form;
+}
+
+/**
+ * Implementation of hook_ca_predicate().
+ */
+function uc_price_alter_ca_predicate() {
+ $predicates = array();
+
+ $predicates['uc_price_alter_test_predicate'] = array(
+ '#title' => t('Test how the price altering works with this system'),
+ '#description' => t('You can easily see how to alter prices by enabling this predicate.'),
+ '#class' => 'price',
+ '#status' => 0,
+ '#trigger' => 'uc_price_alter',
+ '#conditions' => array(
+ '#operator' => 'AND',
+ '#conditions' => array(
+ array(
+ '#name' => 'uc_price_alter_is_class',
+ '#title' => t("Only if the class isn't from the cart item review on the checkout page."),
+ '#argument_map' => array(
+ 'price' => 'price',
+ ),
+ '#settings' => array(
+ 'inclusive' => FALSE,
+ 'classes' => "uc-price-cart-item\nuc-price-cart-summary",
+ ),
+ ),
+ ),
+ ),
+ '#actions' => array(
+ array(
+ '#name' => 'uc_price_alter',
+ '#title' => t('Add 10,000 to prices'),
+ '#argument_map' => array(
+ 'price' => 'price',
+ ),
+ '#settings' => array(
+ 'operator' => '+',
+ 'amount' => '10000',
+ ),
+ ),
+ array(
+ '#name' => 'uc_price_alter_add_xfix',
+ '#title' => t('Add a little prefix and suffix to the price'),
+ '#argument_map' => array(
+ 'price' => 'price',
+ ),
+ '#settings' => array(
+ 'prefix' => 'ONLY ',
+ 'suffix' => ' incl. VAT',
+ ),
+ ),
+ ),
+ );
+
+ return $predicates;
+}
+
+
=== added file 'uc_price_alter/uc_price_alter.info'
--- uc_price_alter/uc_price_alter.info 1970-01-01 00:00:00 +0000
+++ uc_price_alter/uc_price_alter.info 2009-03-12 11:40:54 +0000
@@ -0,0 +1,6 @@
+; $Id$
+name = Ubercart price alterations
+description = Change the way prices are displayed throughout your store.
+package = Ubercart - extra
+core = 6.x
+php = 5.0
=== added file 'uc_price_alter/uc_price_alter.module'
--- uc_price_alter/uc_price_alter.module 1970-01-01 00:00:00 +0000
+++ uc_price_alter/uc_price_alter.module 2009-03-12 11:45:00 +0000
@@ -0,0 +1,50 @@
+ $price,
+ 'class' => $class,
+ 'result' => &$result,
+ );
+ // Let CA do the altering.
+ ca_pull_trigger('uc_price_alter', $to_alter);
+ $price += array_sum($result['alterations']);
+ // Render.
+ $output = '';
+ // Prefix?
+ if ($prefix = implode(" ", $result['prefixes'])) {
+ $output .= $prefix;
+ }
+ // The output from the price formatter.
+ $output .= strip_tags(theme_uc_product_price($price, $class, $no_label));
+ // Suffix?
+ if ($suffix = implode(" ", $result['suffixes'])) {
+ $output .= $suffix;
+ }
+ $output .= '
';
+ return $output;
+
+}
+
=== modified file 'uc_product/uc_product.module'
--- uc_product/uc_product.module 2009-03-08 04:24:29 +0000
+++ uc_product/uc_product.module 2009-03-12 11:40:54 +0000
@@ -699,7 +699,7 @@
'#weight' => $weight['image'],
);
}
- $node->content['display_price'] = array('#value' => theme('uc_product_price', $node->sell_price, 'display-price', TRUE),
+ $node->content['display_price'] = array('#value' => theme('uc_product_price', $node->sell_price, 'display-price uc-price-product', TRUE),
'#access' => $enabled['display_price'],
'#weight' => $weight['display_price'],
);
@@ -1191,7 +1191,7 @@
'#cell_attributes' => array('width' => '100%'),
);
if ($enabled['list_price']) {
- $data['list_price'] = array('#value' => uc_currency_format($node->list_price), '#cell_attriubtes' => array('nowrap' => 'nowrap'));
+ $data['list_price'] = array('#value' => theme('uc_product_price', $node->list_price, 'list-price', TRUE), '#cell_attriubtes' => array('nowrap' => 'nowrap'));
}
if ($enabled['sell_price']) {
$data['price'] = array('#value' => theme('uc_product_price', $node->sell_price, 'sell-price', TRUE), '#cell_attriubtes' => array('nowrap' => 'nowrap'));