服务报价 | 域名主机 | 网络营销 | 软件工具| [加入收藏]
 热线电话: #
当前位置: 主页 > php教程 > zencart教程 >

在zencart系统中自定义产品字段

时间:2015-07-09 17:54来源:未知 作者:最模板 点击:
1.在表products中添加需要定义的字段:products_moq ,products_price_term ,products_payment_term ,products_delivery ,products_port ALTER TABLE`products`ADD`products_moq` VARCHAR ( 100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT

1.在表products中添加需要定义的字段:products_moq , products_price_term , products_payment_term , products_delivery , products_port

ALTER TABLE`products`ADD`products_moq` VARCHAR ( 100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'Negotiable';

ALTER TABLE`products`ADD`products_price_term` VARCHAR ( 100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'FOB / CNF / CIF / Ex-work';

ALTER TABLE`products`ADD`products_payment_term` VARCHAR ( 100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'T/T. / LC / Western Union / Paypal';

ALTER TABLE`products`ADD`products_delivery` VARCHAR ( 100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'Negotiable';

ALTER TABLE`products`ADD`products_port` VARCHAR ( 100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'China Mainland';

2.编辑文件 [collect_info.php](在目录/admin/includes/modules/product/collect_info.php)
(1)在最开始的地方有一个变量参数设置,添加你的字段到它们的最后:

'products_moq' => '',

'products_price_term' => '',

'products_payment_term' => '',

'products_delivery' => '',

'products_port' => '' );

当然,上面1中定义了默认属性,但是并不会在新增商品的时候显示出来,所有需要在此处定义一下,上面的代码修改为:

'products_moq' => 'Negotiable',

'products_price_term' => 'FOB/CNF/CIF/Ex-work',

'products_payment_term' => 'T/T./LC/Western Union/Paypal',

'products_delivery' => 'Negotiable',

'products_port' => 'China Mainland');

这样默认值就会显示出来.

(2)在下边有一个数据库查询:

$product = $db->Execute("

添加你的字段在 [from …] 部分的前边,并且字段前添加[p.]:

p.products_moq, p.products_price_term, p.products_payment_term,

p.products_delivery, p.products_port

from " . TABLE_PRODUCTS .......

(3)现在添加输入框到产品表单中,具体位置自己看情况定,本人添加在了产品型号下面,可以搜索 TEXT_PRODUCTS_MODEL,然后在下面接着添加即可:

<tr>

<td class="main"><?php echo TEXT_PRODUCTS_MOQ; ?></td>

<td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . zen_draw_input_field('products_moq', htmlspecialchars(stripslashes($pInfo->products_moq), ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_PRODUCTS, 'products_moq')); ?></td>

</tr>
<tr>

<td class="main"><?php echo TEXT_PRODUCTS_Price_Term; ?></td>

<td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . zen_draw_input_field('products_price_term', htmlspecialchars(stripslashes($pInfo->products_price_term), ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_PRODUCTS, 'products_price_term')); ?></td>

</tr>
<tr>

<td class="main"><?php echo TEXT_PRODUCTS_Payment_Term; ?></td>

<td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . zen_draw_input_field('products_payment_term', htmlspecialchars(stripslashes($pInfo->products_payment_term), ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_PRODUCTS, 'products_payment_term')); ?></td>

</tr>
<tr>

<td class="main"><?php echo TEXT_PRODUCTS_Delivery_Lead_Time; ?></td>

<td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . zen_draw_input_field('products_delivery', htmlspecialchars(stripslashes($pInfo->products_delivery), ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_PRODUCTS, 'products_delivery')); ?></td>

</tr>
<tr>

<td class="main"><?php echo TEXT_PRODUCTS_Place_of_Origin; ?></td>

<td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . zen_draw_input_field('products_port', htmlspecialchars(stripslashes($pInfo->products_port), ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_PRODUCTS, 'products_port')); ?></td>

</tr>

注意上面用到的TEXT_PRODUCTS_MOQ等等这些常量需要在语言文件中自己定义,语言文件位置:/admin/includes/languages/schinese/product.php和

/admin/includes/languages/english/product.php)

3.编辑文件 [preview_info.php] (在目录 /admin/includes/modules/product/preview_info.php)

找到变量[$product]的定义. 像上边2.2中的一样添加查询字段.

4.编辑 [update_product.php] (在目录/admin/includes/modules/update_product.php)
找到第一个$sql_data_array变量那个的定义. 在最后一行的[);] 前边添加新字段:

'products_moq' => zen_db_prepare_input($_POST['products_moq']),
'products_price_term' => zen_db_prepare_input($_POST['products_price_term']),
'products_payment_term' => zen_db_prepare_input($_POST['products_payment_term']),
'products_delivery' => zen_db_prepare_input($_POST['products_delivery']),
'products_port' => zen_db_prepare_input($_POST['products_port'])

5.编辑 [main_template_vars.php] (在目录/includes/modules/pages/product_info/main_template_vars.php)
在第78行左右找到变量[$sql]的定义,像2.2中一样添加新字段的查询:

6.最后一步:在产品信息中显示。
编辑[tpl_product_info_display.php](在目录/includes/templates/你的模板/templates/tpl_product_info_display.php)
你可以把下边的代码添加到你认为合适的显示位置:

echo '<li>' . TEXT_PRODUCT_MOQ . $product_info->fields['products_moq'] . '</li>\n';
echo '<li>' . TEXT_PRODUCT_PRICE_TERM . $product_info->fields['products_price_term'] . '</li>\n';
echo '<li>' . TEXT_PRODUCT_PAYMENT_TERM . $product_info->fields['products_payment_term'] . '</li>\n';
echo '<li>' . TEXT_PRODUCT_DELIVERY . $product_info->fields['products_delivery'] . '</li>\n';
echo '<li>' . TEXT_PRODUCT_PORT . $product_info->fields['products_port'] . '</li>\n';

其中用到的TEXT_PRODUCT_MOQ等等这些变量,需要在/includes/languages/english/product_info.php以及/includes/languages/schinese/product_info.php中自己定义:

define('TEXT_PRODUCT_MOQ', 'Mimimum order quantity: ');
define('TEXT_PRODUCT_PRICE_TERM', 'Price Term: ');
define('TEXT_PRODUCT_PAYMENT_TERM', 'Payment Term: ');
define('TEXT_PRODUCT_DELIVERY', 'Delivery Lead Time: ');
define('TEXT_PRODUCT_PORT', 'Place of Origin: ');


(责任编辑:最模板)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------