Esempio n. 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'));
 }
Esempio n. 2
0
 public function initialize()
 {
     $OSCOM_Cache = Registry::get('Cache');
     $OSCOM_Language = Registry::get('Language');
     $OSCOM_Currencies = Registry::get('Currencies');
     $OSCOM_Category = Registry::get('Category');
     $OSCOM_Database = Registry::get('Database');
     $OSCOM_Image = Registry::get('Image');
     $data = array();
     if (MODULE_CONTENT_NEW_PRODUCTS_CACHE > 0 && $OSCOM_Cache->read('new_products-' . $OSCOM_Language->getCode() . '-' . $OSCOM_Currencies->getCode() . '-' . $OSCOM_Category->getID(), MODULE_CONTENT_NEW_PRODUCTS_CACHE)) {
         $data = $OSCOM_Cache->getCache();
     } else {
         if ($OSCOM_Category->getID() < 1) {
             $Qproducts = $OSCOM_Database->query('select products_id from :table_products where products_status = :products_status and parent_id is null order by products_date_added desc limit :max_display_new_products');
         } else {
             $Qproducts = $OSCOM_Database->query('select distinct p2c.products_id from :table_products p, :table_products_to_categories p2c, :table_categories c where c.parent_id = :category_parent_id and c.categories_id = p2c.categories_id and p2c.products_id = p.products_id and p.products_status = :products_status and p.parent_id is null order by p.products_date_added desc limit :max_display_new_products');
             $Qproducts->bindInt(':category_parent_id', $OSCOM_Category->getID());
         }
         $Qproducts->bindInt(':products_status', 1);
         $Qproducts->bindInt(':max_display_new_products', MODULE_CONTENT_NEW_PRODUCTS_MAX_DISPLAY);
         $Qproducts->execute();
         while ($Qproducts->next()) {
             $OSCOM_Product = new Product($Qproducts->valueInt('products_id'));
             $data[$OSCOM_Product->getID()] = $OSCOM_Product->getData();
             $data[$OSCOM_Product->getID()]['display_price'] = $OSCOM_Product->getPriceFormated(true);
             $data[$OSCOM_Product->getID()]['display_image'] = $OSCOM_Product->getImage();
         }
         $OSCOM_Cache->write($data);
     }
     if (!empty($data)) {
         $this->_content = '<div style="overflow: auto; height: 100%;">';
         foreach ($data as $product) {
             $this->_content .= '<span style="width: 33%; float: left; text-align: center;">' . osc_link_object(OSCOM::getLink(null, 'Products', $product['keyword']), $OSCOM_Image->show($product['display_image'], $product['name'])) . '<br />' . osc_link_object(OSCOM::getLink(null, 'Products', $product['keyword']), $product['name']) . '<br />' . $product['display_price'] . '</span>';
         }
         $this->_content .= '</div>';
     }
 }
Esempio n. 3
0
 public static function isValid(Product $OSCOM_Product)
 {
     $OSCOM_ShoppingCart = Registry::get('ShoppingCart');
     return $OSCOM_Product->getQuantity() - $OSCOM_ShoppingCart->getQuantity($OSCOM_ShoppingCart->getBasketID($OSCOM_Product->getID())) > 0;
 }
Esempio n. 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;
 }