function initialize() { global $osC_Database, $osC_Services, $osC_Language, $osC_Currencies, $osC_Image, $osC_Specials, $current_category_id; if ($current_category_id < 1) { $Qnewproducts = $osC_Database->query('select p.products_id, p.products_tax_class_id, p.products_price, pd.products_name, pd.products_keyword, i.image from :table_products p left join :table_products_images i on (p.products_id = i.products_id and i.default_flag = :default_flag), :table_products_description pd where p.products_status = 1 and p.products_id = pd.products_id and pd.language_id = :language_id order by p.products_date_added desc limit :max_display_new_products'); } else { $Qnewproducts = $osC_Database->query('select distinct p.products_id, p.products_tax_class_id, p.products_price, pd.products_name, pd.products_keyword, i.image from :table_products p left join :table_products_images i on (p.products_id = i.products_id and i.default_flag = :default_flag), :table_products_description pd, :table_products_to_categories p2c, :table_categories c where c.parent_id = :parent_id and c.categories_id = p2c.categories_id and p2c.products_id = p.products_id and p.products_status = 1 and p.products_id = pd.products_id and pd.language_id = :language_id order by p.products_date_added desc limit :max_display_new_products'); $Qnewproducts->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES); $Qnewproducts->bindTable(':table_categories', TABLE_CATEGORIES); $Qnewproducts->bindInt(':parent_id', $current_category_id); } $Qnewproducts->bindTable(':table_products', TABLE_PRODUCTS); $Qnewproducts->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES); $Qnewproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION); $Qnewproducts->bindInt(':default_flag', 1); $Qnewproducts->bindInt(':language_id', $osC_Language->getID()); $Qnewproducts->bindInt(':max_display_new_products', MODULE_CONTENT_NEW_PRODUCTS_MAX_DISPLAY); if (MODULE_CONTENT_NEW_PRODUCTS_CACHE > 0) { $Qnewproducts->setCache('new_products-' . $osC_Language->getCode() . '-' . $osC_Currencies->getCode() . '-' . $current_category_id, MODULE_CONTENT_NEW_PRODUCTS_CACHE); } $Qnewproducts->execute(); if ($Qnewproducts->numberOfRows()) { $i = 0; while ($Qnewproducts->next()) { if ($i % 3 == 0 && $i != 0) { $this->_content .= '<div style="clear:both"></div>'; } $product = new osC_Product($Qnewproducts->valueInt('products_id')); $this->_content .= '<div style="margin-top: 10px; float:left; width: 33%; text-align: center">' . '<span style="display:block; height: 32px; text-align: center">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $Qnewproducts->value('products_id')), $Qnewproducts->value('products_name')) . '</span>' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $Qnewproducts->value('products_id')), $osC_Image->show($Qnewproducts->value('image'), $Qnewproducts->value('products_name')), 'id="productImage' . $Qnewproducts->value('products_id') . '"') . '<span style="display:block; padding: 3px; text-align: center">' . $product->getPriceFormated(true) . '</span>' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $Qnewproducts->valueInt('products_id') . '&action=cart_add'), osc_draw_image_button('button_add_to_cart.png', $osC_Language->get('button_add_to_cart'), 'class="ajaxAddToCart" id="ac_newproductsmodule_' . $Qnewproducts->value('products_id') . '"')) . '</div>'; $i++; } $this->_content .= '<div style="clear:both"></div>'; } $Qnewproducts->freeResult(); }
function initialize() { global $osC_Cache, $osC_Database, $osC_Services, $osC_Currencies, $osC_Specials, $osC_Language, $osC_Image; $this->_title_link = osc_href_link(FILENAME_PRODUCTS, 'new'); if (BOX_WHATS_NEW_CACHE > 0 && $osC_Cache->read('box-whats_new-' . $osC_Language->getCode() . '-' . $osC_Currencies->getCode(), BOX_WHATS_NEW_CACHE)) { $data = $osC_Cache->getCache(); } else { $data = array(); $Qnew = $osC_Database->query('select p.products_id, p.products_tax_class_id, p.products_price, pd.products_name, pd.products_keyword, i.image from :table_products p left join :table_products_images i on (p.products_id = i.products_id and i.default_flag = :default_flag), :table_products_description pd where p.products_status = 1 and p.products_id = pd.products_id and pd.language_id = :language_id order by p.products_date_added desc limit :max_random_select_new'); $Qnew->bindTable(':table_products', TABLE_PRODUCTS); $Qnew->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES); $Qnew->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION); $Qnew->bindInt(':default_flag', 1); $Qnew->bindInt(':language_id', $osC_Language->getID()); $Qnew->bindInt(':max_random_select_new', BOX_WHATS_NEW_RANDOM_SELECT); $Qnew->executeRandomMulti(); if ($Qnew->numberOfRows()) { $data = $Qnew->toArray(); $osC_Product = new osC_Product($Qnew->valueInt('products_id')); $products_price = $osC_Currencies->displayPrice($Qnew->valueDecimal('products_price'), $Qnew->valueInt('products_tax_class_id')); if ($osC_Services->isStarted('specials') && $osC_Specials->isActive($Qnew->valueInt('products_id'))) { $products_price = '<s>' . $products_price . '</s> <span class="productSpecialPrice">' . $osC_Currencies->displayPrice($osC_Specials->getPrice($Qnew->valueInt('products_id')), $Qnew->valueInt('products_tax_class_id')) . '</span>'; } $data['products_price'] = $osC_Product->getPriceFormated(true); } $osC_Cache->writeBuffer($data); } if (empty($data) === false) { $this->_content = ''; if (empty($data['image']) === false) { $this->_content .= osc_link_object(osc_href_link(FILENAME_PRODUCTS, $data['products_id']), $osC_Image->show($data['image'], $data['products_name'])) . '<br />'; } $this->_content .= '<span>' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $data['products_id']), $data['products_name']) . '</span><br /><span class="productPrice">' . $data['products_price'] . '</span>'; } }
function getProducts() { global $osC_Database, $osC_Language, $toC_Json, $osC_Image; if (defined('IMAGE_GROUP_AUTO_COMPLETER')) { $image_group = IMAGE_GROUP_AUTO_COMPLETER; } else { $image_group = 'mini'; } if (defined('MAX_CHARACTERS_AUTO_COMPLETER')) { $max_name_len = MAX_CHARACTERS_AUTO_COMPLETER; } else { $max_name_len = 40; } $products = array(); if (isset($_POST['keywords']) && !empty($_POST['keywords'])) { $Qproducts = $osC_Database->query("select distinct p.products_id as products_id, pd.products_name from :table_products_description pd, :table_products p where pd.products_id = p.products_id and p.products_status = :products_status and products_name like :keywords and language_id =" . $osC_Language->getID() . ' limit :max_results'); $Qproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION); $Qproducts->bindTable(':table_products', TABLE_PRODUCTS); $Qproducts->bindInt(':products_status', 1); $Qproducts->bindInt(':max_results', MAX_DISPLAY_AUTO_COMPLETER_RESULTS); $Qproducts->bindValue(':keywords', '%' . $_POST['keywords'] . '%'); $Qproducts->execute(); while ($Qproducts->next()) { $osC_Product = new osC_Product($Qproducts->valueInt('products_id')); $products_name = $Qproducts->value('products_name'); if (strlen($products_name) > $max_name_len) { $products_name = substr($products_name, 0, $max_name_len) . '...'; } $products[] = '<div class="image">' . $osC_Image->show($osC_Product->getImage(), null, null, $image_group) . '</div><div class="details">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $Qproducts->valueInt('products_id')), $products_name) . '<strong class="price">' . $osC_Product->getPriceFormated(true) . '</strong></div>'; } } echo $toC_Json->encode($products); }
function initialize() { global $osC_Cache, $osC_Database, $osC_Services, $osC_Currencies, $osC_Specials, $osC_Language, $osC_Image; $this->_title_link = osc_href_link(FILENAME_PRODUCTS, 'new'); $data = array(); if (BOX_WHATS_NEW_CACHE > 0 && $osC_Cache->read('box-whats_new-' . $osC_Language->getCode() . '-' . $osC_Currencies->getCode(), BOX_WHATS_NEW_CACHE)) { $data = $osC_Cache->getCache(); } else { $Qnew = $osC_Database->query('select products_id from :table_products where products_status = :products_status order by products_date_added desc limit :max_random_select_new'); $Qnew->bindTable(':table_products', TABLE_PRODUCTS); $Qnew->bindInt(':products_status', 1); $Qnew->bindInt(':max_random_select_new', BOX_WHATS_NEW_RANDOM_SELECT); $Qnew->executeRandomMulti(); if ($Qnew->numberOfRows()) { $osC_Product = new osC_Product($Qnew->valueInt('products_id')); $data = $osC_Product->getData(); $data['display_price'] = $osC_Product->getPriceFormated(true); $data['display_image'] = $osC_Product->getImage(); } $osC_Cache->write($data); } if (!empty($data)) { $this->_content = ''; if (!empty($data['display_image'])) { $this->_content .= osc_link_object(osc_href_link(FILENAME_PRODUCTS, $data['keyword']), $osC_Image->show($data['display_image'], $data['name'])) . '<br />'; } $this->_content .= osc_link_object(osc_href_link(FILENAME_PRODUCTS, $data['keyword']), $data['name']) . '<br />' . $data['display_price']; } }
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 initialize() { global $osC_Language, $osC_Template, $toC_Compare_Products; if ($toC_Compare_Products->hasContents()) { $osC_Template->addStyleSheet('ext/multibox/multibox.css'); $osC_Template->addJavascriptFilename('ext/multibox/Overlay.js'); $osC_Template->addJavascriptFilename('ext/multibox/MultiBox.js'); $this->_content = '<ul>'; foreach ($toC_Compare_Products->getProducts() as $products_id) { $osC_Product = new osC_Product($products_id); $this->_content .= '<li>' . osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), $products_id . '&' . osc_get_all_get_params(array('action')) . '&action=compare_products_remove'), osc_draw_image_button('button_delete_icon.png', $osC_Language->get('button_delete')), 'style="float: right; margin: 0 3px 1px 3px"') . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id), $osC_Product->getTitle()) . '</li>'; } $this->_content .= '</ul>'; $this->_content .= '<p>' . '<span style="float: right">' . osc_link_object(osc_href_link(FILENAME_JSON, 'module=products&action=compare_products'), osc_draw_image_button('small_compare_now.png', $osC_Language->get('button_compare_now')), 'class="multibox" rel="width:800,height:400,ajax:true"') . '</span>' . osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), osc_get_all_get_params(array('action')) . '&action=compare_products_clear'), osc_draw_image_button('small_clear.png', $osC_Language->get('button_clear'))) . ' ' . '</p>'; $js .= '<script type="text/javascript"> window.addEvent("domready",function() { var overlay = new Overlay(); var box = new MultiBox(\'multibox\', { overlay: overlay }); }); </script>'; $this->_content .= "\n" . $js; } }
function execute() { global $osC_ShoppingCart; if (isset($_POST['products']) && is_array($_POST['products']) && !empty($_POST['products'])) { foreach ($_POST['products'] as $product => $quantity) { if (!is_numeric($quantity)) { return false; } $product = explode('#', $product, 2); $variants_array = array(); if (isset($product[1])) { $variants = explode(';', $product[1]); foreach ($variants as $set) { $variant = explode(':', $set); if (is_numeric($variant[0]) && is_numeric($variant[1])) { $variants_array[$variant[0]] = $variant[1]; } } } $osC_Product = new osC_Product($product[0]); if ($osC_Product->isGiftCertificate()) { $variants_array = $product[1]; } $osC_ShoppingCart->add($product[0], $variants_array, $quantity, null, 'update'); } } osc_redirect(osc_href_link(FILENAME_CHECKOUT)); }
function initialize() { global $osC_Database, $osC_Services, $osC_Language, $osC_Currencies, $osC_Image, $osC_Specials, $current_category_id; if ($current_category_id < 1) { $Qproducts = $osC_Database->query('select p.products_id, p.products_tax_class_id, p.products_price, pd.products_name, pd.products_keyword, pf.sort_order, i.image from :table_products p left join :table_products_images i on (p.products_id = i.products_id and i.default_flag = :default_flag), :table_products_description pd, :table_products_frontpage pf where p.products_status = 1 and p.products_id = pd.products_id and pd.products_id = pf.products_id and pd.language_id = :language_id order by pf.sort_order limit :max_display_feature_products'); } else { $Qproducts = $osC_Database->query('select distinct p.products_id, p.products_tax_class_id, p.products_price, pd.products_name, pf.sort_order, pd.products_keyword, i.image from :table_products p left join :table_products_images i on (p.products_id = i.products_id and i.default_flag = :default_flag), :table_products_description pd, :table_products_to_categories p2c, :table_categories c, :table_products_frontpage pf where c.parent_id = :parent_id and c.categories_id = p2c.categories_id and p2c.products_id = p.products_id and p.products_id = pf.products_id and p.products_status = 1 and p.products_id = pd.products_id and pd.language_id = :language_id order by pf.sort_order limit :max_display_feature_products'); $Qproducts->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES); $Qproducts->bindTable(':table_categories', TABLE_CATEGORIES); $Qproducts->bindInt(':parent_id', $current_category_id); } $Qproducts->bindTable(':table_products', TABLE_PRODUCTS); $Qproducts->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES); $Qproducts->bindTable(':table_products_frontpage', TABLE_PRODUCTS_FRONTPAGE); $Qproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION); $Qproducts->bindInt(':default_flag', 1); $Qproducts->bindInt(':language_id', $osC_Language->getID()); $Qproducts->bindInt(':max_display_feature_products', MODULE_CONTENT_FEATURE_PRODUCTS_MAX_DISPLAY); $Qproducts->setCache('feature-products-' . $osC_Language->getCode() . '-' . $osC_Currencies->getCode() . '-' . $current_category_id); $Qproducts->execute(); if ($Qproducts->numberOfRows()) { $this->_content = '<div style="overflow: auto; height: 100%;">'; $i = 0; while ($Qproducts->next()) { if ($i % 3 == 0 && $i != 0) { $this->_content .= '<div style="clear:both"></div>'; } $osC_Product = new osC_Product($Qproducts->valueInt('products_id')); $this->_content .= '<span style="width: 32%; float: left; text-align: center; padding: 2px;">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $Qproducts->value('products_id')), $osC_Image->show($Qproducts->value('image'), $Qproducts->value('products_name'))) . '<br />' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $Qproducts->value('products_id')), $Qproducts->value('products_name')) . '<br />' . $osC_Product->getPriceFormated(true) . '</span>'; $i++; } $this->_content .= '</div>'; } $Qproducts->freeResult(); }
function osC_Products_Products() { global $osC_Database, $osC_Services, $osC_Session, $osC_Language, $osC_Breadcrumb, $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 ((preg_match('/^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$/', $key) || preg_match('/^[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); $osC_Product->incrementCounter(); $this->addPageTags('keywords', $osC_Product->getTitle()); $this->addPageTags('keywords', $osC_Product->getModel()); if ($osC_Product->hasTags()) { $this->addPageTags('keywords', $osC_Product->getTags()); } $this->addJavascriptFilename('templates/' . $this->getCode() . '/javascript/' . $this->_group . '/info.js'); osC_Services_category_path::process($osC_Product->getCategoryID()); if ($osC_Services->isStarted('breadcrumb')) { $osC_Breadcrumb->add($osC_Product->getTitle(), osc_href_link(FILENAME_PRODUCTS, $osC_Product->getKeyword())); } $this->_page_title = $osC_Product->getTitle(); } 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'; } }
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_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())); }
public function quote() { global $osC_ShoppingCart, $osC_Weight; $dest_country = $osC_ShoppingCart->getShippingAddress('country_iso_code_2'); $dest_zone = 0; $error = false; $shipping_method = null; $shipping_cost = null; $shipping_weight = 0; foreach ($osC_ShoppingCart->getProducts() as $product) { $osC_Product = new osC_Product($product['id']); if ($osC_Product->isTypeActionAllowed('apply_shipping_fees')) { $shipping_weight += $osC_Weight->convert($product['weight'], SHIPPING_WEIGHT_UNIT, MODULE_SHIPPING_ZONES_WEIGHT_UNIT) * $product['quantity']; } } for ($i = 1; $i <= $this->num_zones; $i++) { $countries_table = constant('MODULE_SHIPPING_ZONES_COUNTRIES_' . $i); $country_zones = preg_split("/[,]/", $countries_table); if (in_array($dest_country, $country_zones)) { $dest_zone = $i; break; } } if ($dest_zone == 0) { $error = true; } else { $shipping = -1; $zones_cost = constant('MODULE_SHIPPING_ZONES_COST_' . $dest_zone); $zones_table = preg_split("/[:,]/", $zones_cost); $size = sizeof($zones_table); for ($i = 0; $i < $size; $i += 2) { if ($shipping_weight <= $zones_table[$i]) { $shipping = $zones_table[$i + 1]; $shipping_method = __('shipping_zones_method') . ' ' . $dest_country . ' : ' . $osC_Weight->display($osC_ShoppingCart->getWeight(), MODULE_SHIPPING_ZONES_WEIGHT_UNIT); break; } } if ($shipping == -1) { $shipping_cost = 0; $shipping_method = __('shipping_zones_undefined_rate'); } else { $shipping_cost = $shipping * $osC_ShoppingCart->numberOfShippingBoxes() + constant('MODULE_SHIPPING_ZONES_HANDLING_' . $dest_zone); } } $this->quotes = array('id' => $this->_code, 'module' => $this->_title, 'methods' => array(array('id' => $this->_code, 'title' => $shipping_method, 'cost' => $shipping_cost)), 'tax_class_id' => $this->tax_class); if (!empty($this->icon)) { $this->quotes['icon'] = osc_image($this->icon, $this->_title); } if ($error == true) { $this->quotes['error'] = __('shipping_zones_invalid_zone'); } return $this->quotes; }
function initialize() { global $osC_Language, $osC_Template, $toC_Compare_Products; if ($toC_Compare_Products->hasContents()) { $osC_Template->addStyleSheet('ext/multibox/multibox.css'); $osC_Template->addJavascriptFilename('ext/multibox/Overlay.js'); $osC_Template->addJavascriptFilename('ext/multibox/MultiBox.js'); $this->_content = '<ul>'; foreach ($toC_Compare_Products->getProducts() as $products_id) { $osC_Product = new osC_Product($products_id); $cid = $products_id; $str_variants = ''; //if the product have any variants, it means that the $products_id should be a product string such as 1#1:1;2:2 if ($osC_Product->hasVariants()) { $variants = $osC_Product->getVariants(); if (preg_match('/^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)+$/', $products_id)) { $products_variant = $variants[$products_id]; } else { $products_variant = $osC_Product->getDefaultVariant(); } //if the product have any variants, get the group_name:value_name string if (isset($products_variant) && isset($products_variant['groups_name']) && is_array($products_variant['groups_name']) && !empty($products_variant['groups_name'])) { $str_variants .= ' -- '; foreach ($products_variant['groups_name'] as $groups_name => $value_name) { $str_variants .= '<strong>' . $groups_name . ': ' . $value_name . '</strong>;'; } //clean the last ';' if (($pos = strrpos($str_variants, ';')) !== false) { $str_variants = substr($str_variants, 0, -1); } } //build the product string that could be used if (strpos($products_id, '#') !== false) { $cid = str_replace('#', '_', $products_id); } } $this->_content .= '<li>' . osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), 'cid=' . $cid . '&' . osc_get_all_get_params(array('cid', 'action')) . '&action=compare_products_remove'), osc_draw_image_button('button_delete_icon.png', $osC_Language->get('button_delete')), 'style="float: right; margin: 0 3px 1px 3px"') . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id), $osC_Product->getTitle() . $str_variants) . '</li>'; } $this->_content .= '</ul>'; $this->_content .= '<p>' . '<span style="float: right">' . osc_link_object(osc_href_link(FILENAME_JSON, 'module=products&action=compare_products'), osc_draw_image_button('small_compare_now.png', $osC_Language->get('button_compare_now')), 'class="multibox" rel="ajax:true"') . '</span>' . osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), osc_get_all_get_params(array('action')) . '&action=compare_products_clear'), osc_draw_image_button('small_clear.png', $osC_Language->get('button_clear'))) . ' ' . '</p>'; $js .= '<script type="text/javascript"> window.addEvent("domready",function() { var box = new MultiBox(\'multibox\', { movieWidth: 820, movieHeight: 600 }); }); </script>'; $this->_content .= "\n" . $js; } }
function initialize() { global $osC_Language, $toC_Compare_Products; if ($toC_Compare_Products->hasContents()) { $this->_content = '<ul>'; foreach ($toC_Compare_Products->getProducts() as $products_id) { $osC_Product = new osC_Product($products_id); $this->_content .= '<li>' . osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), $products_id . '&' . osc_get_all_get_params(array('action')) . '&action=compare_products_remove'), osc_draw_image_button('button_delete_icon.png', $osC_Language->get('button_delete')), 'style="float: right; margin: 0 3px 1px 3px"') . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id), $osC_Product->getTitle()) . '</li>'; } $this->_content .= '</ul>'; $this->_content .= '<p>' . '<span style="float: right">' . osc_link_object('javascript:popupWindow(\'' . osc_href_link(FILENAME_PRODUCTS, 'compare_products') . '\', \'popupWindow\', \'scrollbars=yes\');', osc_draw_image_button('small_compare_now.png', $osC_Language->get('button_compare_now'))) . '</span>' . osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), osc_get_all_get_params(array('action')) . '&action=compare_products_clear'), osc_draw_image_button('small_clear.png', $osC_Language->get('button_clear'))) . ' ' . '</p>'; } }
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')))); }
public function quote() { global $osC_ShoppingCart; $number_of_items = 0; foreach ($osC_ShoppingCart->getProducts() as $product) { $osC_Product = new osC_Product($product['id']); if ($osC_Product->isTypeActionAllowed('apply_shipping_fees')) { $number_of_items += $product['quantity']; } } $this->quotes = array('id' => $this->_code, 'module' => $this->_title, 'methods' => array(array('id' => $this->_code, 'title' => __('shipping_item_method'), 'cost' => MODULE_SHIPPING_ITEM_COST * $number_of_items + MODULE_SHIPPING_ITEM_HANDLING)), 'tax_class_id' => $this->tax_class); if (!empty($this->icon)) { $this->quotes['icon'] = osc_image($this->icon, $this->_title); } return $this->quotes; }
function getVariantsFormattedPrice() { global $toC_Json; $response = array(); if (isset($_POST['products_id_string']) && preg_match('/^[0-9]+(#([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)$/', $_POST['products_id_string'])) { $response['success'] = true; $variants = osc_parse_variants_from_id_string($_POST['products_id_string']); $osC_Product = new osC_Product($_POST['products_id_string']); $formatted_price = $osC_Product->getPriceFormated(true, $variants); $response['formatted_price'] = $formatted_price; } else { $response['success'] = false; $response['feedback'] = 'The products id string is not valid'; } echo $toC_Json->encode($response); }
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_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, $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, $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 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 removeProduct() { global $toC_Json, $osC_ShoppingCart; $products_id = isset($_REQUEST['pID']) ? $_POST['pID'] : null; if (!empty($products_id) && osC_Product::checkEntry($products_id)) { $osC_ShoppingCart->remove($products_id); $response = array('success' => true); } else { $response = array('success' => false); } echo $toC_Json->encode($response); }
function osC_Products_Images() { global $osC_Session, $osC_Language, $osC_Product; if (empty($_GET) === false) { $id = false; $counter = 0; foreach ($_GET as $key => $value) { $counter++; if ($counter < 2) { continue; } if ((preg_match('/^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$/', $key) || preg_match('/^[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); $this->addPageTags('keywords', $osC_Product->getTitle()); $this->addPageTags('keywords', $osC_Product->getModel()); if ($osC_Product->hasTags()) { $this->addPageTags('keywords', $osC_Product->getTags()); } $this->_page_title = $osC_Product->getTitle(); } 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'; } }
function initialize() { global $osC_Database, $osC_Language, $osC_Currencies, $osC_Image, $osC_Template; $Qupcoming = $osC_Database->query('select p.products_id, p.products_price, p.products_tax_class_id, p.products_date_available as date_expected, pd.products_name, pd.products_keyword, s.specials_new_products_price, i.image from :table_products p left join :table_products_images i on (p.products_id = i.products_id and i.default_flag = :default_flag) left join :table_specials s on (p.products_id = s.products_id and s.status = 1), :table_products_description pd where to_days(p.products_date_available) >= to_days(now()) and p.products_status = :products_status and p.products_id = pd.products_id and pd.language_id = :language_id order by p.products_date_available limit :max_display_upcoming_products'); $Qupcoming->bindTable(':table_products', TABLE_PRODUCTS); $Qupcoming->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES); $Qupcoming->bindTable(':table_specials', TABLE_SPECIALS); $Qupcoming->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION); $Qupcoming->bindInt(':default_flag', 1); $Qupcoming->bindInt(':products_status', 1); $Qupcoming->bindInt(':language_id', $osC_Language->getID()); $Qupcoming->bindInt(':max_display_upcoming_products', MODULE_CONTENT_UPCOMING_PRODUCTS_MAX_DISPLAY); if (MODULE_CONTENT_UPCOMING_PRODUCTS_CACHE > 0) { $Qupcoming->setCache('upcoming_products-' . $osC_Language->getCode() . '-' . $osC_Currencies->getCode(), MODULE_CONTENT_UPCOMING_PRODUCTS_CACHE); } $Qupcoming->execute(); $i = 0; if ($Qupcoming->numberOfRows() > 0) { $this->_content = '<div class="upcomingProductsModule clearfix">'; while ($Qupcoming->next()) { $osC_Product = new osC_Product($Qupcoming->valueInt('products_id')); if ($i % 3 == 0 && $i != 0) { $this->_content .= '<div class="productItem clearLeft">'; } else { $this->_content .= '<div class="productItem">'; } $this->_content .= '<div class="productName">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $Qupcoming->value('products_id')), $Qupcoming->value('products_name')) . '</div>' . '<div>' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $Qupcoming->value('products_id')), $osC_Image->show($Qupcoming->value('image'), $Qupcoming->value('products_name'))) . '</div>' . '<div>' . $osC_Product->getPriceFormated(true) . '</div>' . '<div><strong>' . osC_DateTime::getLong($Qupcoming->value('date_expected')) . '</strong></div>'; $this->_content .= '</div>'; $i++; } $this->_content .= '</div>'; //add the css block for this module $osC_Template->addStyleDeclaration('.clearLeft{clear:left;} .upcomingProductsModule{overflow: auto; height: 100%;} .upcomingProductsModule .productItem{width: 32%; float: left; text-align: center; padding: 2px;} .upcomingProductsModule .productItem .productName{height:30px;} .upcomingProductsModule .productItem div {margin:3px 0;}'); } $Qupcoming->freeResult(); }
public function quote() { global $osC_ShoppingCart; $this->_setMachinable('False'); $this->_setContainer('None'); $this->_setSize('REGULAR'); // usps doesnt accept zero weight $shipping_weight = 0.1; foreach ($osC_ShoppingCart->getProducts() as $product) { $osC_Product = new osC_Product($product['id']); if ($osC_Product->isTypeActionAllowed('apply_shipping_fees')) { $shipping_weight += $product['weight'] * $product['quantity']; } } $shipping_pounds = floor($shipping_weight); $shipping_ounces = round(16 * ($shipping_weight - floor($shipping_weight))); $this->_setWeight($shipping_pounds, $shipping_ounces); $uspsQuote = $this->_getQuote(); if (is_array($uspsQuote)) { if (isset($uspsQuote['error'])) { $this->quotes = array('module' => $this->_title, 'error' => $uspsQuote['error']); } else { $this->quotes = array('id' => $this->_code, 'module' => $this->_title . ' (' . $osC_ShoppingCart->numberOfShippingBoxes() . ' x ' . ($osC_ShoppingCart->getShippingBoxesWeight() < 0.1 ? 0.1 : $osC_ShoppingCart->getShippingBoxesWeight()) . 'lbs)', 'tax_class_id' => $this->tax_class); $methods = array(); $size = sizeof($uspsQuote); for ($i = 0; $i < $size; $i++) { list($type, $cost) = each($uspsQuote[$i]); $methods[] = array('id' => $type, 'title' => isset($this->types[$type]) ? $this->types[$type] : $type, 'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $osC_ShoppingCart->numberOfShippingBoxes()); } $this->quotes['methods'] = $methods; } } else { $this->quotes = array('module' => $this->_title, 'error' => __('shipping_usps_error')); } if (!empty($this->icon)) { $this->quotes['icon'] = osc_image($this->icon, $this->_title); } return $this->quotes; }
public function quote() { global $osC_Currencies, $osC_Tax, $osC_ShoppingCart, $osC_Weight; $order_total = 0; if (MODULE_SHIPPING_TABLE_MODE == 'price') { foreach ($osC_ShoppingCart->getProducts() as $product) { $osC_Product = new osC_Product($product['id']); if ($osC_Product->isTypeActionAllowed('apply_shipping_fees')) { $tax = $osC_Tax->getTaxRate($product['tax_class_id'], $osC_ShoppingCart->getTaxingAddress('country_id'), $osC_ShoppingCart->getTaxingAddress('zone_id')); $order_total += $osC_Currencies->addTaxRateToPrice($product['price'], $tax, $product['quantity']); } } } else { foreach ($osC_ShoppingCart->getProducts() as $product) { $osC_Product = new osC_Product($product['id']); if ($osC_Product->isTypeActionAllowed('apply_shipping_fees')) { $order_total += $osC_Weight->convert($product['weight'], $product['weight_class_id'], MODULE_SHIPPING_TABLE_WEIGHT_UNIT) * $product['quantity']; } } } $table_cost = preg_split("/[:,]/", MODULE_SHIPPING_TABLE_COST); $size = sizeof($table_cost); for ($i = 0, $n = $size; $i < $n; $i += 2) { if ($order_total <= $table_cost[$i]) { $shipping = $table_cost[$i + 1]; break; } } if (MODULE_SHIPPING_TABLE_MODE == 'weight') { $shipping = $shipping * $osC_ShoppingCart->numberOfShippingBoxes(); } $this->quotes = array('id' => $this->_code, 'module' => $this->_title, 'methods' => array(array('id' => $this->_code, 'title' => __('shipping_table_method'), 'cost' => $shipping + MODULE_SHIPPING_TABLE_HANDLING)), 'tax_class_id' => $this->tax_class); if (!empty($this->icon)) { $this->quotes['icon'] = osc_image($this->icon, $this->_title); } return $this->quotes; }
function initialize() { global $osC_Database, $osC_Language, $osC_Currencies; $Qupcoming = $osC_Database->query('select p.products_id, pa.value as date_expected from :table_products p, :table_templates_boxes tb, :table_product_attributes pa where tb.code = :code and tb.id = pa.id and to_days(str_to_date(pa.value, "%Y-%m-%d")) >= to_days(now()) and pa.products_id = p.products_id and p.products_status = :products_status order by pa.value limit :max_display_upcoming_products'); $Qupcoming->bindTable(':table_products', TABLE_PRODUCTS); $Qupcoming->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); $Qupcoming->bindTable(':table_product_attributes', TABLE_PRODUCT_ATTRIBUTES); $Qupcoming->bindValue(':code', 'date_available'); $Qupcoming->bindInt(':products_status', 1); $Qupcoming->bindInt(':max_display_upcoming_products', MODULE_CONTENT_UPCOMING_PRODUCTS_MAX_DISPLAY); if (MODULE_CONTENT_UPCOMING_PRODUCTS_CACHE > 0) { $Qupcoming->setCache('upcoming_products-' . $osC_Language->getCode() . '-' . $osC_Currencies->getCode(), MODULE_CONTENT_UPCOMING_PRODUCTS_CACHE); } $Qupcoming->execute(); if ($Qupcoming->numberOfRows() > 0) { $this->_content = '<ol style="list-style: none;">'; while ($Qupcoming->next()) { $osC_Product = new osC_Product($Qupcoming->valueInt('products_id')); $this->_content .= '<li>' . osC_DateTime::getLong($Qupcoming->value('date_expected')) . ': ' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getKeyword()), $osC_Product->getTitle()) . ' ' . $osC_Product->getPriceFormated(true) . '</li>'; } $this->_content .= '</ol>'; } $Qupcoming->freeResult(); }
function osC_Products_Tell_a_friend() { global $osC_Services, $osC_Session, $osC_Language, $osC_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')) { $osC_Breadcrumb->add($osC_Product->getTitle(), osc_href_link(FILENAME_PRODUCTS, $osC_Product->getKeyword())); $osC_Breadcrumb->add($osC_Language->get('breadcrumb_tell_a_friend'), osc_href_link(FILENAME_PRODUCTS, $this->_module . '&' . $osC_Product->getKeyword())); } 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 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_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, 'cart_items' => $osC_ShoppingCart->numberOfItems()); } } } else { $response = array('success' => false); } echo $toC_Json->encode($response); }