2
私の製品のview.phtmlファイルにこのコードがあります:私は、配送見積もりを取得しており、イギリスの住所に最も低いコストを基にして、これを製品ページに表示しています。ページ上に完全な吹き飛ばされた見積りをするよりもむしろ。 シンプル製品のため正常に動作しますは、設定可能な製品の商品ページに配送コストをどのように置くことができますか?
<?php
if($_product->isSaleable())
{
$quote = Mage::getModel('sales/quote');
$quote->getShippingAddress()->setCountryId('GB');
$quote->addProduct($_product);
$quote->getShippingAddress()->collectTotals();
$quote->getShippingAddress()->setCollectShippingRates(true);
$quote->getShippingAddress()->collectShippingRates();
$rates = $quote->getShippingAddress()->getShippingRatesCollection();
$minPrice = PHP_INT_MAX;
foreach ($rates as $rate) {
$minPrice = min($minPrice, $rate->getPrice());
}
if ($minPrice == 0) {
echo ('This item qualifies for FREE shipping');
}
elseif ($minPrice < PHP_INT_MAX) {
echo ('Shipping to UK from £' . money_format('%i', $rate->getPrice()) . "\n");
}
}
?>
。ただし設定可能製品には、常に送料が無料で表示されます!どのようにこれを回避することができますか?
これは理にかなっています。上記のコードを構成可能な製品で動作させる方法を見つけましたが、今は単純な製品では機能しません。私は後で私の解決策で更新します。 –