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(); } } } } }
function getWeight($variants = null) { if ($variants == null || empty($variants)) { return $this->_data['products_weight']; } else { $product_id_string = osc_get_product_id_string($this->getID(), $variants); return $this->_data['variants'][$product_id_string]['weight']; } }
function addProduct() { global $osC_ShoppingCart, $toC_Json, $osC_Language, $toC_Customization_Fields, $osC_Image, $osC_Currencies; $osC_Language->load('products'); if (is_numeric($_POST['pID']) && osC_Product::checkEntry($_POST['pID'])) { $osC_ShoppingCart->resetShippingMethod(); $osC_Product = new osC_Product($_POST['pID']); //gift certificate check if ($osC_Product->isGiftCertificate() && !isset($_POST['senders_name'])) { $response = array('success' => false, 'feedback' => $osC_Language->get('error_gift_certificate_data_missing')); } else { if ($osC_Product->hasRequiredCustomizationFields() && !$toC_Customization_Fields->exists($osC_Product->getID())) { $response = array('success' => false, 'feedback' => $osC_Language->get('error_customization_fields_missing')); } else { $variants = null; if (isset($_POST['variants']) && !empty($_POST['variants'])) { $variants = osc_parse_variants_string($_POST['variants']); } $gift_certificate_data = null; if ($osC_Product->isGiftCertificate() && isset($_POST['senders_name']) && isset($_POST['recipients_name']) && isset($_POST['message'])) { if ($osC_Product->isEmailGiftCertificate()) { $gift_certificate_data = array('senders_name' => $_POST['senders_name'], 'senders_email' => $_POST['senders_email'], 'recipients_name' => $_POST['recipients_name'], 'recipients_email' => $_POST['recipients_email'], 'message' => $_POST['message']); } else { $gift_certificate_data = array('senders_name' => $_POST['senders_name'], 'recipients_name' => $_POST['recipients_name'], 'message' => $_POST['message']); } if ($osC_Product->isOpenAmountGiftCertificate()) { $gift_certificate_data['price'] = $_POST['gift_certificate_amount']; } $gift_certificate_data['type'] = $osC_Product->getGiftCertificateType(); } $osC_ShoppingCart->add($_POST['pID'], $variants, $_POST['pQty'], $gift_certificate_data); $items = 0; foreach ($osC_ShoppingCart->getProducts() as $products_id => $data) { $items += $data['quantity']; } //build the content of the confirmation dialog $product_id_string = osc_get_product_id_string($_POST['pID'], $variants); //find the added product $added_product = null; foreach ($osC_ShoppingCart->getProducts() as $id_string => $product) { if ($product_id_string == $id_string) { $added_product = $product; break; } } //build the dialog $confirm_dialog = null; if ($added_product !== null) { $confirm_dialog .= '<div class="dlgConfirm">' . '<div class="itemImage">' . $osC_Image->show($added_product['image'], $added_product['name'], '', 'thumbnail') . '</div>' . '<div class="itemDetail"><p>' . sprintf($osC_Language->get('add_to_cart_confirmation'), $added_product['quantity'] . ' x ' . osc_link_object(osc_href_link(FILENAME_CHECKOUT, null, 'SSL'), $added_product['name'])); //gift certificates if ($added_product['type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) { $confirm_dialog .= '<br />- ' . $osC_Language->get('senders_name') . ': ' . $product['gc_data']['senders_name']; if ($added_product['gc_data']['type'] == GIFT_CERTIFICATE_TYPE_EMAIL) { $confirm_dialog .= '<br />- ' . $osC_Language->get('senders_email') . ': ' . $product['gc_data']['senders_email']; } $confirm_dialog .= '<br />- ' . $osC_Language->get('recipients_name') . ': ' . $product['gc_data']['recipients_name']; if ($added_product['gc_data']['type'] == GIFT_CERTIFICATE_TYPE_EMAIL) { $confirm_dialog .= '<br />- ' . $osC_Language->get('recipients_email') . ': ' . $product['gc_data']['recipients_email']; } $confirm_dialog .= '<br />- ' . $osC_Language->get('message') . ': ' . $product['gc_data']['message']; } $confirm_dialog .= '</p>'; //variants products if ($osC_ShoppingCart->hasVariants($product['id'])) { foreach ($osC_ShoppingCart->getVariants($product['id']) as $variants) { $confirm_dialog .= '<div>'; $confirm_dialog .= '<strong>' . $variants['groups_name'] . ' - </strong><strong>' . $variants['values_name'] . '</strong></tr>'; $confirm_dialog .= '</div>'; } } $confirm_dialog .= '</div>'; //cart total $confirm_dialog .= '<p><strong>' . $osC_ShoppingCart->numberOfItems() . ' ' . $osC_Language->get('text_items') . '</strong> - <strong>' . $osC_Currencies->format($osC_ShoppingCart->getTotal()) . '</strong></p>'; //bottom buttons $confirm_dialog .= '<div class="btns">' . osc_link_object(osc_href_link(FILENAME_CHECKOUT, 'checkout', 'SSL'), osc_draw_image_button('button_checkout.gif', $osC_Language->get('button_checkout'))) . osc_link_object(osc_href_link(FILENAME_CHECKOUT, 'cart', 'SSL'), osc_draw_image_button('button_ajax_cart.png')) . osc_link_object(osc_href_link(FILENAME_DEFAULT), osc_draw_image_button('button_continue.gif'), 'id="btnContinue"') . '</div>'; $confirm_dialog .= '</div>'; } $response = array('success' => true, 'items' => $items, 'confirm_dialog' => $confirm_dialog); } } } else { $response = array('success' => false); } echo $toC_Json->encode($response); }
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(); } }
function _getProducts() { global $osC_Database; $Qproducts = $osC_Database->query('select op.orders_products_id, op.products_id, op.products_type, op.products_name, op.products_sku, op.products_price, op.products_tax, op.products_quantity, op.products_return_quantity, op.final_price, p.products_weight, p.products_weight_class, p.products_tax_class_id from :table_orders_products op, :table_products p where p.products_id = op.products_id and orders_id = :orders_id'); $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS); $Qproducts->bindTable(':table_products', TABLE_PRODUCTS); $Qproducts->bindInt(':orders_id', $this->_order_id); $Qproducts->execute(); while ($Qproducts->next()) { $product = array('id' => $Qproducts->valueInt('products_id'), 'orders_products_id' => $Qproducts->valueInt('orders_products_id'), 'type' => $Qproducts->valueInt('products_type'), 'quantity' => $Qproducts->valueInt('products_quantity'), 'return_quantity' => $Qproducts->valueInt('products_return_quantity'), 'name' => $Qproducts->value('products_name'), 'sku' => $Qproducts->value('products_sku'), 'tax' => $Qproducts->value('products_tax'), 'tax_class_id' => $Qproducts->value('products_tax_class_id'), 'price' => $Qproducts->value('products_price'), 'final_price' => $Qproducts->value('final_price'), 'weight' => $Qproducts->value('products_weight'), 'tax_class_id' => $Qproducts->value('products_tax_class_id'), 'weight_class_id' => $Qproducts->value('products_weight_class')); if ($product['type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) { $Qcertificate = $osC_Database->query('select gift_certificates_type, gift_certificates_code, senders_name, senders_email, recipients_name, recipients_email, messages from :table_gift_certificates where orders_id = :orders_id and orders_products_id = :orders_products_id'); $Qcertificate->bindTable(':table_gift_certificates', TABLE_GIFT_CERTIFICATES); $Qcertificate->bindInt(':orders_id', $this->_order_id); $Qcertificate->bindInt(':orders_products_id', $Qproducts->valueInt('orders_products_id')); $Qcertificate->execute(); if ($Qcertificate->numberOfRows() > 0) { $product['gift_certificates_type'] = $Qcertificate->valueInt('gift_certificates_type'); $product['gift_certificates_code'] = $Qcertificate->value('gift_certificates_code'); $product['senders_name'] = $Qcertificate->value('senders_name'); $product['senders_email'] = $Qcertificate->value('senders_email'); $product['recipients_name'] = $Qcertificate->value('recipients_name'); $product['recipients_email'] = $Qcertificate->value('recipients_email'); $product['messages'] = $Qcertificate->value('messages'); } $Qcertificate->freeResult(); } $Qvariants = $osC_Database->query('select products_variants_groups_id as groups_id, products_variants_groups as groups_name, products_variants_values_id as values_id, products_variants_values as values_name from :table_orders_products_variants where orders_id = :orders_id and orders_products_id = :orders_products_id'); $Qvariants->bindTable(':table_orders_products_variants', TABLE_ORDERS_PRODUCTS_VARIANTS); $Qvariants->bindInt(':orders_id', $this->_order_id); $Qvariants->bindInt(':orders_products_id', $Qproducts->valueInt('orders_products_id')); $Qvariants->execute(); $variants = array(); if ($Qvariants->numberOfRows() > 0) { while ($Qvariants->next()) { $product['variants'][] = array('groups_id' => $Qvariants->valueInt('groups_id'), 'values_id' => $Qvariants->valueInt('values_id'), 'groups_name' => $Qvariants->value('groups_name'), 'values_name' => $Qvariants->value('values_name')); $variants[$Qvariants->valueInt('groups_id')] = $Qvariants->valueInt('values_id'); } } $Qcustomizations = $osC_Database->query('select orders_products_customizations_id, quantity from :table_orders_products_customizations where orders_id = :orders_id and orders_products_id = :orders_products_id'); $Qcustomizations->bindTable(':table_orders_products_customizations', TABLE_ORDERS_PRODUCTS_CUSTOMIZATIONS); $Qcustomizations->bindInt(':orders_id', $this->_order_id); $Qcustomizations->bindInt(':orders_products_id', $Qproducts->valueInt('orders_products_id')); $Qcustomizations->execute(); $customizations = null; while ($Qcustomizations->next()) { $Qfields = $osC_Database->query('select * from :table_orders_products_customizations_values where orders_products_customizations_id = :orders_products_customizations_id'); $Qfields->bindTable(':table_orders_products_customizations_values', TABLE_ORDERS_PRODUCTS_CUSTOMIZATIONS_VALUES); $Qfields->bindInt(':orders_products_customizations_id', $Qcustomizations->valueInt('orders_products_customizations_id')); $Qfields->execute(); $fields = array(); while ($Qfields->next()) { $fields[$Qfields->valueInt('orders_products_customizations_values_id')] = array('customization_fields_id' => $Qfields->valueInt('customization_fields_id'), 'customization_fields_name' => $Qfields->value('customization_fields_name'), 'customization_type' => $Qfields->valueInt('customization_fields_type'), 'customization_value' => $Qfields->value('customization_fields_value'), 'cache_filename' => $Qfields->value('cache_file_name')); } $customizations[] = array('qty' => $Qcustomizations->valueInt('quantity'), 'fields' => $fields); } if ($customizations != null) { $product['customizations'] = $customizations; } if ($product['type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) { $products_id_string = $Qproducts->valueInt('products_id') . '#' . $product['orders_products_id']; } else { $products_id_string = osc_get_product_id_string($Qproducts->valueInt('products_id'), $variants); } $this->_contents[$products_id_string] = $product; } }
<th width="100" class="visible-desktop"><?php echo $osC_Language->get('listing_date_added_heading'); ?> </th> <th class="visible-desktop"></th> </tr> </thead> <tbody> <?php $rows = 0; foreach ($toC_Wishlist->getProducts() as $product) { $rows++; ?> <tr> <td class="center" width="150"><?php echo osc_link_object(osc_href_link(FILENAME_PRODUCTS, !osc_empty($product['variants']) ? str_replace('#', '_', osc_get_product_id_string($product['products_id'], $product['variants'])) : $product['products_id']), $osC_Image->show($product['image'], $product['name'], 'hspace="5" vspace="5"')) . '<br />' . $product['name'] . '<br />' . $osC_Currencies->format($product['price']); ?> </td> <td><?php echo osc_draw_textarea_field('comments[' . $product['products_id'] . ']', $product['comments'], 20, 5, 'id="comments_' . $product['products_id'] . '"'); ?> </td> <td width="96" class="visible-desktop"><?php echo $product['date_added']; ?> </td> <td class="center btn-toolbar visible-desktop"> <a href="<?php echo osc_href_link(FILENAME_ACCOUNT, 'wishlist=delete&products_id=' . $product['products_id']); ?> " class="btn btn-mini btn-inverse pull-left"><?php
/** * Get product variants id * * @param $variants * @return array */ public function get_product_variants_id($variants) { $product_id_string = osc_get_product_id_string($this->get_id(), $variants); if (isset($this->data['variants']) && isset($this->data['variants'][$product_id_string])) { return $this->data['variants'][$product_id_string]['variants_id']; } else { return FALSE; } }
function get_price($variants = null, $quantity = 1) { //get product price $product_price = $this->data['price']; //get variant price if (is_array($variants) && !empty($variants)) { $product_id_string = osc_get_product_id_string($this->id, $variants); if (isset($this->data['variants'][$product_id_string])) { $product_price = $this->data['variants'][$product_id_string]['price']; } } else { if ($this->has_variants()) { if (is_array($this->data['default_variant']) && !empty($this->data['default_variant'])) { $product_price = $this->data['default_variant']['price']; } } } $qty_discount = $this->get_quantity_discount($quantity); $customer_grp_discount = is_numeric($this->_customer_group_discount) ? $this->_customer_group_discount : 0; $product_price = round($product_price * (1 - $qty_discount / 100) * (1 - $customer_grp_discount / 100), 2); return $product_price; }