protected function processForm() { // get a product collection (aka cart) global $objPage; $objCart = new Cart(); // Can't call the individual rows here, it would trigger markModified and a save() $objCart->setRow(array_merge($objCart->row(), array('tstamp' => time(), 'member' => 0, 'uniqid' => null, 'config_id' => $this->iso_config_id, 'store_id' => (int) \PageModel::findByPk($objPage->rootId)->iso_store_id))); $objSubmission = $this->getSubmission(false); // add products to cart foreach ($this->arrProducts as $arrProduct) { $strProduct = 'product_' . $arrProduct['product']->id; $strQuantity = 'quantity_' . $arrProduct['product']->id; if (($this->getProductCount() > 1 || $this->getTypeCount() > 1) && !$objSubmission->{$strProduct}) { continue; } if (!$objCart->addProduct($arrProduct['product'], $arrProduct['useQuantity'] ? $objSubmission->{$strQuantity} : 1)) { $this->transformIsotopeErrorMessages(); return; } } $objCart->save(); $objOrder = $objCart->getDraftOrder(); // temporarily override the cart for generating the reviews... $objCartTmp = Isotope::getCart(); Isotope::setCart($objCart); // create steps $arrSteps = array(); $arrCheckoutInfo = array(); // billing address $objBillingAddress = new Address(); foreach ($this->arrBillingAddressFields as $strName) { $objBillingAddress->{$strName} = $objSubmission->{$strName}; } $objBillingAddress->save(); $objOrder->setBillingAddress($objBillingAddress); $objBillingAddressStep = new BillingAddress($this->objCheckoutModule); $arrSteps[] = $objBillingAddressStep; $arrCheckoutInfo['billing_address'] = $objBillingAddressStep->review()['billing_address']; // shipping address $objShippingAddress = new Address(); // standard isotope handling for distinguishing between the address types: // -> if only a billing address is available, it's also the shipping address foreach ($objSubmission->shippingaddress ? $this->arrShippingAddressFields : $this->arrBillingAddressFields as $strName) { $objShippingAddress->{str_replace('shippingaddress_', '', $strName)} = $objSubmission->{$objSubmission->shippingaddress ? $strName : str_replace('shippingaddress_', 'billingaddress_', $strName)}; } $objShippingAddress->save(); // $objOrder->setShippingAddress($objShippingAddress); // $objShippingAddressStep = new ShippingAddress($this->objCheckoutModule); // $arrSteps[] = $objShippingAddressStep; // $arrCheckoutInfo['shipping_address'] = $objShippingAddressStep->review()['shipping_address']; // add shipping method $objIsotopeShipping = Flat::findByPk($this->iso_shipping_modules); $objOrder->setShippingMethod($objIsotopeShipping); $objShippingMethodStep = new ShippingMethod($this->objCheckoutModule); $arrSteps[] = $objShippingMethodStep; $arrCheckoutInfo['shipping_method'] = $objShippingMethodStep->review()['shipping_method']; // add all the checkout info to the order $objOrder->checkout_info = $arrCheckoutInfo; $objOrder->notes = $objSubmission->notes; //... restore the former cart again Isotope::setCart($objCartTmp); $objOrder->nc_notification = $this->nc_notification; $objOrder->email_data = $this->getNotificationTokensFromSteps($arrSteps, $objOrder); // !HOOK: pre-process checkout if (isset($GLOBALS['ISO_HOOKS']['preCheckout']) && is_array($GLOBALS['ISO_HOOKS']['preCheckout'])) { foreach ($GLOBALS['ISO_HOOKS']['preCheckout'] as $callback) { $objCallback = \System::importStatic($callback[0]); if ($objCallback->{$callback}[1]($objOrder, $this->objCheckoutModule) === false) { \System::log('Callback ' . $callback[0] . '::' . $callback[1] . '() cancelled checkout for Order ID ' . $this->id, __METHOD__, TL_ERROR); $this->objCheckoutModule->redirectToStep('failed'); } } } $objOrder->lock(); $objOrder->checkout(); $objOrder->complete(); if (is_array($this->dca['config']['onsubmit_callback'])) { foreach ($this->dca['config']['onsubmit_callback'] as $key => $callback) { if ($callback[0] == 'Isotope\\Backend\\ProductCollection\\Callback' && $callback[1] == 'executeSaveHook') { unset($this->dca['config']['onsubmit_callback'][$key]); break; } } } $this->transformIsotopeErrorMessages(); parent::processForm(); }