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


PHP Currency::getSelectedCurrencyInstance方法代码示例

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


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

示例1: cartGetCartContent

/**
 * @return array
 */
function cartGetCartContent()
{
    $cart_content = array();
    $total_price = 0;
    $freight_cost = 0;
    $variants = '';
    $currencyEntry = Currency::getSelectedCurrencyInstance();
    $customerEntry = Customer::getAuthedInstance();
    if (!is_null($customerEntry)) {
        //get cart content from the database
        $q = db_phquery('
			SELECT t3.*, t1.itemID, t1.Quantity, t1.sample, t4.thumbnail FROM ?#SHOPPING_CARTS_TABLE t1
				LEFT JOIN ?#SHOPPING_CART_ITEMS_TABLE t2 ON t1.itemID=t2.itemID
				LEFT JOIN ?#PRODUCTS_TABLE t3 ON t2.productID=t3.productID
				LEFT JOIN ?#PRODUCT_PICTURES t4 ON t3.default_picture=t4.photoID
			WHERE customerID=?', $customerEntry->customerID);
        while ($cart_item = db_fetch_assoc($q)) {
            // get variants
            $variants = GetConfigurationByItemId($cart_item["itemID"]);
            LanguagesManager::ml_fillFields(PRODUCTS_TABLE, $cart_item);
            if (isset($cart_item["sample"]) && $cart_item["sample"] == 1) {
                $q_sample_price = db_phquery('SELECT sample_price FROM SC_categories WHERE categoryID=(SELECT categoryID FROM SC_products WHERE productID=?)', $cart_item["productID"]);
                $sample_price = db_fetch_assoc($q_sample_price);
                $costUC = $sample_price["sample_price"];
                $quantity = 1;
                $free_shipping = 1;
            } else {
                $costUC = GetPriceProductWithOption($variants, $cart_item["productID"]);
                $quantity = $cart_item["Quantity"];
                $free_shipping = $cart_item["free_shipping"];
            }
            $tmp = array("productID" => $cart_item["productID"], "slug" => $cart_item["slug"], "id" => $cart_item["itemID"], "name" => $cart_item["name"], 'thumbnail_url' => $cart_item['thumbnail'] && file_exists(DIR_PRODUCTS_PICTURES . '/' . $cart_item['thumbnail']) ? URL_PRODUCTS_PICTURES . '/' . $cart_item['thumbnail'] : '', "brief_description" => $cart_item["brief_description"], "quantity" => $quantity, "free_shipping" => $free_shipping, "costUC" => $costUC, "product_priceWithUnit" => show_price($costUC), "cost" => show_price($quantity * $costUC), "product_code" => $cart_item["product_code"]);
            if ($tmp['thumbnail_url']) {
                list($thumb_width, $thumb_height) = getimagesize(DIR_PRODUCTS_PICTURES . '/' . $cart_item['thumbnail']);
                list($tmp['thumbnail_width'], $tmp['thumbnail_height']) = shrink_size($thumb_width, $thumb_height, round(CONF_PRDPICT_THUMBNAIL_SIZE / 2), round(CONF_PRDPICT_THUMBNAIL_SIZE / 2));
            }
            $freight_cost += $cart_item["Quantity"] * $cart_item["shipping_freight"];
            $strOptions = GetStrOptions(GetConfigurationByItemId($tmp["id"]));
            if (trim($strOptions) != "") {
                $tmp["name"] .= "  (" . $strOptions . ")";
            }
            if (isset($cart_item["sample"]) && $cart_item["sample"] == 1) {
                $tmp["name"] .= " [SAMPLE]";
            }
            if ($cart_item["min_order_amount"] > $cart_item["Quantity"]) {
                $tmp["min_order_amount"] = $cart_item["min_order_amount"];
            }
            if ($cart_item["min_order_amount"] > 1 && $cart_item["Quantity"] % $cart_item["min_order_amount"] != 0) {
                $tmp["multiplicity"] = $cart_item["min_order_amount"];
            }
            if (isset($cart_item["sample"]) && $cart_item["sample"] == 1) {
                unset($tmp["min_order_amount"]);
                unset($tmp["multiplicity"]);
                $tmp["sample"] = 1;
            }
            $total_price += $quantity * $costUC;
            $cart_content[] = $tmp;
        }
    } else {
        //unauthorized user - get cart from session vars
        $total_price = 0;
        //total cart value
        $cart_content = array();
        //shopping cart items count
        if (isset($_SESSION["gids"])) {
            for ($j = 0; $j < count($_SESSION["gids"]); $j++) {
                if ($_SESSION["gids"][$j]) {
                    $session_items[] = CodeItemInClient($_SESSION["configurations"][$j], $_SESSION["gids"][$j]);
                    $q = db_phquery("SELECT t1.*, p1.thumbnail FROM ?#PRODUCTS_TABLE t1 LEFT JOIN ?#PRODUCT_PICTURES p1 ON t1.default_picture=p1.photoID WHERE t1.productID=?", $_SESSION["gids"][$j]);
                    if ($r = db_fetch_row($q)) {
                        LanguagesManager::ml_fillFields(PRODUCTS_TABLE, $r);
                        if (isset($_SESSION["sample"][$j]) && $_SESSION["sample"][$j] == 1) {
                            $q_sample_price = db_phquery('SELECT sample_price FROM SC_categories WHERE categoryID=(SELECT categoryID FROM SC_products WHERE productID=?)', $_SESSION["gids"][$j]);
                            $sample_price = db_fetch_assoc($q_sample_price);
                            $costUC = $sample_price["sample_price"];
                            $quantity = 1;
                            $free_shipping = 1;
                        } else {
                            $costUC = GetPriceProductWithOption($_SESSION["configurations"][$j], $_SESSION["gids"][$j]);
                            $quantity = $_SESSION["counts"][$j];
                            $free_shipping = $r["free_shipping"];
                        }
                        $id = $_SESSION["gids"][$j];
                        if (count($_SESSION["configurations"][$j]) > 0) {
                            for ($tmp1 = 0; $tmp1 < count($_SESSION["configurations"][$j]); $tmp1++) {
                                $id .= "_" . $_SESSION["configurations"][$j][$tmp1];
                            }
                        }
                        $tmp = array("productID" => $_SESSION["gids"][$j], "slug" => $r['slug'], "id" => $id, "name" => $r['name'], 'thumbnail_url' => $r['thumbnail'] && file_exists(DIR_PRODUCTS_PICTURES . '/' . $r['thumbnail']) ? URL_PRODUCTS_PICTURES . '/' . $r['thumbnail'] : '', "brief_description" => $r["brief_description"], "quantity" => $quantity, "free_shipping" => $free_shipping, "costUC" => $costUC, "product_priceWithUnit" => show_price($costUC), "cost" => show_price($costUC * $quantity));
                        if ($tmp['thumbnail_url']) {
                            list($thumb_width, $thumb_height) = getimagesize(DIR_PRODUCTS_PICTURES . '/' . $r['thumbnail']);
                            list($tmp['thumbnail_width'], $tmp['thumbnail_height']) = shrink_size($thumb_width, $thumb_height, round(CONF_PRDPICT_THUMBNAIL_SIZE / 2), round(CONF_PRDPICT_THUMBNAIL_SIZE / 2));
                        }
                        $strOptions = GetStrOptions($_SESSION["configurations"][$j]);
                        if (trim($strOptions) != "") {
                            $tmp["name"] .= "  (" . $strOptions . ")";
                        }
//.........这里部分代码省略.........
开发者ID:max-severin,项目名称:sample_products,代码行数:101,代码来源:cart_functions.php

示例2: error404page

     error404page();
     //RedirectSQ('?');
 } else {
     if (!isset($_GET["vote"])) {
         IncrementProductViewedTimes($productID);
     }
     $dontshowcategory = 1;
     $smarty->assign("main_content_template", "product_info.frame.html");
     $a = $product;
     $a["PriceWithUnit"] = show_price($a["Price"]);
     $a["map_priceWithUnit"] = show_price($a["map_price"]);
     $a["list_priceWithUnit"] = show_price($a["list_price"]);
     $q_sample_price = db_phquery('SELECT sample_price FROM SC_categories WHERE categoryID=(SELECT categoryID FROM SC_products WHERE productID=?)', $productID);
     $sample_price = db_fetch_assoc($q_sample_price);
     $a["sample_price"] = $sample_price["sample_price"];
     $currencyEntry = Currency::getSelectedCurrencyInstance();
     $a["price_incurr"] = $currencyEntry->convertUnits($a["Price"]);
     $a["list_price_incurr"] = $currencyEntry->convertUnits($a["list_price"]);
     if ((double) $a["shipping_freight"] > 0) {
         $a["shipping_freightUC"] = show_price($a["shipping_freight"]);
     }
     if (isset($_GET["picture_id"])) {
         $picture_row = db_phquery_fetch(DBRFETCH_ASSOC, "SELECT * FROM ?#PRODUCT_PICTURES WHERE photoID=?", $_GET["picture_id"]);
     } else {
         if (!is_null($a["default_picture"])) {
             $picture_row = db_phquery_fetch(DBRFETCH_ASSOC, 'SELECT * FROM ?#PRODUCT_PICTURES WHERE photoID=?', $a["default_picture"]);
         } else {
             $picture_row = db_phquery_fetch(DBRFETCH_ASSOC, 'SELECT * FROM ?#PRODUCT_PICTURES WHERE productID=? ORDER BY priority LIMIT 1', $productID);
             if (isset($picture_row["photoID"])) {
                 $a["default_picture"] = $picture_row["photoID"];
             } else {
开发者ID:max-severin,项目名称:sample_products,代码行数:31,代码来源:product_detailed.php

示例3: show_priceWithOutUnit

function show_priceWithOutUnit($price)
{
    $currencyEntry = Currency::getSelectedCurrencyInstance();
    return $currencyEntry->convertUnits($price, true);
}
开发者ID:max-severin,项目名称:sample_products,代码行数:5,代码来源:functions.php

示例4: main

 function main()
 {
     $Register =& Register::getInstance();
     $smarty =& $Register->get(VAR_SMARTY);
     /*@var $smarty Smarty*/
     // shopping cart
     //iframe cookie security workaround
     if (isset($_GET['check_cookie'])) {
         if ($_GET['check_cookie'] != session_id()) {
             $productID = (int) $_GET['productID'];
             $product_data = GetProduct($productID);
             $product_slug = $product_data && isset($product_data['slug']) ? $product_data['slug'] : '';
             $url = "?ukey=product_widget&productID={$productID}&product_slug={$product_slug}&check_cookie&";
             $widgets = false;
             $Register->set('widgets', $widgets);
             $_SERVER['REQUEST_URI'] = preg_replace('/(^|&)widgets=1/', '', $_SERVER['REQUEST_URI']);
             RedirectSQ($url);
         } else {
             renderURL('check_cookie&productID', '', true);
         }
     }
     if (isset($_GET["make_more_exact_cart_content"])) {
         $smarty->assign("make_more_exact_cart_content", 1);
     }
     if (isset($_GET["remove"]) && $_GET["remove"] > 0) {
         //remove from cart product with productID == $remove
         $cartEntry = new ShoppingCart();
         $cartEntry->loadCurrentCart();
         $cartEntry->setItemQuantity($_GET['remove'], 0);
         $cartEntry->saveCurrentCart();
         if ($cartEntry->isEmpty()) {
             //remove coupon from empty cart
             ClassManager::includeClass('discount_coupon');
             discount_coupon::remove();
         }
         RedirectSQ('remove=');
     }
     $cart_view = $this->_detect_cart_view();
     if (isset($_POST["update"]) || isset($_POST["recalculate"])) {
         //update shopping cart content
         if ($_POST['discount_coupon_code'] != '') {
             $this->_check_and_apply_coupon($_POST['discount_coupon_code']);
         }
         $cartEntry = new ShoppingCart();
         $cartEntry->loadCurrentCart();
         $upd_data = scanArrayKeysForID($_POST, 'count');
         foreach ($upd_data as $_itemID => $_data) {
             $cartEntry->setItemQuantity($_itemID, intval($_data['count']));
         }
         $cartEntry->saveCurrentCart();
         if ($cartEntry->isEmpty()) {
             //remove coupon from empty cart
             ClassManager::includeClass('discount_coupon');
             discount_coupon::remove();
         }
         if (cartCheckMinOrderAmount() && cartCheckMinTotalOrderAmount()) {
             switch ($cart_view) {
                 case CARTVIEW_FRAME:
                     if (isset($_POST['checkout']) && $Register->get('store_mode') == 'facebook') {
                         $store_mode = false;
                         $Register->set('store_mode', $store_mode);
                         $jsgoto = '?ukey=checkout&view=noframe';
                         RedirectSQ($jsgoto ? 'jsgoto=' . base64_encode(set_query($jsgoto)) : '');
                     }
                     RedirectSQ(isset($_POST['checkout']) ? '?ukey=checkout' : (isset($_POST['ppe_checkout_x']) ? 'ppexpresscheckout2=1' : (isset($_POST['google_checkout_x']) ? 'googlecheckout2=1' : '')));
                     break;
                 case CARTVIEW_WIDGET:
                 case CARTVIEW_FADE:
                     $jsgoto = isset($_POST['checkout']) ? '?ukey=checkout&view=noframe' : (isset($_POST['ppe_checkout_x']) ? 'ppexpresscheckout2=1&view=frame' : (isset($_POST['google_checkout_x']) ? 'googlecheckout2=1&view=frame' : ''));
                     RedirectSQ($jsgoto ? 'jsgoto=' . base64_encode(set_query($jsgoto)) : '');
                     break;
             }
         } elseif (isset($_POST['checkout']) || isset($_POST['google_checkout_x']) || isset($_POST['ppe_checkout_x'])) {
             $smarty->assign('cart_error_show', '1');
         }
     }
     if (isset($_GET["clear_cart"])) {
         //completely clear shopping cart
         $cartEntry = new ShoppingCart();
         $cartEntry->loadCurrentCart();
         $cartEntry->cleanCurrentCart('erase');
         //remove coupon from empty cart
         ClassManager::includeClass('discount_coupon');
         discount_coupon::remove();
         RedirectSQ('clear_cart=');
     }
     if (isset($_POST['checkout'])) {
         if (SystemSettings::is_hosted() && file_exists(WBS_DIR . '/kernel/classes/class.metric.php')) {
             include_once WBS_DIR . '/kernel/classes/class.metric.php';
             $DB_KEY = SystemSettings::get('DB_KEY');
             $U_ID = sc_getSessionData('U_ID');
             $metric = metric::getInstance();
             $metric->addAction($DB_KEY, $U_ID, 'SC', 'CHECKOUT', isset($_GET['widgets']) ? 'WIDGET' : 'STOREFRONT', '');
         }
     }
     $resCart = cartGetCartContent();
     $resDiscount = dscGetCartDiscounts($resCart["total_price"], isset($_SESSION["log"]) ? $_SESSION["log"] : "");
     $currencyEntry = Currency::getSelectedCurrencyInstance();
     $cart_discount_show = $resDiscount['other_discounts']['cu'] > 0 ? $currencyEntry->getView($resDiscount['other_discounts']['cu']) : '';
     $coupon_discount_show = $resDiscount['coupon_discount']['cu'] > 0 ? $currencyEntry->getView($resDiscount['coupon_discount']['cu']) : '';
//.........这里部分代码省略.........
开发者ID:max-severin,项目名称:sample_products,代码行数:101,代码来源:shopping_cart.php


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