Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter annoxoli

    (@annoxoli)

    Update:
    its work, but only if i create manual some user with their right email address!
    Code:

    public function addFromCheckout() {
            $url = '';
            $post = req::get('post');
            $res = $this->validateStep1($post);
    		//if registration from checkout is enabled and unregistered users don't allow to checkout
            if(isset($post['registration']) && !frame::_()->getModule('options')->get('allow_guest_checkout')) {
                $userAddErrors = frame::_()->getModule('user')->getModel()->validate($post['registration']);
                if(!empty($userAddErrors)) {
                    $regErrors = array();
                    foreach($userAddErrors as $key => $error)
                        $regErrors['registration['. $key. ']'] = lang::_('Registration: '). $error;     //To touch only registration fields
                    $res->pushError( $regErrors );
                }
            }
            if(!$res->error) {
                if(!frame::_()->getModule('user')->getCurrentID()) {
                    if(empty($post['registration']) && frame::_()->getModule('options')->get('checkout_force_create_user')) {
                        if(empty($post['registration']['password']))
                            $post['registration']['password'] = wp_generate_password(12, false);
                        $post['registration']['email'] = frame::_()->getModule('user')->getCurrentEmail();
                        if(empty($post['registration']['email'])) {
                            $post['registration']['username'] = utils::getRandStr();
                            $post['registration']['email'] = $post['registration']['username']. '@temp.com';
                        } else {
                            $userNameArr = explode('@', $post['registration']['email']);
                            $post['registration']['username'] = $userNameArr[0];
                        }
                    }
                    if(isset($post['registration'])) {                      //if registration from checkout is enabled
                        $post['registration']['forceLogin'] = true;         //make he logged right affter his add
                        req::setVar('loggedOnCheckoutRegister', true, 'session'); //to know that we logged him, @see checkoutView::getConfirnationPage()
                        frame::_()->getModule('user')->getModel()->post( $post['registration'], true /*This will skip validation*/ );
                    }
                }
                if($id = $this->getModel()->post($post)) {
                    $res->setHtml( frame::_()->getModule('checkout')->getView('checkout')->getConfirnationPage() );
                } else {
                    errors::push(lang::_('Can not add Order Record'));
                    $res->addError( errors::get() );
                }
            }
            return $res->ajaxExec();
        }

    Here:

    $post['registration']['email'] = $post['registration']['username']. '@temp.com';

    there create some user email with randome value! (Like: yHNIGotv8t@temp.com )
    you must select there user email on orders.php (billing_email)

    how can i do that ?

    greetings

Viewing 1 replies (of 1 total)