if ($cart->hasMembershipProducts() || $cart->hasSpreedlySubscriptions()) { // Set up a new Cart66Account and start by pre-populating the data or load the logged in account if ($accountId = Cart66Common::isLoggedIn()) { $account = new Cart66Account($accountId); } else { $account = new Cart66Account(); if (isset($_POST['account'])) { $acctData = Cart66Common::postVal('account'); Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] New Account Data: " . print_r($acctData, true)); $account->firstName = $acctData['first_name']; $account->lastName = $acctData['last_name']; $account->email = $acctData['email']; $account->username = $acctData['username']; $account->password = md5($acctData['password']); $errors = $account->validate(); $jqErrors = $account->getJqErrors(); if ($acctData['password'] != $acctData['password2']) { $errors[] = __("Passwords do not match", "cart66"); $jqErrors[] = 'account-password'; $jqErrors[] = 'account-password2'; } if (count($errors) == 0) { $createAccount = true; } else { if (count($errors)) { try { Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Unable to process order: " . print_r($errors, true)); throw new Cart66Exception(__('Your order could not be processed for the following reasons:', 'cart66'), 66500); } catch (Cart66Exception $e) { $exception = Cart66Exception::exceptionMessages($e->getCode(), $e->getMessage(), $errors); echo Cart66Common::getView('views/error-messages.php', $exception);
public function showReceipt($attrs) { $account = null; if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['ouid'])) { if (CART66_PRO && isset($_POST['account'])) { $acctData = Cart66Common::postVal('account'); Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] New Account Data: " . print_r($acctData, true)); $account = new Cart66Account(); $account->firstName = $acctData['first_name']; $account->lastName = $acctData['last_name']; $account->email = $acctData['email']; $account->username = $acctData['username']; $account->password = md5($acctData['password']); $errors = $account->validate(); $jqErrors = $account->getJqErrors(); if ($acctData['password'] != $acctData['password2']) { $errors[] = __("Passwords do not match", "cart66"); $jqErrors[] = 'account-password'; $jqErrors[] = 'account-password2'; } if (count($errors) == 0) { // Attach account to order $order = new Cart66Order(); $ouid = Cart66Common::postVal('ouid'); Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Trying to load order with OUID: {$ouid}"); if ($order->loadByOuid($ouid)) { // Make sure the order can be loaded, then save the account $account->save(); // Attach membership to account and account to the order if ($mp = $order->getMembershipProduct()) { $account->attachMembershipProduct($mp, $account->firstName, $account->lastName); $order->account_id = $account->id; $order->save(); $account->clear(); } } } else { $attrs['errors'] = $errors; $attrs['jqErrors'] = $jqErrors; } } } $attrs['account'] = $account; $view = Cart66Common::getView('views/receipt.php', $attrs, true, true); return $view; }
<?php } ?> </ul> </div><!-- #shippingInfo --> <?php } else { ?> <?php } ?> </div> <?php if (isset($errors) && count($errors) > 0) { echo Cart66Common::showErrors($errors, 'Unable to create account'); echo Cart66Common::getJqErrorScript($account->getJqErrors()); } ?> <form class="phorm2" action="" method='post' style="<?php if (isset($data['completestyle'])) { echo $data['completestyle']; } ?> "> <input type="hidden" name="task" value="doexpresscheckout"> <input type="hidden" name="token" value="<?php echo $token; ?> "> <input type="hidden" name="PayerID" value="<?php