Reputation: 5824
I used Ubercart module for my shopping cart site. I want to get the cart total on the checkout page? I research on google but I can't able to find any proper help for getting the cart total.
I used below code but it returns empty.
http://api.ubercart.me/api/drupal/ubercart%21uc_cart%21uc_cart.module/function/uc_cart_block_view/7
$data = uc_cart_block_view();
print_r($data);
Please help me how can I get the cart total on check out page.
Upvotes: 0
Views: 644
Reputation: 916
I don't think there is a native ubercart function. However you can peek inside the uc_cart_checkout() function to see how the total is displayed on the checkout page.
I created my own function to do this based on the method used in uc_cart_checkout:
function mycustommodule_uc_cart_total($oid = NULL){
$items = uc_cart_get_contents($oid);
$subtotal = 0;
if (is_array($items) && count($items) > 0) {
foreach ($items as $item) {
$data = module_invoke($item->module, 'uc_cart_display', $item);
if (!empty($data)) {
$subtotal += $data['#total'];
}
}
}
return $subtotal;
}//end function
Note, this only tallies the cart item totals and does not include things like shipping or other additional line items.
Upvotes: 1