예제 #1
0
 function initialize()
 {
     global $osC_Cache, $osC_Database, $osC_Services, $osC_Currencies, $osC_Specials, $osC_Language, $osC_Image;
     $this->_title_link = osc_href_link(FILENAME_PRODUCTS, 'new');
     $data = array();
     if (BOX_WHATS_NEW_CACHE > 0 && $osC_Cache->read('box-whats_new-' . $osC_Language->getCode() . '-' . $osC_Currencies->getCode(), BOX_WHATS_NEW_CACHE)) {
         $data = $osC_Cache->getCache();
     } else {
         $Qnew = $osC_Database->query('select products_id from :table_products where products_status = :products_status order by products_date_added desc limit :max_random_select_new');
         $Qnew->bindTable(':table_products', TABLE_PRODUCTS);
         $Qnew->bindInt(':products_status', 1);
         $Qnew->bindInt(':max_random_select_new', BOX_WHATS_NEW_RANDOM_SELECT);
         $Qnew->executeRandomMulti();
         if ($Qnew->numberOfRows()) {
             $osC_Product = new osC_Product($Qnew->valueInt('products_id'));
             $data = $osC_Product->getData();
             $data['display_price'] = $osC_Product->getPriceFormated(true);
             $data['display_image'] = $osC_Product->getImage();
         }
         $osC_Cache->write($data);
     }
     if (!empty($data)) {
         $this->_content = '';
         if (!empty($data['display_image'])) {
             $this->_content .= osc_link_object(osc_href_link(FILENAME_PRODUCTS, $data['keyword']), $osC_Image->show($data['display_image'], $data['name'])) . '<br />';
         }
         $this->_content .= osc_link_object(osc_href_link(FILENAME_PRODUCTS, $data['keyword']), $data['name']) . '<br />' . $data['display_price'];
     }
 }
예제 #2
0
 function initialize()
 {
     global $osC_Database, $osC_Cache, $osC_Language, $osC_Currencies, $osC_Image, $current_category_id;
     $data = array();
     if (MODULE_CONTENT_NEW_PRODUCTS_CACHE > 0 && $osC_Cache->read('new_products-' . $osC_Language->getCode() . '-' . $osC_Currencies->getCode() . '-' . $current_category_id, MODULE_CONTENT_NEW_PRODUCTS_CACHE)) {
         $data = $osC_Cache->getCache();
     } else {
         if ($current_category_id < 1) {
             $Qproducts = $osC_Database->query('select products_id from :table_products where products_status = :products_status and parent_id is null order by products_date_added desc limit :max_display_new_products');
         } else {
             $Qproducts = $osC_Database->query('select distinct p2c.products_id from :table_products p, :table_products_to_categories p2c, :table_categories c where c.parent_id = :category_parent_id and c.categories_id = p2c.categories_id and p2c.products_id = p.products_id and p.products_status = :products_status and p.parent_id is null order by p.products_date_added desc limit :max_display_new_products');
             $Qproducts->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
             $Qproducts->bindTable(':table_categories', TABLE_CATEGORIES);
             $Qproducts->bindInt(':category_parent_id', $current_category_id);
         }
         $Qproducts->bindTable(':table_products', TABLE_PRODUCTS);
         $Qproducts->bindInt(':products_status', 1);
         $Qproducts->bindInt(':max_display_new_products', MODULE_CONTENT_NEW_PRODUCTS_MAX_DISPLAY);
         $Qproducts->execute();
         while ($Qproducts->next()) {
             $osC_Product = new osC_Product($Qproducts->valueInt('products_id'));
             $data[$osC_Product->getID()] = $osC_Product->getData();
             $data[$osC_Product->getID()]['display_price'] = $osC_Product->getPriceFormated(true);
             $data[$osC_Product->getID()]['display_image'] = $osC_Product->getImage();
         }
         $osC_Cache->write($data);
     }
     if (!empty($data)) {
         $this->_content = '<div style="overflow: auto; height: 100%;">';
         foreach ($data as $product) {
             $this->_content .= '<span style="width: 33%; float: left; text-align: center;">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $product['keyword']), $osC_Image->show($product['display_image'], $product['name'])) . '<br />' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $product['keyword']), $product['name']) . '<br />' . $product['display_price'] . '</span>';
         }
         $this->_content .= '</div>';
     }
 }
예제 #3
0
         $p_short_desc = '<p>' . $osC_Language->get('no_products_short_description') . '</p>';
     } else {
         if (strlen($Qlisting->value('products_short_description')) > 80) {
             $p_short_desc = '<p>' . substr($Qlisting->value('products_short_description'), 0, 80) . '...</p>';
         } else {
             $p_short_desc = '<p>' . substr($Qlisting->value('products_short_description'), 0, 80) . '</p>';
         }
     }
     if (isset($_GET['manufacturers'])) {
         $lc_text = osc_link_object(osc_href_link(FILENAME_PRODUCTS, $Qlisting->value('products_id') . '&manufacturers=' . $_GET['manufacturers']), $Qlisting->value('products_name'), 'class="productGrid-name"') . $p_short_desc;
     } else {
         $lc_text = '&nbsp;' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $Qlisting->value('products_id') . ($cPath ? '&cPath=' . $cPath : '')), $Qlisting->value('products_name'), 'class="productGrid-name"') . $p_short_desc;
     }
     break;
 case 'PRODUCT_LIST_REVIEWS':
     if ($osC_Product->getData('reviews_average_rating') > 0) {
         $lc_text = osc_image(DIR_WS_IMAGES . 'stars_' . $osC_Product->getData('reviews_average_rating') . '.png', sprintf($osC_Language->get('rating_of_5_stars'), $osC_Product->getData('reviews_average_rating')));
         $lc_text .= osc_link_object(osc_href_link(FILENAME_PRODUCTS, $Qlisting->value('products_id') . ($cPath ? '&cPath=' . $cPath : '')), $osC_Product->getData('reviews_total') . ' Reviews', 'class="reviewTotal"');
     } else {
         $lc_text = osc_image(DIR_WS_IMAGES . 'stars_0.png', 'There is not any reviews for this product');
     }
     break;
 case 'PRODUCT_LIST_MANUFACTURER':
     $lc_align = '';
     $lc_text = '&nbsp;' . osc_link_object(osc_href_link(FILENAME_DEFAULT, 'manufacturers=' . $Qlisting->valueInt('manufacturers_id')), $Qlisting->value('manufacturers_name')) . '&nbsp;';
     break;
 case 'PRODUCT_LIST_PRICE':
     $lc_align = 'right';
     $lc_text = $osC_Product->getPriceFormated(true);
     break;
 case 'PRODUCT_LIST_QUANTITY':
예제 #4
0
 function _getShoppingCart()
 {
     global $osC_ShoppingCart, $osC_Currencies, $osC_Specials, $osC_Language;
     $cart = array();
     //products
     $products = array();
     foreach ($osC_ShoppingCart->getProducts() as $products_id_string => $data) {
         $osC_Product = new osC_Product(osc_get_product_id($products_id_string));
         $product = explode('#', $products_id_string, 2);
         $variants_array = array();
         if (!$osC_Product->isGiftCertificate()) {
             if (isset($product[1])) {
                 $variants = explode(';', $product[1]);
                 foreach ($variants as $set) {
                     $variant = explode(':', $set);
                     if (!is_numeric($variant[0]) || !is_numeric($variant[1])) {
                         continue 2;
                         // skip product
                     }
                     $variants_array[$variant[0]] = $variant[1];
                 }
             }
         }
         $price = $osC_Product->getPrice($variants_array, $data['quantity']);
         if ($osC_Product->hasSpecial()) {
             $special_price = $osC_Specials->getPrice($osC_Product->getID());
             if ($osC_Product->hasVariants()) {
                 $special_percentage = $special_price / $osC_Product->getData('price');
                 $special_price = $price * $special_percentage;
             }
             $price = '<s>' . $osC_Currencies->displayPrice($price, $osC_Product->getData('tax_class_id')) . '</s> <span class="productSpecialPrice">' . $osC_Currencies->displayPrice($special_price, $osC_Product->getData('tax_class_id')) . '</span>';
         }
         $product = array('id' => $products_id_string, 'link' => osc_href_link(FILENAME_PRODUCTS, $osC_Product->getID()), 'name' => substr($data['name'], 0, self::PRODUCTS_NAME_LENGTH) . (strlen($data['name']) > self::PRODUCTS_NAME_LENGTH ? '..' : ''), 'title' => $data['name'], 'quantity' => $data['quantity'] . ' x ', 'price' => $price);
         //variantsol
         if (is_array($data['variants']) && !empty($data['variants'])) {
             $product['variants'] = array_values($data['variants']);
         }
         //customizations
         if (is_array($data['customizations']) && !empty($data['customizations'])) {
             $product['customizations'] = array_values($data['customizations']);
         }
         //gift certificate
         if ($data['type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) {
             $gc_data = $osC_Language->get('senders_name') . ': ' . $data['gc_data']['senders_name'];
             if ($data['gc_data']['type'] == GIFT_CERTIFICATE_TYPE_EMAIL) {
                 $gc_data .= '<br />- ' . $osC_Language->get('senders_email') . ': ' . $data['gc_data']['senders_email'];
             }
             $gc_data .= '<br />- ' . $osC_Language->get('recipients_name') . ': ' . $data['gc_data']['recipients_name'];
             if ($data['gc_data']['type'] == GIFT_CERTIFICATE_TYPE_EMAIL) {
                 $gc_data .= '<br />- ' . $osC_Language->get('recipients_email') . ': ' . $data['gc_data']['recipients_email'];
             }
             $gc_data .= '<br />- ' . $osC_Language->get('message') . ': ' . $data['gc_data']['message'];
             $product['gc_data'] = $gc_data;
         }
         $products[] = $product;
     }
     $cart['products'] = $products;
     //order totals
     $order_totals = array();
     foreach ($osC_ShoppingCart->getOrderTotals() as $module) {
         $order_totals[] = array('title' => $module['title'], 'text' => $module['text']);
     }
     $cart['orderTotals'] = $order_totals;
     //numberOfItems
     $cart['numberOfItems'] = $osC_ShoppingCart->numberOfItems();
     //cart total
     $cart['total'] = $osC_Currencies->format($osC_ShoppingCart->getTotal());
     return $cart;
 }
예제 #5
0
 function add($products_id_string, $variants = null, $quantity = null, $gift_certificates_data = null, $customization_qty = null, $action = 'add')
 {
     global $osC_Database, $osC_Services, $osC_Language, $osC_Customer, $osC_Image, $toC_Wishlist, $toC_Customization_Fields, $osC_Specials;
     $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)) {
             $old_quantity = $this->getQuantity($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 (isset($customization_qty) && !empty($customization_qty)) {
                                 foreach ($customization_qty as $key => $value) {
                                     $this->_contents[$products_id_string]['customizations'][$key]['qty'] = $value;
                                 }
                             }
                         }
                     }
                 }
             }
             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_Product->hasSpecial()) {
                     $special_price = $osC_Specials->getPrice($osC_Product->getID());
                     if ($osC_Product->hasVariants()) {
                         $special_percentage = $special_price / $osC_Product->getData('price');
                         $special_price = $price * $special_percentage;
                     }
                     $price = $special_price;
                 }
             }
             $this->_contents[$products_id_string]['quantity'] = $quantity;
             $this->_contents[$products_id_string]['price'] = $price;
             $this->_contents[$products_id_string]['final_price'] = $price;
             if ($toC_Customization_Fields->exists($products_id)) {
                 $fields = $toC_Customization_Fields->get($products_id);
                 $this->_contents[$products_id_string]['customizations'][time()] = array('qty' => $quantity - $old_quantity, 'fields' => array_values($fields));
                 $toC_Customization_Fields->remove($products_id);
             }
             // 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, customizations = :customizations 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');
                 }
                 if (isset($this->_contents[$products_id_string]['customizations']) && !empty($this->_contents[$products_id_string]['customizations'])) {
                     $Qupdate->bindValue(':customizations', serialize($this->_contents[$products_id_string]['customizations']));
                 } else {
                     $Qupdate->bindRaw(':customizations', '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 product has variants and variants is not given
             if ($osC_Product->hasVariants() && $variants == null) {
                 $variant = $osC_Product->getDefaultVariant();
                 $variants = osc_parse_variants_from_id_string($variant['product_id_string']);
             }
             if ($osC_Product->isGiftCertificate() && $osC_Product->isOpenAmountGiftCertificate()) {
                 $price = $gift_certificates_data['price'];
             } else {
                 $price = $osC_Product->getPrice($variants, $quantity);
                 if ($osC_Product->hasSpecial()) {
                     $special_price = $osC_Specials->getPrice($osC_Product->getID());
                     if ($osC_Product->hasVariants()) {
                         $special_percentage = $special_price / $osC_Product->getData('price');
                         $special_price = $price * $special_percentage;
                     }
                     $price = $special_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);
             if ($toC_Customization_Fields->exists($products_id)) {
                 $fields = $toC_Customization_Fields->get($products_id);
                 $time = time();
                 $this->_contents[$products_id_string]['customizations'][$time] = array('qty' => $quantity, 'fields' => array_values($fields));
                 $toC_Customization_Fields->remove($products_id);
             }
             //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, customizations, customers_basket_date_added) values (:customers_id, :products_id, :customers_basket_quantity, :gift_certificates_data, :customizations, 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');
                 }
                 if (isset($this->_contents[$products_id_string]['customizations']) && !empty($this->_contents[$products_id_string]['customizations'])) {
                     $Qnew->bindValue(':customizations', serialize($this->_contents[$products_id_string]['customizations']));
                 } else {
                     $Qnew->bindRaw(':customizations', 'null');
                 }
                 $Qnew->execute();
             }
             if (is_array($variants) && !empty($variants)) {
                 $variants_array = $osC_Product->getVariants();
                 $products_variants_id_string = osc_get_product_id_string($products_id_string, $variants);
                 $products_variants_id = $variants_array[$products_variants_id_string]['variants_id'];
                 $this->_contents[$products_id_string]['products_variants_id'] = $products_variants_id;
                 if (isset($variants_array[$products_variants_id_string]['filename']) && !empty($variants_array[$products_variants_id_string]['filename'])) {
                     $this->_contents[$products_id_string]['variant_filename'] = $variants_array[$products_variants_id_string]['filename'];
                     $this->_contents[$products_id_string]['variant_cache_filename'] = $variants_array[$products_variants_id_string]['cache_filename'];
                 }
                 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();
     }
 }