示例#1
0
 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';
     }
 }
示例#2
0
 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';
     }
 }
示例#3
0
 function outputCompareProductsTable()
 {
     global $osC_Language, $osC_Image, $osC_Weight;
     $content = '';
     $products_images = '';
     $products_titles = '';
     $products_price = '';
     $products_weight = '';
     $products_sku = '';
     $products_manufacturers = '';
     $products_desciptions = '';
     $products_attributes = '';
     if ($this->hasContents()) {
         foreach ($this->getProducts() as $products_id) {
             $osC_Product = new osC_Product($products_id);
             $image = $osC_Product->getImages();
             $products_images .= '<td width="120" valign="top" align="center">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id), $osC_Image->show($image[0]['image'], $osC_Product->getTitle())) . '<br /><br />' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id . '&action=cart_add'), osc_draw_image_button('button_in_cart.gif', $osC_Language->get('button_add_to_cart'))) . '</td>';
             $products_titles .= '<td valign="top" align="center">' . $osC_Product->getTitle() . '</td>';
             $products_price .= '<td valign="top" align="center">' . $osC_Product->getPriceFormated(true) . '</td>';
             $products_weight .= '<td valign="top" align="center">' . $osC_Weight->display($osC_Product->getWeight(), $osC_Product->getWeightClass()) . '</td>';
             $products_sku .= '<td valign="top" align="center">' . $osC_Product->getSKU() . '</td>';
             $products_manufacturers .= '<td valign="top" align="center">' . $osC_Product->getManufacturer() . '</td>';
             $products_desciptions .= '<td valign="top" align="center">' . $osC_Product->getDescription() . '</td>';
             if ($osC_Product->hasAttributes()) {
                 foreach ($osC_Product->getAttributes() as $attribute) {
                     $products_attributes[$attribute['name']][$products_id] = $attribute['value'];
                 }
             }
         }
         $content .= '<table id="compareProducts" cellspacing="0" cellpadding="2" border="0">';
         $content .= '<tr class="odd"><td width="120">&nbsp;</td>' . $products_images . '</tr>';
         $content .= '<tr class="even"><td valign="top" align="left" class="label">' . $osC_Language->get('field_products_name') . '</td>' . $products_titles . '</tr>';
         $content .= '<tr class="odd"><td valign="top" align="left" class="label">' . $osC_Language->get('field_products_price') . '</td>' . $products_price . '</tr>';
         $content .= '<tr class="even"><td valign="top" align="left" class="label">' . $osC_Language->get('field_products_weight') . '</td>' . $products_weight . '</tr>';
         $content .= '<tr class="odd"><td valign="top" align="left" class="label">' . $osC_Language->get('field_products_sku') . '</td>' . $products_sku . '</tr>';
         $content .= '<tr class="even"><td valign="top" align="left" class="label">' . $osC_Language->get('field_products_manufacturer') . '</td>' . $products_manufacturers . '</tr>';
         if (!empty($products_attributes)) {
             $rows = 0;
             foreach ($products_attributes as $name => $attribute) {
                 $content .= '<tr class="' . ($rows / 2 == floor($rows / 2) ? 'odd' : 'even') . '">';
                 $content .= '<td valign="top" align="left" class="label">' . $name . ':</td>';
                 foreach ($this->getProducts() as $products_id) {
                     if (isset($attribute[$products_id])) {
                         $content .= '<td align = "center">' . $attribute[$products_id] . '</td>';
                     } else {
                         $content .= '<td align = "center"> -- </td>';
                     }
                 }
                 $content .= '</tr>';
                 $rows++;
             }
         }
         $content .= '<tr class="' . ($rows / 2 == floor($rows / 2) ? 'odd' : 'even') . '"><td valign="top" align="left" class="label">' . $osC_Language->get('field_products_description') . '</td>' . $products_desciptions . '</tr>';
         $content .= '</table></div>';
     }
     return $content;
 }
示例#4
0
 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'))) . '&nbsp;&nbsp;' . '</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 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'))) . '&nbsp;&nbsp;' . '</p>';
         $js .= '<script type="text/javascript">
               window.addEvent("domready",function() {
                 
                 var box = new MultiBox(\'multibox\', { 
                     movieWidth: 820,
                     movieHeight: 600
                 });
               });
             </script>';
         $this->_content .= "\n" . $js;
     }
 }
示例#6
0
 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'))) . '&nbsp;&nbsp;' . '</p>';
     }
 }
示例#7
0
 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';
     }
 }
示例#8
0
 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();
 }
示例#9
0
?>

<?php 
if ($osC_Product->hasAccessories()) {
    $accessories = $osC_Product->getAccessories();
    ?>
    <div id="tabAccessories">
      <div class="moduleBox">
        <div class="content">
          <?php 
    foreach ($accessories as $accessory) {
        $product = new osC_Product($accessory);
        ?>
          <div class="accessories">
            <div class="image"><?php 
        echo osc_link_object(osc_href_link(FILENAME_PRODUCTS, $accessory), $osC_Image->show($product->getImage(), $product->getTitle()));
        ?>
</div>
            <div class="desc">
              <h6><?php 
        echo osc_link_object(osc_href_link(FILENAME_PRODUCTS, $accessory), $product->getTitle());
        ?>
</h6>
              <p><?php 
        echo $product->getShortDescription();
        ?>
</p>
            </div>
          </div>
          <div style="clear: both"></div>
          <?php 
 function outputCompareProductsTable()
 {
     global $osC_Language, $osC_Image, $osC_Weight, $osC_Currencies;
     $content = '';
     $products_images = array();
     $products_titles = array();
     $products_price = array();
     $products_weight = array();
     $products_sku = array();
     $products_manufacturers = array();
     $products_desciptions = array();
     $products_attributes = array();
     $products_variants = array();
     $cols = array('<col width="20%">');
     $col_width = round(80 / count($this->getProducts()));
     if ($this->hasContents()) {
         foreach ($this->getProducts() as $products_id) {
             $cols[] = '<col width="' . $col_width . '%">';
             $osC_Product = new osC_Product($products_id);
             $image = $osC_Product->getImages();
             $product_title = $osC_Product->getTitle();
             $product_price = $osC_Product->getPriceFormated(true);
             $product_weight = $osC_Product->getWeight();
             $product_sku = $osC_Product->getSKU();
             //if the product have any variants, it means that the $products_id should be a product string such as 1#1:1;2:2
             $variants = array();
             if ($osC_Product->hasVariants()) {
                 $product_variants = $osC_Product->getVariants();
                 if (preg_match('/^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)+$/', $products_id)) {
                     $products_variant = $product_variants[$products_id];
                     $variants = osc_parse_variants_from_id_string($products_id);
                 } else {
                     $products_variant = $osC_Product->getDefaultVariant();
                     $variants = $products_variant['groups_id'];
                 }
                 //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'])) {
                     $products_variants[$products_id]['variants'] = array();
                     foreach ($products_variant['groups_name'] as $groups_name => $value_name) {
                         $products_variants[$products_id]['variants'][] = array('name' => $groups_name, 'value' => $value_name);
                     }
                 }
                 $product_price = $osC_Currencies->displayPrice($osC_Product->getPrice($variants), $osC_Product->getTaxClassID());
                 $product_weight = $products_variant['weight'];
                 $product_sku = $products_variant['sku'];
                 $image = $products_variant['image'];
             }
             $image = is_array($image) ? $image[0]['image'] : $image;
             $products_titles[] = $product_title;
             if (!osc_empty($product_price)) {
                 $products_price[] = $product_price;
             }
             if (!osc_empty($product_weight)) {
                 $products_weight[] = $osC_Weight->display($product_weight, $osC_Product->getWeightClass());
             }
             if (!osc_empty($product_sku)) {
                 $products_sku[] = $product_sku;
             }
             if (!osc_empty($osC_Product->getManufacturer())) {
                 $products_manufacturers[] = $osC_Product->getManufacturer();
             }
             if (!osc_empty($osC_Product->getDescription())) {
                 $products_desciptions[] = $osC_Product->getDescription();
             }
             if ($osC_Product->hasAttributes()) {
                 foreach ($osC_Product->getAttributes() as $attribute) {
                     $products_attributes[$products_id]['attributes'][] = array('name' => $attribute['name'], 'value' => $attribute['value']);
                 }
             }
             $products_id = str_replace('#', '_', $products_id);
             $products_images[] = '<div class="image">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id), $osC_Image->show($image, $osC_Product->getTitle())) . '</div>' . '<div class="button">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id . '&action=cart_add' . (osc_empty(osc_parse_variants_array($variants)) ? '' : '&variants=' . osc_parse_variants_array($variants))), osc_draw_image_button('button_in_cart.gif', $osC_Language->get('button_add_to_cart'))) . '</div>';
         }
         $content .= '<table id="compareProducts" cellspacing="0" cellpadding="2" border="0">';
         //add col groups
         $content .= '<colgroup>';
         foreach ($cols as $col) {
             $content .= $col;
         }
         $content .= '</colgroup>';
         //add product header
         $content .= '<tbody>';
         $content .= '<tr class="first">';
         $content .= '<th>&nbsp;</th>';
         if (!osc_empty($products_images)) {
             foreach ($products_images as $k => $product_image) {
                 $content .= '<td' . ($k == count($products_images) - 1 ? ' class="last"' : '') . '>' . $product_image . '</td>';
             }
         }
         $content .= '</tr>';
         $content .= '</tbody>';
         //add compare details
         $content .= '<tbody>';
         $row_class = 'even';
         //add product name
         if (!osc_empty($products_titles)) {
             $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_name') . '</th>';
             foreach ($products_titles as $k => $product_title) {
                 $content .= '<td' . ($k == count($products_titles) - 1 ? ' class="last"' : '') . '>' . $product_title . '</td>';
             }
             $content .= '</tr>';
             $row_class = $row_class == 'even' ? 'odd' : 'even';
         }
         //add product price
         if (!osc_empty($products_price)) {
             $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_price') . '</th>';
             foreach ($products_price as $k => $product_price) {
                 $content .= '<td' . ($k == count($products_price) - 1 ? ' class="last"' : '') . '>' . $product_price . '</td>';
             }
             $content .= '</tr>';
             $row_class = $row_class == 'even' ? 'odd' : 'even';
         }
         //add product weight
         if (!osc_empty($products_weight)) {
             $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_weight') . '</th>';
             foreach ($products_weight as $k => $product_weight) {
                 $content .= '<td' . ($k == count($products_weight) - 1 ? ' class="last"' : '') . '>' . $product_weight . '</td>';
             }
             $content .= '</tr>';
             $row_class = $row_class == 'even' ? 'odd' : 'even';
         }
         //add product sku
         if (!osc_empty($products_sku)) {
             $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_sku') . '</th>';
             foreach ($products_sku as $k => $product_sku) {
                 $content .= '<td' . ($k == count($products_sku) - 1 ? ' class="last"' : '') . '>' . $product_sku . '</td>';
             }
             $content .= '</tr>';
             $row_class = $row_class == 'even' ? 'odd' : 'even';
         }
         //add product manufacturers
         if (!osc_empty($products_manufacturers)) {
             $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_manufacturer') . '</th>';
             foreach ($products_manufacturers as $k => $product_manufacturer) {
                 $content .= '<td' . ($k == count($products_manufacturers) - 1 ? ' class="last"' : '') . '>' . $product_manufacturer . '</td>';
             }
             $content .= '</tr>';
             $row_class = $row_class == 'even' ? 'odd' : 'even';
         }
         //add product variants
         if (!osc_empty($products_variants)) {
             $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_variants') . '</th>';
             foreach ($this->getProducts() as $k => $products_id) {
                 if (isset($products_variants[$products_id]['variants']) && !osc_empty($products_variants[$products_id]['variants'])) {
                     $content .= '<td' . ($k == count($this->getProducts()) - 1 ? ' class="last"' : '') . '>';
                     foreach ($products_variants[$products_id]['variants'] as $variant) {
                         $content .= '<span class="variant">' . $variant['name'] . ': ' . $variant['value'] . '</span>';
                     }
                     $content .= '</td>';
                 }
             }
             $content .= '</tr>';
             $row_class = $row_class == 'even' ? 'odd' : 'even';
         }
         //add product attributes
         if (!osc_empty($products_attributes)) {
             $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_attributes') . '</th>';
             foreach ($this->getProducts() as $k => $products_id) {
                 if (isset($products_attributes[$products_id]['attributes']) && !osc_empty($products_attributes[$products_id]['attributes'])) {
                     $content .= '<td' . ($k == count($this->getProducts()) - 1 ? ' class="last"' : '') . '>';
                     foreach ($products_attributes[$products_id]['attributes'] as $attribute) {
                         $content .= '<span class="attribute">' . $attribute['name'] . ': ' . $attribute['value'] . '</span>';
                     }
                     $content .= '</td>';
                 }
             }
             $content .= '</tr>';
             $row_class = $row_class == 'even' ? 'odd' : 'even';
         }
         //add product description
         if (!osc_empty($products_desciptions)) {
             $content .= '<tr class="' . $row_class . ' last">' . '<th>' . $osC_Language->get('field_products_description') . '</th>';
             foreach ($products_desciptions as $k => $product_description) {
                 $content .= '<td' . ($k == count($products_desciptions) - 1 ? ' class="last"' : '') . '>' . $product_description . '</td>';
             }
             $content .= '</tr>';
             $row_class = $row_class == 'even' ? 'odd' : 'even';
         }
         $content .= '</tbody>';
         $content .= '</table>';
     }
     return $content;
 }
示例#11
0
$osC_Products->setSortBy('date_added', '-');
$Qproducts = $osC_Products->execute();
if ($Qproducts->numberOfRows() > 0) {
    while ($Qproducts->next()) {
        $osC_Product = new osC_Product($Qproducts->valueInt('products_id'));
        ?>

  <tr>
    <td width="<?php 
        echo $osC_Image->getWidth('thumbnails') + 10;
        ?>
" valign="top" align="center">

<?php 
        if ($osC_Product->hasImage()) {
            echo osc_link_object(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getKeyword()), $osC_Image->show($osC_Product->getImage(), $osC_Product->getTitle()));
        }
        ?>

    </td>
    <td valign="top"><?php 
        echo osc_link_object(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getKeyword()), '<b><u>' . $osC_Product->getTitle() . '</u></b>') . '<br />' . $osC_Language->get('date_added') . ' ' . osC_DateTime::getLong($osC_Product->getDateAdded()) . '<br />' . $osC_Language->get('manufacturer') . ' ' . $osC_Product->getManufacturer() . '<br /><br />' . $osC_Language->get('price') . ' ' . $osC_Product->getPriceFormated();
        ?>
</td>
    <td align="right" valign="middle"><?php 
        echo osc_link_object(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getKeyword() . '&action=cart_add'), osc_draw_image_button('button_in_cart.gif', $osC_Language->get('button_add_to_cart')));
        ?>
</td>
  </tr>
  <tr>
    <td colspan="3">&nbsp;</td>
 /**
  * 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;
 }
示例#13
0
 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();
         }
     }
 }
                $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);
        }
    }
    ?>
          	<li>
          		<span class="pull-right" style="margin: 0 3px 1px 3px; width: 16px"><a href="<?php 
    echo osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), 'cid=' . $cid . '&' . osc_get_all_get_params(array('cid', 'action')) . '&action=compare_products_remove');
    ?>
"> <i class="icon-trash"></i> </a></span>
          		<?php 
    echo osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id), $osC_Product->getTitle() . $str_variants, 'style="width: 160px"');
    ?>
          	</li>
            <?php 
}
?>
		</ul>
        <p>
            <span style="float: right"><a class="btn btn-mini multibox" rel="ajax:true" href="<?php 
echo osc_href_link(FILENAME_JSON, 'module=products&action=compare_products&template=' . $osC_Template->getCode());
?>
"><?php 
echo $osC_Language->get('button_compare_now');
?>
</a></span>
            <a class="btn btn-mini" href="<?php 
示例#15
0
 function buildProductsRss($group)
 {
     global $osC_Language, $osC_Image;
     $group_title = $group . '_products';
     $rss = array();
     $rss['rss'] = array();
     $rss['rss attr'] = array('xmlns:atom' => 'http://www.w3.org/2005/Atom', 'version' => '2.0');
     //channel
     $rss['rss']['channel'] = array('title' => '<![CDATA[' . $osC_Language->get($group_title) . ']]>', 'link' => '<![CDATA[' . osc_href_link(FILENAME_PRODUCTS, $group) . ']]>', 'description' => '<![CDATA[' . $osC_Language->get($group_title) . ']]>', 'pubDate' => date("D, d M Y H:i:s O"));
     //items
     if ($group == "new") {
         $Qproducts = osC_Product::getListingNew();
     } else {
         if ($group == 'special') {
             $Qproducts = osC_Specials::getListing();
         } else {
             if ($group == 'feature') {
                 $Qproducts = osC_Product::getListingFeature();
             }
         }
     }
     $items = array();
     while ($Qproducts->next()) {
         $osC_Product = new osC_Product($Qproducts->valueInt('products_id'));
         $link = osc_href_link(FILENAME_PRODUCTS, $Qproducts->valueInt('products_id'), 'NONSSL', false, false, true);
         $description = '
     <![CDATA[
     <table>
       <tr>
         <td align="center" valign="top">' . osc_link_object($link, osc_image($osC_Image->getImageUrl($osC_Product->getImage(), 'product_info'), $osC_Product->getTitle())) . '</td>
         <td valign="top">' . $osC_Product->getDescription() . '</td>
       </tr>
     </table>
     ]]>';
         $items[] = array('title' => '<![CDATA[' . $osC_Product->getTitle() . ' -- ' . $osC_Product->getPriceFormated() . ']]>', 'link' => '<![CDATA[' . $link . ']]>', 'description' => $description, 'pubDate' => date("D, d M Y H:i:s O"));
     }
     $rss['rss']['channel']['item'] = $items;
     return $rss;
 }
示例#16
0
 function listChooseProducts()
 {
     global $toC_Json, $osC_Database, $osC_Language, $osC_Currencies, $osC_Tax;
     $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start'];
     $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit'];
     $Qproducts = $osC_Database->query('select SQL_CALC_FOUND_ROWS * from :table_products p left join :table_products_description pd on p.products_id = pd.products_id where p.products_status = 1 and pd.language_id = :language_id and p.products_status = 1');
     if (!empty($_REQUEST['search'])) {
         $Qproducts->appendQuery('and pd.products_name  like :products_name');
         $Qproducts->bindValue(':products_name', '%' . $_REQUEST['search'] . '%');
     }
     $Qproducts->appendQuery('order by p.products_id ');
     $Qproducts->bindTable(':table_products', TABLE_PRODUCTS);
     $Qproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
     $Qproducts->bindInt(':language_id', $osC_Language->getID());
     $Qproducts->setExtBatchLimit($start, $limit);
     $Qproducts->execute();
     $osC_Currencies = new osC_Currencies();
     $osC_Order = new osC_Order($_REQUEST['orders_id']);
     $osC_Tax = new osC_Tax_Admin();
     $_SESSION['currency'] = $osC_Order->getCurrency();
     $records = array();
     while ($Qproducts->next()) {
         $products_id = $Qproducts->valueInt('products_id');
         $osC_Product = new osC_Product($products_id, $osC_Order->getCustomer('customers_id'));
         if (!$osC_Product->hasVariants()) {
             $products_name = $osC_Product->getTitle();
             $products_price = $osC_Product->getPriceFormated();
             if ($osC_Product->isGiftCertificate()) {
                 $products_name .= '<table cellspacing="0" cellpadding="0" border="0">';
                 if ($osC_Product->isOpenAmountGiftCertificate()) {
                     $products_name .= '<tr><td><i>--&nbsp;&nbsp;' . $osC_Language->get('field_amount') . '</i></td><td><input id="' . $products_id . '_price' . '" type="text" class="x-form-text x-form-field x-form-empty-field" style="width: 140px" value="' . round($osC_Product->getOpenAmountMinValue() * $osC_Order->getCurrencyValue(), 2) . '"/></td></tr>';
                 }
                 if ($osC_Product->isEmailGiftCertificate()) {
                     $products_name .= '<tr><td><i>--&nbsp;&nbsp;' . $osC_Language->get('field_recipient_sender_name') . '</i></td><td><input id="' . $products_id . '_sender_name' . '" type="text" class="x-form-text x-form-field x-form-empty-field" style="width: 140px" /></td></tr>' . '<tr><td><i>--&nbsp;&nbsp;' . $osC_Language->get('field_recipient_sender_email') . '</i></td><td><input id="' . $products_id . '_sender_email' . '" type="text" class="x-form-text x-form-field x-form-empty-field" style="width: 140px" /></td></tr>' . '<tr><td><i>--&nbsp;&nbsp;' . $osC_Language->get('field_recipient_name') . '</i></td><td><input id="' . $products_id . '_recipient_name' . '" type="text" class="x-form-text x-form-field x-form-empty-field" style="width: 140px" /></td></tr>' . '<tr><td><i>--&nbsp;&nbsp;' . $osC_Language->get('field_recipient_email') . '</i></td><td><input id="' . $products_id . '_recipient_email' . '" type="text" class="x-form-text x-form-field x-form-empty-field" style="width: 140px" /></td></tr>' . '<tr><td><i>--&nbsp;&nbsp;' . $osC_Language->get('field_message') . '</i></td><td><textarea id="' . $products_id . '_message' . '" class=" x-form-textarea x-form-field" style="width: 140px" /></textarea></td></tr>';
                 } else {
                     if ($osC_Product->isPhysicalGiftCertificate()) {
                         $products_name .= '<tr><td><i>--&nbsp;&nbsp;' . $osC_Language->get('field_recipient_sender_name') . '</i></td><td><input id="' . $products_id . '_sender_name' . '" type="text" class="x-form-text x-form-field x-form-empty-field" style="width: 140px" /></td></tr>' . '<tr><td><i>--&nbsp;&nbsp;' . $osC_Language->get('field_recipient_name') . '</i></td><td><input id="' . $products_id . '_recipient_name' . '" type="text" class="x-form-text x-form-field x-form-empty-field" style="width: 140px" /></td></tr>' . '<tr><td><i>--&nbsp;&nbsp;' . $osC_Language->get('field_message') . '</i></td><td><textarea id="' . $products_id . '_message' . '" class=" x-form-textarea x-form-field" style="width: 140px" /></textarea></td></tr>';
                     }
                 }
                 $products_name .= '</table>';
             }
             $records[] = array('products_id' => $products_id, 'products_name' => $products_name, 'products_type' => $osC_Product->getProductType(), 'products_sku' => $osC_Product->getSKU(), 'products_price' => $products_price, 'products_quantity' => $osC_Product->getQuantity(), 'new_qty' => $Qproducts->valueInt('products_moq'), 'has_variants' => false);
         } else {
             $records[] = array('products_id' => $products_id, 'products_name' => $osC_Product->getTitle(), 'products_type' => $osC_Product->getProductType(), 'products_sku' => $osC_Product->getSKU(), 'products_price' => $osC_Product->getPriceFormated(), 'products_quantity' => $osC_Product->getQuantity(), 'new_qty' => $Qproducts->valueInt('products_moq'), 'has_variants' => true);
             foreach ($osC_Product->getVariants() as $product_id_string => $details) {
                 $variants = '';
                 foreach ($details['groups_name'] as $groups_name => $values_name) {
                     $variants .= '&nbsp;&nbsp;&nbsp;<i>' . $groups_name . ' : ' . $values_name . '</i><br />';
                 }
                 $records[] = array('products_id' => $product_id_string, 'products_name' => $variants, 'products_type' => $osC_Product->getProductType(), 'products_sku' => $osC_Product->getSKU(osc_parse_variants_from_id_string($product_id_string)), 'products_price' => $osC_Currencies->format($osC_Product->getPrice(osc_parse_variants_from_id_string($product_id_string)), $osC_Order->getCurrency()), 'products_quantity' => $details['quantity'], 'new_qty' => $Qproducts->valueInt('products_moq'), 'has_variants' => false);
             }
         }
     }
     unset($_SESSION['currency']);
     $response = array(EXT_JSON_READER_TOTAL => $Qproducts->getBatchSize(), EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
示例#17
0
 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();
     }
 }
示例#18
0
 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';
             }
         }
     }
 }
 function _getShoppingCart()
 {
     global $osC_ShoppingCart, $osC_Currencies, $osC_Language, $osC_Customer;
     //when the language is changed, it is necessary to update the shopping cart
     if (isset($_SESSION['language_change']) && $_SESSION['language_change'] == true) {
         if ($osC_Customer->isLoggedOn()) {
             $osC_ShoppingCart->reset();
             $osC_ShoppingCart->synchronizeWithDatabase();
         } else {
             foreach ($osC_ShoppingCart->getProducts() as $products_id_string => $data) {
                 $osC_Product = new osC_Product($products_id_string);
                 $data['name'] = $osC_Product->getTitle();
                 $data['keyword'] = $osC_Product->getKeyword();
                 $_SESSION['osC_ShoppingCart_data']['contents'][$products_id_string] = $data;
             }
             $osC_ShoppingCart->_calculate();
         }
         unset($_SESSION['language_change']);
     }
     $cart = array();
     //products
     $products = array();
     foreach ($osC_ShoppingCart->getProducts() as $products_id => $data) {
         $product = array('id' => $products_id, 'link' => osc_href_link(FILENAME_PRODUCTS, osc_get_product_id($products_id)), 'name' => substr($data['name'], 0, self::PRODUCTS_NAME_LENGTH) . (strlen($data['name']) > self::PRODUCTS_NAME_LENGTH ? '..' : ''), 'title' => $data['name'], 'quantity' => $data['quantity'] . ' x ', 'price' => $osC_Currencies->displayPrice($data['price'], $data['tax_class_id'], $data['quantity']));
         //variants
         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;
 }
示例#20
0
 $rows = 0;
 while ($Qlisting->next()) {
     $osC_Product = new osC_Product($Qlisting->valueInt('products_id'));
     $rows++;
     echo '    <tr class="' . ($rows / 2 == floor($rows / 2) ? 'productListing-even' : 'productListing-odd') . '">' . "\n";
     for ($col = 0, $n = sizeof($column_list); $col < $n; $col++) {
         $lc_align = '';
         switch ($column_list[$col]) {
             case 'PRODUCT_LIST_MODEL':
                 $lc_align = '';
                 $lc_text = '&nbsp;' . $osC_Product->getModel() . '&nbsp;';
                 break;
             case 'PRODUCT_LIST_NAME':
                 $lc_align = '';
                 if (isset($_GET['manufacturers'])) {
                     $lc_text = osc_link_object(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getKeyword() . '&manufacturers=' . $_GET['manufacturers']), $osC_Product->getTitle());
                 } else {
                     $lc_text = '&nbsp;' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getKeyword() . ($cPath ? '&cPath=' . $cPath : '')), $osC_Product->getTitle()) . '&nbsp;';
                 }
                 break;
             case 'PRODUCT_LIST_MANUFACTURER':
                 $lc_align = '';
                 $lc_text = '&nbsp;';
                 if ($osC_Product->hasManufacturer()) {
                     $lc_text = '&nbsp;' . osc_link_object(osc_href_link(FILENAME_DEFAULT, 'manufacturers=' . $osC_Product->getManufacturerID()), $osC_Product->getManufacturer()) . '&nbsp;';
                 }
                 break;
             case 'PRODUCT_LIST_PRICE':
                 $lc_align = 'right';
                 $lc_text = '&nbsp;' . $osC_Product->getPriceFormated() . '&nbsp;';
                 break;
 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;
 }
$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>    
 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();
                 }
             }
         }
     }
 }
示例#24
0
 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';
     }
 }
示例#25
0
 /**
  * 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;
 }
function output_compare_products_table()
{
    global $osC_Language, $osC_Image, $osC_Weight, $osC_Currencies, $toC_Compare_Products, $osC_Services;
    $content = '';
    $products_images = array();
    $products_titles = array();
    $products_price = array();
    $products_weight = array();
    $products_sku = array();
    $products_manufacturers = array();
    $products_desciptions = array();
    $products_attributes = array();
    $products_variants = array();
    $cols = array('<col width="20%">');
    $col_width = round(80 / count($toC_Compare_Products->getProducts()));
    if ($toC_Compare_Products->hasContents()) {
        foreach ($toC_Compare_Products->getProducts() as $products_id_string) {
            $cols[] = '<col width="' . $col_width . '%">';
            $osC_Product = new osC_Product($products_id_string);
            $products_id = osc_get_product_id($products_id_string);
            $image = $osC_Product->getImages();
            $product_title = $osC_Product->getTitle();
            $product_price = $osC_Product->getPriceFormated(true);
            $product_weight = $osC_Product->getWeight();
            $product_sku = $osC_Product->getSKU();
            //if the product have any variants, it means that the $products_id should be a product string such as 1#1:1;2:2
            $variants = array();
            if ($osC_Product->hasVariants()) {
                $product_variants = $osC_Product->getVariants();
                if (preg_match('/^[0-9]+(?:#?(?:[0-9]+:?[0-9]+)+(?:;?([0-9]+:?[0-9]+)+)*)+$/', $products_id_string)) {
                    $products_variant = $product_variants[$products_id_string];
                    $variants = osc_parse_variants_from_id_string($products_id_string);
                } else {
                    $products_variant = $osC_Product->getDefaultVariant();
                    $variants = $products_variant['groups_id'];
                }
                //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'])) {
                    $products_variants[$products_id_string]['variants'] = array();
                    foreach ($products_variant['groups_name'] as $groups_name => $value_name) {
                        $products_variants[$products_id_string]['variants'][] = array('name' => $groups_name, 'value' => $value_name);
                    }
                }
                $product_price = $osC_Currencies->displayPrice($osC_Product->getPrice($variants), $osC_Product->getTaxClassID());
                $product_weight = $products_variant['weight'];
                $product_sku = $products_variant['sku'];
                $image = $products_variant['image'];
            }
            $image = is_array($image) ? $image[0]['image'] : $image;
            $products_titles[] = $product_title;
            if (!osc_empty($product_price)) {
                $products_price[] = $product_price;
            }
            if (!osc_empty($product_weight)) {
                $products_weight[] = $osC_Weight->display($product_weight, $osC_Product->getWeightClass());
            }
            if (!osc_empty($product_sku)) {
                $products_sku[] = $product_sku;
            }
            if (!osc_empty($osC_Product->getManufacturer())) {
                $products_manufacturers[] = $osC_Product->getManufacturer();
            }
            if (!osc_empty($osC_Product->getDescription())) {
                $products_desciptions[] = $osC_Product->getDescription();
            }
            if ($osC_Product->hasAttributes()) {
                foreach ($osC_Product->getAttributes() as $attribute) {
                    $products_attributes[$products_id]['attributes'][] = array('name' => $attribute['name'], 'value' => $attribute['value']);
                }
            }
            $products_id_string = str_replace('#', '_', $products_id_string);
            //used to fix bug [#209 - Compare / wishlist variant problem]
            if (isset($osC_Services) && $osC_Services->isStarted('sefu') && count($variants) > 0) {
                $products_images[] = '<div class="image">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id), $osC_Image->show($image, $osC_Product->getTitle())) . '</div>' . '<div class="button">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id . '&pid=' . $products_id_string . '&action=cart_add'), '<i class="icon-shopping-cart icon-white"></i> ' . $osC_Language->get('button_add_to_cart'), 'class="btn btn-mini"') . '</div>';
            } else {
                $products_images[] = '<div class="image">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id), $osC_Image->show($image, $osC_Product->getTitle())) . '</div>' . '<div class="button">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id_string . '&action=cart_add'), '<i class="icon-shopping-cart icon-white"></i> ' . $osC_Language->get('button_add_to_cart'), 'class="btn btn-mini"') . '</div>';
            }
        }
        $content .= '<table class="table table-hover table-striped">';
        //add col groups
        $content .= '<colgroup>';
        foreach ($cols as $col) {
            $content .= $col;
        }
        $content .= '</colgroup>';
        //add product header
        $content .= '<tbody>';
        $content .= '<tr class="first">';
        $content .= '<th>&nbsp;</th>';
        if (!osc_empty($products_images)) {
            foreach ($products_images as $k => $product_image) {
                $content .= '<td' . ($k == count($products_images) - 1 ? ' class="last"' : '') . '>' . $product_image . '</td>';
            }
        }
        $content .= '</tr>';
        $content .= '</tbody>';
        //add compare details
        $content .= '<tbody>';
        $row_class = 'even';
        //add product name
        if (!osc_empty($products_titles)) {
            $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_name') . '</th>';
            foreach ($products_titles as $k => $product_title) {
                $content .= '<td' . ($k == count($products_titles) - 1 ? ' class="last"' : '') . '>' . $product_title . '</td>';
            }
            $content .= '</tr>';
            $row_class = $row_class == 'even' ? 'odd' : 'even';
        }
        //add product price
        if (!osc_empty($products_price)) {
            $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_price') . '</th>';
            foreach ($products_price as $k => $product_price) {
                $content .= '<td' . ($k == count($products_price) - 1 ? ' class="last"' : '') . '>' . $product_price . '</td>';
            }
            $content .= '</tr>';
            $row_class = $row_class == 'even' ? 'odd' : 'even';
        }
        //add product weight
        if (!osc_empty($products_weight)) {
            $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_weight') . '</th>';
            foreach ($products_weight as $k => $product_weight) {
                $content .= '<td' . ($k == count($products_weight) - 1 ? ' class="last"' : '') . '>' . $product_weight . '</td>';
            }
            $content .= '</tr>';
            $row_class = $row_class == 'even' ? 'odd' : 'even';
        }
        //add product sku
        if (!osc_empty($products_sku)) {
            $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_sku') . '</th>';
            foreach ($products_sku as $k => $product_sku) {
                $content .= '<td' . ($k == count($products_sku) - 1 ? ' class="last"' : '') . '>' . $product_sku . '</td>';
            }
            $content .= '</tr>';
            $row_class = $row_class == 'even' ? 'odd' : 'even';
        }
        //add product manufacturers
        if (!osc_empty($products_manufacturers)) {
            $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_manufacturer') . '</th>';
            foreach ($products_manufacturers as $k => $product_manufacturer) {
                $content .= '<td' . ($k == count($products_manufacturers) - 1 ? ' class="last"' : '') . '>' . $product_manufacturer . '</td>';
            }
            $content .= '</tr>';
            $row_class = $row_class == 'even' ? 'odd' : 'even';
        }
        //add product variants
        if (!osc_empty($products_variants)) {
            $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_variants') . '</th>';
            foreach ($toC_Compare_Products->getProducts() as $k => $products_id_string) {
                if (isset($products_variants[$products_id_string]['variants']) && !osc_empty($products_variants[$products_id_string]['variants'])) {
                    $content .= '<td' . ($k == count($toC_Compare_Products->getProducts()) - 1 ? ' class="last"' : '') . '>';
                    foreach ($products_variants[$products_id_string]['variants'] as $variant) {
                        $content .= '<span class="variant label label-info">' . $variant['name'] . ': ' . $variant['value'] . '</span>&nbsp;&nbsp;';
                    }
                    $content .= '</td>';
                }
            }
            $content .= '</tr>';
            $row_class = $row_class == 'even' ? 'odd' : 'even';
        }
        //add product attributes
        if (!osc_empty($products_attributes)) {
            $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_attributes') . '</th>';
            foreach ($toC_Compare_Products->getProducts() as $k => $products_id_string) {
                if (isset($products_attributes[$products_id_string]['attributes']) && !osc_empty($products_attributes[$products_id_string]['attributes'])) {
                    $content .= '<td' . ($k == count($toC_Compare_Products->getProducts()) - 1 ? ' class="last"' : '') . '>';
                    foreach ($products_attributes[$products_id_string]['attributes'] as $attribute) {
                        $content .= '<span class="attribute">' . $attribute['name'] . ': ' . $attribute['value'] . '</span>';
                    }
                    $content .= '</td>';
                }
            }
            $content .= '</tr>';
            $row_class = $row_class == 'even' ? 'odd' : 'even';
        }
        //add product description
        if (!osc_empty($products_desciptions)) {
            $content .= '<tr class="' . $row_class . ' last">' . '<th>' . $osC_Language->get('field_products_description') . '</th>';
            foreach ($products_desciptions as $k => $product_description) {
                $content .= '<td' . ($k == count($products_desciptions) - 1 ? ' class="last"' : '') . '>' . $product_description . '</td>';
            }
            $content .= '</tr>';
            $row_class = $row_class == 'even' ? 'odd' : 'even';
        }
        $content .= '</tbody>';
        $content .= '</table>';
    }
    return $content;
}