Fazer com que os produtos apareçam se o cliente não atingir o valor da entrega gratuita

magento.stackexchange https://magento.stackexchange.com//questions/31586

  •  11-12-2019
  •  | 
  •  

Pergunta

Quero que alguns produtos sejam exibidos se um usuário não atingir nossa meta de entrega gratuita (£ 75 sem IVA), então tentei escrever uma declaração IF em meu arquivo cart.phtml, mas não sou bom em codificação, mas dei é uma tentativa, então se alguém pudesse me ajudar, seria ótimo.

Este é meu arquivo 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; ?>">&nbsp;</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">&nbsp;</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>

e este é o código que tentei verificar se o subtotal estava acima de 75,00 ou não

    <div class="upsell">

    <?php if ($this->__('Subtotal') < 75.00)
        {
         echo "Why not add these products to qualify for Free Delivery";

        }?>
        </div>

Mas isso não funcionou, minha teoria por trás disso era que $this->__('Subtotal') exibe o subtotal, então pensei em passar isso e verificar se estava abaixo de 75,00, aparentemente não (ou apenas fiz errado caminho).

se você pudesse ajudar seria muito apreciado.

Então, para recapitular, quero que minha instrução IF inclua o subtotal, verifique se o subtotal está abaixo de 75,00, se for o caso, exiba uma mensagem.

Agradeço antecipadamente.

Foi útil?

Solução

Tente usar Mage::helper('checkout/cart')->getQuote()->getGrandTotal() no seu IF em vez de $this->__('Subtotal').Há muito o que explicar aqui, mas basicamente você usou o rótulo do preço como variável de preço.

Você pode querer descartar a variável que forneci primeiro para ver o formato e o tipo de dados que ela retorna, para poder compará-los com seu preço.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top