Jump to content

[Solved] [1.6] Getting errors after creating an order with a payment module


5haun

Recommended Posts

Hi All

I hope someone can help me here.

I  am using a payment module called Payfast and when I create an order and select it as the payment method, the order is created with two hyphens "--" as the payment status instead of the "Payment Accepted". No email is sent to the customer either.

Here is the error_log inside the Payfast module folder:
 

PHP Notice:  Trying to get property of non-object in /classes/stock/StockManager.php on line 318
PHP Notice:  Trying to get property of non-object in /classes/stock/StockManager.php on line 318
PHP Notice:  Trying to get property of non-object in /classes/stock/StockManager.php on line 319
PHP Notice:  Trying to get property of non-object in /classes/stock/StockManager.php on line 319
PHP Notice:  Trying to get property of non-object in /classes/stock/StockManager.php on line 320
PHP Notice:  Trying to get property of non-object in /classes/stock/StockManager.php on line 320
PHP Fatal error:  Uncaught exception 'PrestaShopException' with message 'Property StockMvt->id_employee is empty' in /classes/ObjectModel.php:909
Stack trace:
#0 /classes/ObjectModel.php(246): ObjectModelCore->validateFields()
#1 /classes/ObjectModel.php(487): ObjectModelCore->getFields()
#2 /classes/ObjectModel.php(445): ObjectModelCore->add(true, false)
#3 /classes/stock/StockManager.php(335): ObjectModelCore->save()
#4 /classes/order/OrderHistory.php(241): StockManagerCore->removeProduct('782', '0', Object(Warehouse), 1, '3', true, 15419, 0, NULL)
#5 /classes/PaymentModule.php(682): OrderHistoryCore->changeIdOrderState(2, Object(Order), true)
#6 /modules/payfast/validati in /classes/ObjectModel.php on line 909

If I use the bank wire module I do not get any errors
I am using PS v1.6.1.6

Edited by 5haun
Added more info (see edit history)
Link to comment
Share on other sites

Ok I fixed it

Changed lines 318 - 320 in /classes/stock/StockManager.php  to

                        'id_employee' => (int)$context->employee->id ? (int)$context->employee->id : (int)$id_employee,
                        'employee_firstname' => $context->employee->firstname,
                        'employee_lastname' => $context->employee->lastname,

And line 240 in /classes/order/OrderHistory.php to

                        (int)$this->id_employee

 

Edited by 5haun
Added more code (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 5haun changed the title to [Solved] [1.6] Getting errors after creating an order with a payment module
  • 3 months later...

Since 1.6.1.11, replace in this file, this function:

    /**
     * @param $employee
     * @return array
     */
    protected function getAttributesOfEmployeeRequestingStockMovement($employee)
    {
		if (!Validate::isLoadedObject($employee) && !$context->employee) {

			return array(
				'employee_id' => 0,
				'first_name' => 'Module',
				'last_name' => 'Module'
			);
		}
        $context = Context::getContext();

        if ((int)$context->employee->id) {
            $employeeId = (int)$context->employee->id;
        } else {
            $employeeId = $employee->id;
        }

        if ($context->employee->firstname) {
            $employeeFirstName = $context->employee->firstname;
        } else {
            $employeeFirstName = $employee->firstname;
        }

        if ($context->employee->lastname) {
            $employeeLastName = $context->employee->lastname;
        } else {
            $employeeLastName = $employee->lastname;
        }

        return array(
            'employee_id' => $employeeId,
            'first_name' => $employeeFirstName,
            'last_name' => $employeeLastName
        );
    }

 

  • Thanks 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...