WooCommerce + woocommerce-checkout-fields-for-TW.php + 綠界物流,超商取貨結帳資訊清空問題
修改綠界物流外掛
1.js/ECPay-shipping-checkout.js
//取代每次選帳單地址就更新,改在點選超商地圖時才更新
jQuery("#ECPayForm").submit(function() {
jQuery('#billing_postcode').trigger('update');
return true;
});
var ecpay_checkout_form = {
.....................
// 取得結帳資訊
get_input_value: function() {
var billing_first_name = ecpay_checkout_form.ecpay_get_element_value('billing_first_name');
var billing_last_name = ecpay_checkout_form.ecpay_get_element_value('billing_last_name');
var billing_company = ecpay_checkout_form.ecpay_get_element_value('billing_company');
var billing_company_tax_id = ecpay_checkout_form.ecpay_get_element_value('billing_company_tax_id');//統編,自訂欄位
var billing_phone = ecpay_checkout_form.ecpay_get_element_value('billing_phone');
var billing_email = ecpay_checkout_form.ecpay_get_element_value('billing_email');
var order_comments = ecpay_checkout_form.ecpay_get_element_value('order_comments');
var shipping_first_name = '';
var shipping_last_name = '';
var shipping_company = '';
var shipping_to_different_address = '0';
if ( $( '#ship-to-different-address' ).find( 'input' ).is( ':checked' ) ) {
shipping_to_different_address = '1';
shipping_first_name = ecpay_checkout_form.ecpay_get_element_value('shipping_first_name');
shipping_last_name = ecpay_checkout_form.ecpay_get_element_value('shipping_last_name');
shipping_company = ecpay_checkout_form.ecpay_get_element_value('shipping_company');
}
var data = {
billing_first_name : billing_first_name,
billing_last_name : billing_last_name,
billing_company : billing_company,
billing_company_tax_id : billing_company_tax_id,//統編,自訂欄位
billing_phone : billing_phone,
billing_email : billing_email,
order_comments : order_comments,
shipping_to_different_address : shipping_to_different_address,
shipping_first_name : shipping_first_name,
shipping_last_name : shipping_last_name,
shipping_company : shipping_company
};
return data;
}
.............................................................
// 取得元素值-如沒有欄位則回傳空值
ecpay_get_element_value: function (id) {
return (document.getElementById(id) == null )? "":document.getElementById(id).value;
},
...........................................................
}
2.ECPay-shipping-integration.php
// 綠界結帳記錄 session 欄位
private $checkoutData = array(
'billing_first_name',
'billing_last_name',
'billing_company',
'billing_company_tax_id',//統編,自訂欄位
'billing_phone',
'billing_email',
'shipping_first_name',
'shipping_last_name',
'shipping_company',
'shipping_to_different_address',
'order_comments'
);
1.js/ECPay-shipping-checkout.js
//取代每次選帳單地址就更新,改在點選超商地圖時才更新
jQuery("#ECPayForm").submit(function() {
jQuery('#billing_postcode').trigger('update');
return true;
});
var ecpay_checkout_form = {
.....................
// 取得結帳資訊
get_input_value: function() {
var billing_first_name = ecpay_checkout_form.ecpay_get_element_value('billing_first_name');
var billing_last_name = ecpay_checkout_form.ecpay_get_element_value('billing_last_name');
var billing_company = ecpay_checkout_form.ecpay_get_element_value('billing_company');
var billing_company_tax_id = ecpay_checkout_form.ecpay_get_element_value('billing_company_tax_id');//統編,自訂欄位
var billing_phone = ecpay_checkout_form.ecpay_get_element_value('billing_phone');
var billing_email = ecpay_checkout_form.ecpay_get_element_value('billing_email');
var order_comments = ecpay_checkout_form.ecpay_get_element_value('order_comments');
var shipping_first_name = '';
var shipping_last_name = '';
var shipping_company = '';
var shipping_to_different_address = '0';
if ( $( '#ship-to-different-address' ).find( 'input' ).is( ':checked' ) ) {
shipping_to_different_address = '1';
shipping_first_name = ecpay_checkout_form.ecpay_get_element_value('shipping_first_name');
shipping_last_name = ecpay_checkout_form.ecpay_get_element_value('shipping_last_name');
shipping_company = ecpay_checkout_form.ecpay_get_element_value('shipping_company');
}
var data = {
billing_first_name : billing_first_name,
billing_last_name : billing_last_name,
billing_company : billing_company,
billing_company_tax_id : billing_company_tax_id,//統編,自訂欄位
billing_phone : billing_phone,
billing_email : billing_email,
order_comments : order_comments,
shipping_to_different_address : shipping_to_different_address,
shipping_first_name : shipping_first_name,
shipping_last_name : shipping_last_name,
shipping_company : shipping_company
};
return data;
}
.............................................................
// 取得元素值-如沒有欄位則回傳空值
ecpay_get_element_value: function (id) {
return (document.getElementById(id) == null )? "":document.getElementById(id).value;
},
...........................................................
}
2.ECPay-shipping-integration.php
// 綠界結帳記錄 session 欄位
private $checkoutData = array(
'billing_first_name',
'billing_last_name',
'billing_company',
'billing_company_tax_id',//統編,自訂欄位
'billing_phone',
'billing_email',
'shipping_first_name',
'shipping_last_name',
'shipping_company',
'shipping_to_different_address',
'order_comments'
);
留言
張貼留言