2

Magento OPC の配送方法の後に 1 ステップ追加しました。

顧客がエクスプレス配送を選択した場合、配送量を 2 倍にして節約する必要があります。これを達成する方法は?

私が試したこと:

1. $quote = $this->getQuote();
 $quote->setShippingAmount($price);
 $quote->setBaseShippingAmount($price);
 $quote->getShippingAddress()->collectShippingRates();
 $quote->getShippingAddress()->collectTotals();
 $quote->save();

これは機能しません。

2.$address = $this->getQuote()->getShippingAddress();
 $method   = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getShippingMethod();

 if ($method) {
    foreach ($address->getAllShippingRates() as $rate) {
         if ($rate->getCode()==$method) {
            $amountPrice = $address->getQuote()->getStore()->convertPrice($rate->getPrice(), false);
            $method->setPrice('20');
            $method->setCost('20');
            $shippingDescription = $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle();
            $address->setShippingDescription(trim($shippingDescription, ' -'));
            break;
            }
        }
    }
4

1 に答える 1