Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

getCustomerEmail() not working
 
hmpierson
Sr. Member
 
Total Posts:  101
Joined:  2008-11-15
 

Hi,

I’m trying to add some code to Ga.php to implement ResellerRatings.com evaluations.

I’m using their “advanced code” which is supposed to pass along the Increment_id (order number) and email. In

public function getOrderHtml()

we start with:

$order $this->getOrder();
        if (!
$order{
            
return '';
        
}

        
if (!$order instanceof Mage_Sales_Model_Order{
            $order 
Mage::getModel('sales/order')->load($order);
        
}

        
if (!$order{
            
return '';
        
}


        $address 
$order->getBillingAddress();

After the end of the Google code for the success page:

$html .= '_gaq.push(["_trackTrans"]);' "\n";
        
$html .= '//]]>' "\n";
        
$html .= '</script>' "\n";
I add
//add reseller ID stuff

$html .= '<link rel="stylesheet" href="https://www.resellerratings.com/images/js/dhtml_survey.css" type="text/css" />' "\n";
        
$html .= '<script type="text/javascript">' "\n";
        
$html .= 'seller_id =  xxxxx' ";\n";
        
$html .= '__rr_inv = "' $order->getIncrementId() . "\";\n";
        
        if (
$order->getCustomerEmail()) {
            
$email = $order->getCustomerEmail();
        } elseif (
$address->getEmail()) {
            
$email = $address->getEmail();
        } else {
            
$email = '';
        }        
        
        
$html .= '__rr_email_pass = "' . $email . "\";\n";
        $html .= "[removed]('
<'+ 'script type=\"text/javascript\" src=\"https://www.resellerratings.com/images/js/popup_include.js\"><\/script>');\n";
        $html .= "</script>\n";

Everything seems to work, except that the $email variable is always empty.

Any suggestions?

 
Magento Community Magento Community
Magento Community
Magento Community
 
hmpierson
Sr. Member
 
Total Posts:  101
Joined:  2008-11-15
 

to be clear, the resellerratings.com popup works, and if I look at the page source code on my “success” page, I see that the invoice number is being properly populated.

It’s just the email field that is always empty.

 
Magento Community Magento Community
Magento Community
Magento Community
 
hmpierson
Sr. Member
 
Total Posts:  101
Joined:  2008-11-15
 

Thank you for your suggestion.

I did finally give up on piggybacking on Ga.php, and utp the following code in success.phtml:

<?php>
$order_details Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
<?>
<
link rel="stylesheet" href="https://www.resellerratings.com/images/js/dhtml_survey.css" type="text/css" />
<
script type="text/javascript">
seller_id =  xxxxx;
__rr_inv "<?php echo $order_details->increment_id; ?>";
__rr_email_pass "<?php echo $order_details->customer_email; ?>";
[removed]('<''script type="text/javascript" src="https://www.resellerratings.com/images/js/popup_include.js"><\/script>');
</script>
 
Magento Community Magento Community
Magento Community
Magento Community
 
Andre N
Sr. Member
 
Avatar
Total Posts:  186
Joined:  2009-12-09
CA
 

Maybe you could try something along the lines of:

$customer $order->getCustomer();
$email        $customer->getEmail();
 
Magento Community Magento Community
Magento Community
Magento Community
 
luisvalencia
Jr. Member
 
Total Posts:  20
Joined:  2012-01-05
 

Can I just copy paste that code? I dont understand why the coude shows this [removed]

??

 
Magento Community Magento Community
Magento Community
Magento Community
 
centerfireguns
Jr. Member
 
Total Posts:  3
Joined:  2010-12-11
 

The code hmpierson posted is a step in the right direction, but has some code errors. Here’s what we use in EE 1.11, and should work in CE 1.6 or 1.7, although we didn’t test it in CE.

<?php
    $order_id 
$this->getOrderId();
    
//echo $order_id;
    
$order Mage::getModel('sales/order')->loadByIncrementId($order_id);
    
$order_email $order->getCustomerEmail();
    
//echo $order_email;
?>
<link rel="stylesheet" href="https://www.resellerratings.com/images/js/dhtml_survey.css" type="text/css" />
<
script type="text/javascript">
    
seller_id "XXXXX";
    
__rr_inv "<?php echo $order_id; ?>";
    
__rr_email_pass "<?php echo $order_email; ?>";
    
[removed]('<'+'script type = "text/javascript" src="https://www.resellerratings.com/images/js/popup_include.js"><\/script>');
</script>

You can remove the comments in front of the echos to test that the order id and email are being retrieved, you should see them echoed at the bottom of the success page.

Put this code at the very bottom of success.phtml after:

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

and you should be good to go, of course you have to use your own seller_id and not XXXXX.

 
Magento Community Magento Community
Magento Community
Magento Community
 
centerfireguns
Jr. Member
 
Total Posts:  3
Joined:  2010-12-11
 

After I posted I saw that the forum replaced some of the code with “[removed]”. This should be the javascript code to open a pop up window, and I can’t enter the exact code here as it will be replaced, it is documentDOTwrite and replace the DOT with a single period (".").

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top