ZenCart 时间与随机数结合产生订单号
来源: 阅读:944 次 日期:2014-09-03 11:13:01
温馨提示: 小编为您整理了“ZenCart 时间与随机数结合产生订单号”,方便广大网友查阅!

不少使用Zen Cart的朋友发现Zen Cart的系统默认定单号并不一定是大家想要的,很多人希望通过定单时间来确定不同的定单号以方便管理和使用,这里发布下目前适合1.38版本的定单时间与随机数字结合产生定单号的方法,在 includesclassesorder.php 里需要做出如下的代码调整,注意::修改前请一定要备份好数据库,以防出现调整错误。

具体方法,在order.php里:

function create($zf_ot_modules, $zf_mode = 2) {

global $db;

$t1 = date("Ymd");

srand ((float) microtime() * 10000000);

$input = array ("1", "2", "3", "4", "5", "6", "7", "8", "9", "0");

$rand_keys = array_rand ($input, 2);

//$t1 = $input[$rand_keys[0]];

$t2 = $input[$rand_keys[1]];

$t3 = rand(0,9);

$ordernum = $t1.$t2.$t3;

if ($this->info['total'] == 0) {

if (DEFAULT_ZERO_BALANCE_ORDERS_STATUS_ID == 0) {

$this->info['order_status'] = DEFAULT_ORDERS_STATUS_ID;

} else {

$this->info['order_status'] = DEFAULT_ZERO_BALANCE_ORDERS_STATUS_ID;

}

}

if ($_SESSION['shipping'] == ‘free_free’) {

$this->info['shipping_module_code'] = $_SESSION['shipping'];

}

$sql_data_array = array(’orders_id’ => $ordernum,

‘customers_id’ => $_SESSION['customer_id'],

‘customers_name’ => $this->customer['firstname'] . ‘ ‘ . $this->customer['lastname'],

‘customers_company’ => $this->customer['company'],

‘customers_street_address’ => $this->customer['street_address'],

‘customers_suburb’ => $this->customer['suburb'],

‘customers_city’ => $this->customer['city'],

‘customers_postcode’ => $this->customer['postcode'],

‘customers_state’ => $this->customer['state'],

‘customers_country’ => $this->customer['country']['title'],

‘customers_telephone’ => $this->customer['telephone'],

‘customers_email_address’ => $this->customer['email_address'],

‘customers_address_format_id’ => $this->customer['format_id'],

‘delivery_name’ => $this->delivery['firstname'] . ‘ ‘ . $this->delivery['lastname'],

‘delivery_company’ => $this->delivery['company'],

‘delivery_street_address’ => $this->delivery['street_address'],

‘delivery_suburb’ => $this->delivery['suburb'],

‘delivery_city’ => $this->delivery['city'],

‘delivery_postcode’ => $this->delivery['postcode'],

‘delivery_state’ => $this->delivery['state'],

‘delivery_country’ => $this->delivery['country']['title'],

‘delivery_address_format_id’ => $this->delivery['format_id'],

‘billing_name’ => $this->billing['firstname'] . ‘ ‘ . $this->billing['lastname'],

‘billing_company’ => $this->billing['company'],

‘billing_street_address’ => $this->billing['street_address'],

‘billing_suburb’ => $this->billing['suburb'],

‘billing_city’ => $this->billing['city'],

‘billing_postcode’ => $this->billing['postcode'],

‘billing_state’ => $this->billing['state'],

‘billing_country’ => $this->billing['country']['title'],

‘billing_address_format_id’ => $this->billing['format_id'],

‘payment_method’ => (($this->info['payment_module_code'] == ” and $this->info['payment_method'] == ”) ? PAYMENT_METHOD_GV : $this->info['payment_method']),

‘payment_module_code’ => (($this->info['payment_module_code'] == ” and $this->info['payment_method'] == ”) ? PAYMENT_MODULE_GV : $this->info['payment_module_code']),

’shipping_method’ => $this->info['shipping_method'],

’shipping_module_code’ => (strpos($this->info['shipping_module_code'], ‘_’) > 0 ? substr($this->info['shipping_module_code'], 0, strpos($this->info['shipping_module_code'], ‘_’)) : $this->info['shipping_module_code']),

‘coupon_code’ => $this->info['coupon_code'],

‘cc_type’ => $this->info['cc_type'],

‘cc_owner’ => $this->info['cc_owner'],

‘cc_number’ => $this->info['cc_number'],

‘cc_expires’ => $this->info['cc_expires'],

‘date_purchased’ => ‘now()’,

‘orders_status’ => $this->info['order_status'],

‘order_total’ => $this->info['total'],

‘order_tax’ => $this->info['tax'],

‘currency’ => $this->info['currency'],

‘currency_value’ => $this->info['currency_value'],

‘ip_address’ => $_SESSION['customers_ip_address'] . ‘ - ‘ . $_SERVER['REMOTE_ADDR']

);

zen_db_perform(TABLE_ORDERS, $sql_data_array);

$insert_id = $ordernum;

// $insert_id = $db->Insert_ID();

这样以来,一个较为完善的根据顾客下单时间与系统随机数生成的定单号即生成了,有朋友说在1.38a貌似有BUG和不完善的地方,我这还没来的及看到,PS:默认其实我是在1.37下改进的,但1.38的版本里关于order.php相关函数无多大变化,这里顺推应该可以在1.38下正常使用的。

更多信息请查看IT技术专栏

更多信息请查看CMS教程
由于各方面情况的不断调整与变化, 提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!

2025国考·省考课程试听报名

  • 报班类型
  • 姓名
  • 手机号
  • 验证码
关于我们 | 联系我们 | 人才招聘 | 网站声明 | 网站帮助 | 非正式的简要咨询 | 简要咨询须知 | 加入群交流 | 手机站点 | 投诉建议
工业和信息化部备案号:滇ICP备2023014141号-1 云南省教育厅备案号:云教ICP备0901021 滇公网安备53010202001879号 人力资源服务许可证:(云)人服证字(2023)第0102001523号
云南网警备案专用图标
联系电话:0871-65317125(9:00—18:00) 获取招聘考试信息及咨询关注公众号:
咨询QQ:526150442(9:00—18:00)版权所有:
云南网警报警专用图标
Baidu
map