[I am trying to update a running ZC 151 install to ZC157C that has custom code that adds a field named “pak” to the order_products table. The original discussion about this is still on the forum as “Adding in Product Activation Key”, and also “How to detect if an order has been paid?”
Between the originator of this code being deceased and some of the ZC internals being reworked, I am struggling.
The ZC 151 code was added to ..includes/classes/order.php in the function Query to revise the $order_products_query (approx. line 164) to:
V151
$orders_products_query = "select orders_products_id, products_id, products_name,
………
products_discount_type_from, pak
$orders_products = $db->Execute($orders_products_query);
V157C
$orders_products_query = "SELECT *
FROM " . TABLE_ORDERS_PRODUCTS . "
$orders_products = $db->Execute($orders_products_query);
Question: It appears that since the added field is in the DB, and fetched in the query, pak doesn’t need to be explicitly named?
Further down into order.php in the function create_add_products
V151
$newPAK = $this->generate_product_key();
$this->notify('NOTIFY_ORDER_PROCESSING_STOCK_DECREMENT_END');
$sql_data_array = array('orders_id' => $zf_insert_id,
'products_id' => zen_get_prid($this->products[$i]['id']),
……………………
'pak' => $newPAK);
zen_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);
V157C
At about line 850 “ $sql_data_array” is created:
$sql_data_array = array('orders_id' => $zf_insert_id,
'products_id' => zen_get_prid($this->products[$i]['id']),
…………………….
products[$i]['products_mixed_discount_quantity'] );
zen_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);
Question: Is it permissible to add the code for updating pak on the DB to the end of the $sql_data_array with statement something like the following?
$sql_data_array = array('orders_id' => $zf_insert_id,
…………………….
products[$i]['products_mixed_discount_quantity'], );
'pak' => (int)$this->products[$i]['pak’]);
zen_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);
Bookmarks