george
george

Reputation: 4349

adding SSL authority javascript code in Magento one page checkout page

I have been trying to add a string of javscript code provided by SSL signing authority in margin of one-page Magento checkout. Something in Magento seems to be stripping out javascript code after the first step of the check out, but I can't find offending code. Anyone else note this issue or a solution?

I added JS code to bottom of \app\design\frontend\default\myTheme\template\checkout\onepage\progress.phtml.

Code looked like this:

 <span id="siteseal"><script type="text/javascript" src="https://seal.godaddy.com/getSeal?sealID=xxx"></script></span>

At first I thought it was hidden, but the logo appeared on the first step but disappeared on subsequent steps, however the "siteseal" span was still there -empty

Upvotes: 1

Views: 1109

Answers (1)

Alana Storm
Alana Storm

Reputation: 166126

While the initial output of the progress section is PHP based, Magento updates the progress section of the page via AJAX as you move from step to step to step. This is handled by the following code

#File: skin/frontend/base/default/js/opcheckout.js
reloadProgressBlock: function(toStep) {
    var updater = new Ajax.Updater('checkout-progress-wrapper', this.progressUrl, {
        method: 'get',
        onFailure: this.ajaxFailure.bind(this),
        parameters: toStep ? {toStep: toStep} : null
    });
},

If you check the documentation for Ajax.Updater, you'll see there's an additional option that Magento doesn't pass in

evalScripts (Boolean; defaults to false): Whether elements in the response text should be evaluated.

This means scripts aren't evaluated when Magento updates that section of the page via Ajax, and is the most likely reason you're seeing the behavior you describe.

To solve you problem, I'd skip adding this code to the progress.phtml template, and instead use the following layout update (in local.xml, or somewhere else if that's your style)

<layouts>
    <checkout_onepage_index>
        <reference name="right">
            <block type="core/text" name="my_extra_stuff" before="checkout.progress.wrapper">
                <action method="setText"><text><![CDATA[
                <span id="siteseal"><script type="text/javascript" src="https://seal.godaddy.com/getSeal?sealID=xxx"></script></span>
                ]]></text></action>
            </block>
        </reference>
    </checkout_onepage_index>
</layouts>  

If you want your code below the progress stuff, just remove before="checkout.progress.wrapper" from the layout update xml.

Upvotes: 1

Related Questions