zencart 時(shí)間與隨機(jī)數(shù)結(jié)合產(chǎn)生訂單號(hào)
來源:易賢網(wǎng) 閱讀:726 次 日期:2016-06-28 09:23:18
溫馨提示:易賢網(wǎng)小編為您整理了“zencart 時(shí)間與隨機(jī)數(shù)結(jié)合產(chǎn)生訂單號(hào)”,方便廣大網(wǎng)友查閱!

不少使用zen cart的朋友發(fā)現(xiàn)zen cart的系統(tǒng)默認(rèn)定單號(hào)并不一定是大家想要的,很多人希望通過定單時(shí)間來確定不同的定單號(hào)以方便管理和使用,這里發(fā)布下目前適合1.38版本的定單時(shí)間與隨機(jī)數(shù)字結(jié)合產(chǎn)生定單號(hào)的方法,在 includesclassesorder.php 里需要做出如下的代碼調(diào)整,注意::修改前請(qǐng)一定要備份好數(shù)據(jù)庫,以防出現(xiàn)調(diào)整錯(cuò)誤。

具體方法,在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();

這樣以來,一個(gè)較為完善的根據(jù)顧客下單時(shí)間與系統(tǒng)隨機(jī)數(shù)生成的定單號(hào)即生成了,有朋友說在1.38a貌似有bug和不完善的地方,我這還沒來的及看到,ps:默認(rèn)其實(shí)我是在1.37下改進(jìn)的,但1.38的版本里關(guān)于order.php相關(guān)函數(shù)無多大變化,這里順推應(yīng)該可以在1.38下正常使用的。

更多信息請(qǐng)查看CMS教程
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!
相關(guān)閱讀CMS教程

2025國考·省考課程試聽報(bào)名

  • 報(bào)班類型
  • 姓名
  • 手機(jī)號(hào)
  • 驗(yàn)證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 加入群交流 | 手機(jī)站點(diǎn) | 投訴建議
工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
咨詢QQ:526150442(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報(bào)警專用圖標(biāo)