marcot Posted February 7, 2009 Posted February 7, 2009 This code is from the contribution: http://www.oscommerce.com/community/contributions,3643/ $orders_query = tep_db_query("select * from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'"); if(mysql_num_rows($orders_query)) { $orders_array = tep_db_fetch_array($orders_query); // orders_id für auto_insert löschen $orders_array['orders_id'] = ''; //only if you have orders_type (offer, redemp, order,invoice,packingslip) installed // $orders_array['orders_type'] = 'A'; $werte = implode("','",$orders_array); // Insert Abfrage $insert_query = tep_db_query("INSERT INTO " . TABLE_ORDERS . " VALUES ('" . $werte . "')"); //neue orders_id feststellen $insert_id = tep_db_insert_id(); // orders_products abfragen $orders_products_query = tep_db_query("select * from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$oID . "'"); $cnt_inserts=0; while ($orders_products = tep_db_fetch_array($orders_products_query)) { $orders_products['orders_products_id'] = ''; $orders_products['orders_id'] = $insert_id; $werte = implode("','",$orders_products); $insert_products_query = tep_db_query("INSERT INTO " . TABLE_ORDERS_PRODUCTS . " VALUES ('" . $werte . "')"); $i_id[$cnt_inserts] = tep_db_insert_id(); $cnt_inserts++; } $orders_products_a_query = tep_db_query("select * from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$oID . "'"); $cnt_inserts=0; while ($orders_products_a = tep_db_fetch_array($orders_products_a_query)) { $orders_products_a['orders_products_attributes_id'] = ''; $orders_products_a['orders_id'] = $insert_id; $orders_products_a['orders_products_id'] = $i_id[$cnt_inserts]; $werte = implode("','",$orders_products_a); $insert_products_query = tep_db_query("INSERT INTO " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " VALUES ('" . $werte . "')"); $cnt_inserts++; } I'm having te problem that the attributes are not updated in db correctly. the problem seems te be inside this line: $orders_products_a['orders_products_id'] = $i_id[$cnt_inserts]; It's the the function thats copying the attributes to the new copied order For example i have order 507 this order has to products 706 and 707 See image: As you can see te product 706 has one option, this script copy's the product okay, without problems so far, Product 707 has 7 options al with number 707 inside orders_products_id NOW if we use the above script if i copy order 507 a new order is created in this example order 554 The 2 products are inside the new created order with the options 875 (correct) and 876 (only one) all the rest is 0 ?! But all these needs to be 876. see image: Who can help me ! please...
marcot Posted February 23, 2009 Author Posted February 23, 2009 Nobody who knows anything about this issue ??. :blush:
Recommended Posts
Archived
This topic is now archived and is closed to further replies.