function initialize() { global $osC_Database, $osC_Cache, $osC_Language, $osC_Currencies, $osC_Image, $current_category_id; $data = array(); if (MODULE_CONTENT_NEW_PRODUCTS_CACHE > 0 && $osC_Cache->read('new_products-' . $osC_Language->getCode() . '-' . $osC_Currencies->getCode() . '-' . $current_category_id, MODULE_CONTENT_NEW_PRODUCTS_CACHE)) { $data = $osC_Cache->getCache(); } else { if ($current_category_id < 1) { $Qproducts = $osC_Database->query('select products_id from :table_products where products_status = :products_status and parent_id is null order by products_date_added desc limit :max_display_new_products'); } else { $Qproducts = $osC_Database->query('select distinct p2c.products_id from :table_products p, :table_products_to_categories p2c, :table_categories c where c.parent_id = :category_parent_id and c.categories_id = p2c.categories_id and p2c.products_id = p.products_id and p.products_status = :products_status and p.parent_id is null order by p.products_date_added desc limit :max_display_new_products'); $Qproducts->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES); $Qproducts->bindTable(':table_categories', TABLE_CATEGORIES); $Qproducts->bindInt(':category_parent_id', $current_category_id); } $Qproducts->bindTable(':table_products', TABLE_PRODUCTS); $Qproducts->bindInt(':products_status', 1); $Qproducts->bindInt(':max_display_new_products', MODULE_CONTENT_NEW_PRODUCTS_MAX_DISPLAY); $Qproducts->execute(); while ($Qproducts->next()) { $osC_Product = new osC_Product($Qproducts->valueInt('products_id')); $data[$osC_Product->getID()] = $osC_Product->getData(); $data[$osC_Product->getID()]['display_price'] = $osC_Product->getPriceFormated(true); $data[$osC_Product->getID()]['display_image'] = $osC_Product->getImage(); } $osC_Cache->write($data); } if (!empty($data)) { $this->_content = '<div style="overflow: auto; height: 100%;">'; foreach ($data as $product) { $this->_content .= '<span style="width: 33%; float: left; text-align: center;">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $product['keyword']), $osC_Image->show($product['display_image'], $product['name'])) . '<br />' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $product['keyword']), $product['name']) . '<br />' . $product['display_price'] . '</span>'; } $this->_content .= '</div>'; } }
function execute() { global $osC_Database, $osC_Session, $osC_NavigationHistory, $osC_Customer; if (!$osC_Customer->isLoggedOn()) { $osC_NavigationHistory->setSnapshot(); osc_redirect(osc_href_link(FILENAME_ACCOUNT, 'login', 'SSL')); return false; } $id = false; foreach ($_GET as $key => $value) { if ((ereg('^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && $key != $osC_Session->getName()) { $id = $key; } break; } if ($id !== false && osC_Product::checkEntry($id)) { $osC_Product = new osC_Product($id); $Qcheck = $osC_Database->query('select products_id from :table_products_notifications where customers_id = :customers_id and products_id = :products_id limit 1'); $Qcheck->bindTable(':table_products_notifications', TABLE_PRODUCTS_NOTIFICATIONS); $Qcheck->bindInt(':customers_id', $osC_Customer->getID()); $Qcheck->bindInt(':products_id', $osC_Product->getID()); $Qcheck->execute(); if ($Qcheck->numberOfRows() > 0) { $Qn = $osC_Database->query('delete from :table_products_notifications where customers_id = :customers_id and products_id = :products_id'); $Qn->bindTable(':table_products_notifications', TABLE_PRODUCTS_NOTIFICATIONS); $Qn->bindInt(':customers_id', $osC_Customer->getID()); $Qn->bindInt(':products_id', $osC_Product->getID()); $Qn->execute(); } } osc_redirect(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), osc_get_all_get_params(array('action')))); }
function execute() { global $osC_Session, $osC_ShoppingCart, $osC_Product, $osC_Language, $messageStack, $toC_Customization_Fields; if (!isset($osC_Product)) { $id = false; foreach ($_GET as $key => $value) { if ((ereg('^[0-9]+(_?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && $key != $osC_Session->getName()) { $id = $key; } break; } if (strpos($id, '_') !== false) { $id = str_replace('_', '#', $id); } if ($id !== false && osC_Product::checkEntry($id)) { $osC_Product = new osC_Product($id); } } if (isset($osC_Product)) { //customization fields check if ($osC_Product->hasRequiredCustomizationFields()) { if (!$toC_Customization_Fields->exists($osC_Product->getID())) { $osC_Language->load('products'); $messageStack->add_session('products', $osC_Language->get('error_customization_fields_missing'), 'error'); osc_redirect(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getID())); } } $variants = null; if (isset($_POST['variants']) && is_array($_POST['variants'])) { $variants = $_POST['variants']; } else { if (isset($_GET['variants']) && !empty($_GET['variants'])) { $variants = osc_parse_variants_string($_GET['variants']); } } $gift_certificate_data = null; if ($osC_Product->isGiftCertificate() && isset($_POST['senders_name']) && isset($_POST['recipients_name']) && isset($_POST['message'])) { if ($osC_Product->isEmailGiftCertificate()) { $gift_certificate_data = array('senders_name' => $_POST['senders_name'], 'senders_email' => $_POST['senders_email'], 'recipients_name' => $_POST['recipients_name'], 'recipients_email' => $_POST['recipients_email'], 'message' => $_POST['message']); } else { $gift_certificate_data = array('senders_name' => $_POST['senders_name'], 'recipients_name' => $_POST['recipients_name'], 'message' => $_POST['message']); } if ($osC_Product->isOpenAmountGiftCertificate()) { $gift_certificate_data['price'] = $_POST['gift_certificate_amount']; } $gift_certificate_data['type'] = $osC_Product->getGiftCertificateType(); } $quantity = null; if (isset($_POST['quantity']) && is_numeric($_POST['quantity'])) { $quantity = $_POST['quantity']; } if ($osC_Product->isGiftCertificate() && $gift_certificate_data == null) { osc_redirect(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getID())); return false; } else { $osC_ShoppingCart->add($osC_Product->getID(), $variants, $quantity, $gift_certificate_data); } } osc_redirect(osc_href_link(FILENAME_CHECKOUT)); }
function execute() { global $osC_Session, $osC_Product, $toC_Customization_Fields, $osC_Language, $messageStack; if (!isset($osC_Product)) { $id = false; foreach ($_GET as $key => $value) { if ((ereg('^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && $key != $osC_Session->getName()) { $id = $key; } break; } if ($id !== false && osC_Product::checkEntry($id)) { $osC_Product = new osC_Product($id); } } if (isset($osC_Product)) { $errors = array(); $data = array(); $customizations = $osC_Product->getCustomizations(); foreach ($customizations as $field) { $fields_id = $field['customization_fields_id']; if ($field['type'] == CUSTOMIZATION_FIELD_TYPE_INPUT_TEXT) { $value = isset($_POST['customizations'][$fields_id]) ? $_POST['customizations'][$fields_id] : null; if ($field['is_required'] && $value == null) { $messageStack->add_session('products_customizations', sprintf($osC_Language->get('error_customization_field_must_be_specified'), $field['name']), 'error'); } else { if ($value != null) { $data[$fields_id] = array('customization_fields_id' => $field['customization_fields_id'], 'customization_fields_name' => $field['name'], 'customization_type' => CUSTOMIZATION_FIELD_TYPE_INPUT_TEXT, 'customization_value' => $value); } } } else { $file = new upload('customizations_' . $fields_id, DIR_FS_CACHE . '/products_customizations/'); if ($field['is_required'] && !$file->exists() && !$toC_Customization_Fields->hasCustomizationField($osC_Product->getID(), $fields_id)) { $messageStack->add_session('products', sprintf($osC_Language->get('error_customization_field_must_be_specified'), $field['name']), 'error'); } else { if ($file->exists()) { if ($file->parse() && $file->save()) { $filename = $file->filename; $cache_filename = md5($filename . time()); rename(DIR_FS_CACHE . '/products_customizations/' . $filename, DIR_FS_CACHE . '/products_customizations/' . $cache_filename); $data[$fields_id] = array('customization_fields_id' => $field['customization_fields_id'], 'customization_fields_name' => $field['name'], 'customization_type' => CUSTOMIZATION_FIELD_TYPE_INPUT_FILE, 'customization_value' => $filename, 'cache_filename' => $cache_filename); } else { $messageStack->add_session('products_customizations', $file->getLastError(), 'error'); } } } } } //var_dump($data);exit; if ($messageStack->size('products_customizations') === 0) { $toC_Customization_Fields->set($osC_Product->getID(), $data); } } osc_redirect(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getID())); }
function execute() { global $osC_Session, $osC_ShoppingCart, $osC_Product; if (!isset($osC_Product)) { $id = false; foreach ($_GET as $key => $value) { if ((ereg('^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && $key != $osC_Session->getName()) { $id = $key; } break; } if ($id !== false && osC_Product::checkEntry($id)) { $osC_Product = new osC_Product($id); } } if (isset($osC_Product)) { $variants = null; if (isset($_POST['variants']) && is_array($_POST['variants'])) { $variants = $_POST['variants']; } else { if (isset($_GET['variants']) && !empty($_GET['variants'])) { $variants = osc_parse_variants_string($_GET['variants']); } } $gift_certificate_data = null; if ($osC_Product->isGiftCertificate() && isset($_POST['senders_name']) && isset($_POST['recipients_name']) && isset($_POST['message'])) { if ($osC_Product->isEmailGiftCertificate()) { $gift_certificate_data = array('senders_name' => $_POST['senders_name'], 'senders_email' => $_POST['senders_email'], 'recipients_name' => $_POST['recipients_name'], 'recipients_email' => $_POST['recipients_email'], 'message' => $_POST['message']); } else { $gift_certificate_data = array('senders_name' => $_POST['senders_name'], 'recipients_name' => $_POST['recipients_name'], 'message' => $_POST['message']); } if ($osC_Product->isOpenAmountGiftCertificate()) { $gift_certificate_data['price'] = $_POST['gift_certificate_amount']; } $gift_certificate_data['type'] = $osC_Product->getGiftCertificateType(); } $quantity = null; if (isset($_POST['quantity']) && is_numeric($_POST['quantity'])) { $quantity = $_POST['quantity']; } if ($osC_Product->hasVariants() && empty($variants) || $osC_Product->isGiftCertificate() && $gift_certificate_data == null) { osc_redirect(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getID())); return false; } else { $osC_ShoppingCart->add($osC_Product->getID(), $variants, $quantity, $gift_certificate_data); } } osc_redirect(osc_href_link(FILENAME_CHECKOUT)); }
function execute() { global $osC_Session, $osC_ShoppingCart; $id = false; foreach ($_GET as $key => $value) { if ((ereg('^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && $key != $osC_Session->getName()) { $id = $key; } break; } if ($id !== false && osC_Product::checkEntry($id)) { $osC_Product = new osC_Product($id); $product_id = $osC_Product->getID(); //gift certificate use timestamp as variant if ($osC_Product->isGiftCertificate()) { $product_id .= '#' . $_GET['variants']; } else { if (isset($_GET['variants']) && ereg('^([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*$', $_GET['variants'])) { $product_id .= '#' . $_GET['variants']; } } $osC_ShoppingCart->remove($product_id); } osc_redirect(osc_href_link(FILENAME_CHECKOUT)); }
function execute() { global $osC_Session, $osC_ShoppingCart, $osC_Product; if (!isset($osC_Product)) { $id = false; foreach ($_GET as $key => $value) { if ((is_numeric($key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && $key != $osC_Session->getName()) { $id = $key; } break; } if ($id !== false && osC_Product::checkEntry($id)) { $osC_Product = new osC_Product($id); } } if (isset($osC_Product)) { if ($osC_Product->hasVariants()) { if (isset($_POST['variants']) && is_array($_POST['variants']) && !empty($_POST['variants'])) { if ($osC_Product->variantExists($_POST['variants'])) { $osC_ShoppingCart->add($osC_Product->getProductVariantID($_POST['variants'])); } else { osc_redirect(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getKeyword())); return false; } } else { osc_redirect(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getKeyword())); return false; } } else { $osC_ShoppingCart->add($osC_Product->getID()); } } osc_redirect(osc_href_link(FILENAME_CHECKOUT)); }
function execute() { global $osC_Session, $toC_Wishlist, $osC_Product; $id = false; foreach ($_GET as $key => $value) { if ((ereg('^[0-9]+(_?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && $key != $osC_Session->getName()) { $id = $key; } break; } //change the variants in the product info page, then attach the wid param to represent the variant product if (isset($_GET['wid']) && preg_match('/^[0-9]+(_?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$/', $_GET['wid'])) { $id = $_GET['wid']; } if (strpos($id, '_') !== false) { $id = str_replace('_', '#', $id); } if ($id !== false && osC_Product::checkEntry($id)) { $osC_Product = new osC_Product($id); } if (isset($osC_Product)) { $variants = null; if (isset($_POST['variants']) && is_array($_POST['variants'])) { $variants = $_POST['variants']; } else { if (isset($_GET['variants']) && !empty($_GET['variants'])) { $variants = osc_parse_variants_string($_GET['variants']); } else { if (strpos($id, '#') !== false) { $variants = osc_parse_variants_from_id_string($id); } } } if (!osc_empty($variants)) { $toC_Wishlist->add($osC_Product->getID(), $variants); } else { $toC_Wishlist->add($osC_Product->getID()); } } osc_redirect(osc_href_link(FILENAME_ACCOUNT, 'wishlist')); }
function osC_Products_Tell_a_friend() { global $osC_Services, $osC_Session, $osC_Language, $breadcrumb, $osC_Customer, $osC_NavigationHistory, $osC_Product; if (ALLOW_GUEST_TO_TELL_A_FRIEND == '-1' && $osC_Customer->isLoggedOn() === false) { $osC_NavigationHistory->setSnapshot(); osc_redirect(osc_href_link(FILENAME_ACCOUNT, 'login', 'SSL')); } $counter = 0; foreach ($_GET as $key => $value) { $counter++; if ($counter < 2) { continue; } if ((ereg('^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && $key != $osC_Session->getName()) { if (osC_Product::checkEntry($key) === false) { $this->_page_title = $osC_Language->get('product_not_found_heading'); $this->_page_contents = 'info_not_found.php'; } else { $osC_Product = new osC_Product($key); $this->_page_title = $osC_Product->getTitle(); if ($osC_Services->isStarted('breadcrumb')) { $breadcrumb->add($osC_Product->getTitle(), osc_href_link(FILENAME_PRODUCTS, $osC_Product->getID())); $breadcrumb->add($osC_Language->get('breadcrumb_tell_a_friend'), osc_href_link(FILENAME_PRODUCTS, $this->_module . '&' . $osC_Product->getID())); } if (isset($_GET['action']) && $_GET['action'] == 'process') { $this->_process(); } } break; } } if ($counter < 2) { $this->_page_title = $osC_Language->get('product_not_found_heading'); $this->_page_contents = 'info_not_found.php'; } }
function execute() { global $osC_Database, $osC_Session, $osC_NavigationHistory, $osC_Customer; if (!$osC_Customer->isLoggedOn()) { $osC_NavigationHistory->setSnapshot(); osc_redirect(osc_href_link(FILENAME_ACCOUNT, 'login', 'SSL')); return false; } $notifications = array(); if (isset($_GET['products']) && !empty($_GET['products'])) { $products_array = explode(';', $_GET['products']); foreach ($products_array as $product_id) { if (is_numeric($product_id) && !in_array($product_id, $notifications)) { $notifications[] = $product_id; } } } else { $id = false; foreach ($_GET as $key => $value) { if ((ereg('^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && $key != $osC_Session->getName()) { $id = $key; } break; } if ($id !== false && osC_Product::checkEntry($id)) { $osC_Product = new osC_Product($id); $notifications[] = $osC_Product->getID(); } } if (!empty($notifications)) { foreach ($notifications as $product_id) { $Qcheck = $osC_Database->query('select products_id from :table_products_notifications where customers_id = :customers_id and products_id = :products_id limit 1'); $Qcheck->bindTable(':table_products_notifications', TABLE_PRODUCTS_NOTIFICATIONS); $Qcheck->bindInt(':customers_id', $osC_Customer->getID()); $Qcheck->bindInt(':products_id', $product_id); $Qcheck->execute(); if ($Qcheck->numberOfRows() < 1) { $Qn = $osC_Database->query('insert into :table_products_notifications (products_id, customers_id, date_added) values (:products_id, :customers_id, :date_added)'); $Qn->bindTable(':table_products_notifications', TABLE_PRODUCTS_NOTIFICATIONS); $Qn->bindInt(':products_id', $product_id); $Qn->bindInt(':customers_id', $osC_Customer->getID()); $Qn->bindRaw(':date_added', 'now()'); $Qn->execute(); } } } osc_redirect(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), osc_get_all_get_params(array('action')))); }
function execute() { global $osC_Session, $toC_Wishlist, $osC_Product; if (!isset($osC_Product)) { $id = false; foreach ($_GET as $key => $value) { if ((ereg('^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && $key != $osC_Session->getName()) { $id = $key; } break; } if ($id !== false && osC_Product::checkEntry($id)) { $osC_Product = new osC_Product($id); } } if (isset($osC_Product)) { $toC_Wishlist->add($osC_Product->getID()); } osc_redirect(osc_href_link(FILENAME_ACCOUNT, 'wishlist')); }
function addProduct() { global $osC_ShoppingCart, $toC_Json, $osC_Language, $toC_Customization_Fields; $osC_Language->load('products'); if (is_numeric($_REQUEST['pID']) && osC_Product::checkEntry($_REQUEST['pID'])) { $osC_ShoppingCart->resetShippingMethod(); $osC_Product = new osC_Product($_REQUEST['pID']); //gift certificate check if ($osC_Product->isGiftCertificate() && !isset($_POST['senders_name'])) { $response = array('success' => false, 'feedback' => $osC_Language->get('error_gift_certificate_data_missing')); } else { if ($osC_Product->hasRequiredCustomizationFields() && !$toC_Customization_Fields->exists($osC_Product->getID())) { $response = array('success' => false, 'feedback' => $osC_Language->get('error_customization_fields_missing')); } else { $variants = null; if (isset($_REQUEST['variants']) && !empty($_REQUEST['variants'])) { $variants = osc_parse_variants_string($_REQUEST['variants']); } $gift_certificate_data = null; if ($osC_Product->isGiftCertificate() && isset($_POST['senders_name']) && isset($_POST['recipients_name']) && isset($_POST['message'])) { if ($osC_Product->isEmailGiftCertificate()) { $gift_certificate_data = array('senders_name' => $_POST['senders_name'], 'senders_email' => $_POST['senders_email'], 'recipients_name' => $_POST['recipients_name'], 'recipients_email' => $_POST['recipients_email'], 'message' => $_POST['message']); } else { $gift_certificate_data = array('senders_name' => $_POST['senders_name'], 'recipients_name' => $_POST['recipients_name'], 'message' => $_POST['message']); } if ($osC_Product->isOpenAmountGiftCertificate()) { $gift_certificate_data['price'] = $_POST['gift_certificate_amount']; } $gift_certificate_data['type'] = $osC_Product->getGiftCertificateType(); } $osC_ShoppingCart->add($_REQUEST['pID'], $variants, $_REQUEST['pQty'], $gift_certificate_data); $content = self::_getShoppingCart(); $response = array('success' => true, 'content' => $content); } } } else { $response = array('success' => false); } echo $toC_Json->encode($response); }
function getProducts() { $history = array(); if (isset($this->visits['products']) && empty($this->visits['products']) === false) { $counter = 0; foreach ($this->visits['products'] as $k => $v) { $counter++; $osC_Product = new osC_Product($v['id']); $osC_Category = new osC_Category($osC_Product->getCategoryID()); if ($osC_Product->isValid() === true) { $history[] = array('name' => $osC_Product->getTitle(), 'id' => $osC_Product->getID(), 'keyword' => $osC_Product->getKeyword(), 'price' => SERVICE_RECENTLY_VISITED_SHOW_PRODUCT_PRICES == '1' ? $osC_Product->getPriceFormated(true) : '', 'image' => $osC_Product->getImage(), 'category_name' => $osC_Category->getTitle(), 'category_path' => $osC_Category->getPath()); } if ($counter == SERVICE_RECENTLY_VISITED_MAX_PRODUCTS) { break; } } } return $history; }
function addProduct() { global $osC_ShoppingCart, $toC_Json, $osC_Language, $toC_Customization_Fields, $osC_Image, $osC_Currencies; $osC_Language->load('products'); if (is_numeric($_POST['pID']) && osC_Product::checkEntry($_POST['pID'])) { $osC_ShoppingCart->resetShippingMethod(); $osC_Product = new osC_Product($_POST['pID']); //gift certificate check if ($osC_Product->isGiftCertificate() && !isset($_POST['senders_name'])) { $response = array('success' => false, 'feedback' => $osC_Language->get('error_gift_certificate_data_missing')); } else { if ($osC_Product->hasRequiredCustomizationFields() && !$toC_Customization_Fields->exists($osC_Product->getID())) { $response = array('success' => false, 'feedback' => $osC_Language->get('error_customization_fields_missing')); } else { $variants = null; if (isset($_POST['variants']) && !empty($_POST['variants'])) { $variants = osc_parse_variants_string($_POST['variants']); } $gift_certificate_data = null; if ($osC_Product->isGiftCertificate() && isset($_POST['senders_name']) && isset($_POST['recipients_name']) && isset($_POST['message'])) { if ($osC_Product->isEmailGiftCertificate()) { $gift_certificate_data = array('senders_name' => $_POST['senders_name'], 'senders_email' => $_POST['senders_email'], 'recipients_name' => $_POST['recipients_name'], 'recipients_email' => $_POST['recipients_email'], 'message' => $_POST['message']); } else { $gift_certificate_data = array('senders_name' => $_POST['senders_name'], 'recipients_name' => $_POST['recipients_name'], 'message' => $_POST['message']); } if ($osC_Product->isOpenAmountGiftCertificate()) { $gift_certificate_data['price'] = $_POST['gift_certificate_amount']; } $gift_certificate_data['type'] = $osC_Product->getGiftCertificateType(); } $osC_ShoppingCart->add($_POST['pID'], $variants, $_POST['pQty'], $gift_certificate_data); $items = 0; foreach ($osC_ShoppingCart->getProducts() as $products_id => $data) { $items += $data['quantity']; } //build the content of the confirmation dialog $product_id_string = osc_get_product_id_string($_POST['pID'], $variants); //find the added product $added_product = null; foreach ($osC_ShoppingCart->getProducts() as $id_string => $product) { if ($product_id_string == $id_string) { $added_product = $product; break; } } //build the dialog $confirm_dialog = null; if ($added_product !== null) { $confirm_dialog .= '<div class="dlgConfirm">' . '<div class="itemImage">' . $osC_Image->show($added_product['image'], $added_product['name'], '', 'thumbnail') . '</div>' . '<div class="itemDetail"><p>' . sprintf($osC_Language->get('add_to_cart_confirmation'), $added_product['quantity'] . ' x ' . osc_link_object(osc_href_link(FILENAME_CHECKOUT, null, 'SSL'), $added_product['name'])); //gift certificates if ($added_product['type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) { $confirm_dialog .= '<br />- ' . $osC_Language->get('senders_name') . ': ' . $product['gc_data']['senders_name']; if ($added_product['gc_data']['type'] == GIFT_CERTIFICATE_TYPE_EMAIL) { $confirm_dialog .= '<br />- ' . $osC_Language->get('senders_email') . ': ' . $product['gc_data']['senders_email']; } $confirm_dialog .= '<br />- ' . $osC_Language->get('recipients_name') . ': ' . $product['gc_data']['recipients_name']; if ($added_product['gc_data']['type'] == GIFT_CERTIFICATE_TYPE_EMAIL) { $confirm_dialog .= '<br />- ' . $osC_Language->get('recipients_email') . ': ' . $product['gc_data']['recipients_email']; } $confirm_dialog .= '<br />- ' . $osC_Language->get('message') . ': ' . $product['gc_data']['message']; } $confirm_dialog .= '</p>'; //variants products if ($osC_ShoppingCart->hasVariants($product['id'])) { foreach ($osC_ShoppingCart->getVariants($product['id']) as $variants) { $confirm_dialog .= '<div>'; $confirm_dialog .= '<strong>' . $variants['groups_name'] . ' - </strong><strong>' . $variants['values_name'] . '</strong></tr>'; $confirm_dialog .= '</div>'; } } $confirm_dialog .= '</div>'; //cart total $confirm_dialog .= '<p><strong>' . $osC_ShoppingCart->numberOfItems() . ' ' . $osC_Language->get('text_items') . '</strong> - <strong>' . $osC_Currencies->format($osC_ShoppingCart->getTotal()) . '</strong></p>'; //bottom buttons $confirm_dialog .= '<div class="btns">' . osc_link_object(osc_href_link(FILENAME_CHECKOUT, 'checkout', 'SSL'), osc_draw_image_button('button_checkout.gif', $osC_Language->get('button_checkout'))) . osc_link_object(osc_href_link(FILENAME_CHECKOUT, 'cart', 'SSL'), osc_draw_image_button('button_ajax_cart.png')) . osc_link_object(osc_href_link(FILENAME_DEFAULT), osc_draw_image_button('button_continue.gif'), 'id="btnContinue"') . '</div>'; $confirm_dialog .= '</div>'; } $response = array('success' => true, 'items' => $items, 'confirm_dialog' => $confirm_dialog); } } } else { $response = array('success' => false); } echo $toC_Json->encode($response); }
function add($products_id_string, $variants = null, $quantity = null, $gift_certificates_data = null, $action = 'add') { global $osC_Database, $osC_Services, $osC_Language, $osC_Customer, $osC_Image, $toC_Wishlist; $products_id = osc_get_product_id($products_id_string); $osC_Product = new osC_Product($products_id); if ($osC_Product->isGiftCertificate()) { if ($variants == null || empty($variants)) { $products_id_string = $products_id . '#' . time(); } else { $products_id_string = $products_id . '#' . $variants; //set variants to null $variants = null; } } else { $products_id_string = osc_get_product_id_string($products_id_string, $variants); } if ($osC_Product->getID() > 0) { if ($toC_Wishlist->hasProduct($products_id)) { $toC_Wishlist->deleteProduct($products_id); } if ($this->exists($products_id_string)) { if (!is_numeric($quantity)) { $quantity = $this->getQuantity($products_id_string) + 1; } else { if (is_numeric($quantity) && $quantity == 0) { $this->remove($products_id_string); return; } else { if ($action == 'add') { $quantity = $this->getQuantity($products_id_string) + $quantity; } else { if ($action == 'update') { $quantity = $quantity; } } } } if ($osC_Product->isGiftCertificate()) { if ($quantity > 1) { $quantity = 1; $error = $osC_Language->get('error_gift_certificate_quantity_must_be_one'); } } //check minimum order quantity $products_moq = $osC_Product->getMOQ(); if ($quantity < $products_moq) { $quantity = $products_moq; $error = sprintf($osC_Language->get('error_minimum_order_quantity'), $osC_Product->getTitle(), $products_moq); } //check maximum order quantity $products_max_order_quantity = $osC_Product->getMaxOrderQuantity(); if ($products_max_order_quantity > 0) { if ($quantity > $products_max_order_quantity) { $quantity = $products_max_order_quantity; $error = sprintf($osC_Language->get('error_maximum_order_quantity'), $osC_Product->getTitle(), $products_max_order_quantity); } } //check order increment $increment = $osC_Product->getOrderIncrement(); if (($quantity - $products_moq) % $increment != 0) { $quantity = $products_moq + (floor(($quantity - $products_moq) / $increment) + 1) * $increment; $error = sprintf($osC_Language->get('error_order_increment'), $osC_Product->getTitle(), $increment); } //set error to session if (isset($error) && !empty($error)) { $this->_contents[$products_id_string]['error'] = $error; } if ($osC_Product->isGiftCertificate() && $osC_Product->isOpenAmountGiftCertificate()) { $price = $this->_contents[$products_id_string]['price']; } else { $price = $osC_Product->getPrice($variants, $quantity); if ($osC_Services->isStarted('specials')) { global $osC_Specials; if ($new_price = $osC_Specials->getPrice($products_id)) { $price = $new_price; } } } $this->_contents[$products_id_string]['quantity'] = $quantity; $this->_contents[$products_id_string]['price'] = $price; $this->_contents[$products_id_string]['final_price'] = $price; // update database if ($osC_Customer->isLoggedOn()) { $Qupdate = $osC_Database->query('update :table_customers_basket set customers_basket_quantity = :customers_basket_quantity, gift_certificates_data = :gift_certificates_data where customers_id = :customers_id and products_id = :products_id'); $Qupdate->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET); $Qupdate->bindInt(':customers_basket_quantity', $quantity); if ($osC_Product->getProductType() == PRODUCT_TYPE_GIFT_CERTIFICATE) { $Qupdate->bindValue(':gift_certificates_data', serialize($gift_certificates_data)); } else { $Qupdate->bindRaw(':gift_certificates_data', 'null'); } $Qupdate->bindInt(':customers_id', $osC_Customer->getID()); $Qupdate->bindValue(':products_id', $products_id_string); $Qupdate->execute(); } } else { if (!is_numeric($quantity)) { $quantity = 1; } if ($osC_Product->isGiftCertificate()) { if ($quantity > 1) { $quantity = 1; $error = $osC_Language->get('error_gift_certificate_quantity_must_be_one'); } } //check minimum order quantity $products_moq = $osC_Product->getMOQ(); if ($quantity < $products_moq) { $quantity = $products_moq; $error = sprintf($osC_Language->get('error_minimum_order_quantity'), $osC_Product->getTitle(), $products_moq); } //check order increment $increment = $osC_Product->getOrderIncrement(); if (($quantity - $products_moq) % $increment != 0) { $quantity = $products_moq + (floor(($quantity - $products_moq) / $increment) + 1) * $increment; $error = sprintf($osC_Language->get('error_order_increment'), $osC_Product->getTitle(), $increment); } if ($osC_Product->isGiftCertificate() && $osC_Product->isOpenAmountGiftCertificate()) { $price = $gift_certificates_data['price']; } else { $price = $osC_Product->getPrice($variants, $quantity); if ($osC_Services->isStarted('specials')) { global $osC_Specials; if ($new_price = $osC_Specials->getPrice($products_id)) { $price = $new_price; } } } $this->_contents[$products_id_string] = array('id' => $products_id_string, 'name' => $osC_Product->getTitle(), 'type' => $osC_Product->getProductType(), 'keyword' => $osC_Product->getKeyword(), 'sku' => $osC_Product->getSKU($variants), 'image' => $osC_Product->getImage(), 'price' => $price, 'final_price' => $price, 'quantity' => $quantity, 'weight' => $osC_Product->getWeight($variants), 'tax_class_id' => $osC_Product->getTaxClassID(), 'date_added' => osC_DateTime::getShort(osC_DateTime::getNow()), 'weight_class_id' => $osC_Product->getWeightClass(), 'gc_data' => $gift_certificates_data); //set error to session if (isset($error) && !empty($error)) { $this->_contents[$products_id_string]['error'] = $error; } // insert into database if ($osC_Customer->isLoggedOn()) { $Qnew = $osC_Database->query('insert into :table_customers_basket (customers_id, products_id, customers_basket_quantity, gift_certificates_data, customers_basket_date_added) values (:customers_id, :products_id, :customers_basket_quantity, :gift_certificates_data, now())'); $Qnew->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET); $Qnew->bindInt(':customers_id', $osC_Customer->getID()); $Qnew->bindValue(':products_id', $products_id_string); $Qnew->bindInt(':customers_basket_quantity', $quantity); if ($osC_Product->getProductType() == PRODUCT_TYPE_GIFT_CERTIFICATE) { $Qnew->bindValue(':gift_certificates_data', serialize($gift_certificates_data)); } else { $Qnew->bindRaw(':gift_certificates_data', 'null'); } $Qnew->execute(); } if (is_array($variants) && !empty($variants)) { foreach ($variants as $group_id => $value_id) { $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 = :language_id and pvv.language_id = :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', $osC_Product->getID()); $Qvariants->bindInt(':groups_id', $group_id); $Qvariants->bindInt(':variants_values_id', $value_id); $Qvariants->bindInt(':language_id', $osC_Language->getID()); $Qvariants->bindInt(':language_id', $osC_Language->getID()); $Qvariants->execute(); $this->_contents[$products_id_string]['variants'][$group_id] = array('groups_id' => $group_id, 'variants_values_id' => $value_id, 'groups_name' => $Qvariants->value('products_variants_groups_name'), 'values_name' => $Qvariants->value('products_variants_values_name')); } } } $this->_cleanUp(); $this->_calculate(); } }
$lc_align = ''; $lc_text = ' ' . $Qlisting->value('products_sku') . ' '; break; case 'PRODUCT_LIST_NAME': $lc_align = ''; if (isset($_GET['manufacturers'])) { $lc_text = osc_link_object(osc_href_link(FILENAME_PRODUCTS, $Qlisting->value('products_id') . '&manufacturers=' . $_GET['manufacturers']), $Qlisting->value('products_name')) . ($Qlisting->value('products_short_description') === NULL || $Qlisting->value('products_short_description') === '' ? '' : '<p>' . $Qlisting->value('products_short_description') . '</p>'); $lc_text .= osc_link_object(osc_href_link(FILENAME_PRODUCTS, $Qlisting->value('products_id') . '&manufacturers=' . $_GET['manufacturers']), $osC_Language->get('button_read_more'), 'class="readMore"'); } else { $lc_text = ' ' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $Qlisting->value('products_id') . ($cPath ? '&cPath=' . $cPath : '')), $Qlisting->value('products_name')) . ($Qlisting->value('products_short_description') === NULL || $Qlisting->value('products_short_description') === '' ? '' : '<p>' . $Qlisting->value('products_short_description') . '</p>') . ' '; $lc_text .= osc_link_object(osc_href_link(FILENAME_PRODUCTS, $Qlisting->value('products_id') . ($cPath ? '&cPath=' . $cPath : '')), $osC_Language->get('button_read_more'), 'class="readMore"'); } //variants options is enabled if ($variants_enabled) { if ($osC_Product->hasVariants()) { $lc_text .= '<ul class="options variants_' . $osC_Product->getID() . '">'; $combobox_array = $osC_Product->getVariantsComboboxArray(); foreach ($combobox_array as $groups_name => $combobox) { $lc_text .= '<li class="variant">'; $lc_text .= '<label>' . $groups_name . ':</label>'; $lc_text .= $combobox; $lc_text .= '</li>'; } $lc_text .= '</ul>'; } } break; case 'PRODUCT_LIST_MANUFACTURER': $lc_align = ''; $lc_text = ' ' . osc_link_object(osc_href_link(FILENAME_DEFAULT, 'manufacturers=' . $Qlisting->valueInt('manufacturers_id')), $Qlisting->value('manufacturers_name')) . ' '; break;
function osC_Products_Reviews() { global $osC_Services, $osC_Session, $osC_Language, $osC_Breadcrumb, $osC_Product, $osC_Customer, $osC_NavigationHistory; if ($osC_Services->isStarted('reviews') === false) { osc_redirect(osc_href_link(FILENAME_DEFAULT)); } $this->_page_title = $osC_Language->get('reviews_heading'); if ($osC_Services->isStarted('breadcrumb')) { $osC_Breadcrumb->add($osC_Language->get('breadcrumb_reviews'), osc_href_link(FILENAME_PRODUCTS, $this->_module)); } if (is_numeric($_GET[$this->_module])) { if (osC_Reviews::exists($_GET[$this->_module])) { $osC_Product = new osC_Product(osC_Reviews::getProductID($_GET[$this->_module])); $this->_page_title = $osC_Product->getTitle(); $this->_page_contents = 'reviews_info.php'; if ($osC_Services->isStarted('breadcrumb')) { $osC_Breadcrumb->add($osC_Product->getTitle(), osc_href_link(FILENAME_PRODUCTS, $this->_module . '=' . $_GET[$this->_module])); } } else { $this->_page_contents = 'reviews_not_found.php'; } } else { $counter = 0; foreach ($_GET as $key => $value) { $counter++; if ($counter < 2) { continue; } if ((ereg('^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && $key != $osC_Session->getName()) { if (osC_Product::checkEntry($key) === false) { $this->_page_contents = 'info_not_found.php'; } elseif ($_GET[$this->_module] == 'new') { if ($osC_Customer->isLoggedOn() === false && SERVICE_REVIEW_ENABLE_REVIEWS == 1) { $osC_NavigationHistory->setSnapshot(); osc_redirect(osc_href_link(FILENAME_ACCOUNT, 'login', 'SSL')); } $osC_Product = new osC_Product($key); $this->_page_title = $osC_Product->getTitle(); $this->_page_contents = 'reviews_new.php'; $this->addJavascriptPhpFilename('templates/' . $this->getCode() . '/javascript/products/reviews_new.php'); if ($osC_Services->isStarted('breadcrumb')) { $osC_Breadcrumb->add($osC_Product->getTitle(), osc_href_link(FILENAME_PRODUCTS, $this->_module . '&' . $osC_Product->getKeyword())); $osC_Breadcrumb->add($osC_Language->get('breadcrumb_reviews_new'), osc_href_link(FILENAME_PRODUCTS, $this->_module . '=new&' . $osC_Product->getKeyword())); } if (isset($_GET['action']) && $_GET['action'] == 'process') { $this->_process($osC_Product->getID()); } } else { $osC_Product = new osC_Product($key); $this->_page_title = $osC_Product->getTitle(); $this->_page_contents = 'product_reviews.php'; if ($osC_Services->isStarted('breadcrumb')) { $osC_Breadcrumb->add($osC_Product->getTitle(), osc_href_link(FILENAME_PRODUCTS, $this->_module . '&' . $osC_Product->getKeyword())); } } } break; } if ($counter < 2) { if (osC_Reviews::exists() === false) { $this->_page_contents = 'reviews_not_found.php'; } } } }
/** * Add the products to this order. */ function addProduct($products_id_string, $quantity, $gift_certificate_data = null) { global $osC_Database, $osC_Language, $osC_Tax; $error = false; $osC_Database->startTransaction(); $products_id = osc_get_product_id($products_id_string); $variants = osc_parse_variants_from_id_string($products_id_string); $osC_Product = new osC_Product($products_id, $this->getCustomer('customers_id')); //If the products with the variants exists in the order, then increase the order quantity //Each gift certificate added to order will be considered as a new product // if (isset($this->_contents[$products_id_string])) { $orders_products_id = $this->_contents[$products_id_string]['orders_products_id']; $new_quantity = $this->_contents[$products_id_string]['quantity'] + $quantity; $Qupdate = $osC_Database->query('update :table_orders_products set products_quantity = :products_quantity, products_price = :products_price, final_price = :final_price, products_type = :products_type where orders_products_id = :orders_products_id '); $Qupdate->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS); $Qupdate->bindInt(':products_quantity', $new_quantity); $Qupdate->bindValue(':products_price', $osC_Product->getPrice($variants, $new_quantity)); $Qupdate->bindValue(':final_price', $osC_Product->getPrice($variants, $new_quantity)); $Qupdate->bindInt(':orders_products_id', $orders_products_id); $Qupdate->bindInt(':products_type', $osC_Product->getProductType()); $Qupdate->setLogging($_SESSION['module'], $this->_order_id); $Qupdate->execute(); if ($osC_Database->isError()) { $error = true; } else { $this->_contents[$products_id_string]['quantity'] = $new_quantity; $this->_contents[$products_id_string]['price'] = $osC_Product->getPrice($variants, $new_quantity); $this->_contents[$products_id_string]['final_price'] = $osC_Product->getPrice($variants, $new_quantity); } } else { $products_price = $osC_Product->getPrice($variants, $quantity); if ($osC_Product->isEmailGiftCertificate() && $osC_Product->isOpenAmountGiftCertificate()) { $products_price = $gift_certificate_data['price']; } $Qinsert = $osC_Database->query('insert into :table_orders_products (orders_id, products_id, products_sku, products_name, products_price, final_price, products_tax, products_quantity, products_type) values (:orders_id, :products_id, :products_sku, :products_name, :products_price, :final_price, :products_tax, :products_quantity, :products_type) '); $Qinsert->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS); $Qinsert->bindInt(':orders_id', $this->_order_id); $Qinsert->bindInt(':products_id', $osC_Product->getID()); $Qinsert->bindValue(':products_sku', $osC_Product->getSKU()); $Qinsert->bindValue(':products_name', $osC_Product->getTitle()); $Qinsert->bindValue(':products_price', $products_price); $Qinsert->bindValue(':final_price', $products_price); $Qinsert->bindValue(':products_tax', $osC_Tax->getTaxRate($osC_Product->getTaxClassID(), $this->_shipping_address['country_id'], $this->_shipping_address['zone_id'])); $Qinsert->bindInt(':products_quantity', $quantity); $Qinsert->bindInt(':products_type', $osC_Product->getProductType()); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; } else { $orders_products_id = $osC_Database->nextID(); if (is_array($variants) && !empty($variants)) { foreach ($variants as $groups_id => $values_id) { $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 = :language_id and pvv.language_id = :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', $osC_Product->getID()); $Qvariants->bindInt(':groups_id', $groups_id); $Qvariants->bindInt(':variants_values_id', $values_id); $Qvariants->bindInt(':language_id', $osC_Language->getID()); $Qvariants->bindInt(':language_id', $osC_Language->getID()); $Qvariants->execute(); $Qinsert = $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) '); $Qinsert->bindTable(':table_orders_products_variants', TABLE_ORDERS_PRODUCTS_VARIANTS); $Qinsert->bindInt(':orders_id', $this->_order_id); $Qinsert->bindInt(':orders_products_id', $orders_products_id); $Qinsert->bindInt(':products_variants_groups_id', $groups_id); $Qinsert->bindValue(':products_variants_groups', $Qvariants->value('products_variants_groups_name')); $Qinsert->bindInt(':products_variants_values_id', $values_id); $Qinsert->bindValue(':products_variants_values', $Qvariants->value('products_variants_values_name')); $Qinsert->setLogging($_SESSION['module'], $this->_order_id); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { if ($osC_Product->getProductType() == 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', $products_id); $Qdownloadable->execute(); $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', $_REQUEST['orders_id']); $Qopd->bindInt(':orders_products_id', $orders_products_id); $Qopd->bindValue(':orders_products_filename', $Qdownloadable->value('filename')); $Qopd->bindValue(':orders_products_cache_filename', $Qdownloadable->value('cache_filename')); $Qopd->bindValue(':download_maxdays', $Qdownloadable->valueInt('number_of_accessible_days')); $Qopd->bindValue(':download_count', $Qdownloadable->valueInt('number_of_downloads')); $Qopd->setLogging($_SESSION['module'], $this->_order_id); $Qopd->execute(); if ($osC_Database->isError()) { $error = true; } } } if ($error === false) { if ($osC_Product->getProductType() == PRODUCT_TYPE_GIFT_CERTIFICATE) { require_once '../includes/classes/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', $_REQUEST['orders_id']); $Qgc->bindInt(':gift_certificates_type', $gift_certificate_data['type']); $Qgc->bindInt(':orders_products_id', $orders_products_id); $Qgc->bindValue(':amount', $gift_certificate_data['price']); $Qgc->bindValue(':gift_certificates_code', toC_Gift_Certificates::createGiftCertificateCode()); $Qgc->bindValue(':recipients_name', $gift_certificate_data['recipients_name']); $Qgc->bindValue(':recipients_email', $gift_certificate_data['recipients_email']); $Qgc->bindValue(':senders_name', $gift_certificate_data['senders_name']); $Qgc->bindValue(':senders_email', $gift_certificate_data['senders_email']); $Qgc->bindValue(':messages', $gift_certificate_data['message']); $Qgc->setLogging($_SESSION['module'], $this->_order_id); $Qgc->execute(); if ($osC_Database->isError()) { $error = true; } } } } if ($error === false) { $this->_contents[$products_id_string] = array('id' => $products_id, 'orders_products_id' => $orders_products_id, 'quantity' => $quantity, 'name' => $osC_Product->getTitle(), 'sku' => $osC_Product->getSKU($variants_array), 'tax' => $osC_Tax->getTaxRate($osC_Product->getTaxClassID(), $this->_shipping_address['country_id'], $this->_shipping_address['zone_id']), 'price' => $product_price, 'final_price' => $products_price, 'weight' => $osC_Product->getWeight($variants), 'tax_class_id' => $osC_Product->getTaxClassID(), 'weight_class_id' => $osC_Product->getWeightClass()); } } osC_Product::updateStock($this->_order_id, $orders_products_id, $products_id, $quantity); if ($error === false) { $osC_Database->commitTransaction(); $this->_calculate(); $this->updateOrderTotal(); return true; } $osC_Database->rollbackTransaction(); return false; }
function add($products_id) { global $osC_Database, $osC_Services, $osC_Customer; //if wishlist empty, create a new wishlist if (!$this->hasWishlistID()) { $token = $this->generateToken(); $Qnew = $osC_Database->query('insert into :table_wishlists (customers_id, wishlists_token) values (:customers_id, :wishlists_token)'); $Qnew->bindTable(':table_wishlists', TABLE_WISHLISTS); if (!$osC_Customer->isLoggedOn()) { $Qnew->bindRaw(':customers_id', 'null'); } else { $Qnew->bindInt(':customers_id', $osC_Customer->getID()); } $Qnew->bindValue(':wishlists_token', $token); $Qnew->execute(); $this->_wishlists_id = $osC_Database->nextID(); $this->_token = $token; } $osC_Product = new osC_Product($products_id); if ($osC_Product->getID() > 0) { if (!$this->exists($products_id)) { $price = $osC_Product->getPrice(); if ($osC_Services->isStarted('specials')) { global $osC_Specials; if ($new_price = $osC_Specials->getPrice($products_id)) { $price = $new_price; } } $this->_contents[$products_id] = array('products_id' => $products_id, 'name' => $osC_Product->getTitle(), 'image' => $osC_Product->getImage(), 'price' => $price, 'date_added' => osC_DateTime::getShort(osC_DateTime::getNow()), 'comments' => ''); $Qnew = $osC_Database->query('insert into :table_wishlist_products (wishlists_id, products_id, date_added, comments) values (:wishlists_id, :products_id, now(), :comments)'); $Qnew->bindTable(':table_wishlist_products', TABLE_WISHLISTS_PRODUCTS); $Qnew->bindInt(':wishlists_id', $this->_wishlists_id); $Qnew->bindInt(':products_id', $products_id); $Qnew->bindValue(':comments', ''); $Qnew->execute(); } } }
function osC_Products_Products() { global $osC_Database, $osC_Services, $osC_Session, $osC_Language, $breadcrumb, $cPath, $cPath_array, $osC_Manufacturer, $osC_Product; if (empty($_GET) === false) { $id = false; // PHP < 5.0.2; array_slice() does not preserve keys and will not work with numerical key values, so foreach() is used foreach ($_GET as $key => $value) { if ((ereg('^[0-9]+(_?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && $key != $osC_Session->getName()) { $id = $key; } break; } if (strpos($id, '_') !== false) { $id = str_replace('_', '#', $id); } if ($id !== false && osC_Product::checkEntry($id)) { $osC_Product = new osC_Product($id); $osC_Product->incrementCounter(); $this->_page_title = $osC_Product->getTitle(); $this->addPageTags('keywords', $osC_Product->getTitle()); $this->addPageTags('keywords', $osC_Product->getSKU()); if ($osC_Product->hasPageTitle()) { $this->setMetaPageTitle($osC_Product->getPageTitle()); } if ($osC_Product->hasTags()) { $this->addPageTags('keywords', $osC_Product->getTags()); } if ($osC_Product->hasMetaKeywords()) { $this->addPageTags('keywords', $osC_Product->getMetaKeywords()); } if ($osC_Product->hasMetaDescription()) { $this->addPageTags('description', $osC_Product->getMetaDescription()); } osC_Services_category_path::process($osC_Product->getCategoryID()); if (isset($_GET['manufacturers']) && empty($_GET['manufacturers']) === false) { require_once 'includes/classes/manufacturer.php'; $osC_Manufacturer = new osC_Manufacturer($_GET['manufacturers']); if ($osC_Services->isStarted('breadcrumb')) { $breadcrumb->add($osC_Manufacturer->getTitle(), osc_href_link(FILENAME_DEFAULT, 'manufacturers=' . $_GET['manufacturers'])); $breadcrumb->add($osC_Product->getTitle(), osc_href_link(FILENAME_PRODUCTS, $osC_Product->getID())); } //Using rel=”canonical” links to remove the duplication - same product info page //To fix the bug - [#123] Two Different SEO link for one product if (isset($osC_Services) && $osC_Services->isStarted('sefu')) { $this->_add_canonical($osC_Product->getID()); } } else { if ($osC_Services->isStarted('breadcrumb')) { $Qcategories = $osC_Database->query('select categories_id, categories_name from :table_categories_description where categories_id in (:categories_id) and language_id = :language_id'); $Qcategories->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION); $Qcategories->bindRaw(':categories_id', implode(',', $cPath_array)); $Qcategories->bindInt(':language_id', $osC_Language->getID()); $Qcategories->execute(); $categories = array(); while ($Qcategories->next()) { $categories[$Qcategories->value('categories_id')] = $Qcategories->valueProtected('categories_name'); } $Qcategories->freeResult(); for ($i = 0, $n = sizeof($cPath_array); $i < $n; $i++) { $breadcrumb->add($categories[$cPath_array[$i]], osc_href_link(FILENAME_DEFAULT, 'cPath=' . implode('_', array_slice($cPath_array, 0, $i + 1)))); } $breadcrumb->add($osC_Product->getTitle(), osc_href_link(FILENAME_PRODUCTS, $osC_Product->getID())); } } $this->addStyleSheet('ext/mojozoom/mojozoom.css'); $this->addStyleSheet('templates/' . $this->getCode() . '/javascript/milkbox/milkbox.css'); } else { $this->_page_title = $osC_Language->get('product_not_found_heading'); $this->_page_contents = 'info_not_found.php'; } } else { $this->_page_title = $osC_Language->get('product_not_found_heading'); $this->_page_contents = 'info_not_found.php'; } }
?> <br /> <?php echo osc_link_object($wishlist_link, $osC_Language->get('add_to_wishlist'), 'class="wishlist"'); ?> </span> </div> <?php //variants options is enabled if ($variants_enabled && $view_type == 'list') { if ($osC_Product->hasVariants()) { $combobox_array = $osC_Product->getVariantsComboboxArray(); ?> <ul class="options variants_<?php echo $osC_Product->getID(); ?> clearfix"> <?php foreach ($combobox_array as $groups_name => $combobox) { ?> <li class="variant"> <label><?php echo $groups_name; ?> :</label> <?php echo $combobox; ?> </li> <?php
function add($products_id, $variants = array()) { global $osC_Database, $osC_Services, $osC_Customer, $osC_Product; //if wishlist empty, create a new wishlist if (!$this->hasWishlistID()) { $token = $this->generateToken(); $Qnew = $osC_Database->query('insert into :table_wishlists (customers_id, wishlists_token) values (:customers_id, :wishlists_token)'); $Qnew->bindTable(':table_wishlists', TABLE_WISHLISTS); $Qnew->bindInt(':customers_id', $osC_Customer->getID()); $Qnew->bindValue(':wishlists_token', $token); $Qnew->execute(); $this->_wishlists_id = $osC_Database->nextID(); $this->_token = $token; $Qnew->freeResult(); } if (!isset($osC_Product)) { $osC_Product = new osC_Product($products_id); } if ($osC_Product->getID() > 0) { if (!$this->exists($products_id)) { $product_price = $osC_Product->getPrice(); $product_name = $osC_Product->getTitle(); $product_image = $osC_Product->getImage(); if ($osC_Services->isStarted('specials')) { global $osC_Specials; if ($new_price = $osC_Specials->getPrice($products_id)) { $price = $new_price; } } //if the product has variants, set the image, price etc according to the variants if ($osC_Product->hasVariants()) { $products_variants = $osC_Product->getVariants(); if (is_array($variants) && !osc_empty($variants)) { $product_id_string = osc_get_product_id_string($products_id, $variants); $products_variant = $products_variants[$product_id_string]; } else { $products_variant = $osC_Product->getDefaultVariant(); } $variants_groups_id = $products_variant['groups_id']; $variants_groups_name = $products_variant['groups_name']; if (!osc_empty($variants_groups_name)) { $product_name .= '<br />'; foreach ($variants_groups_name as $group_name => $value_name) { $product_name .= '<em>' . $group_name . ': ' . $value_name . '</em>' . '<br />'; } } $product_price = $products_variant['price']; $product_image = $products_variant['image']; } $this->_contents[$products_id] = array('products_id' => $products_id, 'name' => $product_name, 'image' => $product_image, 'price' => $product_price, 'date_added' => osC_DateTime::getShort(osC_DateTime::getNow()), 'variants' => $variants, 'comments' => ''); //insert into wishlist products $Qnew = $osC_Database->query('insert into :table_wishlist_products (wishlists_id, products_id, date_added, comments) values (:wishlists_id, :products_id, now(), :comments)'); $Qnew->bindTable(':table_wishlist_products', TABLE_WISHLISTS_PRODUCTS); $Qnew->bindInt(':wishlists_id', $this->_wishlists_id); $Qnew->bindInt(':products_id', $products_id); $Qnew->bindValue(':comments', ''); $Qnew->execute(); $wishlists_products_id = $osC_Database->nextID(); $Qnew->freeResult(); //if the wishlists products has variants $products_variants_groups_id = array(); $products_variants_groups_name = array(); if (isset($variants_groups_id) && isset($variants_groups_name)) { foreach ($variants_groups_id as $groups_id => $values_id) { $products_variants_groups_id[] = array('groups_id' => $groups_id, 'values_id' => $values_id); } foreach ($variants_groups_name as $groups_name => $values_name) { $products_variants_groups_name[] = array('groups_name' => $groups_name, 'values_name' => $values_name); } } if (!osc_empty($products_variants_groups_id)) { foreach ($products_variants_groups_id as $key => $groups_id) { $Qinsert = $osC_Database->query('insert into :table_wishlists_products_variants (wishlists_id, wishlists_products_id, products_variants_groups_id, products_variants_groups, products_variants_values_id, products_variants_values) values (:wishlists_id, :wishlists_products_id, :products_variants_groups_id, :products_variants_groups, :products_variants_values_id, :products_variants_values)'); $Qinsert->bindTable(':table_wishlists_products_variants', TABLE_WISHLISTS_PRODUCTS_VARIANTS); $Qinsert->bindInt(':wishlists_id', $this->_wishlists_id); $Qinsert->bindInt(':wishlists_products_id', $wishlists_products_id); $Qinsert->bindInt(':products_variants_groups_id', $groups_id['groups_id']); $Qinsert->bindInt(':products_variants_values_id', $groups_id['values_id']); $Qinsert->bindValue(':products_variants_groups', $products_variants_groups_name[$key]['groups_name']); $Qinsert->bindValue(':products_variants_values', $products_variants_groups_name[$key]['values_name']); $Qinsert->execute(); } } } } }
function _getShoppingCart() { global $osC_ShoppingCart, $osC_Currencies, $osC_Specials, $osC_Language; $cart = array(); //products $products = array(); foreach ($osC_ShoppingCart->getProducts() as $products_id_string => $data) { $osC_Product = new osC_Product(osc_get_product_id($products_id_string)); $product = explode('#', $products_id_string, 2); $variants_array = array(); if (!$osC_Product->isGiftCertificate()) { if (isset($product[1])) { $variants = explode(';', $product[1]); foreach ($variants as $set) { $variant = explode(':', $set); if (!is_numeric($variant[0]) || !is_numeric($variant[1])) { continue 2; // skip product } $variants_array[$variant[0]] = $variant[1]; } } } $price = $osC_Product->getPrice($variants_array, $data['quantity']); if ($osC_Product->hasSpecial()) { $special_price = $osC_Specials->getPrice($osC_Product->getID()); if ($osC_Product->hasVariants()) { $special_percentage = $special_price / $osC_Product->getData('price'); $special_price = $price * $special_percentage; } $price = '<s>' . $osC_Currencies->displayPrice($price, $osC_Product->getData('tax_class_id')) . '</s> <span class="productSpecialPrice">' . $osC_Currencies->displayPrice($special_price, $osC_Product->getData('tax_class_id')) . '</span>'; } $product = array('id' => $products_id_string, 'link' => osc_href_link(FILENAME_PRODUCTS, $osC_Product->getID()), 'name' => substr($data['name'], 0, self::PRODUCTS_NAME_LENGTH) . (strlen($data['name']) > self::PRODUCTS_NAME_LENGTH ? '..' : ''), 'title' => $data['name'], 'quantity' => $data['quantity'] . ' x ', 'price' => $price); //variantsol if (is_array($data['variants']) && !empty($data['variants'])) { $product['variants'] = array_values($data['variants']); } //customizations if (is_array($data['customizations']) && !empty($data['customizations'])) { $product['customizations'] = array_values($data['customizations']); } //gift certificate if ($data['type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) { $gc_data = $osC_Language->get('senders_name') . ': ' . $data['gc_data']['senders_name']; if ($data['gc_data']['type'] == GIFT_CERTIFICATE_TYPE_EMAIL) { $gc_data .= '<br />- ' . $osC_Language->get('senders_email') . ': ' . $data['gc_data']['senders_email']; } $gc_data .= '<br />- ' . $osC_Language->get('recipients_name') . ': ' . $data['gc_data']['recipients_name']; if ($data['gc_data']['type'] == GIFT_CERTIFICATE_TYPE_EMAIL) { $gc_data .= '<br />- ' . $osC_Language->get('recipients_email') . ': ' . $data['gc_data']['recipients_email']; } $gc_data .= '<br />- ' . $osC_Language->get('message') . ': ' . $data['gc_data']['message']; $product['gc_data'] = $gc_data; } $products[] = $product; } $cart['products'] = $products; //order totals $order_totals = array(); foreach ($osC_ShoppingCart->getOrderTotals() as $module) { $order_totals[] = array('title' => $module['title'], 'text' => $module['text']); } $cart['orderTotals'] = $order_totals; //numberOfItems $cart['numberOfItems'] = $osC_ShoppingCart->numberOfItems(); //cart total $cart['total'] = $osC_Currencies->format($osC_ShoppingCart->getTotal()); return $cart; }
/** * Add a product or variant product into the wishlist * * @access public * @param mixed products id or products id string including the variants such as 1#1:1;2:3 * @return boolean */ function add($products_id_string) { global $osC_Database, $osC_Services, $osC_Customer, $osC_Product; //flag to reprent the action performed or not $error = false; // if wishlist empty, create a new wishlist if (!$this->hasWishlistID()) { $token = $this->generateToken(); $Qnew = $osC_Database->query('insert into :table_wishlists (customers_id, wishlists_token) values (:customers_id, :wishlists_token)'); $Qnew->bindTable(':table_wishlists', TABLE_WISHLISTS); $Qnew->bindInt(':customers_id', $osC_Customer->getID()); $Qnew->bindValue(':wishlists_token', $token); $Qnew->execute(); $this->_wishlists_id = $osC_Database->nextID(); $this->_token = $token; $Qnew->freeResult(); } if (!isset($osC_Product)) { $osC_Product = new osC_Product($products_id_string); } if ($osC_Product->getID() > 0) { if (!$this->exists($products_id_string)) { $product_price = $osC_Product->getPrice(); $product_name = $osC_Product->getTitle(); $product_image = $osC_Product->getImage(); if ($osC_Services->isStarted('specials')) { global $osC_Specials; if ($new_price = $osC_Specials->getPrice($products_id)) { $price = $new_price; } } // if the product has variants, set the image, price etc according to the variants if ($osC_Product->hasVariants()) { $variant_product = $this->_updateProduct($products_id_string, $osC_Product, $product_name); $product_name = $variant_product['name']; $product_price = $variant_product['price']; $product_image = $variant_product['image']; } $this->_contents[$products_id_string] = array('products_id_string' => $products_id_string, 'name' => $product_name, 'image' => $product_image, 'price' => $product_price, 'date_added' => osC_DateTime::getShort(osC_DateTime::getNow()), 'comments' => ''); // insert into wishlist products only if there isn't the same product existing in the table $QnewCheck = $osC_Database->query('select * from :table_wishlist_products where products_id_string = :products_id_string limit 1'); $QnewCheck->bindTable(':table_wishlist_products', TABLE_WISHLISTS_PRODUCTS); $QnewCheck->bindValue(':products_id_string', $products_id_string); $QnewCheck->execute(); if ($QnewCheck->numberOfRows() < 1) { $Qnew = $osC_Database->query('insert into :table_wishlist_products (wishlists_id, products_id_string, date_added, comments) values (:wishlists_id, :products_id_string, now(), :comments)'); $Qnew->bindTable(':table_wishlist_products', TABLE_WISHLISTS_PRODUCTS); $Qnew->bindInt(':wishlists_id', $this->_wishlists_id); $Qnew->bindValue(':products_id_string', $products_id_string); $Qnew->bindValue(':comments', ''); $Qnew->execute(); $wishlists_products_id = $osC_Database->nextID(); } else { $wishlists_products_id = $QnewCheck->valueInt('wishlists_products_id'); } $QnewCheck->freeResult(); } else { $error = true; } } if ($error === true) { return false; } return true; }
$Qproducts->bindTable(':table_wishlist_products', TABLE_WISHLISTS_PRODUCTS); $Qproducts->bindTable(':table_wishlist', TABLE_WISHLISTS); $Qproducts->bindValue(':token', $_GET['token']); $Qproducts->execute(); $rows = 0; while ($Qproducts->next()) { $rows++; $osC_Product = new osC_Product($Qproducts->valueInt('products_id')); ?> <tr class="<?php echo $rows / 2 == floor($rows / 2) ? 'productListing-even' : 'productListing-odd'; ?> "> <td align="center"><?php echo osc_link_object(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getID()), $osC_Image->show($osC_Product->getImage(), $osC_Product->getTitle(), 'hspace="5" vspace="5"')) . '<br />' . $osC_Product->getTitle() . '<br />' . $osC_Currencies->format($osC_Product->getPrice()); ?> </td> <td valign="top"><?php echo $Qproducts->value('comments'); ?> </td> <td align="center" valign="top"><?php echo osC_DateTime::getShort($Qproducts->value('date_added')); ?> </td> <td align="center" valign="top"><?php echo osc_link_object(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getID() . '&action=cart_add'), osc_draw_image_button('button_in_cart.gif', $osC_Language->get('button_add_to_cart'))); ?> </td> </tr>