0

In my magento store, I have merged the payment method and review steps in the onepage checkout. The shipping method is also skipped since it's fixed(table rates). With that, after I input the billing info, it goes to the Payment and Order Review step which is the last step of my checkout page.

At the order review table on that section, the shipping fee is not displayed unless I go back one step and then forward again to Payment and Order Review step.

What I want to do is when I input the billing info, it computes the shipping fee before proceeding to the payment method step. That way it would already appear at the review table.

0

I've been struggling with the same issue for the past weeks. The only way I got it working is through this rather nasty hack. I really hope someone will find a cleaner solution, but for now, it works.

Basically I do a recalculation just before the template is rendered. I created a copy of review.phtml: app/design/frontend/custom/view/template/checkout/onepage/review.phtml and added a method call at the top of the template:

<?php
$this->reCalculateTotals();
?>

Then I created a copy of Review.php: app/code/local/Mage/Checkout/Block/Onepage/Review.php and added the public method:

public function reCalculateTotals() {
    $this->getQuote()->collectTotals(true)->save();
}

Pay close attention to the parameter true I pass to collectTotals: A copy of Quote.php goes to app/code/local/Mage/Sales/Model/Quote.php and at around line 1280 I change the signature of collectTotals to:

/**
 * Collect totals
 *
 * @param bool $force Should we ignore getTotalsCollectedFlag
 *
 * @return Mage_Sales_Model_Quote
 */
public function collectTotals($force = false)

and change the if statement to ignore a return when forced to recalculate"

    /**
     * Protect double totals collection
     */
    if (!$force && $this->getTotalsCollectedFlag()) {
        return $this;
    }

This should do the trick (as long as you have your shipping method already saved). If not, let me know and I'll add more info on how I saved the shipping method (this might be a bit tricky since I use Carriers and not table rates).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.