1 / 8
Apr 2010

Here are some requests to have an ability to customise the shopping cart page.



Request 1:

Can we have an ability to include a link in the text area. Currently, I can use the following command to display a text in the shopping basket.





function EJEJC_shown()

{

jQuery("#tdPmnt").attr("innerHTML", "Some text here");

}



In place of "Some text here", can we use "Some text <a href="http://www.somesite.com">here></a>"





Request 2:

Following from request 1, can we have a check box next to a link in the shopping cart page. This can be used to ask a customer to agree to terms & conditions before placing an order. If the check box is not ticked, a warning must appear to say that the customer has to agree to it before proceeding.



Request 3:

Following from request 1 and 2, can we track the clicks on terms and conditions link displayed in the shopping basket. Currently I can track using google with the following code:



<a onclick="javascript:

ejGATracker.trackPageview('/TermsConditions');" href="/Portals/0/Termsand_Conditions.pdf">terms & conditions</a>



Can we pass the above with all the double quotations and the rest to your EJEJC_shown function.



It would be great to have all three requests and I guess many can benefit from as this would make it legally safer when selling to customers.



Thanks

  • created

    Apr '10
  • last reply

    Apr '10
  • 7

    replies

  • 1.1k

    views

  • 2

    users

  • 4

    links

Addressing your inquiries in order:



1) You can use HTML, but you should change any "double quotes" in your HTML into 'single quotes' and put it all on one long line -- e.g., you would add something like this just before the "// ->" line in the standard View Cart code you obtain from Seller Admin:



function EJEJC_config() {

EJEJC_POSTCALL=true;

}

function EJEJC_shown() {

jQuery("#tdPmnt").attr("innerHTML",

"Some HTML <a href='http://www.somesite.com/'>here</a>");

}



2) We don't have a built-in way to do that, but you could do something like that by programming some custom javascript into your own page. One of our clients, www.CommonCraft.com, has done something like that in the past and recently done even fancier things, so you might contact them to see if they're willing to share any tips, or you can hire one of the competent, E-junkie-experienced developers listed in our directory:

1http://www.e-junkie.com/ej/developer-directory.htm1



3) That may be possible with custom-programmed javascript as explained above.

Thank you very much for the help. It was very useful.

I have now tested the Request 3 and it does not work. I suspect the reason is that text has single quotes as well as double quotes. Here is what I want to pass to your function:



<a onclick="javascript:

ejGATracker.trackPageview('/TermsConditions');" href="/Portals/0/Termsand_Conditions.pdf">terms & conditions</a>



As you stated, to pass it to your function, single quotes should be used in place of double quote which is what I have done. What should I use to pass a single quote?

My reply #3 was actually referring to the solution described in #2, not #1, but I may have misunderstood what you were asking. If you just want to add a link to Terms & Conditions in your cart, try this:



function EJEJC_config() {

EJEJC_POSTCALL=true;

}

function EJEJC_shown() {

jQuery("#tdPmnt").attr("innerHTML",

"<a onclick=javascript:ejGATracker.trackPageview('/TermsConditions'); href=/Portals/0/Termsand_Conditions.pdf target=_blank>Terms & Conditions</a>");

}



Everything from "<a... to </a>"); should be all on one long line together. BTW, do you really want buyers to have to download a PDF file and open that to read your terms & conditions? The target=_blank attribute I added should pop open a new window when the link is clicked (so clicking the link won't lose the buyer's cart), then you could put your Ts&Cs in a normal HTML page and just link to that page instead of the PDF file.

I tried the above solution and as I suspected it doesn't work. The link is not between double quotes which means when you click on it, goes to nowhere.



Here is a best version so far:



function EJEJC_config() {

EJEJC_POSTCALL=true;

}

function EJEJC_shown() {

jQuery("#tdPmnt").attr("innerHTML",

"<a onclick='javascript: ejGATracker.trackPageview('/TermsConditionsCheckout');' href='/Portals/5/Downloads/Other/Terms and Conditions.pdf' target='blank'>terms & conditions</a>");

}



As you can, there are several single quotes used. When I use the following, the link works and opens up in a new page, but tracking doesnt work.



The reason is that the single quotes here all get converted to double quotes which is good for the correct functioning of the HTML. When passes our text between <a> and </a> will be converted to:



<a onclick="javascript: ejGATracker.trackPageview("/TermsConditionsCheckout");" href="/Portals/5/Downloads/Other/Terms and Conditions.pdf" target="blank">terms & conditions</a>



However, the following single quotes also get converted:



ejGATracker._trackPageview('/TermsConditionsCheckout')



making it look like this:



ejGATracker._trackPageview("/TermsConditionsCheckout")



which is wrong.



I think these need to stay as single quote. Hence, my question is how can we pass single quotes to the jQuery.attr function. Suggestion: can we pass two single quotes next to each other like this.



ejGATracker._trackPageview(''/TermsConditionsCheckout'')



or how about this?



ejGATracker._trackPageview(\'/TermsConditionsCheckout\')



Thanks

Hm, part of the problem is that jQuery uses double-quotes to delimit strings, so where you have the line starting with this:



jQuery("#tdPmnt").attr("innerHTML","



...everything from that point until the very next " character gets treated as the string to insert, so if the string you want already includes any double-quotes, the first one will terminate the string prematurely. You just need to use a \ (backslash) to escape each double-quote in your string, like so:



function EJEJC_config() {

EJEJC_POSTCALL=true;

}

function EJEJC_shown() {

jQuery("#tdPmnt").attr("innerHTML",

"<a onclick=\"javascript:ejGATracker.trackPageview('/TermsConditions');\" href=\"/Portals/0/Termsand_Conditions.pdf\">terms & conditions</a>");

}

8 days later

Based on your email, I eventually found how to get it to work. Here is the functional code. The idea is to use \' for ' and \" for "





function EJEJC_config() {

EJEJC_POSTCALL=true;

}

function EJEJC_shown() {

jQuery("#tdPmnt").attr("innerHTML",

"<a onclick=\"javascript:ejGATracker.trackPageview(\'/TermsConditions\');\" href=\"/Portals/0/Termsand_Conditions.pdf\">terms & conditions</a>");

}



Thanks for you help.