简体   繁体   English

如何将EAV值传递给Paypal支付信息

[英]How to pass an EAV value to the Paypal payment information

I've introduced a custom EAV attribute for the customer object. 我已经为客户对象引入了自定义EAV属性。 Let's call it myvalue. 我们称之为myvalue。 Within several places in magento, I'm printing the value like this: 在magento的几个地方,我打印的值如下:

echo Mage::getSingleton('customer/session')->getCustomer()->getMyvalue();

When the customer pays with paypal, I'd like to have myvalue in the reason as an addition to the order number. 当客户使用paypal付款时,我希望将myvalue作为订单号的补充。 My intent is to match the order with some shop-side process. 我的意图是将订单与一些店边流程相匹配。

So, how can I pass myvalue to paypal to make it visible together with the order number? 那么,我如何将myvalue传递给paypal以使其与订单号一起显示?

You can try to override the class Mage_Paypal_Block_Standard_Redirect into something like this: 您可以尝试将类Mage_Paypal_Block_Standard_Redirect重写为以下内容:

protected function _toHtml()
{
    $standard = Mage::getModel('paypal/standard');

    //...

    foreach ($standard->getStandardCheckoutFormFields() as $field=>$value) {
        if ($field == 'REASON_CODE') {
            $myvalue = Mage::getSingleton('customer/session')->getCustomer()->getMyvalue();
            $value .= $myvalue;
        }
        $form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
    }

    //...

    return $html;
}

I have added a condition in the foreach to edit the reason with your special customer value. 我在foreach中添加了一个条件来编辑具有特殊客户价值的原因。

I don't know what is the code for the reason you speak about, if you don't as well you can first log that in the foreach: 我不知道你说的原因是什么代码,如果你不这样做,你可以先在foreach中记录:

Mage::log($field);
Mage::log($value);

Then don't forget to edit 'REASON_CODE' and getCustomer()->getMyvalue() in my example. 然后不要忘记在我的示例中编辑'REASON_CODE'getCustomer()->getMyvalue()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM