Jump to content

[solved] how to add 'add to cart button' on favorite products


jahyax
 Share

Recommended Posts

is there a way to add the "ADD TO CART" button on list of products under my favorite products?

 

so that the customer can click 'ADD TO CART' just by being on the favorite product list and without having to click on the product itself.

Edited by vekia (see edit history)

Share this post


Link to post
Share on other sites

In basic, you can do something like this:

 

edit file: modules/favoriteproducts/views/templates/front/favoriteproducts-account.tpl

 

and add the red code:

 

 

{foreach from=$favoriteProducts item=favoriteProduct}

<div class="favoriteproduct clearfix">

<a href="{$link->getProductLink($favoriteProduct.id_product, null, null, null, null, $favoriteProduct.id_shop)|escape:'htmlall':'UTF-8'}" class="product_img_link">

<img src="{$link->getImageLink($favoriteProduct.link_rewrite, $favoriteProduct.image, 'medium_default')|escape:'htmlall':'UTF-8'}" alt=""/></a>

<h3><a href="{$link->getProductLink($favoriteProduct.id_product, null, null, null, null, $favoriteProduct.id_shop)|escape:'htmlall':'UTF-8'}">{$favoriteProduct.name|escape:'htmlall':'UTF-8'}</a></h3>

<div class="product_desc">{$favoriteProduct.description_short|strip_tags|escape:'htmlall':'UTF-8'}</div>

 

 

<a class="button ajax_add_to_cart_button exclusive" rel="ajax_id_product_{$favoriteProduct.id_product|intval}" href="{$link->getPageLink('cart',false, NULL, "add=1&id_product={$favoriteProduct.id_product|intval}", false)}" title="{l s='Add to cart'}"><span></span>{l s='Add to cart'}</a>

 

<div class="remove">

...

 

This does basically the job, but there should maybe be added some code for tests when exactly you can enable/ should disable the button, like when the shop is in catalog mode, the product is out of stock, if there are selectable attributes to choose first etc. This I didn't do. There are probably some sample files where they do this already.

 

My 2 cents,

pascal

Edited by PascalVG (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

Pascal,

 

so far when i set my shop into catalog mode, the add to cart button wont disappear, it is still clickable, and it will re direct to the home page.

 

hopefully we could find a workaround on this.

 

but your solution is very helpful , this will do the trick for now..

Share this post


Link to post
Share on other sites

glad to hear that Pascal and I helped you here, and finally everything work as you expected.

Im going to mark this topic as [solved]

if you have any additonal questions related to this case - feel free to continue discussion here

 

best regards

Share this post


Link to post
Share on other sites

  • 1 year later...

Hi,

 

I don't know if it's possible to post in a solved topic...

 

Many thanks for the trick. It works but when I try to add a product to cart, it says that it doesn't exist

 

Can you help me please ?

Thanks in advance

Share this post


Link to post
Share on other sites

  • 3 weeks later...

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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More