コード例 #1
0
    public static function refreshCurrencies()
    {
        parent::refreshCurrencies();
        if (!($feed = Tools::simplexml_load_file(_GOINTERPAY_RATES_URL_ . Configuration::get('GOINTERPAY_MERCHANT_ID')))) {
            return Tools::displayError('Cannot parse Interpay feed.');
        }
        foreach ($feed->rateOffer as $currency) {
            if ($currency->buyCurrency != 'USD') {
                continue;
            }
            $currency_to_update_id = Currency::getIdByIsoCode($currency->sellCurrency);
            if ($currency_to_update_id) {
                $currency_to_update = new Currency((int) $currency_to_update_id);
                if (Validate::isLoadedObject($currency_to_update)) {
                    $currency_to_update->conversion_rate = (double) $currency->rate;
                    $currency_to_update->update();
                    Db::getInstance()->Execute('
					UPDATE ' . _DB_PREFIX_ . 'currency
					SET rateoffer_id = \'' . pSQL($currency->id) . '\', expiry = \'' . pSQL($currency->expiry) . '\'
					WHERE id_currency = ' . (int) $currency_to_update_id);
                }
            }
        }
        Configuration::updateValue('GOINTERPAY_CURRENCY_UPDATE', time());
    }
コード例 #2
0
ファイル: submit.php プロジェクト: priyankajsr19/indusdiva2
function displayConfirm()
{
    global $cookie, $smarty, $ppPayment, $cart;
    if (!$cookie->isLogged(true)) {
        header('location:../../../');
        exit;
        die('Not logged');
    }
    unset($cookie->paypal_token);
    /*if ($cart->id_currency != $ppPayment->getCurrency((int)$cart->id_currency)->id)
    	{
    		$cart->id_currency = (int)($ppPayment->getCurrency((int)$cart->id_currency)->id);
    		$cookie->id_currency = (int)($cart->id_currency);
    		$cart->update();
    		Tools::redirect('modules/'.$ppPayment->name.'/payment/submit.php');
    	}*/
    $smarty->assign('hide_header', 1);
    // Display all and exit
    include _PS_ROOT_DIR_ . '/header.php';
    $smarty->assign(array('logo' => $ppPayment->getLogo(), 'cust_currency' => $cart->id_currency, 'currency' => CurrencyCore::getCurrency($cart->id_currency), 'total' => $cart->getOrderTotal(true, Cart::BOTH), 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $ppPayment->name . '/', 'mode' => 'payment/'));
    echo $ppPayment->display('paypal.php', 'confirm.tpl');
    include _PS_ROOT_DIR_ . '/footer.php';
    die;
}
コード例 #3
0
    public function generateFiltersBlock($selectedFilters = array())
    {
        global $smarty, $link, $cookie;
        $id_lang = (int) $cookie->id_lang;
        $id_manufacturer = Tools::getValue('id_manufacturer', false);
        $new_products = Tools::getValue('latest', false);
        $sale_products = Tools::getValue('sale', false);
        $express_shipping = Tools::getValue('express_shipping', false);
        $cat_id = Tools::getValue('cat_id', false);
        /* If the current category isn't defined of if it's homepage, we have nothing to display */
        $id_parent = (int) Tools::getValue('id_category', Tools::getValue('id_category_layered', 1));
        if ($id_parent == 1 && !$this->search_query && !$id_manufacturer && !$new_products && !$sale_products && !$express_shipping && !$cat_id) {
            return;
        }
        $curr_currency = CurrencyCore::getCurrency($cookie->id_currency);
        /* First we need to get all subcategories of current category */
        $category = new Category((int) $id_parent);
        $selectedCategory = $category->getName($id_lang);
        //Set parent category if its a category navigation and current category is not the root
        if ($id_manufacturer || $this->search_query || $category->id_parent != 1) {
            $smarty->assign('parentID', $category->id_parent);
        }
        $subCategories = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
		SELECT c.id_category, c.id_parent, cl.name
		FROM ' . _DB_PREFIX_ . 'category c
		LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (cl.id_category = c.id_category)
		WHERE c.nleft > ' . (int) $category->nleft . ' and c.nright <= ' . (int) $category->nright . ' AND c.active = 1 AND c.id_parent = ' . (int) $category->id . ' AND cl.id_lang = ' . (int) $cookie->id_lang . '
		ORDER BY c.position, c.id_parent ASC');
        try {
            $resultSet = $this->getResults($id_parent, $this->search_query, $id_manufacturer, $selectedFilters);
        } catch (Exception $e) {
            return false;
        }
        $filterBlocks = array();
        //category filter block
        $filterBlocks[] = array('type' => 'category', 'name' => 'Categories', 'is_category' => true, 'values' => null);
        $filterBlocks[] = array('type' => 'pr', 'name' => 'Prices', 'is_category' => false, 'values' => null);
        $filterBlocks[] = array('type' => 'manufacturer', 'name' => 'Brands', 'is_category' => false, 'values' => null);
        $filterBlocks[] = array('type' => 'fabric', 'name' => 'Fabrics', 'is_category' => false, 'values' => null);
        $filterBlocks[] = array('type' => 'stone', 'name' => 'Stones', 'is_category' => false, 'values' => null);
        $filterBlocks[] = array('type' => 'plating', 'name' => 'Platings', 'is_category' => false, 'values' => null);
        $filterBlocks[] = array('type' => 'material', 'name' => 'Materials', 'is_category' => false, 'values' => null);
        $filterBlocks[] = array('type' => 'look', 'name' => 'Looks', 'is_category' => false, 'values' => null);
        $filterBlocks[] = array('type' => 'size', 'name' => 'Sizes', 'is_category' => false, 'values' => null);
        $filterBlocks[] = array('type' => 'customization', 'name' => 'Costomization', 'is_category' => false, 'values' => null);
        $filterBlocks[] = array('type' => 'color', 'name' => 'Colors', 'is_category' => false, 'values' => null);
        $filterBlocks[] = array('type' => 'handbag_occasion', 'name' => 'Occasions', 'is_category' => false, 'values' => null);
        $filterBlocks[] = array('type' => 'handbag_style', 'name' => 'Styles', 'is_category' => false, 'values' => null);
        $filterBlocks[] = array('type' => 'handbag_material', 'name' => 'Materials', 'is_category' => false, 'values' => null);
        $filterBlocks[] = array('type' => 'sla', 'name' => 'Shipped In', 'is_category' => false, 'values' => null);
        $selectedBrands = array();
        foreach ($selectedFilters['manufacturer'] as $selectedMan) {
            $selectedBrands[] = $selectedMan['id'];
        }
        $selectedPrices = array();
        foreach ($selectedFilters['pr'] as $selectedprice) {
            $selectedPrices[] = $selectedprice['id'];
        }
        $selectedColors = array();
        foreach ($selectedFilters['color'] as $selectedcolor) {
            $selectedColors[] = $selectedcolor['id'];
        }
        $selectedFabrics = array();
        foreach ($selectedFilters['fabric'] as $selectedfabric) {
            $selectedFabrics[] = $selectedfabric['id'];
        }
        $selectedStones = array();
        foreach ($selectedFilters['stone'] as $selectedstone) {
            $selectedStones[] = $selectedstone['id'];
        }
        $selectedPlatings = array();
        foreach ($selectedFilters['plating'] as $selectedplating) {
            $selectedPlatings[] = $selectedplating['id'];
        }
        $selectedMaterials = array();
        foreach ($selectedFilters['material'] as $selectedmaterial) {
            $selectedMaterials[] = $selectedmaterial['id'];
        }
        $selectedLooks = array();
        foreach ($selectedFilters['look'] as $selectedlook) {
            $selectedLooks[] = $selectedlook['id'];
        }
        $selectedSizes = array();
        foreach ($selectedFilters['size'] as $selectedsize) {
            $selectedSizes[] = $selectedsize['id'];
        }
        $selectedcustomizationTypes = array();
        foreach ($selectedFilters['customization'] as $selectedcustomizationType) {
            $selectedcustomizationTypes[] = $selectedcustomizationType['id'];
        }
        $selectedHandbagOcassions = array();
        foreach ($selectedFilters['handbag_occasion'] as $selectedhandbag_occasion) {
            $selectedHandbagOccasions[] = $selectedhandbag_occasion['id'];
        }
        $selectedHandbagStyles = array();
        foreach ($selectedFilters['handbag_style'] as $selectedhandbag_style) {
            $selectedHandbagStyles[] = $selectedhandbag_style['id'];
        }
        $selectedHandbagMaterials = array();
        foreach ($selectedFilters['handbag_material'] as $selectedhandbag_material) {
            $selectedHandbagMaterials[] = $selectedhandbag_material['id'];
        }
        $selectedSlas = array();
        foreach ($selectedFilters['sla'] as $selectedsla) {
            $selectedSlas[] = $selectedsla['id'];
        }
        foreach ($filterBlocks as &$filterBlock) {
            if ($filterBlock['type'] == 'category') {
                $c = array();
                foreach ($subCategories as $subCat) {
                    $c[] = (int) $subCat['id_category'];
                    $filterBlock['values'][(int) $subCat['id_category']]['name'] = $subCat['name'];
                    //init the number of product in this category
                    if (!isset($filterBlock['values'][(int) $subCat['id_category']]['nbr'])) {
                        $filterBlock['values'][(int) $subCat['id_category']]['nbr'] = 0;
                    }
                }
                //get cat numers form facet field
                $catFacet = $resultSet->getFacetSet()->getFacet('cat_id');
                $catCounts = $catFacet->getValues();
                //count nbr product in category
                foreach ($c as $idSubCategory) {
                    $filterBlock['values'][(int) $idSubCategory]['nbr'] = $catCounts[(int) $idSubCategory];
                }
            } elseif ($filterBlock['type'] == 'manufacturer') {
                $filterBlock['name'] = $this->l('Brands');
                $man = array();
                if ($manFacet = $resultSet->getFacetSet()->getFacet('brand_id')) {
                    $manCounts = $manFacet->getValues();
                    foreach ($manCounts as $manID => $manCount) {
                        $manName = Manufacturer::getNameById($manID);
                        $filterBlock['values'][(int) $manID]['name'] = $manName;
                        $filterBlock['values'][(int) $manID]['nbr'] = $manCount;
                        if (isset($selectedFilters['manufacturer']) and in_array($manID, $selectedBrands)) {
                            $filterBlock['values'][(int) $manID]['checked'] = true;
                        }
                    }
                }
            } elseif ($filterBlock['type'] == 'pr') {
                $priceFacet = $resultSet->getFacetSet()->getFacet('priceranges');
                $priceCounts = $priceFacet->getValues();
                $prCounts = array(1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0);
                foreach ($priceCounts as $priceRange => $priceCount) {
                    if ($cookie->id_currency == 4) {
                        $rangeStart = floatval($priceRange);
                        if ($rangeStart >= 0.0 && $rangeStart < 1000.0) {
                            $prCounts[1] += $priceCount;
                        } elseif ($rangeStart >= 1000.0 && $rangeStart < 2500.0) {
                            $prCounts[2] += $priceCount;
                        } elseif ($rangeStart >= 2500.0 && $rangeStart < 5000.0) {
                            $prCounts[3] += $priceCount;
                        } elseif ($rangeStart >= 5000.0 && $rangeStart < 10000.0) {
                            $prCounts[4] += $priceCount;
                        }
                    } else {
                        $conversion_rate = $curr_currency['conversion_rate'];
                        $rangeStart = floatval($priceRange);
                        if ($rangeStart >= 0.0 && $rangeStart < Tools::ps_round(50 / $conversion_rate)) {
                            $prCounts[1] += $priceCount;
                        } elseif ($rangeStart >= Tools::ps_round(50 / $conversion_rate) && $rangeStart < Tools::ps_round(100 / $conversion_rate)) {
                            $prCounts[2] += $priceCount;
                        } elseif ($rangeStart >= Tools::ps_round(100 / $conversion_rate) && $rangeStart < Tools::ps_round(150 / $conversion_rate)) {
                            $prCounts[3] += $priceCount;
                        } elseif ($rangeStart >= Tools::ps_round(150 / $conversion_rate) && $rangeStart < Tools::ps_round(200 / $conversion_rate)) {
                            $prCounts[4] += $priceCount;
                        }
                    }
                }
                $prCounts[5] = $priceFacet->getAfter();
                if ($cookie->id_currency == 4) {
                    $filterBlock['values'][1]['name'] = '< Rs. 1000';
                    $filterBlock['values'][1]['nbr'] = $prCounts[1];
                    if (isset($selectedFilters['pr']) and in_array(1, $selectedPrices)) {
                        $filterBlock['values'][1]['checked'] = true;
                    }
                    $filterBlock['values'][2]['name'] = 'Rs. 1000 - Rs. 2500';
                    $filterBlock['values'][2]['nbr'] = $prCounts[2];
                    if (isset($selectedFilters['pr']) and in_array(2, $selectedPrices)) {
                        $filterBlock['values'][2]['checked'] = true;
                    }
                    $filterBlock['values'][3]['name'] = 'Rs. 2500 - Rs. 5000';
                    $filterBlock['values'][3]['nbr'] = $prCounts[3];
                    if (isset($selectedFilters['pr']) and in_array(3, $selectedPrices)) {
                        $filterBlock['values'][3]['checked'] = true;
                    }
                    $filterBlock['values'][4]['name'] = 'Rs. 5000 - Rs. 10000';
                    $filterBlock['values'][4]['nbr'] = $prCounts[4];
                    if (isset($selectedFilters['pr']) and in_array(4, $selectedPrices)) {
                        $filterBlock['values'][4]['checked'] = true;
                    }
                    $filterBlock['values'][5]['name'] = '> Rs. 10000';
                    $filterBlock['values'][5]['nbr'] = $prCounts[5];
                    if (isset($selectedFilters['pr']) and in_array(5, $selectedPrices)) {
                        $filterBlock['values'][5]['checked'] = true;
                    }
                } else {
                    $sign = $curr_currency['sign'];
                    $filterBlock['values'][1]['name'] = '< ' . $sign . ' 50';
                    $filterBlock['values'][1]['nbr'] = $prCounts[1];
                    if (isset($selectedFilters['pr']) and in_array(1, $selectedPrices)) {
                        $filterBlock['values'][1]['checked'] = true;
                    }
                    $filterBlock['values'][2]['name'] = '' . $sign . ' 50 - ' . $sign . ' 100';
                    $filterBlock['values'][2]['nbr'] = $prCounts[2];
                    if (isset($selectedFilters['pr']) and in_array(2, $selectedPrices)) {
                        $filterBlock['values'][2]['checked'] = true;
                    }
                    $filterBlock['values'][3]['name'] = '' . $sign . ' 100 - ' . $sign . ' 150';
                    $filterBlock['values'][3]['nbr'] = $prCounts[3];
                    if (isset($selectedFilters['pr']) and in_array(3, $selectedPrices)) {
                        $filterBlock['values'][3]['checked'] = true;
                    }
                    $filterBlock['values'][4]['name'] = '' . $sign . ' 150 - ' . $sign . ' 200';
                    $filterBlock['values'][4]['nbr'] = $prCounts[4];
                    if (isset($selectedFilters['pr']) and in_array(4, $selectedPrices)) {
                        $filterBlock['values'][4]['checked'] = true;
                    }
                    $filterBlock['values'][5]['name'] = '> ' . $sign . ' 200';
                    $filterBlock['values'][5]['nbr'] = $prCounts[5];
                    if (isset($selectedFilters['pr']) and in_array(5, $selectedPrices)) {
                        $filterBlock['values'][5]['checked'] = true;
                    }
                }
            } elseif ($filterBlock['type'] == 'fabric') {
                $filterBlock['name'] = $this->l('Fabrics');
                if ($fabricFacet = $resultSet->getFacetSet()->getFacet('fabric')) {
                    $fabricCounts = $fabricFacet->getValues();
                    foreach ($fabricCounts as $fabricID => $manCount) {
                        if ($fabricID != '') {
                            $filterBlock['values'][$fabricID]['name'] = ucwords(str_replace("-", " ", $fabricID));
                            $filterBlock['values'][$fabricID]['nbr'] = $manCount;
                            if (isset($selectedFilters['fabric']) and in_array($fabricID, $selectedFabrics)) {
                                $filterBlock['values'][$fabricID]['checked'] = true;
                            }
                        }
                    }
                }
            } elseif ($filterBlock['type'] == 'stone') {
                $filterBlock['name'] = 'Stones';
                if ($stoneFacet = $resultSet->getFacetSet()->getFacet('stone')) {
                    $stoneCounts = $stoneFacet->getValues();
                    foreach ($stoneCounts as $stoneID => $manCount) {
                        if ($stoneID != '') {
                            $filterBlock['values'][$stoneID]['name'] = ucwords(str_replace("-", " ", $stoneID));
                            $filterBlock['values'][$stoneID]['nbr'] = $manCount;
                            if (isset($selectedFilters['stone']) and in_array($stoneID, $selectedStones)) {
                                $filterBlock['values'][$stoneID]['checked'] = true;
                            }
                        }
                    }
                }
            } elseif ($filterBlock['type'] == 'plating') {
                $filterBlock['name'] = 'Platings';
                if ($platingFacet = $resultSet->getFacetSet()->getFacet('plating')) {
                    $platingCounts = $platingFacet->getValues();
                    foreach ($platingCounts as $platingID => $manCount) {
                        if ($platingID != '') {
                            $filterBlock['values'][$platingID]['name'] = ucwords(str_replace("-", " ", $platingID));
                            $filterBlock['values'][$platingID]['nbr'] = $manCount;
                            if (isset($selectedFilters['plating']) and in_array($platingID, $selectedPlatings)) {
                                $filterBlock['values'][$platingID]['checked'] = true;
                            }
                        }
                    }
                }
            } elseif ($filterBlock['type'] == 'material') {
                $filterBlock['name'] = 'Materials';
                if ($materialFacet = $resultSet->getFacetSet()->getFacet('material')) {
                    $materialCounts = $materialFacet->getValues();
                    foreach ($materialCounts as $materialID => $manCount) {
                        if ($materialID != '') {
                            $filterBlock['values'][$materialID]['name'] = ucwords(str_replace("-", " ", $materialID));
                            $filterBlock['values'][$materialID]['nbr'] = $manCount;
                            if (isset($selectedFilters['material']) and in_array($materialID, $selectedMaterials)) {
                                $filterBlock['values'][$materialID]['checked'] = true;
                            }
                        }
                    }
                }
            } elseif ($filterBlock['type'] == 'look') {
                $filterBlock['name'] = $this->l('Looks');
                if ($lookFacet = $resultSet->getFacetSet()->getFacet('look')) {
                    $lookCounts = $lookFacet->getValues();
                    foreach ($lookCounts as $lookID => $manCount) {
                        if ($lookID != '') {
                            $filterBlock['values'][$lookID]['name'] = ucwords(str_replace("-", " ", $lookID));
                            $filterBlock['values'][$lookID]['nbr'] = $manCount;
                            if (isset($selectedFilters['look']) and in_array($lookID, $selectedLooks)) {
                                $filterBlock['values'][$lookID]['checked'] = true;
                            }
                        }
                    }
                }
            } elseif ($filterBlock['type'] == 'size') {
                $filterBlock['name'] = $this->l('Sizes');
                if ($sizeFacet = $resultSet->getFacetSet()->getFacet('size')) {
                    $sizeCounts = $sizeFacet->getValues();
                    foreach ($sizeCounts as $sizeID => $sizeCount) {
                        $filterBlock['values'][$sizeID]['name'] = ucwords($sizeID);
                        $filterBlock['values'][$sizeID]['nbr'] = $sizeCount;
                        if (isset($selectedFilters['size']) and in_array($sizeID, $selectedSizes)) {
                            $filterBlock['values'][$sizeID]['checked'] = true;
                        }
                    }
                }
            } elseif ($filterBlock['type'] == 'customization') {
                $filterBlock['name'] = $this->l('Customization');
                if ($custFacet = $resultSet->getFacetSet()->getFacet('is_customizable')) {
                    $custCounts = $custFacet->getValues();
                    if (count($custCounts) > 1) {
                        foreach ($custCounts as $custType => $custCount) {
                            $filterBlock['values'][$custType]['name'] = $custType == 0 ? "Ready to wear" : "Customizable";
                            $filterBlock['values'][$custType]['nbr'] = $custCount;
                            if (isset($selectedFilters['customization']) and in_array($custType, $selectedcustomizationTypes)) {
                                $filterBlock['values'][$custType]['checked'] = true;
                            }
                        }
                    }
                }
            } elseif ($filterBlock['type'] == 'color') {
                $filterBlock['name'] = $this->l('Colors');
                if ($colorFacet = $resultSet->getFacetSet()->getFacet('color')) {
                    $colorCounts = $colorFacet->getValues();
                    foreach ($colorCounts as $colorID => $colorCount) {
                        $filterBlock['values'][$colorID]['name'] = ucwords(str_replace("-", " ", $colorID));
                        $filterBlock['values'][$colorID]['nbr'] = $colorCount;
                        if (isset($selectedFilters['color']) and in_array($colorID, $selectedColors)) {
                            $filterBlock['values'][$colorID]['checked'] = true;
                        }
                    }
                }
            } elseif ($filterBlock['type'] == 'handbag_occasion') {
                $filterBlock['name'] = 'Occasions';
                if ($handbag_occasionFacet = $resultSet->getFacetSet()->getFacet('handbag_occasion')) {
                    $handbag_occasionCounts = $handbag_occasionFacet->getValues();
                    foreach ($handbag_occasionCounts as $handbag_occasionID => $manCount) {
                        if ($handbag_occasionID != '') {
                            $filterBlock['values'][$handbag_occasionID]['name'] = ucwords(str_replace("-", " ", $handbag_occasionID));
                            $filterBlock['values'][$handbag_occasionID]['nbr'] = $manCount;
                            if (isset($selectedFilters['handbag_occasion']) and in_array($handbag_occasionID, $selectedHandbagOcassions)) {
                                $filterBlock['values'][$handbag_occasionID]['checked'] = true;
                            }
                        }
                    }
                }
            } elseif ($filterBlock['type'] == 'handbag_style') {
                $filterBlock['name'] = 'Styles';
                if ($handbag_styleFacet = $resultSet->getFacetSet()->getFacet('handbag_style')) {
                    $handbag_styleCounts = $handbag_styleFacet->getValues();
                    foreach ($handbag_styleCounts as $handbag_styleID => $manCount) {
                        if ($handbag_styleID != '') {
                            $filterBlock['values'][$handbag_styleID]['name'] = ucwords(str_replace("-", " ", $handbag_styleID));
                            $filterBlock['values'][$handbag_styleID]['nbr'] = $manCount;
                            if (isset($selectedFilters['handbag_style']) and in_array($handbag_styleID, $selectedHandbagStyles)) {
                                $filterBlock['values'][$handbag_styleID]['checked'] = true;
                            }
                        }
                    }
                }
            } elseif ($filterBlock['type'] == 'handbag_material') {
                $filterBlock['name'] = 'Materials';
                if ($handbag_materialFacet = $resultSet->getFacetSet()->getFacet('handbag_material')) {
                    $handbag_materialCounts = $handbag_materialFacet->getValues();
                    foreach ($handbag_materialCounts as $handbag_materialID => $manCount) {
                        if ($handbag_materialID != '') {
                            $filterBlock['values'][$handbag_materialID]['name'] = ucwords(str_replace("-", " ", $handbag_materialID));
                            $filterBlock['values'][$handbag_materialID]['nbr'] = $manCount;
                            if (isset($selectedFilters['handbag_material']) and in_array($handbag_materialID, $selectedHandbagMaterials)) {
                                $filterBlock['values'][$handbag_materialID]['checked'] = true;
                            }
                        }
                    }
                }
            } elseif ($filterBlock['type'] == 'sla') {
                $slaFacet = $resultSet->getFacetSet()->getFacet('slaranges');
                $slaCounts = $slaFacet->getValues();
                $sCounts = array(1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0);
                foreach ($slaCounts as $slaRange => $slaCount) {
                    $rangeStart = intval($slaRange);
                    if ($rangeStart >= 0 && $rangeStart < 5) {
                        $sCounts[1] += $slaCount;
                    } elseif ($rangeStart >= 5 && $rangeStart < 10) {
                        $sCounts[2] += $slaCount;
                    } elseif ($rangeStart >= 10 && $rangeStart < 15) {
                        $sCounts[3] += $slaCount;
                    } elseif ($rangeStart >= 15 && $rangeStart < 20) {
                        $sCounts[4] += $slaCount;
                    }
                }
                $sCounts[5] = $slaFacet->getAfter();
                $filterBlock['values'][1]['name'] = '< 5 days';
                $filterBlock['values'][1]['nbr'] = $sCounts[1];
                if (isset($selectedFilters['sla']) and in_array(1, $selectedSlas)) {
                    $filterBlock['values'][1]['checked'] = true;
                }
                $filterBlock['values'][2]['name'] = '5-10 days';
                $filterBlock['values'][2]['nbr'] = $sCounts[2];
                if (isset($selectedFilters['sla']) and in_array(2, $selectedSlas)) {
                    $filterBlock['values'][2]['checked'] = true;
                }
                $filterBlock['values'][3]['name'] = '10-15 days';
                $filterBlock['values'][3]['nbr'] = $sCounts[3];
                if (isset($selectedFilters['sla']) and in_array(3, $selectedSlas)) {
                    $filterBlock['values'][3]['checked'] = true;
                }
                $filterBlock['values'][4]['name'] = '15-20 days';
                $filterBlock['values'][4]['nbr'] = $sCounts[4];
                if (isset($selectedFilters['sla']) and in_array(4, $selectedSlas)) {
                    $filterBlock['values'][4]['checked'] = true;
                }
                $filterBlock['values'][5]['name'] = '> 20 days';
                $filterBlock['values'][5]['nbr'] = $sCounts[5];
                if (isset($selectedFilters['sla']) and in_array(5, $selectedSlas)) {
                    $filterBlock['values'][5]['checked'] = true;
                }
            }
        }
        $nFilters = 0;
        foreach ($selectedFilters as $filters) {
            $nFilters += sizeof($filters);
        }
        $displayFilters = array();
        //echo var_dump($filterBlocks);exit;
        foreach ($filterBlocks as $filterblock) {
            if ($filterblock['type'] == 'customization') {
                $displayFilters[0] = $filterblock;
            }
            if ($filterblock['type'] == 'size') {
                $displayFilters[1] = $filterblock;
            }
            if ($filterblock['type'] == 'category') {
                $displayFilters[2] = $filterblock;
            }
            if ($filterblock['type'] == 'pr') {
                $displayFilters[3] = $filterblock;
            }
            if ($filterblock['type'] == 'sla') {
                $displayFilters[4] = $filterblock;
            }
            if ($filterblock['type'] == 'fabric') {
                $displayFilters[5] = $filterblock;
            }
            if ($filterblock['type'] == 'color') {
                $displayFilters[6] = $filterblock;
            }
            if ($filterblock['type'] == 'stone') {
                $displayFilters[7] = $filterblock;
            }
            if ($filterblock['type'] == 'plating') {
                $displayFilters[8] = $filterblock;
            }
            if ($filterblock['type'] == 'material') {
                $displayFilters[9] = $filterblock;
            }
            if ($filterblock['type'] == 'look') {
                $displayFilters[10] = $filterblock;
            }
            if ($filterblock['type'] == 'handbag_occasion') {
                $displayFilters[11] = $filterblock;
            }
            if ($filterblock['type'] == 'handbag_style') {
                $displayFilters[12] = $filterblock;
            }
            if ($filterblock['type'] == 'handbag_material') {
                $displayFilters[13] = $filterblock;
            }
            //if ($filterblock['type'] == 'manufacturer') $displayFilters[2] = $filterblock;
        }
        ksort($displayFilters);
        //echo var_dump($displayFilters);
        if ($id_manufacturer) {
            $smarty->assign('brand', $id_manufacturer);
        }
        if ($new_products) {
            $smarty->assign('latest', 1);
        } else {
            $smarty->assign('latest', 0);
        }
        if ($sale_products) {
            $smarty->assign('sale', 1);
        } else {
            $smarty->assign('sale', 0);
        }
        if ($express_shipping) {
            $smarty->assign('express_shipping', 1);
        } else {
            $smarty->assign('express_shipping', 0);
        }
        if ($cat_id) {
            $smarty->assign('cat_id', $cat_id);
        } else {
            $smarty->assign('cat_id', 0);
        }
        if ($id_manufacturer || $this->search_query || $category->id_parent != 1 || $new_products || $sale_products || $express_shipping || $cat_id) {
            $smarty->assign('isCategoryCloseable', '1');
        }
        $smarty->assign(array('name_category_layered' => $selectedCategory, 'search_query' => $this->search_query, 'layered_use_checkboxes' => (int) Configuration::get('PS_LAYERED_NAVIGATION_CHECKBOXES'), 'id_category_layered' => (int) $id_parent, 'selected_filters' => $selectedFilters, 'n_filters' => (int) $nFilters, 'nbr_filterBlocks' => sizeof($filterBlocks), 'filters' => $displayFilters));
        $html_fragment = $this->display(__FILE__, 'blocklayered.tpl');
        return $html_fragment;
    }
コード例 #4
0
 protected function _assignPayment()
 {
     global $orderTotal;
     $invoice_address = new Address((int) self::$cart->id_address_invoice);
     if ($invoice_address->id_country != 110) {
         include_once _PS_MODULE_DIR_ . 'paypal/paypal.php';
         include_once _PS_MODULE_DIR_ . 'paypal/payment/paypalpayment.php';
         include_once _PS_MODULE_DIR_ . 'paypal/payment/submit.php';
         //GetPaypal stuff
         unset(self::$cookie->paypal_token);
         /*if (self::$cart->id_currency != $ppPayment->getCurrency((int) self::$cart->id_currency)->id) {
               self::$cart->id_currency = (int) ($ppPayment->getCurrency((int) self::$cart->id_currency)->id);
               self::$cookie->id_currency = (int) (self::$cart->id_currency);
               self::$cart->update();
               Tools::redirect('modules/' . $ppPayment->name . '/payment/submit.php');
           }*/
         $curr_sel_currency = CurrencyCore::getCurrency(self::$cart->id_currency);
         self::$smarty->assign(array('cust_currency' => self::$cart->id_currency, 'currency' => $curr_sel_currency, 'total' => self::$cart->getOrderTotal(true, Cart::BOTH), 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $ppPayment->name . '/', 'mode' => 'payment/'));
     }
     // Redirect instead of displaying payment modules if any module are grefted on
     Hook::backBeforePayment('order.php?step=3');
     /* We may need to display an order summary */
     self::$smarty->assign(self::$cart->getSummaryDetails());
     self::$smarty->assign(array('total_price' => Tools::ps_round((double) $orderTotal), 'taxes_enabled' => (int) Configuration::get('PS_TAX')));
     self::$cookie->checkedTOS = '1';
     parent::_assignPayment();
 }
コード例 #5
0
ファイル: checkout.php プロジェクト: priyankajsr19/indusdiva2
 function execPayment($cart)
 {
     global $cart;
     global $smarty;
     $invoice_address = new Address((int) $cart->id_address_invoice);
     if ($invoice_address->id_country == 110) {
         return;
     }
     $curr_currency = CurrencyCore::getCurrency($cart->id_currency);
     if ((int) $curr_currency['paypal_support'] === 1) {
         return;
     }
     $delivery = new Address(intval($cart->id_address_delivery));
     $invoice = new Address(intval($cart->id_address_invoice));
     $customer = new Customer(intval($cart->id_customer));
     global $cookie, $smarty;
     //Verify currencies and display payment form
     $currencies = Currency::getCurrencies();
     $authorized_currencies = array_flip(explode(',', $this->currencies));
     $currencies_used = array();
     foreach ($currencies as $key => $currency) {
         if (isset($authorized_currencies[$currency['id_currency']])) {
             $currencies_used[] = $currencies[$key];
         }
     }
     $smarty->assign('currencies_used', $currencies_used);
     $products = $cart->getProducts();
     foreach ($products as $key => $product) {
         $products[$key]['name'] = str_replace('"', '\'', $product['name']);
         $products[$key]['name'] = htmlentities(utf8_decode($product['name']));
     }
     $CheckoutUrl = 'https://www.2checkout.com/checkout/spurchase';
     $x_receipt_link_url = 'http://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'modules/checkout/validation.php';
     $sid = Configuration::get('CHECKOUT_SID');
     $total = number_format($cart->getOrderTotal(true, 3), 0, '.', '');
     $cart_order_id = $cart->id;
     $email = $customer->email;
     $secure_key = $customer->secure_key;
     $demo = "Y";
     // Change to "Y" for demo mode
     $outside_state = "XX";
     // This will pre-select Outside USA and Canada, if state does not exist
     // Invoice Parameters
     $card_holder_name = $invoice->firstname . ' ' . $invoice->lastname;
     $street_address = $invoice->address1;
     $street_address2 = $invoice->address2;
     $phone = $invoice->phone_mobile;
     $city = $invoice->city;
     $state = (Validate::isLoadedObject($invoice) and $invoice->id_state) ? new State(intval($invoice->id_state)) : false;
     $zip = $invoice->postcode;
     $country = $invoice->country;
     // Shipping Parameters
     $ship_name = $delivery->firstname . ' ' . $invoice->lastname;
     $ship_street_address = $delivery->address1;
     $ship_street_address2 = $delivery->address2;
     $ship_city = $delivery->city;
     $ship_state = (Validate::isLoadedObject($delivery) and $delivery->id_state) ? new State(intval($delivery->id_state)) : false;
     $ship_zip = $delivery->postcode;
     $ship_country = $delivery->country;
     if ($cart->id_currency != 2) {
         $total = Tools::convertPrice($total, $cart->id_currency, false);
         $this_currency = CurrencyCore::getCurrency($cart->id_currency);
         $curr_conversion_msg = "<p>Dear Customer, we do not accept payments in <b>{$this_currency['name']}</b>, we will process the equivalent amount of <b>" . Tools::displayPrice($total, 2) . "</b> in USD(United States Dollar).</p> <p>The currency conversion rates are provided by openexchangerates.org</p>";
         $smarty->assign("curr_conversion_msg", $curr_conversion_msg);
     }
     $total = round($total);
     $smarty->assign(array('CheckoutUrl' => $CheckoutUrl, 'return_url' => $return_url, 'sid' => $sid, 'total' => $total, 'cart_order_id' => $cart_order_id, 'email' => $email, 'demo' => $demo, 'outside_state' => $outside_state, 'secure_key' => $secure_key, 'card_holder_name' => $card_holder_name, 'street_address' => $street_address, 'street_address2' => $street_address2, 'phone' => $phone, 'city' => $city, 'state' => $state, 'zip' => $zip, 'country' => $country, 'ship_name' => $ship_name, 'ship_street_address' => $ship_street_address, 'ship_street_address2' => $ship_street_address2, 'ship_city' => $ship_city, 'ship_state' => $ship_state, 'ship_zip' => $ship_zip, 'ship_country' => $ship_country, 'products' => $products, 'x_receipt_link_url' => $x_receipt_link_url, 'TotalAmount' => number_format($total), 'this_path' => $this->_path, 'this_path_ssl' => Configuration::get('PS_FO_PROTOCOL') . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . "modules/{$this->name}/"));
     /* Complementos */
     $cart = new Cart($cookie->id_cart);
     $address = new Address($cart->id_address_delivery, intval($cookie->id_lang));
     $state = State::getNameById($address->id_state);
     $state = $state ? '(' . $state . ')' : '';
     $str_address = ($address->company ? $address->company . '<br>' : '') . $address->firstname . ' ' . $address->lastname . '<br>' . $address->address1 . '<br>' . ($address->address2 ? $address->address2 . '<br>' : '') . $address->postcode . ' ' . $address->city . '<br>' . $address->country . $state;
     $smarty->assign('address', $str_address);
     $carrier = Carrier::getCarriers(intval($cookie->id_lang));
     if ($carrier) {
         foreach ($carrier as $c) {
             if ($cart->id_carrier == $c[id_carrier]) {
                 $smarty->assign('carrier', $c['name']);
                 break;
             }
         }
     }
     /* FIN Complementos */
     return $this->display(__FILE__, 'payment_execution.tpl');
 }
コード例 #6
0
 public static function getCurrent()
 {
     global $cookie;
     if (!self::$current) {
         if (isset($cookie->id_currency) and $cookie->id_currency) {
             self::$current = new Currency((int) $cookie->id_currency);
         } else {
             self::$current = new Currency((int) Configuration::get('PS_CURRENCY_DEFAULT'));
         }
     }
     return self::$current;
 }
コード例 #7
0
ファイル: reindex2.php プロジェクト: priyankajsr19/indusdiva2
function update_currency()
{
    echomsg("Start Updating Currency Conversion Rates");
    try {
        $curr_list = file_get_contents("http://openexchangerates.org/api/latest.json?app_id=c8cbe15270254f4686d6b3f3a7a2af89");
        $curr = Tools::jsonDecode($curr_list);
        if (strtoupper((string) $curr->base) === 'USD') {
            $update_clause = array();
            $rates = $curr->rates;
            $currencies = CurrencyCore::getCurrencies(false, 0);
            foreach ($currencies as $currency) {
                $iso_code = $currency['iso_code'];
                $this_rate = number_format((double) $rates->{$iso_code}, 2, '.', '');
                if ((string) $iso_code === 'INR') {
                    $inr_rate = $this_rate;
                }
                array_push($update_clause, "WHEN iso_code = '{$iso_code}' THEN '{$this_rate}'");
            }
            $sql = "update ps_currency set conversion_rate = CASE ";
            $sql .= implode(" ", $update_clause);
            $sql .= " END";
            Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
            echomsg("All Currencies Conversions Updated Successfully");
            //add USD to INR in history table
            $today = date("Y-m-d 00:00:00");
            $sql = "insert into ps_currency_rates values('{$today}','{$inr_rate}')";
            Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
        } else {
            echomsg("Base Currency not in US", true);
        }
    } catch (Exception $ex) {
        echomsg('Unable to retrieve currency conversion list', true);
    }
}
コード例 #8
0
ファイル: payu.php プロジェクト: priyankajsr19/shalu
 public function hookPayment($params)
 {
     global $cart;
     global $smarty, $cart, $cookie;
     $invoice_address = new Address((int) $cart->id_address_invoice);
     $key = Configuration::get('PAYU_MERCHANT_ID');
     $salt = Configuration::get('PAYU_SALT');
     if (!$this->active) {
         return;
     }
     $mode = Configuration::get('PAYU_MODE');
     $log = Configuration::get('PAYU_LOGS');
     $amount = $cart->getOrderTotal(true, Cart::BOTH);
     $curr_currency = CurrencyCore::getCurrency($cart->id_currency);
     if ($invoice_address->id_country == 110) {
         $key = 'VLBB6Z';
         $salt = 'KQUxLUkT';
         if ($cart->id_currency != 4) {
             //convert to USD(default)
             $amount = Tools::convertPrice($amount, $cart->id_currency, false);
             //convert to INT
             $amount = Tools::convertPrice($amount, 4);
             $inr_currency = CurrencyCore::getCurrency(4);
             $curr_conversion_msg = "<p>Dear Customer, any order with an Indian billing address entails processing of the order value in {$inr_currency['iso_code']} ({$inr_currency['name']}). The order value of <b>" . Tools::displayPrice($amount, 4) . "</b> will be processed.</p><p>Currency conversion rates are provided by  openexchangerates.org</p>";
             $smarty->assign("curr_conversion_msg", $curr_conversion_msg);
         }
     } else {
         if ((int) $curr_currency['paypal_support'] === 1 && $cart->id_currency != 2) {
             //For all Paypal supported curencies except USD, we dont show PayU
             return;
         } else {
             if ($cart->id_currency != 2) {
                 // Currency not supported by Paypal and not USD, convert to USD and proceed
                 $amount = Tools::convertPrice($amount, $cart->id_currency, false);
                 $this_currency = CurrencyCore::getCurrency($cart->id_currency);
                 $curr_conversion_msg = "<p>Unfortunately we are unable to accept payments in <b>{$this_currency['name']}</b>.</p> <p>An equivalent order value of USD <b>" . Tools::displayPrice($amount, 2) . "</b> will be processed.</p>";
                 $smarty->assign("curr_conversion_msg", $curr_conversion_msg);
             }
         }
     }
     $amount = round($amount);
     //else
     //return;
     //convert to INR if the currency is not
     //if ($cart->id_currency != 4)
     //$amount = Tools::convertPrice($amount, 4, true);
     $customer = new Customer((int) $cart->id_customer);
     $action = 'https://test.payu.in/_payment.php';
     $txnid = $cart->id;
     $productInfo = 'Payu product information';
     $firstname = $customer->firstname;
     $Lastname = $customer->lastname;
     $deloveryAddress = new Address((int) $cart->id_address_invoice);
     $Zipcode = $deloveryAddress->postcode;
     $email = $customer->email;
     $phone = $deloveryAddress->phone;
     $deloveryAddress->country = Country::getNameById(1, $deloveryAddress->id_country);
     $deloveryAddress->state = State::getNameById($deloveryAddress->id_state);
     if ($mode == 'real') {
         $action = 'https://secure.payu.in/_payment.php';
     }
     $request = $key . '|' . $txnid . '|' . $amount . '|' . $productInfo . '|' . $firstname . '|' . $email . '|||||||||||' . $salt;
     $Hash = hash('sha512', $key . '|' . $txnid . '|' . $amount . '|' . $productInfo . '|' . $firstname . '|' . $email . '|||||||||||' . $salt);
     $baseUrl = Tools::getShopDomain(true, true) . __PS_BASE_URI__;
     if ($log == 1) {
         $query = "insert into ps_payu_order(id_order,payment_request) values({$orderId},'{$request}')";
         Db::getInstance()->Execute($query);
     }
     $surl = $baseUrl . 'modules/' . $this->name . '/success.php';
     $curl = $baseUrl . 'modules/' . $this->name . '/failure.php';
     $Furl = $baseUrl . 'modules/' . $this->name . '/failure.php';
     $Pg = 'CC';
     $payuInfo = array('action' => $action, 'key' => $key, 'txnid' => $txnid, 'amount' => $amount, 'productinfo' => $productInfo, 'firstname' => $firstname, 'Lastname' => $Lastname, 'Zipcode' => $Zipcode, 'email' => $email, 'phone' => $phone, 'surl' => $surl, 'Furl' => $Furl, 'curl' => $curl, 'Hash' => $Hash, 'Pg' => $Pg, 'deliveryAddress' => $deloveryAddress);
     $smarty->assign('Message', 'Please wait, you will be redirected to payu website');
     $smarty->assign($payuInfo);
     return $this->display(__FILE__, 'payu.tpl');
 }
コード例 #9
0
 /**
  * Return available currencies
  *
  * @return array Currencies
  */
 public function getCurrencies($object = false, $active = true, $group_by = false)
 {
     return \CurrencyCore::getCurrencies($object = false, $active = true, $group_by = false);
 }
コード例 #10
0
<?php

define('_PS_ADMIN_DIR_', getcwd());
define('PS_ADMIN_DIR', _PS_ADMIN_DIR_);
// Retro-compatibility
include PS_ADMIN_DIR . '/../config/config.inc.php';
include PS_ADMIN_DIR . '/functions.php';
echomsg("Start Updating Currency Conversion Rates");
try {
    $curr_list = file_get_contents("http://openexchangerates.org/api/latest.json?app_id=c8cbe15270254f4686d6b3f3a7a2af89");
    $curr = Tools::jsonDecode($curr_list);
    if (strtoupper((string) $curr->base) === 'USD') {
        $update_clause = array();
        $rates = $curr->rates;
        $currencies = CurrencyCore::getCurrencies(false, 0);
        foreach ($currencies as $currency) {
            $iso_code = $currency['iso_code'];
            $this_rate = number_format((double) $rates->{$iso_code}, 2, '.', '');
            array_push($update_clause, "WHEN iso_code = '{$iso_code}' THEN '{$this_rate}'");
        }
        $sql = "update ps_currency set conversion_rate = CASE ";
        $sql .= implode(" ", $update_clause);
        $sql .= " END";
        Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
        echomsg("All Currencies Conversions Updated Successfully");
    } else {
        echomsg("Base Currency not in US", true);
    }
} catch (Exception $ex) {
    echomsg('Unable to retrieve currency conversion list', true);
}
コード例 #11
0
 public function updateProductPrice($id_product)
 {
     $product_sbm = $this->GetMultiCurrency($id_product);
     $def_currency = CurrencyCore::getDefaultCurrency();
     $sbm_currency = new Currency((int) $product_sbm['id_currency']);
     $new_product_price = (double) $product_sbm['product_price'] * ($def_currency->conversion_rate / $sbm_currency->conversion_rate);
     $new_product_sale_price = (double) $product_sbm['product_sale_price'] * ($def_currency->conversion_rate / $sbm_currency->conversion_rate);
     // $new_product_price = (float)$this->priceRound($new_product_price);
     // $new_product_sale_price = (float)$this->priceRound($new_product_sale_price);
     $sql1 = "UPDATE `" . _DB_PREFIX_ . "product` SET \n\t        \t\t\t\t\t\t\t\t`price` = " . $new_product_price . ", \n\t        \t\t\t\t\t\t\t\t`wholesale_price` = " . $new_product_sale_price . " \n\t        \t\t\t\t\t\t\t\tWHERE `id_product` = " . $id_product . " LIMIT 1 ";
     $sql2 = "UPDATE `" . _DB_PREFIX_ . "product_shop` SET \n\t        \t\t\t\t\t\t\t\t`price` = " . $new_product_price . ",\t\n\t        \t\t\t\t\t\t\t\t`wholesale_price` = " . $new_product_sale_price . " \n\t        \t\t\t\t\t\t\t\tWHERE `id_product` = " . $id_product . " ";
     if (Db::getInstance()->Execute($sql1, false) and Db::getInstance()->Execute($sql2, false)) {
         return true;
     }
     return false;
 }
コード例 #12
0
ファイル: Currency.php プロジェクト: Evil1991/PrestaShop-1.4
 public static function getCurrent()
 {
     global $cookie;
     if (!self::$current) {
         if (isset($cookie->id_currency) && $cookie->id_currency) {
             self::$current = new Currency((int) $cookie->id_currency);
         } else {
             self::$current = new Currency((int) _PS_CURRENCY_DEFAULT_);
         }
     }
     return self::$current;
 }
コード例 #13
0
ファイル: Tools.php プロジェクト: priyankajsr19/indusdiva2
 public static function getPointsToCash($id_currency)
 {
     $currency = CurrencyCore::getCurrency($id_currency);
     return (double) (POINTS_TO_CASH * $currency['conversion_rate']);
 }