关于睿艾科技

企业级电子商务及供应链解决方案


ZenCart:最新商品上面加上直接”购买”按钮

新闻添加时间:2010-01-01 16:46:36

/includes/templates/template_default/templates/tpl_product_info_display.php
这个文件中购买按钮的代码。

需要修改的代码在:
/includes/modules/new_products.php
商店首页上显示的商品的内容都在变量$list_box_contents中,加上需要的内容就可以了。

例如,增加”购买”按钮,

可以将源代码从

  1. $list_box_contents[$row][$col] = array(align => center,
  2.                                              params => class="smallText" width=" . $col_width . %" valign="top",
  3.                                              text => <a href=" . zen_href_link(zen_get_info_page($new_products->fields[products_id]), products_id= . $new_products->fields[products_id]) . "> . zen_image(DIR_WS_IMAGES . $new_products->fields[products_image], $new_products->fields[products_name], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . </a><br /><a href=" . zen_href_link(zen_get_info_page($new_products->fields[products_id]), products_id= . $new_products->fields[products_id]) . "> . $new_products->fields[products_name] . </a><br /> . $products_price);

改为

  1. if ($products_qty_box_status == 0 or $products_quantity_order_max== 1) { 
  2.  // hide the quantity box and default to 1
  3.  $the_button = <input type="hidden" name="cart_quantity" value="1" /> . zen_draw_hidden_field(products_id, (int)$new_products->fields[products_id]) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
  4.  } else { 
  5.  // show the quantity box
  6.  $the_button = PRODUCTS_ORDER_QTY_TEXT . <input type="text" name="cart_quantity" value=" . (zen_get_buy_now_qty($new_products->fields[products_id])) . " maxlength="6" size="4" /><br /> . zen_get_products_quantity_min_units_display((int)$new_products->fields[products_id]) . <br /> . zen_draw_hidden_field(products_id, (int)$new_products->fields[products_id]) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
  7.  };
  8.         
  9.  $list_box_contents[$row][$col] = array(align => center,
  10.                                              params => class="smallText" width=" . $col_width . %" valign="top",
  11.                                              text => <a href=" . zen_href_link(zen_get_info_page($new_products->fields[products_id]), products_id= . $new_products->fields[products_id]) . "> . zen_image(DIR_WS_IMAGES . $new_products->fields[products_image], $new_products->fields[products_name], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . </a><br /><a href=" . zen_href_link(zen_get_info_page($new_products->fields[products_id]), products_id= . $new_products->fields[products_id]) . "> . $new_products->fields[products_name] . </a><br /> . $products_price  . <br /> . zen_draw_form(cart_quantity, zen_href_link(zen_get_info_page($new_products->fields[products_id]), zen_get_all_get_params(array(action)) . action=add_product), post, enctype="multipart/form-data") . zen_get_buy_now_button($new_products->fields[products_id], $the_button) . </form><br /><br />);