OpenCart 🇺🇦

Схема

public mixed addCredit ( )

Аргументы

Аргумент Возможный тип Описание
У метода нет аргументов

Описание

Метод пока еще не документирован.

Исходный код

$this->language->load('sale/order');

$json = array();

if (!$this->user->hasPermission('modify', 'sale/order')) {
	$json['error'] = $this->language->get('error_permission');
} elseif (isset($this->request->get['order_id'])) {
	$this->load->model('sale/order');

	$order_info = $this->model_sale_order->getOrder($this->request->get['order_id']);

	if ($order_info && $order_info['customer_id']) {
		$this->load->model('sale/customer');

		$credit_total = $this->model_sale_customer->getTotalTransactionsByOrderId($this->request->get['order_id']);

		if (!$credit_total) {
			$this->model_sale_customer->addTransaction($order_info['customer_id'], $this->language->get('text_order_id') . ' #' . $this->request->get['order_id'], $order_info['total'], $this->request->get['order_id']);

			$json['success'] = $this->language->get('text_credit_added');
		} else {
			$json['error'] = $this->language->get('error_action');
		}
	}
}

$this->response->setOutput(json_encode($json));