Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to realize the function of automatic order confirmation in the background by ecshop

Shulou Source: shulou.com Published: 2022-06-02 00:18:58 10月02日 Update

Editor to share with you ecshop how to achieve automatic confirmation of backstage orders, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

CREATE TABLE `order_auto_ Secretm` (`id` INT (10) UNSIGNED NOT NULL AUTO_INCREMENT, `order_ id` INT (10) UNSIGNED NOT NULL DEFAULT '0mm, `order_ SN` VARCHAR (20) NOT NULL, `execute_ time` INT (10) UNSIGNED NOT NULL DEFAULT' 0mm, `order_ status` TINYINT (3) UNSIGNED NOT NULL DEFAULT'0' COMMENT'0 is not determined 1 has been determined', `addtime` INT (10) UNSIGNED NOT NULL DEFAULT '0confirmation, `update_ time` INT (10) UNSIGNED NOT NULL DEFAULT' 0recording mastering primary KEY (`id`), UNIQUE INDEX `order_ id` (`execute_ id`), INDEX `timetime` (`execute_ time`) COMMENT=' orders are automatically determined on a regular basis' COLLATE='utf8_general_ci'ENGINE=MyISAM'

I.

/ admin/order.php adds the following code:

Elseif ($_ REQUEST ['act'] = =' order_cron') {$act1 = empty ($_ POST ['act1'])? 0: $_ POST [' act1']; if (empty ($act1) |! in_array ($act1, array ('add',' cancel')) make_json_response (',-1, 'unknown request act1'); $order_id = intval ($_ POST [' order_id']); $order = order_info ($order_id) If (empty ($order)) make_json_response ('',-2,'no order ID'); if ($order ['order_status']) make_json_response ('',-3, 'this order has been confirmed without automatic confirmation'); if ($order ['pay_status']) make_json_response ('',-4, 'this order payment status has been changed and tasks cannot be added') If ($act1 = = 'add') {$order_cron_time = empty ($_ POST [' order_cron_time'])? 0: $_ POST ['order_cron_time']; if (empty ($order_cron_time)) make_json_response ('',-10, 'request time error'); $sql = 'select order_id from'. $ecs- > table ('order_auto_confirm'). Where order_id='.$order_id;$rs = $db- > getRow ($sql); if ($rs ['order_id'] = = $order_id) {make_json_response (',-30, 'this order task already exists and cannot be added repeatedly');} $execute_time = local_strtotime ($order_cron_time) $sql = "insert into". $ecs- > table ('order_auto_confirm'). (order_id, order_sn, execute_time, order_status, addtime) values (". $order_id.",'. $order ['order_sn']. ",". $execute_time. ", 0," .local _ gettime (). "); $result = $db- > query ($sql); if ($result) {make_json_response (', 0,') } make_json_response (',-9, 'failed to add task schedule');} elseif ($act1 = = 'cancel') {$sql =' delete from'. $ecs- > table ('order_auto_confirm'). Where order_id='.$order_id.' And order_status=0'; $db- > query ($sql); make_json_response (', 0,');}}

II.

Add the following in elseif ($_ REQUEST ['act'] = =' info'):

/ / fetch automatically determined order information $sql = 'select order_status, execute_time, addtime, update_time from'. $ecs- > table ('order_auto_confirm'). Where order_id='.$order ['order_id']; $cron= $db- > getRow ($sql); if (! empty ($cron)) {if ($cron [' order_status'] = = 1) $cron ['update_time'] = sprintf ($_ LANG [' order_auto_croned'], local_date ('Y-m-d sprintf, $cron [' update_time'])) Else$cron ['execute_time'] = sprintf ($_ LANG [' order_auto_cron'], local_date ('Y-m-d Hlav isprintf slots, $cron [' execute_time']));} $smarty- > assign ('cron', $cron)

3.

/ includes/modules/cron/order_auto_confirm.php

If (! defined ('IN_ECS')) {die (' Hacking attempt');} require_once (ROOT_PATH. 'includes/lib_order.php'); $cron_lang = ROOT_PATH. 'languages/'. $GLOBALS [' _ CFG'] ['lang']. '/ cron/order_auto_confirm.php';if (file_exists ($cron_lang)) {global $_ LANG; include_once ($cron_lang);} / * basic information of the module * / if (isset ($set_modules) & & $set_modules = = TRUE) {$I = isset ($modules)? Count ($modules): 0; / * Code * / $modules [$I] ['code'] = basename (_ _ FILE__,' .php'); / * describe the corresponding language entry * / $modules [$I] ['desc'] =' order_auto_confirm_desc'; / * author * / $modules [$I] ['author'] =' wjzhhr' / * URL * / $modules [$I] ['website'] =' http://www.wodeqingchun.com'; / * version number * / $modules [$I] ['version'] =' 1.0.0"; / * configuration information * / $modules [$I] ['config'] = array (' name' = > 'order_auto_confirm_count',' type' = > 'select',' value' = > '10'),); return } $time = gmtime (); / / $time = local_gettime (); $limit = empty ($cron ['order_auto_confirm_count'])? 5: $cron [' order_auto_confirm_count']; $sql = "SELECT * FROM". $GLOBALS ['ecs']-> table (' order_auto_confirm'). "WHERE execute_time

Tags: Orders tasks information inventory time status articles updates functions background success code content amount Danyu Riga important not much no two Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Huawei NVidia Apple macOS