Jump to content

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


jahyax

Recommended Posts

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
Link to comment
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..

Link to comment
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

Link to comment
Share on other sites

  • 1 year later...
  • 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
×
×
  • Create New...