0

Magento 1.9.1.0

Theme: Porto

I have placed the following code in my success.phtml file:

(in public_html/app/design/frontend/smartwave/porto/template/checkout)

<script type="text/javascript"> var sa_values = { "site":33891 };  function saLoadScript(src) { var js = window.document.createElement("script"); js.src = src; js.type = "text/javascript"; document.getElementsByTagName("head")[0].appendChild(js); } var d = new Date(); if (d.getTime() - 172800000 > 1484759782000) saLoadScript("//www.shopperapproved.com/thankyou/rate/33891.js"); else saLoadScript("//direct.shopperapproved.com/thankyou/rate/33891.js?d=" + d.getTime()); </script>

As per this post here:

How to change the page that shows up AFTER customer places an order? (order success page)

It suppose to make a pop-up appear for the customer after the customer places an order and ask them for a reference. It works great! Except this only suppose to be for 1 website but it comes up for my second website also! (I have multiple websites setup under the same Magento installation and they all use the same PORTO theme).

How can I make it to only appear on 1 website?


Does it suppose to be exactly like this on bottom of my success.phtml file?

<?php if (Mage::app()->getWebsite()->getId() == 1): ?>
    <script type="text/javascript"> var sa_values = { "site":33891 };  function saLoadScript(src) { var js = window.document.createElement("script"); js.src = src; js.type = "text/javascript"; document.getElementsByTagName("head")[0].appendChild(js); } var d = new Date(); if (d.getTime() - 172800000 > 1484759782000) saLoadScript("//www.shopperapproved.com/thankyou/rate/33891.js"); else saLoadScript("//direct.shopperapproved.com/thankyou/rate/33891.js?d=" + d.getTime()); </script>
<?php endif; ?>

Because it does not seem to be working (I don't see the pop-up like I did before I added this extra code in). Is the website ID 1? I assume it should be if it for the primary/first website I setup under that installation?

Magento 1.9.1.0

The whole success.phtml file looks like this:

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<div class="page-title">
    <h1><?php echo $this->__('Your order has been received.') ?></h1>
</div>
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<div class="form-wrap">
    <h2 class="sub-title"><?php echo $this->__('Thank you for your purchase!') ?></h2>

    <?php if ($this->getOrderId()):?>
    <?php if ($this->getCanViewOrder()) :?>
        <p><?php echo $this->__('Your order # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId()))) ?></p>
    <?php  else :?>
        <p><?php echo $this->__('Your order # is: %s.', $this->escapeHtml($this->getOrderId())) ?></p>
    <?php endif;?>
        <p><?php echo $this->__('You will receive an order confirmation email with details of your order and a link to track its progress.') ?></p>
    <?php if ($this->getCanViewOrder() && $this->getCanPrintOrder()) :?>
        <p>
            <?php echo $this->__('Click <a href="%s" onclick="this.target=\'_blank\'">here to PRINT</a> a copy of your order confirmation.', $this->getPrintUrl()) ?>
            <?php echo $this->getChildHtml() ?>
        </p>
    <?php endif;?>
    <?php endif;?>

    <?php if ($this->getAgreementRefId()): ?>
        <p><?php echo $this->__('Your billing agreement # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getAgreementUrl()), $this->escapeHtml($this->getAgreementRefId())))?></p>
    <?php endif;?>

    <?php if ($profiles = $this->getRecurringProfiles()):?>
    <p><?php echo $this->__('Your recurring payment profiles:'); ?></p>
    <ul class="disc">
    <?php foreach($profiles as $profile):?>
    <?php $profileIdHtml = ($this->getCanViewProfiles() ? sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getProfileUrl($profile)), $this->escapeHtml($this->getObjectData($profile, 'reference_id'))) : $this->escapeHtml($this->getObjectData($profile, 'reference_id')));?>
        <li><?php echo $this->__('Payment profile # %s: "%s".', $profileIdHtml, $this->escapeHtml($this->getObjectData($profile, 'schedule_description')))?></li>
    <?php endforeach;?>
    </ul>
    <?php endif;?>

    <div class="buttons-set">
        <button type="button" class="button" title="<?php echo $this->__('Continue Shopping') ?>" onclick="window.location='<?php echo $this->getUrl() ?>'"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
    </div>
</div>


<?php if (Mage::app()->getWebsite()->getId() == 1): ?>
    <script type="text/javascript"> var sa_values = { "site":33891 };  function saLoadScript(src) { var js = window.document.createElement("script"); js.src = src; js.type = "text/javascript"; document.getElementsByTagName("head")[0].appendChild(js); } var d = new Date(); if (d.getTime() - 172800000 > 1484759782000) saLoadScript("//www.shopperapproved.com/thankyou/rate/33891.js"); else saLoadScript("//direct.shopperapproved.com/thankyou/rate/23891.js?d=" + d.getTime()); </script>
<?php endif; ?>
1

You can modify your code like this:

<?php if (Mage::app()->getWebsite()->getId() == 99): ?>
    <script type="text/javascript"> var sa_values = { "site":33891 };  function saLoadScript(src) { var js = window.document.createElement("script"); js.src = src; js.type = "text/javascript"; document.getElementsByTagName("head")[0].appendChild(js); } var d = new Date(); if (d.getTime() - 172800000 > 1484759782000) saLoadScript("//www.shopperapproved.com/thankyou/rate/33891.js"); else saLoadScript("//direct.shopperapproved.com/thankyou/rate/33891.js?d=" + d.getTime()); </script>
<?php endif; ?>

Just replace 99 with the id of the website you need the script for.

  • Where do I find the ID of the main website? – Allysin Jan 20 '17 at 8:02
  • Can you please see my updated information in my original question? It does not seem to be working....I have no idea what the website ID is or where I can find it....I tried 1 but that does not seem to be working.... – Allysin Jan 20 '17 at 11:59
  • @Allysin to find out your website ID go to System > Manage Stores in the backend. Click on the website and in the URL the ID will be right after the website_id – Raphael at Digital Pianism Jan 23 '17 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.