diff --git a/uc_cart/uc_cart.controller.inc b/uc_cart/uc_cart.controller.inc index 4fb4658..8416877 100644 --- a/uc_cart/uc_cart.controller.inc +++ b/uc_cart/uc_cart.controller.inc @@ -4,8 +4,11 @@ * * Contains the controller for uc_cart_item entities. */ -class UcCartItemController extends UcOrderProductController { +class UcCartItemController extends EntityAPIController { + /** + * Overrides EntityAPIController::attachLoad(). + */ public function attachLoad(&$items, $revision_id = FALSE) { foreach ($items as &$item) { $product = uc_product_load_variant($item->nid, $item->data); @@ -17,4 +20,19 @@ class UcCartItemController extends UcOrderProductController { } parent::attachLoad($items, $revision_id); } + + /** + * Overrides EntityAPIController::buildContent(). + */ + public function buildContent($product, $view_mode = 'full', $langcode = NULL, $content = array()) { + $content += module_invoke($product->data['module'], 'uc_cart_display', $product); + if (!empty($content)) { + $content['cart_item_id'] = array( + '#type' => 'hidden', + '#value' => isset($product->cart_item_id) ? $product->cart_item_id : 0, + ); + } + + return parent::buildContent($product, $view_mode, $langcode, $content); + } } diff --git a/uc_cart/uc_cart_checkout_pane.inc b/uc_cart/uc_cart_checkout_pane.inc index 7ac6961..7e28008 100644 --- a/uc_cart/uc_cart_checkout_pane.inc +++ b/uc_cart/uc_cart_checkout_pane.inc @@ -494,20 +494,12 @@ function theme_uc_cart_review_table($variables) { if (!empty($display_items['uc_order_product'])) { foreach (element_children($display_items['uc_order_product']) as $key) { $display_item = $display_items['uc_order_product'][$key]; - if (count(element_children($display_item)) && isset($display_item['#total'])) { - $total = $display_item['#total']; - $subtotal += $total; - $description = $display_item['title']['#markup']; - if (!empty($display_item['description']['#markup'])) { - $description .= $display_item['description']['#markup']; - } - $qty = $display_item['qty']['#default_value']; - $suffix = !empty($display_item['#suffixes']) ? implode(' ', $display_item['#suffixes']) : ''; - + if (count(element_children($display_item))) { + $subtotal += $display_item['total']['#price']; $rows[] = array( - array('data' => array('#theme' => 'uc_qty', '#qty' => $qty), 'class' => array('qty')), - array('data' => $description, 'class' => array('products')), - array('data' => array('#theme' => 'uc_price', '#price' => $total, '#suffix' => $suffix), 'class' => array('price')), + array('data' => $display_item['qty'], 'class' => array('qty')), + array('data' => $display_item['product'], 'class' => array('products')), + array('data' => $display_item['total'], 'class' => array('price')), ); } } diff --git a/uc_order/uc_order.controller.inc b/uc_order/uc_order.controller.inc index 5cf746b..a064d96 100644 --- a/uc_order/uc_order.controller.inc +++ b/uc_order/uc_order.controller.inc @@ -63,55 +63,46 @@ class UcOrderController extends DrupalDefaultEntityController { * Controller class for the uc_order_product entity. */ class UcOrderProductController extends EntityAPIController { - public function buildContent($product, $view_mode = 'full', $langcode = NULL, $content = array()) { - switch ($view_mode) { - case 'cart': - $content = array(); - $content += module_invoke($product->data['module'], 'uc_cart_display', $product); - if (!empty($content)) { - $content['cart_item_id'] = array( - '#type' => 'hidden', - '#value' => isset($product->cart_item_id) ? $product->cart_item_id : 0, - ); - } - break; - default: - $content['qty'] = array( - '#theme' => 'uc_qty', - '#qty' => $product->qty, - '#cell_attributes' => array('class' => array('qty')), - ); - $node = node_load($product->nid); - $title = node_access('view', $node) ? l($product->title, 'node/' . $node->nid) : check_plain($product->title); - $content['product'] = array( - '#markup' => $title . uc_product_get_description($product), - '#cell_attributes' => array('class' => array('product')), - ); - $content['model'] = array( - '#markup' => check_plain($product->model), - '#cell_attributes' => array('class' => array('sku')), - ); - if (user_access('administer products')) { - $content['cost'] = array( - '#theme' => 'uc_price', - '#price' => $product->cost, - '#cell_attributes' => array('class' => array('cost')), - ); - } - $content['price'] = array( - '#theme' => 'uc_price', - '#price' => $product->price, - '#suffixes' => array(), - '#cell_attributes' => array('class' => array('price')), - ); - $content['total'] = array( - '#theme' => 'uc_price', - '#price' => $product->price * $product->qty, - '#suffixes' => array(), - '#cell_attributes' => array('class' => array('total')), - ); + /** + * Overrides EntityAPIController::buildContent(). + */ + public function buildContent($product, $view_mode = 'full', $langcode = NULL, $content = array()) { + $content['qty'] = array( + '#theme' => 'uc_qty', + '#qty' => $product->qty, + '#cell_attributes' => array('class' => array('qty')), + ); + $node = node_load($product->nid); + $title = node_access('view', $node) ? l($product->title, 'node/' . $node->nid) : check_plain($product->title); + $content['product'] = array( + '#markup' => $title . uc_product_get_description($product), + '#cell_attributes' => array('class' => array('product')), + ); + $content['model'] = array( + '#markup' => check_plain($product->model), + '#cell_attributes' => array('class' => array('sku')), + ); + if (user_access('administer products')) { + $content['cost'] = array( + '#theme' => 'uc_price', + '#price' => $product->cost, + '#cell_attributes' => array('class' => array('cost')), + ); } + $content['price'] = array( + '#theme' => 'uc_price', + '#price' => $product->price, + '#suffixes' => array(), + '#cell_attributes' => array('class' => array('price')), + ); + $content['total'] = array( + '#theme' => 'uc_price', + '#price' => $product->price * $product->qty, + '#suffixes' => array(), + '#cell_attributes' => array('class' => array('total')), + ); + return parent::buildContent($product, $view_mode, $langcode, $content); } diff --git a/uc_taxes/uc_taxes.module b/uc_taxes/uc_taxes.module index 5cdaed9..b32e1fe 100644 --- a/uc_taxes/uc_taxes.module +++ b/uc_taxes/uc_taxes.module @@ -119,28 +119,28 @@ function uc_taxes_entity_view_alter(&$build, $entity_type) { break; case 'uc_cart_item': - case 'uc_order_product': list($amount, $suffixes) = uc_taxes_get_included_tax($build['#entity'], isset($build['#entity']->order) ? $build['#entity']->order : NULL); - if ($build['#view_mode'] == 'cart') { - if (!empty($build['#total'])) { - if (!empty($amount) && !empty($build['#total'])) { - $build['#total'] += $amount * $build['qty']['#default_value']; - } - if (!empty($suffixes)) { - if (empty($build['#suffixes'])) { - $build['#suffixes'] = array(); - } - $build['#suffixes'] += $suffixes; - } - } + + if (!empty($amount) && !empty($build['#total'])) { + $build['#total'] += $amount * $build['qty']['#default_value']; } - else { - $build['price']['#price'] += $amount; - $build['total']['#price'] += $amount * $build['#entity']->qty; - $build['price']['#suffixes'] += $suffixes; - $build['total']['#suffixes'] += $suffixes; + + if (!empty($suffixes)) { + if (empty($build['#suffixes'])) { + $build['#suffixes'] = array(); + } + $build['#suffixes'] += $suffixes; } break; + + case 'uc_order_product': + list($amount, $suffixes) = uc_taxes_get_included_tax($build['#entity'], isset($build['#entity']->order) ? $build['#entity']->order : NULL); + + $build['price']['#price'] += $amount; + $build['total']['#price'] += $amount * $build['#entity']->qty; + $build['price']['#suffixes'] += $suffixes; + $build['total']['#suffixes'] += $suffixes; + break; } }