function eo_remove_product_from_order($order_id, $orders_products_id) { global $db, $order; // First grab the order <==> product mappings $orders_products_id_mapping = eo_get_orders_products_id_mappings((int) $order_id); // Handle product stock if (STOCK_LIMITED == 'true') { $query = $db->Execute('SELECT `products_id`, `products_quantity` ' . 'FROM `' . TABLE_ORDERS_PRODUCTS . '` ' . 'WHERE `orders_id`=\'' . (int) $order_id . '\' ' . 'AND `orders_products_id`=\'' . (int) $orders_products_id . '\''); while (!$query->EOF) { if (DOWNLOAD_ENABLED == 'true') { $check = $db->Execute('SELECT `p`.`products_quantity`, `pad`.`products_attributes_filename`, `p`.`product_is_always_free_shipping` ' . 'FROM `' . TABLE_PRODUCTS . '` AS `p` ' . 'LEFT JOIN `' . TABLE_PRODUCTS_ATTRIBUTES . '` AS `pa` ON `p`.`products_id`=`pa`.`products_id` ' . 'LEFT JOIN `' . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . '` AS `pad` ON `pa`.`products_attributes_id`=`pad`.`products_attributes_id` ' . 'WHERE `p`.`products_id` = \'' . (int) $query->fields['products_id'] . '\''); } else { $check = $db->Execute('SELECT `p`.`products_quantity` FROM `' . TABLE_PRODUCTS . '` AS `p` ' . 'WHERE `p`.`products_id` = \'' . (int) $query->fields['products_id'] . '\''); } if (!$check->EOF && (DOWNLOAD_ENABLED != 'true' || $check->fields['product_is_always_free_shipping'] == 2 || !$check->fields['products_attributes_filename'])) { $sql_data_array = array('products_quantity' => $check->fields['products_quantity'] + $query->fields['products_quantity'], 'products_ordered' => $check->fields['products_ordered'] - $query->fields['products_quantity']); if ($sql_data_array['products_ordered'] < 0) { $sql_data_array['products_ordered'] = 0; } if ($sql_data_array['products_quantity'] > 0) { // Only set status to on when not displaying sold out if (SHOW_PRODUCTS_SOLD_OUT == '0') { $sql_data_array['products_status'] = 1; } } zen_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', 'products_id = \'' . (int) $query->fields['products_id'] . '\''); } $query->MoveNext(); } unset($check, $query, $sql_data_array); } // Remove the product from the order in the database $remove_query = 'DELETE FROM `%1$s` ' . 'WHERE `orders_id`=\'' . (int) $order_id . '\' ' . 'AND `orders_products_id`=\'' . (int) $orders_products_id . '\''; $db->Execute(sprintf($remove_query, TABLE_ORDERS_PRODUCTS)); $db->Execute(sprintf($remove_query, TABLE_ORDERS_PRODUCTS_ATTRIBUTES)); $db->Execute(sprintf($remove_query, TABLE_ORDERS_PRODUCTS_DOWNLOAD)); unset($remove_query); // Hande the internal products array for ($i = 0; $i < sizeof($order->products); $i++) { if ($orders_products_id == $orders_products_id_mapping[$i]) { // Remove from the product from the array unset($order->products[$i]); // rekey the array (so for loops work) $order->products = array_values($order->products); break; } } }
echo TABLE_HEADING_TAX; ?> </td> <td class="dataTableHeadingContent" align="right" width="10%"><?php echo TABLE_HEADING_UNIT_PRICE; ?> </td> <td class="dataTableHeadingContent" align="right" width="10%"><?php echo TABLE_HEADING_TOTAL_PRICE; ?> </td> </tr> <!-- Begin Products Listings Block --> <?php $orders_products_id_mapping = eo_get_orders_products_id_mappings((int) $oID); for ($i = 0; $i < sizeof($order->products); $i++) { $orders_products_id = $orders_products_id_mapping[$i]; if (EO_DEBUG_ACTION_LEVEL > 3) { eo_log(PHP_EOL . '============================================================' . PHP_EOL . '= Creating display of Order Product #' . $orders_products_id . PHP_EOL . '============================================================' . PHP_EOL . 'Product Details:' . PHP_EOL . var_export($order->products[$i], true) . PHP_EOL); } ?> <tr class="dataTableRow"> <td class="dataTableContent" valign="top" align="left"><input name="update_products[<?php echo $orders_products_id; ?> ][qty]" size="2" value="<?php echo zen_db_prepare_input($order->products[$i]['qty']); ?> " /> X</td>