고객이 무료 배달 금액에 도달하지 않은 경우 제품을 얻는 것
문제
사용자가 무료 배달 목표 (£ 75 excl)에 도달 한 경우 몇 가지 제품을 소지하고 싶습니다. 그래서 Cart.phtml 파일에 if 문을 작성하려고했지만 코딩에 좋지는 않지만누군가가 나를 도울 수있게 해줄 수 있다면 나는 그것을주었습니다.
이것은 my cart.phtml 파일 입니다.
<div class="cart">
<div class="page-title title-buttons">
<h1><?php echo $this->__('Shopping Cart') ?></h1>
<?php if(!$this->hasError()): ?>
<ul class="checkout-types">
<?php foreach ($this->getMethods('top_methods') as $method): ?>
<?php if ($methodHtml = $this->getMethodHtml($method)): ?>
<li><?php echo $methodHtml; ?></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<?php echo $this->getChildHtml('form_before') ?>
<form action="<?php echo $this->getUrl('checkout/cart/updatePost') ?>" method="post">
<?php echo $this->getBlockHtml('formkey'); ?>
<fieldset>
<table id="shopping-cart-table" class="data-table cart-table">
<col width="1" />
<col />
<col width="1" />
<?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
<col width="1" />
<?php endif ?>
<?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
<col width="1" />
<?php endif; ?>
<?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
<col width="1" />
<?php endif; ?>
<col width="1" />
<?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
<col width="1" />
<?php endif; ?>
<?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
<col width="1" />
<?php endif; ?>
<col width="1" />
<?php $mergedCells = ($this->helper('tax')->displayCartBothPrices() ? 2 : 1); ?>
<thead>
<tr>
<th class="td-image" rowspan="<?php echo $mergedCells; ?>"> </th>
<th class="td-name" rowspan="<?php echo $mergedCells; ?>"><span class="nobr"><?php echo $this->__('Product Name') ?></span></th>
<th class="td-edit" rowspan="<?php echo $mergedCells; ?>"></th>
<?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
<th class="td-wishlist" rowspan="<?php echo $mergedCells; ?>" class="a-center"><span class="nobr"><?php echo $this->__('Move to Wishlist') ?></span></th>
<?php endif ?>
<th class="td-price" class="a-center" colspan="<?php echo $mergedCells; ?>"><span class="nobr"><?php echo $this->__('Unit Price') ?></span></th>
<th class="td-qty" rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Qty') ?></th>
<th class="td-price" class="a-center" colspan="<?php echo $mergedCells; ?>"><?php echo $this->__('Subtotal') ?></th>
<th class="td-delete" rowspan="<?php echo $mergedCells; ?>" class="a-center"> </th>
</tr>
<?php if ($this->helper('tax')->displayCartBothPrices()): ?>
<tr>
<th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
<th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
<th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
<th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
</tr>
<?php endif; ?>
</thead>
<tfoot>
<tr>
<td colspan="50" class="a-right">
<?php if(Mage::getUrl()): ?>
<button type="button" title="<?php echo $this->__('Continue Shopping') ?>" class="button button_white btn-continue" onclick="setLocation('<?php echo Mage::getUrl() ?>')"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
<?php endif; ?>
<button type="submit" title="<?php echo $this->__('Update Shopping Cart') ?>" class="button button_white btn-update"><span><span><?php echo $this->__('Update Shopping Cart') ?></span></span></button>
</td>
</tr>
</tfoot>
<tbody>
<?php foreach($this->getItems() as $_item): ?>
<?php echo $this->getItemHtml($_item) ?>
<?php endforeach ?>
</tbody>
</table>
<script type="text/javascript">decorateTable('shopping-cart-table')</script>
</fieldset>
</form>
<div class="cart-collaterals row clearfix">
<div class="grid_4">
<?php if (!$this->getIsVirtual()): echo '<div class="cart-block cart-shipping">'.$this->getChildHtml('shipping').'</div>'; endif; ?>
</div>
<div class="grid_4">
<div class="cart-block cart-coupon">
<?php echo $this->getChildHtml('coupon') ?>
</div>
</div>
<div class="grid_4">
<div class="cart-block cart-total">
<?php echo $this->getChildHtml('totals'); ?>
<?php if(!$this->hasError()): ?>
<ul class="checkout-types">
<?php foreach ($this->getMethods('methods') as $method): ?>
<?php if ($methodHtml = $this->getMethodHtml($method)): ?>
<li><?php echo $methodHtml; ?></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
</div>
</div>
<?php echo $this->getChildHtml('crosssell') ?>
</div>
.
이 코드는 하위 합계가 75.00 이상인지 가 아닌지 확인하려고 시도한 코드입니다.
<div class="upsell">
<?php if ($this->__('Subtotal') < 75.00)
{
echo "Why not add these products to qualify for Free Delivery";
}?>
</div>
.
그러나 그 뒤에있는 이론은 $ this -> __ ( 'subtotal')가 소계를 표시하므로 내가 그냥 통과 할 수 있다고 생각하고 75.00 미만이 아닌지 확인할 수 있다고 생각했습니다.그것은 잘못된 방향).
도움이 될 수 있다면 많이 알게 될 것입니다.
Recap에서 if 문을 소계에서 가져 오기를 원한다면 소계가 75.00 미만인지 확인하십시오.
미리 감사드립니다.
해결책
Mage::helper('checkout/cart')->getQuote()->getGrandTotal()
대신에 $this->__('Subtotal')
를 사용해보십시오.여기서 설명하는 것이 많지만 기본적으로 가격 변수로 가격의 라벨을 사용했습니다.
First를 먼저 볼 수있는 변수를 덤프하고 데이터의 유형을 비교할 수 있어야합니다.
제휴하지 않습니다 magento.stackexchange