添加新项目时,Woocommerce会从购物车中删除商品

时间:2014-05-01 00:26:37

标签: jquery ajax wordpress wordpress-plugin woocommerce

我正在使用华丽的产品设计师进行woocommerce(http://fancyproductdesigner.com/woocommerce-plugin/

使用此插件,用户可以创建自定义产品设计并将其添加到购物车。查看购物车时,有一个链接可以返回并编辑其设计。在编辑用户点击后,再次添加到购物车,它将新项目添加到购物车而不是更新当前。然后,用户必须从购物车中手动删除旧设计。

我在编辑项目时创建了一个ajax调用,因此当单击“添加到购物车”链接时,它会执行以下ajax调用以从购物车中删除旧项目。这是下面的ajax调用。

// if a user is editing an item. remove the old one on save.
        $('.single_add_to_cart_button').click(function(evt) {
            $.ajaxSetup({ cache: false });
            if(options.editingFP) {

                //$.get( options.removeCI.replace('&','&'), function( data ) { alert(data); });
                $.ajax({
                  type: 'GET',
                  url: options.removeCI.replace('&','&'),
                  beforeSend:function(){
                    // this is where we append a loading image
                    alert('getting ready to send ajax call to remove item from cart');
                  },
                  success:function(data){
                    // successful request; do something with the data

                    alert('success');
                  },
                  error:function(){
                    // failed request; give feedback to user
                    alert('error');
                  }
                });

            }

        });

问题是有时在ajax调用完成之前提交购物车。

还有其他办法吗?

0 个答案:

没有答案
相关问题