Author Topic: PHP Code to get users total spend  (Read 260 times)

phil147

  • Beginner
  • *
  • Posts: 9
  • A beginner
PHP Code to get users total spend
« on: August 31, 2019, 18:42:26 pm »
Hi,

I have searched for hours for help on this, I want to get the total of logged in users spend so I can allocate a coupon amount based on total.

for example, when logged in the information is available on the /order-history page , but I want to access the object from the login page /log-in

I will be placing the code in html/com_vm/user/login3.php file

I want to assign the total amount to a var within the log-in page

I need a line of code similar to $orderModel = VmModel::getModel('orders');


Thanks for reading,
Phil

Using VM 3.2 12
Joomla 3.9 11


phil147

  • Beginner
  • *
  • Posts: 9
  • A beginner
Re: PHP Code to get users total spend
« Reply #1 on: September 03, 2019, 11:48:32 am »

Hello,

eventually (after 4 days searching) found the answer in the view.html file within vm/views/user folder

I placed the code in the login file, so I'm able to access logged in users history etc

see below, might save someone heartache

// Check for existing orders for this user
               
$orders = VmModel::getModel('orders');

$orderList = $orders->getOrdersList($userDetails);

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9973
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: PHP Code to get users total spend
« Reply #2 on: September 04, 2019, 21:50:02 pm »
in the new core is a function for order count, it is quite easy to rewrite it for the totals.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/