diff --git a/src/templates/widgets/TopCustomers/body.twig b/src/templates/widgets/TopCustomers/body.twig index 76475a1..4b4f678 100755 --- a/src/templates/widgets/TopCustomers/body.twig +++ b/src/templates/widgets/TopCustomers/body.twig @@ -14,7 +14,6 @@ {% for customer in customers %} - {% set userId = craft.commercewidgets.userIdByCustomerId(customer.customerId).userId %} @@ -26,13 +25,9 @@ - {% if userId|length %} - - {{ customer.email }} - - {% else %} - {{ customer.email }} - {% endif %} + + {{ customer.email }} + {{ customer.totalRevenue|currency(commerce.currency) }} {{ customer.totalOrders|number_format() }} diff --git a/src/widgets/ProductsTop.php b/src/widgets/ProductsTop.php index c255b1a..c1760e8 100644 --- a/src/widgets/ProductsTop.php +++ b/src/widgets/ProductsTop.php @@ -52,8 +52,8 @@ public function getProducts() ) ->select( [ - 'variants.productId as id', - 'variants.sku as sku', + 'variants.primaryOwnerId as id', + 'purchasables.sku as sku', 'SUM(items.total) as totalRevenue', 'count(*) as totalOrdered', ] @@ -69,7 +69,7 @@ public function getProducts() 'LEFT JOIN', '{{%commerce_orders}} orders', 'orders.id = items.orderId' ) ->join( - 'LEFT JOIN', '{{%elements}} elements', 'elements.id = variants.productId' + 'LEFT JOIN', '{{%elements}} elements', 'elements.id = variants.primaryOwnerId' ) ->where(['elements.dateDeleted' => null]) ->andWhere(['orders.isCompleted' => 1]) @@ -81,7 +81,7 @@ public function getProducts() { $query ->andWhere(['orders.orderStatusId' => $this->orderStatusId]) - ->andWhere(['not', ['variants.productId' => null]]); + ->andWhere(['not', ['variants.primaryOwnerId' => null]]); } $result = $query->cache(CommerceWidgets::$plugin->getSettings()->cacheDuration)->all();