0

配送業者のドロップダウンと配送方法のラジオ ボタンを、javascript 関数を使用して 1 回だけ変更する必要があります。永久に変更する必要はありません。

ただし、注文が $5 未満のときに [レビューと送信] ページで実行されるこの関数を使用すると、無限ループに陥ります。

function setFreeSampShipping(){
 var options = document.forms['checkout'].shippingcarrierselect.getElementsByTagName('option');
 for (i=0;i<options.length;i++){
  if (options[i].value == 'nonups'){
   document.forms['checkout'].shippingcarrierselect.value='nonups';
   document.forms['checkout'].shippingcarrierselect.onchange();
   document.location.href='/app/site/backend/setshipmeth.nl?c=659197&n=1&sc=4&sShipMeth=2035';
  }
 }
}

関数 setSampPolicyElems() のこの部分から呼び出されます。ループを停止するためにコメントアウトしたことがわかります。

if (carTotl < 5 && hasSampp == 1) { 
    /*
    if (document.forms['checkout'].shippingcarrierselect.value =='ups'){
      setFreeSampShipping();
    }
    */
    document.getElementById('sampAdd').style.display="none";
    document.getElementById("custbody_ava_webshiptype").value = "7";//no charge free freight
    if (document.getElementById("applycoupon")) {
        document.location.href='/app/site/backend/setpromocode.nl?c=659197&n=1&sc=4&kReferralCode=SAMPLE'
    } 
    document.write("<div id='msg'><strong>Sample & Shipping:</strong></span> No Charge. (Your sample order is < $5.)</div>");
}

問題を確認するには、次の注文の確認と送信のページにアクセスしてください: https://checkout.netsuite.com/s.nl?c=659197&sc=4&n=1 (またはhttp://www.avaline.comに移動します。 「チェックアウト」を押してログインします)

次の資格情報でログインできます:
電子メール: test2@gmail.com
パス: test03

これまでの私の解決策は、onchange() イベント トリガー行をこれと交換することでした。これにより、document.location.href を 2 回実行しなくなりました。代わりに、1 つの URL クエリ文字列で 2 つの変数を渡しています。

var dropdown = document.getElementById('shippingcarrierselect');
document.body.style.cursor = 'wait';
document.location.href='/app/site/backend/setshipmeth.nl?c=659197&n=1&sc=4&sShipMeth=2035&sShipCarrier='+dropdown.value;
4

2 に答える 2

0

変数「i」はグローバルです。また、options.lengthを変数に格納する必要があります。「i」は、無限ループを引き起こす一部のスクリプトによって設定される場合があります。

于 2010-06-05T06:17:56.553 に答える
0

これが私の解決策でした:

var dropdown = document.getElementById('shippingcarrierselect'); document.body.style.cursor = 'wait'; document.location.href='/app/site/backend/setshipmeth.nl?c=659197&n=1&sc=4&sShipMeth=2035&sShipCarrier='+dropdown.value;
于 2010-06-07T15:24:59.543 に答える