Pergunta

Eu criei uma instrução if que eu tenho na minha página envio.Onde se o atributo "entrega direta" é verdadeiro, então ele irá exibir uma mensagem de erro e não mostrar entrega gratuita.Coloquei a instrução Se abaixo.

<?php $quote = Mage::getSingleton('checkout/session')->getQuote();
        $cartItems = $quote->getAllVisibleItems();

        foreach ($cartItems as $item)
        {
            $productId = $item->getProductId();
            $product = Mage::getModel('catalog/product')->load($productId);
                   if($product->getData('direct_delivery_product')==1){?>

             <div class="direct_message">
             <?php echo 'You have direct delivery products in your shopping cart. This means it may take longer than the standard 2-5 working days to deliver.';?></div>

                <?php unset($_shippingRateGroups["freeshipping"]);
                 break;
             }

                }

?>

No entanto no meu cesto página onde mostra o total de ele ainda diz que a entrega é grátis.Eu tentei adicionar a minha instrução SE para o arquivo de modelo, onde ele exibe o transporte, mas que não funcionam.Alguém poderia me dizer como posso obtê-lo apresentar o padrão taxa de envio em vez de frete grátis.Se o atributo for true.Este é o meu o arquivo de modelo que mostra a entrega na página carrinho.

<?php if ($this->displayBoth()):?>
<tr>
    <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
        <?php echo $this->getExcludeTaxLabel() ?>
    </td>
    <td style="<?php echo $this->getStyle() ?>" class="a-right">
        <?php echo $this->helper('checkout')->formatPrice($this->getShippingExcludeTax()) ?>
    </td>
</tr>

<tr>
    <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
        <?php echo $this->getIncludeTaxLabel() ?>
    </td>
    <td style="<?php echo $this->getStyle() ?>" class="a-right">
        <?php echo $this->helper('checkout')->formatPrice($this->getShippingIncludeTax()) ?>
    </td>
</tr>


<?php elseif($this->displayIncludeTax()) : ?>
<tr>
    <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
        <?php echo $this->getTotal()->getTitle() ?>
    </td>
    <td style="<?php echo $this->getStyle() ?>" class="a-right">
        <?php echo $this->helper('checkout')->formatPrice($this->getShippingIncludeTax()) ?>
    </td>
</tr>
<?php else:?>


<tr>

    <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
        <?php echo $this->escapeHtml($this->getTotal()->getTitle()) ?>
    </td>
    <td style="<?php echo $this->getStyle() ?>" class="a-right">
        <?php echo $this->helper('checkout')->formatPrice($this->getShippingExcludeTax()) ?>
    </td>
</tr>
<?php endif;?>
Foi útil?

Solução

Você pode reescrever o frete grátis transportadora modelo Mage_Shipping_Model_Carrier_Freeshipping e adicionar esse método dentro da sua nova classe

public function proccessAdditionalValidation(Mage_Shipping_Model_Rate_Request $request)
{
    $items = $request->getAllVisibleItems();
    foreach ($items as $item) { 
        if ($items->getProduct()->getData('direct_delivery_product')) {
             return false;
        }
    }
}

este deve desabilitar o envio gratuito de método quando um produto com direct_delivery_product definida para sim no seu carrinho.

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