0
Magento 1.9.1の製品詳細ページに製品原価を表示する方法はありますか? 各商品に関連する送料が表示されますよう、本当にありがとうございます。Magento 1.9.1の製品ページで製品ごとの送料を表示する方法
Magento 1.9.1の製品詳細ページに製品原価を表示する方法はありますか? 各商品に関連する送料が表示されますよう、本当にありがとうございます。Magento 1.9.1の製品ページで製品ごとの送料を表示する方法
テーマの '/template/catalog/product/view.phtml'ファイルに次のコードを貼り付けることができます。
if($_product->isSaleable())
{
$quote = Mage::getModel('sales/quote');
$quote->getShippingAddress()->setCountryId('DK');
$quote->addProduct($_product);
$quote->getShippingAddress()->collectTotals();
$quote->getShippingAddress()->setCollectShippingRates(true);
$quote->getShippingAddress()->collectShippingRates();
$rates = $quote->getShippingAddress()->getShippingRatesCollection();
foreach ($rates as $rate)
{
echo $rate->getPrice();
}
}
最後のforeachはあなたに有効な別の配送方法の配送料金を提供します。任意の変数に格納し、view.phtmlファイルに必要な場所に表示します。あなたは終わった!
Magento CE 1.9.3.6でうまく動作します。 – Anse
誰もデンマークに住んでいるわけではないので、ちょうど1つのグリッチです: '$ quote-> getShippingAddress() - > setCountryId(Mage :: getStoreConfig( 'general/country/default')); ' – Anse
デンマークのために設定されたなぜ。 –