Results 1 to 1 of 1
  1. #1
    Join Date
    Feb 2005
    Posts
    11
    Plugin Contributions
    0

    Edit Order Upgrade

    Hi,

    Just upgraded from v1.2.4 to v1.3.0.2. I need the use the module edit_order contribution which was available for v1.2.4. I added this module in, did some changes, all working except the order total. It is giving me S$0 always. So for v1.3.0.2, what changes are made in the way they calculate the total?

    The way they calculate order total is attached, the edited module is also attached.

    // Update Products
    $RunningSubTotal = 0;
    $RunningTax = 0;
    $update_products = $_POST['update_products'];
    foreach($update_products as $orders_products_id => $products_details)
    {
    // Update orders_products Table
    //UPDATE_INVENTORY_QUANTITY_START################################################# #############################################################
    #$order = zen_db_fetch_array($order_query);
    if ($products_details["qty"] != $order_query->fields['products_quantity']){
    $differenza_quantita = ($products_details["qty"] - $order_query->fields['products_quantity']);
    $db -> Execute("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity - " . $differenza_quantita . ", products_ordered = products_ordered + " . $differenza_quantita . " where products_id = '" . (int)$order_query->fields['products_id'] . "'");
    }
    //UPDATE_INVENTORY_QUANTITY_END################################################### ###########################################################
    if($products_details["qty"] > 0)
    {
    $Query = "update " . TABLE_ORDERS_PRODUCTS . " set
    products_model = '" . $products_details["model"] . "',
    products_name = '" . str_replace("'", "'", $products_details["name"]) . "',
    final_price = '" . $products_details["final_price"] . "',
    products_tax = '" . $products_details["tax"] . "',
    products_quantity = '" . $products_details["qty"] . "'
    where orders_products_id = '$orders_products_id';";
    $db -> Execute($Query);

    // Update Tax and Subtotals
    $RunningSubTotal += $products_details["qty"] * $products_details["final_price"];
    $RunningTax += (($products_details["tax"]/100) * ($products_details["qty"] * $products_details["final_price"]));

    // Update Any Attributes
    if(IsSet($products_details[attributes]))
    {
    foreach($products_details["attributes"] as $orders_products_attributes_id => $attributes_details)
    {
    $Query = "update " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " set
    products_options = '" . $attributes_details["option"] . "',
    products_options_values = '" . $attributes_details["value"] . "'
    where orders_products_attributes_id = '$orders_products_attributes_id';";
    $db -> Execute($Query);
    }
    }
    }
    else
    {
    // 0 Quantity = Delete
    $Query = "delete from " . TABLE_ORDERS_PRODUCTS . " where orders_products_id = '$orders_products_id';";
    $db -> Execute($Query);
    //UPDATE_INVENTORY_QUANTITY_START################################################# #############################################################
    #$order = zen_db_fetch_array($order_query);
    if ($products_details["qty"] != $order['products_quantity']){
    $differenza_quantita = ($products_details["qty"] - $order['products_quantity']);
    $db -> Execute("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity - " . $differenza_quantita . ", products_ordered = products_ordered + " . $differenza_quantita . " where products_id = '" . (int)$order['products_id'] . "'");
    }
    //UPDATE_INVENTORY_QUANTITY_END################################################### ###########################################################
    $Query = "delete from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_products_id = '$orders_products_id';";
    $db -> Execute($Query);
    }
    $order_query -> MoveNext();
    }

    // Shipping Tax
    $update_totals = $_POST['update_totals'];
    foreach($update_totals as $total_index => $total_details)
    {
    extract($total_details,EXTR_PREFIX_ALL,"ot");
    if($ot_class == "ot_shipping")
    {
    $RunningTax += (($AddShippingTax / 100) * $ot_value);
    }
    }

    // Update Totals

    $RunningTotal = 0;
    $sort_order = 0;

    // Do pre-check for Tax field existence
    $ot_tax_found = 0;
    foreach($update_totals as $total_details)
    {
    extract($total_details,EXTR_PREFIX_ALL,"ot");
    if($ot_class == "ot_tax")
    {
    $ot_tax_found = 1;
    break;
    }
    }

    foreach($update_totals as $total_index => $total_details)
    {
    extract($total_details,EXTR_PREFIX_ALL,"ot");

    if( trim(strtolower($ot_title)) == "tax" || trim(strtolower($ot_title)) == "tax:" )
    {
    if($ot_class != "ot_tax" && $ot_tax_found == 0)
    {
    // Inserting Tax
    $ot_class = "ot_tax";
    $ot_value = "x"; // This gets updated in the next step
    $ot_tax_found = 1;
    }
    }

    if( trim($ot_title) && trim($ot_value) )
    {
    $sort_order++;

    // Update ot_subtotal, ot_tax, and ot_total classes
    if($ot_class == "ot_subtotal")
    $ot_value = $RunningSubTotal;

    if($ot_class == "ot_tax")
    {
    $ot_value = $RunningTax;
    // print "ot_value = $ot_value<br>\n";
    }

    if($ot_class == "ot_total")
    $ot_value = $RunningTotal;

    // Set $ot_text (display-formatted value)
    // $ot_text = "\$" . number_format($ot_value, 2, '.', ',');

    $order = new order($oID);
    $ot_text = $currencies->format($ot_value, true, $order->info['currency'], $order->info['currency_value']);

    if($ot_class == "ot_total")
    $ot_text = "<b>" . $ot_text . "</b>";

    if($ot_total_id > 0)
    {
    // In Database Already - Update
    $Query = "update " . TABLE_ORDERS_TOTAL . " set
    title = '$ot_title',
    text = '$ot_text',
    value = '$ot_value',
    sort_order = '$sort_order'
    where orders_total_id = '$ot_total_id'";
    $db -> Execute($Query);
    }
    else
    {

    // New Insert
    $Query = "insert into " . TABLE_ORDERS_TOTAL . " set
    orders_id = '$oID',
    title = '$ot_title',
    text = '$ot_text',
    value = '$ot_value',
    class = '$ot_class',
    sort_order = '$sort_order'";
    $db -> Execute($Query);
    }

    $RunningTotal += $ot_value;
    }
    elseif($ot_total_id > 0)
    {
    // Delete Total Piece
    $Query = "delete from " . TABLE_ORDERS_TOTAL . " where orders_total_id = '$ot_total_id'";
    $db -> Execute($Query);
    }

    }

    if ($order_updated)
    {
    $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success');
    }

    zen_redirect(zen_href_link("edit_orders.php", zen_get_all_get_params(array('action')) . 'action=edit'));


    Regards,
    Yee Ling
    http://www.whoopeekiddies.com
    Attached Files Attached Files

 

 

Similar Threads

  1. Replies: 2
    Last Post: 8 Apr 2015, 01:23 PM
  2. v154 Edit order (orders.php) is blank after upgrade from 1.3.9h to 1.5.4
    By gti_suzuki in forum Upgrading to 1.5.x
    Replies: 11
    Last Post: 16 Feb 2015, 05:45 PM
  3. Product edit problem after upgrade to 1.3.9h
    By johnbendall in forum Upgrading from 1.3.x to 1.3.9
    Replies: 4
    Last Post: 11 Dec 2012, 02:25 AM
  4. How do I Edit Order of Order Totals in Order Confirmation Email?
    By toussi in forum Managing Customers and Orders
    Replies: 1
    Last Post: 20 Mar 2009, 08:05 AM
  5. RFQ/ Super Order help charging client after i edit the order
    By nycdan in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 2 Feb 2008, 09:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg