Jump to content

[solved] how to hide add to cart button on product listing page? (when attributes)


lovemyseo

Recommended Posts

see  themes/yourtheme/product-list.tpl

 

here you can modify how/when the add to cart button is displayed, it's a start :)

 

make sure to back up any files before updating them, and for .tpl files bo-->adv parms-->smart complile should be set to 'if udpdated' so you can see your changes.

Should I simply comment out Add to cart button from product listing.tpl?

And if I want to hide only for specific product listing then what I have to do PS version is 1.6.0.9?

As shown in above example

 

here is my theme product.tpl file display 

 

{*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2013 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}
 
{if isset($products)}
<script>
jQuery(document).ready(function($){
    var default_view = "{$theme_options['product_list_layout']}";
theid = $('a.switcher').attr("id"),
theproducts = $("ul#product_list"),
classNames = $('a.switcher').attr('class').split(' '),
gridthumb = "{$base_dir}themes/control/images/grid-default-thumb.png",
listthumb = "{$base_dir}themes/control/images/list-default-thumb.png";
 
    if($.cookie('view') !== 'undefined'){
        $.cookie('view', default_view, { expires: 7, path: '/' });
    } 
    function get_grid(){
$('#gridview').addClass("active");
$("#listview").removeClass("active");
 
$("#listview").children("img").attr("src","{$base_dir}themes/control/images/list-view.png");
 
var theimg = $('#gridview').children("img");
theimg.attr("src","{$base_dir}themes/control/images/grid-view-active.png");
 
theproducts.removeClass("list");
theproducts.addClass("grid");
 
$("img.thumb").attr("src",gridthumb);
    }
    function get_list(){
$('#listview').addClass("active");
$("#gridview").removeClass("active");
 
$("#gridview").children("img").attr("src","{$base_dir}themes/control/images/grid-view.png");
 
var theimg = $('#listview').children("img");
theimg.attr("src","{$base_dir}themes/control/images/list-view-active.png");
 
theproducts.removeClass("grid")
theproducts.addClass("list");
 
$("img.thumb").attr("src",listthumb);
    }
 
    if($.cookie('view') == 'list'){ 
$('#listview').addClass("active");
$("#gridview").removeClass("active");
 
$("#gridview").children("img").attr("src","{$base_dir}themes/control/images/grid-view.png");
 
var theimg = $('#listview').children("img");
theimg.attr("src","{$base_dir}themes/control/images/list-view-active.png");
 
theproducts.removeClass("grid")
theproducts.addClass("list");
 
$("img.thumb").attr("src",listthumb);
    } 
 
    if($.cookie('view') == 'grid'){ 
$('#gridview').addClass("active");
$("#listview").removeClass("active");
 
$("#listview").children("img").attr("src","{$base_dir}themes/control/images/list-view.png");
 
var theimg = $('#gridview').children("img");
theimg.attr("src","{$base_dir}themes/control/images/grid-view-active.png");
 
theproducts.removeClass("list");
theproducts.addClass("grid");
 
$("img.thumb").attr("src",gridthumb);
    }
 
    $('#listview').click(function(e){   
        $.cookie('view', 'list'); 
        get_list();
e.preventDefault();
    });
 
    $('#gridview').click(function(e){ 
        $.cookie('view', 'grid'); 
        get_grid();
e.preventDefault();
    });
 
});
</script>
<!-- Products list -->
<ul id="product_list" class="nolist grid">
{foreach from=$products item=product name=products}
{if $theme_options['global_layout'] == full}
<li class="col-lg-3 col-sm-4 col-xs-6 col-ms-12">
{else}
<li class="col-lg-4 col-sm-6 col-xs-6 col-ms-12">
{/if}
<div>
 
{if $theme_options['control_quickview'] == '1'}
<a class="quick-view" href="{$product.link|escape:'html':'UTF-8'}" rel="{$product.link|escape:'html':'UTF-8'}">
<i class="fa fa-search"></i> {l s='Quick view'}
</a>
{/if}
 
<p class="icons">
{if isset($product.new) && $product.new == 1}<span class="new_list">{l s='New'}</span>{/if}
{if isset($product.on_sale) && $product.on_sale && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE}<span class="on_sale_list">{l s='Sale'}</span>
{elseif isset($product.reduction) && $product.reduction && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE}<span class="discount_list">{l s='Promotion'}</span>{/if}
</p>
<a class="product_img" href="{$product.link|escape:'html'}"><img class="img-responsive" src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'ph_home')|escape:'html'}" alt="{$product.name|escape:'htmlall':'UTF-8'}" /></a>
<div class="desc">
<h3><a href="{$product.link|escape:'html'}" title="{l s='see product'} {$product.name|escape:'htmlall':'UTF-8'}">{$product.name|truncate:100:'...'|escape:'htmlall':'UTF-8'}</a></h3>
<p class="p_desc">
{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}
                                                </p>
{if (!$PS_CATALOG_MODE AND ((isset($product.show_price) && $product.show_price) || (isset($product.available_for_order) && $product.available_for_order)))}
{if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}
<span class="price">
{if !$priceDisplay}
{convertPrice price=$product.price}
{else}
{convertPrice price=$product.price_tax_exc}
{/if}
 
{hook h="displayProductPriceBlock" product=$product type="price"}
{hook h="displayProductPriceBlock" product=$product type="unit_price"}
 
{if isset($product.reduction) && $product.reduction && $theme_options['control_display_price_wo_reduction']}
{hook h="displayProductPriceBlock" product=$product type="old_price"}
<span class="price_without_reduction">
{convertPrice price=$product.price_without_reduction}
</span>
{/if}
</span>
{/if}
{/if}
 
<div class="displayProductDeliveryTime displayProductPriceBlock">
{hook h="displayProductDeliveryTime" product=$product}
{hook h="displayProductPriceBlock" product=$product type="weight"}
</div>
 
<div class="info">
<div class="buttons-wrapper">
{if $theme_options['control_display_add2cart']}
{if ($product.id_product_attribute == 0 || (isset($add_prod_display) && ($add_prod_display == 1))) && $product.available_for_order && !isset($restricted_country_mode) && $product.minimal_quantity <= 1 && $product.customizable != 2 && !$PS_CATALOG_MODE}
{if ($product.allow_oosp || $product.quantity > 0)}
{if isset($static_token)}
<a class="ajax_add_to_cart_button pull-left button yellow" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart',false, NULL, "add=1&id_product={$product.id_product|intval}&token={$static_token}", false)|escape:'html'}" title="{l s='Add to cart'}">{l s='Add to cart'}</a>
{else}
<a class="ajax_add_to_cart_button pull-left button yellow" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart',false, NULL, "add=1&id_product={$product.id_product|intval}", false)|escape:'html'}" title="{l s='Add to cart'}">{l s='Add to cart'}</a>
{/if}
{else}
 
{/if}
{/if}
{/if}
 
{if !$product.available_for_order || isset($restricted_country_mode) || $product.quantity < 1 && !$product.allow_oosp}
{if $theme_options['control_display_noavailable_text']}
<span class="noavailable_text">{$theme_options['control_noavailable_text']}</a></span>
{/if}
{/if}
 
{if $theme_options['control_display_view']}
<a href="{$product.link|escape:'html'}" title="{l s='View product'}" class="pull-right button">{l s='View product'}</a>
{/if}
</div>
{hook h='displayProductCommentsOnList' id_product=$product.id_product}
{hook h='displayProductListActionsButton' id_product=$product.id_product}
</div><!-- .info -->
</div><!-- .desc -->
<div class="link-col">
{if (!$PS_CATALOG_MODE AND ((isset($product.show_price) && $product.show_price) || (isset($product.available_for_order) && $product.available_for_order)))}
{if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}<span class="price">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span>{/if}
{/if}
{if $theme_options['control_display_add2cart']}
{if ($product.id_product_attribute == 0 || (isset($add_prod_display) && ($add_prod_display == 1))) && $product.available_for_order && !isset($restricted_country_mode) && $product.minimal_quantity <= 1 && $product.customizable != 2 && !$PS_CATALOG_MODE}
{if ($product.allow_oosp || $product.quantity > 0)}
{if isset($static_token)}
<a class="ajax_add_to_cart_button pull-left button yellow" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart',false, NULL, "add=1&id_product={$product.id_product|intval}&token={$static_token}", false)|escape:'html'}" title="{l s='Add to cart'}">{l s='Add to cart'}</a>
{else}
<a class="ajax_add_to_cart_button pull-left button yellow" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart',false, NULL, "add=1&id_product={$product.id_product|intval}", false)|escape:'html'}" title="{l s='Add to cart'}">{l s='Add to cart'}</a>
{/if}
{else}
{/if}
{/if}
{/if}
{if $theme_options['control_display_view']}
<a href="{$product.link|escape:'html'}" title="{l s='View product'}" class="pull-right button">{l s='View product'}</a>
{/if}
</div><!-- .link-col -->
</div>
</li>
{/foreach}
</ul>
<!-- /Products list -->
{/if}
 
Edited by lovemyseo (see edit history)
Link to comment
Share on other sites

Should I simply comment out Add to cart button from product listing.tpl?

And if I want to hide only for specific product listing then what I have to do PS version is 1.6.0.9?

As shown in above example

 

welcome to dev, back up back up back up...

 

then play, try a couple variations.

 

if you have specific products 'only' then you can code in .tpl file statement to 'not display' add to cart....

 

this is not highly technical programming that will give your some good experience. 

Link to comment
Share on other sites

welcome to dev, back up back up back up...

 

then play, try a couple variations.

 

if you have specific products 'only' then you can code in .tpl file statement to 'not display' add to cart....

 

this is not highly technical programming that will give your some good experience. 

Ok I got successfull hiding the add to cart on all categories ,

 

http://biophoretics.com/upgrade/187-polyethylene-glycols 

 

this is test shop with new theme , but for I have some specific categories only to hide just like biochemical A-Z

Link to comment
Share on other sites

I used to be SEO by profession and still are but since I have jioned this forum and had issues with developers I have decided to do Prestashop by myself no motr help needed with this forum has gurus like you (y) Thanks
Can you specify the text which will hide add to cart button on specific category?

Link to comment
Share on other sites

I used to be SEO by profession and still are but since I have jioned this forum and had issues with developers I have decided to do Prestashop by myself no motr help needed with this forum has gurus like you (y) Thanks

Can you specify the text which will hide add to cart button on specific category?

 

find 'id' of categories you want to hide (compare to), then study If statement...for multiples you should build array and do shorter code...but you are right, the more we do ourselves, the less we count on others.  It's beyonid my scope to supply untested code, plus my coffee buzz is wearing off.  jajajaja

 

make sure to visit the community to help others with your experience.

Link to comment
Share on other sites

find 'id' of categories you want to hide (compare to), then study If statement...for multiples you should build array and do shorter code...but you are right, the more we do ourselves, the less we count on others.  It's beyonid my scope to supply untested code, plus my coffee buzz is wearing off.  jajajaja

 

make sure to visit the community to help others with your experience.

Found a simpler solution for this 

 

You can do this from the backend of your PrestaShop. After you log in to the back office, click on the Preferences tab and then on the Products sub-tab. Find the option Display the "add to cart" button when a product has attributes and mark the No button. Then click on the Save button at the bottom of the page, and that's it. Now a product that has attributes can be added to the cart only from the product page, and not from the category page.

 

I just testd it it worked perfectly.

 

Thanks for your help

How can I hide add to cart button for specific product listing page just want to display view button .

issue resolved

Link to comment
Share on other sites

Found a simpler solution for this 

 

You can do this from the backend of your PrestaShop. After you log in to the back office, click on the Preferences tab and then on the Products sub-tab. Find the option Display the "add to cart" button when a product has attributes and mark the No button. Then click on the Save button at the bottom of the page, and that's it. Now a product that has attributes can be added to the cart only from the product page, and not from the category page.

 

I just testd it it worked perfectly.

 

Thanks for your help

issue resolved

 

gosh, yes, I knew about that one but then I can guess all day long..:)

 

awesome you found native way, that is best.  happy selling

Link to comment
Share on other sites

gosh, yes, I knew about that one but then I can guess all day long.. :)

 

awesome you found native way, that is best.  happy selling

One more question for you is this possible to build whole sale shop/private shop in prestashop, in shop on product details only whole sale dealers will order and they have to specific quanitity for each item, is it possible to get this done in prestashop?

Link to comment
Share on other sites

One more question for you is this possible to build whole sale shop/private shop in prestashop, in shop on product details only whole sale dealers will order and they have to specific quanitity for each item, is it possible to get this done in prestashop?

 

yes, very possible...

 

I personally recommend learning mulitshop and adding wholesale shop...this allows you more flexibility in managing content between retail/wholesale...though one can easily add wholesale to one shop using bo-->customers-->groups add wholesale group..then assign certain customers to this group...then use specific prices and/or other means by group to reflect their prices etc....my first module Authorized Only is an example of how you can extend ps for wholesale, there are others you can search for but I of course like mine best. :)

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...