Exemple #1
0
 public function orderComplete($orderNumber)
 {
     $order = \CI::Orders()->getOrder($orderNumber);
     $orderCustomer = \CI::Customers()->get_customer($order->customer_id);
     if ($orderCustomer->is_guest || $orderCustomer->id == $this->customer->id) {
         $this->view('orderComplete', ['order' => $order]);
     } else {
         if (!\CI::Login()->isLoggedIn(false, false)) {
             redirect('login');
         } else {
             throw_404();
         }
     }
 }
Exemple #2
0
 public function __construct()
 {
     parent::__construct();
     //add the theme to the packages path
     \CI::load()->add_package_path(FCPATH . 'themes/' . config_item('theme') . '/');
     \CI::load()->model(array('Pages', 'Customers', 'Login', 'Categories', 'Coupons', 'Locations', 'Products', 'ProductOptions', 'DigitalProducts'));
     //load in some base information
     \CI::load()->helper('theme');
     \CI::lang()->load('common');
     $this->pages = \CI::Pages()->get_pages_tiered();
     //see if the customer is logged in.
     //if the customer is not logged in, then we'll have a temporary guest customer created.
     $this->isLoggedIn = \CI::Login()->isLoggedIn();
 }
 public function download($fileId, $orderId)
 {
     //get the order.
     $order = \CI::db()->where('orders.id', $orderId)->join('customers', 'customers.id = orders.customer_id')->get('orders')->row();
     $file = \CI::db()->where('order_item_files.id', $fileId)->join('digital_products', 'digital_products.id = order_item_files.file_id')->get('order_item_files')->row();
     if ($order && $file) {
         if ($order->is_guest || $order->customer_id == $this->customer->id) {
             if ($file->max_downloads == 0 || $file->downloads_used < $file->max_downloads) {
                 \CI::DigitalProducts()->touchDownload($fileId);
                 \CI::DigitalProducts()->downloadFile($file->filename);
             }
         } else {
             //send to login page
             if (\CI::Login()->isLoggedIn(false, false)) {
                 redirect('login');
             } else {
                 throw_404();
             }
         }
     } else {
         //move along nothing to see here
         throw_404();
     }
 }
Exemple #4
0
 public function __construct()
 {
     parent::__construct();
     $this->state_taxes = config_item('state_taxes');
     $customer = CI::Login()->customer();
     $order = GC::getCart();
     $taxType = config_item('tax_address');
     if ($taxType == 'ship') {
         if ((bool) $order->shipping_address_id) {
             $this->address = CI::Customers()->get_address($order->shipping_address_id);
         } else {
             return 0;
         }
     } else {
         if ((bool) $order->billing_address_id) {
             $this->address = CI::Customers()->get_address($order->billing_address_id);
         } else {
             return 0;
         }
     }
     if (!$this->address) {
         return 0;
     }
 }
Exemple #5
0
 public function index()
 {
     $redirect = \CI::Login()->isLoggedIn(false, false);
     //if they are logged in, we send them back to the my_account by default
     if ($redirect) {
         redirect('my-account');
     }
     \CI::load()->library('form_validation');
     //default values are empty if the customer is new
     $data = ['company' => '', 'firstname' => '', 'lastname' => '', 'email' => '', 'phone' => '', 'address1' => '', 'address2' => '', 'city' => '', 'state' => '', 'zip' => '', 'redirect' => \CI::session()->flashdata('redirect')];
     \CI::form_validation()->set_rules('company', 'lang:address_company', 'trim|max_length[128]');
     \CI::form_validation()->set_rules('firstname', 'lang:address_firstname', 'trim|required|max_length[32]');
     \CI::form_validation()->set_rules('lastname', 'lang:address_lastname', 'trim|required|max_length[32]');
     \CI::form_validation()->set_rules('email', 'lang:address_email', ['trim', 'required', 'valid_email', 'max_length[128]', ['check_email_callable', function ($str) {
         return $this->check_email($str);
     }]]);
     \CI::form_validation()->set_rules('phone', 'lang:address_phone', 'trim|required|max_length[32]');
     \CI::form_validation()->set_rules('email_subscribe', 'lang:account_newsletter_subscribe', 'trim|numeric|max_length[1]');
     \CI::form_validation()->set_rules('password', 'Password', 'required|min_length[6]');
     \CI::form_validation()->set_rules('confirm', 'Confirm Password', 'required|matches[password]');
     if (\CI::form_validation()->run() == FALSE) {
         //if they have submitted the form already and it has returned with errors, reset the redirect
         if (\CI::input()->post('submitted')) {
             $data['redirect'] = \CI::input()->post('redirect');
         }
         // load other page content
         //\CI::load()->model('banner_model');
         \CI::load()->helper('directory');
         $this->view('register', $data);
     } else {
         $save['id'] = false;
         $save['firstname'] = \CI::input()->post('firstname');
         $save['lastname'] = \CI::input()->post('lastname');
         $save['email'] = \CI::input()->post('email');
         $save['phone'] = \CI::input()->post('phone');
         $save['company'] = \CI::input()->post('company');
         $save['active'] = config_item('new_customer_status');
         $save['email_subscribe'] = intval((bool) \CI::input()->post('email_subscribe'));
         $save['password'] = \CI::input()->post('password');
         $redirect = \CI::input()->post('redirect');
         //if we don't have a value for redirect
         if ($redirect == '') {
             $redirect = 'my-account';
         }
         // save the customer info and get their new id
         $id = \CI::Customers()->save($save);
         /* send an email */
         // get the email template
         $row = \CI::db()->where('id', '6')->get('canned_messages')->row_array();
         // set replacement values for subject & body
         // {customer_name}
         $row['subject'] = str_replace('{customer_name}', \CI::input()->post('firstname') . ' ' . \CI::input()->post('lastname'), $row['subject']);
         $row['content'] = str_replace('{customer_name}', \CI::input()->post('firstname') . ' ' . \CI::input()->post('lastname'), $row['content']);
         // {url}
         $row['subject'] = str_replace('{url}', config_item('base_url'), $row['subject']);
         $row['content'] = str_replace('{url}', config_item('base_url'), $row['content']);
         // {site_name}
         $row['subject'] = str_replace('{site_name}', config_item('company_name'), $row['subject']);
         $row['content'] = str_replace('{site_name}', config_item('company_name'), $row['content']);
         \CI::load()->library('email');
         $config['mailtype'] = 'html';
         \CI::email()->initialize($config);
         \CI::email()->from(config_item('email'), config_item('company_name'));
         \CI::email()->to($save['email']);
         \CI::email()->bcc(config_item('email'));
         \CI::email()->subject($row['subject']);
         \CI::email()->message(html_entity_decode($row['content']));
         \CI::email()->send();
         \CI::session()->set_flashdata('message', sprintf(lang('registration_thanks'), \CI::input()->post('firstname')));
         //lets automatically log them in
         \CI::Login()->loginCustomer($save['email'], \CI::input()->post('confirm'));
         //we're just going to make this secure regardless, because we don't know if they are
         //wanting to redirect to an insecure location, if it needs to be secured then we can use the secure redirect in the controller
         //to redirect them, if there is no redirect, the it should redirect to the homepage.
         redirect($redirect);
     }
 }
 public function index($offset = 0)
 {
     //make sure they're logged in
     \CI::Login()->isLoggedIn('my-account');
     $data['customer'] = (array) \CI::Customers()->get_customer($this->customer->id);
     $data['addresses'] = \CI::Customers()->get_address_list($this->customer->id);
     $data['customer_addresses'] = \CI::Customers()->get_address_list($this->customer->id);
     // load other page content
     //\CI::load()->model('banner_model');
     \CI::load()->helper('directory');
     \CI::load()->helper('date');
     // paginate the orders
     \CI::load()->library('pagination');
     $config['base_url'] = site_url('my_account');
     $config['total_rows'] = \CI::Orders()->countCustomerOrders($this->customer->id);
     $config['per_page'] = '15';
     $config['first_link'] = 'First';
     $config['first_tag_open'] = '<li>';
     $config['first_tag_close'] = '</li>';
     $config['last_link'] = 'Last';
     $config['last_tag_open'] = '<li>';
     $config['last_tag_close'] = '</li>';
     $config['full_tag_open'] = '<div class="pagination"><ul>';
     $config['full_tag_close'] = '</ul></div>';
     $config['cur_tag_open'] = '<li class="active"><a href="#">';
     $config['cur_tag_close'] = '</a></li>';
     $config['num_tag_open'] = '<li>';
     $config['num_tag_close'] = '</li>';
     $config['prev_link'] = '&laquo;';
     $config['prev_tag_open'] = '<li>';
     $config['prev_tag_close'] = '</li>';
     $config['next_link'] = '&raquo;';
     $config['next_tag_open'] = '<li>';
     $config['next_tag_close'] = '</li>';
     \CI::pagination()->initialize($config);
     $data['orders_pagination'] = \CI::pagination()->create_links();
     $data['orders'] = \CI::Orders()->getCustomerOrders($this->customer->id, $offset);
     //print_r($offset);
     \CI::load()->library('form_validation');
     //        \CI::form_validation()->set_rules('company', 'lang:address_company', 'trim|max_length[128]');
     \CI::form_validation()->set_rules('firstname', 'lang:address_firstname', 'trim|required|max_length[32]');
     \CI::form_validation()->set_rules('lastname', 'lang:address_lastname', 'trim|required|max_length[32]');
     \CI::form_validation()->set_rules('email', 'lang:address_email', ['trim', 'required', 'valid_email', 'max_length[128]', ['check_email_callable', function ($str) {
         return $this->check_email($str);
     }]]);
     \CI::form_validation()->set_rules('phone', 'lang:address_phone', 'trim|required|max_length[32]');
     \CI::form_validation()->set_rules('email_subscribe', 'lang:account_newsletter_subscribe', 'trim|numeric|max_length[1]');
     if (\CI::input()->post('password') != '' || \CI::input()->post('confirm') != '') {
         \CI::form_validation()->set_rules('password', 'Password', 'required|min_length[6]|sha1');
         \CI::form_validation()->set_rules('confirm', 'Confirm Password', 'required|matches[password]');
     } else {
         \CI::form_validation()->set_rules('password', 'Password');
         \CI::form_validation()->set_rules('confirm', 'Confirm Password');
     }
     if (\CI::form_validation()->run() == FALSE) {
         $this->view('my_account', $data);
     } else {
         $customer = [];
         $customer['id'] = $this->customer->id;
         //            $customer['company'] = \CI::input()->post('company');
         $customer['firstname'] = \CI::input()->post('firstname');
         $customer['lastname'] = \CI::input()->post('lastname');
         $customer['email'] = \CI::input()->post('email');
         $customer['phone'] = \CI::input()->post('phone');
         $customer['email_subscribe'] = intval((bool) \CI::input()->post('email_subscribe'));
         if (\CI::input()->post('password') != '') {
             $customer['password'] = \CI::input()->post('password');
         }
         \GC::save_customer($this->customer);
         \CI::Customers()->save($customer);
         \CI::session()->set_flashdata('message', lang('message_account_updated'));
         redirect('my-account');
     }
 }
Exemple #7
0
 public function getCart($refresh = false)
 {
     if ($refresh) {
         $this->customer = CI::Login()->customer();
         $this->cart = CI::Orders()->getCustomerCart($this->customer->id);
         if (!$this->cart) {
             //create a new cart
             CI::Orders()->saveOrder(['status' => 'cart', 'customer_id' => $this->customer->id]);
             $this->cart = CI::Orders()->getCustomerCart($this->customer->id);
         }
         $this->getCartItems(true);
     }
     return $this->cart;
 }
Exemple #8
0
        <div class="col-nest">
            <div class="col" data-cols="1/2">
                <a class="logo" href="<?php 
echo base_url();
?>
"><img src="<?php 
echo theme_img('logo.png');
?>
" /></a>
            </div>
            <div class="col" data-cols="1/2">
                <nav> 
                    <ul class="nav nav-right mobileNav" style="font-size:14px; font-weight:bold; text-transform:uppercase;">

                        <?php 
if (CI::Login()->isLoggedIn(false, false)) {
    ?>
                            <li>
                                <a><?php 
    echo lang('account');
    ?>
 <i class="icon-chevron-down"></i></a>
                                <ul>
                                    <li><a href="<?php 
    echo site_url('my-account');
    ?>
"><?php 
    echo lang('my_account');
    ?>
</a></li>
                                    <li><a href="<?php 
Exemple #9
0
 public function register()
 {
     $redirect = \CI::Login()->isLoggedIn(false, false);
     //if they are logged in, we send them back to the my_account by default
     if ($redirect) {
         redirect('my-account');
     }
     \CI::load()->library('form_validation');
     //default values are empty if the customer is new
     $data = ['company' => '', 'firstname' => '', 'lastname' => '', 'email' => '', 'phone' => '', 'address1' => '', 'address2' => '', 'city' => '', 'state' => '', 'zip' => '', 'redirect' => \CI::session()->flashdata('redirect')];
     \CI::form_validation()->set_rules('company', 'lang:account_company', 'trim|max_length[128]');
     \CI::form_validation()->set_rules('firstname', 'lang:account_firstname', 'trim|required|max_length[32]');
     \CI::form_validation()->set_rules('lastname', 'lang:account_lastname', 'trim|required|max_length[32]');
     \CI::form_validation()->set_rules('email', 'lang:account_email', ['trim', 'required', 'valid_email', 'max_length[128]', ['check_email_callable', function ($str) {
         return $this->check_email($str);
     }]]);
     \CI::form_validation()->set_rules('phone', 'lang:account_phone', 'trim|required|max_length[32]');
     \CI::form_validation()->set_rules('email_subscribe', 'lang:email_subscribe', 'trim|numeric|max_length[1]');
     \CI::form_validation()->set_rules('password', 'lang:account_password', 'required|min_length[6]');
     \CI::form_validation()->set_rules('confirm', 'lang:account_confirm', 'required|matches[password]');
     if (\CI::form_validation()->run() == FALSE) {
         //if they have submitted the form already and it has returned with errors, reset the redirect
         if (\CI::input()->post('submitted')) {
             $data['redirect'] = \CI::input()->post('redirect');
         }
         // load other page content
         //\CI::load()->model('banner_model');
         \CI::load()->helper('directory');
         $data['registrationErrors'] = \CI::form_validation()->get_error_array();
         $this->view('login', $data);
     } else {
         $save['id'] = false;
         $save['firstname'] = \CI::input()->post('firstname');
         $save['lastname'] = \CI::input()->post('lastname');
         $save['email'] = \CI::input()->post('email');
         $save['phone'] = \CI::input()->post('phone');
         $save['company'] = \CI::input()->post('company');
         $save['active'] = (bool) config_item('new_customer_status');
         $save['email_subscribe'] = intval((bool) \CI::input()->post('email_subscribe'));
         $save['password'] = \CI::input()->post('password');
         $redirect = \CI::input()->post('redirect');
         //if we don't have a value for redirect
         if ($redirect == '') {
             $redirect = 'my-account';
         }
         // save the customer info and get their new id
         $id = \CI::Customers()->save($save);
         //send the registration email
         \GoCart\Emails::registration($save);
         //load twig for this language string
         $loader = new \Twig_Loader_String();
         $twig = new \Twig_Environment($loader);
         //if they're automatically activated log them in and send them where they need to go
         if ($save['active']) {
             \CI::session()->set_flashdata('message', $twig->render(lang('registration_thanks'), $save));
             //lets automatically log them in
             \CI::Login()->loginCustomer($save['email'], \CI::input()->post('confirm'));
             //to redirect them, if there is no redirect, the it should redirect to the homepage.
             redirect($redirect);
         } else {
             //redirect to the login page if they need to wait for activation
             \CI::session()->set_flashdata('message', $twig->render(lang('registration_awaiting_activation'), $save));
             redirect('login');
         }
     }
 }
Exemple #10
0
 public function __construct()
 {
     parent::__construct();
     \CI::load()->model(array('Locations'));
     $this->customer = \CI::Login()->customer();
 }
Exemple #11
0
 public function __construct()
 {
     $this->customer = \CI::Login()->customer();
 }
Exemple #12
0
 public function __construct()
 {
     $this->tiered = [];
     $this->customer = \CI::Login()->customer();
     $this->get_categories_tiered();
 }
Exemple #13
0
 public function logout()
 {
     \CI::Login()->logoutCustomer();
     redirect('login');
 }
Exemple #14
0
 public function form($id = 0)
 {
     $data['addressCount'] = \CI::Customers()->count_addresses($this->customer->id);
     $customer = \CI::Login()->customer();
     //grab the address if it's available
     $data['id'] = false;
     $data['firstname'] = $customer->firstname;
     $data['lastname'] = $customer->lastname;
     $data['email'] = $customer->email;
     $data['phone'] = $customer->phone;
     $data['address1'] = '';
     $data['address2'] = '';
     $data['city'] = '';
     $data['country_id'] = '';
     $data['zone_id'] = '';
     $data['zip'] = '';
     if ($id != 0) {
         $a = \CI::Customers()->get_address($id);
         if ($a['customer_id'] != $this->customer->id) {
             redirect('addresses/form');
             // don't allow cross-customer editing
         }
         $data = array_merge($data, $a);
         $data['zones_menu'] = \CI::Locations()->get_zones_menu($data['country_id']);
     }
     //get the countries list for the dropdown
     $data['countries_menu'] = \CI::Locations()->get_countries_menu();
     if ($id == 0) {
         //if there is no set ID, the get the zones of the first country in the countries menu
         $data['zones_menu'] = \CI::Locations()->get_zones_menu(array_shift(array_keys($data['countries_menu'])));
     } else {
         $data['zones_menu'] = \CI::Locations()->get_zones_menu($data['country_id']);
     }
     \CI::load()->library('form_validation');
     //        \CI::form_validation()->set_rules('company', 'lang:address_company', 'trim|max_length[128]');
     \CI::form_validation()->set_rules('firstname', 'lang:address_firstname', 'trim|required|max_length[32]');
     \CI::form_validation()->set_rules('lastname', 'lang:address_lastname', 'trim|required|max_length[32]');
     \CI::form_validation()->set_rules('email', 'lang:address_email', 'trim|required|valid_email|max_length[128]');
     \CI::form_validation()->set_rules('phone', 'lang:address_phone', 'trim|required|max_length[32]');
     \CI::form_validation()->set_rules('address1', 'lang:address', 'trim|required|max_length[128]');
     \CI::form_validation()->set_rules('address2', 'lang:address2', 'trim|max_length[128]');
     \CI::form_validation()->set_rules('city', 'lang:address_city', 'trim|required|max_length[32]');
     \CI::form_validation()->set_rules('country_id', 'lang:address_country', 'trim|required|numeric');
     \CI::form_validation()->set_rules('zone_id', 'lang:address_state', 'trim|required|numeric');
     \CI::form_validation()->set_rules('zip', 'lang:address_zip', 'trim|required|max_length[32]');
     if (\CI::form_validation()->run() == FALSE) {
         $this->partial('address_form', $data);
     } else {
         $a = [];
         $a['id'] = $id == 0 ? '' : $id;
         $a['customer_id'] = $this->customer->id;
         $a['firstname'] = \CI::input()->post('firstname');
         $a['lastname'] = \CI::input()->post('lastname');
         $a['email'] = \CI::input()->post('email');
         $a['phone'] = \CI::input()->post('phone');
         $a['address1'] = \CI::input()->post('address1');
         $a['address2'] = \CI::input()->post('address2');
         $a['city'] = \CI::input()->post('city');
         $a['zip'] = \CI::input()->post('zip');
         // get zone / country data using the zone id submitted as state
         $country = \CI::Locations()->get_country(assign_value('country_id'));
         $zone = \CI::Locations()->get_zone(assign_value('zone_id'));
         if (!empty($country)) {
             $a['zone'] = $zone->code;
             // save the state for output formatted addresses
             $a['country'] = $country->name;
             // some shipping libraries require country name
             $a['country_code'] = $country->iso_code_2;
             // some shipping libraries require the code
             $a['country_id'] = \CI::input()->post('country_id');
             $a['zone_id'] = \CI::input()->post('zone_id');
         }
         \CI::Customers()->save_address($a);
         echo 1;
     }
 }