我正在尝试实现并从success.phtml页面获取一些联盟计算。一切都运作良好,除了' bd'这应该是总计没有运费。我可能会遗漏“bd'码。我是php代码的新手。请帮我解决这个问题! Please look into screenshot
<?php
// Add this to the file in the following path: app/design/frontend/[package]/[theme]/template/checkout/success.phtml
$iProgramId = 9560; // Insert your Program ID here
// Add the matching domain here.
$sMatchingDomain = 'https://dt51.net'; //For example: ds1.nl or dt51.net
// Retrieve order details and billing address
$oOrderDetails = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
$aBillingAddressData = $oOrderDetails->getBillingAddress();
$amount = $order->getGrandTotal() - $order->getShippingAmount();
foreach ($oOrderDetails->getAllItems() as $oItem)
{
break;
}
$aVariables = array(
'si' => $iProgramId,
'ti' => $this->getOrderId(),
'oa' => substr($oItem->getName(), 0, 50),
'om' => substr($oItem->getName(), 0, 50),
'bd' => number_format($oOrderDetails->getGrandTotal - $oOrderDetails->getShippingAmount(), 2, '.', ''),
'ln' => $aBillingAddressData['country_id'],
'pc' => $aBillingAddressData['postcode'],
'rv' => number_format($oOrderDetails->getGrandTotal(), 2, '.', ''),
'e1' => $oOrderDetails->getPayment()->getMethodInstance()->getTitle(),
'e2' => $oItem->getSku(),
'e3' => round($oItem->getQtyOrdered(), 0)
);
$sUrl = "".$sMatchingDomain."/t/";
$sGlue = "?";
foreach ($aVariables as $sKey => $mValue)
{
$sUrl .= $sGlue.$sKey."=".urlencode($mValue);
$sGlue = "&";
}
echo '<img src="'.$sUrl.'" style="border: 0px; height: 1px; width: 1px;" alt="Affiliate Marketing" />';
?>
答案 0 :(得分:0)
您在以下行中犯了错误。 getGrandTotal()
'bd' => number_format($oOrderDetails->getGrandTotal - $oOrderDetails->getShippingAmount(), 2, '.', '')
替换为
'bd' => number_format($oOrderDetails->getGrandTotal() - $oOrderDetails->getShippingAmount(), 2, '.', ''),