1

私はmagento 1.7.0.2で代金引換支払い方法を使用しています。

この支払いオプションは、特定の郵便番号/暗証番号に対してのみ必要です。

誰でも助けることができますか?

4

5 に答える 5

1

app\design\frontend\base\default\template\checkout\onepage\payment\methods.phtml ファイルを開きます。

このファイルでは、引用オブジェクトから見積もりの​​配送先住所を取得できます。住所から郵便番号を取得しforeach ($methods as $_method):、郵便番号と一致するかどうかを内部で確認してから$_method->getCode();戻ります。メソッドコードはこちらから取得できます。

于 2013-05-08T12:13:24.427 に答える
1

CODには機能があります

public function isAvailable($quote = null)

この最後の行の前にreturn $checkResult->isAvailable;

if条件if($checkResult->isAvailable) 呼び出しを配置し​​ます

$this->isZipCodeallowedForCod($zipCode,$quote)

この関数では、見積もりオブジェクトから請求先住所の郵便番号を取得し、許可された郵便番号のリストをチェックしてフラグを設定するロジックを適用します。

注 : これを変更する場合は、コア コードを変更しないでください。Magento の書き換えまたはオーバーライドの概念を使用してください。

于 2013-05-08T17:30:25.707 に答える
0

私は次のことをしました

app\code\local\Mage\Payment\Model\Method\Cashondelivery.php 内

以下の機能を追加しました

public function getCODPincodes(){
    $write = Mage::getSingleton('core/resource')->getConnection('core_read');
    $query = "select pincode from `pincode`";
    $results = $write->fetchAll($query);
    foreach($results as $result){
        $postcodes[] = $result['pincode'];
    }
    return $postcodes;
}

app\code\local\Mage\Payment\Block\Form\Container.php

protected function _canUseMethod($method){...の下に次のコードを追加しました

次のブロックの後

if((!empty($minTotal) && ($total < $minTotal)) || (!empty($maxTotal) && ($total > $maxTotal))) {
        return false;
    }

追加

if($method->getCode() == "cashondelivery"){
        $postcodes = Mage::getModel('payment/method_cashondelivery')->getCODPincodes();
        $shippingPincode = $this->getQuote()->getShippingAddress()->getData('postcode');
        if(!in_array($shippingPincode, $postcodes)){
            return false;
        }
    }

ノート:

ピンコードと呼ばれるテーブルにすべてのピンコードがあります。

これは私の要件の簡単な修正であるため、これに関する小さなモジュールを開発します

于 2013-05-10T12:15:10.450 に答える
0

必要なのは、ファイル /app/code/core/Mage/Payment/Model/Method/Cashondelivery.php を編集することだけです

それを開き、以下のコードをクラスの最後 (ファイルの最後の「}」の直前) に追加します。

public function isAvailable($quote = null)
{
    if ($quote) {
        // Here is the list of restricted Zip Codes
        $restrictedZips = array(
            '85001',
            '87965'
        );
        $address = $quote->isVirtual() ? $quote->getBillingAddress() : $quote->getShippingAddress();
        $customerZip = $address->getPostcode();
        if (in_array($customerZip, $restrictedZips)) {
            return false;
        }
    }
    return parent::isAvailable($quote);
}
于 2015-07-16T09:14:59.507 に答える