lenny_ Posted November 11, 2015 Share Posted November 11, 2015 Hi Guys I'm new to Prestashop development and I like what I see so far :-) However, I have hit a stumbling block in the development of a payment module. Once payment has been made and I validate that it has been successful, I now want to save the cart contents to the orders table. So I am extending my main class and then I am calling the following function: public function prepareOrder($result) { // $customer = new Customer($this->context->cart->id_customer); $currency = $this->context->currency->id; $id_cart = $this->context->cart->id; $id_order_state = '2'; $message = $this->context->cart->gift_message; $shop_id = $this->context->cart->id_shop; $this->validateOrder($id_cart, $id_order_state, (float)$this->context->cart->getOrderTotal(true, Cart::BOTH), $this->module->displayName); } I have read that the validateOrder method is the one to use to save the cart to the orders table. However, when I do this I have the following error: Notice: Undefined property: CreateOrder::$module in C:\wamp\www\prestashop\modules\rinsedbt\classes\CreateOrder.php on line 28 Call Stack # Time Memory Function Location 1 0.0010 264904 {main}( ) ..\checkout.php:0 2 0.2150 21393216 BtCheckoutSubmit->__construct( ) ..\checkout.php:50 3 0.2180 21569480 BtCheckoutSubmit->prepare_order_details( ) ..\checkout.php:20 4 1.5352 26162120 BtCheckoutSubmit->showPaymentResult( ) ..\checkout.php:33 5 1.5352 26168952 CreateOrder->prepareOrder( ) ..\checkout.php:46 ( ! ) Notice: Trying to get property of non-object in C:\wamp\www\prestashop\modules\rinsedbt\classes\CreateOrder.php on line 28 Call Stack # Time Memory Function Location 1 0.0010 264904 {main}( ) ..\checkout.php:0 2 0.2150 21393216 BtCheckoutSubmit->__construct( ) ..\checkout.php:50 3 0.2180 21569480 BtCheckoutSubmit->prepare_order_details( ) ..\checkout.php:20 4 1.5352 26162120 BtCheckoutSubmit->showPaymentResult( ) ..\checkout.php:33 5 1.5352 26168952 CreateOrder->prepareOrder( ) ..\checkout.php:46 ( ! ) Fatal error: Uncaught exception 'PrestaShopException' with message 'Property Order->payment is empty' in C:\wamp\www\prestashop\classes\ObjectModel.php on line 866 ( ! ) PrestaShopException: Property Order->payment is empty in C:\wamp\www\prestashop\classes\ObjectModel.php on line 866 Call Stack # Time Memory Function Location 1 0.0010 264904 {main}( ) ..\checkout.php:0 2 0.2150 21393216 BtCheckoutSubmit->__construct( ) ..\checkout.php:50 3 0.2180 21569480 BtCheckoutSubmit->prepare_order_details( ) ..\checkout.php:20 4 1.5352 26162120 BtCheckoutSubmit->showPaymentResult( ) ..\checkout.php:33 5 1.5352 26168952 CreateOrder->prepareOrder( ) ..\checkout.php:46 6 1.5502 26180408 PaymentModuleCore->validateOrder( ) ..\CreateOrder.php:28 7 1.5782 26386784 OrderCore->add( ) ..\PaymentModule.php:335 8 1.5782 26387824 ObjectModelCore->add( ) ..\Order.php:304 9 1.5782 26388336 OrderCore->getFields( ) ..\ObjectModel.php:480 10 1.5782 26388536 ObjectModelCore->getFields( ) ..\Order.php:299 11 1.5782 26388632 ObjectModelCore->validateFields( ) ..\ObjectModel.php:272 I'm really stumped here and can find no solution to this. Anyone have any ideas? thanks in advance! Link to comment Share on other sites More sharing options...
bellini13 Posted November 11, 2015 Share Posted November 11, 2015 Undefined property: CreateOrder::$module in C:\wamp\www\prestashop\modules\rinsedbt\classes\CreateOrder.php on line 28 What does line 28 of CreateOrder.php look like? Link to comment Share on other sites More sharing options...
lenny_ Posted November 11, 2015 Author Share Posted November 11, 2015 Hi Thanks for the reply :-) Line 28 is the last line of the above code: $this->validateOrder($id_cart, $id_order_state, (float)$this->context->cart->getOrderTotal(true, Cart::BOTH), $this->module->displayName); It seems that is doesn't like $this->module->displayName However, as this extends from the main module file, it should have the same properties... And in the class it extends from I have $this->displayName = $this->l('My Payment Gateway'); Any ideas? Link to comment Share on other sites More sharing options...
bellini13 Posted November 11, 2015 Share Posted November 11, 2015 so would it be $this or parent ? Link to comment Share on other sites More sharing options...
lenny_ Posted November 13, 2015 Author Share Posted November 13, 2015 Not sure... Perhaps I should do this in the constructor: parent::__construct(); ?? Link to comment Share on other sites More sharing options...
lenny_ Posted November 13, 2015 Author Share Posted November 13, 2015 When I add the parent constructor method to the class I am now getting the following error: Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now