Skip to content

Commit

Permalink
fix: add password to customer and set currency to the order
Browse files Browse the repository at this point in the history
  • Loading branch information
VivienCormier committed Mar 16, 2023
1 parent 20f3adc commit 107ac4a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bienoubien.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct()
{
$this->name = 'bienoubien';
$this->tab = 'merchandizing';
$this->version = '1.0.10';
$this->version = '1.0.11';
$this->author = 'Binshops';
$this->need_instance = 0;

Expand Down
24 changes: 18 additions & 6 deletions controllers/front/createorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,21 @@ protected function processPostRequest()
* step 1
* create customer
*/
$password = 'bienoubien';
$customer = new Customer();
$authentication = $customer->getByEmail(
$this->_customer['email'],
$password
);
if ($authentication && $customer->id) {
$this->ajaxRender(json_encode([
'success' => false,
'code' => 303,
'psdata' => [],
'message' => 'Customer already created'
]));
die;
}
$guestAllowedCheckout = Configuration::get('PS_GUEST_CHECKOUT_ENABLED');
$customerPresister = new CustomerPersister(
$this->context,
Expand All @@ -90,11 +105,8 @@ protected function processPostRequest()
$customer->email = $this->_customer['email'];
$customer->firstname = $this->_customer['first_name'];
$customer->lastname = $this->_customer['last_name'];

$customer->note = $this->_note;

// for later use we can fill password here
$password = '';
$password = 'bienoubien';

$psdata['registered'] = $customerPresister->save($customer, $password);

Expand Down Expand Up @@ -320,10 +332,10 @@ protected function processPostRequest()
]));
die;
}

$this->module->validateOrder($cart->id, Configuration::get('PS_OS_PAYMENT'), $total, $this->module->displayName, NULL, $mailVars, (int)$this->context->currency->id, false, $customer->secure_key);
$this->module->validateOrder($cart->id, Configuration::get('PS_OS_PAYMENT'), $total, $this->module->displayName, NULL, $mailVars, $cart->id_currency, false, $customer->secure_key);

$order = new Order($cart->id);
$order->id_currency = $cart->id_currency;
$order_to_display = (new OrderPresenter())->present($order);

$psdata['order_details'] = $order_to_display;
Expand Down

0 comments on commit 107ac4a

Please sign in to comment.