I want to use a form like the code I am providing so that a site visitor can take a price quote by choosing what facilities he wants. But I do not want any prices to be displayed I want prices to be sent by email:
Is it possible to do this ?
<form>
<table width="421">
<tr>
<td width="24">
<input value="Machine_cost....*85,000$" size="35" class=" validate['required']" name="Machine cost" id="Machine cost" type="hidden" checked /></td>
<td width="150">REASON</td>
<td>Patient Documentation</td>
<td><font color="BLUE"><strong>Item 10</strong> :</font></td>
<td><strong>-</strong></td>
</tr>
<tr>
<td><input type="checkbox" id="Network Monitoring" name="Network Monitoring" value="Network_Monitoring....*200.00$" /></td>
<td>User and Admin control</td>
<td><font color="BLUE"><strong>Item 11</strong> :</font></td>
<td><strong>-</strong></td>
</tr>
<tr>
<td><input type="checkbox" id="Voice guiding" name="Voice guiding" value="Voice_guiding....*210.00$" /></td>
<td>Audible voice guideance</td>
<td><font color="BLUE"><strong>Item 12</strong> :</font></td>
<td><strong>-</strong></td>
</tr>
<tr>
<td colspan=4 align=left>
<input type=submit value="Order">
</td>
</tr>
</table>
</form>
I am also trying to use the java script:
function decodeString() {
valNum = new Array();
valData = new Array();
var string, length, dataCount, orderData, grandTotal; string = "" + unescape(location.search); string = string.substring(1,string.length);
length = location.search.length;
orderData = "";
dataCount = 1;
for (var c = 0; c < string.length; c++)
if (string.charAt(c).indexOf("&") != -1) dataCount++;
orderData = "<table border=1 width=400>"; orderData += "<tr><td>Item</td><td>Description</td><td>Cost</td></tr>";
grandTotal = 0;
for (var i = 0; i < dataCount; i++)
{
string = string.substring(ampd+1,string.length);
orderData += "<tr>";
orderData += "<input type=hidden name=item" + (i+1) + "num value='" + itemnum + "'>"; orderData += "<input type=hidden name=item" + (i+1) + "dsc value='" + itemdsc + "'>"; orderData += "<input type=hidden name=item" + (i+1) + "cst value='$" + itemcst + "'>"; orderData += "<td>" + itemnum + "</td>"; orderData += "<td>" + itemdsc + "</td>"; orderData += "<td>" + itemcst + "</td>"; orderData += "</tr>"; grandTotal += parseInt(itemcst); } orderData += "<tr>"; orderData += "<td colspan=2 align=center>Total</td><td>" + grandTotal + ".00</td>"; orderData += "</tr>"; orderData += "<tr>"; orderData += "<td colspan=3 align=center><input type=submit value='Confirm Order!'> or <a href='javascript:history.go(-1)'>Go Back</a></td>"; orderData += "</tr>"; orderData += "<input type=hidden name=grandtotal value='$" + grandTotal + ".00'>"; orderData += "</table>"; document.write(orderData); }
function openThanks() {
}
I am not able to succeed as I have very little knowledge of coding.
Thanks for any possible help.
Ron
You can add prices after the form is submitted by looking them up from a table or array in the OnSubmit Before Email box (in CFv3) or a Custom Code action (in CFv4).
I'm sorry, I haven't the slightest idea what the script is intended to do.
Bob
If we are talking CFv3, I'd probably add some php-code to the email template to do the magic:
Form code:
<form>
<table width="421">
<th>
<td></td>
<td width="150px">Reason</td>
<td>Item</td>
<td>Something</td>
</th>
<tr>
<td><input type="checkbox" value="1" name="MachineCost" id="MachineCost" checked="checked" disabled="disabled" /></td>
<td>Patient Documentation (mandatory)</td>
<td><font color="BLUE"><strong>Item 10</strong> :</font></td>
<td><strong>-</strong></td>
</tr>
<tr>
<td><input type="checkbox" id="NetworkMonitoring" name="NetworkMonitoring" value="1" /></td>
<td>User and Admin control</td>
<td><font color="BLUE"><strong>Item 11</strong> :</font></td>
<td><strong>-</strong></td>
</tr>
<tr>
<td><input type="checkbox" id="VoiceGuiding" name="VoiceGuiding" value="1" /></td>
<td>Audible voice guideance</td>
<td><font color="BLUE"><strong>Item 12</strong> :</font></td>
<td><strong>-</strong></td>
</tr>
<tr>
<td colspan=4 align=left>
<input type=submit value="Order">
</td>
</tr>
</table>
</form>
And the Email template (you'll have to disable the Template Editor in the email setup to add php-tags):
Hi ...,
Your order is as follows:
Machine Cost: *85,000$
<?php
$totals = 85000;
if (!empty($_POST['NetworkMonitoring']))
{
echo("\nNetwork Monitoring: *200$");
$totals += 200;
}
if (!empty($_POST['VoiceGuiding']))
{
echo("\nVoice Guiding: *210$");
$totals += 210;
}
echo( "\nTotal: *" . $totals . "\$");
?>
...
Please have a nice day,
...and so on...
I've modified the form code, as it is not adviceable to use spaces in the form field names.
Also, as I havn't used CFv4, I can't tell if this technique is useable there.
/Fredrik
That was a nice reply. I could understand it but. I have a test site on which I am trying the V4. I have used Java Script to do this. and I am successful except that I have a few issues. Like for example look at this code:
<li><label for="siso_treatment_mode"><font color="BLUE"><strong>SISO Treatment Mode</strong> : </font></label>
<input type="checkbox" value="6000.00" onClick="this.form.total.value=CheckChoice(this);" name="stm" id="stm" /></li>
<li><label for="arm_cuffs"><font color="BLUE"><strong>Arm Cuffs</strong> : </font> </label>
<input type="checkbox" value="1290.00" onClick="this.form.total.value=CheckChoice(this);" name="ac" id="ac" /></li>
<li><label for="outdoor_unit_automation"><font color="BLUE"><strong>Outdoor-unit Automation</strong> : </font></label>
<input type="checkbox" value="4020.00" onClick="this.form.total.value=CheckChoice(this);" name="oua" id="oua"/></li>
These check boxes above when I get an email reply for the check boxes chosen giving the value I am also trying to take a breakup of how the total value was reached:
So I get:
1. SISO treatment Mode : {stm}
2. Arm Cuffs : {ac}
3. Outdoor Unit Automation : {oua}
TOTAL
Now If some one chooses {stm} and dose not choose {ac} and {oua}. So what reply me or the chooser gets:
1. SISO treatment Mode : 6000.00
2. Arm Cuffs : {ac}
3. Outdoor Unit Automation : {oua}
TOTAL 6000.00
Now I do not want {ac} and {oua} displayed. It does not look professional.I want only the value to be displayed. To display the values of check boxes chosen I am using the following java script:
// Get Checkbox checked status
function GetCheckBoxValue(id)
{
alert(document.getElementById(id).checked);
}
Is it possible to may be change this java script that if a check box is chosen It displays the value and if not it displays the name.
Thanks
Sorry for the delay.. I've been out of town hunting for a week.
To the issue though; the problem at hand is the way browsers handle checkboxes. Unlike other form inputs, they're only included in the form submission is they're checked. The way CF currently works, it will only substitute {fieldname} if there is such a form input included in the submission.
The simplest way to work around this, is not to use the {fieldname} feature in your email template, but a php-snippet such as this:
<?php if (!empty($_POST['fieldname'])) echo($_POST['fieldname']); ?>
It'd take some coding to work around this using javascript, since changing the value of the checkbox would have no effect as long as the checkbox isn't checked.. You could probably have a hidden input; which you update using javascripts, and use in your email template instead - though this would break on non-javascript enabled browsers...
/Fredrik
So my email to admin should be like this:
<p>Hello Admin</p>
<p>Â </p>
<p>This is a test email. The form is still being set.</p>
<table width="295" border="0">
<tr>
<th width="25" scope="row">1</th>
<td width="179">Main Equipment.</td>
<td width="77"><?php if (!empty($_POST['be']) echo($_POST['be']); ?></td>
</tr>
<tr>
<th scope="row">2</th>
<td>Massaging mattress</td>
<td><?php if (!empty($_POST['mm']) echo($_POST['mm']); ?></td>
</tr>
<tr>
<th scope="row">3</th>
<td>Heated Mattress</td>
<td><?php if (!empty($_POST['hm']) echo($_POST['hm']); ?></td>
</tr>
<tr>
<th scope="row">4</th>
<td>Low voltage system</td>
<td><?php if (!empty($_POST['lvs']) echo($_POST['lvs']); ?></td>
</tr>
<tr>
<th scope="row">5</th>
<td>SISO Treatment Mode</td>
<td><?php if (!empty($_POST['stm']) echo($_POST['stm']); ?></td>
</tr>
<tr>
<th scope="row">6</th>
<td>Outdoor unit Automation</td>
<td><?php if (!empty($_POST['oua']) echo($_POST['oua']); ?></td>
</tr>
<tr>
<th scope="row">7</th>
<td>Multi-lingual display</td>
<td><?php if (!empty($_POST['nld']) echo($_POST['nld']); ?></td>
</tr>
<tr>
<th scope="row">8</th>
<td>Wifi control capability</td>
<td><?php if (!empty($_POST['wcc']) echo($_POST['wcc']); ?></td>
</tr>
<tr>
<th scope="row">9</th>
<td> Bigger HM Interface</td>
<td><?php if (!empty($_POST['bhi']) echo($_POST['bhi']); ?></td>
</tr>
<tr>
<th scope="row">10</th>
<td>Thermal Printer</td>
<td><?php if (!empty($_POST['tp']) echo($_POST['tp']); ?></td>
</tr>
<tr>
<th scope="row">11</th>
<td>Network Monitoring</td>
<td><?php if (!empty($_POST['nm']) echo($_POST['nm']); ?></td>
</tr>
<tr>
<th scope="row">12</th>
<td>Voice guiding</td>
<td><?php if (!empty($_POST['vg']) echo($_POST['vg']); ?></td>
</tr>
<tr>
<th scope="row">13</th>
<td>Arm Cuffs</td>
<td><?php if (!empty($_POST['ac']) echo($_POST['ac']); ?></td>
</tr>
<tr>
<th scope="row">Â </th>
<td><strong>Total Price</strong></td>
<td><strong>{total}</strong></td>
</tr>
</table>
<p>Thias i only a test</p>
<p>Wesite</p>
instead of this ?
<p>Hello Admin</p>
<p>Â </p>
<p>This is a test email. The form is still being set.</p>
<table width="295" border="0">
<tr>
<th width="25" scope="row">1</th>
<td width="179">Main Equipment.</td>
<td width="77">{be}</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Massaging mattress</td>
<td>{mm}</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Heated Mattress</td>
<td>{hm}</td>
</tr>
<tr>
<th scope="row">4</th>
<td>Low voltage system</td>
<td>{lvs}</td>
</tr>
<tr>
<th scope="row">5</th>
<td>SISO Treatment Mode</td>
<td>{stm}</td>
</tr>
<tr>
<th scope="row">6</th>
<td>Outdoor unit Automation</td>
<td>{oua}</td>
</tr>
<tr>
<th scope="row">7</th>
<td>Multi-lingual display</td>
<td>{mld}</td>
</tr>
<tr>
<th scope="row">8</th>
<td>Wifi control capability</td>
<td>{wcc}</td>
</tr>
<tr>
<th scope="row">9</th>
<td> Bigger HM Interface</td>
<td>{bhi}</td>
</tr>
<tr>
<th scope="row">10</th>
<td>Thermal Printer</td>
<td>{tp}</td>
</tr>
<tr>
<th scope="row">11</th>
<td>Network Monitoring</td>
<td>{nm}</td>
</tr>
<tr>
<th scope="row">12</th>
<td>Voice guiding</td>
<td>{vg}</td>
</tr>
<tr>
<th scope="row">13</th>
<td>Arm Cuffs</td>
<td>{ac}</td>
</tr>
<tr>
<th scope="row">Â </th>
<td><strong>Total Price</strong></td>
<td><strong>{total}</strong></td>
</tr>
</table>
<p>Thias i only a test</p>
<p>Wesite</p>
When I do this I get a blank email reply.
Ron
Sorry, had a minor typo in my earlier post - lost a right-parenthesis..
Change this:
<?php if (!empty($_POST['be']) echo($_POST['be']); ?>
Into this:
<?php if (!empty($_POST['be'])) echo($_POST['be']); ?>
I'll update my previous post in a moment..
/Fredrik
I was looking at this post of yours and got interested in using it for a price quote section for subtracting values from a main figure of say $ 85,000.00
I used it in the custom code before email the code works okay. But I get a display on the screen on submit. I do not want it to display rather I want the price quote template to pickup the values and email to the customer.
Could you please suggest.
Thanks
Ron
Hi Ron,
If we are talking CFv3, I'd probably add some php-code to the email template to do the magic:
Form code:
<form>
<table width="421">
<th>
<td></td>
<td width="150px">Reason</td>
<td>Item</td>
<td>Something</td>
</th>
<tr>
<td><input type="checkbox" value="1" name="MachineCost" id="MachineCost" checked="checked" disabled="disabled" /></td>
<td>Patient Documentation (mandatory)</td>
<td><font color="BLUE"><strong>Item 10</strong> :</font></td>
<td><strong>-</strong></td>
</tr>
<tr>
<td><input type="checkbox" id="NetworkMonitoring" name="NetworkMonitoring" value="1" /></td>
<td>User and Admin control</td>
<td><font color="BLUE"><strong>Item 11</strong> :</font></td>
<td><strong>-</strong></td>
</tr>
<tr>
<td><input type="checkbox" id="VoiceGuiding" name="VoiceGuiding" value="1" /></td>
<td>Audible voice guideance</td>
<td><font color="BLUE"><strong>Item 12</strong> :</font></td>
<td><strong>-</strong></td>
</tr>
<tr>
<td colspan=4 align=left>
<input type=submit value="Order">
</td>
</tr>
</table>
</form>
And the Email template (you'll have to disable the Template Editor in the email setup to add php-tags):
Hi ...,
Your order is as follows:
Machine Cost: *85,000$
<?php
$totals = 85000;
if (!empty($_POST['NetworkMonitoring']))
{
echo("\nNetwork Monitoring: *200$");
$totals += 200;
}
if (!empty($_POST['VoiceGuiding']))
{
echo("\nVoice Guiding: *210$");
$totals += 210;
}
echo( "\nTotal: *" . $totals . "\$");
?>
...
Please have a nice day,
...and so on...
I've modified the form code, as it is not adviceable to use spaces in the form field names.
Also, as I havn't used CFv4, I can't tell if this technique is useable there.
/Fredrik
No. The PHP-code goes into the Email template. Just make sure you don't use the WYSISYG editor (goes for either v3.x or v4)
/Fredrik
Does it go in the Email template.. or Does it go in the form. I am a bit confused.
Thanks
Ron
Hi Ron,
No. The PHP-code goes into the Email template. Just make sure you don't use the WYSISYG editor (goes for either v3.x or v4)
/Fredrik
Well, the form code goes into the form html/show html part. I only included it initially to point out that the form inputs had been renamed to remove the spaces in them...
As for the second part (containing the php-code), that's intended for the email template, as the heading suggests.
/Fredrik
Can I make a dynamic file from where this template can pickup prices. The prices keep changing and it becomes very difficult making changes into the forms and email templates.
Say I have a file name and the file is having a list of prices and the template can pickup the price from there for what ever choice has been made and then do the calculations...
Hi Ron,
If we are talking CFv3, I'd probably add some php-code to the email template to do the magic:
Form code:
<form>
<table width="421">
<th>
<td></td>
<td width="150px">Reason</td>
<td>Item</td>
<td>Something</td>
</th>
<tr>
<td><input type="checkbox" value="1" name="MachineCost" id="MachineCost" checked="checked" disabled="disabled" /></td>
<td>Patient Documentation (mandatory)</td>
<td><font color="BLUE"><strong>Item 10</strong> :</font></td>
<td><strong>-</strong></td>
</tr>
<tr>
<td><input type="checkbox" id="NetworkMonitoring" name="NetworkMonitoring" value="1" /></td>
<td>User and Admin control</td>
<td><font color="BLUE"><strong>Item 11</strong> :</font></td>
<td><strong>-</strong></td>
</tr>
<tr>
<td><input type="checkbox" id="VoiceGuiding" name="VoiceGuiding" value="1" /></td>
<td>Audible voice guideance</td>
<td><font color="BLUE"><strong>Item 12</strong> :</font></td>
<td><strong>-</strong></td>
</tr>
<tr>
<td colspan=4 align=left>
<input type=submit value="Order">
</td>
</tr>
</table>
</form>
And the Email template (you'll have to disable the Template Editor in the email setup to add php-tags):
Hi ...,
Your order is as follows:
Machine Cost: *85,000$
<?php
$totals = 85000;
if (!empty($_POST['NetworkMonitoring']))
{
echo("\nNetwork Monitoring: *200$");
$totals += 200;
}
if (!empty($_POST['VoiceGuiding']))
{
echo("\nVoice Guiding: *210$");
$totals += 210;
}
echo( "\nTotal: *" . $totals . "\$");
?>
...
Please have a nice day,
...and so on...
I've modified the form code, as it is not adviceable to use spaces in the form field names.
Also, as I havn't used CFv4, I can't tell if this technique is useable there.
/Fredrik
Thanks for all the help.
Ron
You can either keep info like this in a databse table and use a little form to update it; or if it's really simple then put an array into a file and the include the file when it's needed. Here's a price file:
<?php
$prices = array(
'NetworkMonitoring' => 200,
'VoiceGuiding' => 300
);
?>
Let's say this is saved as /components/com_chronoforms/includes/my_form_name/prices.php The to use it add:
<?php
. . .
include('/components/com_chronoforms/includes/my_form_name/prices.php');
. . .
echo("\nVoice Guiding: *{$prices['VoiceGuiding']}$");
. . .
?>
Bob
That is wonderful example. But is it not possible I do not show the complete URL of the price file: (components/com_chronoforms/includes/my_form_name/prices.php ) But I use something like Joomla uses in it's index.php files:
<?php $joomla= '<a href="http://www.joomla.org">Joomla!®</a>';
echo JText::sprintf('JGLOBAL_ISFREESOFTWARE', $joomla) ?>
where it picks up information from en-GB.in file.
Thanks for all the help
I think you may have this backwards. An included PHP File is invisible to the user; a header link is fully visible in the page source.
Bob
But this code does not pickup the price:
<?php include('/components/com_chronoforms/includes/my_form_name/prices.php'); echo("\n *{$prices['VoiceGuiding']}$"); ?>
Where could I be going wrong ? Do I put this code in the email reply or the form ?
ron
<?php include('/scripts/form_name/prices.php'); echo("\n *{$prices['VoiceGuiding']}$"); ?>
I put it in the price part of the email reply.
Ron
It should work OK like that. You may need to remove the \ from the start of the file path.
Bob
I have a code in the price quote figure as this:
<?php if (!empty($_POST['rt']))
{
print("\n *1290$");
$totals += 1290;
} ?>
I want to know how can I add the undermentioned with it so that it picks up the price from the usd.php file
<?php include('prices/form_name/usd.php'); echo("\n *{$prices['rt']}$"); ?>
Thanks again
Ron
Sorry, I'm slowly working backwards though the posts from the last week or two . . .
The two code snippets should merge very simply
<?php
include('prices/form_name/usd.php');
if ( !empty($form->data['rt'] ) ) {
print("\n *{$prices[$form->data['rt']]}$");
$totals += 1290;
}
?>
Bob
Bob I do not want any figure being displayed at the code. Like I do not want the price 1290 to come anywhere in the code. I want it picked up from the usd.php file:
So the code that you mentioned below should also pick up the price from the usd.php array:
<?php
include('prices/form_name/usd.php');
if ( !empty($form->data['rt'] ) ) {
print("\n *{$prices[$form->data['rt']]}$");
$totals += 1290;
}
?>
Please help
Ron
OK - this will pick up the price from the file - what do you want to happen to it next?
Bob
These are components of a single price quote proforma. The usd.php has various prices in its array. When the visitor needs a price quote he fills in a form and enters his name,email etc. and also makes a choice by the facilities he may need by checking the relative check boxes.
The php code will make additions and send a price quote of what ever selections have been made to the requester.
The usd.php file:
<?php
$prices = array(
/* ---------------- Cost of main Equipment of main Equipment -------------------- */
'usd_x4' => 10800,
'eur_x4' => 8300,
'bhd_x4' => 4100,
'sar_x4' => 40510,
'gbp_x4' => 26000,
'uah_x4' => 86700,
'inr_x4' => 367800,
/* ---------------- Cost of optional Equipment --------------------- */
'usd_sa' => 5800,
'eur_sa' => 4500,
'bhd_sa' => 2200,
'sar_sa' => 21760,
'gbp_sa' => 13965,
'uah_sa' => 46600,
'inr_sa' => 149000,
);
?>
I intend to pick up these prices and add or subtract them as and when required. To pick up the prices I intend to use this code provided by you in my email template:
<?php
include('prices/form_name/usd.php');
if ( !empty($form->data['rt'] ) ) {
print("\n *{$prices[$form->data['rt']]}$");
$totals += 1290;
}
?>
So If I have a price mentioned already in a code the reason for having a price array is basically not needed.
A price change takes place from time to time so instead of making changes in the email template of so many forms we can just change the usd.php making it very simple to handle.
Thanks very much
Ron
That mostly makes sense to be but I no longer understand exactly what your question is?
Bob
I have a form with many check boxes. A few are below:
<p><h3 class="blinkytext"><font color="PURPLE">Aditional Optional Facilities: </font></h3>
<li><label for="Ultra-life shockwave generator"><font color="BLUE"><strong>Ultra-life shockwave generator</strong> : </font> </label>
<input type="checkbox" value="1" name="ul_swg" id="ul_swg" />Â Â Â Â </li>
<li><label for="Tendelberg position of patient table"><font color="BLUE"><strong>Tendelberg position of patient table</strong> : </font></label>
<input type="checkbox" value="1" name="tdb" id="tdb" />Â Â Â Â </li>
<li><label for="Auto roll"><font color="BLUE"><strong>Auto roll</strong> : </font></label>
<input type="checkbox" value="1" name="ar" id="ar"/>Â Â Â Â </li>
When Choice is made the email template makes the addition as below:What ever is not chosen is not displayed and not added.
<p><strong><font color="RED">Price Break-up of Optional Facilities:</font></strong></p>
<div>
<table width="301" border="0">
<tr>
<th width="22" scope="row"><strong>Sr.</strong></th>
<td width="186"><strong>Main Unit cost</strong></td>
<td width="73"><?php
$totals = 10800; ?></td>
</tr>
<tr>
<th scope="row">1</th>
<td>Ultra-life shockwave generator.</td>
<td><?php if (!empty($_POST['ul_swg']))
{
print("\n *680$");
$totals += 680;
} ?></td>
</tr>
<tr>
<th scope="row">2</th>
<td>Tendelberg position of patient table.</td>
<td><?php if (!empty($_POST['tdb']))
{
print("\n *290$");
$totals += 290;
} ?></td>
</tr>
<tr>
<th height="20" scope="row">Â </th>
<td><strong>Total Price</strong></td>
<td><strong><?php print( "\n *" . $totals . "\$"); ?></strong></td>
</tr>
</table>
</div>
</td>
</tr>
</tbody>
</table>
But there are so many forms that when ever there is a price change all the forms and all the fields have to be updated.
I just need a dynamic file as price array e.g: usd.php so that the below code that you suggested may pick up the price from the dynamic file and allow it to be added or subtracted as the case may be.
The code is as below in which I do not need any price display rather it picks up from the dynamic file array:
<?php
include('prices/form_name/usd.php');
if ( !empty($form->data['rt'] ) ) {
print("\n *{$prices[$form->data['rt']]}$");
$totals += 1290;
}
?>
I hope I have been able to explain rightly.
Thanks
Ron
Yes I understood all that. I still don't know what your question is?
The code you have there picks up the price from the file. What you do with it after that is up to you.
Bob
This code has a figure in it: $totals += 1290;. What is the reason of having this code when this figure will change on different prices.
<?php
include('prices/form_name/usd.php');
if ( !empty($form->data['rt'] ) ) {
print("\n *{$prices[$form->data['rt']]}$");
$totals += 1290;
}
?>
I do not understand how to get rid of that figure.🤨 I am a bit confused.
I hope I am able to explain what I want.
Ron
I don't know, I think that's left over from your code example not mine; if you don't need it the delete it.
Bob
You said delete it ?? Well.. when I have to Add something I put a "+" and when I have to subtract I put a "-" this comes from the code "$totals += 1290;" . SO If I delete it how will my code work ? Or my email template may not be able to make the calculations. This is the figure I want to get from the price array.
My email template goes something like this:
Hi ...,
Your order is as follows:
Machine Cost: *8500$
<?php
$totals = 8500;
if (!empty($_POST['NetworkMonitoring']))
{
echo("\nNetwork Monitoring: *200$");
$totals += 200;
}
if (!empty($_POST['VoiceGuiding']))
{
echo("\nVoice Guiding: *210$");
$totals += 210;
}
echo( "\nTotal: *" . $totals . "\$");
?>
...
Please have a nice day,
...and so on...
I just want to pickup prices from the usd.php file that is my price array to do these calculations. I am sorry.. I am not able to explain or may be not able to understand the depth of the code you mention.
Please help.
Ron
I said, delete it if you don't need it. If you do need it then keep it.
I'm sorry but I can neither read your mind, nor write your PHP for you.
Bob
It's okay. One cannot be successful all the time. maybe I have to give up on it.
Thanks a lot for all the help.
Have a great new year.
As I recall, the $total variable holds a total of the selected products and options, hence it was originally incremented with the value of the option (here 1290). Now, since we'd like to read our prices from an external source, we need to replace the fixed value with the one from $prices here as well, not only in the description.
/Fredrik
So the code should be as follows ?
<?php
include('prices/form_name/usd.php');
if ( !empty($form->data['rt'] ) ) {
print("\n *{$prices[$form->data['rt']]}$");
$totals += $prices;
}
?>
I hope I am right. Please comment.
I also wish you a Happy New Year.
Ron
Almost there. $prices is an array, so you'll have to specify the proper "indice" as well, similar to Bob's code ($totals += $prices[$form->data['rt']]).
/Fredrik
Hi Ronn,
Almost there. $prices is an array, so you'll have to specify the proper "indice" as well, similar to Bob's code ($totals += $prices['$form->data['rt']']).
/Fredrik
The the total code would be something like this:
<?php
include('prices/form_name/usd.php');
if ( !empty($form->data['rt'] ) ) {
print("\n *{$prices[$form->data['rt']]}$");
$totals += $prices[$form->data['rt']];
}
?>
I hope I am right.
Best wishes for a Happy New year.
Ron
Apart from a typo of mine (updated my previous post to remove two ' in the wrong place), that should probably do.
/Fredrik
I updated my earlier post hope that code is okay. I am unable to get prices pickup from the price array file. I get a blank output in the email template. The price section is blank !
Thanks
Ron
Looking a bit further, the whole $form->data[] bit does not belong there at all.
The code below assumes we're picking the prices for the usd_sa item from the usd.php script you posted earlier:
<?php
include('prices/form_name/usd.php');
?>
....
<?php
if (!empty($form->data['rt'])) {
print("\n *{$prices['usd_sa']}$");
$totals += $prices['usd_sa'];
}
?>
/Fredrik
Thanks for all the help. I am sorry I have created a bit of confusion. Actually the price array have so many prices that I made a mistake. It may be actually :
<?php
if (!empty($form->data['usd_sa'])) {
print("\n *{$prices['usd_sa']}$");
$totals += $prices['usd_sa'];
}
?>
Hi Ronn,
Looking a bit further, the whole $form->data[] bit does not belong there at all.
The code below assumes we're picking the prices for the usd_sa item from the usd.php script you posted earlier:
<?php
include('prices/form_name/usd.php');
?>
....
<?php
if (!empty($form->data['rt'])) {
print("\n *{$prices['usd_sa']}$");
$totals += $prices['usd_sa'];
}
?>
/Fredrik
'rt' is another price element and 'usd_sa' is another price element but belong to the same price array usd.php file.
Thanks
Ron
Well, I think we're getting closer...
<?php
if (!empty($form->data['something'])) {
'something' here should match the name of the form input (checkbox), it does not have to match anything from your usd.php file. If we'd look back to the original code back on page 1, the form fields were named 'MachineCost', 'NetworkMonitoring', 'VoiceGuiding', etc. Possibly you've changed this by now though?
Next, this...
print("\n *" . $prices['otherthing'] . "\$");
$totals += $prices['otherthing'];
}
?>
'otherthing' here should match the sought-after value from usd.php, such as 'usd_sa'..
/Fredrik
Thanks again for all the help. But I am not able to get it to work.
This is my submit form:
<table class="tmc">
<tr><th rowspan="2" nowrap>Customization of Price quote - Information Required.</th>
<td>Product "IA"</td><td class="tmc"></tr></table>
<table width="100%" border="0" cellspacing="1" cellpadding="4">
<tr>
<td width="210" align="left" valign="middle" class="">Region or Continent:</td>
<td><select onChange="set_country(this,country,city_state)" type="text" class=" validate['required']" style='width:250px;' size="1" id="region" name="region">
<option value="" selected="selected">Select an Option</option>
<option value=""></option>
<script type="text/javascript">
setRegions(this);
</script>
</select>
</td>
</tr>
<tr>
<td width="210" align="left" valign="middle" class="">Your Country:</td>
<td><select class=" validate['required']" name="country" id="country" type="text" size="1" disabled="disabled" onChange="set_city_state(this,city_state)" style='width:250px;'></select></td>
</tr>
<tr>
<td width="210" align="left" valign="middle" class="">Your full Name:</td>
<td><input size="42" class=" validate['required']" name="fullname" id="fullname" type="text" /></td>
</tr>
<tr>
<td width="210" align="left" valign="middle" class="">Address 1:</td>
<td><input size="42" class=" validate['required']" name="address1" id="address1" type="text" /></td>
</tr>
<tr>
<td width="210" align="left" valign="middle" class="">Address 2:</td>
<td><input size="42" class=" validate['required']" name="address2" id="address2" type="text" /></td>
</tr>
<tr>
<td width="210" align="left" valign="middle" class="">Your City:</td>
<td><input size="42" class=" validate['required']" name="city" id="city" type="text" /></td>
</tr>
<tr>
<td width="210" align="left" valign="middle" class="">Your State/Province:</td>
<td><select name="city_state" id="city_state" type="text" size="1" disabled="disabled" onChange="print_city_state(country,this)" style='width:250px;' class=" validate['required']"></select>
</td>
</tr>
<tr>
<td width="210" align="left" valign="middle" class="">Postal (Zip) Code:</td>
<td><input size="25" class=" validate['required']" name="zip" id="zip" type="text" /></td>
</tr>
<tr>
<td width="210" align="left" valign="middle" class="">Email Address:</td>
<td><input size="35" class=" validate['required']" name="email" id="email" type="text" /></td>
</tr>
<tr>
<td width="220" align="left" valign="middle" class="">If you wish an executive to call you please mention your phone number:</td>
<td><input size="35" class="memorize" name="phone" id="phone" type="text" /></td>
</tr>
<tr>
<td width="210" align="left" valign="middle" class="">Telephone call from an executive can help.</td>
<td><input value="Model - IA" size="35" class=" validate['required']" name="subject" id="subject" type="hidden" /></td>
</tr>
<tr>
<td width="210" align="left" valign="middle" class=""></td>
<td><input value="<?php echo date("d-m-Y")?>" size="35" class=" validate['required']" name="date" id="date" type="hidden" /></td>
</tr>
<tr>
<td width="210" align="left" valign="middle" class="">Price quote for IA ?</td>
<td><input value="1" class=" validate['required']" name="torro" id="torro" type="checkbox" checked/>
Yes</td>
</tr
><tr>
<td width="220" align="left" valign="middle" class=""><input value="Submit " name="submitbtn" type="submit" id="submitbtn" /></td>
<td><input value="Reset " name="reset" type="reset" id="reset" /></td>
</tr>
</table>
<p><input type="checkbox" id="persistbox" />
Remember me ?</p>
<script type="text/javascript">
var f1=new rememberForm("my_form")
f1.persistfields("region","country","fullname", "address1", "address2", "city", "city_state", "zip", "email","phone")
f1.addtoggle("persistbox")
</script>
</div>
<div>
<p>
<?
if (getenv(HTTP_X_FORWARDED_FOR)) {
$ip_address = getenv(HTTP_X_FORWARDED_FOR);
} else {
$ip_address = getenv(REMOTE_ADDR);
}
?>
</p>
<p></p>
And this is a basic sample of the reply:
<p>Dear Customer,</p>
<p>Â </p>
<p>Thank you for your order........</p>
<p>The price of your equipment is as follows:</p>
<p>Price FOB works: <?php
include('prices/my_form/usd.php');
if (!empty($form->data['torro'])) {
print("\n *{$prices['usd_sa']}$");
$totals += $prices['usd_sa'];
}
?></p>
<p>Terms and Conditions:</p>
<p>etc.......</p>
<p>Thanking you</p>
I get an out put like this:
Price FOB works: *$
Thanks
Ron
The code looks proper now, so the most likely issue is that the usd.php file cannot be found or opened. Most likely, you've got the path to the file wrong. Since you're using a relative path, it should be relative to the root of your joomla site. An option might be to use a full path with the help of the JPATH_ROOT macro.
/Fredrik
I am able to get it rightly.
$path = JPATH_ROOT.DS.'components'.DS.'com_prices'.DS;
Thanks very much. I am yet to try the calculations as I would be travelling for two days from tomorrow. Will let you know further soon.
Thanks for all the help.
Bye
Ron
I want to pickup the prices in words too.
Can I have my price array in this way?
<?php
$prices = array(
/* ---------------- Cost of main Equipment of main Equipment -------------------- */
'usd_ia' => 10800,
'wd_usd_ia' => US Dollars ten thousand eight hundred,
'eur_ia' => 8300,
'wd_eur_ia' => Euro Eight thousand three hundred,
);
?>
How can I modify the code that can pick up the words ?
<?php
$path = JPATH_ROOT.DS.'components'.DS.'com_prices'.DS;
require_once($path.'prices.php');
echo("\n {$prices['wd_usd_ia']}"); ?>
Thanks
Ron
When defining your $prices array, you'll have to enclose the strings with " or '
<?php
$prices = array(
/* ---------------- Cost of main Equipment of main Equipment -------------------- */
'usd_ia' => 10800,
'wd_usd_ia' => 'US Dollars ten thousand eight hundred',
'eur_ia' => 8300,
'wd_eur_ia' => 'Euro Eight thousand three hundred'
);
?>
/Fredrik
I could get it to work. I made an array this way:
<?php
$prices = array(
'usd_ia' => 10800,
'eur_ia' => 8300,
);
$words = array(
'wd_usd_ia' => 'US Dollars ten thousand eight hundred',
'wd_eur_ia' => 'Euro Eight thousand three hundred'
);
?>
I have not yet tried doing math yet but will let you know soon.
I must thanks for all the help. It meant a lot to me. I also thank you for putting all that time for me I thank you from the core of my heart.
I wish you all the best in 2012.
Ron
I have tested all the calculations and everything is working great. Thanks a lot for your help.
This is a great forum. Thanks to Greyhead too for all the help.
Best wishes
Ron
Can I make some modifications in this code that when it picks up the price it adds decimal point like ( .00 ) to the price figure everytime.
The code:
<?php
$path = JPATH_ROOT.DS.'components'.DS.'com_prices'.DS;
require_once($path.'price.php');
if (!empty($form->data['tabe'])) {
print("\n {$prices['usd_20e']}");
$totals += $prices['usd_20e'];
}
?>
Thanks
Ron
The most flexible way to achieve this, would be to use printf to format the output string:
<?php
$path = JPATH_ROOT.DS.'components'.DS.'com_prices'.DS;
require_once($path.'price.php');
if (!empty($form-data['tabe']))
{
//Print first variable as a float with 2 decimals
printf("\n %.02f", $prices['usd_20e']);
$totals += $prices['usd_20e'];
}
/Fredrik