Ecshop Add shopping cart plus picture fly-in effect

Source: Internet
Author: User

Add a picture fly-in effect for Ecshop's added shopping cart.
First of all:
Find the Add Shopping cart button in GOODS.DWT:
Add the ID for adding the cart button:
For example:
<a id= "iproduct_{$goods. goods_id}" href= "Javascript:{addtocart ({$goods. goods_id})" >
</a>
Then: Add in JS:
<script type= "Text/javascript" >

var Cart = {
ID: ' Ecs_cartinfo ',
Addproduct:function (cpid, num, t) {
Add Item
var ops =$ ("[Id=iproduct_" +cpid+ "]"). Parents ("#goodsInfo"). Children (". Goodsitem"). Find ("[id=product_" +cpid+ "]");
if (ops.length>0) {
var NPS =ops.clone (). css ({"position": "Absolute", "Top": Ops.offset (). Top, "left": Ops.offset (). Left, "Z-index": 999999999}). Show ();
Nps.appendto ("Body"). Animate ({top:$ ("#ECS_CARTINFO"). Offset (). Top,left: $ ("#ECS_CARTINFO"). Offset (). Left, Width: height:50},{duration:1000,
Callback:function () {}, Complete:function () {nps.remove (); AddToCart ({$goods. goods_id});});
}
var op =$ ("[Id=iproduct_" +cpid+ "]"). Parents ("#goodsInfo"). Children ('. Imginfo '). Find ("Img:first");
if (op.length>0) {
var np =op.clone (). css ({"position": "Absolute", "Top": Op.offset (). Top, "left": Op.offset (). Left, "Z-index": 999999999} ). Show ();
Np.appendto ("Body"). Animate ({top:$ ("#ECS_CARTINFO"). Offset (). Top,left: $ ("#ECS_CARTINFO"). Offset (). Left, Width: height:50},{duration:1000,
Callback:function () {}, Complete:function () {np.remove (); AddToCart ({$goods. goods_id});});
}
}
}
$ (function () {
$ (' [id^=iproduct_{$goods. goods_id}] '). Click (function () {
var cpid =this.id.replace (' iproduct_{$goods. goods_id} ', ' {$goods. goods_id} ');
varn=$ (' #number '). Val ();
if (n!=null| | n!=undefined) {
if (n<1) {n=1;}
Cart.addproduct (cpid, n, 0);
}else{
Cart.addproduct (cpid, 1, 0);
}
Returnfalse;
});
});
</script>
Modify:
To modify the shopping cart function:
After the shopping cart has been added successfully: Modify the shopping cart display information:
Add Change_cart_info after callback function
Add the function in JS:
Update the shopping cart display information after Ajax add
Functionchange_cart_info () {
$.ajax ({
Type: "POST",
URL: "flow.php",
Data: "Step=ajax_update_cart",
Success:function (res) {
$ ("#ECS_CARTINFO"). HTML (RES)
}
})
}
To add a handler function in flow.php:


if ($_request[' step '] = = ' Ajax_update_cart ') {
echo "OK";
$sql = ' SELECT sum (goods_number) as number, SUM (Goods_price *goods_number) as amount '.
' From '. $GLOBALS [' ECS ']->table (' cart ').
"WHERE session_id = '". sess_id. "' and Rec_type = '". Cart_general_goods. "‘";
$row = $GLOBALS [' db ']->getrow ($sql);

if ($row)
{
= Intval ($row [' number ']);
$amount = Floatval ($row [' Amount ']);
}
Else
{
= 0;
$amount = 0;
}
$str =sprintf ($GLOBALS [' _lang '] [' cart_info '],, Price_format ($amount, false));

Exit (' <a href= ' flow.php "title=" '. $GLOBALS [' _lang '] [' View_cart ']. ' > '. $str. ' </a> ');
}

Effect
Original state:

Click Add to Cart:

Taken off:

Landed on the AH:

Ecshop Add shopping cart plus picture fly-in effect

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.