Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9024183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:56:34+00:00 2026-06-16T05:56:34+00:00

i creating a drag&drop cart in virtuemark. but i have a problem in this

  • 0

i creating a drag&drop cart in virtuemark. but i have a problem in this javascript jquery script and i spent all a day to find error in these codes:

function addToCart( jQueryitem ) {
        var jQuerylist = jQuery( "ul", jQueryhv_cart_items ).length ?
        jQuery( "ul", jQueryhv_cart_items ) :
            jQuery( "<ul class='gallery ui-helper-reset'/>" ).appendTo( jQueryhv_cart_items );

        //ajax add to cart
        var hvvid = jQueryitem.attr("id");
        var hvvcatid = jQueryitem.attr("catid");

        jQuery.get("index.php?quantity[]=1&addtocart=Thêm vào giỏ hàng&option=com_virtuemart&view=cart&task=add&virtuemart_product_id[]="+hvvid+"&virtuemart_category_id[]="+hvvcatid,function(data,status){
            //alert("Data: " + data + "\nStatus: " + status);
        });

        //@hoangvi: find product has the same id with hvvid
        //if founded update product quantity
        //otherwise add product to cart
        var total_li = jQuerylist.find("li").length;
        for (var i=0; i<total_li; ++i) {
            var current_li = jQuerylist.find("li")[i];
            //alert(jQuery('<div/>').append(current_li.clone()).html());
            var li_hidden = current_li.find("span.hv_hidden");
            //alert(jQuery('<div/>').append(li_hidden.clone()).html());
            var id = li_hidden.attr("id");
            //alert(id);
            if (id == hvvid) { //founded
                var quantity = li_hidden.attr('quantity');
                //alert(quantity);
                quantity = quantity+1;
                li_hidden.attr('quantity',quantity);
                return;
            }
        }

        //add product to cart
        var jQueryitem2 = jQuery('<li class="ui-widget-content ui-corner-tr"></li>');
        var jQueryitem_img = jQuery("<div />").append(jQueryitem.find( 'img' ).clone()).html();

        jQueryitem2.append( jQueryitem_img ).append('<span>SL: 1</span> ' )
        .append('<span class="hv_hidden" id="' + hvvid + '" quantity="1"> </span> ');
        jQueryitem2.appendTo( jQuerylist ).fadeIn(function() {
            jQueryitem2
                .animate({ width: "48px" })
                .find( "img" )
                    .animate({ height: "36px" });
        });
        jQueryitem2.append()
    //});
}

i think this problem in these codes:

        //@hoangvi: find product has the same id with hvvid
        //if founded update product quantity
        //otherwise add product to cart
        var total_li = jQuerylist.find("li").length;
        for (var i=0; i<total_li; ++i) {
            var current_li = jQuerylist.find("li")[i];
            //alert(jQuery('<div/>').append(current_li.clone()).html());
            var li_hidden = current_li.find("span.hv_hidden");
            //alert(jQuery('<div/>').append(li_hidden.clone()).html());
            var id = li_hidden.attr("id");
            //alert(id);
            if (id == hvvid) { //founded
                var quantity = li_hidden.attr('quantity');
                //alert(quantity);
                quantity = quantity+1;
                li_hidden.attr('quantity',quantity);
                return;
            }
        }

because it work normally when i delete the above code(but cannot update product quantity when i add two product has same id). i think this is a syntax error because it make jquery cant work normally. the html code like this:

<ul class="gallery ui-helper-reset">
                                <li class="ui-widget-content ui-corner-tr" style="width: 48px;"><img src="/chovietnam.com/images/stories/virtuemart/product/resized/vantech-vt-3500i_90x90.jpg" alt="vantech-vt-3500i" class="featuredProductImage" border="0" style="height: 36px;"><span>SL: 1</span> <span class="hv_hidden" id="24" quantity="1"> </span> </li><li class="ui-widget-content ui-corner-tr" style="width: 48px;"><img src="/chovietnam.com/images/stories/virtuemart/product/resized/lenovo-g460small_90x90.jpg" alt="lenovo-g460small" class="featuredProductImage" border="0" style="height: 36px;"><span>SL: 1</span> <span class="hv_hidden" id="21" quantity="1"> </span> </li><li class="ui-widget-content ui-corner-tr" style="width: 48px;"><img src="/chovietnam.com/images/stories/virtuemart/product/resized/designer-handbag-223093101833428290_90x90.jpg" alt="designer-handbag-223093101833428290" class="featuredProductImage" border="0" style="height: 36px;"><span>SL: 1</span> <span class="hv_hidden" id="19" quantity="1"> </span> </li></ul>

anyone can help me solve this problem, thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:56:36+00:00Added an answer on June 16, 2026 at 5:56 am

    The error is in the lines below.

    var current_li = jQuerylist.find("li")[i]' // This gets the DOM Object
    
    var li_hidden = current_li.find("span.hv_hidden");
    

    current_li is a DOM Object and not a jQuery Object

    So current_li should be $(current_li)

    Convert that into a jQuery Object before you use .find()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been creating a HTML5 Drag & Drop image up-loader. All is good with
I have a working version of HTML5 drag & drop file uploader. I was
I have 5 label that I created by drag & drop on the form.
I was creating Tree Panel similar to TreeGrid example with drag'n'drop. The only problem
I have problem with setTimeout. In all major browsers it works fine but not
I'm creating a flex drag and drop interface of sorts that will have a
I have a drag and drop event in a game I am creating. Instead
I'm creating a simple drag and drop game with jquery's draggable plugin. There are
I am creating different frames for my GUI(Netbeans drag and drop) and in that
I am looking for some framework or toolkit (style drag and drop) for creating

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.