Jump to content

Display nb of orders on my-account


eagleman

Recommended Posts

Hello

can you please help me with this issue, I need to display the total of orders on the client area section 

 

like 

{$orders_count} placed

$this->context->smarty->assign(array(

           

            'totalorders' => $totalorders,

     ));

 $this->setTemplate('customer/my-account');

Regards

 

 

Link to comment
Share on other sites

Hi @eagleman,

for these two variables to be included into the \themes\YOURTHEME\templates\customer\my-account.tpl , you should create an override: override\controllers\front\MyAccountController.php and at this code to it:

<?php
class MyAccountController extends MyAccountControllerCore
{
    public function initContent()
    {
        $orders_count = Order::getCustomerNbOrders($this->context->customer->id);
        $totalorders = Order::getCustomerOrders($this->context->customer->id);
        $this->context->smarty->assign(
            [
                'orders_count'=> $orders_count,
                'totalorders'=> $totalorders
            ]
        );
        parent::initContent();
    }
}

Then clear cache and you can use these variables in your template:{$orders_count} and {$totalorders|dump}

I hope that I could help.
Have a nice day, Leo.
 

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...