magento 按支付方式收取交易费

用优惠券的方式实现






web\app\design\frontend\base\default\template\lotusbreath\onestepcheckout\onepage\review\totals.phtml

<?php
$isNewsletter = Mage::getStoreConfig('lotusbreath_onestepcheckout/general/allowsubscribe');
if ($isNewsletter) {
    if (Mage::getSingleton('customer/session')->isLoggedIn()) {
        $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail(
            Mage::getSingleton('customer/session')->getCustomer()->getEmail());
        if ($subscriber && $subscriber->getId()) {
            $isNewsletter = false;
        }
    }
}
?>

<?php
/*得到各种数值*/
//$totalKeys = array('subtotal', 'shipping', 'tax', 'discount', 'grand_total');
$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object
$subtotal = $totals["subtotal"]->getValue(); //Subtotal value
//echo $subtotal;
//echo "---1";
$grandtotal = $totals["grand_total"]->getValue(); //Grandtotal value
//echo $grandtotal;
//echo "---2";
$shipping = $totals["shipping"]->getValue(); //shipping value
//echo $shipping;
//echo "---3";
//if($totals["discount"] && $totals["discount"]->getValue()){
if(isset($totals['discount']) && $totals['discount']->getValue()) {
    $discount = $totals["discount"]->getValue(); //discount value
}else{
    $discount = 0;
}

$t = $subtotal + $shipping;

$appliedRuleIds = Mage::getSingleton('checkout/session')->getQuote()->getAppliedRuleIds();
//$file = fopen("dh.txt","a+");
//fwrite($file,json_encode($appliedRuleIds));
//fclose($file);
//echo ($appliedRuleIds);
$paymentfee = 0;
$discountfee = 0;
$paymentfeeformat = '';
$discountformat = '';
$appliedRuleIds = explode(',',$appliedRuleIds);
foreach($appliedRuleIds as $appliedRuleId){
    $oRule = Mage::getModel('salesrule/rule')->load($appliedRuleId);
    $name = $oRule->getData('name');
    $discount_amount = $oRule->getData('discount_amount');
    if($appliedRuleId == 9){
        $paymentfee = -($t * $discount_amount /100);
        $paymentfeeformat = Mage::helper('core')->currency($paymentfee);
    }
//    var_dump($oRule->getData());
//    echo $name;
//    echo "-->";
//    echo $discount_amount;
//    echo "-->";
}
if($paymentfee){
    if(count($appliedRuleIds) == 1){
        $discountfee = 0;
        $discountformat = Mage::helper('core')->currency($discountfee);
    }else{
        $discountfee = ($discount - $paymentfee);
        $discountformat = Mage::helper('core')->currency($discountfee);
    }
}else{
    $discountfee = $discount;
    $discountformat = Mage::helper('core')->currency($discountfee);

}
?>

<?php if ($this->getTotals()): ?>
    <tfoot>
    <?php $_colspan = $this->helper('tax')->displayCartBothPrices() ? 5 : 3; ?>
    <!-- ///   -->
    <?php $getShippingAddress = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getShippingAmount(); ?>
    <?php if ($getShippingAddress): ?>
        <tr>
            <td class="a-right" colspan="<?php echo $_colspan; ?>">
                <small>Shipping & Handling </small>
            </td>
            <td class="a-right">
                <span class="price">
                    <?php echo Mage::helper('checkout')->formatPrice($getShippingAddress,true,true); ?>
                    </span>
            </td>
        </tr>
    <?php endif ?>
<!-- ///   -->
    <?php
        $payment = '<tr>
        <td colspan="3" style="" class="a-right">
        Payment Fee             </td>
        <td style="" class="a-right">
        <span class="price">'.$paymentfeeformat.'</span>            </td>
    </tr>';
    $discount = '<tr>
        <td colspan="3" style="" class="a-right">
        DISCOUNT             </td>
        <td style="" class="a-right">
        <span class="price">'.$discountformat.'</span>            </td>
    </tr>';
    ?>
    <?php if($paymentfee)echo $payment; ?>
    <?php if($discountfee)echo $discount; ?>
    <?php echo $this->renderTotals(null, $_colspan); ?>
    <!--<tr>
        <td class="a-right" colspan="4" style="height: 10px;"></td>
    </tr>
    !-->
    <?php echo $this->renderTotals('footer', $_colspan); ?>


    <?php if ($this->needDisplayBaseGrandtotal()): ?>
        <tr>
            <td class="a-right" colspan="<?php echo $_colspan; ?>">
                <small><?php echo $this->helper('sales')->__('Your credit card will be charged for') ?></small>
            </td>
            <td class="a-right">
                <small><?php echo $this->displayBaseGrandtotal() ?></small>
            </td>
        </tr>
    <?php endif ?>
    </tfoot>
<?php endif; ?>

<script type="application/javascript">
/*    var paymentfee = '<tr>
        <td colspan="3" style="" class="a-right">
        Payment Fee             </td>
        <td style="" class="a-right">
        <span class="price">100</span>            </td>
    </tr>';
    var discount = '<tr>
        <td colspan="3" style="" class="a-right">
        Discount (yy)            </td>
        <td style="" class="a-right">
        <span class="price">200</span>            </td>
    </tr>';*/
jQuery(document).ready(function(){
    jQuery("#checkout-review-table-wrapper tr:contains('Discount')").last().remove();
});
</script>


直接去掉discount

app\code\core\Mage\Checkout\Block\Cart\Totals.php

    public function renderTotal($total, $area = null, $colspan = 1)
    {
        $code = $total->getCode();
        if ($total->getAs()) {
            $code = $total->getAs();
        }
//        $file = fopen("mama.txt","a+");
//        fwrite($file,($code));
//        fclose($file);
        /*后面会重置优惠券,所以此处无需设置*/
        if($code == 'discount'){
            return '';
        }else{
            return $this->_getTotalRenderer($code)
                ->setTotal($total)
                ->setColspan($colspan)
                ->setRenderingArea(is_null($area) ? -1 : $area)
                ->toHtml();
        }
    }


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值