public function init() { if ($this->isInitialized) { return; } $this->isInitialized = true; if ($this->config->get('CHECKOUT_METHOD') == 'CHECKOUT_MULTISTEP') { return new ActionRedirectResponse('checkout', 'index'); } $this->isTosRequired = $this->config->get('REQUIRE_TOS'); parent::init(); $this->config->setRuntime('CHECKOUT_CUSTOM_FIELDS', self::CUSTOM_FIELDS_STEP); $this->config->setRuntime('ENABLE_CHECKOUTDELIVERYSTEP', true); $this->config->setRuntime('DISABLE_CHECKOUT_ADDRESS_STEP', false); $this->config->setRuntime('DISABLE_GUEST_CHECKOUT', false); $this->config->setRuntime('ENABLE_SHIPPING_ESTIMATE', false); $this->config->setRuntime('SKIP_SHIPPING', false); $this->config->setRuntime('SKIP_PAYMENT', false); $this->config->setRuntime('REG_EMAIL_CONFIRM', false); $this->config->setRuntime('EMAIL_NEW_USER', false); $this->config->setRuntime('REQUIRE_TOS', false); $this->loadLanguageFile('Order'); $this->loadLanguageFile('User'); $this->order->loadSpecification(); ActiveRecordModel::loadEav(); if ($this->user->isAnonymous()) { if ($this->session->get('checkoutUser')) { $checkoutUser = unserialize($this->session->get('checkoutUser')); $checkoutUser->setID(null); SessionUser::setUser($checkoutUser); if ($this->user !== $checkoutUser && $checkoutUser instanceof User) { $this->user = $checkoutUser; } } $this->user->grantAccess('login'); $this->setAnonAddresses(); $this->order->user->set($this->user); $this->order->shippingAddress->resetModifiedStatus(); $this->order->billingAddress->resetModifiedStatus(); $this->order->user->resetModifiedStatus(); } else { $this->user->load(); $this->user->loadAddresses(); $address = $this->user->defaultShippingAddress->get(); if (!$address) { $address = $this->user->defaultBillingAddress->get(); } if (!$this->order->shippingAddress->get() && $address && $this->isShippingRequired($this->order)) { $userAddress = $address->userAddress->get(); $this->order->shippingAddress->set($userAddress); $this->order->save(); } $address = $this->user->defaultBillingAddress->get(); if (!$this->order->billingAddress->get() && $address) { $userAddress = $address->userAddress->get(); $this->order->billingAddress->set($userAddress); $this->order->save(); } } }