misscotton:
Hi - i am hoping you can help me here. I am modifying this add on to include a "Product Cost" column to the report. I have it working except I can't quite figure out how I take the value and place it into the new column I created. It is essentially making the same query to the db as what is used for filling the "Products Atrributes" column only I don't need to format the multiple attribute options, i.e. like below where the field I am pulling out of the db is "options_values_price_w":
$product_attributes_rows="SELECT Count(*) as num_rows
FROM " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . "
WHERE orders_id = " . $order_details->fields['orders_id'] . "
AND orders_products_id = " . $order_details->fields['orders_products_id'] . "";
$attributes_query_rows = $db->Execute($product_attributes_rows);
$num_rows = $attributes_query_rows->fields['num_rows'];
If ( $num_rows > 0) {
$product_attributes_query="SELECT *
FROM " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . "
WHERE orders_id = " . $order_details->fields['orders_id'] . "
AND orders_products_id = " . $order_details->fields['orders_products_id'] . "";
$attributes_query_results = $db->Execute($product_attributes_query);
$str_export = $str_export . "\"";
for ($i = 0, $n = $num_rows; $i < $n; $i++) {
$str_export = $str_export . $attributes_query_results->fields['options_values_price_w'] .
$attributes_query_results->MoveNext();
}
$str_export = $str_export . "\"";
}
>
> If I replace this code with what is used to fill the "Product Attributes" column it shows the cost value properly. But I would like both columns displayed - "Products Attributes" and "Product Cost". I added the name of the column successfully like below, but don't know what would make the data go into that column:
> ```
if ($_POST['product_details'] == 1) { // add to header row
if ($_POST['filelayout'] == 2) { // 1 Product Per row RADIO
$str_header = $str_header . ",Product Qty,Products Price,Product Name,Product Model,Product Attributes,Product Cost";
} else { // File layout is 1 OPR
/**************the following exports 1 OPR attribs****************/
$oID = zen_db_prepare_input($order_details->fields['orders_id']);
$oIDME = $order_details->fields['orders_id'];
$order = new order($oID);
for ($i = 0, $n = $max_products; $i < $n; $i++) {
$str_header = $str_header . ",Product " . $i . " Qty";
$str_header = $str_header . ",Product " . $i . " Price";
$str_header = $str_header . ",Product " . $i . " Name";
$str_header = $str_header . ",Product " . $i . " Model";
$str_header = $str_header . ",Product " . $i . " Attributes";
$str_header = $str_header . ",Product " . $i . " Cost";
}
/*****************************************************************/
} // End if to determine which header to use
} // end Row header if product details selected
hope that makes sense - I feel like I am really close to figuring it out, but I am kinda crash coursing learning db and php coding to make this work..any help would be appreciated....thanks
In order to get that to work and keep your current setup correct you'll need to ad a few items.
-
add a new header row column for that new field and don't forget to only show that IF the user chose that option otherwise it will through off the export.
-
Add the exported data to two sections in the program. (a) the section that exports data "one order per row" and (b) to the section that exports data "one product per row".
-
You'll also need to update the query itself to pull that extra field in order to have the "data" to put into the export.
Make a backup file of your current working copy before you change anything so you have a working version.
So you're looking at a number of edit areas to get it to work.