Example #1
0
 public static function execute(ApplicationAbstract $application)
 {
     $OSCOM_ShoppingCart = Registry::get('ShoppingCart');
     $requested_product = null;
     if (count($_GET) > 2) {
         $requested_product = basename(key(array_slice($_GET, 2, 1, true)));
         if ($requested_product == 'Add') {
             unset($requested_product);
             if (count($_GET) > 3) {
                 $requested_product = basename(key(array_slice($_GET, 3, 1, true)));
             }
         }
     }
     if (isset($requested_product)) {
         if (Product::checkEntry($requested_product)) {
             $OSCOM_Product = new Product($requested_product);
             if ($OSCOM_Product->isTypeActionAllowed('AddToShoppingCart')) {
                 if ($OSCOM_Product->hasVariants()) {
                     if (isset($_POST['variants']) && is_array($_POST['variants']) && !empty($_POST['variants'])) {
                         if ($OSCOM_Product->variantExists($_POST['variants'])) {
                             $OSCOM_ShoppingCart->add($OSCOM_Product->getProductVariantID($_POST['variants']));
                         } else {
                             OSCOM::redirect(OSCOM::getLink(null, 'Products', $OSCOM_Product->getKeyword()));
                         }
                     } else {
                         OSCOM::redirect(OSCOM::getLink(null, 'Products', $OSCOM_Product->getKeyword()));
                     }
                 } else {
                     $OSCOM_ShoppingCart->add($OSCOM_Product->getID());
                 }
             }
         }
     }
     OSCOM::redirect(OSCOM::getLink(null, 'Cart'));
 }
Example #2
0
 public function initialize()
 {
     $OSCOM_Database = Registry::get('Database');
     $OSCOM_Language = Registry::get('Language');
     $OSCOM_Currencies = Registry::get('Currencies');
     $Qupcoming = $OSCOM_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->bindValue(':code', 'DateAvailable');
     $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-' . $OSCOM_Language->getCode() . '-' . $OSCOM_Currencies->getCode(), MODULE_CONTENT_UPCOMING_PRODUCTS_CACHE);
     }
     $Qupcoming->execute();
     if ($Qupcoming->numberOfRows() > 0) {
         $this->_content = '<ol style="list-style: none;">';
         while ($Qupcoming->next()) {
             $OSCOM_Product = new Product($Qupcoming->valueInt('products_id'));
             $this->_content .= '<li>' . DateTime::getLong($Qupcoming->value('date_expected')) . ': ' . osc_link_object(OSCOM::getLink(null, 'Products', $OSCOM_Product->getKeyword()), $OSCOM_Product->getTitle()) . ' ' . $OSCOM_Product->getPriceFormated(true) . '</li>';
         }
         $this->_content .= '</ol>';
     }
     $Qupcoming->freeResult();
 }
 public function initialize()
 {
     $OSCOM_PDO = Registry::get('PDO');
     $OSCOM_Language = Registry::get('Language');
     $OSCOM_Currencies = Registry::get('Currencies');
     $Qupcoming = $OSCOM_PDO->prepare('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->bindValue(':code', 'DateAvailable');
     $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-' . $OSCOM_Language->getCode() . '-' . $OSCOM_Currencies->getCode(), MODULE_CONTENT_UPCOMING_PRODUCTS_CACHE);
     }
     $Qupcoming->execute();
     $result = $Qupcoming->fetchAll();
     if (!empty($result)) {
         $this->_content = '<ol style="list-style: none;">';
         foreach ($result as $r) {
             $OSCOM_Product = new Product($r['products_id']);
             $this->_content .= '<li>' . DateTime::getLong($r['date_expected']) . ': ' . HTML::link(OSCOM::getLink(null, 'Products', $OSCOM_Product->getKeyword()), $OSCOM_Product->getTitle()) . ' ' . $OSCOM_Product->getPriceFormated(true) . '</li>';
         }
         $this->_content .= '</ol>';
     }
 }
Example #4
0
 function getProducts()
 {
     $history = array();
     if (isset($this->visits['products']) && empty($this->visits['products']) === false) {
         $counter = 0;
         foreach ($this->visits['products'] as $k => $v) {
             $counter++;
             $OSCOM_Product = new Product($v['id']);
             $OSCOM_Category = new Category($OSCOM_Product->getCategoryID());
             $history[] = array('name' => $OSCOM_Product->getTitle(), 'id' => $OSCOM_Product->getID(), 'keyword' => $OSCOM_Product->getKeyword(), 'price' => SERVICE_RECENTLY_VISITED_SHOW_PRODUCT_PRICES == '1' ? $OSCOM_Product->getPriceFormated(true) : '', 'image' => $OSCOM_Product->getImage(), 'category_name' => $OSCOM_Category->getTitle(), 'category_path' => $OSCOM_Category->getPath());
             if ($counter == SERVICE_RECENTLY_VISITED_MAX_PRODUCTS) {
                 break;
             }
         }
     }
     return $history;
 }
Example #5
0
$OSCOM_Products->setSortBy('date_added', '-');
$Qproducts = $OSCOM_Products->execute();
if ($Qproducts->numberOfRows() > 0) {
    while ($Qproducts->next()) {
        $OSCOM_Product = new Product($Qproducts->valueInt('products_id'));
        ?>

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

<?php 
        if ($OSCOM_Product->hasImage()) {
            echo osc_link_object(OSCOM::getLink(null, null, $OSCOM_Product->getKeyword()), $OSCOM_Image->show($OSCOM_Product->getImage(), $OSCOM_Product->getTitle()));
        }
        ?>

    </td>
    <td valign="top"><?php 
        echo osc_link_object(OSCOM::getLink(null, null, $OSCOM_Product->getKeyword()), '<b><u>' . $OSCOM_Product->getTitle() . '</u></b>') . '<br />' . OSCOM::getDef('date_added') . ' ' . DateTime::getLong($OSCOM_Product->getDateAdded()) . '<br />' . OSCOM::getDef('manufacturer') . ' ' . $OSCOM_Product->getManufacturer() . '<br /><br />' . OSCOM::getDef('price') . ' ' . $OSCOM_Product->getPriceFormated();
        ?>
</td>
    <td align="right" valign="middle"><?php 
        echo osc_link_object(OSCOM::getLink(null, 'Cart', 'Add&' . $OSCOM_Product->getKeyword()), osc_draw_image_button('button_in_cart.gif', OSCOM::getDef('button_add_to_cart')));
        ?>
</td>
  </tr>
  <tr>
    <td colspan="3">&nbsp;</td>
 public function add($product_id, $quantity = null)
 {
     $OSCOM_Customer = Registry::get('Customer');
     $OSCOM_PDO = Registry::get('PDO');
     $OSCOM_Language = Registry::get('Language');
     if (!is_numeric($product_id)) {
         return false;
     }
     $OSCOM_Product = new Product($product_id);
     if ($OSCOM_Product->isValid()) {
         if ($this->exists($product_id)) {
             $item_id = $this->getBasketID($product_id);
             if (!is_numeric($quantity)) {
                 $quantity = $this->getQuantity($item_id) + 1;
             }
             $this->_contents[$item_id]['quantity'] = $quantity;
             if ($OSCOM_Customer->isLoggedOn()) {
                 $Qupdate = $OSCOM_PDO->prepare('update :table_shopping_carts set quantity = :quantity where customers_id = :customers_id and item_id = :item_id');
                 $Qupdate->bindInt(':quantity', $quantity);
                 $Qupdate->bindInt(':customers_id', $OSCOM_Customer->getID());
                 $Qupdate->bindInt(':item_id', $item_id);
                 $Qupdate->execute();
             }
         } else {
             if (!is_numeric($quantity)) {
                 $quantity = 1;
             }
             if ($OSCOM_Customer->isLoggedOn()) {
                 $Qid = $OSCOM_PDO->prepare('select max(item_id) as item_id from :table_shopping_carts where customers_id = :customers_id');
                 $Qid->bindInt(':customers_id', $OSCOM_Customer->getID());
                 $Qid->execute();
                 $item_id = $Qid->valueInt('item_id') + 1;
             } else {
                 if (empty($this->_contents)) {
                     $item_id = 1;
                 } else {
                     $item_id = max(array_keys($this->_contents)) + 1;
                 }
             }
             $this->_contents[$item_id] = array('item_id' => $item_id, 'id' => $product_id, 'parent_id' => (int) $OSCOM_Product->getData('parent_id'), 'name' => $OSCOM_Product->getTitle(), 'model' => $OSCOM_Product->getModel(), 'keyword' => $OSCOM_Product->getKeyword(), 'image' => $OSCOM_Product->getImage(), 'price' => $OSCOM_Product->getPrice(true), 'quantity' => $quantity, 'weight' => $OSCOM_Product->getData('weight'), 'tax_class_id' => $OSCOM_Product->getData('tax_class_id'), 'date_added' => DateTime::getShort(DateTime::getNow()), 'weight_class_id' => $OSCOM_Product->getData('weight_class_id'));
             if ($OSCOM_Customer->isLoggedOn()) {
                 $Qnew = $OSCOM_PDO->prepare('insert into :table_shopping_carts (customers_id, item_id, products_id, quantity, date_added) values (:customers_id, :item_id, :products_id, :quantity, now())');
                 $Qnew->bindInt(':customers_id', $OSCOM_Customer->getID());
                 $Qnew->bindInt(':item_id', $item_id);
                 $Qnew->bindInt(':products_id', $product_id);
                 $Qnew->bindInt(':quantity', $quantity);
                 $Qnew->execute();
             }
             if ($OSCOM_Product->getData('parent_id') > 0) {
                 $Qvariant = $OSCOM_PDO->prepare('select pvg.id as group_id, pvg.title as group_title, pvg.module, pvv.id as value_id, pvv.title as value_title from :table_products_variants pv, :table_products_variants_values pvv, :table_products_variants_groups pvg where pv.products_id = :products_id and pv.products_variants_values_id = pvv.id and pvv.languages_id = :languages_id_pvv and pvv.products_variants_groups_id = pvg.id and pvg.languages_id = :languages_id_pvg');
                 $Qvariant->bindInt(':products_id', $product_id);
                 $Qvariant->bindInt(':languages_id_pvv', $OSCOM_Language->getID());
                 $Qvariant->bindInt(':languages_id_pvg', $OSCOM_Language->getID());
                 $Qvariant->execute();
                 while ($Qvariant->fetch()) {
                     $group_title = ProductVariants::getGroupTitle($Qvariant->value('module'), $Qvariant->toArray());
                     $value_title = ProductVariants::getValueTitle($Qvariant->value('module'), $Qvariant->toArray());
                     $has_custom_value = ProductVariants::hasCustomValue($Qvariant->value('module'));
                     $this->_contents[$item_id]['variants'][] = array('group_id' => $Qvariant->valueInt('group_id'), 'value_id' => $Qvariant->valueInt('value_id'), 'group_title' => $group_title, 'value_title' => $value_title, 'has_custom_value' => $has_custom_value);
                     if ($OSCOM_Customer->isLoggedOn() && $has_custom_value === true) {
                         $Qnew = $OSCOM_PDO->prepare('insert into :table_shopping_carts_custom_variants_values (shopping_carts_item_id, customers_id, products_id, products_variants_values_id, products_variants_values_text) values (:shopping_carts_item_id, :customers_id, :products_id, :products_variants_values_id, :products_variants_values_text)');
                         $Qnew->bindInt(':shopping_carts_item_id', $item_id);
                         $Qnew->bindInt(':customers_id', $OSCOM_Customer->getID());
                         $Qnew->bindInt(':products_id', $product_id);
                         $Qnew->bindInt(':products_variants_values_id', $Qvariant->valueInt('value_id'));
                         $Qnew->bindValue(':products_variants_values_text', $value_title);
                         $Qnew->execute();
                     }
                 }
             }
         }
         $this->_cleanUp();
         $this->_calculate();
     }
 }
Example #7
0
 $rows = 0;
 while ($Qlisting->next()) {
     $OSCOM_Product = new 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;' . $OSCOM_Product->getModel() . '&nbsp;';
                 break;
             case 'PRODUCT_LIST_NAME':
                 $lc_align = '';
                 if (isset($_GET['manufacturers'])) {
                     $lc_text = osc_link_object(OSCOM::getLink(null, 'Products', $OSCOM_Product->getKeyword() . '&manufacturers=' . $_GET['manufacturers']), $OSCOM_Product->getTitle());
                 } else {
                     $lc_text = '&nbsp;' . osc_link_object(OSCOM::getLink(null, 'Products', $OSCOM_Product->getKeyword() . ($OSCOM_Category->getID() > 0 ? '&cPath=' . $OSCOM_Category->getPath() : '')), $OSCOM_Product->getTitle()) . '&nbsp;';
                 }
                 break;
             case 'PRODUCT_LIST_MANUFACTURER':
                 $lc_align = '';
                 $lc_text = '&nbsp;';
                 if ($OSCOM_Product->hasManufacturer()) {
                     $lc_text = '&nbsp;' . osc_link_object(OSCOM::getLink(null, 'Index', 'manufacturers=' . $OSCOM_Product->getManufacturerID()), $OSCOM_Product->getManufacturer()) . '&nbsp;';
                 }
                 break;
             case 'PRODUCT_LIST_PRICE':
                 $lc_align = 'right';
                 $lc_text = '&nbsp;' . $OSCOM_Product->getPriceFormated() . '&nbsp;';
                 break;
Example #8
0
$OSCOM_Products->setSortBy('date_added', '-');
$products_listing = $OSCOM_Products->execute();
if ($products_listing['total'] > 0) {
    foreach ($products_listing['entries'] as $p) {
        $OSCOM_Product = new Product($p['products_id']);
        ?>

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

<?php 
        if ($OSCOM_Product->hasImage()) {
            echo HTML::link(OSCOM::getLink(null, null, $OSCOM_Product->getKeyword()), $OSCOM_Image->show($OSCOM_Product->getImage(), $OSCOM_Product->getTitle()));
        }
        ?>

    </td>
    <td valign="top"><?php 
        echo HTML::link(OSCOM::getLink(null, null, $OSCOM_Product->getKeyword()), '<b><u>' . $OSCOM_Product->getTitle() . '</u></b>') . '<br />' . OSCOM::getDef('date_added') . ' ' . DateTime::getLong($OSCOM_Product->getDateAdded()) . '<br />' . OSCOM::getDef('manufacturer') . ' ' . $OSCOM_Product->getManufacturer() . '<br /><br />' . OSCOM::getDef('price') . ' ' . $OSCOM_Product->getPriceFormated();
        ?>
</td>
    <td align="right" valign="middle"><?php 
        echo HTML::button(array('href' => OSCOM::getLink(null, 'Cart', 'Add&' . $OSCOM_Product->getKeyword()), 'icon' => 'cart', 'title' => OSCOM::getDef('button_add_to_cart')));
        ?>
</td>
  </tr>
  <tr>
    <td colspan="3">&nbsp;</td>
 $rows = 0;
 foreach ($products_listing['entries'] as $p) {
     $OSCOM_Product = new Product($p['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;' . $OSCOM_Product->getModel() . '&nbsp;';
                 break;
             case 'PRODUCT_LIST_NAME':
                 $lc_align = '';
                 if (isset($_GET['manufacturers'])) {
                     $lc_text = HTML::link(OSCOM::getLink(null, 'Products', $OSCOM_Product->getKeyword() . '&manufacturers=' . $_GET['manufacturers']), $OSCOM_Product->getTitle());
                 } else {
                     $lc_text = '&nbsp;' . HTML::link(OSCOM::getLink(null, 'Products', $OSCOM_Product->getKeyword() . ($OSCOM_Category->getID() > 0 ? '&cPath=' . $OSCOM_Category->getPath() : '')), $OSCOM_Product->getTitle()) . '&nbsp;';
                 }
                 break;
             case 'PRODUCT_LIST_MANUFACTURER':
                 $lc_align = '';
                 $lc_text = '&nbsp;';
                 if ($OSCOM_Product->hasManufacturer()) {
                     $lc_text = '&nbsp;' . HTML::link(OSCOM::getLink(null, 'Index', 'Manufacturers=' . $OSCOM_Product->getManufacturerID()), $OSCOM_Product->getManufacturer()) . '&nbsp;';
                 }
                 break;
             case 'PRODUCT_LIST_PRICE':
                 $lc_align = 'right';
                 $lc_text = '&nbsp;' . $OSCOM_Product->getPriceFormated() . '&nbsp;';
                 break;