1. 程式人生 > >ecshop批量列印快遞單

ecshop批量列印快遞單

1.admin\templates\order_list.htm,在
<input name="print" type="submit" id="btnSubmit4" value="{$lang.print_order}" class="button" disabled="true" onclick="this.form.target = '_blank'" />
後,新增
<input name="print_shopping" type="submit" id="btnSubmit6" value="批量列印快遞單" class="button" disabled="true" onclick="this.form.target = '_blank'" />

2.admin\order.php,在

    /* 去發貨 */
    elseif (isset($_POST['to_delivery']))
前,新增
	//批量列印快遞單
	elseif (isset($_POST['print_shopping'])){
		$region_array = array();
		$region_id = !empty($_CFG['shop_country']) ? $_CFG['shop_country'] . ',' : '';
		$region_id .= !empty($_CFG['shop_province']) ? $_CFG['shop_province'] . ',' : '';
		$region_id .= !empty($_CFG['shop_city']) ? $_CFG['shop_city'] . ',' : '';
		$region_id = substr($region_id, 0, -1);
		$region = $db->getAll("SELECT region_id, region_name FROM " . $ecs->table("region") . " WHERE region_id IN ($region_id)");
		
		if (!empty($region))
		{
			foreach($region as $region_data)
			{
				$region_array[$region_data['region_id']] = $region_data['region_name'];
			}
		}
		$smarty->assign('shop_name', $_CFG['shop_name']);
		$smarty->assign('province', $region_array[$_CFG['shop_province']]);
		$smarty->assign('city', $region_array[$_CFG['shop_city']]);
		$smarty->assign('shop_address', $_CFG['shop_address']);
		$smarty->assign('service_phone',$_CFG['service_phone']);
		
		//以上是系統引數
		$order_sn_list = array();
		$order_sn_list = explode(',', $_POST['order_id']);
		foreach ($order_sn_list as $order_sn)
		{
			/* 取得訂單資訊 */
			$order = order_info(0, $order_sn);
			$smarty -> assign('order',$order);
			$shipping = $db->getOne("SELECT * FROM " . $ecs->table("shipping") . " WHERE shipping_id=" . $order['shipping_id']);

			if (empty($shipping['shipping_print']))
			{
				echo $smarty->fetch("str:" . $shipping['shipping_print']);
			}
			else
			{
				$shipping_code = $db->getOne("SELECT shipping_code FROM " . $ecs->table('shipping') . " WHERE shipping_id=" . $order['shipping_id']);
				if ($shipping_code){
					include_once(ROOT_PATH . 'includes/modules/shipping/' . $shipping_code . '.php');
				}
				if (!empty($_LANG['shipping_print']))
				{
					echo $smarty->fetch("str:$_LANG[shipping_print]");
				}
				else
				{
					echo $_LANG['no_print_shipping'];
				}
			}
		}
		exit;
	}

3.這是最重要的一點,其他地方根本沒說過,害得作者君我折騰了兩三天。閒話不多說,切入正題,如果你使用過 系統設定→配送方式→對應模板下的‘編輯列印模板’那麼你可能會發現,你的‘批量列印快遞單’按鈕打印出來的內容和詳情裡面的‘列印快遞單’打印出來的內容不一樣,這是因為我們新設定的列印快單使用的模版並不是新編輯過的模板,而是系統預設的老模板,解決的方法也很簡單,將老模板也改成新模板的樣式就好了。

具體在languages\zh_cn\shipping中對應的php檔案裡

$_LANG['shipping_print']         =‘’;

這一句,將‘’中的內容樣式修改過來就好了。至於取頁面樣式,只要在對應頁面Ctrl+S一下就好了。

效果如圖所示:

得意,批量列印快遞單就是這麼簡單,小夥伴們快去試試吧!