当前位置: 首页>>代码示例>>PHP>>正文


PHP osC_Product::hasVariants方法代码示例

本文整理汇总了PHP中osC_Product::hasVariants方法的典型用法代码示例。如果您正苦于以下问题:PHP osC_Product::hasVariants方法的具体用法?PHP osC_Product::hasVariants怎么用?PHP osC_Product::hasVariants使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在osC_Product的用法示例。


在下文中一共展示了osC_Product::hasVariants方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 function execute()
 {
     global $osC_Session, $osC_ShoppingCart, $osC_Product;
     if (!isset($osC_Product)) {
         $id = false;
         foreach ($_GET as $key => $value) {
             if ((is_numeric($key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && $key != $osC_Session->getName()) {
                 $id = $key;
             }
             break;
         }
         if ($id !== false && osC_Product::checkEntry($id)) {
             $osC_Product = new osC_Product($id);
         }
     }
     if (isset($osC_Product)) {
         if ($osC_Product->hasVariants()) {
             if (isset($_POST['variants']) && is_array($_POST['variants']) && !empty($_POST['variants'])) {
                 if ($osC_Product->variantExists($_POST['variants'])) {
                     $osC_ShoppingCart->add($osC_Product->getProductVariantID($_POST['variants']));
                 } else {
                     osc_redirect(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getKeyword()));
                     return false;
                 }
             } else {
                 osc_redirect(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getKeyword()));
                 return false;
             }
         } else {
             $osC_ShoppingCart->add($osC_Product->getID());
         }
     }
     osc_redirect(osc_href_link(FILENAME_CHECKOUT));
 }
开发者ID:heshuai64,项目名称:gamestore,代码行数:34,代码来源:cart_add.php

示例2: initialize

 function initialize()
 {
     global $osC_Language, $osC_Template, $toC_Compare_Products;
     if ($toC_Compare_Products->hasContents()) {
         $osC_Template->addStyleSheet('ext/multibox/multibox.css');
         $osC_Template->addJavascriptFilename('ext/multibox/Overlay.js');
         $osC_Template->addJavascriptFilename('ext/multibox/MultiBox.js');
         $this->_content = '<ul>';
         foreach ($toC_Compare_Products->getProducts() as $products_id) {
             $osC_Product = new osC_Product($products_id);
             $cid = $products_id;
             $str_variants = '';
             //if the product have any variants, it means that the $products_id should be a product string such as 1#1:1;2:2
             if ($osC_Product->hasVariants()) {
                 $variants = $osC_Product->getVariants();
                 if (preg_match('/^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)+$/', $products_id)) {
                     $products_variant = $variants[$products_id];
                 } else {
                     $products_variant = $osC_Product->getDefaultVariant();
                 }
                 //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'])) {
                     $str_variants .= ' -- ';
                     foreach ($products_variant['groups_name'] as $groups_name => $value_name) {
                         $str_variants .= '<strong>' . $groups_name . ': ' . $value_name . '</strong>;';
                     }
                     //clean the last ';'
                     if (($pos = strrpos($str_variants, ';')) !== false) {
                         $str_variants = substr($str_variants, 0, -1);
                     }
                 }
                 //build the product string that could be used
                 if (strpos($products_id, '#') !== false) {
                     $cid = str_replace('#', '_', $products_id);
                 }
             }
             $this->_content .= '<li>' . osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), 'cid=' . $cid . '&' . osc_get_all_get_params(array('cid', 'action')) . '&action=compare_products_remove'), osc_draw_image_button('button_delete_icon.png', $osC_Language->get('button_delete')), 'style="float: right; margin: 0 3px 1px 3px"') . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $products_id), $osC_Product->getTitle() . $str_variants) . '</li>';
         }
         $this->_content .= '</ul>';
         $this->_content .= '<p>' . '<span style="float: right">' . osc_link_object(osc_href_link(FILENAME_JSON, 'module=products&action=compare_products'), osc_draw_image_button('small_compare_now.png', $osC_Language->get('button_compare_now')), 'class="multibox" rel="ajax:true"') . '</span>' . osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), osc_get_all_get_params(array('action')) . '&action=compare_products_clear'), osc_draw_image_button('small_clear.png', $osC_Language->get('button_clear'))) . '&nbsp;&nbsp;' . '</p>';
         $js .= '<script type="text/javascript">
               window.addEvent("domready",function() {
                 
                 var box = new MultiBox(\'multibox\', { 
                     movieWidth: 820,
                     movieHeight: 600
                 });
               });
             </script>';
         $this->_content .= "\n" . $js;
     }
 }
开发者ID:4DvAnCeBoY,项目名称:tomatocart-shoppingcart,代码行数:52,代码来源:compare_products.php

示例3: execute

 function execute()
 {
     global $osC_Session, $osC_ShoppingCart, $osC_Product;
     if (!isset($osC_Product)) {
         $id = false;
         foreach ($_GET as $key => $value) {
             if ((ereg('^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && $key != $osC_Session->getName()) {
                 $id = $key;
             }
             break;
         }
         if ($id !== false && osC_Product::checkEntry($id)) {
             $osC_Product = new osC_Product($id);
         }
     }
     if (isset($osC_Product)) {
         $variants = null;
         if (isset($_POST['variants']) && is_array($_POST['variants'])) {
             $variants = $_POST['variants'];
         } else {
             if (isset($_GET['variants']) && !empty($_GET['variants'])) {
                 $variants = osc_parse_variants_string($_GET['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();
         }
         $quantity = null;
         if (isset($_POST['quantity']) && is_numeric($_POST['quantity'])) {
             $quantity = $_POST['quantity'];
         }
         if ($osC_Product->hasVariants() && empty($variants) || $osC_Product->isGiftCertificate() && $gift_certificate_data == null) {
             osc_redirect(osc_href_link(FILENAME_PRODUCTS, $osC_Product->getID()));
             return false;
         } else {
             $osC_ShoppingCart->add($osC_Product->getID(), $variants, $quantity, $gift_certificate_data);
         }
     }
     osc_redirect(osc_href_link(FILENAME_CHECKOUT));
 }
开发者ID:Doluci,项目名称:tomatocart,代码行数:49,代码来源:cart_add.php

示例4: add

 /**
  * Add a product or variant product into the wishlist
  * 
  * @access public
  * @param mixed products id or products id string including the variants such as 1#1:1;2:3
  * @return boolean
  */
 function add($products_id_string)
 {
     global $osC_Database, $osC_Services, $osC_Customer, $osC_Product;
     //flag to reprent the action performed or not
     $error = false;
     // if wishlist empty, create a new wishlist
     if (!$this->hasWishlistID()) {
         $token = $this->generateToken();
         $Qnew = $osC_Database->query('insert into :table_wishlists (customers_id, wishlists_token) values (:customers_id, :wishlists_token)');
         $Qnew->bindTable(':table_wishlists', TABLE_WISHLISTS);
         $Qnew->bindInt(':customers_id', $osC_Customer->getID());
         $Qnew->bindValue(':wishlists_token', $token);
         $Qnew->execute();
         $this->_wishlists_id = $osC_Database->nextID();
         $this->_token = $token;
         $Qnew->freeResult();
     }
     if (!isset($osC_Product)) {
         $osC_Product = new osC_Product($products_id_string);
     }
     if ($osC_Product->getID() > 0) {
         if (!$this->exists($products_id_string)) {
             $product_price = $osC_Product->getPrice();
             $product_name = $osC_Product->getTitle();
             $product_image = $osC_Product->getImage();
             if ($osC_Services->isStarted('specials')) {
                 global $osC_Specials;
                 if ($new_price = $osC_Specials->getPrice($products_id)) {
                     $price = $new_price;
                 }
             }
             // if the product has variants, set the image, price etc according to the variants
             if ($osC_Product->hasVariants()) {
                 $variant_product = $this->_updateProduct($products_id_string, $osC_Product, $product_name);
                 $product_name = $variant_product['name'];
                 $product_price = $variant_product['price'];
                 $product_image = $variant_product['image'];
             }
             $this->_contents[$products_id_string] = array('products_id_string' => $products_id_string, 'name' => $product_name, 'image' => $product_image, 'price' => $product_price, 'date_added' => osC_DateTime::getShort(osC_DateTime::getNow()), 'comments' => '');
             // insert into wishlist products only if there isn't the same product existing in the table
             $QnewCheck = $osC_Database->query('select * from :table_wishlist_products where products_id_string = :products_id_string limit 1');
             $QnewCheck->bindTable(':table_wishlist_products', TABLE_WISHLISTS_PRODUCTS);
             $QnewCheck->bindValue(':products_id_string', $products_id_string);
             $QnewCheck->execute();
             if ($QnewCheck->numberOfRows() < 1) {
                 $Qnew = $osC_Database->query('insert into :table_wishlist_products (wishlists_id, products_id_string, date_added, comments) values (:wishlists_id, :products_id_string, now(), :comments)');
                 $Qnew->bindTable(':table_wishlist_products', TABLE_WISHLISTS_PRODUCTS);
                 $Qnew->bindInt(':wishlists_id', $this->_wishlists_id);
                 $Qnew->bindValue(':products_id_string', $products_id_string);
                 $Qnew->bindValue(':comments', '');
                 $Qnew->execute();
                 $wishlists_products_id = $osC_Database->nextID();
             } else {
                 $wishlists_products_id = $QnewCheck->valueInt('wishlists_products_id');
             }
             $QnewCheck->freeResult();
         } else {
             $error = true;
         }
     }
     if ($error === true) {
         return false;
     }
     return true;
 }
开发者ID:ellipsonic,项目名称:tomato_app,代码行数:72,代码来源:wishlist.php

示例5: add

 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();
                 }
             }
         }
     }
 }
开发者ID:4DvAnCeBoY,项目名称:tomatocart-shoppingcart,代码行数:86,代码来源:wishlist.php

示例6: listChooseProducts

 function listChooseProducts()
 {
     global $toC_Json, $osC_Database, $osC_Language, $osC_Currencies, $osC_Tax;
     $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start'];
     $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit'];
     $Qproducts = $osC_Database->query('select SQL_CALC_FOUND_ROWS * from :table_products p left join :table_products_description pd on p.products_id = pd.products_id where p.products_status = 1 and pd.language_id = :language_id and p.products_status = 1');
     if (!empty($_REQUEST['search'])) {
         $Qproducts->appendQuery('and pd.products_name  like :products_name');
         $Qproducts->bindValue(':products_name', '%' . $_REQUEST['search'] . '%');
     }
     $Qproducts->appendQuery('order by p.products_id ');
     $Qproducts->bindTable(':table_products', TABLE_PRODUCTS);
     $Qproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
     $Qproducts->bindInt(':language_id', $osC_Language->getID());
     $Qproducts->setExtBatchLimit($start, $limit);
     $Qproducts->execute();
     $osC_Currencies = new osC_Currencies();
     $osC_Order = new osC_Order($_REQUEST['orders_id']);
     $osC_Tax = new osC_Tax_Admin();
     $_SESSION['currency'] = $osC_Order->getCurrency();
     $records = array();
     while ($Qproducts->next()) {
         $products_id = $Qproducts->valueInt('products_id');
         $osC_Product = new osC_Product($products_id, $osC_Order->getCustomer('customers_id'));
         if (!$osC_Product->hasVariants()) {
             $products_name = $osC_Product->getTitle();
             $products_price = $osC_Product->getPriceFormated();
             if ($osC_Product->isGiftCertificate()) {
                 $products_name .= '<table cellspacing="0" cellpadding="0" border="0">';
                 if ($osC_Product->isOpenAmountGiftCertificate()) {
                     $products_name .= '<tr><td><i>--&nbsp;&nbsp;' . $osC_Language->get('field_amount') . '</i></td><td><input id="' . $products_id . '_price' . '" type="text" class="x-form-text x-form-field x-form-empty-field" style="width: 140px" value="' . round($osC_Product->getOpenAmountMinValue() * $osC_Order->getCurrencyValue(), 2) . '"/></td></tr>';
                 }
                 if ($osC_Product->isEmailGiftCertificate()) {
                     $products_name .= '<tr><td><i>--&nbsp;&nbsp;' . $osC_Language->get('field_recipient_sender_name') . '</i></td><td><input id="' . $products_id . '_sender_name' . '" type="text" class="x-form-text x-form-field x-form-empty-field" style="width: 140px" /></td></tr>' . '<tr><td><i>--&nbsp;&nbsp;' . $osC_Language->get('field_recipient_sender_email') . '</i></td><td><input id="' . $products_id . '_sender_email' . '" type="text" class="x-form-text x-form-field x-form-empty-field" style="width: 140px" /></td></tr>' . '<tr><td><i>--&nbsp;&nbsp;' . $osC_Language->get('field_recipient_name') . '</i></td><td><input id="' . $products_id . '_recipient_name' . '" type="text" class="x-form-text x-form-field x-form-empty-field" style="width: 140px" /></td></tr>' . '<tr><td><i>--&nbsp;&nbsp;' . $osC_Language->get('field_recipient_email') . '</i></td><td><input id="' . $products_id . '_recipient_email' . '" type="text" class="x-form-text x-form-field x-form-empty-field" style="width: 140px" /></td></tr>' . '<tr><td><i>--&nbsp;&nbsp;' . $osC_Language->get('field_message') . '</i></td><td><textarea id="' . $products_id . '_message' . '" class=" x-form-textarea x-form-field" style="width: 140px" /></textarea></td></tr>';
                 } else {
                     if ($osC_Product->isPhysicalGiftCertificate()) {
                         $products_name .= '<tr><td><i>--&nbsp;&nbsp;' . $osC_Language->get('field_recipient_sender_name') . '</i></td><td><input id="' . $products_id . '_sender_name' . '" type="text" class="x-form-text x-form-field x-form-empty-field" style="width: 140px" /></td></tr>' . '<tr><td><i>--&nbsp;&nbsp;' . $osC_Language->get('field_recipient_name') . '</i></td><td><input id="' . $products_id . '_recipient_name' . '" type="text" class="x-form-text x-form-field x-form-empty-field" style="width: 140px" /></td></tr>' . '<tr><td><i>--&nbsp;&nbsp;' . $osC_Language->get('field_message') . '</i></td><td><textarea id="' . $products_id . '_message' . '" class=" x-form-textarea x-form-field" style="width: 140px" /></textarea></td></tr>';
                     }
                 }
                 $products_name .= '</table>';
             }
             $records[] = array('products_id' => $products_id, 'products_name' => $products_name, 'products_type' => $osC_Product->getProductType(), 'products_sku' => $osC_Product->getSKU(), 'products_price' => $products_price, 'products_quantity' => $osC_Product->getQuantity(), 'new_qty' => $Qproducts->valueInt('products_moq'), 'has_variants' => false);
         } else {
             $records[] = array('products_id' => $products_id, 'products_name' => $osC_Product->getTitle(), 'products_type' => $osC_Product->getProductType(), 'products_sku' => $osC_Product->getSKU(), 'products_price' => $osC_Product->getPriceFormated(), 'products_quantity' => $osC_Product->getQuantity(), 'new_qty' => $Qproducts->valueInt('products_moq'), 'has_variants' => true);
             foreach ($osC_Product->getVariants() as $product_id_string => $details) {
                 $variants = '';
                 foreach ($details['groups_name'] as $groups_name => $values_name) {
                     $variants .= '&nbsp;&nbsp;&nbsp;<i>' . $groups_name . ' : ' . $values_name . '</i><br />';
                 }
                 $records[] = array('products_id' => $product_id_string, 'products_name' => $variants, 'products_type' => $osC_Product->getProductType(), 'products_sku' => $osC_Product->getSKU(osc_parse_variants_from_id_string($product_id_string)), 'products_price' => $osC_Currencies->format($osC_Product->getPrice(osc_parse_variants_from_id_string($product_id_string)), $osC_Order->getCurrency()), 'products_quantity' => $details['quantity'], 'new_qty' => $Qproducts->valueInt('products_moq'), 'has_variants' => false);
             }
         }
     }
     unset($_SESSION['currency']);
     $response = array(EXT_JSON_READER_TOTAL => $Qproducts->getBatchSize(), EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
开发者ID:Doluci,项目名称:tomatocart,代码行数:57,代码来源:orders.php

示例7: foreach

 case 'PRODUCT_LIST_SKU':
     $lc_align = '';
     $lc_text = '&nbsp;' . $Qlisting->value('products_sku') . '&nbsp;';
     break;
 case 'PRODUCT_LIST_NAME':
     $lc_align = '';
     if (isset($_GET['manufacturers'])) {
         $lc_text = osc_link_object(osc_href_link(FILENAME_PRODUCTS, $Qlisting->value('products_id') . '&manufacturers=' . $_GET['manufacturers']), $Qlisting->value('products_name')) . ($Qlisting->value('products_short_description') === NULL || $Qlisting->value('products_short_description') === '' ? '' : '<p>' . $Qlisting->value('products_short_description') . '</p>');
         $lc_text .= osc_link_object(osc_href_link(FILENAME_PRODUCTS, $Qlisting->value('products_id') . '&manufacturers=' . $_GET['manufacturers']), $osC_Language->get('button_read_more'), 'class="readMore"');
     } else {
         $lc_text = '&nbsp;' . osc_link_object(osc_href_link(FILENAME_PRODUCTS, $Qlisting->value('products_id') . ($cPath ? '&cPath=' . $cPath : '')), $Qlisting->value('products_name')) . ($Qlisting->value('products_short_description') === NULL || $Qlisting->value('products_short_description') === '' ? '' : '<p>' . $Qlisting->value('products_short_description') . '</p>') . '&nbsp;';
         $lc_text .= osc_link_object(osc_href_link(FILENAME_PRODUCTS, $Qlisting->value('products_id') . ($cPath ? '&cPath=' . $cPath : '')), $osC_Language->get('button_read_more'), 'class="readMore"');
     }
     //variants options is enabled
     if ($variants_enabled) {
         if ($osC_Product->hasVariants()) {
             $lc_text .= '<ul class="options variants_' . $osC_Product->getID() . '">';
             $combobox_array = $osC_Product->getVariantsComboboxArray();
             foreach ($combobox_array as $groups_name => $combobox) {
                 $lc_text .= '<li class="variant">';
                 $lc_text .= '<label>' . $groups_name . ':</label>';
                 $lc_text .= $combobox;
                 $lc_text .= '</li>';
             }
             $lc_text .= '</ul>';
         }
     }
     break;
 case 'PRODUCT_LIST_MANUFACTURER':
     $lc_align = '';
     $lc_text = '&nbsp;' . osc_link_object(osc_href_link(FILENAME_DEFAULT, 'manufacturers=' . $Qlisting->valueInt('manufacturers_id')), $Qlisting->value('manufacturers_name')) . '&nbsp;';
开发者ID:sajad1441,项目名称:TomatoShop-v1,代码行数:31,代码来源:product_listing.php

示例8: outputCompareProductsTable

 function outputCompareProductsTable()
 {
     global $osC_Language, $osC_Image, $osC_Weight, $osC_Currencies;
     $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) {
             $cols[] = '<col width="' . $col_width . '%">';
             $osC_Product = new osC_Product($products_id);
             $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)) {
                     $products_variant = $product_variants[$products_id];
                     $variants = osc_parse_variants_from_id_string($products_id);
                 } 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]['variants'] = array();
                     foreach ($products_variant['groups_name'] as $groups_name => $value_name) {
                         $products_variants[$products_id]['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 = str_replace('#', '_', $products_id);
             $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 . '&action=cart_add' . (osc_empty(osc_parse_variants_array($variants)) ? '' : '&variants=' . osc_parse_variants_array($variants))), 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>&nbsp;</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>';
//.........这里部分代码省略.........
开发者ID:4DvAnCeBoY,项目名称:tomatocart-shoppingcart,代码行数:101,代码来源:compare_products.php

示例9: array

 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;
 }
开发者ID:Doluci,项目名称:tomatocart,代码行数:69,代码来源:ajax_shopping_cart.php

示例10: add


//.........这里部分代码省略.........
                 }
                 if (isset($this->_contents[$products_id_string]['customizations']) && !empty($this->_contents[$products_id_string]['customizations'])) {
                     $Qupdate->bindValue(':customizations', serialize($this->_contents[$products_id_string]['customizations']));
                 } else {
                     $Qupdate->bindRaw(':customizations', 'null');
                 }
                 $Qupdate->bindInt(':customers_id', $osC_Customer->getID());
                 $Qupdate->bindValue(':products_id', $products_id_string);
                 $Qupdate->execute();
             }
         } else {
             if (!is_numeric($quantity)) {
                 $quantity = 1;
             }
             if ($osC_Product->isGiftCertificate()) {
                 if ($quantity > 1) {
                     $quantity = 1;
                     $error = $osC_Language->get('error_gift_certificate_quantity_must_be_one');
                 }
             }
             //check minimum order quantity
             $products_moq = $osC_Product->getMOQ();
             if ($quantity < $products_moq) {
                 $quantity = $products_moq;
                 $error = sprintf($osC_Language->get('error_minimum_order_quantity'), $osC_Product->getTitle(), $products_moq);
             }
             //check order increment
             $increment = $osC_Product->getOrderIncrement();
             if (($quantity - $products_moq) % $increment != 0) {
                 $quantity = $products_moq + (floor(($quantity - $products_moq) / $increment) + 1) * $increment;
                 $error = sprintf($osC_Language->get('error_order_increment'), $osC_Product->getTitle(), $increment);
             }
             //if product has variants and variants is not given
             if ($osC_Product->hasVariants() && $variants == null) {
                 $variant = $osC_Product->getDefaultVariant();
                 $variants = osc_parse_variants_from_id_string($variant['product_id_string']);
             }
             if ($osC_Product->isGiftCertificate() && $osC_Product->isOpenAmountGiftCertificate()) {
                 $price = $gift_certificates_data['price'];
             } else {
                 $price = $osC_Product->getPrice($variants, $quantity);
                 if ($osC_Services->isStarted('specials')) {
                     global $osC_Specials;
                     if ($new_price = $osC_Specials->getPrice($products_id, $variants)) {
                         $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);
             if ($toC_Customization_Fields->exists($products_id)) {
                 $fields = $toC_Customization_Fields->get($products_id);
                 $time = time();
                 $this->_contents[$products_id_string]['customizations'][$time] = array('qty' => $quantity, 'fields' => array_values($fields));
                 $toC_Customization_Fields->remove($products_id);
             }
             //set error to session
             if (isset($error) && !empty($error)) {
                 $this->_contents[$products_id_string]['error'] = $error;
             }
             // insert into database
             if ($osC_Customer->isLoggedOn()) {
                 $Qnew = $osC_Database->query('insert into :table_customers_basket (customers_id, products_id, customers_basket_quantity, gift_certificates_data, customizations, customers_basket_date_added) values (:customers_id, :products_id, :customers_basket_quantity, :gift_certificates_data, :customizations, now())');
                 $Qnew->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET);
                 $Qnew->bindInt(':customers_id', $osC_Customer->getID());
                 $Qnew->bindValue(':products_id', $products_id_string);
                 $Qnew->bindInt(':customers_basket_quantity', $quantity);
开发者ID:Doluci,项目名称:tomatocart,代码行数:67,代码来源:shopping_cart.php

示例11: output_compare_products_table

function output_compare_products_table()
{
    global $osC_Language, $osC_Image, $osC_Weight, $osC_Currencies, $toC_Compare_Products, $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($toC_Compare_Products->getProducts()));
    if ($toC_Compare_Products->hasContents()) {
        foreach ($toC_Compare_Products->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'), '<i class="icon-shopping-cart icon-white"></i> ' . $osC_Language->get('button_add_to_cart'), 'class="btn btn-mini"') . '</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'), '<i class="icon-shopping-cart icon-white"></i> ' . $osC_Language->get('button_add_to_cart'), 'class="btn btn-mini"') . '</div>';
            }
        }
        $content .= '<table class="table table-hover table-striped">';
        //add col groups
        $content .= '<colgroup>';
        foreach ($cols as $col) {
            $content .= $col;
        }
        $content .= '</colgroup>';
        //add product header
        $content .= '<tbody>';
        $content .= '<tr class="first">';
        $content .= '<th>&nbsp;</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
//.........这里部分代码省略.........
开发者ID:seshna,项目名称:Tomatocart-Bootstrap,代码行数:101,代码来源:compare_products.php


注:本文中的osC_Product::hasVariants方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。