1、添加产品属性:
catalog->Attributes->Manage Attributes
进去栏目添加一个code:is_reserve lable:customized products的产品属性
2、添加用户属性:
#添加Custom Type 属性 $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $AttrCode = 'type'; $settings = array ( 'position' => 1, 'label' => 'Custom Type', 'is_required'=> 0, 'input' => 'select', 'type' => 'int', 'sort_order' => '999', 'model' => 'eav/entity_attribute_source_customertype' ); $setup->addAttribute('1', $AttrCode, $settings); #上传Eav/Model/Entity/Attribute/Source/customertype.php文件选择公司和个人的选择器
form_code = adminhtml_customer #管理属性
attribute_id = 556 #属性表的id
#添加Custom Type 属性 $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $AttrCode = 'credit_limit'; $settings = array ( 'position' => 1, 'label' => 'Credit Limit', 'is_required'=> 0, 'input' => 'text', 'type' => 'int', 'sort_order' => '999', ); $setup->addAttribute('1', $AttrCode, $settings); #添加完之后再数据库中找这个attribute_id form_code = adminhtml_customer #管理属性 attribute_id = 557 #属性表的id #月结支付的显示阈值 #添加Credit Limit Threshold 属性 $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $AttrCode = 'credit_threshold'; $settings = array ( 'position' => 1, 'label' => 'Credit Limit Threshold', 'is_required'=> 0, 'input' => 'text', 'type' => 'int', 'sort_order' => '999', ); $setup->addAttribute('1', $AttrCode, $settings); #添加完之后再数据库中找这个attribute_id
#单笔订单金额收取百分百比 #添加预付金百分比 属性 $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $AttrCode = 'custom_payment'; $settings = array ( 'position' => 1, 'label' => 'Percentage of Deposit', 'is_required'=> 0, 'input' => 'text', 'type' => 'int', 'sort_order' => '999', ); $setup->addAttribute('1', $AttrCode, $settings); #添加完之后再数据库中找这个attribute_id #添加Max Credit Limit 属性 $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $AttrCode = 'max_credit_payment'; $settings = array ( 'position' => 1, 'label' => 'Max Credit Limit per Order', 'is_required'=> 0, 'input' => 'text', 'type' => 'int', 'sort_order' => '999', ); $setup->addAttribute('1', $AttrCode, $settings); #添加完之后再数据库中找这个attribute_id #添加Use Credit Limit属性 $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $AttrCode = 'use_credit_limit'; $settings = array ( 'position' => 1, 'label' => 'Use Credit Limit', 'is_required'=> 0, 'input' => 'text', 'type' => 'int', 'sort_order' => '999', ); $setup->addAttribute('1', $AttrCode, $settings); #添加完之后再数据库中找这个attribute_id
#添加cumulative_credit用户属性。
$AttrCode = 'cumulative_credit';
$settings = array (
'position' => 1,
'label' => 'Cumulative credit',
'is_required'=> 0,
'input' => 'text',
'type' => 'varchar',
'sort_order' => '999',
);
$setup->addAttribute('1', $AttrCode, $settings);
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$AttrCode = 'remain_credit';
$settings = array (
'position' => 1,
'label' => 'Available Credit Line',
'is_required'=> 0,
'input' => 'text',
'type' => 'varchar',
'sort_order' => '999',
);
$setup->addAttribute('1', $AttrCode, $settings);
3、添加支付插件
#Payment/etc/system.xml <!--自定义支付方式--> <creditlimit translate="label"> <label>Credit Limit</label> <frontend_type>text</frontend_type> <sort_order>30</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> <fields> <active translate="label"> <label>Enabled</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_yesno</source_model> <sort_order>1</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </active> <order_status translate="label"> <label>New Order Status</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_order_status_new</source_model> <sort_order>20</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </order_status> <sort_order translate="label"> <label>Sort Order</label> <frontend_type>text</frontend_type> <sort_order>100</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> <frontend_class>validate-number</frontend_class> </sort_order> <title translate="label"> <label>Title</label> <frontend_type>text</frontend_type> <sort_order>10</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </title> <allowspecific translate="label"> <label>Payment from Applicable Countries</label> <frontend_type>allowspecific</frontend_type> <sort_order>50</sort_order> <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </allowspecific> <specificcountry translate="label"> <label>Payment from Specific Countries</label> <frontend_type>multiselect</frontend_type> <sort_order>51</sort_order> <source_model>adminhtml/system_config_source_country</source_model> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> <can_be_empty>1</can_be_empty> </specificcountry> <!-- <payable_to translate="label"> <label>Make Check Payable to</label> <sort_order>61</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </payable_to> --> <!-- <mailing_address translate="label"> <label>Send Check to</label> <frontend_type>textarea</frontend_type> <sort_order>62</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </mailing_address> --> <min_order_total translate="label"> <label>Minimum Order Total</label> <frontend_type>text</frontend_type> <sort_order>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
配置完之后再后台支付哪里可以看到,启用支付插件System > Configuration > Payment Methods
5、修改前端支付方法文件
#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、处理订单
#在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文件中
#/js/mage/adminhtml/tools.js文件中添加了一个方法后台处理订单状态使用
#/design/adminhtml/default/default/template/qquoteadv/sales/order/view/info.phtml文件中添加订单状态处理按钮
创建订单字断段
ALTER TABLE `sales_flat_order` ADD `deposit` VARCHAR(10) NOT NULL DEFAULT '0' COMMENT '预订金' AFTER `c2q_internal_quote_id`;
在后台订单状态哪里新建状态,已收定金