0

I keep getting the following error :

PHP Fatal error: Call to a member function setCollectShippingRates() on a non-object in /chroot/home/Client/Client.com/html/app/code/local/Company/Checkout/controllers/OnepageController.php on line 12

I don't know if its something to do with $result or setCollectShippingRates() ? Maybe Varien Data somehow? Thanks for the help.

app/code/local/Company/Checkout/controllers/OnepageController.php

require_once'app/code/local/Mage/Checkout/controllers/OnepageController.php';

class Company_Checkout_OnepageController extends Mage_Checkout_OnepageController
{
    public function couponAction()
    {
        $this->loadLayout('checkout_onepage_review');
        $this->couponCode = (string) $this->getRequest()->getParam('coupon_code');

        Mage::getSingleton('checkout/cart')->getQuote()->getShippingAdress()->setCollectShippingRates(true);
        Mage::getSingleton('checkout/cart')->getQuote()->setCouponCode(strlen($this->couponCode) ? $this->couponCode : '')-> collectTotals()->save();

        $result['goto_Section'] = 'review';
        $result['update_section'] = array('name' => 'review', 'html' => $this->_getReviewHtml());

        $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
    }
}
  • 1
    One obvious problem is that you have misspelled getShippingAddress – paj Jul 20 '17 at 20:27
  • Are you rewritting here a OnepageController.php ? – PЯINCƏ Jul 20 '17 at 20:51
  • @Prince Yes. Making new module to add coupon form to review step of one page checkout. Thanks Paj totally missed that. – John Jul 20 '17 at 20:54
0

Try like this:

require_once 'Mage/Checkout/controllers/OnepageController.php';

class Company_Checkout_OnepageController extends Mage_Checkout_OnepageController {
    public function couponAction() {
        $this->loadLayout('checkout_onepage_review');
        $this->couponCode = (string) $this->getRequest()->getParam('coupon_code');

        Mage::getSingleton('checkout/cart')->getQuote()->getShippingAdress()->setCollectShippingRates(true);
        Mage::getSingleton('checkout/cart')->getQuote()->setCouponCode(strlen($this->couponCode) ? $this->couponCode : '')-> collectTotals()->save();

        $result['goto_Section'] = 'review';
        $result['update_section'] = array('name' => 'review', 'html' => $this->_getReviewHtml());

        $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
    }
}
  • You're welcome ;) – PЯINCƏ Jul 20 '17 at 21:04
  • Thanks also @paj spelling error probably would not have helped either – John Jul 20 '17 at 21:04

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.