最模板 - 外贸网站建设,外贸网站模板

最模板

当前位置: 首页 > Magento > Magento教程 >

magento 下订单后手动修改运费

时间:2014-07-11 00:30来源:未知 作者:最模板zuimoban 点击:
magento magento 下订单后手动修改运费 一:配置config.xml 跟订单费率相关的 我们都进行重写方法 重写方法的依据是我们根据core/mage下面的方法来 config modules More_CustomShippingRate version0.1.0/v

magento magento 下订单后手动修改运费

magento 下订单后手动修改运费

 

一:配置config.xml 跟订单费率相关的 我们都进行重写方法 重写方法的依据是我们根据core/mage下面的方法来
 

<config>
 
<modules>
 
<More_CustomShippingRate>
<version>0.1.0</version>
<depends>
<Mage_Shipping />
</depends>
</More_CustomShippingRate>
</modules>
<global>
<blocks>
<adminhtml>
<rewrite><!--重写shipping method-->
<sales_order_create_shipping_method_form>More_CustomShippingRate_Block_Sales_Order_Create_Shipping_Method_Form</sales_order_create_shipping_method_form>
</rewrite>
</adminhtml>
<checkout>
<rewrite><!--重写 cart shipping multishipping  onepage shipping -->
<cart_shipping>More_CustomShippingRate_Block_Cart_Shipping</cart_shipping>
<multishipping_shipping>More_CustomShippingRate_Block_Multishipping_Shipping</multishipping_shipping>
<onepage_shipping_method_available>More_CustomShippingRate_Block_Onepage_Shipping_Method_Available</onepage_shipping_method_available>
</rewrite>
</checkout>
<paypal>
<rewrite>
<express_review>More_CustomShippingRate_Block_Express_Review</express_review>
</rewrite>
</paypal>
</blocks>
<helpers>
<customshippingrate>
<class>More_CustomShippingRate_Helper</class>
</customshippingrate>
</helpers>
<models>
<customshippingrate>
<class>More_CustomShippingRate_Model</class>
</customshippingrate>
<adminhtml>
<rewrite>
<sales_order_create>More_CustomShippingRate_Model_Sales_Order_Create</sales_order_create>
</rewrite>
</adminhtml>
<sales>
<rewrite>
<quote_address_total_shipping>More_CustomShippingRate_Model_Quote_Address_Total_Shipping</quote_address_total_shipping>
<service_quote>More_CustomShippingRate_Model_Service_Quote</service_quote>
</rewrite>
</sales>
</models>
<resources>
<customshippingrate_setup>
<setup>
<module>More_CustomShippingRate</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</customshippingrate_setup>
</resources>
</global>
<adminhtml>
<translate>
<modules>
<More_CustomShippingRate>
<files>
<default>More_CustomShippingRate.csv</default>
</files>
</More_CustomShippingRate>
</modules>
</translate>
<layout>
<updates>
<customshippingrate>
<file>more_customshippingrate.xml</file>
</customshippingrate>
</updates>
</layout>
</adminhtml>
<default>
<carriers>
<customshippingrate>
<active>1</active>
<sallowspecific>0</sallowspecific>
<model>customshippingrate/carrier_customshippingrate</model>
<name>CustomShippingRate</name>
<specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method</specificerrmsg>
</customshippingrate>
</carriers>
</default>
</config>
二:配置前端 layout 我们根据后台默认的sales.xml reference
 
 
<layout>
<adminhtml_sales_order_create_index>
<reference name="shipping_method">
<block type="adminhtml/sales_order_create_shipping_method_form" template="more/customshippingrate/form_custom.phtml" name="form_custom" />
</reference>
</adminhtml_sales_order_create_index>
<adminhtml_sales_order_create_load_block_data>
<reference name="shipping_method">
<block type="adminhtml/sales_order_create_shipping_method_form" template="more/customshippingrate/form_custom.phtml" name="form_custom" />
</reference>
</adminhtml_sales_order_create_load_block_data>
<adminhtml_sales_order_create_load_block_shipping_method>
<reference name="shipping_method">
<block type="adminhtml/sales_order_create_shipping_method_form" template="more/customshippingrate/form_custom.phtml" name="form_custom" />
</reference>
</adminhtml_sales_order_create_load_block_shipping_method>
</layout>
三:前台模板 phtml
 
  
 
<?php if (Mage::helper('customshippingrate')->isEnabled()): ?>
<div>
<dl>
<dt><br/><hr/><br/></dt>
<dd id="custom-shipping-area">
 
<p><strong><?php echo $this->__('Custom Shipping Rate:'); ?></strong>&nbsp;&nbsp;<input id="custom-shipping-rate" type="text" style="width: 100px;" value="<?php if ($this->getCustomShippingPrice()): echo sprintf("%.2f", $this->getCustomShippingPrice()); endif; ?>" /></p>
<p><strong><?php echo $this->__('Title:'); ?></strong>&nbsp;&nbsp;<input id="custom-shipping-title" type="text" style="width: 200px;" value="<?php echo $this->getCustomTitle() ?>" />&nbsp;&nbsp;<button id="custom-shipping-button" type="button" class="scalable "
onclick="order.setCustomShippingValues(document.getElementById('custom-shipping-rate').value,document.getElementById('custom-shipping-title').value,'customshippingrate');"><span><?php echo $this->__('Save'); ?></span></button></p>
<input id="custom-shipping-code" type="hidden" value="customshippingrate" />
 
<input type="radio" id="s_method_customshippingrate_customshippingrate" value="customshippingrate_customshippingrate" onclick="order.setShippingMethod(this.value)" name="order[shipping_method]">
<span>if you want update your rate,click this first!</span>
<ul class="messages">
<li class="notice-msg"><?php echo $this->__('Note: This will override any shipping method selected above.'); ?></li>
</ul>
<script type="text/javascript">
//<![CDATA[
AdminOrder.addMethods({
setCustomShippingValues : function(amount, description, method){
var data = {};
data['order[shipping_amount]'] = amount;
data['order[base_shipping_amount]'] = amount;
data['order[shipping_description]'] = description;
data['order[shipping_method]'] = method;
this.loadArea(['shipping_method', 'totals', 'billing_method'], true, data);
},
 
customshipFieldsBind : function(container){
if($(container)){
var fields = $(container).select('input');
for(var i=0; i<fields.length; i++){
fields[i].observe('change', this.customshipFieldChange.bind(this))
}
}
},
 
customshipFieldChange : function(){
if (document.getElementById('custom-shipping-rate').value && document.getElementById('custom-shipping-title').value) {
var data = {};
data['order[shipping_amount]'] = document.getElementById('custom-shipping-rate').value;
data['order[base_shipping_amount]'] = document.getElementById('custom-shipping-rate').value;
data['order[shipping_description]'] = document.getElementById('custom-shipping-title').value;
data['order[shipping_method]'] = document.getElementById('custom-shipping-code').value;
this.loadArea(false, false, data);
}
},
 
submit : function()
{
if (this.orderItemChanged) {
if (confirm('You have item changes')) {
//if (editForm.submit()) {
// disableElements('save');
// }
} else {
this.itemsUpdate();
}
} else {
if (editForm.submit()) {
disableElements('save');
}
}
}
});
order.customshipFieldsBind($('custom-shipping-area'));
//]]>
</script>
</dd>
</dl>
</div>
<?php endif; ?>
(责任编辑:最模板)
------分隔线----------------------------
栏目列表
推荐内容