credit.php (1279B)
1 <?php 2 class ModelExtensionTotalCredit extends Model { 3 public function getTotal($total) { 4 $this->load->language('extension/total/credit'); 5 6 $balance = $this->customer->getBalance(); 7 8 if ((float)$balance) { 9 $credit = min($balance, $total['total']); 10 11 if ((float)$credit > 0) { 12 $total['totals'][] = array( 13 'code' => 'credit', 14 'title' => $this->language->get('text_credit'), 15 'value' => -$credit, 16 'sort_order' => $this->config->get('total_credit_sort_order') 17 ); 18 19 $total['total'] -= $credit; 20 } 21 } 22 } 23 24 public function confirm($order_info, $order_total) { 25 $this->load->language('extension/total/credit'); 26 27 if ($order_info['customer_id']) { 28 $this->db->query("INSERT INTO " . DB_PREFIX . "customer_transaction SET customer_id = '" . (int)$order_info['customer_id'] . "', order_id = '" . (int)$order_info['order_id'] . "', description = '" . $this->db->escape(sprintf($this->language->get('text_order_id'), (int)$order_info['order_id'])) . "', amount = '" . (float)$order_total['value'] . "', date_added = NOW()"); 29 } 30 } 31 32 public function unconfirm($order_id) { 33 $this->db->query("DELETE FROM " . DB_PREFIX . "customer_transaction WHERE order_id = '" . (int)$order_id . "'"); 34 } 35 }