チェックアウトのレビュー命令段階での配送方法の変更を防ぐための書き換えモデル
-
29-09-2020 - |
質問
この提案。これは、最終的に「注文」ボタンをクリックする前に注文をチェックするためにPayPalから顧客が返却されたポイントです。私達は見積を通して私達の顧客との送料を事前に同意しているので、彼らに出荷方法を変更するための選択肢は意味がありません。
これはマゼントでこれをすることを最初の試みです。私は のように感じていますが、それは機能していません:
href="https://i.stack.imgur.com/29hy.png" rel="nofollow noreferrer">
マゼントのモデルクラスを上書きする経験を持つ人なら誰もが私が間違っているところであるところに言うことができます。
(1)
(a)/ app / code / local / lms / paypal / model / express and copy in / paypal/core/mage/paypal/model/express/checkout.php
(b)checkout.phpのクラスの名前変更:MAGE_PAYPAL_MODEL_EXPRESS_CHECKOUT to:lms_paypal_model_express_ccheckout mage_paypal_model_express_checkout
を拡張します(c)クラス本体を消去し、この関数だけを置き換える:
/**
* Check whether order review has enough data to initialize
*
* @param $token
* @throws Mage_Core_Exception
*/
public function prepareOrderReview($token = null)
{
parent::prepareOrderReview($token);
$this->_quote->setMayEditShippingAddress(false);
$this->_quote->setMayEditShippingMethod(false);
$this->_ignoreAddressValidation();
$this->_quote->collectTotals()->save();
}
.
(2)
(a)DIR / APP /コード/ローカル/ LMS / PayPal / etc /
(b)そのDIRでconfig.xmlファイルを作成し、このコードを配置します。
<?xml version="1.0"?>
<config>
<modules>
<lms_paypal>
<version>0.1</version>
</lms_paypal>
</modules>
<global>
<models>
<paypal>
<rewrite>
<express>Lms_Paypal_Model_Express</express>
</rewrite>
</paypal>
</models>
</global>
</config>
.
(3)
(a)/ app / etc / modules /
(b)そのDIRにLMS_PAYPAL.XMLを作成し、このコードをLMS_PAYPAL.XMLに入れる:
<?xml version="1.0"?>
<config>
<modules>
<Lms_Paypal>
<active>true</active>
<codePool>local</codePool>
</Lms_Paypal>
</modules>
</config>
. 解決
/app/code/local/Lms/Paypal/etc/config.xml
とモデルファイルで誤って誤って進む
/app/code/local/Lms/Paypal/Model/Express/Checkout.php
.
config.xml
ファイルコードを
<?xml version="1.0"?>
<config>
<modules>
<lms_paypal>
<version>0.1</version>
</lms_paypal>
</modules>
<global>
<models>
<paypal>
<rewrite>
<express>Lms_Paypal_Model_Express</express>
</rewrite>
</paypal>
</models>
</global>
</config>
.
<?xml version="1.0"?>
<config>
<modules>
<Lms_Paypal>
<version>0.1</version>
</Lms_Paypal>
</modules>
<global>
<models>
<paypal>
<rewrite>
<express_checkout>Lms_Paypal_Model_Express_Checkout</express_checkout>
</rewrite>
</paypal>
</models>
</global>
</config>
.
ファイルapp/code/local/Lms/Paypal/Model/Express/Checkout.php
からコードを
public function prepareOrderReview($token = null)
{
parent::prepareOrderReview($token);
$this->_quote->setMayEditShippingAddress(false);
$this->_quote->setMayEditShippingMethod(false);
$this->_ignoreAddressValidation();
$this->_quote->collectTotals()->save();
}
.
class Lms_Paypal_Model_Express_Checkout extends Mage_Paypal_Model_Express_Checkout
{
public function prepareOrderReview($token = null)
{
$payment = $this->_quote->getPayment();
if (!$payment || !$payment->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_PAYER_ID)) {
Mage::throwException(Mage::helper('paypal')->__('Payer is not identified.'));
}
$this->_quote->setMayEditShippingAddress(false);
$this->_quote->setMayEditShippingMethod(false);
$this->_ignoreAddressValidation();
$this->_quote->collectTotals()->save();
}
}
.