服务报价 | 域名主机 | 网络营销 | 软件工具| [加入收藏]
 热线电话: #
当前位置: 主页 > php教程 > magento教程 >

magento信用金额支付插件开发

时间:2017-03-10 10:39来源:未知 作者:最模板 点击:
magento信用金额支付插件开发, der98/sort_order show_in_default1/show_in_default show_in_website1/show_in_website show_in_store0/show_in_store /min_order_total max_order_total translate= label labelMaximum Order Total/label frontend_
magento信用金额支付插件开发,
der>98</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </min_order_total>
                        <max_order_total translate="label">
                            <label>Maximum Order Total</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>99</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </max_order_total>
                        <model>
                        </model>
                    </fields>
                </creditlimit>
 
#Payment/etc/config.xml
  <creditlimit>
       <active>1</active>
       <model>payment/method_creditlimit</model>
       <order_status>pending</order_status>
       <title>Credit Limit</title>
       <allowspecific>0</allowspecific>
       <group>offline</group>
</creditlimit>
#payment/method_creditlimit ->Mage/Payment/Model/Method/creditlimit.php<br>配置完之后再后台支付哪里可以看到,启用支付插件System > Configuration > Payment Methods

5、修改前端支付方法文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#app/design/frontend/default/theme592/template/checkout/onepage/payment/methods.phtml
 
/*处理是否允许用户类型支付*/
if($_code == "creditlimit"){
            $Type = $this->getCustomer()->getType();
            /*用户是个人,支付只支持公司*/
            if(intval($Type) != 1){
                continue;
            }
            /*如果是企业用户*/
            $maxOrderTotalCL= $this->getCustomer()->getCreditThreshold();
            $grandTotal = $this->getQuote()->getBaseGrandTotal();
            if(intval($maxOrderTotalCL) > $grandTotal){ //如果订单总数小于允许最大值时
                continue;
            }
            /*获取当前可用信用额度*/
            $CreditLimit = (float)$this->getCustomer()->getCreditLimit();  //该用户的信用额度
            $useCreditLimit = (float)$this->getCustomer()->getUseCreditLimit();//已经使用了信用额度
            $CreditLimitPercent = (float)$this->getCustomer()->getCustomPayment();//已经使用了信用额度
            $usedCreditLimit = (float)($CreditLimit-$useCreditLimit);//可用额度
            $usedCreditLimit = $usedCreditLimit<0?0:$usedCreditLimit;
            $tipceCreditLimit[$_code] = $this->__('当前可用信用额度 <b style="color:#f00;">HK$%s</b>',sprintf('%.2f',$usedCreditLimit));
            /*信用额度不足的情况*/
            if($grandTotal > $CreditLimit){
                if($CreditLimitPercent==0) $CreditLimitPercent = 50;
                $MethodFormHtml[$_code] = $this->__('因定单金额过大,下单后我们将先收取该订单金额的%s',$CreditLimitPercent."%");
            }elseif($usedCreditLimit<$grandTotal){
                $MethodFormHtml[$_code] = $this->__('当前可用信用额度不足,下单后请等待客服人员联系.');
            }
}

6、后台添加订单状态

System > Order Status

在app/code/core/Mage/order.php文件中的351行下面添加两个状态

const STATE_PENDING_REPAYMENT = 'pending_repayment';
const STATE_PENDING_DEPOSIT = 'pending_deposit';

7、处理订单

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#在code/core/Mage/Checkout/controllers/OnepageController.php文件的successAction方法中添加代码
 
/*订单*/
 $order = Mage::getSingleton('sales/order')->loadByIncrementId($IncrementId);
        $paymentMethod = $order->getPayment()->getMethod();
        if($paymentMethod == 'creditlimit'){
            Mage::dispatchEvent('payment_model_method_creditlimit_pay', array('order' => $order));
}
#payment_model_method_creditlimit_pay触发器在code/core/Mage/Checkout/etc/config.xml文件中添加事件
<payment_model_method_creditlimit_pay><!-- 事件的名字 --> 
      <observers> 
          <update_creadit_limit><!-- 任何唯一的标示符 --> 
          <type>singleton</type>
          <class>Mage_Payment_Model_Method_Creditlimit</class><!-- 我们自己的类(class) --> 
          <method>UpdateCustomerCreditLimit</method><!-- 方法名 -->
          </update_creadit_limit> 
       </observers> 
 </payment_model_method_creditlimit_pay>  
#类和方法在code/core/Mage/Payment/Model/Method/Creditlimit.php文件中<br>#/js/mage/adminhtml/tools.js文件中添加了一个方法后台处理订单状态使用<br>#/design/adminhtml/default/default/template/qquoteadv/sales/order/view/info.phtml文件中添加订单状态处理按钮
 
(责任编辑:最模板)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
栏目列表
热点内容