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));
 }
}
PЯINCƎ
11.8k3 gold badges27 silver badges85 bronze badges
asked Jul 20, 2017 at 19:37
3
  • 1
    One obvious problem is that you have misspelled getShippingAddress Commented Jul 20, 2017 at 20:27
  • Are you rewritting here a OnepageController.php ? Commented Jul 20, 2017 at 20:51
  • @Prince Yes. Making new module to add coupon form to review step of one page checkout. Thanks Paj totally missed that. Commented Jul 20, 2017 at 20:54

1 Answer 1

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));
 }
}
answered Jul 20, 2017 at 21:01
2
  • You're welcome ;) Commented Jul 20, 2017 at 21:04
  • Thanks also @paj spelling error probably would not have helped either Commented Jul 20, 2017 at 21:04

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.