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


PHP osC_Product::hasSpecial方法代码示例

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


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

示例1: 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

示例2: add

 function add($products_id_string, $variants = null, $quantity = null, $gift_certificates_data = null, $customization_qty = null, $action = 'add')
 {
     global $osC_Database, $osC_Services, $osC_Language, $osC_Customer, $osC_Image, $toC_Wishlist, $toC_Customization_Fields, $osC_Specials;
     $products_id = osc_get_product_id($products_id_string);
     $osC_Product = new osC_Product($products_id);
     if ($osC_Product->isGiftCertificate()) {
         if ($variants == null || empty($variants)) {
             $products_id_string = $products_id . '#' . time();
         } else {
             $products_id_string = $products_id . '#' . $variants;
             //set variants to null
             $variants = null;
         }
     } else {
         $products_id_string = osc_get_product_id_string($products_id_string, $variants);
     }
     if ($osC_Product->getID() > 0) {
         if ($toC_Wishlist->hasProduct($products_id)) {
             $toC_Wishlist->deleteProduct($products_id);
         }
         if ($this->exists($products_id_string)) {
             $old_quantity = $this->getQuantity($products_id_string);
             if (!is_numeric($quantity)) {
                 $quantity = $this->getQuantity($products_id_string) + 1;
             } else {
                 if (is_numeric($quantity) && $quantity == 0) {
                     $this->remove($products_id_string);
                     return;
                 } else {
                     if ($action == 'add') {
                         $quantity = $this->getQuantity($products_id_string) + $quantity;
                     } else {
                         if ($action == 'update') {
                             $quantity = $quantity;
                             if (isset($customization_qty) && !empty($customization_qty)) {
                                 foreach ($customization_qty as $key => $value) {
                                     $this->_contents[$products_id_string]['customizations'][$key]['qty'] = $value;
                                 }
                             }
                         }
                     }
                 }
             }
             if ($osC_Product->isGiftCertificate()) {
                 if ($quantity > 1) {
                     $quantity = 1;
                     $error = $osC_Language->get('error_gift_certificate_quantity_must_be_one');
                 }
             }
             //check minimum order quantity
             $products_moq = $osC_Product->getMOQ();
             if ($quantity < $products_moq) {
                 $quantity = $products_moq;
                 $error = sprintf($osC_Language->get('error_minimum_order_quantity'), $osC_Product->getTitle(), $products_moq);
             }
             //check maximum order quantity
             $products_max_order_quantity = $osC_Product->getMaxOrderQuantity();
             if ($products_max_order_quantity > 0) {
                 if ($quantity > $products_max_order_quantity) {
                     $quantity = $products_max_order_quantity;
                     $error = sprintf($osC_Language->get('error_maximum_order_quantity'), $osC_Product->getTitle(), $products_max_order_quantity);
                 }
             }
             //check order increment
             $increment = $osC_Product->getOrderIncrement();
             if (($quantity - $products_moq) % $increment != 0) {
                 $quantity = $products_moq + (floor(($quantity - $products_moq) / $increment) + 1) * $increment;
                 $error = sprintf($osC_Language->get('error_order_increment'), $osC_Product->getTitle(), $increment);
             }
             //set error to session
             if (isset($error) && !empty($error)) {
                 $this->_contents[$products_id_string]['error'] = $error;
             }
             if ($osC_Product->isGiftCertificate() && $osC_Product->isOpenAmountGiftCertificate()) {
                 $price = $this->_contents[$products_id_string]['price'];
             } else {
                 $price = $osC_Product->getPrice($variants, $quantity);
                 if ($osC_Product->hasSpecial()) {
                     $special_price = $osC_Specials->getPrice($osC_Product->getID());
                     if ($osC_Product->hasVariants()) {
                         $special_percentage = $special_price / $osC_Product->getData('price');
                         $special_price = $price * $special_percentage;
                     }
                     $price = $special_price;
                 }
             }
             $this->_contents[$products_id_string]['quantity'] = $quantity;
             $this->_contents[$products_id_string]['price'] = $price;
             $this->_contents[$products_id_string]['final_price'] = $price;
             if ($toC_Customization_Fields->exists($products_id)) {
                 $fields = $toC_Customization_Fields->get($products_id);
                 $this->_contents[$products_id_string]['customizations'][time()] = array('qty' => $quantity - $old_quantity, 'fields' => array_values($fields));
                 $toC_Customization_Fields->remove($products_id);
             }
             // update database
             if ($osC_Customer->isLoggedOn()) {
                 $Qupdate = $osC_Database->query('update :table_customers_basket set customers_basket_quantity = :customers_basket_quantity, gift_certificates_data = :gift_certificates_data, customizations = :customizations where customers_id = :customers_id and products_id = :products_id');
                 $Qupdate->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET);
                 $Qupdate->bindInt(':customers_basket_quantity', $quantity);
                 if ($osC_Product->getProductType() == PRODUCT_TYPE_GIFT_CERTIFICATE) {
//.........这里部分代码省略.........
开发者ID:Doluci,项目名称:tomatocart,代码行数:101,代码来源:shopping_cart.php


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