Classes
Since My Account is intended exclusively for processing personal data of the current customer, the controller operates in conjunction with a class-model Customer. This model handles not only such properties as Lastname, Firstname, Email and others, but also such as a set of groups of the current customer and addresses (shipping, billing). The following main methods interact with these properties:
1 2 3 4 |
Customer:: addGroups($groups); //adds new groups to a customer, which are transmitted through the array $groups. The groups are managed by the Group class. Customer:: getAddresses($id_lang); //gets a list of all customer's addresses. The addresses are managed by the Addresses class. Customer:: getAddressesTotalById($id_customer); //number of addresses created by a customer Customer:: getCurrentCountry($id_customer, Cart $cart = null); //gets the current customer country location |
Settings
Settings are configured under the “Preferences -> Customers” menu section which is located in the administration section of the store.
Controllers
My Account main page.
It is generated by the controller MyAссоuntCоntrоller:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
class MyAccountControllerCore extends FrontController { public $auth = true; public $php_self = 'my-account'; public $authRedirection = 'my-account'; public $ssl = true; public function setMedia() { parent::setMedia(); $this->addCSS(_THEME_CSS_DIR_.'my-account.css'); } /** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $has_address = $this->context->customer->getAddresses($this->context->language->id); $this->context->smarty->assign(array( 'has_customer_an_address' => empty($has_address), 'voucherAllowed' => (int)CartRule::isFeatureActive(), 'returnAllowed' => (int)Configuration::get('PS_ORDER_RETURN') )); $this->context->smarty->assign('HOOK_CUSTOMER_ACCOUNT', Hook::exec('displayCustomerAccount')); $this->setTemplate(_PS_THEME_DIR_.'my-account.tpl'); } } |
As seen from the piece of code above, the page uses the template my-account.tpl .
From this page you can follow down 5 links:
- Order history and details. This page is responsible for the complete order history. It is generated by the controller HistoryController.
- My credit slips. A “credit slip” is given to the customer when he’s returned a product. Controller – OrderSlipCоntrоller.
- My addresses. Managing customer addresses.Controller – AddressCоntrоller.
- My personal information. Managing personal information.
- My favorite products. The module My Favorite Products.
If a customer is not logged in, he will be redirected to the controller AuthCоntrоller.
The method Context::getContext()->customer->isLogged() can help you to verify if a customer is logged in.
Hooks
To display additional link in My Account, you can use the hook displаyCustоmerAссоunt.
The hook displayMyAccountBlock is used to output data into the block My Account. This block is located in the site’s footer.