VirtueMart Forum

VirtueMart 2 + 3 => General Questions => Topic started by: phil147 on August 31, 2019, 18:42:26 pm

Title: PHP Code to get users total spend
Post by: phil147 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

Title: Re: PHP Code to get users total spend
Post by: phil147 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);
Title: Re: PHP Code to get users total spend
Post by: Milbo 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.