コード例 #1
0
function eo_update_database_order_totals($oID)
{
    global $db, $order;
    // Load required modules for order totals if enabled
    if (defined('MODULE_ORDER_TOTAL_INSTALLED') && zen_not_null(MODULE_ORDER_TOTAL_INSTALLED)) {
        // Load order totals.
        require_once DIR_FS_CATALOG . DIR_WS_CLASSES . 'order_total.php';
        $GLOBALS['order_total_modules'] = new order_total();
        // Load the shopping cart class into the session
        eo_shopping_cart();
        // This fixes an issue caused by ot_shipping assuming shipping tax amount
        // has not already been added to the shipping cost and order tax.
        if (array_key_exists('shipping_tax', $order->info)) {
            $order->info['tax'] -= $order->info['shipping_tax'];
            if (DISPLAY_PRICE_WITH_TAX == 'true') {
                $order->info['shipping_cost'] -= $order->info['shipping_tax'];
            }
        }
        // Reset the final total (include tax if not already tax-inc)
        // This code causes the order totals to be correctly calculated.
        if (DISPLAY_PRICE_WITH_TAX == 'true') {
            $order->info['total'] = $order->info['subtotal'] + $order->info['shipping_cost'];
        } else {
            $order->info['total'] = $order->info['subtotal'] + $order->info['tax'] + $order->info['shipping_cost'];
        }
        // Process the order totals
        $order_totals = $GLOBALS['order_total_modules']->process();
        // Update the order totals in the database
        for ($i = 0, $n = sizeof($order_totals); $i < $n; $i++) {
            eo_update_database_order_total($oID, $order_totals[$i]);
        }
        unset($order_totals);
    }
}
コード例 #2
0
     eo_log('Product Being Added:' . PHP_EOL . var_export($new_product, true) . PHP_EOL);
 }
 eo_add_product_to_order($oID, $new_product);
 // Update Subtotal and Pricing
 eo_update_order_subtotal($oID, $new_product);
 // Save the changes
 eo_update_database_order_totals($oID);
 $GLOBALS['order'] = eo_get_order_by_id($oID);
 // Remove the low order fee (will automatically repopulate if needed)
 foreach ($GLOBALS['order']->totals as $key => $total) {
     if ($total['class'] == 'ot_loworderfee') {
         // Update the information in the order
         $total['title'] = '';
         $total['value'] = 0;
         $total['code'] = $total['class'];
         eo_update_database_order_total($oID, $total);
         unset($GLOBALS['order']->totals[$key]);
         break;
     }
 }
 // Requires $GLOBALS['order'] to be reset and populated
 $GLOBALS['order'] = eo_get_order_by_id($oID);
 eo_update_database_order_totals($oID);
 switch (true) {
     case EO_DEBUG_ACTION_LEVEL > 3:
         eo_log('Final Products in Order:' . PHP_EOL . var_export($GLOBALS['order']->products, true) . PHP_EOL);
     case EO_DEBUG_ACTION_LEVEL > 2:
         eo_log('Final Order Totals:' . PHP_EOL . var_export($GLOBALS['order']->totals, true) . PHP_EOL);
     case EO_DEBUG_ACTION_LEVEL > 1:
         eo_log('Final Tax (total): ' . $GLOBALS['order']->info['tax']);
         eo_log('Final Tax Groups:' . PHP_EOL . var_export($GLOBALS['order']->info['tax_groups'], true) . PHP_EOL);