発送連絡のページの改善 配送状況確認ページURLを自動入力

追記 2025/4/10のヤフオク改悪によりこのページの内容は使用不可となりました。

// 配送状況確認ページURLのフィールドを非表示にする場合は
$(function() {
$('fieldset:contains(配送状況確認ページURL)').hide();
});

 

主要な配送業者はGETメソッドによるパラメータ渡しができるので、発送連絡のページで追跡番号を入力すると配送状況確認ページURLを更新させるようにする。
荷物の追跡をURLで調べる方法 | Nissan March Blog

.shipurlselectdiv {
margin: 4px 0;
}
.shipurlselectdiv input{
vertical-align: text-top;
}
input[type=url]:read-only {
background: #e9ecef !important;
}
// 追跡番号に入力した文字から数字以外を削除する
$(document).on('keyup', 'input[name="shipInvoiceNumber1"]', function (e) {
let input_text = $('input[name="shipInvoiceNumber1"]').val();
input_text = input_text
.replace(/[0-9]/g, function(s) {
return String.fromCharCode(s.charCodeAt(0) - 65248);
})
.replace(/[^0-9]/g, '');
$('input[name="shipInvoiceNumber1"]').val(input_text);
});
// /追跡番号に入力した文字から数字以外を削除する


// 配送状況確認ページURL【任意】をラジオボタンで選択
$(function() {
$('input[name="shipUrl"]').attr('readonly', true);
$('input[name="shipUrl"]').before('<div class="shipurlselectdiv"><label><input type="radio" id="yamato" name="shipUrlselect" value=""> ヤマト運輸</label> <label><input type="radio" id="sagawa" name="shipUrlselect" value=""> 佐川急便</label> <label><input type="radio" id="seino" name="shipUrlselect" value=""> 西濃運輸</label> <label><input type="radio" id="jppost" name="shipUrlselect" value=""> 日本郵便</label></div>');


function shipUrlselectnum(){
shipUrlselect = $('input[name="shipUrlselect"]:checked').val();
shipInvoiceNumber1 = $('input[name="shipInvoiceNumber1"]').val();


if($('input[id="yamato"]').prop('checked')){
$('input[name="shipUrl"]').val('https://jizen.kuronekoyamato.co.jp/jizen/servlet/crjz.b.NQ0010?id='+shipInvoiceNumber1).change();
}
else if($('input[id="sagawa"]').prop('checked')){
$('input[name="shipUrl"]').val('http://k2k.sagawa-exp.co.jp/p/web/okurijosearch.do?okurijoNo='+shipInvoiceNumber1).change();
}
else if($('input[id="seino"]').prop('checked')){
$('input[name="shipUrl"]').val('https://track.seino.co.jp/cgi-bin/gnpquery.pgm?GNPNO1='+shipInvoiceNumber1).change();
}
else if($('input[id="jppost"]').prop('checked')){
$('input[name="shipUrl"]').val('https://trackings.post.japanpost.jp/services/srv/search/?search=追跡スタート&requestNo1='+shipInvoiceNumber1).change();
}
}


$(document).on('keyup', 'input[name="shipInvoiceNumber1"]', function (e) {
shipUrlselectnum();
});


$('input[name="shipUrlselect"]').change( function() {
shipUrlselectnum();
});
});
// /配送状況確認ページURL【任意】をラジオボタンで選択

コメントをどうぞ

メールアドレスが公開されることはありません。 が付いている欄は必須項目です