Thursday 15 April 2010

php - Issue on store credit of opencart 1.5.6 -



php - Issue on store credit of opencart 1.5.6 -

i want create order client in administration. client has credit (let's $200). order total calculated order total - customer's credit = new order total.

the problem customer's credit not alter after creating order.

for example:

the order total is: $500 credit is: $200 then order total : $500 - $200 = $300 but customer's credit still: $200

has else had same problem?

i seek alter status of order, both processing , setting, doesn't work.

the transaction in client info page not change.

i have checked code in backend - there no code operate oc_customer_transaction table.

in frontend, there function in /catalog/model/total/credit.php

class="lang-php prettyprint-override">public function confirm($order_info, $order_total) { $this->language->load('total/credit'); if ($order_info['customer_id']) { $this->db->query("insert " . 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()"); } }

it called during checkout process recalculate customer's credit balance. haven't found such code in backend.

i prepare that.

code:

$this->db->query("insert " . 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()");

just add together credit calculate code when @ next place:

1./admin/model/sale/order.php addorder method

a. when add together product new client order in backend, scheme send request frontend (/catalog/checkout/mannual.php index ) wo calculate order total(such as: subtotal, credit, shipping, total). after request, order total in page refreshed

b. when save order, (admin/model/sale/order.php) addorder method called eventually. need add together code above function.

insert into..... customer_transaction means utilize credit

2./admin/model/sale/order.php editorder method

a. when edit order, each item in totals changed. so, should delete credit used order before.

delete * oc_customer_transaction 'order_id'=$order_id

b. since each item of totals(involve credit) has been recalculated in step1, method receive new credit amount. insert new amount code blow

3.you not need alter admin/model/sale/order.php deleteorder method because delete totals, include item in info table oc_customer_transaction

things done!

php opencart

No comments:

Post a Comment