The automatic splitting function is not provided in the ecshop system. if we need to add a single splitting function, we need to go to secondary development. The following is an example for you. Rough logic: the backend automatically splits an order when it is delivered, and the backend cancels delivery ,... the automatic splitting function is not provided in the ecshop system. if we need to add a single splitting function, we need to go to secondary development. The following is an example for you.
Rough logic:
The background operation automatically divides an order when it is delivered. the background cancels the delivery and returns the order. Instead, it removes the automatic parts when it is not delivered.
Core code: lib_common.php
// Divide into points for calculation
GetRow ("SELECT * from ". $ GLOBALS ['ecs']-> table ('users '). "u ". "WHERE u. shopid = ". $ order ['parent _ shopid ']. "and u. usertype = 1 "); // Obtain the pid $ up_uid = $ row ['User _ id']; if (! Empty ($ up_uid) & $ up_uid> 0) {$ money = $ point = 0; $ point = fenchenjifen (1, $ integral ['m M _ points']); // $ info = sprintf ($ GLOBALS ['_ LANG'] ['separate _ info'], $ order ['Order _ sn '], $ money, $ point ); $ info = "order ". $ order ['Order _ sn ']. "Points for splitting :". $ point; log_account_change ($ up_uid, $ money, 0, ($ type) * $ point, ($ type) * $ point, $ info ); // var_dump ($ info); if ($ type = 1) {write_affiliate_log1 ($ ord Er_id, $ up_uid, $ row ['User _ name'], $ money, $ point, $ separate_by);} else {rollback_affiliate_log ($ order_id );} $ orderupdate ['is _ separate'] = $ type = 1? $ Separate_by: 0; $ GLOBALS ['DB']-> autoExecute ($ GLOBALS ['ecs']-> table ('Order _ info'), $ orderupdate, 'update', "order_id = '$ order_id'");} break; case '3': $ row = $ GLOBALS ['DB']-> getAll ("SELECT u. shopid, u. user_id, u. usertype, u. user_name FROM ". $ GLOBALS ['ecs']-> table ('users '). "u ". "WHERE u. shopid = ". $ order ['parent _ shopid ']. "and u. usertype in (1, 2) "); foreach ($ row as $ val) {// Obtain dealer and finance Split into if ($ val ['usertype'] = 1) {$ pointf = fenchenjifen (1, $ integral ['m M _ points']);} if ($ val ['usertype'] = 2) {$ pointf = fenchenjifen (2, $ integral ['m M _ points']);} $ up_uid = $ val ['User _ id']; // $ info = sprintf ($ GLOBALS ['_ LANG'] ['separate _ info'], $ order ['Order _ sn '], $ money, $ pointf); $ info = "order ". $ order ['Order _ sn ']. "Points for splitting :". $ pointf; log_account_change ($ up_uid, $ money, 0, ($ type )* $ Pointf, ($ type) * $ pointf, $ info); if ($ type = 1) {write_affiliate_log1 ($ order_id, $ up_uid, $ val ['User _ name'], $ money, $ pointf, $ separate_by);} else {rollback_affiliate_log ($ order_id );} $ orderupdate ['is _ separate'] = $ type = 1? $ Separate_by: 0; $ GLOBALS ['DB']-> autoExecute ($ GLOBALS ['ecs']-> table ('Order _ info'), $ orderupdate, 'update', "order_id = '$ order_id'");} break;} return true ;} /***** @ param undefined $ oid * @ param undefined $ uid * @ param undefined $ username * @ param undefined $ money * @ param undefined $ point * @ param undefined $ separate_by * The write order is divided into log */function write_affiliate_log1 ($ oid, $ uid, $ username, $ money, $ point, $ separate_by) {$ time = gmtime (); $ SQL = "INSERT ". $ GLOBALS ['ecs']-> table ('affiliate _ log '). "(order_id, user_id, user_name, time, money, point, separate_type )". "VALUES ('$ ID',' $ uid', '$ username',' $ time', '$ money',' $ point', $ separate_by )"; if ($ oid) {$ GLOBALS ['DB']-> query ($ SQL) ;}// revoke the order into function rollback_affiliate_log ($ order_id, $ falg =-2) {$ SQL = "UPDATE ". $ GLOBALS ['ecs']-> table ('affiliate _ log '). "SET separate_type = '$ falg '". "WHERE order_id = '$ order_id'"; $ GLOBALS ['DB']-> query ($ SQL );}
Note: The background shipping program needs to be modified in admin/order. php: Ship 866 lines, cancel shipping 1035 lines, and change to not ship 3961 lines to return 4132 lines. This code only calculates the parts. Order part separately. This code is divided into multiple merchants according to the store ID. This is the secondary development version of ecshop. Cannot be used in the original version. Call splitting: fun_fencheng_change ($ order, $ user, $ integral, 1 );
Unsharding: fun_fencheng_change ($ order, $ user, $ integral,-1 );
Permanent address:
Reprint at will ~ Please bring the tutorial URL ^