eCart confirm page country title
Trying to get Country titles on Confirm page rather than abbreviations - tried recordset.
Any ideas?
eCart5 using mysql and php with tables and fields based on BlueSky
Trying to get Country titles on Confirm page rather than abbreviations - tried recordset.
Any ideas?
eCart5 using mysql and php with tables and fields based on BlueSky
Now going round in circles. The dilemma is I need to satisfy four things from the checkout page to the confirm page for countries as follows:
1. Checkout automatically fills in countries field (dynamic menu) after login
2. Checkout shows country label (after setting dynamic menu values/labels/values equal from recordset)
3. Confirm page correctly calculates tax and shipping using countries abbreviation (eg GB)
4. Confirm page shows country abbreviation or title in address
I've tried just about every setting in the countries dynamic menu setting and can get 3 of the above working but never 4
Ideas:
Add an abbreviation field to the countries table and try again
OR
Add a recordset to the confirm page and set the formulas for tax and shipping to use IDs instead of abbreviations (EG US). Note: Can't use DW to add recordset as get a javascript error so will need to hand code it in.
OR
There's a better session variable satisfy all the 1-4 above which needs hand coding
What's best
The checkout forms that eCart 5 creates are going to show the full name of the country for the label and the abbreviation for the value. So a user who is from The United Kingdom would Select United Kingdom from the menu and the value that is held and passed around will be the abbreviation for this country 'GB'.
So it seems this would satisfy all of the needs that you have for the country abbreviation from the checkout page onward. The only thing missing would be to set the country select list to the value held in the record for the user. The user would need to have the country abbreviation stored in their profile.
To do this you will need have a way of identifying the user. Most of the time you would have their id held in a session variable. Then on any page that you would like to reference any details for that user would need to add in a recordset that is filtered by the identifier for the user. So if your logged in user had a session variable called id that was set to a proper value you could filter a recordset to get back all of the info for this user by choosing the filtering options then specifying your id session variable.
Once you have the recordset on the checkout page you can use the dynamic options to select the value that is equal to that column from your recordset. This should prepopulate the country select list on the checkout page.
I have a recordset on the checkout page but the conundrum is as follows:
When I use the visitors ID value in the dynamic options to automatically choose the county on the checkout page it works but sends the country ID rather than country abbreviations (option value) so the Tax and Shipping formulas on the confirm page DON'T work.
When I use the value: VisitorBillCountryID it doesn't automatically choose the county but the Tax and Shipping formulas on the confirm page DO work. EG:
<select name="country" id="country">
<option value="" selected="selected" <?php if (!(strcmp("", $row_rsVisitor['VisitorBillCountryID']))) {echo "selected=\"selected\"";} ?>>Choose a country</option>
<option value="US" <?php if (!(strcmp("US", $row_rsVisitor['VisitorBillCountryID']))) {echo "selected=\"selected\"";} ?>>United States</option>
<option value="GB" <?php if (!(strcmp("GB", $row_rsVisitor['VisitorBillCountryID']))) {echo "selected=\"selected\"";} ?>>United Kingdom</option> ETC ETC
And at the bottom:
<?php
do {
?>
<option value="<?php echo $row_rsVisitor['CountryID']?>"<?php if (!(strcmp($row_rsVisitor['CountryID'], $row_rsVisitor['VisitorBillCountryID']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rsVisitor['CountryName']?></option>
<?php
} while ($row_rsVisitor = mysql_fetch_assoc($rsVisitor));
$rows = mysql_num_rows($rsVisitor);
if($rows > 0) {
mysql_data_seek($rsVisitor, 0);
$row_rsVisitor = mysql_fetch_assoc($rsVisitor);
}
?>
Maybe a hand code the above from CountryID to VisitorID would work?
On your checkout page the Country select list should always post whatever the value attribute has for the selected option. So regardless of what option is selected the corresponding value for that option should be posted to the action of the form. This is not something that would change based on the comparison value that you are using.
I think that you might just be setting the dynamic selection incorrectly. The part of the code that you have listed as being at the bottom is a dynamically populated select list for the country. This is not what you want to be doing. Instead you should just be setting the 'select value equal to' to the value from your recordset. Select the checkout form on the page, then in the property inspector click on the dynamic button. For the 'options from recordset' leave it set to none, then for the 'select value equal to' use the lightning bolt icon to set it to the recordset value that holds the country code.
Thanks Eric but it isn't working:
<th><label for="country" >Country</label></th>
<td><select name="country" id="country" >
<option value="" selected="selected" <?php if (!(strcmp("", $row_rsVisitors['VisitorBillCountryID']))) {echo "selected=\"selected\"";} ?>>Choose a country</option>
<option value="US" <?php if (!(strcmp("US", $row_rsVisitors['VisitorBillCountryID']))) {echo "selected=\"selected\"";} ?>>United States</option>
<option value="GB" <?php if (!(strcmp("GB", $row_rsVisitors['VisitorBillCountryID']))) {echo "selected=\"selected\"";} ?>>United Kingdom</option>
I'm not sure why it is not working for you, would it be possible for you to post back with a copy of your db and this checkout page? If I had this info and the id of the user you are testing with I would better be able to help you determine what is going wrong.
DB and checkout files attached.
The country is working well going from the checkout to the confirm page and correctly calculates tax and shipping when manually selected. But the checkout page still won't select the country automatically using any visitor ID. Other fields do show the visitors name and address automatically.
To automatically show the billing country, would simply adding a recordset inner join of countries and visitors tables work? Or do I need the menu field and would that stop the country abbreviated value working on the confirm page? Do I need to add the abbreviated values to the countries table?
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.