briedis Posted April 7, 2012 Report Share Posted April 7, 2012 Izskatās, ka jāsāk mācīties paši paši php pamati... $product['price_inc'] = number_format(round($product['price_inc'], 2), 2) Quote Link to comment Share on other sites More sharing options...
didje3 Posted April 7, 2012 Report Share Posted April 7, 2012 Jā, šis kārtībā tagad, zinu ka jāmācās. Vēl tik ar to otru problēmu ar to cenu attēlošanu, lai rāda akcijas cenu nevis veco cenu, pārējās produktu cenas rāda pareizi, bet akcijas cenas klibo, rāda pamata cenu? Quote Link to comment Share on other sites More sharing options...
briedis Posted April 7, 2012 Report Share Posted April 7, 2012 Atrodi vietu, kur tiek izvadīta cena, tur arī izvadi parasto/akcijas cenu, ja tāda eksistē... Quote Link to comment Share on other sites More sharing options...
didje3 Posted April 7, 2012 Report Share Posted April 7, 2012 (edited) Laikam cena tiek izvadīta šeit, rinda, kur $product['price'] foreach ($products as $product){ $product['link'] = $link->getProductLink($product['id_product']); $product['price_inc'] = $product['price'] * (1 + $product['tax_rate'] / 100); $product['price_inc'] = number_format(round($product['price_inc'], 2), 2); Edited April 7, 2012 by didje3 Quote Link to comment Share on other sites More sharing options...
briedis Posted April 7, 2012 Report Share Posted April 7, 2012 Tagad noskaidro, kurā mainīgajā glabājas akcijas cena (vai tā īstā, ja šī ir akcijas). Quote Link to comment Share on other sites More sharing options...
didje3 Posted April 7, 2012 Report Share Posted April 7, 2012 Skripts <?php include(dirname(__FILE__).'/../../config/config.inc.php'); require_once(dirname(__FILE__).'/../../init.php'); $tags = array( 'name' => 'name', 'link' => 'link', 'price_inc' => 'price', 'imageUrl' => 'image', 'ean' => 'ean', 'categoryName' => 'category_full', 'subCategoryName' => 'subCategory', ); function my_strip_tags($t) { $t = preg_replace('/</',' <',$t); $t = preg_replace('/>/','> ',$t); $t = preg_replace('/[\n\r\t]/',' ',$t); $t = preg_replace('/ /',' ',$t); return strip_tags($t); } function print_field($k, $v) { global $tags; if (isset($tags[$k])) { $k = $tags[$k]; $v = htmlspecialchars($v, ENT_NOQUOTES, "UTF-8"); print " <$k>$v</$k>\n"; } } header("Content-Type:text/xml; charset=utf-8"); print '<?xml version="1.0" encoding="UTF-8"?>'; print "<root>\n"; $configuration = Configuration::getMultiple(array( 'PS_LANG_DEFAULT', 'PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_METHOD', 'PS_SHIPPING_FREE_WEIGHT', 'PS_CARRIER_DEFAULT')); $id_lang = intval($configuration['PS_LANG_DEFAULT']); $id_zone = intval($defaultCountry->id_zone); $link = new Link(); $id_carrier = $configuration['PS_CARRIER_DEFAULT']; $carrier = new Carrier(intval($id_carrier)); $carrierTax = 0; if ($carrier->id_tax) { $tax = new Tax(intval($carrier->id_tax)); if (Validate::isLoadedObject($tax) AND Tax::zoneHasTax(intval($tax->id), intval($id_zone)) AND !Tax::excludeTaxeOption()) $carrierTax = $tax->rate; } $passwd = Tools::getValue('passwd'); $categories = Category::getCategories($id_lang, true, false); $manufacturers = Manufacturer::getManufacturers(false, $id_lang); if ($passwd == $confPasswd) { $products = Product::getProducts($id_lang, 0, 0, 'price', 'ASC', false, true); } else { $products = array(); } $manMap =array(); foreach ($manufacturers as $manufacturer) { $manMap[$manufacturer['id_manufacturer']] = $manufacturer; } $catMap =array(); foreach ($categories as $category) { $catMap[$category['id_category']] = $category; } foreach ($products as $product){ $product['link'] = $link->getProductLink($product['id_product']); $product['price_inc'] = $product['price'] * (1 + $product['tax_rate']/ 100); $product['price_inc'] = number_format(round($product['price_inc'], 2), 2); $cover = Product::getCover($product['id_product']); $product['imageUrl'] = _PS_BASE_URL_.$link->getImageLink($prodObj->link_rewrite, $product['id_product'].'-'.$cover['id_image'], 'large'); $product['manufacturerName'] = $manMap[$product['id_manufacturer']]['name']; print " <item>\n"; foreach ($product as $k => $v) { print_field($k, $v); } $catList = Product::getIndexedCategories($product['id_product']); foreach ($catList as $cat) $cat=$catList[0];{ $catNames = array(); $catId = $cat['id_category']; while ($catId && $catId != 1) { array_unshift($catNames, trim($catMap[$catId]['name'])); $catId = $catMap[$catId]['id_parent']; } print_field('categoryName', implode(' >> ', $catNames)); //$result = mysql_query("SELECT * FROM s_category_product WHERE id_category='{$cat['id_category']}'"); //while($row = mysql_fetch_array($result)) { echo "<category_link>http://www.lapa.lv/category.php?id_category={$cat['id_category']}</category_link>"; //} } print "</item>\n"; } print "</root>\n"; Kur mainīgais nemaz nezināšu! Quote Link to comment Share on other sites More sharing options...
daGrevis Posted April 9, 2012 Report Share Posted April 9, 2012 Nu vai nu tu kodē pats vai nu tu kādam maksā.... :@ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.