Support » Plugin: MarketPress - WordPress eCommerce » Delete items from Shopping Cart Page 'jquery way'

  • Hey, there,

    I figured out how to delete items in “Shopping Cart Page” without pressing ‘update cart’ button lets say ‘jquery way’. Just check delete checkbox to see it in action. It works, but need your revision on this solution (working on quantity update) 😉

    In store.js add:

    //store.js delete item
    function mp_delete_item() {
        $("input[type='checkbox']").click(function(){
            var mp_item = $(this).val();
            $.post(MP_Ajax.ajaxUrl, {action: 'mp-update-cart', update_cart_submit: 1, 'remove[]': mp_item }, function(vall) {
              $("#mp_cart_form").html(vall);
              mp_delete_item(); //re-init script
            });
        });
      }
      mp_delete_item();

    In marketpress.php function update_cart() add:

    //remove items
      if (is_array($_POST['remove'])) {
        foreach ($_POST['remove'] as $pbid) {
    	  list($bid, $product_id, $variation) = split(':', $pbid);
              unset($global_cart[$bid][$product_id][$variation]);
            }
    
            //save items to cookie
    	$this->set_global_cart_cookie($global_cart);
    
            //ajax thing
            if (defined('DOING_AJAX') && DOING_AJAX) {
            $return = _mp_cart_table('checkout-edit');
            echo $return;
            exit;
            }
          }

    http://wordpress.org/extend/plugins/wordpress-ecommerce/

  • The topic ‘Delete items from Shopping Cart Page 'jquery way'’ is closed to new replies.