简体   繁体   English

jQuery购物车按钮添加删除

[英]Jquery shopping cart button add remove

I have a landing page. 我有一个登陆页面。 I'm showing some product in this landing page.. 我正在此目标网页中显示一些产品。

When users select product in this page must go my virtuemart page.. 当用户在此页面中选择产品时,必须转到我的观点购物页面。

Virtuemart direct add to cart link like that: Virtuemart直接添加到购物车链接是这样的:

http://www.mysite.com/index.php?option=com_virtuemart&view=cart&task=add&virtuemart_product_id[]=2762&quantity[]=5&virtuemart_product_id[]=792&quantity[]=2

When selecting a product reading rel value with jquery (it is virtuemart product id) quantity is not important it is must be 1.. and adding that value end of link checkout button 当选择带有jquery的产品读取rel值(这是德意志商品ID)时,数量并不重要,它必须为1.。并在链接结帐按钮的末尾添加该值

&virtuemart_product_id[]=2762&quantity[]=1

My jsfiddle demo: 274 line starting cart jquery code 我的jsfiddle演示: 274行开始的购物车jquery代码

it is working but when delete a product in checkout list not remove products value in checkout button link. 它正在工作,但是在结帐清单中删除产品时,不会在结帐按钮链接中删除产品值。

if delete a product must delete product id to in checkout button link &virtuemart_product_id[]=2762&quantity[]=1 如果删除产品,则必须在结帐按钮链接中删除产品ID到&virtuemart_product_id[]=2762&quantity[]=1

I don't know very good jQuery.. How can i fix it? 我不知道非常好的jQuery。我该如何解决?

Regards 问候

I've looked at your code and you only add query string to your link and you dont do nothing to clear the string when you trash the items u even not need to use jQuery and only html when you remove item: 我看过您的代码,您只向链接中添加查询字符串,并且在丢弃项目时不做任何操作来清除字符串,甚至在删除项目时也不需要使用jQuery和html:

$(".remove").click(function(){
   var stringToClear= $(this).parent(".someDivWithItemInfo");//->&virtuemart_product_id[]=2762&quantity[]=1
   var currentHrefLink= $("#linkId").attr("href");
   currentHrefLink = currentHrefLink.replace(stringToClear, "");
   $("#linkId").attr("href",currentHrefLink);
});

jsfiddle demo: http://jsfiddle.net/C59Qk/2/ jsfiddle演示: http : //jsfiddle.net/C59Qk/2/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM