zencart购物车增加购买备注二次开发分析

2010-05-24 17:30 来源:www.chinab4c.com 作者:admin

       zencart的购物车十分的复杂,也十分的烦琐。在购买的时候.无法对商品进行购买备注的录入。我们现在通过对zencart购物车的二次开发.修改数据库字段和数据库.从而达到了对所有购买的商品,进行购买备注的提交和录入.

1:languages\schinese\product_info.php
增加以下define('BEIZHU', '购买备注:');


2:
增加以下includes\templates\zccn\templates\tpl_product_info_display.php
BEIZHU.'<input type="text" name="beizhu"  maxlength="6" size="4" />

3:
alter table zen_customers_basket add column beizhu varchar(255);

4:includes/class/shopping_cart.php
  function add_cart($products_id, $qty = '1', $attributes = '', $notify = true,$beizhu='') {

$this->contents[$products_id] = array('qty' => (float)$qty,'beizhu'=>$_REQUEST[beizhu]);

5:includes/class/shopping_cart.php
update_quantity修改数量

6:function adjust_quantity($check_qty, $products, $message=false) {
 
7:
 function update_quantity($products_id, $quantity = '', $attributes = '',$beizhu='') {
    global $db;
    $this->notify('NOTIFIER_CART_UPDATE_QUANTITY_START');
    if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true..

$this->contents[$products_id] = array('qty' => (float)$quantity,'beizhu'=>$_REQUEST[beizhu]);
  
8:
includes\templates\template_default\templates\tpl_shopping_cart_default.php (128)
显示购物车中的备注
 <td class="cartTotalDisplay"><?php echo $product['beizhu']; ?></td>

9:获得购物车产品
$products = $_SESSION['cart']->get_products();

includes\modules\pages\shopping_cart\header_php.php (143) $productArray[$i] = array('attributeHiddenField'=>$attributeHiddenField,

10:includes\classes\shopping_cart.php (1062) function get_products($check_for_valid_cart = false) {

 'beizhu'  => $this->contents[$products_id][beizhu],
 
11:处理购物车中的备注
ncludes\modules\pages\shopping_cart\header_php.php (143)
  $productArray[$i] = array('attributeHiddenField'=>$attributeHiddenField,

                                
 'beizhu'=>$products[$i][beizhu],

  相关文章 :

  ecsho增加购买备注插件

  来源:中国B4C电子商务

来源于香港公司注册管理专家上海租车