【问题标题】:Calling invoice number and customer email on success.phtml在success.phtml上调用发票号码和客户电子邮件
【发布时间】:2011-12-02 21:23:37
【问题描述】:

我需要在 magento success.phtml 上以语法方式调用发票号码和客户电子邮件。

我需要这个用于预填充的电子邮件,用于转销商退出调查代码。

<link rel="stylesheet" href="https://www.resellerratings.com/images
/js/dhtml_survey.css" type="text/css" />
<script type="text/javascript">
seller_id =  XXXX;
inv = "B5000";
email_pass = "customer@someplace.com";
document.write('<'+ 'script type="text/javascript" src="https://www.resellerratings.com/images/js/popup_include.js"><\/script>');
</script>

我知道如何调用订单 ID 和总计:

     $order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
     $amount = number_format($order->getGrandTotal(),2);

我在 magento 论坛的某个地方找到了此代码,但不知道如何调出发票编号和客户电子邮件以进行经销商评级。请帮我解决这个问题。

问候, 乔恩

【问题讨论】:

    标签: magento tracking review


    【解决方案1】:

    $customer = Mage::getSingleton('customer/session')-&gt;getCustomer();

    会有很多你需要的关于当前客户的数据。

    Re:发票:您是否在下订单时生成发票?

    一个订单可以有多个发票和多个发票 ID。

    查看这篇文章,了解如何获取发票 ID 的示例:http://www.magentocommerce.com/boards/viewthread/198222/#t313532

    【讨论】:

    • 感谢 djdy 的帮助。非常欣赏它。我必须将此代码 sn-p 放在 resellerratings 代码上方,对吗?但是如何更改经销商评级代码本身?您能帮我修改转销代码本身吗?我在你给我的链接中找到了代码,我也会在我的 success.phtml 中包含该代码,但我不知道在 resellerratings 代码中写什么而不是 inv = "B5000";
    • 经销商评级是第三方扩展吗?
    • resellerratings 并不是一个真正的扩展,它是一个第三方网站,它收集评论并将其显示在谷歌购物和其他网站上。 resellerratings 提供的代码已在我的问题上方发布。我能够正确输入发票号码,现在我遇到了 email_pass 变量的问题:((再次感谢 djdy 的帮助。我真的很感激。上帝保佑......
    • @JonathanBell 对不起,我不熟悉经销商评级。 email_pass 是否来自客户?它是自定义属性还是电子邮件?尝试查看客户对象,可能在 getData 之后,看看它是否在其中。
    • 如果我在测试后有一个可行的解决方案,将在这里发布。 email_pass 是下订单的客户的电子邮件。你对不起? :)) 无论如何,我感谢您的帮助 djdy,非常感谢!我想我现在有了你的提示,会朝着一个好的方向前进。
    【解决方案2】:

    首先,在你的模块 config.xml /your_module/etc/config.xml 中添加一个事件观察器代码,

    <global> 
      <events>
        <sales_order_invoice_save_after>
          <observers>
            <your_module>
              <type>singleton</type>
              <class>your_module/observer</class>
              <method>sales_order_invoice_save_after</method>
            </your_module>
          </observers>
        </sales_order_invoice_save_after>
      </events>
    </global>
    

    然后,在您的 Observer.php /your_module/model/Observer.php 中添加一个事件观察者

    Class NameSpace_Module_Model_Observer()
    {  
        public function sales_order_invoice_save_after($observer)
        // here should be save_after because invoice id  not available until the object has been saved that means an order
        {  
            $invoice = $observer->getEvent()->getInvoice(); 
            // to see what variables available in $invoice, use the following
            // echo "<pre>"; print_r($invoice->getData()); exit;
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-26
      • 2023-01-16
      • 1970-01-01
      • 2015-11-25
      • 1970-01-01
      相关资源
      最近更新 更多