[pugin] Auto-update currencies

Messagepar nequaquam » Mar 20 Juin 2006, 19:24

Edited: JUMP THIS FIRST POST, ONLY THE FIRST, IT'S AN UGLY SOLUTION!!!

Hello again, I've looked for the way to update currencies automatically. I've searched in the contributions but I've not found anything suitable.
I've tried to create a contribution that actualize automatically the currency with http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml, but I've not been able.

Temporarily I've added the following code in shopping_cart.php:

Code: Tout sélectionner
<a href="http://www.xe.com/pca/launch.cgi?Amount=<?php echo $cart->show_total();?>&From=<?php echo $currency; ?>">Currency converter (Pop Up)</a>

This code opens a PopUp with the cart total in http://www.xe.com/ucc/ and a button to change the currency.
Dernière édition par nequaquam le Lun 31 Juil 2006, 13:22, édité 1 fois.
_______________________________________________________________________________

Website: nequaquam
osCSS shop in development: pugnae
nequaquam
Membre actif
 
Messages: 48
Inscription: Mer 08 Fév 2006, 12:40
Localisation: Barcelona

Messagepar nequaquam » Sam 29 Juil 2006, 22:43

Hello,
a long time ago I found this php class made by Gary White: http://www.apptools.com/phptools/xml/currency/howto.php

The file automatically doesn't update database currencies, but it does what I need, allows to show on the fly more diferent currencies. The XML http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml is updated every day and the class makes a copy in local. I've attached a screenshot to see how it works.

Image

Download link: http://www.apptools.com/phptools/downloads/currencyexchange.zip

Sample code in product info:

Code: Tout sélectionner
<?php
require_once("includes/classes/currencyexchange_class.php");
$cx=new currencyExchange();
$cx->getData();

if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
   $usdollarprice = $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id']));
} else {
   $usdollarprice = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
}
?>   

<p class="productPrice"><?php echo $products_price; ?></p>

<p class="currencyPrice">
<?php
if ($euro=$cx->Convert($currency,"USD",$usdollarprice)){
 $euro=number_format($euro,2, "." ,"");
  echo '(' . APPROX_CURRENCY_TEXT . ' US$ ' . $euro . ')';
}
?>
</p>
Dernière édition par nequaquam le Lun 31 Juil 2006, 07:34, édité 1 fois.
_______________________________________________________________________________

Website: nequaquam
osCSS shop in development: pugnae
nequaquam
Membre actif
 
Messages: 48
Inscription: Mer 08 Fév 2006, 12:40
Localisation: Barcelona

Messagepar nequaquam » Dim 30 Juil 2006, 22:57

In the same way is possible create a currency converter standalone, for shopping cart or for total amount with shipping and handling. See attached screenshot:
Image
European Central Bank feed gives the value of 35+1 diferent currencies.
_______________________________________________________________________________

Website: nequaquam
osCSS shop in development: pugnae
nequaquam
Membre actif
 
Messages: 48
Inscription: Mer 08 Fév 2006, 12:40
Localisation: Barcelona

Messagepar nequaquam » Dim 30 Juil 2006, 23:15

I've added this class to Feedmachine http://www.oscommerce.com/community/contributions,4347/

Code: Tout sélectionner
<?php

/**
 * Feedmachine - osCommerce MS-2.2
 *
 * Generates feeds for any product search engine, e.g. froogle, shopping.com,
 * kelkoo. Simply configure the feeds and run the script to generate them from
 * your product database. Highly flexible system and easy to modify.
 * @package feedmachine
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 * @version 1.01
 * @link http://www.oscommerce-freelancers.com/ osCommerce-Freelancers
 * @copyright Copyright 2005, Lech Madrzyk
 * @author Lech Madrzyk
 * @filesource
 */


/*
This file, feedmachine-release-v1-00.php, should be put in your admin directory
*/


//I put in a check for this variable into application_top that prevents a session from starting - you can do the same (not very important...)
$start_session = false;

/*
The following assumes your admin directory is in your catalog directory - As Is Standard
(This program uses the catalog's application_top (as oppose to admin's) in case any alternative url generator is used.)
*/

chdir('..');
require('includes/application_top.php');

// PRECIO EN DOLARES
require("includes/classes/currencyexchange_class.php");
// PRECIO EN DOLARES


/*
CONFIGURATION
*/

/*
Save Location Relative to Catalog Directory
Create a directory in your catalog directory for your product feed files, ensure its writable and set SAVE_LOCATION
below to the name of this directory followed by a foward slash (/)
*/
define('SAVE_LOCATION', 'feeds/');

/*
Back-Up Files?
If a previous feed file exists, back it up?
(Will be renamed to [name][datelastmodified].[extenstion])
*/
define('BACK_UP_OLD_FEEDS', false);




/*
Feeds
----------------------------
This should be intuative so just look at the examples below before reading this.

Make an entry for each feed file you want in the $feeds array
The format of each feed file's array can be seen in the examples below

Fields:
The fields array is an associative array with
     KEYS SET TO THE FIELD NAMES IN THE OUTPUT FEED FILE
and with the
     VALUES SET TO THE FIELD NAMES IN THE MySQL DATABASE POWERING OSCOMMERCE


Field Keywords:
These are keywords to generate important product information as oppose to just outputting a field's value from the database

FEED_PRODUCTS_URL
FEED_IMAGE_URL
FEED_CATEGORY
FEED_BLANK


Category Output Type:
If using the FEED_CATEGORY keyword this value determines how the field is generated:

1 - The Category Name (default)
2 - Nested Category Path (e.g. TopCat > SubCat > SubSubCat, etc)
3 - Only the root (i.e. top) category


Filters (optional):
Setting the filters array for a field simply runs the function preg_replace (a function that replaces strings matching patterns
in a subject) with the patterns and replacements arrays on the fields value. To do simple things such as replacing words with other words is easy
(You can see how this works in the kelkoo example below). If you are not familiar with this function, and would like to do more complicated
replacements read the great Perl-Compatible Regular Expressions guide
at
http://uk2.php.net/manual/en/reference.pcre.pattern.syntax.php
and the function definition at
http://uk2.php.net/manual/en/function.preg-replace.php


A note on attribute handling:
-----------------------------
If you have installed a contribution or reprogrammed original handling to allow for "=" attribute prefix where the attribute price determines the
products price entirely, I have a modified version of this script which will add a record for each option value and place the value's name in the
product's name field. So for example: for a Gold chain, you might offer many lengths: 17", 18", 20" and 22" that have different prices. Each one is
really a product in itself, but to make things easier for the customer you might have included the length as a product option - the modification
accommodates for this.
The reason this is not in the main release is because it slows things down slightly. If you need it, let me know.



All you need to do now to make your life really easy is write in ftp access and a little cron job handling - then you won't need to think about feeds
ever again, except when setting up new ones.

NEW IN VERSION v1.01
--------------------

text_qualifier is handled properly now.

IMPORTANT: NOTE - READ THIS MESSAGE ONLY IF YOU ARE EXPERIENCING PROBLEMS REGARDING THE ENCODING OF THE FEED FILES:
A new feed configuration parameter (for version v1.01), "encoding", specifies whether to encode the feed file. Currently there are only two options:
false and 'utf8'. Although I know that Froogle/Google Base wants UTF8 encoding, I don't know about the other two feeds (I can't remember what the spec
is and I don't have to worry about it because I only use standard characters that aren't encoded). By default encoding for these is also set to utf8,
so if you experience any such problems try setting it to false.

---------------------

*/


// PRECIO EN DOLARES
$feeds[] = array('filename' => 'froogle-espanol-dollar.txt',
                 'fields' => array('link'   =>   array('name' => 'FEED_PRODUCTS_URL',
                                                     'type' => 'KEYWORD'
                                ),
                          'title'          =>   array('name' => 'products_name',
                                                     'type' => 'DB',
                                             'options' => array('HTML_ENTITIES')
                                    ),
                  'description'   =>   array('name' => 'products_description',
                                                     'type' => 'DB',
                                             'options' => array('STRIP_HTML', 'HTML_ENTITIES', 'STRIP_CRLF')
                                ),
                  'price'         =>   array('name' => 'FEED_DOLLAR_PRICE_WITHOUT_TAX',
                                                      'type' => 'KEYWORD'
                                    ),
                  'image_link'     =>   array('name' => 'FEED_IMAGE_URL',
                                                      'type' => 'KEYWORD'
                                  ),
                  'label'      =>   array('name' => 'FEED_CATEGORY',
                                                     'type' => 'KEYWORD',
                                   ),
                  'id'      =>   array('name' => 'products_id',
                                                      'type' => 'DB'
                                   )
                  ),
         'language_id' => 3,
         'add_field_names' => true, //Whether to start the feed file with the output field names on the first line
         'category_output_type' => 2,
                 'category_seperator' => '>',
         'seperator' => "t",
         'text_qualifier' => '',
         'newline' => "n",
         'encoding' => 'utf8'
       );
// PRECIO EN DOLARES


$feeds[] = array('filename' => 'froogle-espanol-euro.txt',
                 'fields' => array('link'   =>   array('name' => 'FEED_PRODUCTS_URL',
                                                     'type' => 'KEYWORD'
                                ),
                          'title'          =>   array('name' => 'products_name',
                                                     'type' => 'DB',
                                             'options' => array('HTML_ENTITIES')
                                    ),
                  'description'   =>   array('name' => 'products_description',
                                                     'type' => 'DB',
                                             'options' => array('STRIP_HTML', 'HTML_ENTITIES', 'STRIP_CRLF')
                                ),
                  'price'         =>   array('name' => 'FEED_PRICE_WITHOUT_TAX',
                                                     'type' => 'KEYWORD'
                                    ),
                  'image_link'     =>   array('name' => 'FEED_IMAGE_URL',
                                                      'type' => 'KEYWORD'
                                  ),
                  'label'      =>   array('name' => 'FEED_CATEGORY',
                                                     'type' => 'KEYWORD',
                                   ),
                  'id'      =>   array('name' => 'products_id',
                                                      'type' => 'DB'
                                   )
                  ),
         'language_id' => 3,
         'add_field_names' => true, //Whether to start the feed file with the output field names on the first line
         'category_output_type' => 2,
                 'category_seperator' => '>',
         'seperator' => "t",
         'text_qualifier' => '',
         'newline' => "n",
         'encoding' => 'utf8'
       );

$feeds[] = array('filename' => 'shopping.com-espanol.txt',
                 'fields' => array('Product URL'   =>   array('name' => 'FEED_PRODUCTS_URL',
                                                      'type' => 'KEYWORD'
                                ),
                          'Product Name'          =>   array('name' => 'products_name',
                                                      'type' => 'DB',
                                             'options' => array('HTML_ENTITIES')
                                    ),
                  'Product Description'   =>   array('name' => 'products_description',
                                                     'type' => 'DB',
                                             'options' => array('STRIP_HTML', 'HTML_ENTITIES', 'STRIP_CRLF')
                                ),
                  'Product Price'         =>   array('name' => 'FEED_PRICE_WITHOUT_TAX',
                                                     'type' => 'KEYWORD'
                                    ),
                  'Image URL'     =>   array('name' => 'FEED_IMAGE_URL',
                                                     'type' => 'KEYWORD'
                                  ),
                  'Dealtime.co.uk Categorisation'      =>   array('name' => 'FEED_CATEGORY',
                                                     'type' => 'KEYWORD',
                                   ),
                  'Stock'      =>   array('name' => 'Y',
                                                     'type' => 'VALUE'
                                  ),
                  'Standard Shipping'   =>   array('name' => '$output_field_value = $product['products_price'] < 50 ? 3.95 : 0;',
                                                    'type' => 'LOGIC'
                                  )
                  ),
         'language_id' => 3,
         'add_field_names' => true,
        'category_output_type' => 2,
                 'category_seperator' => '>',
         'seperator' => "t",
         'text_qualifier' => '',
         'newline' => "n",
         'encoding' => 'utf8'
       );

$feeds[] = array('filename' => 'kelkoo-espanol.txt',
                 'fields' => array('Category'      =>   array('name' => 'Fashion',
                                                      'type' => 'VALUE'
                                ),
                  'Type'          =>   array('name' => 'FEED_CATEGORY',
                                                      'type' => 'KEYWORD',
                                    'filters' => array('patterns'     => array('#hello#i', '#bob#i'),
                                                      'replacements' => array('byebye', 'tom')
                                           )
                                  ),
                          'Brand'         =>   array('name' => 'if( preg_match('#saul anthony#i', $product['products_name']) ) $output_field_value = 'Saul Anthony'; elseif( preg_match('#simply wedds#i', $product['products_name']) ) $output_field_value = 'Simply Wedds'; else $output_field_value = '';',
                                                     'type' => 'LOGIC',
                                   ),
                          'Name'          =>   array('name' => 'products_name',
                                                      'type' => 'DB',
                                             'options' => array('HTML_ENTITIES')
                                    ),
                  'Size'          =>   array('name' => 'BLANK',
                                                      'type' => 'KEYWORD'
                                ),
                  'Department'    =>   array('name' => 'if( preg_match('#(gents| men)#i', $product['products_name']) || preg_match('#(gents| men)#i', $product['categories_name']) ) $output_field_value = 'Men'; else $output_field_value = 'Women';',
                                                      'type' => 'LOGIC'
                                ),
                  'Colour'        =>   array('name' => 'Gold',
                                                     'type' => 'VALUE'
                                ),
                  'Material'      =>   array('name' => '$output_field_value = 'Gold'; if( preg_match('# diamonds? #i', $product['products_name']) ) $output_field_value .= ', Diamond';',
                                                      'type' => 'LOGIC'
                                ),
                  'Field I'       =>   array('name' => 'BLANK',
                                                      'type' => 'KEYWORD'
                                ),
                  'Field J'       =>   array('name' => 'BLANK',
                                                      'type' => 'KEYWORD'
                                ),
                  'Field K'       =>   array('name' => '$output_field_value = substr($product['products_model'], 1) . ';' . $product['products_model'];',
                                                      'type' => 'LOGIC'
                                ),
                  'Unique Code'   =>   array('name' => 'products_id',
                                                      'type' => 'DB'
                                   ),
                  'Description'   =>   array('name' => 'products_description',
                                                     'type' => 'DB',
                                             'options' => array('STRIP_HTML', 'HTML_ENTITIES', 'STRIP_CRLF')
                                ),
                  'Promotion'     =>   array('name' => 'BLANK',
                                                      'type' => 'KEYWORD'
                                ),
                  'Image'         =>   array('name' => 'FEED_IMAGE_URL',
                                                     'type' => 'KEYWORD'
                                  ),
                  'Product URL'   =>   array('name' => 'FEED_PRODUCTS_URL',
                                                      'type' => 'KEYWORD'
                                ),
                  'Price'         =>   array('name' => 'FEED_PRICE_WITHOUT_TAX',
                                                     'type' => 'KEYWORD'
                                    ),
                  'Delivery Cost' =>   array('name' => '$output_field_value = $product['products_price'] < 50 ? 3.95 : 0;',
                                              'type' => 'LOGIC'
                              ),
                  'Delivery Time' =>   array('name' => '$output_field_value = preg_match('#simply wedds#i', $product['products_name']) ? 'Up to three weeks' : '1-6 working days';',
                                             'type' => 'LOGIC'
                              ),
                  'Availability'  =>   array('name' => ' Available on Order',
                                                      'type' => 'VALUE'
                                ),
                  'Warranty'      =>   array('name' => 'BLANK',
                                                      'type' => 'KEYWORD'
                                ),
                  'Condition'     =>   array('name' => 'BLANK',
                                                      'type' => 'KEYWORD'
                                ),
                  'Offer Type'    =>   array('name' => 'BLANK',
                                                      'type' => 'KEYWORD'
                                ),
                  'Bid'           =>   array('name' => 'BLANK',
                                                      'type' => 'KEYWORD'
                                )
                  ),
         'language_id' => 3,
         'add_field_names' => false,
         'category_output_type' => 3,
                 'category_seperator' => '>',
         'seperator' => "t",
         'text_qualifier' => '',
         'newline' => "n",
         'encoding' => 'utf8'
       );


//END OF CONFIGURATION
///////////////////////////////////////////////////////////////////////////////////////
//The two functions below can be modified/extended to to modify/extend functionality

function field_generator(&$product, &$db_field_name, &$cur_feed) {

  switch( $db_field_name  ) {
    case 'FEED_PRODUCTS_URL':
   $output_field_value = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product['products_id'], 'NONSSL', false);
    break;
  case 'FEED_IMAGE_URL':
    $output_field_value = HTTP_SERVER . DIR_WS_HTTP_CATALOG . DIR_WS_IMAGES . $product['products_image'];
   break;
  case 'FEED_CATEGORY':
   if( $cur_feed['category_output_type'] == 2 ) {
      generate_category_path($product['categories_id'], $cur_feed['category_seperator'], false, $output_field_value);
   }
   elseif( $cur_feed['category_output_type'] == 3 ) {
      generate_category_path($product['categories_id'], $cur_feed['category_seperator'], true, $output_field_value);
    }
   else { //assume 1
     $output_field_value = $product['categories_name'];
    }
   break;
    case 'FEED_PRICE_WITHOUT_TAX':
    $output_field_value = round($product['products_price'], 2);
   break;

// PRECIO EN DOLARES 
    case 'FEED_DOLLAR_PRICE_WITHOUT_TAX':
    $cx=new currencyExchange();
    $cx->getData();
    $temporal = $euro=$cx->Convert('EUR','USD',$product['products_price']);
    $output_field_value = number_format($temporal,2);
   break; 
// PRECIO EN DOLARES   
   
    case 'FEED_PRICE_WITH_TAX':
   $output_field_value = round($product['products_price'] * (1 + tep_get_tax_rate($product['products_tax_class_id'])/100), 2);
   break;
  case 'FEED_BLANK':
    default:
    $output_field_value = '';
   break;
  }
 
  return $output_field_value;
 
}

function process_field_value($field_value, &$field_options) {
 
  if( in_array('STRIP_XHTML', $field_options) ) {
 $field_value = preg_replace('#<([^s]*+).*?>(.*?)</1>#i', '$2', $field_value);
 $field_value = preg_replace('#<.*? />#i', ' ', $field_value);
  }
  elseif( in_array('STRIP_HTML', $field_options) ) {
    $field_value = preg_replace('#</?.*?>#i', ' ', $field_value);
  }
  if( in_array('HTML_ENTITIES', $field_options) ) {
    $field_value = htmlentities($field_value);
  }
  if( in_array('STRIP_CRLF', $field_options) ) {
  $field_value = preg_replace('#[\040\011]*+[nr]+[\040\011]*#s', ' ', $field_value);
  }
 
  return $field_value;
 
}



function generate_category_path($categories_id, &$cat_sep, $top_only = false, &$cat_path) {

  if( !$cat_path || $cat_path == NULL ) {
  $cat_path = '';
  }
 
 
  $query = tep_db_query('SELECT c.parent_id, cd.categories_name FROM osc_categories c, osc_categories_description cd WHERE c.categories_id = cd.categories_id AND c.categories_id = '' . (int)$categories_id . '' AND cd.language_id = '' . 3 . ''');
  $cat_info = tep_db_fetch_array($query);
 
  if( !$cat_info['parent_id'] || !$top_only ) {
    $cat_path = ' ' . $cat_sep . ' ' . $cat_info['categories_name'] . $cat_path;
  }
   
  if( $cat_info['parent_id'] ) {
  generate_category_path($cat_info['parent_id'], $cat_sep, $top_only, $cat_path);
  }
  else {
  $cat_path = substr($cat_path, strlen($cat_sep)+2);
  }

}

$save_path = DIR_FS_CATALOG . SAVE_LOCATION;

if( !file_exists($save_path) ) {
  echo 'The SAVE_LOCATION directory: ' . SAVE_LOCATION . ' does not exist in ' . DIR_FS_CATALOG . '. Please create this directory or change the
  path to an existing directory';
  exit;
}

foreach( $feeds as $feed ) {
  if( isset($feed_common_lang) ) {
    if( $feed['language_id'] !== $feed_common_lang ) {
      $feed_common_lang = false;
    break;
  }
  }
  else {
    $feed_common_lang = $feed['language_id'];
  }
}

$master_query = tep_db_query('SELECT p.*, pd.*, ptc.*, c.*, cd.*, m.*, mi.*
                              FROM osc_products p LEFT JOIN osc_products_description pd ON p.products_id = pd.products_id
                                LEFT JOIN osc_manufacturers m ON p.manufacturers_id = m.manufacturers_id
                            LEFT JOIN osc_manufacturers_info mi ON m.manufacturers_id = mi.manufacturers_id AND pd.language_id = mi.languages_id
                              LEFT JOIN osc_products_to_categories ptc ON p.products_id = ptc.products_id
                             LEFT JOIN osc_categories c ON ptc.categories_id = c.categories_id
                       LEFT JOIN osc_categories_description cd ON c.categories_id = cd.categories_id AND pd.language_id = cd.language_id
               WHERE p.products_status = 1
                 AND p.products_price > 0
                ' . ( $feed_common_lang !== false ? 'AND pd.language_id = ' . $feed_common_lang : '' ) . '
                ORDER BY p.products_id, c.categories_id');

$i=0;
$fields = array();
while( $i < mysql_num_fields($master_query) ) {
  ++$i;
  $cur_field = mysql_fetch_field($master_query);
  $fields[] = $cur_field->name;
}

$output = array();
foreach( $feeds as $cur_feed_id => $cur_feed ) {
  $output[$cur_feed_id] = '';
  foreach( $cur_feed['fields'] as $output_field_name=>$db_field ) {
    if( $db_field['type'] == 'DB' && !in_array($db_field['name'], $fields) ) {
    echo 'The field ' . $db_field['name'] . ' specified in the ' . $cur_feed['filename'] . ' feed does not exist in either the products table
          or products_description table';
    exit;
 }
 elseif( $cur_feed['add_field_names'] ) {
    $output[$cur_feed_id] .= $cur_feed['seperator'] . $output_field_name;
 }
  }
  $output[$cur_feed_id] = substr($output[$cur_feed_id], strlen($cur_feed['seperator'])) . ( $cur_feed['add_field_names'] ? $cur_feed['newline'] : '' );
}

$prev = array('products_id' => '', 'language_id' => '');
while( $product = tep_db_fetch_array($master_query) ) {
 
  // In case some products are listed in more than one category, just take one instance (as oppose to repeating in the feed)
  // (FIND way to do this in the query)
  if( $prev['products_id'] == $product['products_id'] && $prev['language_id'] == $product['language_id'] ) continue;
  $prev['products_id'] = $product['products_id'];
  $prev['language_id'] = $product['language_id'];
  //
 
  foreach( $feeds as $cur_feed_id => $cur_feed ) {
 
  if( $cur_feed['language_id'] != $product['language_id'] ) continue;
 
  $output_line = '';
 
  foreach( $cur_feed['fields'] as $output_field_name=>$db_field ) {
   $output_field_value = '';
   switch( $db_field['type'] ) {
     case 'DB':
      $output_field_value = $product[$db_field['name']];
      break;
      case 'KEYWORD':
       $output_field_value = field_generator($product, $db_field['name'], $feeds[$cur_feed_id]);
     break;
      case 'LOGIC':
       eval($db_field['name']);
      break;
      case 'VALUE':
   default:
        $output_field_value = $db_field['name'];
      break;
    }
   
    if( isset($db_field['options']) ) $output_field_value = process_field_value($output_field_value, $db_field['options']);
      if( isset($db_field['filters']) && is_array($db_field['filters']) ) {
      $output_field_value = preg_replace($db_field['filters']['patterns'], $db_field['filters']['replacements'], $output_field_value);
    }
   
    $output_field_value = empty($cur_feed['text_qualifier']) ? preg_replace('#[' . $cur_feed['seperator'] . $cur_feed['newline'] . ']+#s', ' ', $output_field_value) : preg_replace('#' . $cur_feed['text_qualifier'] . '#s', $cur_feed['text_qualifier'] . $cur_feed['text_qualifier'], $output_field_value);
   
    $output_line .= $cur_feed['seperator'] . $cur_feed['text_qualifier'] . $output_field_value . $cur_feed['text_qualifier'];
   
  }
 $output[$cur_feed_id] .= substr($output_line, strlen($cur_feed['seperator'])) . $cur_feed['newline'];
  }

}

foreach( $output as $cur_feed_id => $cur_feed ) {
  $file = $save_path . $feeds[$cur_feed_id]['filename'];
  if( file_exists($file) ) {
    if( BACK_UP_OLD_FEEDS ) {
   $old_file_last_modified = date('Y-m-d-H.i.s', filemtime($file));
    $file_info = array();
   preg_match('#^(.*?)(..*?)?$#', $feeds[$cur_feed_id]['filename'], $file_info);
   rename($file, $save_path . $file_info[1] . '-' . $old_file_last_modified . ( isset($file_info[2]) ? $file_info[2] : '' ));
  }
 else {
    unlink($file);
  }
  }
 
  if( !empty($feeds[$cur_feed_id]['encoding']) && $feeds[$cur_feed_id]['encoding'] !== false ) {
    switch( $feeds[$cur_feed_id]['encoding'] ) {
    case 'utf8':
    $cur_feed = utf8_encode($cur_feed);
   break;
  }
  }
   
  $fp = fopen($file, 'a');
  $fwrite = fwrite($fp, $cur_feed);
  fclose($fp);
  chmod($file, 0777);
}

echo 'done.' . "nn";

require('includes/application_bottom.php');

?>

Kind to this lines, are language ID and encoding:
Code: Tout sélectionner
'language_id' => 3,

'encoding' => 'utf8'

This is a sample code. I've create two files, one for english and other for spanish. This is for spanish lang (on my shop ID=3), and create four files:

froogle-espanol-dollar.txt
froogle-espanol-euro.txt
kelkoo-espanol.txt
shopping.com-espanol.txt


Froogle and Shopping.com aren't for Euro market, you can modify this files for show the prices in U.S. Dollar, U.K. Pounds...
Dernière édition par nequaquam le Dim 30 Juil 2006, 23:26, édité 1 fois.
_______________________________________________________________________________

Website: nequaquam
osCSS shop in development: pugnae
nequaquam
Membre actif
 
Messages: 48
Inscription: Mer 08 Fév 2006, 12:40
Localisation: Barcelona

Messagepar nequaquam » Lun 31 Juil 2006, 07:05

Also I've added it to RSS Feed. See the attached screenshot of RSSOwl:

Image
_______________________________________________________________________________

Website: nequaquam
osCSS shop in development: pugnae
nequaquam
Membre actif
 
Messages: 48
Inscription: Mer 08 Fév 2006, 12:40
Localisation: Barcelona

Messagepar sidarus » Lun 31 Juil 2006, 11:00

Exellent nequaquam. Can you put it directly in the plugin wiki section ?

[ESP] Exelente nequaquam. Puedes ponerlo directamente en la section plugin del wiki ?

+[sticky] :)
sidarus
Membre très actif
 
Messages: 396
Inscription: Mar 03 Mai 2005, 23:34
Localisation: Geneva (CH)

Messagepar nequaquam » Lun 31 Juil 2006, 13:16

Yes, when finishes my work (I am very occupied) I will make a package and I will put it in the Wiki. ;)

[ESP] Si, cuando acabe mi trabajo (estoy muy ocupado) haré un paquete i lo pondré en el Wiki. ;) ;) ;)
Dernière édition par nequaquam le Lun 31 Juil 2006, 13:18, édité 1 fois.
_______________________________________________________________________________

Website: nequaquam
osCSS shop in development: pugnae
nequaquam
Membre actif
 
Messages: 48
Inscription: Mer 08 Fév 2006, 12:40
Localisation: Barcelona

Messagepar sidarus » Mar 01 Aoû 2006, 20:15

The wiki is waiting for your stuff :: osc:plugin:auto_update_currencies :D
sidarus
Membre très actif
 
Messages: 396
Inscription: Mar 03 Mai 2005, 23:34
Localisation: Geneva (CH)

Messagepar Lowpoint » Sam 22 Déc 2007, 19:39

Is this dead, I'm really interested in the best option to auto update!


thanks for any help!


Adrian
Lowpoint
Membre inactif
 
Messages: 2
Inscription: Sam 22 Déc 2007, 19:21


Retourner vers Plugin

 


  • Articles en relation
    Réponses
    Vus
    Dernier message

Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 1 invité

cron