1
votes

I would like to display a text saying (Additional Shipping costs to be added) just below 'Subtotal' line in Grand Total box if Shipping is not yet calculated.

This is just to notify the customers that there is an additional Shipping costs as well which would be added to their order at the later (Checkout) stage.

Is there an IF..ELSE I could do which would display this text if shipping cost is not yet calculated and display the Shipping cost with Shipping description if it has been calculated.

Any ideas which template/core files I can modify to do this?

Thanks in advance

EDIT: the totals box is in checkout/cart.phtml from this line

   <?php echo $this->getChildHtml('totals'); ?>

Checking the totals.phtml I get the following,

    <table id="shopping-cart-totals-table">
    <col />
    <col width="1" />
    <tfoot>
        <?php echo $this->renderTotals('footer'); ?>
    </tfoot>
    <tbody>
        <?php echo $this->renderTotals(); ?>
    </tbody>
    </table>

I checked the core file that display SubTotal, Shipping (when its calculated) and GrandTotal

app/code/core/Mage/Sales/Model/Quote/Address/Total/Subtotal.php

  public function fetch(Mage_Sales_Model_Quote_Address $address)
  {
    $address->addTotal(array(
        'code'  => $this->getCode(),
        'title' => Mage::helper('sales')->__('Subtotal'),
        'value' => $address->getSubtotal()
    ));
    return $this;
  }

app/code/core/Mage/Sales/Modle/Quote/Address/Total/Shipping.php

  public function fetch(Mage_Sales_Model_Quote_Address $address)
  {
    $amount = $address->getShippingAmount();
    if ($amount != 0 || $address->getShippingDescription()) {
        $title = Mage::helper('sales')->__('Shipping & Handling');
        if ($address->getShippingDescription()) {
            $title .= ' (' . $address->getShippingDescription() . ')';
        }
        $address->addTotal(array(
            'code' => $this->getCode(),
            'title' => $title,
            'value' => $address->getShippingAmount()
        ));
    }
    return $this;
  }

But I'm not sure if any of these files need editing or some other file. I could not proceed after this and hence require an external help from hereon.

1
You need to show us some code - allen213
@allen213 The thing is I myself am not sure as to which code files need editing and where to exactly look for. I have still edited the question with the possible files and areas I think might need alteration. that's all I know and hence I need an external help. So any ideas? - ivn
I dont know personally but we stand a better chance now we have something to look at - allen213
Very True. I would really appreciate if you could spot something. I have a feeling that there should be an IF--ELSE so that when shipping cost is not calculated a text is instead displayed and if it is calculated then the cost needs to be displayed. - ivn
@allen213 I have posted my answer but I am not quite there. do you think you can help me now? - ivn

1 Answers

0
votes

Using Subtotal.php file I added another IF condition and changed the code like this:

 public function fetch(Mage_Sales_Model_Quote_Address $address)
 {
    $amount = $address->getShippingAmount();
    /* MY MODIFIED CODE */
    if($amount == 0)
    {

            $address->addTotal(array(
            'code' => $this->getCode(),
            'title' => Mage::helper('sales')->__('Subtotal <br/><span style="font-size:12px;color:#A4A5A7;">(Additional Shipping cost to be added)</span>'),
            'value' => $address->getSubtotal()
        ));
    }
    /* --------------- */
    else {
        $title = Mage::helper('sales')->__('Subtotal');
        $address->addTotal(array(
            'code' => $this->getCode(),
            'title' => $title,
            'value' => $address->getSubtotal()
        ));
    }
    return $this;
 }

This adds a line 'Additional shipping cost to be added' just after the Subtotal line perfectly fine.