Author: Adam Piotrowski (adam@wellcommerce.org)
Inheritance: extends WellCommerce\Bundle\DoctrineBundle\Entity\EntityInterface, extends Serializable, extends Symfony\Component\Security\Core\User\UserInterface, extends Symfony\Component\Security\Core\User\EquatableInterface, extends WellCommerce\Bundle\CoreBundle\Entity\TimestampableInterface, extends WellCommerce\Bundle\CoreBundle\Entity\BlameableInterface, extends WellCommerce\Bundle\ClientBundle\Entity\ClientGroupAwareInterface, extends WellCommerce\Bundle\ShopBundle\Entity\ShopAwareInterface
 /**
  * Returns client's discount
  *
  * @param null|ClientInterface $client
  *
  * @return float|int
  */
 protected function getDiscountForClient(ClientInterface $client = null)
 {
     if (null !== $client && null !== $client->getClientGroup()) {
         return round((double) $client->getClientGroup()->getDiscount() / 100, 2);
     }
     return 0;
 }
 public function resetPassword(ClientInterface $client)
 {
     $hash = base_convert(sha1(uniqid(mt_rand(), true)), 16, 36) . $client->getId();
     $client->getClientDetails()->setResetPasswordHash($hash);
     $client->getClientDetails()->setHashedPassword(Helper::generateRandomPassword(8));
     $this->updateResource($client);
 }
 /**
  * Calculates client's orders total value
  *
  * @param ClientInterface $client
  *
  * @return int|float
  */
 protected function calculateOrdersAmountForClient(ClientInterface $client)
 {
     $total = 0;
     $client->getOrders()->map(function (OrderInterface $order) use(&$total) {
         $total += $this->convertAmount($order);
     });
     return $total;
 }
 /**
  * Sends the reset instructions to client
  *
  * @param ClientInterface $client
  *
  * @return int
  */
 protected function sendResetInstructions(ClientInterface $client)
 {
     $email = $client->getContactDetails()->getEmail();
     $title = $this->getTranslatorHelper()->trans('client.email.title.reset_password');
     $body = $this->getTemplatingelper()->render('WellCommerceClientBundle:Email:reset_password.html.twig', ['client' => $client]);
     $shop = $client->getShop();
     return $this->getMailerHelper()->sendEmail($email, $title, $body, $shop->getMailerConfiguration());
 }
 /**
  * Copies the client's contact details to cart
  *
  * @param ClientInterface $client
  * @param CartInterface   $cart
  */
 protected function copyContactDetails(ClientInterface $client, CartInterface $cart)
 {
     $cart->setContactDetails($client->getContactDetails());
 }
 /**
  * Sends the reset instructions to client
  *
  * @param ClientInterface $client
  *
  * @return int
  */
 protected function sendResetInstructions(ClientInterface $client) : int
 {
     return $this->getMailerHelper()->sendEmail(['recipient' => $client->getContactDetails()->getEmail(), 'subject' => $this->getTranslatorHelper()->trans('client.email.heading.reset_password'), 'template' => 'WellCommerceAppBundle:Email:reset_password.html.twig', 'parameters' => ['client' => $client], 'configuration' => $client->getShop()]);
 }