Skip to content

Commit

Permalink
Merge pull request #29 from scottcwilson/show_shipping_location
Browse files Browse the repository at this point in the history
Show shipping state and country, see #30 for tracking.
  • Loading branch information
lat9 authored Mar 30, 2022
2 parents 5e7418e + 986a5d3 commit 76d8ac3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
9 changes: 8 additions & 1 deletion YOUR_ADMIN/includes/classes/sales_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,8 @@ function build_li_orders($oID, $field, $value)
// won't work for some customers' names, but will work for the majority.
//
$c_data = $GLOBALS['db']->Execute(
"SELECT customers_id, customers_name
"SELECT customers_id, customers_name,
delivery_country, delivery_state
FROM " . TABLE_ORDERS . "
WHERE orders_id = $oID
LIMIT 1"
Expand All @@ -627,6 +628,8 @@ function build_li_orders($oID, $field, $value)
$firstname = array_shift($pieces);
$this->timeframe[$id]['orders'][$oID]['first_name'] = zen_db_output($firstname);
$this->timeframe[$id]['orders'][$oID]['last_name'] = zen_db_output(implode(' ', $pieces));
$this->timeframe[$id]['orders'][$oID]['country'] = $c_data->fields['delivery_country'];
$this->timeframe[$id]['orders'][$oID]['state'] = $c_data->fields['delivery_state'];
}

// add the passed $value to the passed $field in the ['orders'] array
Expand Down Expand Up @@ -1003,6 +1006,8 @@ function output_csv($csv_header)
TABLE_HEADING_ORDERS_ID,
CSV_HEADING_LAST_NAME,
CSV_HEADING_FIRST_NAME,
CSV_HEADING_COUNTRY,
CSV_HEADING_STATE,
TABLE_HEADING_NUM_PRODUCTS,
TABLE_HEADING_TOTAL_GOODS
);
Expand Down Expand Up @@ -1152,6 +1157,8 @@ function output_csv($csv_header)
$o_data['oID'],
$o_data['last_name'],
$o_data['first_name'],
$o_data['country'],
$o_data['state'],
$o_data['num_products'],
$o_data['goods']
);
Expand Down
4 changes: 4 additions & 0 deletions YOUR_ADMIN/includes/languages/english/stats_sales_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@
// Order Line Items
define('TABLE_HEADING_ORDERS_ID', 'Order ID');
define('TABLE_HEADING_CUSTOMER', 'Customer');
define('TABLE_HEADING_COUNTRY', 'Country');
define('TABLE_HEADING_STATE', 'State');
define('TABLE_HEADING_ORDER_TOTAL', 'Order Total');
define('TABLE_HEADING_ORDER_TOTAL_VALIDATION', 'OT Valid');

Expand Down Expand Up @@ -236,6 +238,8 @@
define('CSV_HEADING_END_DATE', 'End Date');
define('CSV_HEADING_LAST_NAME', 'Last Name');
define('CSV_HEADING_FIRST_NAME', 'First Name');
define('CSV_HEADING_COUNTRY', 'Country');
define('CSV_HEADING_STATE', 'State');
define('CSV_SEPARATOR', ',');
define('CSV_NEWLINE', "\n");

Expand Down
13 changes: 12 additions & 1 deletion YOUR_ADMIN/stats_sales_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@
$payments->MoveNext();
}

$show_country_and_state = false;

// -----
// Build arrays for dropdowns in search menu
//
Expand Down Expand Up @@ -970,6 +972,11 @@ function init()
<tr class="lineItemHeadingRow">
<td class="lineItemHeadingContent"><?php echo TABLE_HEADING_ORDERS_ID . show_arrow('oID'); ?></td>
<td class="lineItemHeadingContent"><?php echo TABLE_HEADING_CUSTOMER . show_arrow('last_name'); ?></td>

<?php if ($show_country_and_state) { ?>
<td class="lineItemHeadingContent"><?php echo TABLE_HEADING_COUNTRY . show_arrow('country'); ?></td>
<td class="lineItemHeadingContent"><?php echo TABLE_HEADING_STATE . show_arrow('state'); ?></td>
<?php } ?>
<td class="lineItemHeadingContent center" colspan="2"><?php echo TABLE_HEADING_NUM_PRODUCTS . show_arrow('num_products'); ?></td>
<td class="lineItemHeadingContent right"><?php echo TABLE_HEADING_TOTAL_GOODS . show_arrow('goods'); ?></td>
<?php
Expand Down Expand Up @@ -1004,6 +1011,10 @@ function init()
<tr class="lineItemRow">
<td class="lineItemContent center"><strong><a href="<?php echo zen_href_link(FILENAME_ORDERS, 'oID=' . $o_data['oID'] . '&action=edit'); ?>"><?php echo $o_data['oID']; ?></a></strong></td>
<td class="lineItemContent"><?php echo $o_data['last_name'] . ', ' . $o_data['first_name']; ?></td>
<?php if ($show_country_and_state) { ?>
<td class="lineItemContent"><?php echo $o_data['country']; ?></td>
<td class="lineItemContent"><?php echo $o_data['state']; ?></td>
<?php } ?>
<td class="lineItemContent right"><?php echo $o_data['num_products']; ?></td>
<td class="lineItemContent no-wrap"><?php echo (sizeof($o_data['diff_products']) > 1 ? TEXT_DIFF . sizeof($o_data['diff_products']) : ($o_data['num_products'] > 1 ? TEXT_SAME : TEXT_SAME_ONE) ); ?></td>
<td class="lineItemContent right"><?php echo $currencies->format($o_data['goods']); ?></td>
Expand Down Expand Up @@ -1095,7 +1106,7 @@ function init()
<?php
}
?>
<td class="lineItemHeadingContent right"<?php echo TABLE_HEADING_PRODUCT_TOTAL . show_arrow('grand'); ?></td>
<td class="lineItemHeadingContent right"><?php echo TABLE_HEADING_PRODUCT_TOTAL . show_arrow('grand'); ?></td>
</tr>
<?php
foreach ($timeframe['products'] as $key => $p_data) {
Expand Down

0 comments on commit 76d8ac3

Please sign in to comment.