private function install() { //Check if translations are available parent::checkTranslations(dirname(__FILE__), $this->getTranslations()); $install_array = array('status' => 'true', 'title' => 'Verzending België', 'description' => '', 'zone' => '', 'quote' => '10', 'order_status_id' => '3', 'sort_order' => '10'); tep_db_query('CREATE TABLE checkout_' . get_class($this) . '( id INT(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), status VARCHAR(255), title VARCHAR(255), description VARCHAR(255), zone VARCHAR(255), quote FLOAT(10,2), order_status_id INT(11), sort_order INT(11))'); tep_db_query('CREATE INDEX title ON checkout_' . get_class($this) . ' (`title`)'); tep_db_query('CREATE INDEX status ON checkout_' . get_class($this) . ' (`status`)'); tep_db_query('CREATE INDEX zone ON checkout_' . get_class($this) . ' (`zone`)'); tep_db_perform('checkout_' . get_class($this), $install_array, 'insert'); }
private function install() { //Check if translations are available parent::checkTranslations(dirname(__FILE__), $this->getTranslations()); $install_array = array('status' => 'true', 'title' => 'Facturatieadres', 'description' => ''); tep_db_query('CREATE TABLE checkout_' . get_class($this) . '( id INT(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), status VARCHAR(255), title VARCHAR(255), description VARCHAR(255))'); tep_db_query('CREATE INDEX title ON checkout_' . get_class($this) . ' (`title`)'); tep_db_query('CREATE INDEX status ON checkout_' . get_class($this) . ' (`status`)'); tep_db_perform('checkout_' . get_class($this), $install_array, 'insert'); }
private function install() { //Check if translations are available parent::checkTranslations(dirname(__FILE__), $this->getTranslations()); $install_array = array('status' => array('type' => 'config', 'value' => 'true', 'options' => array('true', 'false')), 'login' => array('type' => 'config', 'value' => 'true', 'options' => array('true', 'false')), 'create_account' => array('type' => 'config', 'value' => 'true', 'options' => array('true', 'false')), 'change_billing_address' => array('type' => 'config', 'value' => 'true', 'options' => array('true', 'false')), 'billing_name' => array('type' => 'field', 'input' => 'text', 'value' => 'true', 'options' => array('true', 'false'), 'block' => 'billing', 'label' => 'Naam + Familienaam', 'dbvalue' => 'entry_firstname', 'expression' => "/^[\\D]+[\\s][\\D]+\$/", 'error' => 'Vul a.u.b. een volledige naam in.', 'sort_order' => 1), 'billing_company' => array('type' => 'field', 'input' => 'text', 'value' => 'false', 'options' => array('true', 'false'), 'block' => 'billing', 'label' => 'Bedrijf', 'dbvalue' => 'entry_company', 'condition' => "!tep_session_is_registered('customer_id')", 'sort_order' => 2), 'billing_tva_intracom' => array('type' => 'field', 'input' => 'text', 'value' => 'false', 'options' => array('true', 'false'), 'block' => 'billing', 'label' => 'BTW nr.', 'dbvalue' => 'billing_tva_intracom', 'condition' => "!tep_session_is_registered('customer_id')", 'sort_order' => 3), 'billing_street_address' => array('type' => 'field', 'input' => 'text', 'value' => 'true', 'options' => array('true', 'false'), 'block' => 'billing', 'label' => 'Straat + nr.', 'dbvalue' => 'entry_street_address', 'expression' => "/^[\\D]+[\\s][\\d]+[\\D]{0,3}+\$/", 'error' => 'Vul a.u.b. een straat + nummer in.', 'sort_order' => 4), 'billing_city' => array('type' => 'field', 'input' => 'text', 'value' => 'true', 'options' => array('true', 'false'), 'block' => 'billing', 'label' => 'Gemeente', 'dbvalue' => 'entry_city', 'expression' => "/^[\\D]+[\\s]?[\\D]*\$/", 'error' => 'Vul a.u.b. een gemeente in.', 'sort_order' => 5), 'billing_postcode' => array('type' => 'field', 'input' => 'text', 'value' => 'true', 'options' => array('true', 'false'), 'block' => 'billing', 'label' => 'Postcode', 'dbvalue' => 'entry_postcode', 'expression' => "/^[a-zA-Z0-9]+\$/", 'error' => 'Vul a.u.b. een postcode in.', 'sort_order' => 6), 'billing_country' => array('type' => 'dropdown', 'value' => 'true', 'options' => array('true', 'false'), 'block' => 'billing', 'label' => 'Land', 'dbvalue' => 'entry_country_id', 'expression' => "/^[1-9][0-9]*\$/", 'error' => 'Kies a.u.b. een land.', 'sort_order' => 7), 'customers_telephone' => array('type' => 'field', 'input' => 'tel', 'value' => 'true', 'options' => array('true', 'false'), 'block' => 'billing', 'label' => 'Tel.', 'dbvalue' => 'customers_telephone', 'function' => "validate_phone", 'error' => 'Vul a.u.b. een telefoon nummer in.', 'sort_order' => 8), 'customers_email_address' => array('type' => 'field', 'input' => 'email', 'value' => 'true', 'options' => array('true', 'false'), 'block' => 'billing', 'label' => 'E-mailadres', 'dbvalue' => 'customers_email_address', 'function' => "validate_email", 'error' => 'Vul a.u.b. een geldig e-mail adres in.', 'sort_order' => 9), 'delivery_name' => array('type' => 'field', 'input' => 'text', 'value' => 'true', 'options' => array('true', 'false'), 'block' => 'delivery', 'label' => 'Naam + Familienaam', 'dbvalue' => 'entry_firstname', 'expression' => "/^[\\D]+[\\s][\\D]+\$/", 'error' => 'Vul a.u.b. een volledige naam in.', 'sort_order' => 1), 'delivery_company' => array('type' => 'field', 'input' => 'text', 'value' => 'false', 'options' => array('true', 'false'), 'block' => 'delivery', 'label' => 'Bedrijf', 'dbvalue' => 'entry_company', 'condition' => "!tep_session_is_registered('customer_id')", 'sort_order' => 2), 'delivery_tva_intracom' => array('type' => 'field', 'input' => 'text', 'value' => 'false', 'options' => array('true', 'false'), 'block' => 'delivery', 'label' => 'BTW nr.', 'dbvalue' => '', 'condition' => "!tep_session_is_registered('customer_id')", 'sort_order' => 3), 'delivery_street_address' => array('type' => 'field', 'input' => 'text', 'value' => 'true', 'options' => array('true', 'false'), 'block' => 'delivery', 'label' => 'Straat + nr.', 'dbvalue' => 'entry_street_address', 'expression' => "/^[\\D]+[\\s][\\d]+[\\D]{0,3}+\$/", 'error' => 'Vul a.u.b. een straat + nummer in.', 'sort_order' => 4), 'delivery_city' => array('type' => 'field', 'input' => 'text', 'value' => 'true', 'options' => array('true', 'false'), 'block' => 'delivery', 'label' => 'Gemeente', 'dbvalue' => 'entry_city', 'expression' => "/^[\\D]+[\\s]?[\\D]*\$/", 'error' => 'Vul a.u.b. een gemeente in.', 'sort_order' => 5), 'delivery_postcode' => array('type' => 'field', 'input' => 'text', 'value' => 'true', 'options' => array('true', 'false'), 'block' => 'delivery', 'label' => 'Postcode', 'dbvalue' => 'entry_postcode', 'expression' => "/^[a-zA-Z0-9]+\$/", 'error' => 'Vul a.u.b. een postcode in.', 'sort_order' => 6), 'delivery_country' => array('type' => 'dropdown', 'value' => 'true', 'options' => array('true', 'false'), 'block' => 'delivery', 'label' => 'Land', 'dbvalue' => 'entry_country_id', 'expression' => "/^[1-9][0-9]*\$/", 'error' => 'Kies a.u.b. een land.', 'sort_order' => 7)); tep_db_query('CREATE TABLE checkout_' . get_class($this) . '( `id` INT(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), `name` VARCHAR(255), `type` VARCHAR(255), `input` VARCHAR(255), `value` VARCHAR(255), `options` VARCHAR(255), `block` VARCHAR(255), `label` VARCHAR(255), `dbvalue` VARCHAR(255), `expression` VARCHAR(255), `function` VARCHAR(255), `condition` VARCHAR(255), `error` VARCHAR(255), `sort_order` INT(11))'); tep_db_query('CREATE INDEX name ON checkout_' . get_class($this) . ' (name)'); tep_db_query('CREATE INDEX type ON checkout_' . get_class($this) . ' (type)'); foreach ($install_array as $key => $value) { $db_array = array(); $db_array['name'] = $key; foreach ($value as $name => $data) { if (is_array($data)) { $data = serialize($data); } $db_array[$name] = $data; } tep_db_perform('checkout_' . get_class($this), $db_array, 'insert'); } }
private function install() { //Check if translations are available parent::checkTranslations(dirname(__FILE__), $this->getTranslations()); $install_array = array('status' => 'true', 'title' => 'Kiala', 'description' => '', 'dspid' => '', 'min_amount' => '0', 'max_weight' => '0', 'free_shipping_over' => '0', 'shipping_cost' => '0', 'sort_order' => 10); tep_db_query('CREATE TABLE checkout_' . get_class($this) . '( id INT(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), status VARCHAR(255), title VARCHAR(255), description VARCHAR(255), dspid VARCHAR(255), min_amount FLOAT(10,2), max_weight FLOAT(10,2), free_shipping_over FLOAT(10,2), shipping_cost FLOAT(10,2), sort_order INT(11))'); tep_db_query('CREATE INDEX title ON checkout_' . get_class($this) . ' (`title`)'); tep_db_query('CREATE INDEX status ON checkout_' . get_class($this) . ' (`status`)'); tep_db_query('CREATE INDEX sort_order ON checkout_' . get_class($this) . ' (`sort_order`)'); tep_db_perform('checkout_' . get_class($this), $install_array, 'insert'); }
private function install() { //Check if translations are available parent::checkTranslations(dirname(__FILE__), $this->getTranslations()); $install_array = array('status' => 'true', 'title' => 'Betaling via beveiligde Ogone server', 'description' => '', 'zone' => '*', 'order_status_id' => '1', 'shipping_module' => '*', 'pspid' => '', 'sha_string' => '', 'mode' => 'test', 'method_images' => ''); tep_db_query('CREATE TABLE checkout_' . get_class($this) . '( id INT(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), status VARCHAR(255), title VARCHAR(255), description VARCHAR(255), zone VARCHAR(255), order_status_id INT(11), shipping_module VARCHAR(255), pspid VARCHAR(255), sha_string VARCHAR(255), mode VARCHAR(255), method_images TEXT)'); tep_db_query('CREATE INDEX title ON checkout_' . get_class($this) . ' (`title`)'); tep_db_query('CREATE INDEX status ON checkout_' . get_class($this) . ' (`status`)'); tep_db_query('CREATE INDEX zone ON checkout_' . get_class($this) . ' (`zone`)'); tep_db_query('CREATE INDEX shipping_module ON checkout_' . get_class($this) . ' (`shipping_module`)'); tep_db_perform('checkout_' . get_class($this), $install_array, 'insert'); }
public function __construct($show_step = true) { global $Modules, $temp_orders_id, $cart; if (isset($_GET['install'])) { //check if all translations are available for checkout parent::checkTranslations(dirname(__FILE__), $this->getTranslations()); parent::addCron($min = '0', $hour = '4', $dayOfMonth = '1', $month = '*', $dayOfWeek = '*', $cmd = '/usr/bin/php -q ' . dirname(__FILE__) . '/assets/cron/cron.php'); } $this->modules = $Modules->modules; $goto_next_step = true; $errors = array(); if ($temp_orders_id == 0 && $show_step === true) { //create order in db $temp_orders_id = $this->create_order(); } else { if (basename($_SERVER['HTTP_REFERER']) == 'shopping_cart.php') { $this->add_products_to_db(false); } } if (isset($_POST['checkout_modules'])) { //process all modules from filled in step foreach ($_POST['checkout_modules'] as $module) { global ${$module}; $answer = ${$module}->process_data(); if (count(${$module}->errors) > 0) { self::$errors = array_merge(self::$errors, ${$module}->errors); } if ($answer !== true) { $goto_next_step = false; } } } //Check if we comeback from a payment site foreach ($this->modules as $type => $typedata) { foreach ($typedata as $module) { global ${$module}; if (method_exists(${$module}, 'after_extern_process')) { ${$module}->after_extern_process(); } } } //get step if given if (isset($_POST['checkout_step'])) { $getstep = $_POST['checkout_step']; if ($_POST['checkout_step'] == $this->last_active_step() && count(self::$errors) == 0) { //last step is processed and there were no errors tep_db_query('INSERT INTO temp_orders_steps (orders_id, step, status, errors) VALUES("' . $temp_orders_id . '", "' . $getstep . '", "1", "' . addslashes(serialize(self::$errors)) . '")'); $query = tep_db_query('SELECT payment_method FROM temp_orders WHERE orders_id = "' . $temp_orders_id . '"'); $orders_array = tep_db_fetch_array($query); $instance_id = end(explode('_', $orders_array['payment_method'])); $payment_method = substr($orders_array['payment_method'], 0, -(strlen($instance_id) + 1)); //Check if modules need processing before confirm foreach ($this->modules as $type => $typedata) { foreach ($typedata as $module) { if ($module == $payment_method) { global ${$module}; if (method_exists(${$module}, 'before_confirm')) { ${$module}->before_confirm(); } if (method_exists(${$module}, 'after_confirm')) { $module_error = ${$module}->after_confirm(); if (count($module_error) > 0) { self::$errors = array_merge(self::$errors, $module_error); } } } } } if (count(self::$errors) == 0) { //put data from temp to right db tables $this->get_all_data_from_temp_db($temp_orders_id); $orders_id = $this->put_all_data_in_db($temp_orders_id); //process with orders id foreach ($this->modules as $type => $typedata) { foreach ($typedata as $module) { global ${$module}; if (method_exists(${$module}, 'after_process')) { ${$module}->after_process($orders_id); } } } //send mail to customer and shop owner $this->send_order_mail($orders_id); $cart->reset(true); setcookie('temp_orders_id', '', time() - 3600, '/'); tep_redirect(tep_href_link('checkout_success.php')); } } } if ($temp_orders_id > 0) { if (basename($_SERVER['HTTP_REFERER']) == 'shopping_cart.php') { $last_step = $this->next_active_step(''); } else { $last_step_data = $this->last_filled_in_step($temp_orders_id); $last_step = $last_step_data['step']; } } //if step is asked through get param, force this. //first check if step is available => don't skip steps if (isset($_GET['force_checkout_step'])) { $step = $_GET['force_checkout_step']; } else { if (isset($_GET['checkout_step']) && $temp_orders_id > 0 && $last_step >= $_GET['checkout_step']) { $step = $_GET['checkout_step']; //check if the right step is requested } else { if ($temp_orders_id > 0 && count($_POST) > 0) { if ($getstep == '') { //if page was reloaded this brings the customer back to right step $last_step_data = $this->last_filled_in_step($temp_orders_id); $last_step = $last_step_data['step']; foreach (unserialize($last_step_data['errors']) as $module => $module_data) { global ${$module}; ${$module}->errors = $module_erros; } $getstep = $last_step; $goto_next_step = false; } // @TODO test this //check if prev step is completed if ($prev_step = $this->prev_active_step($getstep)) { $query = tep_db_query('SELECT errors FROM temp_orders_steps WHERE orders_id = "' . $temp_orders_id . '" AND step = "' . $prev_step . '" AND status = "1"'); //no completed step found if (tep_db_num_rows($query) < 0) { $goto_next_step = false; $error_query = tep_db_query('SELECT errors FROM temp_orders_steps WHERE orders_id = "' . $temp_orders_id . '" AND step = "' . $prev_step . '" AND status = "0" ORDER BY date desc LIMIT 1'); $errors_array = tep_db_fetch_array($error_query); foreach (unserialize($errors_array) as $module => $module_erros) { global ${$module}; ${$module}->errors = $module_erros; } //prev active step will be loaded again $step = $prev_step; } } // @TODO eof test if ($goto_next_step) { if ($getstep > 0) { tep_db_query('INSERT INTO temp_orders_steps (orders_id, step, status, errors) VALUES("' . $temp_orders_id . '", "' . $getstep . '", "1", "' . addslashes(serialize(self::$errors)) . '")'); } //get next step with active modules if ($this->last_active_step() == $getstep) { //save all data from temp to orders table // @TODO save data after last step with the use of $temp_orders_id } else { $step = $this->next_active_step($getstep); } } else { tep_db_query('INSERT INTO temp_orders_steps (orders_id, step, status, errors) VALUES("' . $temp_orders_id . '", "' . $getstep . '", "0", "' . addslashes(serialize(self::$errors)) . '")'); $step = $getstep; } } else { if ($temp_orders_id > 0) { if (basename($_SERVER['HTTP_REFERER']) == 'shopping_cart.php') { $last_step = $this->next_active_step(''); } else { //if page was reloaded this brings the customer back to right step $last_step_data = $this->last_filled_in_step($temp_orders_id); $last_step = $last_step_data['step']; $last_step_errors = unserialize($last_step_data['errors']); $count_errors = 0; if (is_array($last_step_errors)) { foreach ($last_step_errors as $module => $module_data) { global ${$module}; ${$module}->errors = $module_data; $count_errors += count($module_data); } } else { ${$module}->errors = array(); } } $step = $last_step; } else { if (!empty($getstep)) { $step = $getstep; } else { $step = $this->next_active_step(''); } } } } } if (empty($step)) { $step = $this->next_active_step(''); } if ($show_step) { echo $this->build_steps($step); } }
private function install() { //Check if translations are available parent::checkTranslations(dirname(__FILE__), $this->getTranslations()); $install_array = array('status' => 'true', 'title' => 'Betaling via beveiligde Europabank server', 'description' => '', 'zone' => '*', 'order_status_id' => '2', 'shipping_module' => '*', 'account_number' => '', 'shared_secret' => '', 'mpi_url' => 'https://www.ebonline.be/test/mpi/authenticate', 'redirect_type' => 'DIRECT', 'min_amount' => '0', 'max_amount' => '999999'); tep_db_query('CREATE TABLE checkout_' . get_class($this) . '( id INT(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), status VARCHAR(255), title VARCHAR(255), description VARCHAR(255), zone VARCHAR(255), order_status_id INT(11), shipping_module VARCHAR(255), account_number VARCHAR(255), shared_secret VARCHAR(255), mpi_url VARCHAR(255), redirect_type VARCHAR(255), min_amount FLOAT(10,2), max_amount FLOAT(10,2))'); tep_db_query('CREATE INDEX title ON checkout_' . get_class($this) . ' (`title`)'); tep_db_query('CREATE INDEX status ON checkout_' . get_class($this) . ' (`status`)'); tep_db_query('CREATE INDEX zone ON checkout_' . get_class($this) . ' (`zone`)'); tep_db_query('CREATE INDEX shipping_module ON checkout_' . get_class($this) . ' (`shipping_module`)'); tep_db_perform('checkout_' . get_class($this), $install_array, 'insert'); }
private function install() { //Check if translations are available parent::checkTranslations(dirname(__FILE__), $this->getTranslations()); $install_array = array('status' => 'true', 'title' => 'Betaling via overschrijving', 'short_description' => 'Van zodra wij uw betaling ontvangen hebben verzenden we uw bestelling.', 'description' => 'STORE_NAME' . "\n" . 'STORE_STREET_ADDRESS' . "\n" . 'STORE_POSTCODE STORE_CITY' . "\n" . 'tep_get_country_name(STORE_COUNTRY_ID)' . "\n" . 'Translate(\'BTW nr\'): STORE_BTW' . "\n" . 'Translate(\'Rek. nr\'): STORE_REKENINGNR', 'zone' => '*', 'order_status_id' => '3', 'shipping_module' => '*'); tep_db_query('CREATE TABLE checkout_' . get_class($this) . '( id INT(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), status VARCHAR(255), title VARCHAR(255), short_description VARCHAR(255), description VARCHAR(255), zone VARCHAR(255), order_status_id INT(11), shipping_module VARCHAR(255))'); tep_db_query('CREATE INDEX title ON checkout_' . get_class($this) . ' (`title`)'); tep_db_query('CREATE INDEX status ON checkout_' . get_class($this) . ' (`status`)'); tep_db_query('CREATE INDEX zone ON checkout_' . get_class($this) . ' (`zone`)'); tep_db_query('CREATE INDEX shipping_module ON checkout_' . get_class($this) . ' (`shipping_module`)'); tep_db_perform('checkout_' . get_class($this), $install_array, 'insert'); }