简体   繁体   中英

Prestashop FrontController::$context is protected property when create a order

My module I'm try to make a order from cart.

In my modules controller file I'm calling validateOrder

 PaymentModule::validateOrder((int)$urbCart->id, $order_status, $order_total, "urb-it", NULL, array(), (int)$currency->id, false, $urbCart->secure_key); 

to create an order. However I got error:

PHP Fatal error: Cannot access protected property 'UrbitOrderCompleteModuleFrontController::$context in /opt/webapp/urbit/classes/PaymentModule.php on line 171'

The payment module error is happen in (line 171) is below

if (!isset($this->context)) {
    $this->context = Context::getContext();
}

Why that context is say as protected property? How can I create order?

validateOrder() is not a static method so in your module controller call it like this:

$this->module->validateOrder((int)$urbCart->id, $order_status, $order_total, "urb-it", NULL, array(), (int)$currency->id, false, $urbCart->secure_key);

Any controller which extends either ModuleFrontController or ModuleAdminController have a property module object of the module which uses the controller.

Edit:

Module class must extend PaymentModule in order to use validateOrder method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM