close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Problem refreshing <div class="addToCart"> in Products_Detail.php

Thread began 1/20/2010 3:10 am by davas56386677 | Last modified 2/17/2010 5:33 pm by Dani Chankhour | 4535 views | 14 replies |

davas56386677

Problem refreshing <div class="addToCart"> in Products_Detail.php

Products_Detail.php uses a script to refresh ProductName, ProductPrice in the <div class="addToCart"> when you select either an option or one of its values.
Using ISO-8859-1 character set [Oh yes, I’m the guy using French characters :-)] the initial ProductName is displayed nicely with accented characters as well in Firefox 3.5 (see pic1.jpg) as in IE8 (pic3.jpg).
When selecting another option or value of the product, then the script returns the ProductName as shown in pic2.jpg (Firefox) and pic4.jpg (IE). The red font color (temporarily set within the <h1> tag in Products_Detai.php) is reverted to the green font color I defined in the css for the <h1> tag.
The script appears to first check xmlHttp=new XMLHttpRequest() (for Firefox, Opera 8.0+, Safari) then xmlHttp=new ActiveXObject("Msxml2.XMLHTTP") and finally xmlHttp=new ActiveXObject("Microsoft.XMLHTTP") depending on catch(e).
Could one tell me what to change in that script or elsewhere in the code, to get the French characters displayed correctly in red after selecting either an option or a value of that option and without having to change the default font color of the <h1> tag in the css.
Thank you
Dan

Sign in to reply to this post

Jason ByrnesWebAssist

I'm trying to replicate the problem in fresh install of power store, but cannot see the issue. I have added an item to the catalog using french accented characters in the name, and description fields and added different options for that item. Some options are set with 0 inventory, some are not available on line. All of the options correctly show the name. It would seam there is a modification that you have made to the power store files that is causing the problem to occur.

Sign in to reply to this post

davas56386677

Still sticking with é displayed as &#65533; in Products_Detail.php

Before going on investigating the reason why the é are displayed as a &#65533; in WADAPageTitle after choosing a different OPTION of the product, I'd like to know how your MySQL server at WebAssist is configured:

Connection collation : utf8_general_ci or what else ???
Database charset : UTF-8 Unicode (utf8) or what else ???
Table collation : utf8_general_ci or what else ???
Varchar collation : utf8_general_ci or what else ???

Analyzing the script in Products_Detail.php that updates the WADAPageTitle without refreshing the complete page I noticed that the content is fetched by document.getElementById("WADAPageTitle").innerHTML = getFromRSDump(theRet,"ProductName");

I tried a new product with a lot of é in the ProductName and different options, but the problem persists.

So before going on with my tests I want to be sure if the problem finally relies on the MySQL server configuration.

P.S. I changed all <meta http-equiv="Content-Type" content="text/html; charset=UTF-8 "/> to ISO-8859-1. Doing this solved apparently the problems I had with the Dynamic Web Charts in POWERSTORE 2. Now french characters display accordingly in the charts.

Thank you for telling me the configuration of WebAssist's MySQL server.

Regards

Dan

Sign in to reply to this post

Jason ByrnesWebAssist

these are the settings my connection is using:

Server Character Set: latin1
Client Character Set: utf-8
Database Character Set: latin1

Table Engine: innoDB

Table Collation: latin1_Swedish_ci
Varchar collation: latin1_Swedish_ci
Connection collation: latin1_Swedish_ci

Sign in to reply to this post

davas56386677

Thank you Jason

I'll gonna do the testing tomorrow with the settings provided in your post and revert to you to report the results.

Regards

Dan

Sign in to reply to this post

davas56386677

Converting DOT into COMMA in "thePriceField" (script) in Products_Detail.php

Hi Jason

I made a fresh install of Powerstore 2 on my PC and configure the MySQL server according to your settings.
The ProductName is now displaying the french accented characters the right way when selecting an option or a value.
I modified somewhat the script of the function updateProduct(ProdID) in Products_Detail.php to display the EUROI currency symbol after the price:


var theForm = document.getElementById("WA_Store_Cart_1_ATC_<?php echo $row_WADAProducts["ProductID"]; ?>");
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
if (xmlHttp.responseText != "") {
var theRet=xmlHttp.responseText;
var thePriceField = getFromRSDump(theRet,"ProductPrice");
if (thePriceField.indexOf(".")==-1) {
thePriceField += ",00 €";
}
if (thePriceField.indexOf(".")==thePriceField.length-2) {
thePriceField += "0 €";
}
document.getElementById("ProductPrice").innerHTML = thePriceField;

Can you help me to get rid of the "dot" as a decimal character in this script, because we use a "comma" to separate decimals ?

I think of converting the DOT into a COMMA within "thePriceField", but don't know how to do it !

Thank you for your kind help

Dan

Sign in to reply to this post

Jason ByrnesWebAssist

the code I have is:
var theForm = document.getElementById("WA_Store_Cart_1_ATC_<?php echo $row_WADAProducts["ProductID"]; ?>");
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
if (xmlHttp.responseText != "") {
var theRet=xmlHttp.responseText;
var thePriceField = "$"+ getFromRSDump(theRet,"ProductPrice");
if (thePriceField.indexOf(".")==-1) {
thePriceField += ".00";
}
if (thePriceField.indexOf(".")==thePriceField.length-2) {
thePriceField += "0";
}





is was able to get it to use the comma by changing that to:
var theForm = document.getElementById("WA_Store_Cart_1_ATC_<?php echo $row_WADAProducts["ProductID"]; ?>");
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
if (xmlHttp.responseText != "") {
var theRet=xmlHttp.responseText;
var thePriceField = "€"+ getFromRSDump(theRet,"ProductPrice");
if (thePriceField.indexOf(".")==-1) {
thePriceField += ",00";
}
if (thePriceField.indexOf(".")==thePriceField.length-2) {
thePriceField += "0";
}

Sign in to reply to this post

davas56386677

Here my solution and additional question

Hi Jason,

In order to display the price in EUR (right side) in Products_Detail.php when selecting either options or values, I had to add a function handling separators in "thePriceField" within the script. Look below (the whole script with modified code for "thePriceField" and added function "addSeparatorsNF(nStr, inD, outD, sep)":

<script>
function updateProduct(ProdID) {
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
return false;
}
}
}
var theForm = document.getElementById("WA_Store_Cart_1_ATC_<?php echo $row_WADAProducts["ProductID"]; ?>");
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
if (xmlHttp.responseText != "") {
var theRet=xmlHttp.responseText;
var thePriceField = getFromRSDump(theRet,"ProductPrice");
if (thePriceField.indexOf(".")==-1) {
thePriceField += ".00";
thePriceField = addSeparatorsNF(thePriceField, '.', ',', '.');
thePriceField = thePriceField += " €";
}
if (thePriceField.indexOf(".")==thePriceField.length-2) {
thePriceField += "0";
thePriceField = addSeparatorsNF(thePriceField, '.', ',', '.');
thePriceField = thePriceField += " €";
}
document.getElementById("ProductPrice").innerHTML = thePriceField;
document.getElementById("WADAPageTitle").innerHTML = getFromRSDump(theRet,"ProductName");
document.getElementById("ProductCartDesc").innerHTML = getFromRSDump(theRet,"ProductName");
document.getElementById("ProductLongDesc").innerHTML = getFromRSDump(theRet,"ProductLongDesc");
//document.getElementById("ProductShortDesc").innerHTML = getFromRSDump(theRet,"ProductShortDesc");
document.getElementById("ProductImage").src = "Images/Upload/" + getFromRSDump(theRet,"ProductImage");
document.getElementById("WA_Store_Cart_1_ID_Add").value = getFromRSDump(theRet,"ProductID");
theForm.action = theForm.action.replace(/ProductID=\d*/,"ProductID="+getFromRSDump(theRet,"ProductID"));
document.getElementById("checkingAvail").style.display="none";

if ((parseFloat(getFromRSDump(theRet,"NumLeft")) > 0 || parseInt(getFromRSDump(theRet,"ProductUnlimited")) != 0) && parseInt(getFromRSDump(theRet,"ProductLive")) != 0) {
document.getElementById("addFields").style.display="block";
}
if (parseInt(getFromRSDump(theRet,"ProductLive")) == 0) {
document.getElementById("notSold").style.display="block";
}
if (parseFloat(getFromRSDump(theRet,"NumLeft")) <= 0 && parseInt(getFromRSDump(theRet,"ProductLive")) != 0 && parseInt(getFromRSDump(theRet,"ProductUnlimited")) == 0) {
document.getElementById("soldOut").style.display="block";
}

var numOptions = 0;

numOptions = theRet.match(/\['options'\]=>([^\r\n]*)/);
if (parseInt(numOptions[1]) > 0) {

updateOptions(theRet.substring(theRet.indexOf(numOptions[0])+numOptions[0].length));

}
}
for (var x=0; x<theForm.elements.length; x++) {
theForm.elements.item([x]).removeAttribute("disabled");
}
}
}
var thepage = "Products_Detail_Lookup.php?ProductID="+ProdID;

xmlHttp.open("GET",thepage,true);
xmlHttp.send(null);
document.getElementById("addFields").style.display="none";
document.getElementById("notSold").style.display="none";
document.getElementById("soldOut").style.display="none";
document.getElementById("checkingAvail").style.display="block";
for (var x=0; x<theForm.elements.length; x++) {
theForm.elements.item([x]).disabled="disabled";
}
}

function updateOptions(theOptions) {
var theNameMatch = theOptions.match(/\['name'\]=>([^\r\n]*)/);
while (theNameMatch) {
theOptions = theOptions.substring(theOptions.indexOf(theNameMatch[0]) + theNameMatch[0].length);
nextName = theOptions.match(/\['name'\]=>([^\r\n]*)/);
nextIndex = theOptions.length;
if (nextName) {
nextIndex = theOptions.indexOf(nextName[0]);
}
nextValue = theOptions.match(/\['value'\]=>([^\r\n]*)/);
x = 0;
while (nextValue && theOptions.indexOf(nextValue[0]) < nextIndex) {
document.getElementById(theNameMatch[1].replace(/[\n\r\t]/g,"")).options[x].value = nextValue[1];
nextIndex-=theOptions.indexOf(nextValue[0]) + nextValue[0].length;
theOptions = theOptions.substring(theOptions.indexOf(nextValue[0]) + nextValue[0].length);
nextValue = theOptions.match(/\['value'\]=>([^\r\n]*)/);
x++;
}
theNameMatch = theOptions.match(/\['name'\]=>([^\r\n]*)/);
}
}

function getFromRSDump(RSDump,colName) {
var theReg = new RegExp('\\s\\["'+colName+'"\\]=>\\s([\\w\\W]*)');
var theMatch = RSDump.match(theReg);
var theRet = "";
if (theMatch) {
var nextMatch = theMatch[1].search(/\s\["[^\r\n]*"\]=>/);
if (nextMatch > 0) {
theMatch[1] = theMatch[1].substring(0,nextMatch);
}
theRet = theMatch[1].substring(theMatch[1].indexOf('"')+1,theMatch[1].lastIndexOf('"'));
}
return theRet;
}

function addSeparatorsNF(nStr, inD, outD, sep)
{
nStr += '';
var dpos = nStr.indexOf(inD);
var nStrEnd = '';
if (dpos != -1) {
nStrEnd = outD + nStr.substring(dpos + 1, nStr.length);
nStr = nStr.substring(0, dpos);
}
var rgx = /(\d+)(\d{3})/;
while (rgx.test(nStr)) {
nStr = nStr.replace(rgx, '$1' + sep + '$2');
}
return nStr + nStrEnd;
}

</script>

This modified script within Products_Detail.php may be of interest to everybody who needs to display the price like "12.345,67 €". Those who need another currency symbol have just to modify the line "thePriceField = thePriceField += " €"; replacing the € symbol with whatever needed.


Just a little question: in DYNAMICWEBCHART used in Powerstore 2 for instance in Products_Chart_Results_Data1.php the french accented characters contained in ProductName (or similar) to fill #key# in <![CDATA[Pour: #x_label#<br>#key#<br>Unit%c3%a9(s) vendue(s): #val# ]]> are displayed as an é instead of an é. This happened since I made the fresh install of Powerstore using your MySQL configuration.
Remember: I changed all charset=ISO-8859-1 to charset=UTF-8 to comply the closest possible to the original Powerstore 2 (out of the box). The only charsets left to ISO-8859-1 are those within the PHP files that handle the data for the charts (in the \data subdirectory). When changing these particular chasets to UTF-8, the chart stops building up and displays only vertical lines (the tooltip shows: undefined).

<point datagroup="Total">
<label><?php echo($start); ?></label>
<value><?php echo($total); ?></value>
<tooltip>
<![CDATA[Pour: #x_label#<br>#key#<br>Unit%c3%a9(s) vendue(s): #val# ]]>
</tooltip>
<pointlink>Products_Chart_Daily.php?month=<?php echo($month); ?>%26year=<?php echo($year); ?>%26ProductSKU=<?php echo($sku); ?></pointlink>
</point>

Keep in mind that when using charset=ISO-8859-1 throughout the complete Powerstore 2 package and MySQL configured with utf8_general_ci (or utf8_unicode_ci) then the é are stored as é within the database field and displays also correctly (as é) in the chart, thus avoidind the troubles encountered now.

So to me it seems that there must be a trick (encoding - decoding feature) to foul the chart builder so that he translates the é (actual configuration of the fresh install as told by you in previous post) into é. A similar problem occurs in the receipt.php (WA_Universal_Email\Email_Templates), where the
<?php echo $WA_Store_Cart->DisplayInfo("Name"); ?> displays as Société instead of Société within the confirmation email the customer receives.

Ask the team to check this in depth and help me to find where in the complete Powerstore 2 code a explicit encoding - decoding is used to configure the output (email and chart side)

Many thanks for your assistance

Dan

Sign in to reply to this post

davas56386677

Here 3 slides to document the problem with Dynamic WebCharts in Powerstore 2

Please read the red legends in the slides

Maybe your team shall now understand my concerns related to foreign characters in DWC and in receipt.php of Universal Email in Powerstore 2

Sign in to reply to this post

davas56386677

LARGER PICTURES in JPG format

Sorry but I noticed that PNGs are to small to read effectively, so please find hereinafter JPGs

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

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.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...