Jump to content

'add To Cart' Button In Search Result Drop Down


kaushalsingh

Recommended Posts

I'm running a grocery shop, using prestashop 1.5.3.1. I need to add 'add to cart' button directly into search drop down, so that user can directly add product to cart without going into product page.

 

My complete Idea is:

- When user queries about any product, an 'add to cart' button is also there (on right align) in search result drop down, which is being shown just beneath the search text box.

 

-After clicking 'add to cart' button the product page would not be loaded, instead that one more text field appear on right of seach button, where user can feed for quantity. Then one final button to add to cart.

 

- for example, as currently on querying 'ipod' into search input field one of search result is 'ipods > ipod Nano' in result drop down. Now what i want is to display few details of product, for example.

on searching 'rice' result should like:

'Basmati Rice 1Kg Pack 2$ add button'.

 

Any suggestion or idea to implement these features would be great.

ThankYou

Edited by kaushalsingh (see edit history)
Link to comment
Share on other sites

What you're looking for is not easy as it might seem.

You have to edit 2 files basically:

1- in the blocksearch module:blocksearch-instantsearch.tpl

2. controllers/searchcontroller.php

 

The process is a bit long to explain here, I'll try to write a tutorial on this today and publish it tomorrow ;)

 

Basically, you need to edit the "ajaxSearch" part in the tpl's javascript, but you need to retrieve ALL product data before you can do that, and therefore you must absolutely remove the ajax = true (last parameter passed) at line 63 of the searchcontroller. Stay tuned, I'll see what i can do for the tut ;)

  • Like 1
Link to comment
Share on other sites

Thanx for the reply, Now I dropped the plan of using the default search block. Now I am trying to write individual module for my purpose. Will add a search input field, onkeyup ajax search, using keyword search in database, using 'like' keyword of mysql.

 

For this can you help me for:

what parameters required for add to cart API, and how to call add to cart api. So that I can search for product and directly add to cart from there without going to product page. Hope this wont take much time of you, but i have to do too much research if i do it by myself.

Thank you :)

Link to comment
Share on other sites

I am working on this module but due to little knowledge of prestashop hooks and file architecture got stuck. :(

Here is the link of the part i completed, its not too muchjust a start :

 

https://www.dropbox.com/s/qteyq8arpwvntkq/search.zip

 

To use this, you have to change database settings in dbconf.php

Things to be implemented:

-In dropdown search result unit of price is not being displayed as now, the unit should be according to the currency setting of user

-If you look into mysql query, its not specific about the language. So now this is searching for product in every language. It should be specific to the language setting of user.

-During testing keep opened the javascript console, after product selection final parameters to be passed to add to cart api is being printed there. (this is printed from javascript add function)

 

Also i dont know how to integrate this with prestashop. It would be great if some one work on it further.

Thanks :)

Link to comment
Share on other sites

  • 1 year later...
  • 3 months later...

Sandy

At the moment, when searching products and just press enter (that is, you don't make any choice from the suggestions it shows), a 'product-list' of all products that fulfil the required search are displayed. There you can just add to cart without going to the product page first.

 

Is that sort of what you need/look for?

 

My 2 cents,

pascal.

Link to comment
Share on other sites

Hi Pascal,

 

  Now, in the basic version of the prestashop, we can search the product and select it. And after we select the product, we can add to cart. Is there any way that we can have a cart button in the search results itself.

 

If so, please let us know.

Link to comment
Share on other sites

Hi Sandy,

 

as said, if you DON'T choose one single product from the search result list, but just press Enter, you get more products that match the search. This is similar to a product list, where you can just press add to cart directly without going into the product detail page.

 

So what you could do is then just remove the search drop down list while searching, but force the user to add the search string and press enter. (to achieve this,  in back office, in Preferences->search, turn OFF Ajax search, and turn ON instant search:

post-455771-0-11629000-1427787212_thumb.png

 

To really add the add to cart button in the pop up search result menu is indeed much more work, as people mentioned above. Maybe my idea is a good compromise?

 

 

My 2 cents,

pascal

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...