4images Forum & Community
4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: arnoud on July 25, 2002, 12:58:26 PM
-
Hello
I'm testing the image gellery script and it's working perfect.
I want to use this script to give our customers an overview of our products, up to now I have found a solution for almost everything in your script.
I have added one userdefiendfield where I put in the price of a product. (note: I don't want to make a webshop only a product overview with a price).
Now the problem: I want to show different prices for 2 different usergroups. This is also not a problem but you have to know that to understand the problem. We want to add one price, the other price must be recalculated and by example 10% higher.
I have already tried to make a querie but I don't get the output in the script.
A javascript can also be a solution: by example the JS reads the userdefiendfield value and recalculate the new price, by this I have the problem that JS calculate with a decimal point, so we need the prices serperated by a decimal comma.
I hope someone can give an advice.
Thanks a lot!
Arnoud
P.S. We will buy this script when we have found a solution!
-
PHP also calculates with decimal point. Simple solution after calculating:
$price = str_replace(".", ",", $price);
Greets Jan
-
Thanks for you fast reaction,
Is there maybe a possibility to make a change in an included php script, that makes a new value by example:
{price1} database value.
{price2} value after php formula.
I hope there is.
Thanks a lot
-
Can you post exactly what you defined in "includes/db_field_definitions.php"?
Jan
-
Of course,
This is what the db_field_definitions.php looks like, here I use different amountprices.
$additional_image_fields['amout1'] = array($lang['amount1'], "text", 1);
$additional_image_fields['price1'] = array($lang['price1'], "text", 1);
$additional_image_fields['amount2'] = array($lang['amount2'], "text", 1);
$additional_image_fields['price2'] = array($lang['price2'], "text", 1);
$additional_image_fields['amount3'] = array($lang['amount3'], "text", 1);
$additional_image_fields['price3'] = array($lang['price3'], "text", 1);
But to make it not to difficult I think it is better to sea firt only the following sense:
$additional_image_fields['price1'] = array($lang['price1'], "text", 1);
-
Ok, maybe this is what you want.
Open "include/functions.php" and search for this line:
$additional_field_array[$key] = (!empty($image_row[$key])) ? format_text($image_row[$key], 1) : REPLACE_EMPTY;
Replace this line with:
if ($key == "price1") {
if (!empty($image_row['price1'])) {
$price1 = $image_row['price1'];
// $price1_2 = $price1 + 10%
$price1_2 = $price1 + (($price1 / 100) * 10);
$price1 = str_replace(".", ",", $price1);
$price1_2 = str_replace(".", ",", $price1_2);
}
else {
$price1 = REPLACE_EMPTY;
$price1_2 = REPLACE_EMPTY;
}
$additional_field_array['price1'] = $price1;
$additional_field_array['price1_2'] = $price1_2;
}
else {
$additional_field_array[$key] = (!empty($image_row[$key])) ? format_text($image_row[$key], 1) : REPLACE_EMPTY;
}
Then you can use {price1} and {price1_2} in your template.
Note: You have to enter the prices with decimal point in your Control Panel.
Greets Jan
-
Thanks, :D
It works!
I will ask the responsible person in our company, to order those scripts as soon as possible.
-
Hello Jan,
Can I read in the value "amount of next pages. saved in the settings menu" In the above script, functions.php.
I want to use that field for a currency amount instead of the next pages.
How can I read in this value
Thanks a lot, please help me!
-
Sorry, i don't understand exactly what you mean.
Jan
-
Jan,
$price1_2 = $price1 + (($price1 * DOLLARCURRENCY) * 1,5);
This is a row out of my functions.php, in this row I want to change the word DOLLARCURRENCY by a value that I can type in, in the setting screen of this script.
Is it by example possible to change the field amountofnextpages in the settings menu, so I type in this field the dollarcurrency?
And how can I read in this value in the script functions.php on the place of the word DOLLARCURRENCY.
I hope you can understand, it is dificult to explain, but I think there must be a simple solution.
I hope you can help me.
-
Try:
global $HTTP_GET_VARS, $HTTP_POST_VARS
if (isset($HTTP_GET_VARS['dollarcurrency']) || isset($HTTP_POST_VARS['dollarcurrency'])) {
$dollarcurrency = (isset($HTTP_GET_VARS['dollarcurrency'])) ? intval($HTTP_GET_VARS['dollarcurrency']) : intval($HTTP_POST_VARS['dollarcurrency']);
}
else {
$dollarcurrency = 0; // default value of dollarcurrency
}
The field name on the details page must be "dollarcurrency".
Jan
-
Must I place the script in the admin\settings.php or something?
How else can I type in the dollar value in a textbox in the setting menu, and use it later in the formula in the functions.php script.
Sorry when I'm not clear enough,
-
Ok, i hope this is what you need:
Add a new entry to your 4images_settings table in the database. Maybe use phpMyadmin with this query:
INSERT INTO 4images_settings (setting_name, setting_value) VALUES ('dollarcurrency', '100');
Then open "admin/settings.php" and add after
show_setting_row("gz_compress_level");
this line
show_setting_row("dollarcurrency");
Then use in the function show_image() in "includes/functions.php":
$config['dollarcurrency']
to use the value from the settings.
Example:
$price1_2 = $price1 + (($price1 * $config['dollarcurrency']) * 1,5);
Greets Jan