Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Kelkoo Contribution


mark27uk3

Recommended Posts

Posted

Hi Guys,

 

I have installed the Kelkoo Contribution and managed to change the currency and language settings but the problem I am having is that when the text file is generated the prices look like ?5,00 instead of ?5.00 has anyone used this contrib and can tell me what I need to change to make the prices look right?! :blink:

 

There are two files kelkoo.php and price_comparison.php, below is the code for the kelkoo.php but not sure wether this is the right file - it could be the other one.

 

<?php
/*
 $Id: kelkoo.php v2.0 2004/10/18

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2004 osCommerce

 Released under the GNU General Public License
*/

$kelkoo_list = "#country=uk\n"; // A modifier au besoin
$kelkoo_list .= "#type=BASIC\n";  // A modifier au besoin
$kelkoo_list .= "#currency=GBP\n"; // A modifier au besoin

 require('includes/application_top.php');

$kelkoo_subdir = "kelkoo/";
$kelkoo_dir = DIR_FS_CATALOG . $kelkoo_subdir;
$kelkoo_file = "kelkoo.txt";
 
if (!function_exists('html_entity_decode')) {
function html_entity_decode ($string, $opt = ENT_COMPAT) {
  $trans_tbl = get_html_translation_table (HTML_ENTITIES);
  $trans_tbl = array_flip ($trans_tbl);
  if ($opt & 1) { // Translating single quotes
    // Add single quote to translation table; doesn't appear to be there by default
    $trans_tbl["'"] = "'";
  }
  if (!($opt & 2)) { // Not translating double quotes
    // Remove double quote from translation table
    unset($trans_tbl["""]);
  }
  return strtr ($string, $trans_tbl); 
}
}

// Just to be safe;o)$description = ereg_replace('<[^>]*>', '', $description);
if (!defined("ENT_COMPAT")) define("ENT_COMPAT", 2);
if (!defined("ENT_NOQUOTES")) define("ENT_NOQUOTES", 0);
if (!defined("ENT_QUOTES")) define("ENT_QUOTES", 3);

function clean_html_kelkoo($description, $length) {
 global $its_cleaned;
 $its_cleaned = html_entity_decode ($description);
 $its_cleaned = strip_tags ($description);
 $its_cleaned = trim ($its_cleaned);
 $its_cleaned = strtolower ($its_cleaned);
 $its_cleaned = str_replace(chr(9),"",$its_cleaned);  //$its_cleaned = str_replace("\t","",$its_cleaned);
 $its_cleaned = str_replace(chr(10),"",$its_cleaned);//$its_cleaned = str_replace("\n","",$its_cleaned);
 $its_cleaned = str_replace(chr(13),"",$its_cleaned);//$its_cleaned = str_replace("\r","",$its_cleaned);
 $its_cleaned = preg_replace("[<(.*?)>]","",$its_cleaned);
 if (strlen($its_cleaned) > $length) {
   $its_cleaned = substr($its_cleaned, 0, $length-3);
   $its_cleaned .= '...';
 }
 return $its_cleaned;
}  

$kelkoo_list .= "url\ttitle\tdescription\tprice\tofferid\timage\tcategory\tavailability\tdeliverycost\n";

$products_query = tep_db_query("(SELECT 
p.products_id, 
p.products_quantity, 
p.products_model, 
p.products_image, 
p.products_price, 
p.products_tax_class_id, 
p.products_compare_expedition, 
pd.products_name, 
pd.products_description, 
cd.categories_name FROM 
" . TABLE_PRODUCTS . " p, 
" . TABLE_PRODUCTS_DESCRIPTION . " pd, 
" . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, 
" . TABLE_CATEGORIES . " c, 
" . TABLE_CATEGORIES_DESCRIPTION . " cd
WHERE p.products_id = pd.products_id 
AND cd.categories_id = c.parent_id
AND p.products_id = p2c.products_id 
AND c.categories_id = p2c.categories_id 
AND p.products_status = 1 
AND p.products_price <> 0 
AND p.products_compare_status = 1 
AND pd.language_id = '" . (int)$languages_id . "' 
AND cd.language_id = '" . (int)$languages_id . "' 
GROUP BY p.products_id, cd.categories_id)");

$expedition_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key  = 'EXPEDITION_PRICE'");
$expedition_price = tep_db_fetch_array($expedition_query);
// increment pour donner un num?ro d'offre, pr?f?rable ? l'id
$increment = 347;

while($products = tep_db_fetch_array($products_query)) {  
 $increment++;

// Lien vers le produit;
 $kelkoo_list .= tep_catalog_href_link(FILENAME_DEFAULT, 'products_id=' . $products['products_id'], 'NONSSL', false) . "\t";

// Nom du produit
 $kelkoo_list .= clean_html_kelkoo($products['products_name'], 80) . "\t";

// Description ou nom  
 $kelkoo_list .= clean_html_kelkoo($products['products_description'], 160) . "\t";

// Prix du produit (price)
 if ($new_price = tep_get_products_special_price($products['products_id'])) {
   $kelkoo_list .= number_format((tep_round($new_price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places'])) + (tep_calculate_tax($new_price, tep_get_tax_rate($products['products_tax_class_id']))), 2, ',', '') . "\t";
 } else {
   $kelkoo_list .= number_format((tep_round($products['products_price'], $currencies->currencies[DEFAULT_CURRENCY]['decimal_places'])) + (tep_calculate_tax($products['products_price'], tep_get_tax_rate($products['products_tax_class_id']))) , 2, ',', '') . "\t";
 }                   
// Num?ro de l'offre                     
 $kelkoo_list .= $increment . "\t";

// image
 if (tep_not_null($products['products_image'])) {
    $kelkoo_list .= tep_catalog_href_link(DIR_WS_IMAGES . $products['products_image'], '', 'NONSSL', false) . "\t";
 } else {
    $kelkoo_list .= "no_image\t";
 }

// Categorie
 $kelkoo_list .= $products['categories_name'] . "\t";

// Qt? en stock
 if ( $products['products_quantity'] > 0 ) {
   $kelkoo_list .=  "001\t";
 } else {
   $kelkoo_list .=  "003\t";
 }     

// Cout de la livraison
 if ( $products['products_compare_expedition'] == 0 ) {
   $kelkoo_list .= substr($expedition_price['configuration_value'], 0 , 20);
 } else {
   $kelkoo_list .= $products['products_compare_expedition'];
 }

 $kelkoo_list .= "\n";
}

$fp= fopen($kelkoo_dir . $kelkoo_file,"w");
fputs($fp,"$kelkoo_list");
fclose($fp);
?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="3">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td CLASS="pageHeading"><?php echo HEADING_TITLE; ?></td>
           <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '50'); ?></td>
     <tr>
       <td><table width="100%" cellspacing="0" cellpadding="0" border="0">
         <tr>
           <td class="main">
           <?php
             if (is_file($kelkoo_dir . $kelkoo_file)) {
               $sizefile = 1024*filesize($kelkoo_dir . $kelkoo_file)/pow(2,20);
               $sizeformatted = sprintf("%0.0f Ko", $sizefile);
               $datefile = strftime(DATE_FORMAT_SHORT, filemtime($kelkoo_dir . $kelkoo_file));
               echo TEXT_KELKOO_DOWNLOAD . ' -> <a href="' . tep_catalog_href_link($kelkoo_subdir . $kelkoo_file, '', 'NONSSL', false) . '" target="_blank\">' . '<font color="red">' . $sizeformatted . ' - ' . $datefile . '</font></a>';
             } else echo TEXT_KELKOO_NOFILE . ' ' . $kelkoo_dir; ?>
           </td>
         </tr>
         <tr>
           <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10') ?></td>
         </tr>
         <tr>
           <td class="main"><?php if (is_file($kelkoo_dir . $kelkoo_file)) echo TEXT_KELKOO_UPLOAD; ?></td>
         </tr>
        </table></td>
     </tr>
   </table></td>
<!-- body_text_eof //-->
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

If anyone can help I would appreciate it as this contrib works great!

 

Thanks

 

Mark :-"

Lifes a bitch, then you marry one, then you die!

Posted

Have you tried the support thread in the contribution support section of the forum? If not that would probably be a good place to start.

The Knowledge Base is a wonderful thing.

Do you have a problem? Have you checked out Common Problems?

There are many very useful osC Contributions

Are you having trouble with a installed contribution? Have you checked out the support thread found Here

BACKUP BACKUP BACKUP!!! You did backup, right??

Posted

As far as I can tell there is no support thread for this contribution but if anyone knows differently then please let me know!

 

Mark

Lifes a bitch, then you marry one, then you die!

  • 2 weeks later...
Posted
As far as I can tell there is no support thread for this contribution but if anyone knows differently then please let me know!

 

Mark

 

Hi Mark,

 

Sorry I can't help with the original question but I wondered if you could let me know how you changed the currency from Euro's to GBP in the Kelkoo contribution.

 

I can't see where to change this in the contribution files and my default currency is GBP but the kelkoo.txt file is listing Euro's.

 

You assistance is appreciated..

Posted

Hi Jim,

 

All I could do was change the kelkoo text file after it was created.

 

To change to the currency and country its simple, just change the top three lines of the text file to look like this

 

#country=uk

#type=BASIC

#currency=GBP

 

Also you will manually have to change all the prices to remove the comma to a decimal point i.e. 3,99 to 3.99

 

Also double check the product links as when it creates a link that takes you to the product listing rather than the actual product page.

 

If you need any further help then just ask.

 

Mark

Lifes a bitch, then you marry one, then you die!

Posted

mark

I see that the number format function has the parameters 2 for 2 decimals and ',' as decimal separator. Try changing that to '.'.

 

Carine

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Posted

Hi Carine

 

I changed what you said and it has not changed the way the price is outputted there is still a , instead of a .

 

Mark

Lifes a bitch, then you marry one, then you die!

Posted
Hi Jim,

 

All I could do was change the kelkoo text file after it was created.

 

To change to the currency and country its simple, just change the top three lines of the text file to look like this

Also you will manually have to change all the prices to remove the comma to a decimal point i.e. 3,99 to 3.99

 

Also double check the product links as when it creates a link that takes you to the product listing rather than the actual product page.

 

If you need any further help then just ask.

 

Mark

 

Hi Mark,

 

I think I misunderstood your post and was looking elsewhere to change the country settings - I had already setup the file for 'uk' - 'GBP' etc but thought there was something I was missing.

 

The problem i am having is that all my prices are rounded up to the nearest integer (ie 3.95 becomes 4.00) and I mistakenly thought the prices were still being shown as Euro's and thus that I still needed to change a setting for GBP somewhere else.

 

I need to prevent this rounding to show the prices on my Kelkoo offers as they appear on my site. Any clues on this?

 

Thanks for your quick response to my previous inquiry BTW.. ;-)

 

Regards,

Jimmuk

  • 2 months later...
Posted
Hi Carine

 

I changed what you said and it has not changed the way the price is outputted  there is still a , instead of a .

 

Mark

 

Hi Mark,

 

Could you please give me the exact line you used? I have changed it to '.' but still numbers show like 3.00 instead of 3.01

 

Thanks

  • 9 months later...
Posted
Hi Mark,

 

Could you please give me the exact line you used? I have changed it to '.' but still numbers show like 3.00 instead of 3.01

 

Thanks

 

Hi,

 

There is a fix on the contrib page for the rounding problem. Price_problem_link

 

 

With the deliminator "," instead of "." this is how it should look:

 

 // Price of product
if ($new_price = tep_get_products_special_price($products['products_id'])) {
  $kelkoo_list .= number_format($new_price * (1 + (tep_get_tax_rate($products['products_tax_class_id']))/100), 2, '.', '') . "\t";
} else {
  $kelkoo_list .= number_format($products['products_price'] *(1 +( tep_get_tax_rate($products['products_tax_class_id']))/100), 2, '.', '') . "\t";
}

 

Some more formats:

 

<?php

$number = 1234.56;

// english notation (default)
$english_format_number = number_format($number);
// 1,235

// French notation
$nombre_format_francais = number_format($number, 2, ',', ' ');
// 1 234,56

$number = 1234.5678;

// english notation without thousands seperator
$english_format_number = number_format($number, 2, '.', '');
// 1234.57

?>

 

Byee

 

Darren

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...