WordPress.org

Ready to get started?Download WordPress

Forums

Ready! Ecommerce Shopping Cart
[resolved] Send mail to customer - Bug! (5 posts)

  1. annoxoli
    Member
    Posted 1 year ago #

    Hi,

    follow problem.
    if some customer bought any item in my shop,
    the didn't response some E-Mail about his order!

    i think some value are wrong in :
    "<wordpresspath>\wp-content\plugins\ready-ecommerce\modules\user\mod.php"
    Function:

    public function getCurrentEmail($order = array()) {
            $user = frame::_()->getModule('user')->getCurrent();
            $customerEmail = $user->user_email;
            if(empty($customerEmail) && empty($order))
                $order = frame::_()->getModule('order')->getCurrent();
            if(empty($customerEmail) && !empty($order)) {
    			if(!empty($order['shipping_address']) && is_string($order['shipping_address'])) {
    				$order['shipping_address'] = utils::jsonDecode($order['shipping_address']);
    			}
                if(!empty($order['shipping_address'])) {
                    foreach($order['shipping_address'] as $k => $v) {
                        if(preg_match('/^email/i', $k)) {
                            $customerEmail = $v;
                            break;
                        }
                    }
                }
    			if(!empty($order['billing_address']) && is_string($order['billing_address'])) {
    				$order['billing_address'] = utils::jsonDecode($order['billing_address']);
    			}
                if(empty($customerEmail) && !empty($order['billing_address'])) {
                    foreach($order['billing_address'] as $k => $v) {
                        if(preg_match('/^email/i', $k)) {
                            $customerEmail = $v;
                            break;
                        }
                    }
                }
            }
            return $customerEmail;
        }

    i search 2 hours to fix this bug, but i don't find them!
    i hope you can help me! thanks.

    greetings

    http://wordpress.org/extend/plugins/ready-ecommerce/

  2. annoxoli
    Member
    Posted 1 year ago #

    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

  3. Ready! Developer
    Member
    Plugin Author

    Posted 1 year ago #

    Hello.
    "there create some user email with randome value! " - please see code above:
    if(empty($post['registration']) && frame::_()->getModule('options')->get('checkout_force_create_user'))

    This mean that you have no registration fields for user and enabled option "Create user on checkout in any case". If you don't want to use registration box on checkout - add email to billing or shipping address section - and this should work.

    Regards,
    Alexey.

  4. Ready! Developer
    Member
    Plugin Author

    Posted 1 year ago #

    Hello.
    Was this helpful for you?

    Regards,
    Alexey.

  5. Ready! Developer
    Member
    Plugin Author

    Posted 1 year ago #

    Hello.
    Hope manipulations with option "Create user on checkout in any case" helped you.

    Regards,
    Alexey.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.