ShopWorksが正しい方向にプッシュしたおかげで(そして彼のコードスニペットを含めて、メイトに感謝します!しかし、エクスプレスからカートに戻るとバグが発生します)、この問題は私を悩ませてきました(そしてそれは何年もの間マゼントコミュニティに見えます)チェックアウト、これを防ぐためにチェックインを追加しました。)$ requestパラメーターの次の修正(/ hack)を思いつきました:
Nvp.phpの606行目に、次のように配置します。
$totalValue = $request['TAXAMT'] + $request['ITEMAMT'];
$finalValue = $totalValue - $request['AMT'];
if($request['SHIPPINGAMT'] > 0) {
$request['SHIPPINGAMT'] = ($request['AMT'] - ($request['TAXAMT'] + $request['ITEMAMT']));
$totalValue = $request['TAXAMT'] + $request['ITEMAMT'] + $request['SHIPPINGAMT'];
$finalValue = $totalValue - $request['AMT'];
}
if($request['AMT'] != $totalValue) {
if($totalValue > $request['AMT']) {
$request['TAXAMT'] = $request['TAXAMT'] - $finalValue;
} elseif($totalValue < $request['AMT']) {
$request['TAXAMT'] = $request['TAXAMT'] + $finalValue;
} else {
$request['AMT'] = $request['TAXAMT'] + $request['ITEMAMT'];
}
}
さらに、call()関数内に次のものも配置する必要があります(Nvp.phpの938行目)。
$totalValue = $request['TAXAMT'] + $request['ITEMAMT'] + $request['SHIPPINGAMT'];
$finalValue = $totalValue - $request['AMT'];
if($request['AMT'] != $totalValue) {
if($totalValue > $request['AMT']) {
if($finalValue > 0) {
// its preferable that we change the tax amount over the grand total amount
$request['TAXAMT'] = $request['TAXAMT'] - $finalValue;
} else {
$request['AMT'] = $totalValue;
}
} elseif($totalValue < $request['AMT']) {
if($finalValue > 0) {
// its preferable that we change the tax amount over the grand total amount
$request['TAXAMT'] = $request['TAXAMT'] + $finalValue;
} else {
$request['AMT'] = $totalValue;
}
} else {
$request['AMT'] = $totalValue;
}
}
これはハックであり、そのように扱います。私の同僚は現在テスト中ですが、今のところ問題ないようです。税額の計算方法を単価で設定することも役立ちます(会計士はこの取り決めに満足していますが、これは英国向けです。他の国はその特定の税計算方法に眉をひそめるでしょう)。
私が$request['AMT']を操作している理由は、$ finalValue変数の計算によって-0.9999の繰り返し整数が生成されることがあるためです。これはだれにも役に立たないので、私の数学はひどいので、誰かがこれを改善したい場合は、そうしてください!
いつものように、コアディレクトリのnvp.phpを上書きしないでください。別の書き換えモジュールを作成するか、app / local/mageでこれを行ってください。できれば最初のオプション!:-)