function _getShoppingCart() { global $osC_ShoppingCart, $osC_Currencies, $osC_Language; $cart = array(); //products $products = array(); foreach ($osC_ShoppingCart->getProducts() as $products_id => $data) { $product = array('id' => $products_id, 'link' => osc_href_link(FILENAME_PRODUCTS, osc_get_product_id($products_id)), 'name' => substr($data['name'], 0, self::PRODUCTS_NAME_LENGTH) . (strlen($data['name']) > self::PRODUCTS_NAME_LENGTH ? '..' : ''), 'title' => $data['name'], 'quantity' => $data['quantity'] . ' x ', 'price' => $osC_Currencies->displayPrice($data['price'], $data['tax_class_id'], $data['quantity'])); //variants 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; }
function isInStock($products_id) { global $osC_Database; $osC_Product = new osC_Product(osc_get_product_id($products_id)); if ($osC_Product->getQuantity($products_id) - $this->_contents[$products_id]['quantity'] >= 0) { return true; } elseif ($this->_products_in_stock === true) { $this->_products_in_stock = false; } return false; }
<?php if ($osC_Product->hasVariants()) { $combobox_array = $osC_Product->getVariantsComboboxArray(); foreach ($combobox_array as $groups_name => $combobox) { echo '<tr class="variantCombobox"> <td class="label" valign="top">' . $groups_name . ':</td> <td>' . $combobox . '</td> </tr>'; } } ?> <tr> <td colspan="2" align="center" valign="top" style="padding-top: 15px" id="shoppingCart"> <?php echo '<b>' . $osC_Language->get('field_short_quantity') . '</b> ' . osc_draw_input_field('quantity', $osC_Product->getMOQ(), 'size="3"') . ' ' . osc_draw_image_submit_button('button_in_cart.gif', $osC_Language->get('button_add_to_cart'), 'style="vertical-align:middle;" class="ajaxAddToCart" id="ac_productsinfo_' . osc_get_product_id($osC_Product->getID()) . '"'); ?> </td> </tr> <tr> <td colspan="2" align="center" id = "shoppingAction"> <?php echo osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), $osC_Product->getID() . '&' . '&action=compare_products_add'), $osC_Language->get('add_to_compare')) . ' <span>|</span> ' . osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), $osC_Product->getID() . '&action=wishlist_add'), $osC_Language->get('add_to_wishlist')); ?> </td> </tr> <tr> <td colspan="2"> <p class="shortDescription"><?php echo $osC_Product->getShortDescription();
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; }
public function incrementCounter() { $OSCOM_Database = Registry::get('Database'); $OSCOM_Language = Registry::get('Language'); $Qupdate = $OSCOM_Database->query('update :table_products_description set products_viewed = products_viewed+1 where products_id = :products_id and language_id = :language_id'); $Qupdate->bindInt(':products_id', osc_get_product_id($this->_data['id'])); $Qupdate->bindInt(':language_id', $OSCOM_Language->getID()); $Qupdate->execute(); }
function synchronizeWithDatabase() { global $osC_Database, $osC_Services, $osC_Language, $osC_Customer, $osC_Image; if (!$osC_Customer->isLoggedOn()) { return false; } $Qcheck = $osC_Database->query('select wishlists_id, wishlists_token from :table_wishlists where customers_id = :customers_id'); $Qcheck->bindTable(':table_wishlists', TABLE_WISHLISTS); $Qcheck->bindInt(':customers_id', $osC_Customer->getID()); $Qcheck->execute(); if ($Qcheck->numberOfRows() > 0) { $this->_wishlists_id = $Qcheck->valueInt('wishlists_id'); $this->_token = $Qcheck->value('wishlists_token'); // reset per-session cart contents, but not the database contents $this->_contents = array(); $Qproducts = $osC_Database->query('select wishlists_products_id, products_id, date_added, comments from :table_wishlist_products where wishlists_id = :wishlists_id'); $Qproducts->bindTable(':table_wishlist_products', TABLE_WISHLISTS_PRODUCTS); $Qproducts->bindInt(':wishlists_id', $this->_wishlists_id); $Qproducts->execute(); while ($Qproducts->next()) { $osC_Product = new osC_Product($Qproducts->value('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(osc_get_product_id($Qproducts->value('products_id')))) { $price = $new_price; } } //the product has variants $variants = array(); if ($osC_Product->hasVariants()) { $Qvariants = $osC_Database->query('select products_variants_groups_id, products_variants_groups, products_variants_values_id, products_variants_values from :table_wishlists_products_variants where whishlists_id = :whishlists_id, whishlists_products_id = :whishlists_products_id'); $Qvariants->bindTable(':table_wishlists_products_variants', TABLE_WISHLISTS_PRODUCTS_VARIANTS); $Qvariants->bindInt(':whishlists_id', $this->_wishlists_id); $Qvariants->bindInt(':whishlists_products_id', $Qproducts->valueInt('wishlists_products_id')); $Qvariants->execute(); $products_variants = $osC_Product->getVariants(); $row_variants = array(); if ($Qvariants->numberOfRows() > 0) { while ($Qvariants->next()) { $row_variants[] = array('groups_id' => $Qvariants->valueInt('products_variants_groups_id'), 'values_id' => $Qvariants->valueInt('products_variants_values_id'), 'groups_name' => $Qvariants->value('products_variants_groups'), 'values_name' => $Qvariants->value('products_variants_values')); } $Qvariants->freeResult(); } if (!osc_empty($row_variants)) { $product_name .= '<br />'; foreach ($row_variants as $variant) { $variants[$variant['groups_id']] = $variant['values_id']; $product_name .= '<em>' . $variant['groups_name'] . ': ' . $variant['values_name'] . '</em>' . '<br />'; } 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(); } $product_price = $products_variant['price']; $product_image = $products_variant['image']; } } $this->_contents[$Qproducts->value('products_id')] = array('products_id' => $Qproducts->value('products_id'), 'name' => $product_name, 'image' => $product_image, 'price' => $product_price, 'variants' => $variants, 'date_added' => osC_DateTime::getShort($Qproducts->value('date_added')), 'comments' => $Qproducts->value('comments')); } } else { $token = $this->generateToken(); $Qupdate = $osC_Database->query('update :table_wishlists set customers_id = :customers_id, wishlists_token = :wishlists_token where wishlists_id = :wishlists_id'); $Qupdate->bindTable(':table_wishlists', TABLE_WISHLISTS); $Qupdate->bindInt(':customers_id', $osC_Customer->getID()); $Qupdate->bindValue(':wishlists_token', $token); $Qupdate->bindInt(':wishlists_id', $this->_wishlists_id); $Qupdate->execute(); $this->_token = $token; } }
function addProduct() { global $toC_Json, $osC_Language, $osC_Tax, $osC_Weight, $osC_Currencies, $osC_ShoppingCart; $error = false; $feedback = array(); $osC_ShoppingCart = new toC_ShoppingCart_Adapter($_REQUEST['orders_id']); $osC_Tax = new osC_Tax_Admin(); $osC_Weight = new osC_Weight(); $osC_Currencies = new osC_Currencies(); $osC_Product = new osC_Product(osc_get_product_id($_REQUEST['products_id'])); $gift_certificate_data = null; if ($osC_Product->isGiftCertificate()) { if (!isset($_REQUEST['senders_name']) || empty($_REQUEST['senders_name'])) { $error = true; $feedback[] = $osC_Language->get('error_sender_name_empty'); } if (!isset($_REQUEST['recipients_name']) || empty($_REQUEST['recipients_name'])) { $error = true; $feedback[] = $osC_Language->get('error_recipients_name_empty'); } if (!isset($_REQUEST['message']) || empty($_REQUEST['message'])) { $error = true; $feedback[] = $osC_Language->get('error_message_empty'); } if ($osC_Product->isEmailGiftCertificate()) { if (!isset($_REQUEST['senders_email']) || empty($_REQUEST['senders_email'])) { $error = true; $feedback[] = $osC_Language->get('error_sender_email_empty'); } if (!osc_validate_email_address($_REQUEST['senders_email'])) { $error = true; $feedback[] = $osC_Language->get('error_sender_email_invalid'); } if (!isset($_REQUEST['recipients_email']) || empty($_REQUEST['recipients_email'])) { $error = true; $feedback[] = $osC_Language->get('error_recipients_email_empty'); } if (!osc_validate_email_address($_REQUEST['recipients_email'])) { $error = true; $feedback[] = $osC_Language->get('error_recipients_email_invalid'); } } if ($error === false) { if ($osC_Product->isEmailGiftCertificate()) { $gift_certificate_data = array('senders_name' => $_REQUEST['senders_name'], 'senders_email' => $_REQUEST['senders_email'], 'recipients_name' => $_REQUEST['recipients_name'], 'recipients_email' => $_REQUEST['recipients_email'], 'message' => $_REQUEST['message']); } else { $gift_certificate_data = array('senders_name' => $_REQUEST['senders_name'], 'recipients_name' => $_REQUEST['recipients_name'], 'message' => $_REQUEST['message']); } $gift_certificate_data['type'] = $osC_Product->getGiftCertificateType(); if ($osC_Product->isOpenAmountGiftCertificate()) { $gift_certificate_data['price'] = $_REQUEST['gift_certificate_amount'] / $osC_ShoppingCart->getCurrencyValue(); } } } if ($error === false) { if ($osC_ShoppingCart->addProduct($_REQUEST['products_id'], $_REQUEST['new_qty'], $gift_certificate_data)) { $response = array('success' => true, 'feedback' => $osC_Language->get('ms_success_action_performed')); } else { $response = array('success' => false, 'feedback' => $osC_Language->get('ms_error_action_not_performed')); } } else { $response = array('success' => false, 'feedback' => implode('<br />', $feedback)); } echo $toC_Json->encode($response); }
function getCartContents() { global $osC_Language, $osC_ShoppingCart, $osC_Currencies, $toC_Json, $osC_Image; //the maximum displayed characters of the product name $product_name_length = 18; $content = '<div class="cartInner">'; $content .= '<h6>' . osc_link_object(osc_href_link(FILENAME_CHECKOUT, null, 'SSL'), $osC_Language->get('box_shopping_cart_heading')) . '</h6>' . '<div class="content clearfix">'; //products if ($osC_ShoppingCart->hasContents()) { $content .= '<table class="products">'; foreach ($osC_ShoppingCart->getProducts() as $products_id_string => $product) { //product name if (strlen($product['name']) > $product_name_length) { $product_name = substr($product['name'], 0, $product_name_length) . '..'; } else { $product_name = $product['name']; } $content .= '<tr>' . ' <td>' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $product['id'], 'SSL'), $osC_Image->show($product['image'], $product['name'], '', 'mini')) . '</td>' . ' <td>' . $product['quantity'] . ' x ' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $product['id'], 'SSL'), $product_name); //gift certificates if ($product['type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) { $content .= '<br />- ' . $osC_Language->get('senders_name') . ': ' . $product['gc_data']['senders_name']; if ($products['gc_data']['type'] == GIFT_CERTIFICATE_TYPE_EMAIL) { $content .= '<br />- ' . $osC_Language->get('senders_email') . ': ' . $product['gc_data']['senders_email']; } $content .= '<br />- ' . $osC_Language->get('recipients_name') . ': ' . $product['gc_data']['recipients_name']; if ($product['gc_data']['type'] == GIFT_CERTIFICATE_TYPE_EMAIL) { $content .= '<br />- ' . $osC_Language->get('recipients_email') . ': ' . $product['gc_data']['recipients_email']; } $content .= '<br />- ' . $osC_Language->get('message') . ': ' . $product['gc_data']['message']; } //variants products if ($osC_ShoppingCart->hasVariants($product['id'])) { foreach ($osC_ShoppingCart->getVariants($product['id']) as $variants) { $content .= '<br />- ' . $variants['groups_name'] . ': ' . $variants['values_name']; } } $content .= ' </td>'; //products price $content .= ' <td><strong>' . $osC_Currencies->displayPrice($product['final_price'], $product['tax_class_id'], $product['quantity']) . '</strong></td>'; //only when the ajax shopping cart box is disabled, the delete button will be displayed if (isset($_POST['enable_delete']) && $_POST['enable_delete'] == 'yes') { $variants_string = null; if (!is_numeric($products_id_string) && strpos($products_id_string, '#') != false) { $tmp = explode('#', $products_id_string); $variants_string = $tmp[1]; } $content .= ' <td>' . osc_link_object(osc_href_link(FILENAME_CHECKOUT, osc_get_product_id($product['id']) . (!empty($variants_string) ? '&variants=' . $variants_string : '') . '&action=cart_remove', 'SSL'), osc_draw_image_button('small_delete.gif', $osC_Language->get('button_delete')), 'class="removeBtn" data-pid="' . $product['id'] . '"') . '</td>'; } $content .= '</tr>'; } $content .= '</table>'; } else { $content .= '<div><strong class="cartEmpty">' . $osC_Language->get('box_shopping_cart_empty') . '</strong></div>'; } //order totals $content .= '<table class="orderTotals">'; foreach ($osC_ShoppingCart->getOrderTotals() as $module) { $content .= '<tr>' . ' <td class="title"><strong>' . $module['title'] . '</strong></td>' . ' <td class="text"><strong>' . $module['text'] . '</strong></td>' . '</tr>'; } $content .= '</table>'; $content .= '</div>'; //bottom buttons $content .= '<div class="buttons clearfix">' . osc_link_object(osc_href_link(FILENAME_CHECKOUT, 'checkout', 'SSL'), osc_draw_image_button('button_checkout.gif', $osC_Language->get('button_checkout')), 'class="btnCheckout"') . osc_link_object(osc_href_link(FILENAME_CHECKOUT, 'cart', 'SSL'), osc_draw_image_button('button_ajax_cart.png'), 'class="btnCart"') . '</div>'; $content .= '</div>'; $response = array('success' => true, 'content' => $content, 'total' => $osC_ShoppingCart->numberOfItems()); echo $toC_Json->encode($response); }
</td> <td class="productListing-heading"><?php echo $osC_Language->get('listing_comments_heading'); ?> </td> <td class="productListing-heading" align="center" width="70"><?php echo $osC_Language->get('listing_date_added_heading'); ?> </td> <td class="productListing-heading"></td> </tr> <?php $rows = 0; foreach ($toC_Wishlist->getProducts() as $product) { $rows++; $products_id = osc_get_product_id($products_id_string); $ac_products_id_string = $product['products_id_string']; $products_id_string = str_replace('#', '_', $product['products_id_string']); ?> <tr class="<?php echo $rows / 2 == floor($rows / 2) ? 'productListing-even' : 'productListing-odd'; ?> "> <td align="center"><?php echo osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id_string), $osC_Image->show($product['image'], $product['name'], 'hspace="5" vspace="5" id="product_image" class="productImage"'), 'id="img_ac_wishlist_' . $ac_products_id_string . '"') . '<br />' . $product['name'] . '<br />' . $osC_Currencies->format($product['price']); ?> </td> <td valign="top"><?php echo osc_draw_textarea_field('comments[' . $products_id_string . ']', $product['comments'], 20, 5, 'id="comments_' . $products_id_string . '"'); ?>
function _getShoppingCart() { global $osC_ShoppingCart, $osC_Currencies, $osC_Language, $osC_Customer; //when the language is changed, it is necessary to update the shopping cart if (isset($_SESSION['language_change']) && $_SESSION['language_change'] == true) { if ($osC_Customer->isLoggedOn()) { $osC_ShoppingCart->reset(); $osC_ShoppingCart->synchronizeWithDatabase(); } else { foreach ($osC_ShoppingCart->getProducts() as $products_id_string => $data) { $osC_Product = new osC_Product($products_id_string); $data['name'] = $osC_Product->getTitle(); $data['keyword'] = $osC_Product->getKeyword(); $_SESSION['osC_ShoppingCart_data']['contents'][$products_id_string] = $data; } $osC_ShoppingCart->_calculate(); } unset($_SESSION['language_change']); } $cart = array(); //products $products = array(); foreach ($osC_ShoppingCart->getProducts() as $products_id => $data) { $product = array('id' => $products_id, 'link' => osc_href_link(FILENAME_PRODUCTS, osc_get_product_id($products_id)), 'name' => substr($data['name'], 0, self::PRODUCTS_NAME_LENGTH) . (strlen($data['name']) > self::PRODUCTS_NAME_LENGTH ? '..' : ''), 'title' => $data['name'], 'quantity' => $data['quantity'] . ' x ', 'price' => $osC_Currencies->displayPrice($data['price'], $data['tax_class_id'], $data['quantity'])); //variants 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; }
<?php } } ?> <div class="divider"></div> <div id="shoppingCart"> <b><?php echo $osC_Language->get('field_short_quantity'); ?> </b> <?php echo osc_draw_input_field('quantity', $osC_Product->getMOQ(), 'size="3"'); ?> <button type="submit" id="ac_productsinfo_<?php echo osc_get_product_id($osC_Product->getID()); ?> " class="btn btn-info ajaxAddToCart" title="<?php echo $osC_Language->get('button_add_to_cart'); ?> "><i class="icon-shopping-cart icon-white "></i> <?php echo $osC_Language->get('button_add_to_cart'); ?> </button> </div> <div id="shoppingAction"> <?php if ($osC_Template->isInstalled('compare_products', 'boxes')) { echo osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), osc_get_all_get_params() . '&cid=' . $osC_Product->getID() . '&' . '&action=compare_products_add'), $osC_Language->get('add_to_compare'), 'class="compare-products"') . ' <span>|</span> '; } ?>
<?php } ?> <div> <?php echo $OSCOM_Product->getDescription(); ?> </div> <?php if ($OSCOM_Service->isStarted('Reviews') && Reviews::exists(osc_get_product_id($OSCOM_Product->getID()), true)) { ?> <p><?php echo OSCOM::getDef('number_of_product_reviews') . ' ' . Reviews::getTotal(osc_get_product_id($OSCOM_Product->getID())); ?> </p> <?php } if ($OSCOM_Product->hasURL()) { ?> <p><?php echo sprintf(OSCOM::getDef('go_to_external_products_webpage'), OSCOM::getLink(null, 'Redirect', 'action=url&goto=' . urlencode($OSCOM_Product->getURL()), 'NONSSL', null, false)); ?> </p> <?php }
</tr> <?php } ?> <tr> <td valign="top" width="30" align="center"> <?php $variants_string = null; if (!is_numeric($products_id_string) && strpos($products_id_string, '#') != false) { $tmp = explode('#', $products_id_string); $variants_string = $tmp[1]; } echo osc_link_object(osc_href_link(FILENAME_CHECKOUT, osc_get_product_id($products['id']) . (!empty($variants_string) ? '&variants=' . $variants_string : '') . '&action=cart_remove', 'SSL'), '<i class="icon-trash icon-white" title="' . $osC_Language->get('button_delete') . '"></i>', 'class="btn btn-mini"'); ?> </td> <td valign="top"> <?php echo osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products['id']), '<b>' . $products['name'] . '</b>'); if (STOCK_CHECK == '1' && $osC_ShoppingCart->isInStock($products['id']) === false) { echo '<span class="markProductOutOfStock">' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . '</span>'; } echo ' (Top Category)'; if (isset($products['error'])) { echo '<br /><span class="markProductError">' . $products['error'] . '</span>'; $osC_ShoppingCart->clearError($products_id_string); }
function insert() { global $osC_Database, $osC_Customer, $osC_Language, $osC_Currencies, $osC_ShoppingCart, $osC_Tax; if (isset($_SESSION['prepOrderID'])) { $_prep = explode('-', $_SESSION['prepOrderID']); if ($_prep[0] == $osC_ShoppingCart->getCartID()) { return $_prep[1]; // order_id } else { if (osC_Order::getStatusID($_prep[1]) === 4) { osC_Order::remove($_prep[1]); } } } $customer_address = osC_AddressBook::getEntry($osC_Customer->getDefaultAddressID())->toArray(); $Qorder = $osC_Database->query('insert into :table_orders (customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_state_code, customers_country, customers_country_iso2, customers_country_iso3, customers_telephone, customers_email_address, customers_address_format, customers_ip_address, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_state_code, delivery_country, delivery_country_iso2, delivery_country_iso3, delivery_address_format, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_state_code, billing_country, billing_country_iso2, billing_country_iso3, billing_address_format, payment_method, payment_module, date_purchased, orders_status, currency, currency_value) values (:customers_id, :customers_name, :customers_company, :customers_street_address, :customers_suburb, :customers_city, :customers_postcode, :customers_state, :customers_state_code, :customers_country, :customers_country_iso2, :customers_country_iso3, :customers_telephone, :customers_email_address, :customers_address_format, :customers_ip_address, :delivery_name, :delivery_company, :delivery_street_address, :delivery_suburb, :delivery_city, :delivery_postcode, :delivery_state, :delivery_state_code, :delivery_country, :delivery_country_iso2, :delivery_country_iso3, :delivery_address_format, :billing_name, :billing_company, :billing_street_address, :billing_suburb, :billing_city, :billing_postcode, :billing_state, :billing_state_code, :billing_country, :billing_country_iso2, :billing_country_iso3, :billing_address_format, :payment_method, :payment_module, now(), :orders_status, :currency, :currency_value)'); $Qorder->bindTable(':table_orders', TABLE_ORDERS); $Qorder->bindInt(':customers_id', $osC_Customer->getID()); $Qorder->bindValue(':customers_name', $osC_Customer->getName()); $Qorder->bindValue(':customers_company', $customer_address['entry_company']); $Qorder->bindValue(':customers_street_address', $customer_address['entry_street_address']); $Qorder->bindValue(':customers_suburb', $customer_address['entry_suburb']); $Qorder->bindValue(':customers_city', $customer_address['entry_city']); $Qorder->bindValue(':customers_postcode', $customer_address['entry_postcode']); $Qorder->bindValue(':customers_state', $customer_address['entry_state']); $Qorder->bindValue(':customers_state_code', osC_Address::getZoneCode($customer_address['entry_zone_id'])); $Qorder->bindValue(':customers_country', osC_Address::getCountryName($customer_address['entry_country_id'])); $Qorder->bindValue(':customers_country_iso2', osC_Address::getCountryIsoCode2($customer_address['entry_country_id'])); $Qorder->bindValue(':customers_country_iso3', osC_Address::getCountryIsoCode3($customer_address['entry_country_id'])); $Qorder->bindValue(':customers_telephone', $customer_address['entry_telephone']); $Qorder->bindValue(':customers_email_address', $osC_Customer->getEmailAddress()); $Qorder->bindValue(':customers_address_format', osC_Address::getFormat($customer_address['entry_country_id'])); $Qorder->bindValue(':customers_ip_address', osc_get_ip_address()); $Qorder->bindValue(':delivery_name', $osC_ShoppingCart->getShippingAddress('firstname') . ' ' . $osC_ShoppingCart->getShippingAddress('lastname')); $Qorder->bindValue(':delivery_company', $osC_ShoppingCart->getShippingAddress('company')); $Qorder->bindValue(':delivery_street_address', $osC_ShoppingCart->getShippingAddress('street_address')); $Qorder->bindValue(':delivery_suburb', $osC_ShoppingCart->getShippingAddress('suburb')); $Qorder->bindValue(':delivery_city', $osC_ShoppingCart->getShippingAddress('city')); $Qorder->bindValue(':delivery_postcode', $osC_ShoppingCart->getShippingAddress('postcode')); $Qorder->bindValue(':delivery_state', $osC_ShoppingCart->getShippingAddress('state')); $Qorder->bindValue(':delivery_state_code', $osC_ShoppingCart->getShippingAddress('zone_code')); $Qorder->bindValue(':delivery_country', $osC_ShoppingCart->getShippingAddress('country_title')); $Qorder->bindValue(':delivery_country_iso2', $osC_ShoppingCart->getShippingAddress('country_iso_code_2')); $Qorder->bindValue(':delivery_country_iso3', $osC_ShoppingCart->getShippingAddress('country_iso_code_3')); $Qorder->bindValue(':delivery_address_format', $osC_ShoppingCart->getShippingAddress('format')); $Qorder->bindValue(':billing_name', $osC_ShoppingCart->getBillingAddress('firstname') . ' ' . $osC_ShoppingCart->getBillingAddress('lastname')); $Qorder->bindValue(':billing_company', $osC_ShoppingCart->getBillingAddress('company')); $Qorder->bindValue(':billing_street_address', $osC_ShoppingCart->getBillingAddress('street_address')); $Qorder->bindValue(':billing_suburb', $osC_ShoppingCart->getBillingAddress('suburb')); $Qorder->bindValue(':billing_city', $osC_ShoppingCart->getBillingAddress('city')); $Qorder->bindValue(':billing_postcode', $osC_ShoppingCart->getBillingAddress('postcode')); $Qorder->bindValue(':billing_state', $osC_ShoppingCart->getBillingAddress('state')); $Qorder->bindValue(':billing_state_code', $osC_ShoppingCart->getBillingAddress('zone_code')); $Qorder->bindValue(':billing_country', $osC_ShoppingCart->getBillingAddress('country_title')); $Qorder->bindValue(':billing_country_iso2', $osC_ShoppingCart->getBillingAddress('country_iso_code_2')); $Qorder->bindValue(':billing_country_iso3', $osC_ShoppingCart->getBillingAddress('country_iso_code_3')); $Qorder->bindValue(':billing_address_format', $osC_ShoppingCart->getBillingAddress('format')); $Qorder->bindValue(':payment_method', $osC_ShoppingCart->getBillingMethod('title')); $Qorder->bindValue(':payment_module', $GLOBALS['osC_Payment_' . $osC_ShoppingCart->getBillingMethod('id')]->getCode()); $Qorder->bindInt(':orders_status', 4); $Qorder->bindValue(':currency', $osC_Currencies->getCode()); $Qorder->bindValue(':currency_value', $osC_Currencies->value($osC_Currencies->getCode())); $Qorder->execute(); $insert_id = $osC_Database->nextID(); foreach ($osC_ShoppingCart->getOrderTotals() as $module) { $Qtotals = $osC_Database->query('insert into :table_orders_total (orders_id, title, text, value, class, sort_order) values (:orders_id, :title, :text, :value, :class, :sort_order)'); $Qtotals->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL); $Qtotals->bindInt(':orders_id', $insert_id); $Qtotals->bindValue(':title', $module['title']); $Qtotals->bindValue(':text', $module['text']); $Qtotals->bindValue(':value', $module['value']); $Qtotals->bindValue(':class', $module['code']); $Qtotals->bindInt(':sort_order', $module['sort_order']); $Qtotals->execute(); } $Qstatus = $osC_Database->query('insert into :table_orders_status_history (orders_id, orders_status_id, date_added, customer_notified, comments) values (:orders_id, :orders_status_id, now(), :customer_notified, :comments)'); $Qstatus->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY); $Qstatus->bindInt(':orders_id', $insert_id); $Qstatus->bindInt(':orders_status_id', 4); $Qstatus->bindInt(':customer_notified', '0'); $Qstatus->bindValue(':comments', isset($_SESSION['comments']) ? $_SESSION['comments'] : ''); $Qstatus->execute(); foreach ($osC_ShoppingCart->getProducts() as $products) { $Qproducts = $osC_Database->query('insert into :table_orders_products (orders_id, products_id, products_model, products_name, products_price, products_tax, products_quantity) values (:orders_id, :products_id, :products_model, :products_name, :products_price, :products_tax, :products_quantity)'); $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS); $Qproducts->bindInt(':orders_id', $insert_id); $Qproducts->bindInt(':products_id', osc_get_product_id($products['id'])); $Qproducts->bindValue(':products_model', $products['model']); $Qproducts->bindValue(':products_name', $products['name']); $Qproducts->bindValue(':products_price', $products['price']); $Qproducts->bindValue(':products_tax', $osC_Tax->getTaxRate($products['tax_class_id'])); $Qproducts->bindInt(':products_quantity', $products['quantity']); $Qproducts->execute(); $order_products_id = $osC_Database->nextID(); if ($osC_ShoppingCart->isVariant($products['item_id'])) { foreach ($osC_ShoppingCart->getVariant($products['item_id']) as $variant) { /* HPDL if (DOWNLOAD_ENABLED == '1') { $Qattributes = $osC_Database->query('select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount, pad.products_attributes_filename from :table_products_options popt, :table_products_options_values poval, :table_products_attributes pa left join :table_products_attributes_download pad on (pa.products_attributes_id = pad.products_attributes_id) where pa.products_id = :products_id and pa.options_id = :options_id and pa.options_id = popt.products_options_id and pa.options_values_id = :options_values_id and pa.options_values_id = poval.products_options_values_id and popt.language_id = :popt_language_id and poval.language_id = :poval_language_id'); $Qattributes->bindTable(':table_products_options', TABLE_PRODUCTS_OPTIONS); $Qattributes->bindTable(':table_products_options_values', TABLE_PRODUCTS_OPTIONS_VALUES); $Qattributes->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES); $Qattributes->bindTable(':table_products_attributes_download', TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD); $Qattributes->bindInt(':products_id', $products['id']); $Qattributes->bindInt(':options_id', $attributes['options_id']); $Qattributes->bindInt(':options_values_id', $attributes['options_values_id']); $Qattributes->bindInt(':popt_language_id', $osC_Language->getID()); $Qattributes->bindInt(':poval_language_id', $osC_Language->getID()); $Qattributes->execute(); } */ $Qvariant = $osC_Database->query('insert into :table_orders_products_variants (orders_id, orders_products_id, group_title, value_title) values (:orders_id, :orders_products_id, :group_title, :value_title)'); $Qvariant->bindTable(':table_orders_products_variants', TABLE_ORDERS_PRODUCTS_VARIANTS); $Qvariant->bindInt(':orders_id', $insert_id); $Qvariant->bindInt(':orders_products_id', $order_products_id); $Qvariant->bindValue(':group_title', $variant['group_title']); $Qvariant->bindValue(':value_title', $variant['value_title']); $Qvariant->execute(); /*HPDL if ((DOWNLOAD_ENABLED == '1') && (strlen($Qattributes->value('products_attributes_filename')) > 0)) { $Qopd = $osC_Database->query('insert into :table_orders_products_download (orders_id, orders_products_id, orders_products_filename, download_maxdays, download_count) values (:orders_id, :orders_products_id, :orders_products_filename, :download_maxdays, :download_count)'); $Qopd->bindTable(':table_orders_products_download', TABLE_ORDERS_PRODUCTS_DOWNLOAD); $Qopd->bindInt(':orders_id', $insert_id); $Qopd->bindInt(':orders_products_id', $order_products_id); $Qopd->bindValue(':orders_products_filename', $Qattributes->value('products_attributes_filename')); $Qopd->bindValue(':download_maxdays', $Qattributes->value('products_attributes_maxdays')); $Qopd->bindValue(':download_count', $Qattributes->value('products_attributes_maxcount')); $Qopd->execute(); } */ } } } $_SESSION['prepOrderID'] = $osC_ShoppingCart->getCartID() . '-' . $insert_id; return $insert_id; }
foreach ($combobox_array as $groups_name => $combobox) { echo '<tr class="variantCombobox"> <td class="label" valign="top">' . $groups_name . ':</td> <td>' . $combobox . '</td> </tr>'; } } } ?> <tr> <td colspan="2" align="center" valign="top" style="padding-top: 15px" id="shoppingCart"> <?php echo '<b>' . $osC_Language->get('field_short_quantity') . '</b> ' . osc_draw_input_field('quantity', $osC_Product->getMOQ(), 'size="3"') . ' '; if ($osC_Category->getMode() == CATEGORIES_MODE_AVAILABLE_FOR_ORDER) { echo osc_draw_image_submit_button('button_in_cart.gif', $osC_Language->get('button_add_to_cart'), 'style="vertical-align:middle;" class="ajaxAddToCart" id="ac_productsinfo_' . osc_get_product_id($osC_Product->getID()) . '"'); } else { if ($osC_Category->getMode() == CATEGORIES_MODE_ONLINE_ONLY) { echo '<strong>' . $osC_Language->get('online_only_mode') . '</strong>'; } } ?> </td> </tr> <tr> <td colspan="2" align="center" id = "shoppingAction"> <?php echo osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), $osC_Product->getID() . '&' . '&action=compare_products_add'), $osC_Language->get('add_to_compare')) . ' <span>|</span> ' . osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), $osC_Product->getID() . '&action=wishlist_add'), $osC_Language->get('add_to_wishlist')); ?> </td>
function insert($order_status = DEFAULT_ORDERS_STATUS_ID) { global $osC_Database, $osC_Customer, $osC_Language, $osC_Currencies, $osC_ShoppingCart, $osC_Tax, $toC_Wishlist; if (isset($_SESSION['prepOrderID'])) { $_prep = explode('-', $_SESSION['prepOrderID']); if ($_prep[0] == $osC_ShoppingCart->getCartID()) { return $_prep[1]; // order_id } else { if (osC_Order::getStatusID($_prep[1]) === ORDERS_STATUS_PREPARING) { osC_Order::remove($_prep[1]); } } } if (!class_exists(osC_Account)) { require_once 'includes/classes/account.php'; } if (!$osC_Customer->isLoggedOn()) { osC_Order::createCustomer(); } else { //insert billing address $billing_address = $osC_ShoppingCart->getBillingAddress(); if (isset($billing_address['id']) && $billing_address['id'] == '-1') { osC_Account::createNewAddress($osC_Customer->getID(), $billing_address); } //insert shipping address if (!isset($billing_address['ship_to_this_address']) || isset($billing_address['ship_to_this_address']) && empty($billing_address['ship_to_this_address'])) { $shipping_address = $osC_ShoppingCart->getShippingAddress(); if (isset($shipping_address['id']) && $shipping_address['id'] == '-1') { osC_Account::createNewAddress($osC_Customer->getID(), $shipping_address); } } } $Qorder = $osC_Database->query('insert into :table_orders (customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_comment, customers_state_code, customers_country, customers_country_iso2, customers_country_iso3, customers_telephone, customers_email_address, customers_address_format, customers_ip_address, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_zone_id, delivery_state_code, delivery_country_id, delivery_country, delivery_country_iso2, delivery_country_iso3, delivery_address_format, delivery_telephone, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_zone_id, billing_state_code, billing_country_id, billing_country, billing_country_iso2, billing_country_iso3, billing_address_format, billing_telephone, payment_method, payment_module, uses_store_credit, store_credit_amount, date_purchased, orders_status, currency, currency_value, gift_wrapping, wrapping_message) values (:customers_id, :customers_name, :customers_company, :customers_street_address, :customers_suburb, :customers_city, :customers_postcode, :customers_state, :customers_comment, :customers_state_code, :customers_country, :customers_country_iso2, :customers_country_iso3, :customers_telephone, :customers_email_address, :customers_address_format, :customers_ip_address, :delivery_name, :delivery_company, :delivery_street_address, :delivery_suburb, :delivery_city, :delivery_postcode, :delivery_state, :delivery_zone_id, :delivery_state_code, :delivery_country_id, :delivery_country, :delivery_country_iso2, :delivery_country_iso3, :delivery_address_format, :delivery_telephone, :billing_name, :billing_company, :billing_street_address, :billing_suburb, :billing_city, :billing_postcode, :billing_state, :billing_zone_id, :billing_state_code, :billing_country_id, :billing_country, :billing_country_iso2, :billing_country_iso3, :billing_address_format, :billing_telephone, :payment_method, :payment_module, :uses_store_credit, :store_credit_amount, now(), :orders_status, :currency, :currency_value, :gift_wrapping, :wrapping_message)'); $Qorder->bindTable(':table_orders', TABLE_ORDERS); $Qorder->bindInt(':customers_id', $osC_Customer->getID()); $Qorder->bindValue(':customers_name', $osC_Customer->getName()); $Qorder->bindValue(':customers_company', ''); $Qorder->bindValue(':customers_street_address', ''); $Qorder->bindValue(':customers_suburb', ''); $Qorder->bindValue(':customers_city', ''); $Qorder->bindValue(':customers_postcode', ''); $Qorder->bindValue(':customers_state', ''); $Qorder->bindValue(':customers_state_code', ''); $Qorder->bindValue(':customers_country', ''); $Qorder->bindValue(':customers_country_iso2', ''); $Qorder->bindValue(':customers_country_iso3', ''); $Qorder->bindValue(':customers_telephone', ''); $Qorder->bindValue(':customers_email_address', $osC_Customer->getEmailAddress()); $Qorder->bindValue(':customers_comment', $_SESSION['comments']); $Qorder->bindValue(':customers_address_format', ''); $Qorder->bindValue(':customers_ip_address', osc_get_ip_address()); $Qorder->bindValue(':delivery_name', $osC_ShoppingCart->getShippingAddress('firstname') . ' ' . $osC_ShoppingCart->getShippingAddress('lastname')); $Qorder->bindValue(':delivery_company', $osC_ShoppingCart->getShippingAddress('company')); $Qorder->bindValue(':delivery_street_address', $osC_ShoppingCart->getShippingAddress('street_address')); $Qorder->bindValue(':delivery_suburb', $osC_ShoppingCart->getShippingAddress('suburb')); $Qorder->bindValue(':delivery_city', $osC_ShoppingCart->getShippingAddress('city')); $Qorder->bindValue(':delivery_postcode', $osC_ShoppingCart->getShippingAddress('postcode')); $Qorder->bindValue(':delivery_state', $osC_ShoppingCart->getShippingAddress('state')); $Qorder->bindValue(':delivery_zone_id', $osC_ShoppingCart->getShippingAddress('zone_id')); $Qorder->bindValue(':delivery_state_code', $osC_ShoppingCart->getShippingAddress('zone_code')); $Qorder->bindValue(':delivery_country_id', $osC_ShoppingCart->getShippingAddress('country_id')); $Qorder->bindValue(':delivery_country', $osC_ShoppingCart->getShippingAddress('country_title')); $Qorder->bindValue(':delivery_country_iso2', $osC_ShoppingCart->getShippingAddress('country_iso_code_2')); $Qorder->bindValue(':delivery_country_iso3', $osC_ShoppingCart->getShippingAddress('country_iso_code_3')); $Qorder->bindValue(':delivery_address_format', $osC_ShoppingCart->getShippingAddress('format')); $Qorder->bindValue(':delivery_telephone', $osC_ShoppingCart->getShippingAddress('telephone_number')); $Qorder->bindValue(':billing_name', $osC_ShoppingCart->getBillingAddress('firstname') . ' ' . $osC_ShoppingCart->getBillingAddress('lastname')); $Qorder->bindValue(':billing_company', $osC_ShoppingCart->getBillingAddress('company')); $Qorder->bindValue(':billing_street_address', $osC_ShoppingCart->getBillingAddress('street_address')); $Qorder->bindValue(':billing_suburb', $osC_ShoppingCart->getBillingAddress('suburb')); $Qorder->bindValue(':billing_city', $osC_ShoppingCart->getBillingAddress('city')); $Qorder->bindValue(':billing_postcode', $osC_ShoppingCart->getBillingAddress('postcode')); $Qorder->bindValue(':billing_state', $osC_ShoppingCart->getBillingAddress('state')); $Qorder->bindValue(':billing_zone_id', $osC_ShoppingCart->getBillingAddress('zone_id')); $Qorder->bindValue(':billing_state_code', $osC_ShoppingCart->getBillingAddress('zone_code')); $Qorder->bindValue(':billing_country_id', $osC_ShoppingCart->getBillingAddress('country_id')); $Qorder->bindValue(':billing_country', $osC_ShoppingCart->getBillingAddress('country_title')); $Qorder->bindValue(':billing_country_iso2', $osC_ShoppingCart->getBillingAddress('country_iso_code_2')); $Qorder->bindValue(':billing_country_iso3', $osC_ShoppingCart->getBillingAddress('country_iso_code_3')); $Qorder->bindValue(':billing_address_format', $osC_ShoppingCart->getBillingAddress('format')); $Qorder->bindValue(':billing_telephone', $osC_ShoppingCart->getBillingAddress('telephone_number')); $Qorder->bindValue(':payment_method', implode(',', $osC_ShoppingCart->getCartBillingMethods())); $Qorder->bindValue(':payment_module', implode(',', $osC_ShoppingCart->getCartBillingModules())); $Qorder->bindInt(':uses_store_credit', $osC_ShoppingCart->isUseStoreCredit()); $Qorder->bindValue(':store_credit_amount', $osC_ShoppingCart->isUseStoreCredit() ? $osC_ShoppingCart->getStoreCredit() : '0'); $Qorder->bindInt(':orders_status', $order_status); $Qorder->bindValue(':currency', $osC_Currencies->getCode()); $Qorder->bindValue(':currency_value', $osC_Currencies->value($osC_Currencies->getCode())); $Qorder->bindInt(':gift_wrapping', $osC_ShoppingCart->isGiftWrapping() ? '1' : '0'); $Qorder->bindValue(':wrapping_message', isset($_SESSION['gift_wrapping_comments']) ? $_SESSION['gift_wrapping_comments'] : ''); $Qorder->execute(); $insert_id = $osC_Database->nextID(); foreach ($osC_ShoppingCart->getOrderTotals() as $module) { $Qtotals = $osC_Database->query('insert into :table_orders_total (orders_id, title, text, value, class, sort_order) values (:orders_id, :title, :text, :value, :class, :sort_order)'); $Qtotals->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL); $Qtotals->bindInt(':orders_id', $insert_id); $Qtotals->bindValue(':title', $module['title']); $Qtotals->bindValue(':text', $module['text']); $Qtotals->bindValue(':value', $module['value']); $Qtotals->bindValue(':class', $module['code']); $Qtotals->bindInt(':sort_order', $module['sort_order']); $Qtotals->execute(); } $Qstatus = $osC_Database->query('insert into :table_orders_status_history (orders_id, orders_status_id, date_added, customer_notified, comments) values (:orders_id, :orders_status_id, now(), :customer_notified, :comments)'); $Qstatus->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY); $Qstatus->bindInt(':orders_id', $insert_id); $Qstatus->bindInt(':orders_status_id', $order_status); $Qstatus->bindInt(':customer_notified', '0'); $Qstatus->bindValue(':comments', isset($_SESSION['comments']) ? $_SESSION['comments'] : ''); $Qstatus->execute(); foreach ($osC_ShoppingCart->getProducts() as $products) { $Qproducts = $osC_Database->query('insert into :table_orders_products (orders_id, products_id, products_type, products_sku, products_name, products_price, final_price, products_tax, products_quantity) values (:orders_id, :products_id, :products_type, :products_sku, :products_name, :products_price, :final_price, :products_tax, :products_quantity)'); $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS); $Qproducts->bindInt(':orders_id', $insert_id); $Qproducts->bindInt(':products_id', osc_get_product_id($products['id'])); $Qproducts->bindValue(':products_type', $products['type']); $Qproducts->bindValue(':products_sku', $products['sku']); $Qproducts->bindValue(':products_name', $products['name']); $Qproducts->bindValue(':products_price', $products['price']); $Qproducts->bindValue(':final_price', $products['final_price']); $Qproducts->bindValue(':products_tax', $osC_Tax->getTaxRate($products['tax_class_id'], $osC_ShoppingCart->getTaxingAddress('country_id'), $osC_ShoppingCart->getTaxingAddress('zone_id'))); $Qproducts->bindInt(':products_quantity', $products['quantity']); $Qproducts->execute(); $order_products_id = $osC_Database->nextID(); if (!empty($products['customizations'])) { foreach ($products['customizations'] as $customization) { $Qcustomization = $osC_Database->query('insert into :table_orders_products_customizations (orders_id, orders_products_id, quantity) values (:orders_id, :orders_products_id, :quantity)'); $Qcustomization->bindTable(':table_orders_products_customizations', TABLE_ORDERS_PRODUCTS_CUSTOMIZATIONS); $Qcustomization->bindInt(':orders_id', $insert_id); $Qcustomization->bindInt(':orders_products_id', $order_products_id); $Qcustomization->bindInt(':quantity', $customization['qty']); $Qcustomization->execute(); $orders_products_customizations_id = $osC_Database->nextID(); foreach ($customization['fields'] as $field) { $Qfield = $osC_Database->query('insert into :table_orders_products_customizations_values (orders_products_customizations_id , customization_fields_id, customization_fields_name, customization_fields_type, customization_fields_value, cache_file_name) values (:orders_products_customizations_id, :customization_fields_id, :customization_fields_name, :customization_fields_type, :customization_fields_value, :cache_file_name)'); $Qfield->bindTable(':table_orders_products_customizations_values', TABLE_ORDERS_PRODUCTS_CUSTOMIZATIONS_VALUES); $Qfield->bindInt(':orders_products_customizations_id', $orders_products_customizations_id); $Qfield->bindInt(':customization_fields_id', $field['customization_fields_id']); $Qfield->bindValue(':customization_fields_name', $field['customization_fields_name']); $Qfield->bindInt(':customization_fields_type', $field['customization_type']); $Qfield->bindValue(':customization_fields_value', $field['customization_value']); $Qfield->bindValue(':cache_file_name', $field['cache_filename']); $Qfield->execute(); if ($osC_Database->isError() === false) { @copy(DIR_FS_CACHE . 'products_customizations/' . $field['cache_filename'], DIR_FS_CACHE . 'orders_customizations/' . $field['cache_filename']); } } } } if ($osC_ShoppingCart->hasVariants($products['id'])) { foreach ($osC_ShoppingCart->getVariants($products['id']) as $variants_id => $variants) { $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 = :pvg_language_id and pvv.language_id = :pvv_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', $products['id']); $Qvariants->bindInt(':groups_id', $variants['groups_id']); $Qvariants->bindInt(':variants_values_id', $variants['variants_values_id']); $Qvariants->bindInt(':pvg_language_id', $osC_Language->getID()); $Qvariants->bindInt(':pvv_language_id', $osC_Language->getID()); $Qvariants->execute(); $Qopv = $osC_Database->query('insert into :table_orders_products_variants (orders_id, orders_products_id, products_variants_groups_id, products_variants_groups, products_variants_values_id, products_variants_values) values (:orders_id, :orders_products_id, :products_variants_groups_id, :products_variants_groups, :products_variants_values_id, :products_variants_values)'); $Qopv->bindTable(':table_orders_products_variants', TABLE_ORDERS_PRODUCTS_VARIANTS); $Qopv->bindInt(':orders_id', $insert_id); $Qopv->bindInt(':orders_products_id', $order_products_id); $Qopv->bindInt(':products_variants_groups_id', $variants['groups_id']); $Qopv->bindValue(':products_variants_groups', $Qvariants->value('products_variants_groups_name')); $Qopv->bindInt(':products_variants_values_id', $variants['variants_values_id']); $Qopv->bindValue(':products_variants_values', $Qvariants->value('products_variants_values_name')); $Qopv->execute(); } } if ($products['type'] == PRODUCT_TYPE_DOWNLOADABLE) { $Qdownloadable = $osC_Database->query('select * from :table_products_downloadables where products_id = :products_id'); $Qdownloadable->bindTable(':table_products_downloadables', TABLE_PRODUCTS_DOWNLOADABLES); $Qdownloadable->bindInt(':products_id', osc_get_product_id($products['id'])); $Qdownloadable->execute(); if ($osC_ShoppingCart->hasVariants($products['id'])) { $variants_filename = $products['variant_filename']; $variants_cache_filename = $products['variant_cache_filename']; } else { $variants_filename = $Qdownloadable->value('filename'); $variants_cache_filename = $Qdownloadable->value('cache_filename'); } $Qopd = $osC_Database->query('insert into :table_orders_products_download (orders_id, orders_products_id, orders_products_filename, orders_products_cache_filename, download_maxdays, download_count) values (:orders_id, :orders_products_id, :orders_products_filename, :orders_products_cache_filename, :download_maxdays, :download_count)'); $Qopd->bindTable(':table_orders_products_download', TABLE_ORDERS_PRODUCTS_DOWNLOAD); $Qopd->bindInt(':orders_id', $insert_id); $Qopd->bindInt(':orders_products_id', $order_products_id); $Qopd->bindValue(':orders_products_filename', $variants_filename); $Qopd->bindValue(':orders_products_cache_filename', $variants_cache_filename); $Qopd->bindValue(':download_maxdays', $Qdownloadable->valueInt('number_of_accessible_days')); $Qopd->bindValue(':download_count', $Qdownloadable->valueInt('number_of_downloads') * $products['quantity']); $Qopd->execute(); } if ($products['type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) { require_once 'gift_certificates.php'; $Qgc = $osC_Database->query('insert into :table_gift_certificates (orders_id, orders_products_id, gift_certificates_type, amount, gift_certificates_code, recipients_name, recipients_email, senders_name, senders_email, messages) values (:orders_id, :orders_products_id, :gift_certificates_type, :amount, :gift_certificates_code, :recipients_name, :recipients_email, :senders_name, :senders_email, :messages)'); $Qgc->bindTable(':table_gift_certificates', TABLE_GIFT_CERTIFICATES); $Qgc->bindInt(':orders_id', $insert_id); $Qgc->bindInt(':gift_certificates_type', $products['gc_data']['type']); $Qgc->bindInt(':orders_products_id', $order_products_id); $Qgc->bindValue(':amount', $products['price']); $Qgc->bindValue(':gift_certificates_code', toC_Gift_Certificates::createGiftCertificateCode()); $Qgc->bindValue(':recipients_name', $products['gc_data']['recipients_name']); $Qgc->bindValue(':recipients_email', $products['gc_data']['type'] == GIFT_CERTIFICATE_TYPE_EMAIL ? $products['gc_data']['recipients_email'] : ''); $Qgc->bindValue(':senders_name', $products['gc_data']['senders_name']); $Qgc->bindValue(':senders_email', $products['gc_data']['type'] == GIFT_CERTIFICATE_TYPE_EMAIL ? $products['gc_data']['senders_email'] : ''); $Qgc->bindValue(':messages', $products['gc_data']['message']); $Qgc->execute(); } } if ($osC_ShoppingCart->isUseStoreCredit()) { $Qhistory = $osC_Database->query('insert into :table_customers_credits_history (customers_id, action_type, date_added, amount, comments) values (:customers_id, :action_type, now(), :amount, :comments)'); $Qhistory->bindTable(':table_customers_credits_history', TABLE_CUSTOMERS_CREDITS_HISTORY); $Qhistory->bindInt(':customers_id', $osC_Customer->getID()); $Qhistory->bindInt(':action_type', STORE_CREDIT_ACTION_TYPE_ORDER_PURCHASE); $Qhistory->bindValue(':amount', $osC_ShoppingCart->getStoreCredit() * -1); $Qhistory->bindValue(':comments', sprintf($osC_Language->get('store_credit_order_number'), $insert_id)); $Qhistory->execute(); $Qcustomer = $osC_Database->query('update :table_customers set customers_credits = (customers_credits + :customers_credits) where customers_id = :customers_id'); $Qcustomer->bindTable(':table_customers', TABLE_CUSTOMERS); $Qcustomer->bindRaw(':customers_credits', $osC_ShoppingCart->getStoreCredit() * -1); $Qcustomer->bindInt(':customers_id', $osC_Customer->getID()); $Qcustomer->execute(); $Qcredit = $osC_Database->query('select customers_credits from :table_customers where customers_id = :customers_id'); $Qcredit->bindTable(':table_customers', TABLE_CUSTOMERS); $Qcredit->bindInt(':customers_id', $osC_Customer->getID()); $Qcredit->execute(); $osC_Customer->setStoreCredit($Qcredit->value('customers_credits')); } if ($osC_ShoppingCart->hasCoupon()) { include_once 'includes/classes/coupon.php'; $toC_Coupon = new toC_Coupon($osC_ShoppingCart->getCouponCode()); $Qcoupon = $osC_Database->query('insert into :table_coupons_redeem_history (coupons_id, customers_id, orders_id, redeem_amount, redeem_date, redeem_ip_address) values (:coupons_id, :customers_id, :orders_id, :redeem_amount, now(), :redeem_ip_address)'); $Qcoupon->bindTable(':table_coupons_redeem_history', TABLE_COUPONS_REDEEM_HISTORY); $Qcoupon->bindInt(':coupons_id', $toC_Coupon->getID()); $Qcoupon->bindInt(':customers_id', $osC_Customer->getID()); $Qcoupon->bindInt(':orders_id', $insert_id); $Qcoupon->bindValue(':redeem_amount', $osC_ShoppingCart->getCouponAmount()); $Qcoupon->bindValue(':redeem_ip_address', osc_get_ip_address()); $Qcoupon->execute(); } if ($osC_ShoppingCart->hasGiftCertificate()) { $gift_certificate_codes = $osC_ShoppingCart->getGiftCertificateRedeemAmount(); foreach ($gift_certificate_codes as $gift_certificate_code => $amount) { $Qcertificate = $osC_Database->query('select gift_certificates_id from :table_gift_certificates where gift_certificates_code = :gift_certificates_code'); $Qcertificate->bindTable(':table_gift_certificates', TABLE_GIFT_CERTIFICATES); $Qcertificate->bindValue(':gift_certificates_code', $gift_certificate_code); $Qcertificate->execute(); $Qinsert = $osC_Database->query('insert into :table_gift_certificates_redeem_history (gift_certificates_id, customers_id, orders_id, redeem_date, redeem_amount, redeem_ip_address) values (:gift_certificates_id, :customers_id, :orders_id, now(), :redeem_amount, :redeem_ip_address)'); $Qinsert->bindTable(':table_gift_certificates_redeem_history', TABLE_GIFT_CERTIFICATES_REDEEM_HISTORY); $Qinsert->bindInt(':gift_certificates_id', $Qcertificate->valueInt(gift_certificates_id)); $Qinsert->bindInt(':customers_id', $osC_Customer->getID()); $Qinsert->bindInt(':orders_id', $insert_id); $Qinsert->bindValue(':redeem_amount', $amount); $Qinsert->bindValue(':redeem_ip_address', osc_get_ip_address()); $Qinsert->execute(); } } $_SESSION['prepOrderID'] = $osC_ShoppingCart->getCartID() . '-' . $insert_id; return $insert_id; }
function incrementCounter() { global $osC_Database, $osC_Language; $Qupdate = $osC_Database->query('update :table_products_description set products_viewed = products_viewed+1 where products_id = :products_id and language_id = :language_id'); $Qupdate->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION); $Qupdate->bindInt(':products_id', osc_get_product_id($this->_data['id'])); $Qupdate->bindInt(':language_id', $osC_Language->getID()); $Qupdate->execute(); }
function listWishlists() { global $toC_Json, $osC_Language, $osC_Database; $customers_id = isset($_REQUEST['customers_id']) ? $_REQUEST['customers_id'] : null; if (is_numeric($customers_id)) { $Qwishlists = $osC_Database->query('select wp.wishlists_products_id, wp.products_id, wp.date_added, wp.comments from :table_wishlists w, :table_wishlists_products wp where w.wishlists_id = wp.wishlists_id and w.customers_id = :customers_id'); $Qwishlists->bindTable(':table_wishlists', TABLE_WISHLISTS); $Qwishlists->bindTable(':table_wishlists_products', TABLE_WISHLISTS_PRODUCTS); $Qwishlists->bindInt(':customers_id', $customers_id); $Qwishlists->execute(); $records = array(); while ($Qwishlists->next()) { $products_id = osc_get_product_id($Qwishlists->value('products_id')); $variants = osc_parse_variants_from_id_string($Qwishlists->value('products_id')); $Qname = $osC_Database->query('select products_name from :table_products_description where products_id = :products_id and language_id = :language_id'); $Qname->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION); $Qname->bindInt(':products_id', $products_id); $Qname->bindInt(':language_id', $osC_Language->getID()); $Qname->execute(); $products_name = $Qname->value('products_name'); if (!empty($variants)) { $variants_name = array(); foreach ($variants as $groups_id => $values_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 = :pvg_language_id and pvv.language_id = :pvv_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', $products_id); $Qvariants->bindInt(':groups_id', $groups_id); $Qvariants->bindInt(':variants_values_id', $values_id); $Qvariants->bindInt(':pvg_language_id', $osC_Language->getID()); $Qvariants->bindInt(':pvv_language_id', $osC_Language->getID()); $Qvariants->execute(); $variants_name[] = $Qvariants->value('products_variants_groups_name') . ' : ' . $Qvariants->value('products_variants_values_name'); } $products_name .= '<br />' . implode('<br />', $variants_name); } $records[] = array('wishlists_products_id' => $Qwishlists->value('wishlists_products_id'), 'products_name' => $products_name, 'date_added' => osC_DateTime::getShort($Qwishlists->value('date_added')), 'comments' => $Qwishlists->value('comments')); } $Qwishlists->freeResult(); $response = array(EXT_JSON_READER_ROOT => $records); echo $toC_Json->encode($response); } }
<div class="submitFormButtons" style="text-align: right;"> <?php if ($osC_Services->isStarted('reviews')) { echo '<span>' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, 'reviews&' . osc_get_all_get_params()), osc_draw_image_button('button_reviews.gif', $osC_Language->get('button_reviews'))) . '</span>'; } ?> </div> <?php if ($osC_Services->isStarted('reviews') && osC_Reviews::exists(osc_get_product_id($osC_Product->getID()))) { ?> <p><?php echo $osC_Language->get('number_of_product_reviews') . ' ' . osC_Reviews::getTotal(osc_get_product_id($osC_Product->getID())); ?> </p> <?php } ?> <script type=text/javascript> window.addEvent('domready', function(){ $('defaultProductImage').addEvent('click',function(e){ e.preventDefault(); Milkbox.openMilkbox(Milkbox.galleries[0], 0); });
function synchronizeWithDatabase() { global $osC_Database, $osC_Services, $osC_Language, $osC_Customer, $osC_Image; if (!$osC_Customer->isLoggedOn()) { return false; } $Qcheck = $osC_Database->query('select wishlists_id, wishlists_token from :table_wishlists where customers_id = :customers_id'); $Qcheck->bindTable(':table_wishlists', TABLE_WISHLISTS); $Qcheck->bindInt(':customers_id', $osC_Customer->getID()); $Qcheck->execute(); if ($Qcheck->numberOfRows() > 0) { //remove anonymous wishlist from database $this->deleteGuestWishlist(); $this->_wishlists_id = $Qcheck->valueInt('wishlists_id'); $this->_token = $Qcheck->value('wishlists_token'); // insert current wishlist in database if ($this->hasContents()) { foreach ($this->_contents as $products_id => $data) { $Qproduct = $osC_Database->query('select products_id from :table_wishlists_products where wishlists_id = :wishlists_id and products_id = :products_id'); $Qproduct->bindTable(':table_wishlists_products', TABLE_WISHLISTS_PRODUCTS); $Qproduct->bindInt(':wishlists_id', $this->_wishlists_id); $Qproduct->bindInt(':products_id', $products_id); $Qproduct->execute(); if (!($Qproduct->numberOfRows() > 0)) { $Qnew = $osC_Database->query('insert into :table_wishlists_products (wishlists_id, products_id, date_added, comments) values (:wishlists_id, :products_id, now(),:comments)'); $Qnew->bindTable(':table_wishlists_products', TABLE_WISHLISTS_PRODUCTS); $Qnew->bindInt(':wishlists_id', $this->_wishlists_id); $Qnew->bindInt(':products_id', $products_id); $Qnew->bindValue(':comments', $data['comments']); $Qnew->execute(); } } } // reset per-session cart contents, but not the database contents $this->_contents = array(); $Qproducts = $osC_Database->query('select products_id, date_added, comments from :table_wishlist_products where wishlists_id = :wishlists_id'); $Qproducts->bindTable(':table_wishlist_products', TABLE_WISHLISTS_PRODUCTS); $Qproducts->bindInt(':wishlists_id', $this->_wishlists_id); $Qproducts->execute(); while ($Qproducts->next()) { $osC_Product = new osC_Product($Qproducts->value('products_id')); $price = $osC_Product->getPrice(); if ($osC_Services->isStarted('specials')) { global $osC_Specials; if ($new_price = $osC_Specials->getPrice(osc_get_product_id($Qproducts->value('products_id')))) { $price = $new_price; } } $this->_contents[$Qproducts->value('products_id')] = array('products_id' => $Qproducts->value('products_id'), 'name' => $osC_Product->getTitle(), 'image' => $osC_Product->getImage(), 'price' => $price, 'date_added' => osC_DateTime::getShort($Qproducts->value('date_added')), 'comments' => $Qproducts->value('comments')); } } else { $token = $this->generateToken(); $Qupdate = $osC_Database->query('update :table_wishlists set customers_id = :customers_id, wishlists_token = :wishlists_token where wishlists_id = :wishlists_id'); $Qupdate->bindTable(':table_wishlists', TABLE_WISHLISTS); $Qupdate->bindInt(':customers_id', $osC_Customer->getID()); $Qupdate->bindValue(':wishlists_token', $token); $Qupdate->bindInt(':wishlists_id', $this->_wishlists_id); $Qupdate->execute(); $this->_token = $token; } }
</tr> <?php } ?> <tr> <td valign="top" width="30" align="center"> <?php $variants_string = null; if (!is_numeric($products_id_string) && strpos($products_id_string, '#') != false) { $tmp = explode('#', $products_id_string); $variants_string = $tmp[1]; } echo osc_link_object(osc_href_link(FILENAME_CHECKOUT, osc_get_product_id($products['id']) . (!empty($variants_string) ? '&variants=' . $variants_string : '') . '&action=cart_remove', 'SSL'), osc_draw_image_button('small_delete.gif', $osC_Language->get('button_delete'))); ?> </td> <td valign="center"> <?php echo osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products['id']), '<b>' . $products['name'] . '</b>'); if (STOCK_CHECK == '1' && $osC_ShoppingCart->isInStock($products['id']) === false) { echo '<span class="markProductOutOfStock">' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . '</span>'; } echo ' (Top Category)'; if (isset($products['error'])) { echo '<br /><span class="markProductError">' . $products['error'] . '</span>'; $osC_ShoppingCart->clearError($products_id_string); }
/** * Add the products to this order. */ function addProduct($products_id_string, $quantity, $gift_certificate_data = null) { global $osC_Database, $osC_Language, $osC_Tax; $error = false; $osC_Database->startTransaction(); $products_id = osc_get_product_id($products_id_string); $variants = osc_parse_variants_from_id_string($products_id_string); $osC_Product = new osC_Product($products_id, $this->getCustomer('customers_id')); //If the products with the variants exists in the order, then increase the order quantity //Each gift certificate added to order will be considered as a new product // if (isset($this->_contents[$products_id_string])) { $orders_products_id = $this->_contents[$products_id_string]['orders_products_id']; $new_quantity = $this->_contents[$products_id_string]['quantity'] + $quantity; $Qupdate = $osC_Database->query('update :table_orders_products set products_quantity = :products_quantity, products_price = :products_price, final_price = :final_price, products_type = :products_type where orders_products_id = :orders_products_id '); $Qupdate->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS); $Qupdate->bindInt(':products_quantity', $new_quantity); $Qupdate->bindValue(':products_price', $osC_Product->getPrice($variants, $new_quantity)); $Qupdate->bindValue(':final_price', $osC_Product->getPrice($variants, $new_quantity)); $Qupdate->bindInt(':orders_products_id', $orders_products_id); $Qupdate->bindInt(':products_type', $osC_Product->getProductType()); $Qupdate->setLogging($_SESSION['module'], $this->_order_id); $Qupdate->execute(); if ($osC_Database->isError()) { $error = true; } else { $this->_contents[$products_id_string]['quantity'] = $new_quantity; $this->_contents[$products_id_string]['price'] = $osC_Product->getPrice($variants, $new_quantity); $this->_contents[$products_id_string]['final_price'] = $osC_Product->getPrice($variants, $new_quantity); } } else { $products_price = $osC_Product->getPrice($variants, $quantity); if ($osC_Product->isEmailGiftCertificate() && $osC_Product->isOpenAmountGiftCertificate()) { $products_price = $gift_certificate_data['price']; } $Qinsert = $osC_Database->query('insert into :table_orders_products (orders_id, products_id, products_sku, products_name, products_price, final_price, products_tax, products_quantity, products_type) values (:orders_id, :products_id, :products_sku, :products_name, :products_price, :final_price, :products_tax, :products_quantity, :products_type) '); $Qinsert->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS); $Qinsert->bindInt(':orders_id', $this->_order_id); $Qinsert->bindInt(':products_id', $osC_Product->getID()); $Qinsert->bindValue(':products_sku', $osC_Product->getSKU()); $Qinsert->bindValue(':products_name', $osC_Product->getTitle()); $Qinsert->bindValue(':products_price', $products_price); $Qinsert->bindValue(':final_price', $products_price); $Qinsert->bindValue(':products_tax', $osC_Tax->getTaxRate($osC_Product->getTaxClassID(), $this->_shipping_address['country_id'], $this->_shipping_address['zone_id'])); $Qinsert->bindInt(':products_quantity', $quantity); $Qinsert->bindInt(':products_type', $osC_Product->getProductType()); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; } else { $orders_products_id = $osC_Database->nextID(); if (is_array($variants) && !empty($variants)) { foreach ($variants as $groups_id => $values_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', $groups_id); $Qvariants->bindInt(':variants_values_id', $values_id); $Qvariants->bindInt(':language_id', $osC_Language->getID()); $Qvariants->bindInt(':language_id', $osC_Language->getID()); $Qvariants->execute(); $Qinsert = $osC_Database->query('insert into :table_orders_products_variants (orders_id, orders_products_id, products_variants_groups_id, products_variants_groups, products_variants_values_id, products_variants_values) values (:orders_id, :orders_products_id, :products_variants_groups_id, :products_variants_groups, :products_variants_values_id, :products_variants_values) '); $Qinsert->bindTable(':table_orders_products_variants', TABLE_ORDERS_PRODUCTS_VARIANTS); $Qinsert->bindInt(':orders_id', $this->_order_id); $Qinsert->bindInt(':orders_products_id', $orders_products_id); $Qinsert->bindInt(':products_variants_groups_id', $groups_id); $Qinsert->bindValue(':products_variants_groups', $Qvariants->value('products_variants_groups_name')); $Qinsert->bindInt(':products_variants_values_id', $values_id); $Qinsert->bindValue(':products_variants_values', $Qvariants->value('products_variants_values_name')); $Qinsert->setLogging($_SESSION['module'], $this->_order_id); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { if ($osC_Product->getProductType() == PRODUCT_TYPE_DOWNLOADABLE) { $Qdownloadable = $osC_Database->query('select * from :table_products_downloadables where products_id = :products_id'); $Qdownloadable->bindTable(':table_products_downloadables', TABLE_PRODUCTS_DOWNLOADABLES); $Qdownloadable->bindInt(':products_id', $products_id); $Qdownloadable->execute(); $Qopd = $osC_Database->query('insert into :table_orders_products_download (orders_id, orders_products_id, orders_products_filename, orders_products_cache_filename, download_maxdays, download_count) values (:orders_id, :orders_products_id, :orders_products_filename, :orders_products_cache_filename, :download_maxdays, :download_count)'); $Qopd->bindTable(':table_orders_products_download', TABLE_ORDERS_PRODUCTS_DOWNLOAD); $Qopd->bindInt(':orders_id', $_REQUEST['orders_id']); $Qopd->bindInt(':orders_products_id', $orders_products_id); $Qopd->bindValue(':orders_products_filename', $Qdownloadable->value('filename')); $Qopd->bindValue(':orders_products_cache_filename', $Qdownloadable->value('cache_filename')); $Qopd->bindValue(':download_maxdays', $Qdownloadable->valueInt('number_of_accessible_days')); $Qopd->bindValue(':download_count', $Qdownloadable->valueInt('number_of_downloads')); $Qopd->setLogging($_SESSION['module'], $this->_order_id); $Qopd->execute(); if ($osC_Database->isError()) { $error = true; } } } if ($error === false) { if ($osC_Product->getProductType() == PRODUCT_TYPE_GIFT_CERTIFICATE) { require_once '../includes/classes/gift_certificates.php'; $Qgc = $osC_Database->query('insert into :table_gift_certificates (orders_id, orders_products_id, gift_certificates_type, amount, gift_certificates_code, recipients_name, recipients_email, senders_name, senders_email, messages) values (:orders_id, :orders_products_id, :gift_certificates_type, :amount, :gift_certificates_code, :recipients_name, :recipients_email, :senders_name, :senders_email, :messages)'); $Qgc->bindTable(':table_gift_certificates', TABLE_GIFT_CERTIFICATES); $Qgc->bindInt(':orders_id', $_REQUEST['orders_id']); $Qgc->bindInt(':gift_certificates_type', $gift_certificate_data['type']); $Qgc->bindInt(':orders_products_id', $orders_products_id); $Qgc->bindValue(':amount', $gift_certificate_data['price']); $Qgc->bindValue(':gift_certificates_code', toC_Gift_Certificates::createGiftCertificateCode()); $Qgc->bindValue(':recipients_name', $gift_certificate_data['recipients_name']); $Qgc->bindValue(':recipients_email', $gift_certificate_data['recipients_email']); $Qgc->bindValue(':senders_name', $gift_certificate_data['senders_name']); $Qgc->bindValue(':senders_email', $gift_certificate_data['senders_email']); $Qgc->bindValue(':messages', $gift_certificate_data['message']); $Qgc->setLogging($_SESSION['module'], $this->_order_id); $Qgc->execute(); if ($osC_Database->isError()) { $error = true; } } } } if ($error === false) { $this->_contents[$products_id_string] = array('id' => $products_id, 'orders_products_id' => $orders_products_id, 'quantity' => $quantity, 'name' => $osC_Product->getTitle(), 'sku' => $osC_Product->getSKU($variants_array), 'tax' => $osC_Tax->getTaxRate($osC_Product->getTaxClassID(), $this->_shipping_address['country_id'], $this->_shipping_address['zone_id']), 'price' => $product_price, 'final_price' => $products_price, 'weight' => $osC_Product->getWeight($variants), 'tax_class_id' => $osC_Product->getTaxClassID(), 'weight_class_id' => $osC_Product->getWeightClass()); } } osC_Product::updateStock($this->_order_id, $orders_products_id, $products_id, $quantity); if ($error === false) { $osC_Database->commitTransaction(); $this->_calculate(); $this->updateOrderTotal(); return true; } $osC_Database->rollbackTransaction(); return false; }
/** * Snychorize the wishlist data as the customer logged in * * @access public * @return boolean */ function synchronizeWithDatabase() { global $osC_Database, $osC_Services, $osC_Language, $osC_Customer, $osC_Image; if (!$osC_Customer->isLoggedOn()) { return false; } $Qcheck = $osC_Database->query('select wishlists_id, wishlists_token from :table_wishlists where customers_id = :customers_id'); $Qcheck->bindTable(':table_wishlists', TABLE_WISHLISTS); $Qcheck->bindInt(':customers_id', $osC_Customer->getID()); $Qcheck->execute(); if ($Qcheck->numberOfRows() > 0) { $this->_wishlists_id = $Qcheck->valueInt('wishlists_id'); $this->_token = $Qcheck->value('wishlists_token'); // reset per-session cart contents, but not the database contents $this->_contents = array(); $Qproducts = $osC_Database->query('select wishlists_products_id, products_id_string, date_added, comments from :table_wishlist_products where wishlists_id = :wishlists_id'); $Qproducts->bindTable(':table_wishlist_products', TABLE_WISHLISTS_PRODUCTS); $Qproducts->bindInt(':wishlists_id', $this->_wishlists_id); $Qproducts->execute(); while ($Qproducts->next()) { $products_id_string = $Qproducts->value('products_id_string'); $osC_Product = new osC_Product($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(osc_get_product_id($Qproducts->value('products_id')))) { $price = $new_price; } } //process the variants products in the wishlist if ($osC_Product->hasVariants()) { $variant_product = $this->_updateProduct($products_id_string, $osC_Product, $product_name, false); $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($Qproducts->value('date_added')), 'comments' => $Qproducts->value('comments')); } $Qproducts->freeResult(); } else { $token = $this->generateToken(); $Qupdate = $osC_Database->query('update :table_wishlists set customers_id = :customers_id, wishlists_token = :wishlists_token where wishlists_id = :wishlists_id'); $Qupdate->bindTable(':table_wishlists', TABLE_WISHLISTS); $Qupdate->bindInt(':customers_id', $osC_Customer->getID()); $Qupdate->bindValue(':wishlists_token', $token); $Qupdate->bindInt(':wishlists_id', $this->_wishlists_id); $Qupdate->execute(); $this->_token = $token; } }
function outputCompareProductsTable() { global $osC_Language, $osC_Image, $osC_Weight, $osC_Currencies, $osC_Services; $content = ''; $products_images = array(); $products_titles = array(); $products_price = array(); $products_weight = array(); $products_sku = array(); $products_manufacturers = array(); $products_desciptions = array(); $products_attributes = array(); $products_variants = array(); $cols = array('<col width="20%">'); $col_width = round(80 / count($this->getProducts())); if ($this->hasContents()) { foreach ($this->getProducts() as $products_id_string) { $cols[] = '<col width="' . $col_width . '%">'; $osC_Product = new osC_Product($products_id_string); $products_id = osc_get_product_id($products_id_string); $image = $osC_Product->getImages(); $product_title = $osC_Product->getTitle(); $product_price = $osC_Product->getPriceFormated(true); $product_weight = $osC_Product->getWeight(); $product_sku = $osC_Product->getSKU(); //if the product have any variants, it means that the $products_id should be a product string such as 1#1:1;2:2 $variants = array(); if ($osC_Product->hasVariants()) { $product_variants = $osC_Product->getVariants(); if (preg_match('/^[0-9]+(?:#?(?:[0-9]+:?[0-9]+)+(?:;?([0-9]+:?[0-9]+)+)*)+$/', $products_id_string)) { $products_variant = $product_variants[$products_id_string]; $variants = osc_parse_variants_from_id_string($products_id_string); } else { $products_variant = $osC_Product->getDefaultVariant(); $variants = $products_variant['groups_id']; } //if the product have any variants, get the group_name:value_name string if (isset($products_variant) && isset($products_variant['groups_name']) && is_array($products_variant['groups_name']) && !empty($products_variant['groups_name'])) { $products_variants[$products_id_string]['variants'] = array(); foreach ($products_variant['groups_name'] as $groups_name => $value_name) { $products_variants[$products_id_string]['variants'][] = array('name' => $groups_name, 'value' => $value_name); } } $product_price = $osC_Currencies->displayPrice($osC_Product->getPrice($variants), $osC_Product->getTaxClassID()); $product_weight = $products_variant['weight']; $product_sku = $products_variant['sku']; $image = $products_variant['image']; } $image = is_array($image) ? $image[0]['image'] : $image; $products_titles[] = $product_title; if (!osc_empty($product_price)) { $products_price[] = $product_price; } if (!osc_empty($product_weight)) { $products_weight[] = $osC_Weight->display($product_weight, $osC_Product->getWeightClass()); } if (!osc_empty($product_sku)) { $products_sku[] = $product_sku; } if (!osc_empty($osC_Product->getManufacturer())) { $products_manufacturers[] = $osC_Product->getManufacturer(); } if (!osc_empty($osC_Product->getDescription())) { $products_desciptions[] = $osC_Product->getDescription(); } if ($osC_Product->hasAttributes()) { foreach ($osC_Product->getAttributes() as $attribute) { $products_attributes[$products_id]['attributes'][] = array('name' => $attribute['name'], 'value' => $attribute['value']); } } $products_id_string = str_replace('#', '_', $products_id_string); //used to fix bug [#209 - Compare / wishlist variant problem] if (isset($osC_Services) && $osC_Services->isStarted('sefu') && count($variants) > 0) { $products_images[] = '<div class="image">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id), $osC_Image->show($image, $osC_Product->getTitle())) . '</div>' . '<div class="button">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id . '&pid=' . $products_id_string . '&action=cart_add'), osc_draw_image_button('button_in_cart.gif', $osC_Language->get('button_add_to_cart'))) . '</div>'; } else { $products_images[] = '<div class="image">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id), $osC_Image->show($image, $osC_Product->getTitle())) . '</div>' . '<div class="button">' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id_string . '&action=cart_add'), osc_draw_image_button('button_in_cart.gif', $osC_Language->get('button_add_to_cart'))) . '</div>'; } } $content .= '<table id="compareProducts" cellspacing="0" cellpadding="2" border="0">'; //add col groups $content .= '<colgroup>'; foreach ($cols as $col) { $content .= $col; } $content .= '</colgroup>'; //add product header $content .= '<tbody>'; $content .= '<tr class="first">'; $content .= '<th> </th>'; if (!osc_empty($products_images)) { foreach ($products_images as $k => $product_image) { $content .= '<td' . ($k == count($products_images) - 1 ? ' class="last"' : '') . '>' . $product_image . '</td>'; } } $content .= '</tr>'; $content .= '</tbody>'; //add compare details $content .= '<tbody>'; $row_class = 'even'; //add product name if (!osc_empty($products_titles)) { $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_name') . '</th>'; foreach ($products_titles as $k => $product_title) { $content .= '<td' . ($k == count($products_titles) - 1 ? ' class="last"' : '') . '>' . $product_title . '</td>'; } $content .= '</tr>'; $row_class = $row_class == 'even' ? 'odd' : 'even'; } //add product price if (!osc_empty($products_price)) { $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_price') . '</th>'; foreach ($products_price as $k => $product_price) { $content .= '<td' . ($k == count($products_price) - 1 ? ' class="last"' : '') . '>' . $product_price . '</td>'; } $content .= '</tr>'; $row_class = $row_class == 'even' ? 'odd' : 'even'; } //add product weight if (!osc_empty($products_weight)) { $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_weight') . '</th>'; foreach ($products_weight as $k => $product_weight) { $content .= '<td' . ($k == count($products_weight) - 1 ? ' class="last"' : '') . '>' . $product_weight . '</td>'; } $content .= '</tr>'; $row_class = $row_class == 'even' ? 'odd' : 'even'; } //add product sku if (!osc_empty($products_sku)) { $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_sku') . '</th>'; foreach ($products_sku as $k => $product_sku) { $content .= '<td' . ($k == count($products_sku) - 1 ? ' class="last"' : '') . '>' . $product_sku . '</td>'; } $content .= '</tr>'; $row_class = $row_class == 'even' ? 'odd' : 'even'; } //add product manufacturers if (!osc_empty($products_manufacturers)) { $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_manufacturer') . '</th>'; foreach ($products_manufacturers as $k => $product_manufacturer) { $content .= '<td' . ($k == count($products_manufacturers) - 1 ? ' class="last"' : '') . '>' . $product_manufacturer . '</td>'; } $content .= '</tr>'; $row_class = $row_class == 'even' ? 'odd' : 'even'; } //add product variants if (!osc_empty($products_variants)) { $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_variants') . '</th>'; foreach ($this->getProducts() as $k => $products_id_string) { if (isset($products_variants[$products_id_string]['variants']) && !osc_empty($products_variants[$products_id_string]['variants'])) { $content .= '<td' . ($k == count($this->getProducts()) - 1 ? ' class="last"' : '') . '>'; foreach ($products_variants[$products_id_string]['variants'] as $variant) { $content .= '<span class="variant">' . $variant['name'] . ': ' . $variant['value'] . '</span>'; } $content .= '</td>'; } } $content .= '</tr>'; $row_class = $row_class == 'even' ? 'odd' : 'even'; } //add product attributes if (!osc_empty($products_attributes)) { $content .= '<tr class="' . $row_class . '">' . '<th>' . $osC_Language->get('field_products_attributes') . '</th>'; foreach ($this->getProducts() as $k => $products_id_string) { if (isset($products_attributes[$products_id_string]['attributes']) && !osc_empty($products_attributes[$products_id_string]['attributes'])) { $content .= '<td' . ($k == count($this->getProducts()) - 1 ? ' class="last"' : '') . '>'; foreach ($products_attributes[$products_id_string]['attributes'] as $attribute) { $content .= '<span class="attribute">' . $attribute['name'] . ': ' . $attribute['value'] . '</span>'; } $content .= '</td>'; } } $content .= '</tr>'; $row_class = $row_class == 'even' ? 'odd' : 'even'; } //add product description if (!osc_empty($products_desciptions)) { $content .= '<tr class="' . $row_class . ' last">' . '<th>' . $osC_Language->get('field_products_description') . '</th>'; foreach ($products_desciptions as $k => $product_description) { $content .= '<td' . ($k == count($products_desciptions) - 1 ? ' class="last"' : '') . '>' . $product_description . '</td>'; } $content .= '</tr>'; $row_class = $row_class == 'even' ? 'odd' : 'even'; } $content .= '</tbody>'; $content .= '</table>'; } return $content; }