Totally Zenned
- Join Date:
- Aug 2004
- Posts:
- 732
- Plugin Contributions:
- 0
How To Update New Orders_Products Field?
I recently added a new field to the zen_products and zen_orders_products tables called "Products_Secondary_Model". My goal is to have the zen_orders_products table updated with this field after an order is placed, just as it gets updated with the regular products_model field by default.
I cannot see where this information gets updated into the Zen_Order_Products table (or if I do, then I cannot get my value to stick). The only thing I can find is in the order.php file (located in includes/classes/), where it says this:
$sql_data_array = array('orders_id' => $zf_insert_id,
'products_id' => zen_get_prid($this->products[$i]['id']),
'products_model' => $this->products[$i]['model'],
'products_secondary_model' => $this->products[$i]['secondary_model'],
'products_name' => $this->products[$i]['name'],
'products_price' => $this->products[$i]['price'],
'final_price' => $this->products[$i]['final_price'],
'onetime_charges' => $this->products[$i]['onetime_charges'],
'products_tax' => $this->products[$i]['tax'],
'products_quantity' => $this->products[$i]['qty'],
'products_priced_by_attribute' => $this->products[$i]['products_priced_by_attribute'],
'product_is_free' => $this->products[$i]['product_is_free'],
'products_discount_type' => $this->products[$i]['products_discount_type'],
'products_discount_type_from' => $this->products[$i]['products_discount_type_from'],
'products_prid' => $this->products[$i]['id']);
zen_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);
As you can see above, I added a "products_secondary_model" field, but when the order is placed, this value is empty in the zen_orders_products table. However, this value does exist in my regular zen_products table where I have defined a secondary model field and placed values in there.
Flow I need: Exists in zen_products --> customer purchases item --> put this new field value from zen_products into zen_orders_products
So my question is, where in the code does the orders_products table get updated where I can insert my products_secondary_model value which exists in the products table? This should mimic exactly what happens when the regular model number gets updated into this table during a normal order checkout.
(I am using the latest version of ZenCart).