function _process() { global $osC_Database, $osC_Session, $osC_Language, $osC_ShoppingCart, $messageStack, $osC_Customer, $osC_NavigationHistory, $toC_Wishlist; if (osC_Account::checkEntry($_POST['email_address'])) { if (osC_Account::checkPassword($_POST['password'], $_POST['email_address'])) { if (osC_Account::checkStatus($_POST['email_address'])) { if (SERVICE_SESSION_REGENERATE_ID == '1') { $osC_Session->recreate(); } $osC_Customer->setCustomerData(osC_Account::getID($_POST['email_address'])); $Qupdate = $osC_Database->query('update :table_customers set date_last_logon = :date_last_logon, number_of_logons = number_of_logons+1 where customers_id = :customers_id'); $Qupdate->bindTable(':table_customers', TABLE_CUSTOMERS); $Qupdate->bindRaw(':date_last_logon', 'now()'); $Qupdate->bindInt(':customers_id', $osC_Customer->getID()); $Qupdate->execute(); $osC_ShoppingCart->synchronizeWithDatabase(); $toC_Wishlist->synchronizeWithDatabase(); $osC_NavigationHistory->removeCurrentPage(); if ($osC_NavigationHistory->hasSnapshot()) { $osC_NavigationHistory->redirectToSnapshot(); } else { osc_redirect(osc_href_link(FILENAME_DEFAULT, null, 'AUTO')); } } else { $messageStack->add('login', $osC_Language->get('error_login_status_disabled')); } } else { $messageStack->add('login', $osC_Language->get('error_login_no_match')); } } else { $messageStack->add('login', $osC_Language->get('error_login_no_match')); } }
function _process() { global $messageStack, $osC_Database, $osC_Language, $osC_Customer; $data = array(); $j_to_g = array(); if (ACCOUNT_GENDER == '1') { if (isset($_POST['gender']) && ($_POST['gender'] == 'm' || $_POST['gender'] == 'f')) { $data['gender'] = $_POST['gender']; } else { $messageStack->add($this->_module, $osC_Language->get('field_customer_gender_error')); } } else { $data['gender'] = isset($_POST['gender']) ? $_POST['gender'] : ''; } if (isset($_POST['firstname']) && strlen(trim($_POST['firstname'])) >= ACCOUNT_FIRST_NAME) { $data['firstname'] = $_POST['firstname']; } else { $messageStack->add('account_edit', sprintf($osC_Language->get('field_customer_first_name_error'), ACCOUNT_FIRST_NAME)); } if (isset($_POST['lastname']) && strlen(trim($_POST['lastname'])) >= ACCOUNT_LAST_NAME) { $data['lastname'] = $_POST['lastname']; } else { $messageStack->add('account_edit', sprintf($osC_Language->get('field_customer_last_name_error'), ACCOUNT_LAST_NAME)); } if (ACCOUNT_DATE_OF_BIRTH == '1') { if (isset($_POST['dob_days']) && isset($_POST['dob_months']) && isset($_POST['dob_years']) && jcheckdate($_POST['dob_months'], $_POST['dob_days'], $_POST['dob_years'])) { $j_to_g = jalali_to_gregorian($_POST['dob_years'], $_POST['dob_months'], $_POST['dob_days']); // tabdil shamsi be miladi $data['dob'] = mktime(0, 0, 0, $j_to_g['1'], $j_to_g['2'], $j_to_g['0']); } else { $messageStack->add('account_edit', $osC_Language->get('field_customer_date_of_birth_error')); } } if (isset($_POST['email_address']) && strlen(trim($_POST['email_address'])) >= ACCOUNT_EMAIL_ADDRESS) { if (osc_validate_email_address($_POST['email_address'])) { if (osC_Account::checkDuplicateEntry($_POST['email_address']) === false) { $data['email_address'] = $_POST['email_address']; } else { $messageStack->add('account_edit', $osC_Language->get('field_customer_email_address_exists_error')); } } else { $messageStack->add('account_edit', $osC_Language->get('field_customer_email_address_check_error')); } } else { $messageStack->add('account_edit', sprintf($osC_Language->get('field_customer_email_address_error'), ACCOUNT_EMAIL_ADDRESS)); } if ($messageStack->size('account_edit') === 0) { if (osC_Account::saveEntry($data)) { // reset the session variables if (ACCOUNT_GENDER > -1) { $osC_Customer->setGender($data['gender']); } $osC_Customer->setFirstName(trim($data['firstname'])); $osC_Customer->setLastName(trim($data['lastname'])); $osC_Customer->setEmailAddress($data['email_address']); $messageStack->add_session('account', $osC_Language->get('success_account_updated'), 'success'); } osc_redirect(osc_href_link(FILENAME_ACCOUNT, null, 'SSL')); } }
function _process() { global $osC_MessageStack, $osC_Database, $osC_Language; $Qcheck = $osC_Database->query('select customers_id, customers_firstname, customers_lastname, customers_gender, customers_email_address, customers_password from :table_customers where customers_email_address = :customers_email_address limit 1'); $Qcheck->bindTable(':table_customers', TABLE_CUSTOMERS); $Qcheck->bindValue(':customers_email_address', $_POST['email_address']); $Qcheck->execute(); if ($Qcheck->numberOfRows() === 1) { $password = osc_create_random_string(ACCOUNT_PASSWORD); if (osC_Account::savePassword($password, $Qcheck->valueInt('customers_id'))) { if (ACCOUNT_GENDER > -1) { if ($data['gender'] == 'm') { $email_text = sprintf($osC_Language->get('email_addressing_gender_male'), $Qcheck->valueProtected('customers_lastname')) . "\n\n"; } else { $email_text = sprintf($osC_Language->get('email_addressing_gender_female'), $Qcheck->valueProtected('customers_lastname')) . "\n\n"; } } else { $email_text = sprintf($osC_Language->get('email_addressing_gender_unknown'), $Qcheck->valueProtected('customers_firstname') . ' ' . $Qcheck->valueProtected('customers_lastname')) . "\n\n"; } $email_text .= sprintf($osC_Language->get('email_password_reminder_body'), getenv('REMOTE_ADDR'), STORE_NAME, $password, STORE_OWNER_EMAIL_ADDRESS); osc_email($Qcheck->valueProtected('customers_firstname') . ' ' . $Qcheck->valueProtected('customers_lastname'), $Qcheck->valueProtected('customers_email_address'), sprintf($osC_Language->get('email_password_reminder_subject'), STORE_NAME), $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); $osC_MessageStack->add('login', $osC_Language->get('success_password_forgotten_sent'), 'success'); } osc_redirect(osc_href_link(FILENAME_ACCOUNT, 'login', 'SSL')); } else { $osC_MessageStack->add('password_forgotten', $osC_Language->get('error_password_forgotten_no_email_address_found')); } }
function _process() { global $messageStack, $osC_Database, $osC_Language; $Qcheck = $osC_Database->query('select customers_id, customers_firstname, customers_lastname, customers_gender, customers_email_address, customers_password from :table_customers where customers_email_address = :customers_email_address limit 1'); $Qcheck->bindTable(':table_customers', TABLE_CUSTOMERS); $Qcheck->bindValue(':customers_email_address', $_POST['email_address']); $Qcheck->execute(); if ($Qcheck->numberOfRows() === 1) { $password = osc_create_random_string(ACCOUNT_PASSWORD); if (osC_Account::savePassword($password, $Qcheck->valueInt('customers_id'))) { include 'includes/classes/email_template.php'; $email_template = toC_Email_Template::getEmailTemplate('password_forgotten'); $email_template->setData($Qcheck->valueProtected('customers_firstname'), $Qcheck->valueProtected('customers_lastname'), getenv('REMOTE_ADDR'), $password, $Qcheck->valueProtected('customers_gender'), $Qcheck->valueProtected('customers_email_address')); $email_template->buildMessage(); $email_template->sendEmail(); $messageStack->add_session('login', $osC_Language->get('success_password_forgotten_sent'), 'success'); } osc_redirect(osc_href_link(FILENAME_ACCOUNT, 'login', 'SSL')); } else { $messageStack->add('password_forgotten', $osC_Language->get('error_password_forgotten_no_email_address_found')); } }
function _process() { global $messageStack, $osC_Database, $osC_Language; if (!isset($_POST['password_current']) || strlen(trim($_POST['password_current'])) < ACCOUNT_PASSWORD) { $messageStack->add('account_password', sprintf($osC_Language->get('field_customer_password_current_error'), ACCOUNT_PASSWORD)); } elseif (!isset($_POST['password_new']) || strlen(trim($_POST['password_new'])) < ACCOUNT_PASSWORD) { $messageStack->add('account_password', sprintf($osC_Language->get('field_customer_password_new_error'), ACCOUNT_PASSWORD)); } elseif (!isset($_POST['password_confirmation']) || trim($_POST['password_new']) != trim($_POST['password_confirmation'])) { $messageStack->add('account_password', $osC_Language->get('field_customer_password_new_mismatch_with_confirmation_error')); } if ($messageStack->size('account_password') === 0) { if (osC_Account::checkPassword(trim($_POST['password_current']))) { if (osC_Account::savePassword(trim($_POST['password_new']))) { $messageStack->add_session('account', $osC_Language->get('success_password_updated'), 'success'); osc_redirect(osc_href_link(FILENAME_ACCOUNT, null, 'SSL')); } else { $messageStack->add('account_password', sprintf($osC_Language->get('field_customer_password_new_error'), ACCOUNT_PASSWORD)); } } else { $messageStack->add('account_password', $osC_Language->get('error_current_password_not_matching')); } } }
function _process() { global $messageStack, $osC_Database, $osC_Language, $osC_Customer; $data = array(); if (DISPLAY_PRIVACY_CONDITIONS == '1') { if (isset($_POST['privacy_conditions']) === false || isset($_POST['privacy_conditions']) && $_POST['privacy_conditions'] != '1') { $messageStack->add($this->_module, $osC_Language->get('error_privacy_statement_not_accepted')); } } if (ACCOUNT_GENDER == '1') { if (isset($_POST['gender']) && ($_POST['gender'] == 'm' || $_POST['gender'] == 'f')) { $data['gender'] = $_POST['gender']; } else { $messageStack->add($this->_module, $osC_Language->get('field_customer_gender_error')); } } else { $data['gender'] = isset($_POST['gender']) ? $_POST['gender'] : ''; } if (isset($_POST['firstname']) && strlen(trim($_POST['firstname'])) >= ACCOUNT_FIRST_NAME) { $data['firstname'] = $_POST['firstname']; } else { $messageStack->add($this->_module, sprintf($osC_Language->get('field_customer_first_name_error'), ACCOUNT_FIRST_NAME)); } if (isset($_POST['lastname']) && strlen(trim($_POST['lastname'])) >= ACCOUNT_LAST_NAME) { $data['lastname'] = $_POST['lastname']; } else { $messageStack->add($this->_module, sprintf($osC_Language->get('field_customer_last_name_error'), ACCOUNT_LAST_NAME)); } $data['newsletter'] = isset($_POST['newsletter']) && $_POST['newsletter'] == '1' ? 1 : 0; if (ACCOUNT_DATE_OF_BIRTH == '1') { if (isset($_POST['dob_days']) && isset($_POST['dob_months']) && isset($_POST['dob_years']) && checkdate($_POST['dob_months'], $_POST['dob_days'], $_POST['dob_years'])) { $data['dob'] = mktime(0, 0, 0, $_POST['dob_months'], $_POST['dob_days'], $_POST['dob_years']); } else { $messageStack->add($this->_module, $osC_Language->get('field_customer_date_of_birth_error')); } } if (isset($_POST['email_address']) && strlen(trim($_POST['email_address'])) >= ACCOUNT_EMAIL_ADDRESS) { if (osc_validate_email_address($_POST['email_address'])) { if (osC_Account::checkDuplicateEntry($_POST['email_address']) === false) { $data['email_address'] = $_POST['email_address']; } else { $messageStack->add($this->_module, $osC_Language->get('field_customer_email_address_exists_error')); } } else { $messageStack->add($this->_module, $osC_Language->get('field_customer_email_address_check_error')); } } else { $messageStack->add($this->_module, sprintf($osC_Language->get('field_customer_email_address_error'), ACCOUNT_EMAIL_ADDRESS)); } if (isset($_POST['password']) === false || isset($_POST['password']) && strlen(trim($_POST['password'])) < ACCOUNT_PASSWORD) { $messageStack->add($this->_module, sprintf($osC_Language->get('field_customer_password_error'), ACCOUNT_PASSWORD)); } elseif (isset($_POST['confirmation']) === false || isset($_POST['confirmation']) && trim($_POST['password']) != trim($_POST['confirmation'])) { $messageStack->add($this->_module, $osC_Language->get('field_customer_password_mismatch_with_confirmation')); } else { $data['password'] = $_POST['password']; } if ($messageStack->size($this->_module) === 0) { if (osC_Account::createEntry($data)) { $messageStack->add_session('create', $osC_Language->get('success_account_updated'), 'success'); } osc_redirect(osc_href_link(FILENAME_ACCOUNT, 'create=success', 'SSL')); } }
function insert($order_status = DEFAULT_ORDERS_STATUS_ID) { global $osC_Database, $osC_Customer, $osC_Language, $osC_Currencies, $osC_ShoppingCart, $osC_Tax, $toC_Wishlist; if (isset($_SESSION['prepOrderID'])) { $_prep = explode('-', $_SESSION['prepOrderID']); if ($_prep[0] == $osC_ShoppingCart->getCartID()) { return $_prep[1]; // order_id } else { if (osC_Order::getStatusID($_prep[1]) === ORDERS_STATUS_PREPARING) { osC_Order::remove($_prep[1]); } } } if (!class_exists(osC_Account)) { require_once 'includes/classes/account.php'; } if (!$osC_Customer->isLoggedOn()) { osC_Order::createCustomer(); } else { //insert billing address $billing_address = $osC_ShoppingCart->getBillingAddress(); if (isset($billing_address['id']) && $billing_address['id'] == '-1') { osC_Account::createNewAddress($osC_Customer->getID(), $billing_address); } //insert shipping address if (!isset($billing_address['ship_to_this_address']) || isset($billing_address['ship_to_this_address']) && empty($billing_address['ship_to_this_address'])) { $shipping_address = $osC_ShoppingCart->getShippingAddress(); if (isset($shipping_address['id']) && $shipping_address['id'] == '-1') { osC_Account::createNewAddress($osC_Customer->getID(), $shipping_address); } } } $Qorder = $osC_Database->query('insert into :table_orders (customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_comment, customers_state_code, customers_country, customers_country_iso2, customers_country_iso3, customers_telephone, customers_email_address, customers_address_format, customers_ip_address, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_zone_id, delivery_state_code, delivery_country_id, delivery_country, delivery_country_iso2, delivery_country_iso3, delivery_address_format, delivery_telephone, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_zone_id, billing_state_code, billing_country_id, billing_country, billing_country_iso2, billing_country_iso3, billing_address_format, billing_telephone, payment_method, payment_module, uses_store_credit, store_credit_amount, date_purchased, orders_status, currency, currency_value, gift_wrapping, wrapping_message) values (:customers_id, :customers_name, :customers_company, :customers_street_address, :customers_suburb, :customers_city, :customers_postcode, :customers_state, :customers_comment, :customers_state_code, :customers_country, :customers_country_iso2, :customers_country_iso3, :customers_telephone, :customers_email_address, :customers_address_format, :customers_ip_address, :delivery_name, :delivery_company, :delivery_street_address, :delivery_suburb, :delivery_city, :delivery_postcode, :delivery_state, :delivery_zone_id, :delivery_state_code, :delivery_country_id, :delivery_country, :delivery_country_iso2, :delivery_country_iso3, :delivery_address_format, :delivery_telephone, :billing_name, :billing_company, :billing_street_address, :billing_suburb, :billing_city, :billing_postcode, :billing_state, :billing_zone_id, :billing_state_code, :billing_country_id, :billing_country, :billing_country_iso2, :billing_country_iso3, :billing_address_format, :billing_telephone, :payment_method, :payment_module, :uses_store_credit, :store_credit_amount, now(), :orders_status, :currency, :currency_value, :gift_wrapping, :wrapping_message)'); $Qorder->bindTable(':table_orders', TABLE_ORDERS); $Qorder->bindInt(':customers_id', $osC_Customer->getID()); $Qorder->bindValue(':customers_name', $osC_Customer->getName()); $Qorder->bindValue(':customers_company', ''); $Qorder->bindValue(':customers_street_address', ''); $Qorder->bindValue(':customers_suburb', ''); $Qorder->bindValue(':customers_city', ''); $Qorder->bindValue(':customers_postcode', ''); $Qorder->bindValue(':customers_state', ''); $Qorder->bindValue(':customers_state_code', ''); $Qorder->bindValue(':customers_country', ''); $Qorder->bindValue(':customers_country_iso2', ''); $Qorder->bindValue(':customers_country_iso3', ''); $Qorder->bindValue(':customers_telephone', ''); $Qorder->bindValue(':customers_email_address', $osC_Customer->getEmailAddress()); $Qorder->bindValue(':customers_comment', $_SESSION['comments']); $Qorder->bindValue(':customers_address_format', ''); $Qorder->bindValue(':customers_ip_address', osc_get_ip_address()); $Qorder->bindValue(':delivery_name', $osC_ShoppingCart->getShippingAddress('firstname') . ' ' . $osC_ShoppingCart->getShippingAddress('lastname')); $Qorder->bindValue(':delivery_company', $osC_ShoppingCart->getShippingAddress('company')); $Qorder->bindValue(':delivery_street_address', $osC_ShoppingCart->getShippingAddress('street_address')); $Qorder->bindValue(':delivery_suburb', $osC_ShoppingCart->getShippingAddress('suburb')); $Qorder->bindValue(':delivery_city', $osC_ShoppingCart->getShippingAddress('city')); $Qorder->bindValue(':delivery_postcode', $osC_ShoppingCart->getShippingAddress('postcode')); $Qorder->bindValue(':delivery_state', $osC_ShoppingCart->getShippingAddress('state')); $Qorder->bindValue(':delivery_zone_id', $osC_ShoppingCart->getShippingAddress('zone_id')); $Qorder->bindValue(':delivery_state_code', $osC_ShoppingCart->getShippingAddress('zone_code')); $Qorder->bindValue(':delivery_country_id', $osC_ShoppingCart->getShippingAddress('country_id')); $Qorder->bindValue(':delivery_country', $osC_ShoppingCart->getShippingAddress('country_title')); $Qorder->bindValue(':delivery_country_iso2', $osC_ShoppingCart->getShippingAddress('country_iso_code_2')); $Qorder->bindValue(':delivery_country_iso3', $osC_ShoppingCart->getShippingAddress('country_iso_code_3')); $Qorder->bindValue(':delivery_address_format', $osC_ShoppingCart->getShippingAddress('format')); $Qorder->bindValue(':delivery_telephone', $osC_ShoppingCart->getShippingAddress('telephone_number')); $Qorder->bindValue(':billing_name', $osC_ShoppingCart->getBillingAddress('firstname') . ' ' . $osC_ShoppingCart->getBillingAddress('lastname')); $Qorder->bindValue(':billing_company', $osC_ShoppingCart->getBillingAddress('company')); $Qorder->bindValue(':billing_street_address', $osC_ShoppingCart->getBillingAddress('street_address')); $Qorder->bindValue(':billing_suburb', $osC_ShoppingCart->getBillingAddress('suburb')); $Qorder->bindValue(':billing_city', $osC_ShoppingCart->getBillingAddress('city')); $Qorder->bindValue(':billing_postcode', $osC_ShoppingCart->getBillingAddress('postcode')); $Qorder->bindValue(':billing_state', $osC_ShoppingCart->getBillingAddress('state')); $Qorder->bindValue(':billing_zone_id', $osC_ShoppingCart->getBillingAddress('zone_id')); $Qorder->bindValue(':billing_state_code', $osC_ShoppingCart->getBillingAddress('zone_code')); $Qorder->bindValue(':billing_country_id', $osC_ShoppingCart->getBillingAddress('country_id')); $Qorder->bindValue(':billing_country', $osC_ShoppingCart->getBillingAddress('country_title')); $Qorder->bindValue(':billing_country_iso2', $osC_ShoppingCart->getBillingAddress('country_iso_code_2')); $Qorder->bindValue(':billing_country_iso3', $osC_ShoppingCart->getBillingAddress('country_iso_code_3')); $Qorder->bindValue(':billing_address_format', $osC_ShoppingCart->getBillingAddress('format')); $Qorder->bindValue(':billing_telephone', $osC_ShoppingCart->getBillingAddress('telephone_number')); $Qorder->bindValue(':payment_method', implode(',', $osC_ShoppingCart->getCartBillingMethods())); $Qorder->bindValue(':payment_module', implode(',', $osC_ShoppingCart->getCartBillingModules())); $Qorder->bindInt(':uses_store_credit', $osC_ShoppingCart->isUseStoreCredit()); $Qorder->bindValue(':store_credit_amount', $osC_ShoppingCart->isUseStoreCredit() ? $osC_ShoppingCart->getStoreCredit() : '0'); $Qorder->bindInt(':orders_status', $order_status); $Qorder->bindValue(':currency', $osC_Currencies->getCode()); $Qorder->bindValue(':currency_value', $osC_Currencies->value($osC_Currencies->getCode())); $Qorder->bindInt(':gift_wrapping', $osC_ShoppingCart->isGiftWrapping() ? '1' : '0'); $Qorder->bindValue(':wrapping_message', isset($_SESSION['gift_wrapping_comments']) ? $_SESSION['gift_wrapping_comments'] : ''); $Qorder->execute(); $insert_id = $osC_Database->nextID(); foreach ($osC_ShoppingCart->getOrderTotals() as $module) { $Qtotals = $osC_Database->query('insert into :table_orders_total (orders_id, title, text, value, class, sort_order) values (:orders_id, :title, :text, :value, :class, :sort_order)'); $Qtotals->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL); $Qtotals->bindInt(':orders_id', $insert_id); $Qtotals->bindValue(':title', $module['title']); $Qtotals->bindValue(':text', $module['text']); $Qtotals->bindValue(':value', $module['value']); $Qtotals->bindValue(':class', $module['code']); $Qtotals->bindInt(':sort_order', $module['sort_order']); $Qtotals->execute(); } $Qstatus = $osC_Database->query('insert into :table_orders_status_history (orders_id, orders_status_id, date_added, customer_notified, comments) values (:orders_id, :orders_status_id, now(), :customer_notified, :comments)'); $Qstatus->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY); $Qstatus->bindInt(':orders_id', $insert_id); $Qstatus->bindInt(':orders_status_id', $order_status); $Qstatus->bindInt(':customer_notified', '0'); $Qstatus->bindValue(':comments', isset($_SESSION['comments']) ? $_SESSION['comments'] : ''); $Qstatus->execute(); foreach ($osC_ShoppingCart->getProducts() as $products) { $Qproducts = $osC_Database->query('insert into :table_orders_products (orders_id, products_id, products_type, products_sku, products_name, products_price, final_price, products_tax, products_quantity) values (:orders_id, :products_id, :products_type, :products_sku, :products_name, :products_price, :final_price, :products_tax, :products_quantity)'); $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS); $Qproducts->bindInt(':orders_id', $insert_id); $Qproducts->bindInt(':products_id', osc_get_product_id($products['id'])); $Qproducts->bindValue(':products_type', $products['type']); $Qproducts->bindValue(':products_sku', $products['sku']); $Qproducts->bindValue(':products_name', $products['name']); $Qproducts->bindValue(':products_price', $products['price']); $Qproducts->bindValue(':final_price', $products['final_price']); $Qproducts->bindValue(':products_tax', $osC_Tax->getTaxRate($products['tax_class_id'], $osC_ShoppingCart->getTaxingAddress('country_id'), $osC_ShoppingCart->getTaxingAddress('zone_id'))); $Qproducts->bindInt(':products_quantity', $products['quantity']); $Qproducts->execute(); $order_products_id = $osC_Database->nextID(); if (!empty($products['customizations'])) { foreach ($products['customizations'] as $customization) { $Qcustomization = $osC_Database->query('insert into :table_orders_products_customizations (orders_id, orders_products_id, quantity) values (:orders_id, :orders_products_id, :quantity)'); $Qcustomization->bindTable(':table_orders_products_customizations', TABLE_ORDERS_PRODUCTS_CUSTOMIZATIONS); $Qcustomization->bindInt(':orders_id', $insert_id); $Qcustomization->bindInt(':orders_products_id', $order_products_id); $Qcustomization->bindInt(':quantity', $customization['qty']); $Qcustomization->execute(); $orders_products_customizations_id = $osC_Database->nextID(); foreach ($customization['fields'] as $field) { $Qfield = $osC_Database->query('insert into :table_orders_products_customizations_values (orders_products_customizations_id , customization_fields_id, customization_fields_name, customization_fields_type, customization_fields_value, cache_file_name) values (:orders_products_customizations_id, :customization_fields_id, :customization_fields_name, :customization_fields_type, :customization_fields_value, :cache_file_name)'); $Qfield->bindTable(':table_orders_products_customizations_values', TABLE_ORDERS_PRODUCTS_CUSTOMIZATIONS_VALUES); $Qfield->bindInt(':orders_products_customizations_id', $orders_products_customizations_id); $Qfield->bindInt(':customization_fields_id', $field['customization_fields_id']); $Qfield->bindValue(':customization_fields_name', $field['customization_fields_name']); $Qfield->bindInt(':customization_fields_type', $field['customization_type']); $Qfield->bindValue(':customization_fields_value', $field['customization_value']); $Qfield->bindValue(':cache_file_name', $field['cache_filename']); $Qfield->execute(); if ($osC_Database->isError() === false) { @copy(DIR_FS_CACHE . 'products_customizations/' . $field['cache_filename'], DIR_FS_CACHE . 'orders_customizations/' . $field['cache_filename']); } } } } if ($osC_ShoppingCart->hasVariants($products['id'])) { foreach ($osC_ShoppingCart->getVariants($products['id']) as $variants_id => $variants) { $Qvariants = $osC_Database->query('select pvg.products_variants_groups_name, pvv.products_variants_values_name from :table_products_variants pv, :table_products_variants_entries pve, :table_products_variants_groups pvg, :table_products_variants_values pvv where pv.products_id = :products_id and pv.products_variants_id = pve.products_variants_id and pve.products_variants_groups_id = :groups_id and pve.products_variants_values_id = :variants_values_id and pve.products_variants_groups_id = pvg.products_variants_groups_id and pve.products_variants_values_id = pvv.products_variants_values_id and pvg.language_id = :pvg_language_id and pvv.language_id = :pvv_language_id'); $Qvariants->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS); $Qvariants->bindTable(':table_products_variants_entries', TABLE_PRODUCTS_VARIANTS_ENTRIES); $Qvariants->bindTable(':table_products_variants_groups', TABLE_PRODUCTS_VARIANTS_GROUPS); $Qvariants->bindTable(':table_products_variants_values', TABLE_PRODUCTS_VARIANTS_VALUES); $Qvariants->bindInt(':products_id', $products['id']); $Qvariants->bindInt(':groups_id', $variants['groups_id']); $Qvariants->bindInt(':variants_values_id', $variants['variants_values_id']); $Qvariants->bindInt(':pvg_language_id', $osC_Language->getID()); $Qvariants->bindInt(':pvv_language_id', $osC_Language->getID()); $Qvariants->execute(); $Qopv = $osC_Database->query('insert into :table_orders_products_variants (orders_id, orders_products_id, products_variants_groups_id, products_variants_groups, products_variants_values_id, products_variants_values) values (:orders_id, :orders_products_id, :products_variants_groups_id, :products_variants_groups, :products_variants_values_id, :products_variants_values)'); $Qopv->bindTable(':table_orders_products_variants', TABLE_ORDERS_PRODUCTS_VARIANTS); $Qopv->bindInt(':orders_id', $insert_id); $Qopv->bindInt(':orders_products_id', $order_products_id); $Qopv->bindInt(':products_variants_groups_id', $variants['groups_id']); $Qopv->bindValue(':products_variants_groups', $Qvariants->value('products_variants_groups_name')); $Qopv->bindInt(':products_variants_values_id', $variants['variants_values_id']); $Qopv->bindValue(':products_variants_values', $Qvariants->value('products_variants_values_name')); $Qopv->execute(); } } if ($products['type'] == PRODUCT_TYPE_DOWNLOADABLE) { $Qdownloadable = $osC_Database->query('select * from :table_products_downloadables where products_id = :products_id'); $Qdownloadable->bindTable(':table_products_downloadables', TABLE_PRODUCTS_DOWNLOADABLES); $Qdownloadable->bindInt(':products_id', osc_get_product_id($products['id'])); $Qdownloadable->execute(); if ($osC_ShoppingCart->hasVariants($products['id'])) { $variants_filename = $products['variant_filename']; $variants_cache_filename = $products['variant_cache_filename']; } else { $variants_filename = $Qdownloadable->value('filename'); $variants_cache_filename = $Qdownloadable->value('cache_filename'); } $Qopd = $osC_Database->query('insert into :table_orders_products_download (orders_id, orders_products_id, orders_products_filename, orders_products_cache_filename, download_maxdays, download_count) values (:orders_id, :orders_products_id, :orders_products_filename, :orders_products_cache_filename, :download_maxdays, :download_count)'); $Qopd->bindTable(':table_orders_products_download', TABLE_ORDERS_PRODUCTS_DOWNLOAD); $Qopd->bindInt(':orders_id', $insert_id); $Qopd->bindInt(':orders_products_id', $order_products_id); $Qopd->bindValue(':orders_products_filename', $variants_filename); $Qopd->bindValue(':orders_products_cache_filename', $variants_cache_filename); $Qopd->bindValue(':download_maxdays', $Qdownloadable->valueInt('number_of_accessible_days')); $Qopd->bindValue(':download_count', $Qdownloadable->valueInt('number_of_downloads') * $products['quantity']); $Qopd->execute(); } if ($products['type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) { require_once 'gift_certificates.php'; $Qgc = $osC_Database->query('insert into :table_gift_certificates (orders_id, orders_products_id, gift_certificates_type, amount, gift_certificates_code, recipients_name, recipients_email, senders_name, senders_email, messages) values (:orders_id, :orders_products_id, :gift_certificates_type, :amount, :gift_certificates_code, :recipients_name, :recipients_email, :senders_name, :senders_email, :messages)'); $Qgc->bindTable(':table_gift_certificates', TABLE_GIFT_CERTIFICATES); $Qgc->bindInt(':orders_id', $insert_id); $Qgc->bindInt(':gift_certificates_type', $products['gc_data']['type']); $Qgc->bindInt(':orders_products_id', $order_products_id); $Qgc->bindValue(':amount', $products['price']); $Qgc->bindValue(':gift_certificates_code', toC_Gift_Certificates::createGiftCertificateCode()); $Qgc->bindValue(':recipients_name', $products['gc_data']['recipients_name']); $Qgc->bindValue(':recipients_email', $products['gc_data']['type'] == GIFT_CERTIFICATE_TYPE_EMAIL ? $products['gc_data']['recipients_email'] : ''); $Qgc->bindValue(':senders_name', $products['gc_data']['senders_name']); $Qgc->bindValue(':senders_email', $products['gc_data']['type'] == GIFT_CERTIFICATE_TYPE_EMAIL ? $products['gc_data']['senders_email'] : ''); $Qgc->bindValue(':messages', $products['gc_data']['message']); $Qgc->execute(); } } if ($osC_ShoppingCart->isUseStoreCredit()) { $Qhistory = $osC_Database->query('insert into :table_customers_credits_history (customers_id, action_type, date_added, amount, comments) values (:customers_id, :action_type, now(), :amount, :comments)'); $Qhistory->bindTable(':table_customers_credits_history', TABLE_CUSTOMERS_CREDITS_HISTORY); $Qhistory->bindInt(':customers_id', $osC_Customer->getID()); $Qhistory->bindInt(':action_type', STORE_CREDIT_ACTION_TYPE_ORDER_PURCHASE); $Qhistory->bindValue(':amount', $osC_ShoppingCart->getStoreCredit() * -1); $Qhistory->bindValue(':comments', sprintf($osC_Language->get('store_credit_order_number'), $insert_id)); $Qhistory->execute(); $Qcustomer = $osC_Database->query('update :table_customers set customers_credits = (customers_credits + :customers_credits) where customers_id = :customers_id'); $Qcustomer->bindTable(':table_customers', TABLE_CUSTOMERS); $Qcustomer->bindRaw(':customers_credits', $osC_ShoppingCart->getStoreCredit() * -1); $Qcustomer->bindInt(':customers_id', $osC_Customer->getID()); $Qcustomer->execute(); $Qcredit = $osC_Database->query('select customers_credits from :table_customers where customers_id = :customers_id'); $Qcredit->bindTable(':table_customers', TABLE_CUSTOMERS); $Qcredit->bindInt(':customers_id', $osC_Customer->getID()); $Qcredit->execute(); $osC_Customer->setStoreCredit($Qcredit->value('customers_credits')); } if ($osC_ShoppingCart->hasCoupon()) { include_once 'includes/classes/coupon.php'; $toC_Coupon = new toC_Coupon($osC_ShoppingCart->getCouponCode()); $Qcoupon = $osC_Database->query('insert into :table_coupons_redeem_history (coupons_id, customers_id, orders_id, redeem_amount, redeem_date, redeem_ip_address) values (:coupons_id, :customers_id, :orders_id, :redeem_amount, now(), :redeem_ip_address)'); $Qcoupon->bindTable(':table_coupons_redeem_history', TABLE_COUPONS_REDEEM_HISTORY); $Qcoupon->bindInt(':coupons_id', $toC_Coupon->getID()); $Qcoupon->bindInt(':customers_id', $osC_Customer->getID()); $Qcoupon->bindInt(':orders_id', $insert_id); $Qcoupon->bindValue(':redeem_amount', $osC_ShoppingCart->getCouponAmount()); $Qcoupon->bindValue(':redeem_ip_address', osc_get_ip_address()); $Qcoupon->execute(); } if ($osC_ShoppingCart->hasGiftCertificate()) { $gift_certificate_codes = $osC_ShoppingCart->getGiftCertificateRedeemAmount(); foreach ($gift_certificate_codes as $gift_certificate_code => $amount) { $Qcertificate = $osC_Database->query('select gift_certificates_id from :table_gift_certificates where gift_certificates_code = :gift_certificates_code'); $Qcertificate->bindTable(':table_gift_certificates', TABLE_GIFT_CERTIFICATES); $Qcertificate->bindValue(':gift_certificates_code', $gift_certificate_code); $Qcertificate->execute(); $Qinsert = $osC_Database->query('insert into :table_gift_certificates_redeem_history (gift_certificates_id, customers_id, orders_id, redeem_date, redeem_amount, redeem_ip_address) values (:gift_certificates_id, :customers_id, :orders_id, now(), :redeem_amount, :redeem_ip_address)'); $Qinsert->bindTable(':table_gift_certificates_redeem_history', TABLE_GIFT_CERTIFICATES_REDEEM_HISTORY); $Qinsert->bindInt(':gift_certificates_id', $Qcertificate->valueInt(gift_certificates_id)); $Qinsert->bindInt(':customers_id', $osC_Customer->getID()); $Qinsert->bindInt(':orders_id', $insert_id); $Qinsert->bindValue(':redeem_amount', $amount); $Qinsert->bindValue(':redeem_ip_address', osc_get_ip_address()); $Qinsert->execute(); } } $_SESSION['prepOrderID'] = $osC_ShoppingCart->getCartID() . '-' . $insert_id; return $insert_id; }
<?php /* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2006 osCommerce This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v2 (1991) as published by the Free Software Foundation. */ $Qaccount = osC_Account::getEntry(); ?> <?php echo osc_image(DIR_WS_IMAGES . $osC_Template->getPageImage(), $osC_Template->getPageTitle(), HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT, 'id="pageIcon"'); ?> <h1><?php echo $osC_Template->getPageTitle(); ?> </h1> <?php if ($osC_MessageStack->size('account_edit') > 0) { echo $osC_MessageStack->get('account_edit'); } ?>
function saveBillingAddress() { global $toC_Json, $osC_Language, $osC_Database, $osC_ShoppingCart, $osC_Customer; $data = array(); $errors = array(); $osC_Language->load('checkout'); if (!$osC_Customer->isLoggedOn()) { if (!isset($_REQUEST['billing_email_address']) || !(strlen(trim($_REQUEST['billing_email_address'])) >= ACCOUNT_EMAIL_ADDRESS)) { $errors[] = sprintf($osC_Language->get('field_customer_email_address_error'), ACCOUNT_EMAIL_ADDRESS); } else { if (!osc_validate_email_address($_REQUEST['billing_email_address'])) { $errors[] = $osC_Language->get('field_customer_email_address_check_error'); } else { if (osC_Account::checkDuplicateEntry($_REQUEST['billing_email_address']) === true) { $errors[] = $osC_Language->get('field_customer_email_address_exists_error'); } else { $data['email_address'] = $_REQUEST['billing_email_address']; } } } if (isset($_REQUEST['billing_password']) === false || isset($_REQUEST['billing_password']) && strlen(trim($_REQUEST['billing_password'])) < ACCOUNT_PASSWORD) { $errors[] = sprintf($osC_Language->get('field_customer_password_error'), ACCOUNT_PASSWORD); } elseif (isset($_REQUEST['billing_confirm_password']) === false || isset($_REQUEST['billing_confirm_password']) && trim($_REQUEST['billing_password']) != trim($_REQUEST['billing_confirm_password'])) { $errors[] = $osC_Language->get('field_customer_password_mismatch_with_confirmation'); } else { $data['password'] = $_REQUEST['billing_password']; } } if (!$osC_Customer->isLoggedOn() || $osC_Customer->isLoggedOn() && isset($_REQUEST['create_billing_address']) && $_REQUEST['create_billing_address'] == 1) { if (ACCOUNT_GENDER == '1') { if (isset($_REQUEST['billing_gender']) && ($_REQUEST['billing_gender'] == 'm' || $_REQUEST['billing_gender'] == 'f')) { $data['gender'] = $_REQUEST['billing_gender']; } else { $errors[] = $osC_Language->get('field_customer_gender_error'); } } else { $data['gender'] = isset($_REQUEST['billing_gender']) ? $_REQUEST['billing_gender'] : ''; } if (isset($_REQUEST['billing_firstname']) && strlen(trim($_REQUEST['billing_firstname'])) >= ACCOUNT_FIRST_NAME) { $data['firstname'] = $_REQUEST['billing_firstname']; } else { $errors[] = sprintf($osC_Language->get('field_customer_first_name_error'), ACCOUNT_FIRST_NAME); } if (isset($_REQUEST['billing_lastname']) && strlen(trim($_REQUEST['billing_lastname'])) >= ACCOUNT_LAST_NAME) { $data['lastname'] = $_REQUEST['billing_lastname']; } else { $errors[] = sprintf($osC_Language->get('field_customer_last_name_error'), ACCOUNT_LAST_NAME); } if (ACCOUNT_COMPANY > -1) { if (isset($_REQUEST['billing_company']) && strlen(trim($_REQUEST['billing_company'])) >= ACCOUNT_COMPANY) { $data['company'] = $_REQUEST['billing_company']; } else { $errors[] = sprintf($osC_Language->get('field_customer_company_error'), ACCOUNT_COMPANY); } } if (isset($_REQUEST['billing_street_address']) && strlen(trim($_REQUEST['billing_street_address'])) >= ACCOUNT_STREET_ADDRESS) { $data['street_address'] = $_REQUEST['billing_street_address']; } else { $errors[] = sprintf($osC_Language->get('field_customer_street_address_error'), ACCOUNT_STREET_ADDRESS); } if (ACCOUNT_SUBURB >= 0) { if (isset($_REQUEST['billing_suburb']) && strlen(trim($_REQUEST['billing_suburb'])) >= ACCOUNT_SUBURB) { $data['suburb'] = $_REQUEST['billing_suburb']; } else { $errors[] = sprintf($osC_Language->get('field_customer_suburb_error'), ACCOUNT_SUBURB); } } if (ACCOUNT_POST_CODE > -1) { if (isset($_REQUEST['billing_postcode']) && strlen(trim($_REQUEST['billing_postcode'])) >= ACCOUNT_POST_CODE) { $data['postcode'] = $_REQUEST['billing_postcode']; } else { $errors[] = sprintf($osC_Language->get('field_customer_post_code_error'), ACCOUNT_POST_CODE); } } if (isset($_REQUEST['billing_city']) && strlen(trim($_REQUEST['billing_city'])) >= ACCOUNT_CITY) { $data['city'] = $_REQUEST['billing_city']; } else { $errors[] = sprintf($osC_Language->get('field_customer_city_error'), ACCOUNT_CITY); } if (ACCOUNT_STATE >= 0) { $Qcheck = $osC_Database->query('select zone_id from :table_zones where zone_country_id = :zone_country_id limit 1'); $Qcheck->bindTable(':table_zones', TABLE_ZONES); $Qcheck->bindInt(':zone_country_id', $_REQUEST['billing_country']); $Qcheck->execute(); $entry_state_has_zones = $Qcheck->numberOfRows() > 0; if ($entry_state_has_zones === true) { $Qzone = $osC_Database->query('select zone_id from :table_zones where zone_country_id = :zone_country_id and zone_code like :zone_code'); $Qzone->bindTable(':table_zones', TABLE_ZONES); $Qzone->bindInt(':zone_country_id', $_REQUEST['billing_country']); $Qzone->bindValue(':zone_code', $_REQUEST['billing_state']); $Qzone->execute(); if ($Qzone->numberOfRows() === 1) { $data['zone_id'] = $Qzone->valueInt('zone_id'); } else { $Qzone = $osC_Database->query('select zone_id from :table_zones where zone_country_id = :zone_country_id and zone_name like :zone_name'); $Qzone->bindTable(':table_zones', TABLE_ZONES); $Qzone->bindInt(':zone_country_id', $_REQUEST['billing_country']); $Qzone->bindValue(':zone_name', $_REQUEST['billing_state'] . '%'); $Qzone->execute(); if ($Qzone->numberOfRows() === 1) { $data['zone_id'] = $Qzone->valueInt('zone_id'); } else { $errors[] = $osC_Language->get('field_customer_state_select_pull_down_error'); } } } else { if (strlen(trim($_REQUEST['billing_state'])) >= ACCOUNT_STATE) { $data['state'] = $_REQUEST['billing_state']; } else { $errors[] = sprintf($osC_Language->get('field_customer_state_error'), ACCOUNT_STATE); } } } else { if (strlen(trim($_REQUEST['billing_state'])) >= ACCOUNT_STATE) { $data['state'] = $_REQUEST['billing_state']; } else { $errors[] = sprintf($osC_Language->get('field_customer_state_error'), ACCOUNT_STATE); } } if (isset($_REQUEST['billing_country']) && is_numeric($_REQUEST['billing_country']) && $_REQUEST['billing_country'] >= 1) { $data['country_id'] = $_REQUEST['billing_country']; } else { $errors[] = $osC_Language->get('field_customer_country_error'); } if (ACCOUNT_TELEPHONE >= 0) { if (isset($_REQUEST['billing_telephone']) && strlen(trim($_REQUEST['billing_telephone'])) >= ACCOUNT_TELEPHONE) { $data['telephone'] = $_REQUEST['billing_telephone']; } else { $errors[] = sprintf($osC_Language->get('field_customer_telephone_number_error'), ACCOUNT_TELEPHONE); } } if (ACCOUNT_FAX >= 0) { if (isset($_REQUEST['billing_fax']) && strlen(trim($_REQUEST['billing_fax'])) >= ACCOUNT_FAX) { $data['fax'] = $_REQUEST['billing_fax']; } else { $errors[] = sprintf($osC_Language->get('field_customer_fax_number_error'), ACCOUNT_FAX); } } } if (sizeof($errors) > 0) { $response = array('success' => false, 'errors' => $errors); } else { $data['ship_to_this_address'] = 0; if (isset($_REQUEST['ship_to_this_address']) && $_REQUEST['ship_to_this_address'] == '1') { $data['ship_to_this_address'] = 1; } if ($osC_Customer->isLoggedOn()) { if (isset($_REQUEST['create_billing_address']) && $_REQUEST['create_billing_address'] == '1') { $osC_ShoppingCart->setRawBillingAddress($data); if (isset($_REQUEST['ship_to_this_address']) && $_REQUEST['ship_to_this_address'] == '1') { $osC_ShoppingCart->setRawShippingAddress($data); } } else { $osC_ShoppingCart->setBillingAddress($_REQUEST['billing_address_id']); if (isset($_REQUEST['ship_to_this_address']) && $_REQUEST['ship_to_this_address'] == '1') { $osC_ShoppingCart->setShippingAddress($_REQUEST['billing_address_id']); } } } else { $osC_ShoppingCart->setRawBillingAddress($data); if (isset($_REQUEST['ship_to_this_address']) && $_REQUEST['ship_to_this_address'] == '1') { $osC_ShoppingCart->setRawShippingAddress($data); } } if ($osC_ShoppingCart->isVirtualCart()) { $form = self::_getPaymentMethodForm(); $response = array('success' => true, 'form' => $form['form'], 'javascript' => $form['javascript']); } else { if (isset($_REQUEST['ship_to_this_address']) && $_REQUEST['ship_to_this_address'] == '1') { $form = self::_getShippingMethodForm(); $response = array('success' => true, 'form' => $form); } else { $form = self::_getShippingInformationForm(); $response = array('success' => true, 'form' => $form); } } } echo $toC_Json->encode($response); }
function _get_express_checkout_details($params) { global $osC_ShoppingCart, $osC_Currencies, $osC_Language, $osC_Database, $osC_Tax, $messageStack, $osC_Customer, $osC_Session; // if there is nothing in the customers cart, redirect them to the shopping cart page if (!$osC_ShoppingCart->hasContents()) { osc_redirect(osc_href_link(FILENAME_CHECKOUT, '', 'SSL', true, true, true)); } $params['VERSION'] = $this->api_version; $params['METHOD'] = 'GetExpressCheckoutDetails'; $params['TOKEN'] = $_GET['token']; $post_string = ''; foreach ($params as $key => $value) { $post_string .= $key . '=' . urlencode(utf8_encode(trim($value))) . '&'; } $post_string = substr($post_string, 0, -1); $response = $this->sendTransactionToGateway($this->api_url, $post_string); $response_array = array(); parse_str($response, $response_array); if ($response_array['ACK'] == 'Success' || $response_array['ACK'] == 'SuccessWithWarning') { $force_login = false; // Begin: check if e-mail address exists in database and login or create customer account if ($osC_Customer->isLoggedOn() == false) { $force_login = true; if (class_exists('osC_Account') == false) { require_once 'includes/classes/account.php'; } $email_address = $response_array['EMAIL']; $Qcheck = $osC_Database->query('select * from :table_customers where customers_email_address = :email_address limit 1'); $Qcheck->bindTable(':table_customers', TABLE_CUSTOMERS); $Qcheck->bindValue(':email_address', $email_address); $Qcheck->execute(); if ($Qcheck->numberOfRows() > 0) { $check = $Qcheck->toArray(); $customer_id = $check['customers_id']; $osC_Customer->setCustomerData($customer_id); } else { $data = array('firstname' => $response_array['FIRSTNAME'], 'lastname' => $response_array['LASTNAME'], 'email_address' => $email_address, 'password' => osc_rand(ACCOUNT_PASSWORD, max(ACCOUNT_PASSWORD, 8))); osC_Account::createEntry($data); } $Qcheck->freeResult(); if (SERVICE_SESSION_REGENERATE_ID == '1') { $osC_Session->recreate(); } } // End: check if e-mail address exists in database and login or create customer account // Begin: Add shipping and billing address from paypal to the shopping cart if ($force_login == true) { $country_query = $osC_Database->query('select countries_id, countries_name, countries_iso_code_2, countries_iso_code_3, address_format from :table_countries where countries_iso_code_2 = :country_iso_code_2'); $country_query->bindTable(':table_countries', TABLE_COUNTRIES); $country_query->bindValue(':country_iso_code_2', $response_array['SHIPTOCOUNTRYCODE']); $country_query->execute(); $country = $country_query->toArray(); $zone_name = $response_array['SHIPTOSTATE']; $zone_id = 0; $zone_query = $osC_Database->query('select zone_id, zone_name from :table_zones where zone_country_id = :zone_country_id and zone_code = :zone_code'); $zone_query->bindTable(':table_zones', TABLE_ZONES); $zone_query->bindInt(':zone_country_id', $country['countries_id']); $zone_query->bindValue(':zone_code', $response_array['SHIPTOSTATE']); $zone_query->execute(); if ($zone_query->numberOfRows()) { $zone = $zone_query->toArray(); $zone_name = $zone['zone_name']; $zone_id = $zone['zone_id']; } $sendto = array('firstname' => substr($response_array['SHIPTONAME'], 0, strpos($response_array['SHIPTONAME'], ' ')), 'lastname' => substr($response_array['SHIPTONAME'], strpos($response_array['SHIPTONAME'], ' ') + 1), 'company' => '', 'street_address' => $response_array['SHIPTOSTREET'], 'suburb' => '', 'email_address' => $response_array['EMAIL'], 'postcode' => $response_array['SHIPTOZIP'], 'city' => $response_array['SHIPTOCITY'], 'zone_id' => $zone_id, 'zone_name' => $zone_name, 'country_id' => $country['countries_id'], 'country_name' => $country['countries_name'], 'country_iso_code_2' => $country['countries_iso_code_2'], 'country_iso_code_3' => $country['countries_iso_code_3'], 'address_format_id' => $country['address_format_id'] > 0 ? $country['address_format_id'] : '1'); $osC_ShoppingCart->setRawShippingAddress($sendto); $osC_ShoppingCart->setRawBillingAddress($sendto); $osC_ShoppingCart->setBillingMethod(array('id' => $this->getCode(), 'title' => $this->getMethodTitle())); } // End: Add shipping and billing address from paypal to the shopping cart //Begin: Add the shipping if ($osC_ShoppingCart->getContentType() != 'virtual') { if ($osC_ShoppingCart->hasShippingMethod() === false) { if (class_exists('osC_Shipping') === false) { include_once 'includes/classes/shipping.php'; } $osC_Shipping = new osC_Shipping(); if ($osC_Shipping->hasQuotes()) { $shipping_set = false; // get all available shipping quotes $quotes = $osC_Shipping->getQuotes(); if (isset($response_array['SHIPPINGOPTIONNAME']) && isset($response_array['SHIPPINGOPTIONAMOUNT'])) { foreach ($quotes as $quote) { if (!isset($quote['error'])) { foreach ($quote['methods'] as $rate) { if ($response_array['SHIPPINGOPTIONNAME'] == $quote['module'] . ' (' . $rate['title'] . ')') { if ($response_array['SHIPPINGOPTIONAMOUNT'] == $osC_Currencies->formatRaw($rate['cost'] + $quote['cost'] * $quote['tax'] / 100)) { $shipping = $quote['id'] . '_' . $rate['id']; $module = 'osC_Shipping_' . $quote['module']; if (is_object($GLOBALS[$module]) && $GLOBALS[$module]->isEnabled()) { $quote = $osC_Shipping->getQuote($shipping); if (isset($quote['error'])) { $osC_ShoppingCart->resetShippingMethod(); $errors[] = $quote['error']; } else { $osC_ShoppingCart->setShippingMethod($quote); $shipping_set = true; } } else { $osC_ShoppingCart->resetShippingMethod(); } break 2; } } } } } } if ($shipping_set == false) { // select cheapest shipping method $osC_ShoppingCart->setShippingMethod($osC_Shipping->getCheapestQuote()); } } } } if (!isset($_SESSION['ppe_token'])) { $_SESSION['ppe_token'] = $response_array['TOKEN']; } if (!isset($_SESSION['ppe_payerid'])) { $_SESSION['ppe_payerid'] = $response_array['PAYERID']; } if (!isset($_SESSION['ppe_payerstatus'])) { $_SESSION['ppe_payerstatus'] = $response_array['PAYERSTATUS']; } if (!isset($_SESSION['ppe_addressstatus'])) { $_SESSION['ppe_addressstatus'] = $response_array['ADDRESSSTATUS']; } osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'process', 'SSL')); } else { $messageStack->add_session('shopping_cart', $osC_Language->get('payment_paypal_express_error_title') . ' <strong>' . stripslashes($response_array['L_LONGMESSAGE0']) . '</strong>'); osc_redirect(osc_href_link(FILENAME_CHECKOUT, '', 'SSL')); } }