function start() { global $osC_Database, $osC_MessageStack; $Qcounter = $osC_Database->query('select startdate, counter from :table_counter'); $Qcounter->bindTable(':table_counter', TABLE_COUNTER); $Qcounter->execute(); if ($Qcounter->numberOfRows()) { $counter_startdate = $Qcounter->value('startdate'); $counter_now = $Qcounter->valueInt('counter') + 1; $Qcounterupdate = $osC_Database->query('update :table_counter set counter = counter+1'); $Qcounterupdate->bindTable(':table_counter', TABLE_COUNTER); $Qcounterupdate->execute(); $Qcounterupdate->freeResult(); } else { $counter_startdate = osC_DateTime::getNow(); $counter_now = 1; $Qcounterupdate = $osC_Database->query('insert into :table_counter (startdate, counter) values (:start_date, 1)'); $Qcounterupdate->bindTable(':table_counter', TABLE_COUNTER); $Qcounterupdate->bindValue(':start_date', $counter_startdate); $Qcounterupdate->execute(); $Qcounterupdate->freeResult(); } $Qcounter->freeResult(); return true; }
function getTimestamp($date = '') { global $osC_Language; if (empty($date)) { $date = osC_DateTime::getNow(); } $year = substr($date, 0, 4); $month = (int) substr($date, 5, 2); $day = (int) substr($date, 8, 2); $hour = (int) substr($date, 11, 2); $minute = (int) substr($date, 14, 2); $second = (int) substr($date, 17, 2); return mktime($hour, $minute, $second, $month, $day, $year); }
function expireAll() { global $osC_Database; $Qbanner = $osC_Database->query('select b.banners_id, b.expires_date, b.expires_impressions, sum(bh.banners_shown) as banners_shown from :table_banners b, :table_banners_history bh where b.status = 1 and b.banners_id = bh.banners_id group by b.banners_id'); $Qbanner->bindTable(':table_banners', TABLE_BANNERS); $Qbanner->bindTable(':table_banners_history', TABLE_BANNERS_HISTORY); $Qbanner->execute(); if ($Qbanner->numberOfRows() > 0) { while ($Qbanner->next()) { if (!osc_empty($Qbanner->value('expires_date'))) { if (osC_DateTime::getNow() >= $Qbanner->value('expires_date')) { $this->expire($Qbanner->valueInt('banners_id')); } } elseif (!osc_empty($Qbanner->valueInt('expires_impressions'))) { if ($Qbanner->valueInt('expires_impressions') > 0 && $Qbanner->valueInt('banners_shown') >= $Qbanner->valueInt('expires_impressions')) { $this->expire($Qbanner->valueInt('banners_id')); } } } } $Qbanner->freeResult(); }
/** * 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 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(); } } } } }
</td> </tr> <?php } if ($osC_Product->hasURL()) { ?> <tr> <td colspan="2"><?php echo sprintf($osC_Language->get('go_to_external_products_webpage'), osc_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($osC_Product->getURL()), 'NONSSL', null, false)); ?> </td> </tr> <?php } if ($osC_Product->getDateAvailable() > osC_DateTime::getNow()) { ?> <tr> <td colspan="2" align="center"><?php echo sprintf($osC_Language->get('date_availability'), osC_DateTime::getLong($osC_Product->getDateAvailable())); ?> </td> </tr> <?php } ?> <?php if ($osC_Product->hasAttributes()) { $attributes = $osC_Product->getAttributes(); foreach ($attributes as $attribute) {
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(); } }
public function add($product_id, $quantity = null) { global $osC_Database, $osC_Services, $osC_Language, $osC_Customer; if (!is_numeric($product_id)) { return false; } $Qproduct = $osC_Database->query('select p.parent_id, p.products_price, p.products_tax_class_id, p.products_model, p.products_weight, p.products_weight_class, p.products_status, i.image from :table_products p left join :table_products_images i on (p.products_id = i.products_id and i.default_flag = :default_flag) where p.products_id = :products_id'); $Qproduct->bindTable(':table_products', TABLE_PRODUCTS); $Qproduct->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES); $Qproduct->bindInt(':default_flag', 1); $Qproduct->bindInt(':products_id', $product_id); $Qproduct->execute(); if ($Qproduct->valueInt('products_status') === 1) { 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 ($osC_Customer->isLoggedOn()) { $Qupdate = $osC_Database->query('update :table_shopping_carts set quantity = :quantity where customers_id = :customers_id and item_id = :item_id'); $Qupdate->bindTable(':table_shopping_carts', TABLE_SHOPPING_CARTS); $Qupdate->bindInt(':quantity', $quantity); $Qupdate->bindInt(':customers_id', $osC_Customer->getID()); $Qupdate->bindInt(':item_id', $item_id); $Qupdate->execute(); } } else { if (!is_numeric($quantity)) { $quantity = 1; } $Qdescription = $osC_Database->query('select products_name, products_keyword from :table_products_description where products_id = :products_id and language_id = :language_id'); $Qdescription->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION); $Qdescription->bindInt(':products_id', $Qproduct->valueInt('parent_id') > 0 ? $Qproduct->valueInt('parent_id') : $product_id); $Qdescription->bindInt(':language_id', $osC_Language->getID()); $Qdescription->execute(); $price = $Qproduct->value('products_price'); if ($osC_Services->isStarted('specials')) { global $osC_Specials; if ($new_price = $osC_Specials->getPrice($product_id)) { $price = $new_price; } } if ($osC_Customer->isLoggedOn()) { $Qid = $osC_Database->query('select max(item_id) as item_id from :table_shopping_carts where customers_id = :customers_id'); $Qid->bindTable(':table_shopping_carts', TABLE_SHOPPING_CARTS); $Qid->bindInt(':customers_id', $osC_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' => $Qproduct->valueInt('parent_id'), 'name' => $Qdescription->value('products_name'), 'model' => $Qproduct->value('products_model'), 'keyword' => $Qdescription->value('products_keyword'), 'image' => $Qproduct->value('image'), 'price' => $price, 'quantity' => $quantity, 'weight' => $Qproduct->value('products_weight'), 'tax_class_id' => $Qproduct->valueInt('products_tax_class_id'), 'date_added' => osC_DateTime::getShort(osC_DateTime::getNow()), 'weight_class_id' => $Qproduct->valueInt('products_weight_class')); if ($osC_Customer->isLoggedOn()) { $Qnew = $osC_Database->query('insert into :table_shopping_carts (customers_id, item_id, products_id, quantity, date_added) values (:customers_id, :item_id, :products_id, :quantity, :date_added)'); $Qnew->bindTable(':table_shopping_carts', TABLE_SHOPPING_CARTS); $Qnew->bindInt(':customers_id', $osC_Customer->getID()); $Qnew->bindInt(':item_id', $item_id); $Qnew->bindInt(':products_id', $product_id); $Qnew->bindInt(':quantity', $quantity); $Qnew->bindRaw(':date_added', 'now()'); $Qnew->execute(); } if ($Qproduct->valueInt('parent_id') > 0) { $Qvariant = $osC_Database->query('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 and pvv.products_variants_groups_id = pvg.id and pvg.languages_id = :languages_id'); $Qvariant->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS); $Qvariant->bindTable(':table_products_variants_values', TABLE_PRODUCTS_VARIANTS_VALUES); $Qvariant->bindTable(':table_products_variants_groups', TABLE_PRODUCTS_VARIANTS_GROUPS); $Qvariant->bindInt(':products_id', $product_id); $Qvariant->bindInt(':languages_id', $osC_Language->getID()); $Qvariant->bindInt(':languages_id', $osC_Language->getID()); $Qvariant->execute(); while ($Qvariant->next()) { $group_title = osC_Variants::getGroupTitle($Qvariant->value('module'), $Qvariant->toArray()); $value_title = osC_Variants::getValueTitle($Qvariant->value('module'), $Qvariant->toArray()); $has_custom_value = osC_Variants::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 ($osC_Customer->isLoggedOn() && $has_custom_value === true) { $Qnew = $osC_Database->query('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->bindTable(':table_shopping_carts_custom_variants_values', TABLE_SHOPPING_CARTS_CUSTOM_VARIANTS_VALUES); $Qnew->bindInt(':shopping_carts_item_id', $item_id); $Qnew->bindInt(':customers_id', $osC_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(); } }
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(); } } }