Ecshop secondary development-add remarks for each item during shopping

Source: Internet
Author: User
Tags php source code

Introduction: This is the second development of ecshop-a detailed page for adding remarks to each item during shopping. It introduces PHP, related knowledge, skills, experience, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 345841 'rolling = 'no'>

Objectives:

    1. You can add remarks for a selected item before adding it to the shopping cart.
    2. After adding to the shopping cart, you can view the remarks in the shopping cart.
    3. When viewing the order, the shopkeeper can see the remarks added by the user for the product.
    4. The user can view the product remarks in the personal center.

Objective 1:

Open ecshop/goods. php and search for "display" to see this sentence:

 
$ Smarty-> display ('goods. DWT ', $ cache_id );

Open goods. DWT in the template directory and search for "<! -- {* Optional attributes of the end loop *} --> ", before this sentence, add:

 
<Br/> product remarks: <textarea name = "content" Cols = "40" rows = "5"> </textarea>

Open the ecshop database and execute:

 
Alter table 'ecs _ cart' add'content' text not null

Below we can see that connection a is executed: javascript: addtocart ({$ goods. goods_id}), so we look for the addtocart method in the folder, in JS/Common. the addtocart method in JS shows that the values of the form are obtained here, so we find goods. quick = quick; Add:

 
Goods. content = formbuy. elements ['content']. value;

At the end of the method, we can see that the submitted address is flow. php? Step = add_to_cart.

Open Flow. PHP: Find the add_to_cart method and find if (addto_cart ($ goods-> goods_id, $ goods-> Number, $ goods-> spec, $ goods-> parent )), replace it:

 
If (addto_cart ($ goods-> goods_id, $ goods-> Number, $ goods-> spec, $ goods-> parent, $ goods-> content ))

Find the addto_cart method and replace function addto_cart ($ goods_id, $ num = 1, $ spec = array (), $ parent = 0):

 
Function addto_cart ($ goods_id, $ num = 1, $ spec = array (), $ parent = 0, $ content = '')

Find $ parent ['parent _ id'] = 0; add it below:

$ Parent ['content'] = $ content;

At this time, we will go back to the product page to check whether it can run, enter a message, add it to the shopping cart, and check the database. We can find that the database has been successfully inserted.

However, we returned to the product page and added the remarks to the shopping cart. We found that the database remarks were still original and not updated.

So we find ", goods_price = '$ goods_price'". replace it:

 
", Goods_price = '$ goods_price', content = '$ content '".

Go back to the product page and test the database! We deleted the product, and the database records also disappeared!

Objective 2:

Find flow. DWT in the template directory, search <TD bgcolor = "# ffffff" >{$ goods. goods_attr | nl2br} </TD>, and replace it:

 
<TD bgcolor = "# ffffff"> {$ goods. goods_attr | nl2br} <br/> <! -- {If $ goods. Content} --> remarks: {$ goods. Content} <! -- {/If} --> </TD>

Go back to the shopping cart page and refresh. We found that the remarks have been displayed!

Objective 3:

Go to the database and execute:

 
Alter table 'ecs _ order_goods 'add'content' text not null

The <input type = "hidden" name = "Step" value = "done"/> button on the checkout page shows that its submission is done.

Search done in flow. php, find "/* Insert ORDER item */", and change $ SQL:

 
$ SQL = "insert ". $ ECs-> table ('order _ goods '). "(". "order_id, goods_id, goods_name, content, goods_sn, product_id, goods_number, market_price ,". "goods_price, goods_attr, is_real, extension_code, parent_id, is_gift, goods_attr_id )". "select '$ new_order_id', goods_id, goods_name, content, goods_sn, product_id, goods_number, market_price ,". "goods_price, goods_attr, is_real, extension_code, parent_id, is_gift, goods_attr_id ". "from ". $ ECs-> table ('cart '). "Where session_id = '". sess_id. "'and rec_type =' $ flow_type '";

Order inserted!

Find order. php In the admin folder and go to $ smarty-> display('order_info.htm'your in $ _ request ['act '] = 'info' to inform you that the template of the output is order_info.htm,

Open order_info.htm, find <TD >{$ goods. goods_attr | nl2br} </TD>, and replace it:

 
<TD >{$ goods. goods_attr | nl2br} <br/> <! -- {If $ goods. Content} --> remarks: {$ goods. Content} <! -- {/If} --> </TD>

The background order is partially viewed!

Objective 4:

Complete this step by referring to Objective 2 ~

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/345841.html pageno: 4.

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.