Support » Plugin: Advanced Woo Search » Add To Cart Button

  • Resolved Justin

    (@azyrus_pok)



    Hey ILLID, hey everyone.

    How good would a add to cart button be in the AJAX search result? Have you done this or could you point me in the right direction to build this?

    Thanks in advance!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hey ILLID,

    I’m hoping to add:

    
    if ( ( typeof response.cats !== 'undefined' ) && response.cats.length > 0 ) {
    
                        $.each(response.cats, function (i, result) {
    
                            html += '<li class="aws_result_item aws_result_cat">';
                            html += '<a class="aws_result_link" href="' + result.link + '" >';
                            html += '<span class="aws_result_content">';
                            html += '<span class="aws_result_title">';
                            html += result.name;
                            html += '<span class="aws_result_count"> (' + result.count + ')</span>';
                            html += '</span>';
                            html += '</span>';
    						html += '<a href="http://www.website.com/cart/?add-to-cart= (' + result.id + ')">Add To Cart</a>'
                            html += '</a>';
                            html += '</li>';
    
                        });
    
                    }
    

    How do you propose I pull the $post_ID into the common.js result.id variable?

    Thanks!

    Plugin Author ILLID

    (@mihail-barinov)

    Hi,

    Find loop

    $.each(response.products, function (i, result) {
    .............
    }

    and inside it you can call

    result.post_data.ID

    to get product ID.

    • This reply was modified 6 months, 2 weeks ago by  ILLID.

    Did this work? do you have a demo?

    Hey Wayne,

    if result on sale starts at line 176. (advanced woo search > assets > common.js)

    
                            if ( result.on_sale ) {
                                html += '<span class="aws_result_sale">';
                                html += '<span class="aws_onsale">' + translate.sale + '</span>';
                                html += '</span>';
                            }
    
                            html += '</a>';
    						html += '<a href="http://www.website.com/cart/?add-to-cart= (' + result.post_data.ID + ')" style="float:right;">Add To Cart</a>'
                            html += '</li>';
    

    That did work, unfortunately I can’t provide a demo.

    Good luck!

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.