/** * Update the shop order totals for the give order id * * @param int $orderId */ public static function updateShopOrderTotals($orderId) { $order = new order($orderId); $total = rpData::getBasketAmount($order, $orderId); $sql = "UPDATE orders_total SET value = " . (double) $total . " WHERE class = 'ot_total' AND orders_id = '" . xtc_db_input($orderId) . "'"; xtc_db_query($sql); $tax = rpData::getTotalTaxAmount($orderId); $sql = "UPDATE orders_total SET value = " . (double) $tax . " WHERE class = 'ot_tax' AND orders_id = '" . xtc_db_input($orderId) . "'"; xtc_db_query($sql); $subtotal = rpData::getSubtotal($orderId); $sql = "UPDATE orders_total SET value = " . (double) $subtotal . " WHERE class = 'ot_subtotal' and orders_id = '" . xtc_db_input($orderId) . "'"; xtc_db_query($sql); $classes = array('ot_total', 'ot_tax', 'ot_subtotal'); foreach ($classes as $class) { $sql = "SELECT value from orders_total WHERE orders_id = '" . xtc_db_input($orderId) . "' and class = '{$class}'"; $query = xtc_db_query($sql); $entry = xtc_db_fetch_array($query); $text = rpData::getFormattedPrice($entry['value'], $order->info['language'], $order); if ($class == 'ot_total') { $text = "<b>" . rpData::getFormattedPrice($entry['value'], $order->info['language'], $order) . "</b>"; } $sql = "UPDATE orders_total SET text = '{$text}' WHERE orders_id = '" . xtc_db_input($orderId) . "' and class = '{$class}'"; xtc_db_query($sql); } }