當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ShopFunctions::convertWeightUnit方法代碼示例

本文整理匯總了PHP中ShopFunctions::convertWeightUnit方法的典型用法代碼示例。如果您正苦於以下問題:PHP ShopFunctions::convertWeightUnit方法的具體用法?PHP ShopFunctions::convertWeightUnit怎麽用?PHP ShopFunctions::convertWeightUnit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ShopFunctions的用法示例。


在下文中一共展示了ShopFunctions::convertWeightUnit方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: checkConditions

 /** TODO
  * Here can add check if user has filled in valid phone number or mail so he is reachable by zasilkovna
  */
 protected function checkConditions($cart, $method, $cart_prices)
 {
     $address = $cart->ST == 0 ? $cart->BT : $cart->ST;
     $is_cz = $this->isCz($address['virtuemart_country_id']);
     $is_sk = $this->isSk($address['virtuemart_country_id']);
     if (!$is_sk && !$is_cz) {
         return false;
     }
     $wstart = (double) $method->weight_start;
     $ws = (double) $method->weight_stop;
     $orderWeight = $this->getOrderWeight($cart, $method->weight_unit);
     if (!empty($wstart)) {
         if ($orderWeight < $wstart) {
             return false;
         }
     }
     // do not allow oversize packages
     if (!empty($ws)) {
         if (empty($method->strategy)) {
             if ($orderWeight > $ws) {
                 return false;
             }
         }
     }
     if (!empty($ws)) {
         if (!empty($method->strategy)) {
             if (count($cart->products) > 0) {
                 foreach ($cart->products as $product) {
                     $weight = ShopFunctions::convertWeightUnit($product->product_weight, $product->product_weight_uom, $method->weight_unit);
                     // single product weight is larger then x:
                     if ($weight > $ws) {
                         return false;
                     }
                 }
             }
         }
     }
     $total = (int) $cart->pricesUnformatted['billTotal'];
     if (!empty($method->orderamount_start)) {
         $st = (double) $method->orderamount_start;
         if ($total < $st) {
             return false;
         }
     }
     if (!empty($method->orderamount_stop)) {
         $st = (double) $method->orderamount_stop;
         if ($total < $st) {
             return false;
         }
     }
     return true;
 }
開發者ID:aldegtyarev,項目名稱:stelsvelo,代碼行數:55,代碼來源:ulozenka.php

示例2: getBasket

    public static function getBasket(&$ref, $OPCloader, $withwrapper = true, &$op_coupon = '', $shipping = '', $payment = '', $isexpress = false)
    {
        include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
        $has_k2 = OPCloader::tableExists('k2mart');
        if (!class_exists('ShopFunctions')) {
            require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
        }
        if (!method_exists('ShopFunctions', 'convertWeightUnit')) {
            $opc_show_weight = false;
        }
        /*
           if (!class_exists('VirtueMartModelProduct'))
         require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'product.php');
        */
        require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
        $productClass = OPCmini::getModel('product');
        //new VirtueMartModelProduct();
        if (!class_exists('CurrencyDisplay')) {
            require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
        }
        $currencyDisplay = CurrencyDisplay::getInstance($ref->cart->pricesCurrency);
        $google_html = '';
        $VM_LANG = new op_languageHelper();
        $product_rows = array();
        $p2 = $ref->cart->products;
        if (empty($ref->cart)) {
            $ref->cart = VirtueMartCart::getCart();
        }
        $vm2015 = false;
        $ref->cart->prices = $ref->cart->pricesUnformatted = OPCloader::getCheckoutPrices($ref->cart, false, $vm2015, 'opc');
        $useSSL = VmConfig::get('useSSL', 0);
        $action_url = $OPCloader->getActionUrl($OPCloader, true);
        $xi = 0;
        if (isset($currencyDisplay->_priceConfig)) {
            $savedConfig = $currencyDisplay->_priceConfig;
        }
        if (empty($product_price_display)) {
            $product_price_display = 'salesPrice';
        }
        //$test_product_price_display = array($product_price_display, 'salesPrice', 'basePrice', 'priceWithoutTax', 'basePriceWithTax', 'priceBeforeTax', 'costPrice');
        $test_product_price_display = array($product_price_display, 'salesPrice', 'basePrice', 'priceWithoutTax', 'basePriceWithTax', 'priceBeforeTax');
        // check price config
        $testf = false;
        foreach ($test_product_price_display as $product_price_display_test) {
            $test = $currencyDisplay->createPriceDiv($product_price_display, '', '10', false, false, 1);
            if (empty($test)) {
                if (isset($currencyDisplay->_priceConfig)) {
                    if (isset($currencyDisplay->_priceConfig[$product_price_display_test])) {
                        if (empty($currencyDisplay->_priceConfig[$product_price_display_test][0])) {
                            $currencyDisplay->_priceConfig[$product_price_display_test] = array(1, -1, 1);
                        }
                    }
                }
                $testf = true;
            } else {
                if (!isset($product_price_display_test2)) {
                    $product_price_display_test2 = $product_price_display_test;
                }
            }
        }
        if (empty($testf)) {
            $product_price_display = $product_price_display_test2;
        }
        $totalw = 0;
        $to_weight_unit = VmConfig::get('weight_unit_default', 'KG');
        foreach ($ref->cart->products as $pkey => $prow) {
            if ($opc_show_weight) {
                $totalw += ShopFunctions::convertWeightUnit((double) $prow->product_weight, $prow->product_weight_uom, $to_weight_unit) * (double) $prow->quantity;
            }
            $product = array();
            $id = $prow->virtuemart_media_id;
            if (empty($id)) {
                $imgf = '';
            } else {
                if (is_array($id)) {
                    $id = reset($id);
                }
                $imgf = $OPCloader->getImageFile($id);
            }
            $product['product_full_image'] = $imgf;
            if (!empty($opc_only_parent_links)) {
                if (!empty($prow->product_parent_id)) {
                    $parent = $prow->product_parent_id;
                    $prow->url = JRoute::_('index.php?option=com_virtuemart&virtuemart_product_id=' . $parent . '&view=productdetails', true);
                }
            }
            // check if k2 exists:
            if (!isset($prow->url)) {
                if (isset($prow->link)) {
                    $prow->url = $prow->link;
                    if (strpos($prow->url, '&amp;') === false) {
                        $prow->url = str_replace('&', '&amp;', $prow->url);
                    }
                } else {
                    $prow->url = JRoute::_('index.php?option=com_virtuemart&virtuemart_product_id=' . $prow->virtuemart_product_id . '&view=productdetails', true);
                }
            }
            if ($has_k2) {
                $db = JFactory::getDBO();
                $q = 'select baseID from #__k2mart where referenceID = ' . (int) $prow->virtuemart_product_id . ' limit 0,1';
//.........這裏部分代碼省略.........
開發者ID:aldegtyarev,項目名稱:stelsvelo,代碼行數:101,代碼來源:basket.php

示例3: getOrderWeight

 /**
  * Get the total weight for the order, based on which the proper shipping rate
  * can be selected.
  *
  * @param object $cart Cart object
  * @return float Total weight for the order
  */
 protected function getOrderWeight(VirtueMartCart $cart, $to_weight_unit)
 {
     static $weight = array();
     if (!isset($weight[$to_weight_unit])) {
         $weight[$to_weight_unit] = 0.0;
     }
     if (count($cart->products) > 0 and empty($weight[$to_weight_unit])) {
         foreach ($cart->products as $product) {
             $weight[$to_weight_unit] += ShopFunctions::convertWeightUnit($product->product_weight, $product->product_weight_uom, $to_weight_unit) * $product->quantity;
         }
     }
     return $weight[$to_weight_unit];
 }
開發者ID:naka211,項目名稱:studiekorrektur,代碼行數:20,代碼來源:vmpsplugin.php

示例4: getOrderWeight

 /**
  * Get the total weight for the order, based on which the proper shipping rate
  * can be selected.
  *
  * @param object $cart Cart object
  * @return float Total weight for the order
  * @author Oscar van Eijk
  */
 protected function getOrderWeight(VirtueMartCart $cart, $to_weight_unit)
 {
     static $weight = 0.0;
     if (count($cart->products) > 0 and empty($weight)) {
         foreach ($cart->products as $product) {
             vmdebug('getOrderWeight', $product->product_weight);
             $weight += ShopFunctions::convertWeightUnit($product->product_weight, $product->product_weight_uom, $to_weight_unit) * $product->quantity;
         }
     }
     return $weight;
 }
開發者ID:Arturogcalleja,項目名稱:herbolario,代碼行數:19,代碼來源:vmpsplugin.php


注:本文中的ShopFunctions::convertWeightUnit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。