Imitation Taobao Product detail page Add to cart effect

Source: Internet
Author: User
Tags json php tutorial

Imitation Taobao Product detail page Add to cart effect

GOODS.DWT page <a href= "Web effects: AddToCart ({$goods. goods_id},0,1)" >The layer to be displayed is added to the bottom of this leaf <div class= "cartsure" id= "Cartsurebox" style= "Display:none"; >
<div class= "btn" ><a href= "javascript:;" > Close </a></div>
<div class= "Mesgcon" >
<div> Shopping Cart Total <span id= "Ecs_goods_number" ></span> products total: <span id= "Ecs_goods_price" ></span ></div><br>
<input type= "image" src= "Images/btn_pay.gif"/>

</div>
</div>
Copy Code
I also posted the style for your reference. cartsure{
Position:absolute;
left:0;
top:545px;
width:405px;
height:90px;
z-index:999;
Background:url (images/cartsure_bg.gif) 0 0 no-repeat;
font-size:12px;
}

. mesgcon{
Float:left;
Background:url (images/mesg.png) no-repeat 18px 9px;
Color: #666;
line-height:21px;
padding:0 0 0 100px;
width:320px;
}

. Mesgcon h3{
Float:left;
width:320px;
Color: #333;
font-size:14px;
margin:-1px 0 6px;
Height:auto;
line-height:20px;
Background:none;
Text-align:left;
padding:0;
Font-weight:bold;
}

. Mesgcon Input{float:left; margin:0 11px 0 0}

. Mesgcon Div{float:left Font-size:13px}

. Mesgcon div span{font-size:14px; font-weight:bold; color: #F80}

. cartsure. btn{float:left; padding:5px; width:390px}

. cartsure. BTN a{
Background:url (images/close_bg.gif) no-repeat 0 0;
Float:right;
height:13px;
Overflow:hidden;
text-indent:-5000px;
width:38px;
}

. cartsure. BTN a:hover{background-position:0 -12px}
Copy Code
Open js/common.js File Modify AddToCart function modified:
function AddToCart (Goodsid, Parentid,is_ajax)
{
var goods = new Object ();
var Spec_arr = new Array ();
var Fittings_arr = new Array ();
var number = 1;
var formbuy = document.forms[' ecs_formbuy '];
var quick = 0;
Check if there are any product specifications
if (formbuy)
{
Spec_arr = Getselectedattributes (formbuy);

if (formbuy.elements[' number '])
{
Number = formbuy.elements[' number '].value;
}

Quick = 1;
}

Goods.quick = quick;
Goods.spec = Spec_arr;
goods.goods_id = Goodsid;
Goods.number = number;
Goods.parent = (typeof (ParentID) = = "undefined")? 0:parseint (ParentID);

if (Is_ajax = 1) {
Ajax.call (' flow.php tutorial? Step=add_to_cart ', ' goods= ' + goods.tojs**tring (), Addtocartresp**e_ Ajax, ' POST ', ' JSON ';
}else{
Ajax.call (' Flow.php?step=add_to_cart ', ' goods= ' + goods.tojs**tring (), addtocartresp**e, ' POST ', ' JSON ');
}
}
Copy Code
Add several JS functions * *
* process Add product to cart feedback
*/
Function Addtocartresp**e_ajax (result)
{
if (Result.error > 0)
{
//If a shortage registration is required, jump
if (result.error = 2)
{
if (confirm (result.message))
{ br> location.href = ' user.php?act=add_booking&id= ' + result.goods_id + ' &spec= ' + result.product_spec;
}
//opendiv_booking ();

}
No specification, pop-up property selection box
else if (Result.error = 6)
{
Openspediv (Result.message, result.goods_id, result.parent);
}
Else
{
alert (result.message);
}
}
Else
{
var cartinfo = document.getElementById (' Ecs_cartinfo ');
var cart_url = ' Flow.php?step=cart ';
if (cartinfo)
{
cartinfo.innerhtml = result.content;
}

if (result.one_step_buy = ' 1 ')


{


Location.href = Cart_url;


}


Else


{


Switch (result.confirm_type)


{


Case ' 1 ':


if (Confirm (result.message)) location.href = Cart_url;


Break


Case ' 2 ':


if (!confirm (result.message)) location.href = Cart_url;


Break


Case ' 3 ':


Divtipmiddle (result);


Refresh_cart ();


document.getElementById (' Jdiv '). InnerHTML = RESULT.CJ;


Break


Default:


Break


}


}


}


}


Shopping Cart Tip Box js


function Closetipbox () {


document.getElementById (' Cartsurebox '). style.display= "None";


}


function Divtipmiddle (Result) {


Opentipbox (result);


var a = document.getElementById ("Cartsurebox");


A.style.left= (document.body.clientwidth/2-a.clientwidth/2+245) + "px";


}


function Opentipbox (Result) {


document.getElementById (' Ecs_goods_price '). InnerHTML = Result.goods_price;


document.getElementById (' Ecs_goods_number '). InnerHTML = Result.goods_number;


document.getElementById (' Cartsurebox '). style.display= "Block";


}


function opendiv_booking ()


{


document.getElementById (' buyTip2 '). style.display= "Block";

}

//Shopping cart hint Box js
function Closetipbox () {
document.getElementById (' Cartsurebox '). style.display= "None";
}
Copy Code
Open flow.php 167 lines Add/* Get listings, calculate totals */
$cart _goods = Get_cart_goods ();
//$smarty->assign (' Total ' , $cart _goods[' total ']);
$result [' goods_price '] = $cart _goods[' total '] [' goods_price '];
$result [' goods_number '] = $cart _goods[' total '] [' real_goods_count '];
Copy Code
to achieve results based on the above you should all know as shown in figure:    

Implementation method:
GOODS.DWT page <a href= "Javascript:addtocart ({$goods. goods_id},0,1)" >< /a> and the default link a little bit different everyone contrast add
The layer to be displayed is added to the bottom of this leaf <div class= "cartsure" id= "Cartsurebox" style= "Display:none"; >
<div class= "btn" ><a href= "javascript:;" > Close </a></div>
<div class= "Mesgcon" >
<div> Shopping Cart Total <span id= "Ecs_goods_number" ></span> products total: <span id= "Ecs_goods_price" ></span ></div><br>
<input type= "image" src= "Images/btn_pay.gif"/>

</div>
</div>
Copy Code
I also posted the style for your reference. cartsure{
Position:absolute;
left:0;
top:545px;
width:405px;
height:90px;
z-index:999;
Background:url (images/cartsure_bg.gif) 0 0 no-repeat;
font-size:12px;
}

. mesgcon{
Float:left;
Background:url (images/mesg.png) no-repeat 18px 9px;
Color: #666;
line-height:21px;
padding:0 0 0 100px;
width:320px;
}

. Mesgcon h3{
Float:left;
width:320px;
Color: #333;
font-size:14px;
margin:-1px 0 6px;
Height:auto;
line-height:20px;
Background:none;
Text-align:left;
padding:0;
Font-weight:bold;
}

. Mesgcon Input{float:left; margin:0 11px 0 0}

. Mesgcon Div{float:left Font-size:13px}

. Mesgcon div span{font-size:14px; font-weight:bold; color: #F80}

. cartsure. btn{float:left; padding:5px; width:390px}

. cartsure. BTN a{
Background:url (images/close_bg.gif) no-repeat 0 0;
Float:right;
height:13px;
Overflow:hidden;
text-indent:-5000px;
width:38px;
}

. cartsure. BTN a:hover{background-position:0 -12px}
Copy Code
Open js/common.js File Modify AddToCart function modified:
function AddToCart (Goodsid, Parentid,is_ajax)
{
var goods = new Object ();
var Spec_arr = new Array ();
var Fittings_arr = new Array ();
var number = 1;
var formbuy = document.forms[' ecs_formbuy '];
var quick = 0;
Check if there are any product specifications
if (formbuy)
{
Spec_arr = Getselectedattributes (formbuy);

if (formbuy.elements[' number '])
{
Number = formbuy.elements[' number '].value;
}

Quick = 1;
}

Goods.quick = quick;
Goods.spec = Spec_arr;
goods.goods_id = Goodsid;
Goods.number = number;
Goods.parent = (typeof (ParentID) = = "undefined")? 0:parseint (ParentID);

if (Is_ajax = 1) {
Ajax.call (' Flow.php?step=add_to_cart ', ' goods= ' + goods.tojs**tring (), Addtocartresp**e_ajax , ' POST ', ' JSON ');
}else{
Ajax.call (' Flow.php?step=add_to_cart ', ' goods= ' + goods.tojs**tring (), addtocartresp**e, ' POST ', ' JSON ');
}
}
Copy Code
Add several JS functions * *
* process Add product to cart feedback
*/
Function Addtocartresp**e_ajax (result)
{
if (Result.error > 0)
{
//If a shortage registration is required, jump
if (result.error = 2)
{
if (confirm (result.message))
{ br> location.href = ' user.php?act=add_booking&id= ' + result.goods_id + ' &spec= ' + result.product_spec;
}
//opendiv_booking ();

}
No specification, pop-up property selection box
else if (Result.error = 6)
{
Openspediv (Result.message, result.goods_id, result.parent);
}
Else
{
alert (result.message);
}
}
Else
{
var cartinfo = document.getElementById (' Ecs_cartinfo ');
var cart_url = ' Flow.php?step=cart ';
if (cartinfo)
{
cartinfo.innerhtml = result.content;
}

if (result.one_step_buy = ' 1 ')


{


Location.href = Cart_url;


}


Else


{


Switch (result.confirm_type)


{


Case ' 1 ':


if (Confirm (result.message)) location.href = Cart_url;


Break


Case ' 2 ':


if (!confirm (result.message)) location.href = Cart_url;


Break


Case ' 3 ':


Divtipmiddle (result);


Refresh_cart ();


document.getElementById (' Jdiv '). InnerHTML = RESULT.CJ;


Break


Default:


Break


}


}


}


}


Shopping Cart Tip Box js


function Closetipbox () {


document.getElementById (' Cartsurebox '). style.display= "None";


}


function Divtipmiddle (Result) {


Opentipbox (result);


var a = document.getElementById ("Cartsurebox");


A.style.left= (document.body.clientwidth/2-a.clientwidth/2+245) + "px";


}


function Opentipbox (Result) {


document.getElementById (' Ecs_goods_price '). InnerHTML = Result.goods_price;


document.getElementById (' Ecs_goods_number '). InnerHTML = Result.goods_number;


document.getElementById (' Cartsurebox '). style.display= "Block";


}


function opendiv_booking ()


{


document.getElementById (' buyTip2 '). style.display= "Block";

}

Shopping Cart Tip Box js
function Closetipbox () {
document.getElementById (' Cartsurebox '). style.display= "None";
}
Copy Code
Open flow.php 167 Line Add/* Get list of goods, calculate total * *
$cart _goods = Get_cart_goods ();
$smarty->assign (' Total ', $cart _goods[' total ');
$result [' goods_price '] = $cart _goods[' total '] [' goods_price '];
$result [' goods_number '] = $cart _goods[' total '] [' real_goods_count '];
Copy Code
Based on the above actions can be implemented

Implementation method:
GOODS.DWT page <a href= "Javascript:addtocart ({$goods. goods_id},0,1)" >< /a> and the default link a little bit different everyone contrast add
The layer to be displayed is added to the bottom of this leaf <div class= "cartsure" id= "Cartsurebox" style= "Display:none"; >
<div class= "btn" ><a href= "javascript:;" > Close </a></div>
<div class= "Mesgcon" >
<div> Shopping Cart Total <span id= "Ecs_goods_number" ></span> products total: <span id= "Ecs_goods_price" ></span ></div><br>
<input type= "image" src= "Images/btn_pay.gif"/>

</div>
</div>
Copy Code
I also posted the style for your reference. cartsure{
Position:absolute;
left:0;
top:545px;
width:405px;
height:90px;
z-index:999;
Background:url (images/cartsure_bg.gif) 0 0 no-repeat;
font-size:12px;
}

. mesgcon{
Float:left;
Background:url (images/mesg.png) no-repeat 18px 9px;
Color: #666;
line-height:21px;
padding:0 0 0 100px;
width:320px;
}

. Mesgcon h3{
Float:left;
width:320px;
Color: #333;
font-size:14px;
margin:-1px 0 6px;
Height:auto;
line-height:20px;
Background:none;
Text-align:left;
padding:0;
Font-weight:bold;
}

. Mesgcon Input{float:left; margin:0 11px 0 0}

. Mesgcon Div{float:left Font-size:13px}

. Mesgcon div span{font-size:14px; font-weight:bold; color: #F80}

. cartsure. btn{float:left; padding:5px; width:390px}

. cartsure. BTN a{
Background:url (images/close_bg.gif) no-repeat 0 0;
Float:right;
height:13px;
Overflow:hidden;
text-indent:-5000px;
width:38px;
}

. cartsure. BTN a:hover{background-position:0 -12px}
Copy Code
Open js/common.js File Modify AddToCart function modified:
function AddToCart (Goodsid, Parentid,is_ajax)
{
var goods = new Object ();
var Spec_arr = new Array ();
var Fittings_arr = new Array ();
var number = 1;
var formbuy = document.forms[' ecs_formbuy '];
var quick = 0;
Check if there are any product specifications
if (formbuy)
{
Spec_arr = Getselectedattributes (formbuy);

if (formbuy.elements[' number '])
{
Number = formbuy.elements[' number '].value;
}

Quick = 1;
}

Goods.quick = quick;
Goods.spec = Spec_arr;
goods.goods_id = Goodsid;
Goods.number = number;
Goods.parent = (typeof (ParentID) = = "undefined")? 0:parseint (ParentID);

if (Is_ajax = 1) {
Ajax.call (' Flow.php?step=add_to_cart ', ' goods= ' + goods.tojs**tring (), Addtocartresp**e_ajax , ' POST ', ' JSON ');
}else{
Ajax.call (' Flow.php?step=add_to_cart ', ' goods= ' + goods.tojs**tring (), addtocartresp**e, ' POST ', ' JSON ');
}
}
Copy Code
Add several JS functions * *
* process Add product to cart feedback
*/
Function Addtocartresp**e_ajax (result)
{
if (Result.error > 0)
{
//If a shortage registration is required, jump
if (result.error = 2)
{
if (confirm (result.message))
{ br> location.href = ' user.php?act=add_booking&id= ' + result.goods_id + ' &spec= ' + result.product_spec;
}
//opendiv_booking ();

}
No specification, pop-up property selection box
else if (Result.error = 6)
{
Openspediv (Result.message, result.goods_id, result.parent);
}
Else
{
alert (result.message);
}
}
Else
{
var cartinfo = document.getElementById (' Ecs_cartinfo ');
var cart_url = ' Flow.php?step=cart ';
if (cartinfo)
{
cartinfo.innerhtml = result.content;
}

if (result.one_step_buy = ' 1 ')


{


Location.href = Cart_url;


}


Else


{


Switch (result.confirm_type)


{


Case ' 1 ':


if (Confirm (result.message)) location.href = Cart_url;


Break


Case ' 2 ':


if (!confirm (result.message)) location.href = Cart_url;


Break


Case ' 3 ':


Divtipmiddle (result);


Refresh_cart ();


document.getElementById (' Jdiv '). InnerHTML = RESULT.CJ;


Break


Default:


Break


}


}


}


}


Shopping Cart Tip Box js


function Closetipbox () {


document.getElementById (' Cartsurebox '). style.display= "None";


}


function Divtipmiddle (Result) {


Opentipbox (result);


var a = document.getElementById ("Cartsurebox");


A.style.left= (document.body.clientwidth/2-a.clientwidth/2+245) + "px";


}


function Opentipbox (Result) {


document.getElementById (' Ecs_goods_price '). InnerHTML = Result.goods_price;


document.getElementById (' Ecs_goods_number '). InnerHTML = Result.goods_number;


document.getElementById (' Cartsurebox '). style.display= "Block";


}


function opendiv_booking ()


{


document.getElementById (' buyTip2 '). style.display= "Block";

}

//Shopping cart hint Box js
function Closetipbox () {
document.getElementById (' Cartsurebox '). style.display= "None";
}
Copy Code
Open flow.php 167 lines Add/* Get listings, calculate totals */
$cart _goods = Get_cart_goods ();
//$smarty->assign (' Total ' , $cart _goods[' total ']);
$result [' goods_price '] = $cart _goods[' total '] [' goods_price '];
$result [' goods_number '] = $cart _goods[' total '] [' real_goods_count '];
Copy Code
to implement
&NBSP;&NBSP;&NBSP

based on the above actions

Implementation method:
GOODS.DWT page <a href= "Javascript:addtocart ({$goods. goods_id},0,1)" >< /a> and the default link a little bit different everyone contrast add
The layer to be displayed is added to the bottom of this leaf <div class= "cartsure" id= "Cartsurebox" style= "Display:none"; >
<div class= "btn" ><a href= "javascript:;" > Close </a></div>
<div class= "Mesgcon" >
<div> Shopping Cart Total <span id= "Ecs_goods_number" ></span> products total: <span id= "Ecs_goods_price" ></span ></div><br>
<input type= "image" src= "Images/btn_pay.gif"/>

</div>
</div>
Copy Code
I also posted the style for your reference. cartsure{
Position:absolute;
left:0;
top:545px;
width:405px;
height:90px;
z-index:999;
Background:url (images/cartsure_bg.gif) 0 0 no-repeat;
font-size:12px;
}

. mesgcon{
Float:left;
Background:url (images/mesg.png) no-repeat 18px 9px;
Color: #666;
line-height:21px;
padding:0 0 0 100px;
width:320px;
}

. Mesgcon h3{
Float:left;
width:320px;
Color: #333;
font-size:14px;
margin:-1px 0 6px;
Height:auto;
line-height:20px;
Background:none;
Text-align:left;
padding:0;
Font-weight:bold;
}

. Mesgcon Input{float:left; margin:0 11px 0 0}

. Mesgcon Div{float:left Font-size:13px}

. Mesgcon div span{font-size:14px; font-weight:bold; color: #F80}

. cartsure. btn{float:left; padding:5px; width:390px}

. cartsure. BTN a{
Background:url (images/close_bg.gif) no-repeat 0 0;
Float:right;
height:13px;
Overflow:hidden;
text-indent:-5000px;
width:38px;
}

. cartsure. BTN a:hover{background-position:0 -12px}
Copy Code
Open js/common.js File Modify AddToCart function modified:
function AddToCart (Goodsid, Parentid,is_ajax)
{
var goods = new Object ();
var Spec_arr = new Array ();
var Fittings_arr = new Array ();
var number = 1;
var formbuy = document.forms[' ecs_formbuy '];
var quick = 0;
Check if there are any product specifications
if (formbuy)
{
Spec_arr = Getselectedattributes (formbuy);

if (formbuy.elements[' number '])
{
Number = formbuy.elements[' number '].value;
}

Quick = 1;
}

Goods.quick = quick;
Goods.spec = Spec_arr;
goods.goods_id = Goodsid;
Goods.number = number;
Goods.parent = (typeof (ParentID) = = "undefined")? 0:parseint (ParentID);

if (Is_ajax = 1) {
Ajax.call (' Flow.php?step=add_to_cart ', ' goods= ' + goods.tojs**tring (), Addtocartresp**e_ajax , ' POST ', ' JSON ');
}else{
Ajax.call (' Flow.php?step=add_to_cart ', ' goods= ' + goods.tojs**tring (), addtocartresp**e, ' POST ', ' JSON ');
}
}
Copy Code
Add several JS functions * *
* process Add product to cart feedback
*/
Function Addtocartresp**e_ajax (result)
{
if (Result.error > 0)
{
//If a shortage registration is required, jump
if (result.error = 2)
{
if (confirm (result.message))
{ br> location.href = ' user.php?act=add_booking&id= ' + result.goods_id + ' &spec= ' + result.product_spec;
}
//opendiv_booking ();

}
No specification, pop-up property selection box
else if (Result.error = 6)
{
Openspediv (Result.message, result.goods_id, result.parent);
}
Else
{
alert (result.message);
}
}
Else
{
var cartinfo = document.getElementById (' Ecs_cartinfo ');
var cart_url = ' Flow.php?step=cart ';
if (cartinfo)
{
cartinfo.innerhtml = result.content;
}

if (result.one_step_buy = ' 1 ')


{


Location.href = Cart_url;


}


Else


{


Switch (result.confirm_type)


{


Case ' 1 ':


if (Confirm (result.message)) location.href = Cart_url;


Break


Case ' 2 ':


if (!confirm (result.message)) location.href = Cart_url;


Break


Case ' 3 ':


Divtipmiddle (result);


Refresh_cart ();


document.getElementById (' Jdiv '). InnerHTML = RESULT.CJ;


Break


Default:


Break


}


}


}


}


Shopping Cart Tip Box js


function Closetipbox () {


document.getElementById (' Cartsurebox '). style.display= "None";


}


function Divtipmiddle (Result) {


Opentipbox (result);


var a = document.getElementById ("Cartsurebox");


A.style.left= (document.body.clientwidth/2-a.clientwidth/2+245) + "px";


}


function Opentipbox (Result) {


document.getElementById (' Ecs_goods_price '). InnerHTML = Result.goods_price;


document.getElementById (' Ecs_goods_number '). InnerHTML = Result.goods_number;


document.getElementById (' Cartsurebox '). style.display= "Block";


}


function opendiv_booking ()


{


document.getElementById (' buyTip2 '). style.display= "Block";

}

//Shopping cart hint Box js
function Closetipbox () {
document.getElementById (' Cartsurebox '). style.display= "None";
}
Copy Code
Open flow.php 167 lines Add/* Get listings, calculate totals */
$cart _goods = Get_cart_goods ();
//$smarty->assign (' Total ' , $cart _goods[' total ']);
$result [' goods_price '] = $cart _goods[' total '] [' goods_price '];
$result [' goods_number '] = $cart _goods[' total '] [' real_goods_count '];

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.