Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

changing currency drop down to flag images


facelessface

Recommended Posts

Posted

I currently have a currency drop down on my site, to choose between 3 currencies - euros, pounds and usd.

 

I want to replace this drop down with 3 flags -for a more attractive way of displaying the selection. Do you have any ideas how I would go about doing this?

 

Basically all i need is some kind of hyperlink that will modify the php variable which stores the current currency..

 

thanks

 

mike

my sites:

----------

www.preciousmetal-online.co.uk

www.liparazzi.com

www.yaoh.co.uk

Posted

Anyone have any advice? i'm supposed to be going live with these changes tonight..

my sites:

----------

www.preciousmetal-online.co.uk

www.liparazzi.com

www.yaoh.co.uk

Posted

still looking for an answer.. I just need a way of changing the current currency via a hyperlink..

 

Can't be that hard, but am stumped.. :blink:

my sites:

----------

www.preciousmetal-online.co.uk

www.liparazzi.com

www.yaoh.co.uk

Posted

try to replace you file includes/boxes/currencies.php with that :

if (isset($currencies) && is_object($currencies)) {
?>
<!-- currencies //-->
	 <tr>
	   <td>
<?php
  $info_box_contents = array();
  $info_box_contents[] = array('text' => BOX_HEADING_CURRENCIES);

  new infoBoxHeading($info_box_contents, false, false);

  $hidden_get_variables = '';
  reset($HTTP_GET_VARS);
  while (list($key, $value) = each($HTTP_GET_VARS)) {
 if ( ($key != 'currency') && ($key != tep_session_name()) && ($key != 'x') && ($key != 'y') ) {
   $hidden_get_variables .= tep_draw_hidden_field($key, $value);
 }
  }

  reset($currencies->currencies);
  $currencies_array = array();
  while (list($key, $value) = each($currencies->currencies)) {
 $currencies_string .= ' <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('currency')) . 'currency=' . $key, $request_type) . '">' . $value['title'] . '</a> ';
  }

  $info_box_contents = array();
  $info_box_contents[] = array('align' => 'center',
							'text' => $currencies_string);

  new infoBox($info_box_contents);
?>
	   </td>
	 </tr>
<!-- currencies_eof //-->
<?php
}
?>

 

this is a "rude" piece of code, to be tested

MS2 2.2 fr + Manufacturer copy (5 manufacturers - modified to make it works) + More pics 6 + FCK Editor + zones shipping (modified without weight) + My contribution : Shopping Cart Management for Unique Products

 

I apologize in advance for my poor English I'm French !

  • 3 weeks later...
Posted

hi i've got the hyperlinks to work but how do i configure it for flag images?

 

incidentally, what would the code be to have a bright flag for the active currency and darkened flags for inactive currencies? (given that i'd need 2 images per flag)

 

hope someone can help

 

paul

Posted

you can find out the selected currency using the $currency global var.

The $currencies array contains the value in the title field So you add some code in the currencies while loop:

 

if( $currency == $currencies[$key]['title'] ) {

//Display selected

} else {

// Display non-selected

}

Posted

hi pal

 

thanks for the reply

 

i've only started getting into php and the above to me is pretty foreign. how do i include it in the code? also how would it know the filename of the flag to display?

 

thanks, paul

Posted

I was under the impression you had something already in place. Well the best way is to create one or two image columns in the currencies table so each currency willl also have an image associated with. Once you have the dbase set then you create a box file with something like this.

 

<?php
/*
 $Id: currencies.php,v 1.16 2003/02/12 20:27:31 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 if (isset($currencies) && is_object($currencies)) {
?>
<!-- currencies //-->
	  <tr>
		<td>
<?php
$info_box_contents = array();
$info_box_contents[] = array('text' => BOX_HEADING_CURRENCIES);

new infoBoxHeading($info_box_contents, false, false);

$hidden_get_variables = '';
reset($currencies->currencies);
while (list($key, $value) = each($currencies->currencies) ) {

  if( $currency == $currencies[$key]['title'] ) {
	$hidden_get_variables .= ' <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('language', 'currency')) . 'language=' . $key, $request_type) . '">' . tep_image(DIR_WS_IMAGES . $value['image1'], $value['title']) . '</a> ';
  else
	$hidden_get_variables .= ' <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('language', 'currency')) . 'language=' . $key, $request_type) . '">' . tep_image(DIR_WS_IMAGES . $value['image2'], $value['title']) . '</a> ';
}

 $info_box_contents[] = array('align' => 'center',
						   'text' => $hidden_get_variables);


new infoBox($info_box_contents);
?>
		</td>
	  </tr>
<!-- currencies_eof //-->
<?php
 }
?>

You have to get a bit into php and mysql to achieve it though. You could check how the languages box and table is setup to include and display the images.

Posted

hi mark

 

i've added everything as you said but i'm getting the error:

 

Parse error: parse error, unexpected T_ELSE

 

in /...../boxes/currencies.php on line 30

 

any ideas?

Posted

yea there is an extra opening bracket {

 

this:

if( $currency == $currencies[$key]['title'] ) {

 

should been

if( $currency == $currencies[$key]['title'] )

 

Also you need to setup the database sql table for the currency to hold images before deploying such code. And this is only a sample. Needs further work to be usable. I just used some code from the languages box to glue it together. Haven't tested it or anything

Posted

still same message mate. i've added image1 and image2 fields to currencies, i just copied the same attributes as in languages. filenames added to fields and images uploaded to the images folder.

 

what further work is needed to make it useable?

Posted

Ok,.... here is a box that works I tried it.

 

/*
 $Id: currencies.php,v 1.16 2003/02/12 20:27:31 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

<?php
 if (isset($currencies) && is_object($currencies)) {
?>
<!-- currencies //-->
	  <tr>
		<td>
<?php

$info_box_contents = array();
$info_box_contents[] = array('text' => BOX_HEADING_CURRENCIES);

new infoBoxHeading($info_box_contents, false, false);

reset($currencies->currencies);
$currencies_array = array();
while (list($key, $value) = each($currencies->currencies)) {
  $currencies_array[] = array('id' => $key, 'text' => $value['title']);
}

$hidden_get_variables = '';
reset($currencies->currencies);

while (list($key, $value) = each($currencies->currencies) ) {
  if( $currency == $key )
	$hidden_get_variables .= ' <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('language', 'currency')) . 'language=' . $key, $request_type) . '">' . tep_image(DIR_WS_IMAGES . $value['image1'], $value['title']) . '</a> ';
  else
	$hidden_get_variables .= ' <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('language', 'currency')) . 'language=' . $key, $request_type) . '">' . tep_image(DIR_WS_IMAGES . $value['image2'], $value['title']) . '</a> ';
}

$info_box_contents = array();
 $info_box_contents[] = array('align' => 'center',
						   'text' => $hidden_get_variables);


new infoBox($info_box_contents);

?>
		</td>
	  </tr>
<!-- currencies_eof //-->
<?php
 }
?>

Posted

also set the currency not the language in the tep_href_link calls

 

from:

'language='

to:

'currency='

Posted

i've applied the new code with the currency tep_href_link calls and also added <?php and ?> around the top as it wasn't displaying properly but still no images.

 

the error message has gone and the box is displaying correctly but no flags. i've double checked the database and images folder: image1 and image2 are the field names and the filenames correspond with what's in the images folder but still no go.

 

what do you think?

Posted

have you moded the currencies sql table to add the image column(s)? Where is the sql code you did?

Posted

i just inserted 2 fields manually and copied how the languages image field was set out:

 

field | type | collation | attributes | null | default | extra

image1 | varchar(64) | latin1_general_ci | | Yes | NULL |

image2 | varchar(64) | latin1_general_ci | | Yes | NULL |

Posted

ok have you populated the currency entries with the image filenames? You need to do that too. Then place the images for the currencies in the image directory and test it.

Posted

if you right-click the currency image placeholders what the properties show. Does it show a valid link? you have a url?

Posted

yes you need to change the currencies class. catalog\includes\classes\currencies.php expand the query to include the image1 and image2 columns and for the currencies array just beneath it do the same.

Archived

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

×
×
  • Create New...