Close

Add the SHARE button and ADD TO WHISHLIST to the results

raflebaron
8 years ago
#9534 Quote
Avatar
  • 2
Hello guys,  we have the smart theme, and i d like to add the SHARE button and ADD TO WHISHLIST to the results page or homepage for each product. How can i do that cleanly ? Thanks !
Deni
8 years ago
#9535 Quote
Avatar
  • Moderator
  • 389
raflebaron wrote:
Hello guys,  we have the smart theme, and i d like to add the SHARE button and ADD TO WHISHLIST to the results page or homepage for each product. How can i do that cleanly ? Thanks !


Hi, 

To achieve both functionalities you should follow these steps:

1. Go to this file: \Themes\Smart\Views\Shared\_ProductBox.cshtml.

2. Find the element with class "buttons".

3. In its end plave this code:

@if (!Model.ProductPrice.DisableWishlistButton)
{
  var addtowishlistlink = Url.RouteUrl("AddProductToCart-Catalog", new { productId = Model.Id, shoppingCartTypeId = (int)ShoppingCartType.Wishlist, quantity = 1 });
  <input type="button" value="@T("ShoppingCart.AddToWishlist")" title="@T("ShoppingCart.AddToWishlist")" class="button-2 add-to-wishlist-button" onclick="AjaxCart.addproducttocart_catalog('@addtowishlistlink');return false;" />
}

<!-- Facebook -->
@{
  var storeUrL = Nop.Core.Infrastructure.EngineContext.Current.Resolve<Nop.Core.IStoreContext>().CurrentStore.Url.TrimEnd('/');
  string realProductUrl = storeUrL + Url.RouteUrl("Product", new { SeName = Model.SeName });
}
<a class="fb-share-link" href="javascript:openProductsShareWindow('https://www.facebook.com/sharer.php?u=@realProductUrl')" target="_blank" style="font-size: 13px;">@T("SevenSpikes.FacebookShop.Public.ProductBox.ShareToFacebook")</a>


4. Go to this file: \Themes\Smart\Content\scripts\Smart.js.

5. Add this code to the end of the file: 

function openProductsShareWindow(url) {
    var winWidth = 520;
    var winHeight = 400;
    var winTop = (screen.height / 2) - (winHeight / 2);
    var winLeft = (screen.width / 2) - (winWidth / 2);

    window.open(url, 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight);
}


6. Now you have to style these buttons. I will leave this to you.

I hope everything is clear!
Best Regards,
Mladen Staykov
Nop-Templates.com
raflebaron
8 years ago
#9539 Quote
Avatar
  • 2
I will try with that, thank you!