diff --git a/plugins/woocommerce-admin/client/header/activity-panel/panels/orders.js b/plugins/woocommerce-admin/client/header/activity-panel/panels/orders.js
index 31d4bacb774..0651bfdf1ab 100644
--- a/plugins/woocommerce-admin/client/header/activity-panel/panels/orders.js
+++ b/plugins/woocommerce-admin/client/header/activity-panel/panels/orders.js
@@ -24,7 +24,7 @@ import {
Section,
} from '@woocommerce/components';
import { formatCurrency, getCurrencyFormatDecimal } from '@woocommerce/currency';
-import { getAdminLink } from '@woocommerce/navigation';
+import { getAdminLink, getNewPath } from '@woocommerce/navigation';
/**
* Internal dependencies
@@ -32,7 +32,6 @@ import { getAdminLink } from '@woocommerce/navigation';
import { ActivityCard, ActivityCardPlaceholder } from '../activity-card';
import ActivityHeader from '../activity-header';
import ActivityOutboundLink from '../activity-outbound-link';
-import { getOrderRefundTotal } from 'lib/order-values';
import { QUERY_DEFAULTS } from 'wc-api/constants';
import withSelect from 'wc-api/with-select';
@@ -64,28 +63,56 @@ function OrdersPanel( { orders, isRequesting, isError } ) {
);
- const orderCardTitle = ( order, address ) => {
- const name = `${ address.first_name } ${ address.last_name }`;
+ const getCustomerString = order => {
+ const extended_info = order.extended_info || {};
+ const { first_name, last_name } = extended_info.customer || {};
+
+ if ( ! first_name && ! last_name ) {
+ return '';
+ }
+
+ const name = [ first_name, last_name ].join( ' ' );
+ return sprintf(
+ __(
+ /* translators: describes who placed an order, e.g. Order #123 placed by John Doe */
+ 'placed by {{customerLink}}%(customerName)s{{/customerLink}}',
+ 'wc-admin'
+ ),
+ {
+ customerName: name,
+ }
+ );
+ };
+
+ const orderCardTitle = order => {
+ const { extended_info, order_id } = order;
+ const { customer } = extended_info || {};
+ const customerUrl = customer.customer_id
+ ? getNewPath( {}, '/analytics/customers', {
+ filter: 'single_customer',
+ customer_id: customer.customer_id,
+ } )
+ : null;
return (
{ interpolateComponents( {
mixedString: sprintf(
__(
- /* eslint-disable-next-line max-len */
- 'Order {{orderLink}}#%(orderNumber)s{{/orderLink}} placed by {{customerLink}}%(customerName)s{{/customerLink}} {{destinationFlag/}}',
+ 'Order {{orderLink}}#%(orderNumber)s{{/orderLink}} %(customerString)s {{destinationFlag/}}',
'wc-admin'
),
{
- orderNumber: order.number,
- customerName: name,
+ orderNumber: order_id,
+ customerString: getCustomerString( order ),
}
),
components: {
- orderLink: ,
- // @todo Hook up customer name link
- customerLink: ,
- destinationFlag: ,
+ orderLink: ,
+ destinationFlag: customer.country ? (
+
+ ) : null,
+ customerLink: customerUrl ? : ,
},
} ) }
@@ -93,20 +120,20 @@ function OrdersPanel( { orders, isRequesting, isError } ) {
};
const cards = [];
- orders.forEach( ( order, id ) => {
- // We want the billing address, but shipping can be used as a fallback.
- const address = { ...order.shipping, ...order.billing };
- const productsCount = order.line_items.reduce( ( total, line ) => total + line.quantity, 0 );
+ orders.forEach( order => {
+ const extended_info = order.extended_info || {};
+ const productsCount =
+ extended_info && extended_info.products ? extended_info.products.length : 0;
- const total = order.total;
- const refundValue = getOrderRefundTotal( order );
- const remainingTotal = getCurrencyFormatDecimal( order.total ) + refundValue;
+ const total = order.gross_total;
+ const refundValue = order.refund_total;
+ const remainingTotal = getCurrencyFormatDecimal( total ) + refundValue;
cards.push(
@@ -118,16 +145,15 @@ function OrdersPanel( { orders, isRequesting, isError } ) {
{ refundValue ? (
- { formatCurrency( total, order.currency_symbol ) }{' '}
- { formatCurrency( remainingTotal, order.currency_symbol ) }
+ { formatCurrency( total ) } { formatCurrency( remainingTotal ) }
) : (
- { formatCurrency( total, order.currency_symbol ) }
+ { formatCurrency( total ) }
) }
}
actions={
-