質問

出荷方法の追加は、それがあるべきであるので起こっています。しかし、出荷方法または、カスタム配送料金は注文に追加されていません。

$address = $quoteObj->getShippingAddress ();
$address->setCollectShippingRates ( true )->collectShippingRates()
        ->setShippingMethod('flatrate_flatrate');
$quoteObj->collectTotals ()->save ();
.


他の質問を検索する私は注文にカスタム配送料金を追加するソリューションを見つけましたが、壮大な合計に配送料金を追加しません。

$shippingprice = 0.9;
$orderObj->setShippingAmount($shippingprice);
$orderObj->setBaseShippingAmount($shippingprice);
.

画像の説明がここにあります

役に立ちましたか?

解決

これを試してみてください:

$shippingprice = 0.9;
$orderObj->setShippingAmount($shippingprice);
$orderObj->setBaseShippingAmount($shippingprice);
$orderObj->setGrandTotal($orderObj->getGrandTotal() + $shippingprice); //adding shipping price to grand total
$orderObj->save();
.

他のヒント

あなたはこれを解決しましたか?

これに遭遇した人のために、あなたは2か所に送料を設定する必要があります。 まず最初にあなたはあなたの価格を設定するために必要な配送方法を設定する必要があります。下記のような私自身のSetShippingMethod機能を作りました。

public function setMyShippingMethod($shippingPrice = 0)
{
$result = Mage::getModel('shipping/rate_result');
// Add carrier
$method = Mage::getModel('shipping/rate_result_method');
if ($shippingPrice > 0) {
   // use my custom shipping method but you can use another shipment method here
   $method->setCarrier('dpdelivery'); 
   $method->setMethod('dpdelivery');
   $method->setCarrierTitle('Shipping');
   $method->setMethodTitle('outside the Netherlands'); 
   $method->setPrice($shippingPrice);
   $method->setCost($shippingPrice);
} else {
   $method->setCarrier('flatrate'); 
   $method->setMethod('flatrate');
   $method->setCarrierTitle('Freeshipping');
   $method->setMethodTitle('within the Netherlands');
   $method->setPrice($shippingPrice);
   $method->setCost($shippingPrice);
}
    $result->append($method);
    return $result;
}
.

その後、CreateOrder関数内で、私は輸送addressを追加してからこのような方法を呼び出します。

$shippingMethod = $this->setMyShippingMethod($shippingCost);
$this->_order->setShippingAddress($shippingAddress)
  ->setShippingMethod($shippingMethod);
$this->_order->setShippingDescription('My shipping description');
.

もちろん私は述べたように注文にコストを追加する必要があります。

$this->order->setIsVirtual(0)
    ....    
    ->setShippingAmount($shippingCost)
    ->setShippingTaxAmount($shippingCostTax)
.

私はそれが誰かを助けることを願っています。

これを試してください

$order->setShippingAmount($shippingprice);
$order->setBaseShippingAmount($shippingprice);
$order->save();
.

ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top