Ecshop red packet specifies that certain items cannot be modified

Source: Internet
Author: User
Tags php website

Step 1: Add a field is_bonus type tinyint to the goods table. The default value is 1 (1 indicates that red packets can be used)

Step 2: Modify the background template page goods_info.htm

<Tr id = "alone_sale_1">
<Td id = "alone_sale_2"> {$ lang. lab_is_on_sale} </td>
<Td id = "alone_sale_3"> <input type = "checkbox" name = "is_on_sale" value = "1" {if $ goods. is_on_sale} checked = "checked" {/if}/> {$ lang. on_sale_desc} </td>
</Tr>
<Tr id = "alone_sale_1">
<Td id = "alone_sale_2"> Use of red packets </td>
<Td id = "alone_sale_3"> <input type = "checkbox" name = "is_bonus" value = "1" {if $ goods. is_bonus} checked = "checked" {/if}/> indicates that red packets are allowed; otherwise, red packets are not allowed. </Td>
</Tr>
<Tr>
<Td >{$ lang. lab_is_alone_sale} </td>
<Td> <input type = "checkbox" name = "is_alone_sale" value = "1" {if $ goods. is_alone_sale} checked = "checked" {/if}/> {$ lang. alone_sale} </td>
</Tr>
<Tr id = "alone_sale_1"> <td id = "alone_sale_2"> {$ lang. lab_is_on_sale} </td> <td id = "alone_sale_3"> <input type = "checkbox" name = "is_on_sale" value = "1" {if $ goods. is_on_sale} checked = "checked" {/if}/> {$ lang. on_sale_desc} </td> </tr>

<Tr id = "alone_sale_1"> <td id = "alone_sale_2"> red packet usage </td> <td id = "alone_sale_3"> <input type = "checkbox" name =" is_bonus "value =" 1 "{if $ goods. is_bonus} checked = "checked" {/if}/> indicates that red packets are allowed; otherwise, red packets are not allowed. </Td> </tr>

<Tr> <td> {$ lang. lab_is_alone_sale }</td> <input type = "checkbox" name = "is_alone_sale" value = "1" {if $ goods. is_alone_sale} checked = "checked" {/if}/> {$ lang. alone_sale }</td> </tr>

This is about 230 rows.

* Note: I have not modified the Language Pack. If you need it, you can modify the Language Pack and then call it here (haha)

Step 3: Modify the background goods. php file

Modify the following after adding a new product and editing the product

Add the following red parts to the $ goods array in rows 1 and 158 (I can use red packets by default)
$ Goods = array (

'Goods _ id' => 0,

'Goods _ desc' => ",

'Cat _ id' => $ last_choose [0],

'Brand _ id' => $ last_choose [1],

'Is _ on_sale '=> '1 ′,

'Is _ bonus' => '1 ′,

'Is _ alone_sale '=> '1 ′,

'Is _ shipping' => '0 ′,

'Other _ cat' => array (), // extended category

'Goods _ type' => 0, // item type

'Shop _ price' => 0,

'Promote _ price' => 0,

'Market _ price' => 0,

'Integral' => 0,

'Goods _ number' => $ _ CFG ['default _ store'],

'Warn _ number' => 1,

'Promote _ start_date '=> local_date ('Y-m-d '),

'Promote _ end_date '=> local_date ('Y-m-d', local_strtotime (' + 1 month ')),

'Goods _ weight '=> 0,

'Give _ integral' =>-1,

'Rank _ integral' =>-1

);

Insert and modify some modified code:

805 rows

$ Is_on_sale = isset ($ _ POST ['is _ on_sale '])? 1: 0;

$ Is_bonus = isset ($ _ POST ['is _ bonus'])? 1: 0;

$ Is_alone_sale = isset ($ _ POST ['is _ alone_sale '])? 1: 0;

/* Warehouse receiving */

If ($ is_insert)

{

If ($ code = ")

{

$ SQL = "INSERT INTO". $ ecs-> table ('goods'). "(goods_name, goods_name_style, goods_sn ,".

"Cat_id, brand_id, shop_price, market_price, is_promote, promote_price ,".

"Promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief ,".

"Seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot ,".

"Is_on_sale, is_bonus, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, rank_integral, suppliers_id )".

"VALUES ('$ _ POST [goods_name]', '$ goods_name_style', '$ goods_sn', '$ catgory_id ',".

"'$ Brand_id', '$ shop_price', '$ market_price', '$ is_promote', '$ promote_price',".

"'$ Promote_start_date', '$ promote_end_date', '$ goods_img', '$ goods_thumb', '$ original_img',".

"'$ _ POST [keywords]', '$ _ POST [goods_brief]', '$ _ POST [seller_note]', '$ goods_weight', '$ goods_number ',".

"'$ Warn_number', '$ _ POST [integral]', '$ give_integral', '$ is_best', '$ is_new', '$ is_hot', '$ is_on_sale ', '$ is_bonus', '$ is_alone_sale', $ is_shipping, ".

"'$ _ POST [goods_desc]', '". gmtime (). "','". gmtime (). "',' $ goods_type ',' $ rank_integral ',' $ suppliers_id ')";

}

Else

{

$ SQL = "INSERT INTO". $ ecs-> table ('goods'). "(goods_name, goods_name_style, goods_sn ,".

"Cat_id, brand_id, shop_price, market_price, is_promote, promote_price ,".

"Promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief ,".

"Seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, is_real ,".

"Is_on_sale, is_bonus is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, extension_code, rank_integral )".

"VALUES ('$ _ POST [goods_name]', '$ goods_name_style', '$ goods_sn', '$ catgory_id ',".

"'$ Brand_id', '$ shop_price', '$ market_price', '$ is_promote', '$ promote_price',".

"'$ Promote_start_date', '$ promote_end_date', '$ goods_img', '$ goods_thumb', '$ original_img',".

"'$ _ POST [keywords]', '$ _ POST [goods_brief]', '$ _ POST [seller_note]', '$ goods_weight', '$ goods_number ',".

"'$ Warn_number', '$ _ POST [integral]', '$ give_integral', '$ is_best', '$ is_new', '$ is_hot', 0, '$ is_on_sale', '$ is_bonus', $ is_alone_sale ', $ is_shipping, ".

"'$ _ POST [goods_desc]', '". gmtime (). "','". gmtime (). "',' $ goods_type ',' $ Code', '$ rank_integral ')";

}

}

Row 3:

$ SQL. = "keywords = '$ _ POST [keywords]',".

"Goods_brief = '$ _ POST [goods_brief]',".

"Seller_note = '$ _ POST [seller_note]',".

"Goods_weight = '$ goods_weight ',".

"Goods_number = '$ goods_number ',".

"Warn_number = '$ warn_number ',".

"Integral = '$ _ POST [integral]',".

"Give_integral = '$ give_integral ',".

"Rank_integral = '$ rank_integral ',".

"Is_best = '$ is_best ',".

"Is_new = '$ is_new ',".

"Is_hot = '$ is_hot ',".

"Is_bonus = '$ is_bonus ',".

"Is_on_sale = '$ is_on_sale ',".

"Is_alone_sale = '$ is_alone_sale ',".

"Is_shipping = '$ is_shipping ',".

"Goods_desc = '$ _ POST [goods_desc]',".

"Last_update = '". gmtime (). "',".

"Goods_type = '$ goods_type '".

"WHERE goods_id = '$ _ REQUEST [goods_id] 'limit 1 ″;

Step 4: Modify the template page goods_list.htm

25 rows:

<Th> <a href = "javascript: listTable. sort ('is _ hot '); "> {$ lang. is_hot} </a >{$ sort_is_hot} </th>

<Th> <a href = "javascript: listTable. sort ('is _ bonus');"> Red Packets </a >{$ sort_is_bonus} </th>

<Th> <a href = "javascript: listTable. sort ('sort _ Order'); "> {$ lang. sort_order} </a >{$ sort_sort_order} </th>

Row 47:

<Td align = "center"> </td>

<Td align = "center"> </td>

<Td align = "center"> <span onclick = "listTable. edit (this, 'edit _ sort_order ', {$ goods. goods_id}) "> {$ goods. sort_order} </span> </td>

Row 98:

<Option value = "not_hot" >{$ lang. not_hot} </option>

<Option value = "bonus"> use red packets </option>

<Option value = "not_bonus"> cancel the use of red packets </option>

<Option value = "move_to" >{$ lang. move_to} </option>

Step 5: Modify goods. php In the background

Add

/*------------------*/

//-Modify the red envelope Usage Status

/*------------------*/

Elseif ($ _ REQUEST ['ac'] = 'toggle _ bonus ')

{

Check_authz_json ('goods _ manage ');

 

$ Goods_id = intval ($ _ POST ['id']);

$ Is_bonus = intval ($ _ POST ['val']);

 

If ($ exc-> edit ("is_bonus = '$ is_bonus', last_update =". gmtime (), $ goods_id ))

{

Clear_cache_files ();

Make_json_result ($ is_bonus );

}

}

/*------------------*/

//-Modify the order of items

/*------------------*/

The background function has been modified.

Modify the foreground:

On the homepage, add a field is_bonus type tinyint in the tb_cart table. The default value is 1 (1 indicates that red packets can be used)

Find function addto_cart in node des/lib_order.php.

Row 3:

$ SQL = "SELECT g. goods_name, g. goods_sn, g. is_on_sale, g. is_real, g. is_bonus,".

"G. market_price, g. shop_price AS org_price, g. promote_price, g. promote_start_date,".

"G. promote_end_date, g. goods_weight, g. integral, g. extension_code,".

"G. goods_number, g. is_alone_sale, g. is_shipping ,".

"IFNULL (mp. user_price, g. shop_price * '$ _ SESSION [discount]') AS shop_price".

"FROM". $ GLOBALS ['ecs']-> table ('goods '). "AS g".

"Left join". $ GLOBALS ['ecs']-> table ('Member _ price'). "AS mp".

"ON mp. goods_id = g. goods_id AND mp. user_rank = '$ _ SESSION [user_rank]'".

"WHERE g. goods_id = '$ goods_id '".

"AND g. is_delete = 0 ″;

Row 3:

/* Initialize the basic pieces of data to be inserted into the shopping cart */www.2cto.com

$ Parent = array (

'User _ id' => $ _ SESSION ['user _ id'],

'Session _ id' => SESS_ID,

'Goods _ id' => $ goods_id,

'Goods _ sn '=> addslashes ($ goods ['goods _ sn']),

'Product _ id' => $ product_info ['product _ id'],

'Goods _ name' => addslashes ($ goods ['goods _ name']),

'Market _ price' => $ goods ['market _ price'],

'Goods _ attr' => addslashes ($ goods_attr ),

'Goods _ attr_id '=> $ goods_attr_id,

'Is _ real' => $ goods ['is _ real'],

'Extension _ Code' => $ goods ['extension _ Code'],

'Is _ gift '=> 0,

'Is _ bonus' => $ goods ['is _ bonus'],

'Is _ shipping' => $ goods ['is _ shipping'],

'Rec _ type' => CART_GENERAL_GOODS

);

Modify: The function order_detail is roughly in the 545 rows.

/* Total price */

Foreach ($ goods AS $ val)

{

/* Count the number of physical products */

If ($ val ['is _ real'])

{

$ Total ['real _ goods_count '] ++;

}

If ($ val ['is _ bonus'])

{

$ Total ['goods _ bonus_price '] + = $ val ['goods _ price'] * $ val ['goods _ number'];

}

$ Total ['goods _ price'] + = $ val ['goods _ price'] * $ val ['goods _ number'];

$ Total ['market _ price'] + = $ val ['market _ price'] * $ val ['goods _ number'];

}

The last step is to modify flow. php.

About 686 rows

/* If you use a red envelope, obtain the red envelope you can use and the selected red envelope */

If ((! Isset ($ _ CFG ['use _ bonus']) | $ _ CFG ['use _ bonus'] = '1 ′)

& ($ Flow_type! = CART_GROUP_BUY_GOODS & $ flow_type! = CART_EXCHANGE_GOODS ))

{

// Get available red packets for users

$ User_bonus = user_bonus ($ _ SESSION ['user _ id'], $ total ['goods _ bonus_price ']);

This function has a defect that the specified product cannot use red packets and all red packets cannot be used.

 

From the PHP website construction of shunzi Network

Related Article

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.