When creating a template on the ecshop homepage, increase the discount as required and write a php function call.

Source: Internet
Author: User
: Ecshop itself only involves discounts in the shopping cart. What we want is not the price ratio of a single product. In the include directory, find lib_goods.php and add the following function at the end: functionget_zhekou ($ goods_id) {$ sqlselectshop_price, market_pricefrom. $ GLOBALS [e

: Ecshop itself only involves discounts in the shopping cart. What we want is not the price ratio of a single product. In the include directory, find lib_goods.php and add the following function at the end: function get_zhekou ($ goods_id) {$ SQL = select shop_price, market_price from. $ GLOBALS ['e

:




Ecshop itself only involves discounts in the shopping cart. What we want is not the price of a single product.


Follow these steps:


Find lib_goods.php in the include directory and add the following function at the end:


Function get_zhekou ($ goods_id) {$ SQL = "select shop_price, market_price from ". $ GLOBALS ['ecs']-> table ('goods '). "WHERE goods_id = ". $ goods_id. ""; $ res = $ GLOBALS ['db']-> query ($ SQL ); while ($ row = $ GLOBALS ['db']-> fetchRow ($ res) {$ a = $ row ['shop _ price']; // product price $ B = $ row ['market _ price']; // product market price} $ c = 10; if ($ B <> 0) {$ c = $ a/$ B;} else {} // return number_format ($ c, 2) * 10; return number_format ($ c, 2) * 10 ;}

Find the following content near row 327 of the file:


$goods[$idx]['url']          = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);

Add below this row:


$goods[$idx]['goods_zhekou']= get_zhekou($row['goods_id']); 

Then, add the call in the foreground template:


For example:

{If $ goods. goods_zhekou} {$ goods. goods_zhekou} {else} 0 {/if} fold

Complete, simple.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.