我在Magento中使用onestepcheckout。我增加了一些額外的固定費率,我使用了其中兩個。我希望能夠僅顯示取決於購物車小計的統一費率之一。如果陳述只顯示數組中的一個值
我已經將小計變成了一個變量,但代碼有一個foreach,通過每種運輸方法可用,所以我需要一種方法來說,如果$total
超過500只顯示第二種運輸方法,如果總數低於500只顯示第一種運輸方式。
<?php $total = Mage::getSingleton('checkout/session')->getQuote()->getSubtotal(); ?>
<?php foreach ($_shippingRateGroups as $code => $_rates): ?>
<dd><?php echo $this->getCarrierName($code) ?></dd>
<?php foreach ($_rates as $_rate): ?>
<dt style="margin-bottom: 5px;">
<?php if ($_rate->getErrorMessage()): ?>
<ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
<?php else: ?>
<input name="shipping_method" type="radio" class="validate-one-required-by-name" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> />
<label for="s_method_<?php echo $_rate->getCode() ?>"><!--<b><?php echo $this->getCarrierName($code) ?>:</b>--> <?php echo $_rate->getMethodTitle() ?>
<strong>
<?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
<?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
<?php echo $_excl; ?>
<?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
(<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
<?php endif; ?>
</strong>
</label>
<?php endif ?>
</dt>
<?php endforeach; ?>
<?php endforeach; ?>
什麼部分,具體是你有麻煩嗎?它看起來像你已經知道如何使用'if'語句。 – sgroves
@sgroves我需要一種方法來獲得兩個不同的速率'flatrate'和'flatrate2'到if語句中 – Matt
在這段代碼中,沒有任何地方顯示flatrate或flatrate2任何地方,他們的方法嗎?或變量?或者是什麼? – KyleK