関数
RegisterWithAmazon::registerNewMember()
Creates Welcart account with Amazon account data. Returns GenericError
instance on failure.
戻り値 戻り値
ファイル: src/API/RegisterWithAmazon.php
public function registerNewMember() { global $usces; $password = self::generateWelcartCompliantRandomPassword(); // Add a message that a temporary password is being used to the body of the email add_filter('usces_filter_send_regmembermail_message', function ($message) use ($password) { return __('You are currently using a temporary password. Please log in with your Amazon account from My Page and change your password.', 'wcexaap') . "\r\n\r\n" . __('temporary password : ', 'wcexaap') . $password . "\r\n\r\n" . $message; }); $delivery = isset($_SESSION['usces_entry']['delivery']) ? $_SESSION['usces_entry']['delivery'] : []; $customer = isset($_SESSION['usces_entry']['customer']) ? $_SESSION['usces_entry']['customer'] : []; $giftShipping = isset($_REQUEST['giftShipping']) ? (bool)$_REQUEST['giftShipping'] : false; $_POST['customer']['password1'] = $password; $_POST['customer']['password2'] = $password; $_POST['customer']['mailaddress1'] = $customer['mailaddress1']; $_POST['customer']['mailaddress2'] = $customer['mailaddress2']; $_POST['member_regmode'] = 'newmemberfromcart'; if ($giftShipping === false) { $_POST['customer'] = $delivery; $_POST['customer']['password1'] = $password; $_POST['customer']['password2'] = $password; $_POST['customer']['mailaddress1'] = $customer['mailaddress1']; $_POST['customer']['mailaddress2'] = $customer['mailaddress2']; $_POST['customer']['name1'] = $customer['name1']; $_POST['customer']['name2'] = $customer['name2']; } $registerPayload = $_POST; if ($giftShipping === false) { $_POST['customer']['address1'] = !empty($delivery['address1']) ? $delivery['address1'] : 'temp'; $_POST['customer']['address2'] = !empty($delivery['address2']) ? $delivery['address2'] : 'temp'; $_POST['customer']['tel'] = !empty($delivery['tel']) ? $delivery['tel'] : '00000000000'; } // validate $_POST $errormessage = $usces->member_check_fromcart(); if (!empty($errormessage)) { return $this->getErrorResponse( self::REGISTER_WITH_AMAZON_ERROR, [$errormessage], [$errormessage] ); } // revert $_POST back to Amazon address which may have missing values $_POST = $registerPayload; add_action('usces_action_member_registered', [$this, 'onMemRegistrationSuccess'], 10, 2); if ($this->createAccount() !== 'newcompletion') { return $this->getErrorResponse( self::REGISTER_WITH_AMAZON_ERROR, [$usces->error_message], [$usces->error_message] ); } }