Jump to content

Hide 'add To Cart' Button When Product Has Attributes


Recommended Posts

I'm having an issue with a Prestashop installation. The shop contains many products with attributes (so many possible combinations) so we decided to set the 'Display "add to cart" button when product has attributes' to 'No'.

 

However, it does not work on all pages. If I do a search and hit enter using the default search module, I get my search results and the 'Add to cart' button is not shown on products with attributes, so that's correct.

However, when I just browse to a category, the 'add to cart' button is always shown, regardless of whether the product has any attributes or not.

 

Both the search.tpl and category.tpl files use the product-list.tpl partial template, so this is a bit strange.

 

It seems that somehow the category controller is not assigning a property to the template (it has to do with $product.id_product_attribute).

 

Has anyone else encountered this problem or has anyone got any ideas on how to fix this?

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

I have posted on this forum 2x about the exact same issue with absolutely NO response. This is a huge issue in my opinion as customers can add to cart without choosing the attributes. Then when the wrong item is sent it creates a whole series of issues. This is no small issue but of course that means nothing. You are at the mercy of your own abilities with Prestashop!

 

Best of luck and if you figure it out - and vice versa - please be sure to share!

 

Thanks!

  • Like 1
Link to comment
Share on other sites

What? Log in as a customer and buy something? That is a fix? That is not even close to acceptable.

 

Thanks elpatron! As usual you are trying to be as helpful as possible. Prestashop could take a chapter from your pages on trying to help.

 

It would have been nice if the other thread had opened a bug report and if they did, then I could not find it. :)

 

I suggest always opening a bug report either on these types of obscure problems, or when one does not get a response (i.e. again obscure). The ps techies are pretty good about helping via bug reports, and understandably don't have time to participate in the community forum.

 

so lesson? if you can't google and find a resolution...open a bug report...then place the bug report link in your forum post...

 

Best of luck!

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

It would have been nice if the other thread had opened a bug report and if they did, then I could not find it. :)

 

I suggest always opening a bug report either on these types of obscure problems, or when one does not get a response (i.e. again obscure). The ps techies are pretty good about helping via bug reports, and understandably don't have time to participate in the community forum.

 

so lesson? if you can't google and find a resolution...open a bug report...then place the bug report link in your forum post...

 

Best of luck!

I'll try to remain as hopeful as possible, and will go about the course of action recommended...here is my bug report if anyone finds it helpful: PSCFV-8188

 

I disagree that PS is too busy to man the forums. Too busy to make sure your users are attended to, and/or customers satisfied, should never be a part of any businesses mentality. Yet PS just really doesn't seem to care. They need to assign a team that scours these messages and addresses them.

 

I appreciate you very much but having to rely on the input of other users is not a recipe for success...

 

I am never too busy for my customers and I bet you aren't either. Again, we'll see how PS comes through...

Edited by Online Office USA (see edit history)
  • Like 1
Link to comment
Share on other sites

There is a way to actually make this work for individual products. I discovered this quite accidentally. Here's what can be done:

 

1. Go to the shop back-end

2. Edit a product that has combinations but -erroneously- shows the 'Add to cart' button in the product list

3. Go to the 'Combinations' tab

4. Select another combination as the default one (you can switch back immediately)

5. Now the 'Add to cart' button has -correctly- disappeared.

 

Somehow I guess a property on the product row is changed to its correct value when you edit a product, which is not set correctly when you add a new product with combinations.

 

Later I will do some tests and try to find out what's happening in the database. The shop in this case has about 500 products with combinations, so we don't really want to go through and update them all manually. Hopefully an analysis of the database will yield a more permanent fix (changing all records using a SQL query) and might even pinpoint the source of the problem.

 

I'll keep you posted.

  • Like 2
Link to comment
Share on other sites

I've been struggling with this also but today seem to have found the answer. In back office go to '

Preferences separator_breadcrumb.png Products and at the bottom of the products page section there is a feature to turn it off .........

Display "add to cart" button when product has attributes

 

 

BINGO !!

Hope this helps......

Howard

  • Like 1
Link to comment
Share on other sites

I've been struggling with this also but today seem to have found the answer. In back office go to '

Preferences separator_breadcrumb.png Products and at the bottom of the products page section there is a feature to turn it off .........

Display "add to cart" button when product has attributes

 

 

 

BINGO !!

 

Hope this helps......

 

Howard

 

this topic is about, that this one isn't working.

same problem on 1.5.3.1

Link to comment
Share on other sites

The following change in the PS 1.5.3.1 default template file product-list.tpl fixes this problem for the category displays.

 

Line 57 change this:

{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}

 

to this:

{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 || $product.text_fields == 0) && !$PS_CATALOG_MODE}

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

  • 2 months later...

The following change in the PS 1.5.3.1 default template file product-list.tpl fixes this problem for the category displays.

 

Line 57 change this:

{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}

 

to this:

{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 || $product.text_fields == 0) && !$PS_CATALOG_MODE}

 

I made the change to themes/themeiamcurrentusingiswarehouse/product-list.tpl as desrcibed and Add to cart still shows if you browse products by category even though in the back office I have set do not display add to cart if product has attributes.

 

Please advise

Link to comment
Share on other sites

  • 3 weeks later...

There is a way to actually make this work for individual products. I discovered this quite accidentally. Here's what can be done:

 

1. Go to the shop back-end

2. Edit a product that has combinations but -erroneously- shows the 'Add to cart' button in the product list

3. Go to the 'Combinations' tab

4. Select another combination as the default one (you can switch back immediately)

5. Now the 'Add to cart' button has -correctly- disappeared.

 

Somehow I guess a property on the product row is changed to its correct value when you edit a product, which is not set correctly when you add a new product with combinations.

 

Later I will do some tests and try to find out what's happening in the database. The shop in this case has about 500 products with combinations, so we don't really want to go through and update them all manually. Hopefully an analysis of the database will yield a more permanent fix (changing all records using a SQL query) and might even pinpoint the source of the problem.

 

I'll keep you posted.

 

This works like a charm, thanks a lot! :)

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

My store is in catalogo mode. I've tried all the ways described in the topic but the button stubbornly continue to appear. Does not work, but appears. As the image below:

 

23v14hv.png

 

How to remove it? How to solve editing the theme?

My store is in catalogo mode. I've tried all the ways described in the topic but the button stubbornly continue to appear. Does not work, but appears. As the image below:

 

How to remove it? How to solve editing the theme?

Link to comment
Share on other sites

you can remove button from product.tpl template file located in your there directory (themes/YOUR_THEME)

 

I solved my problem (following his appointment, of course) by removing the following lines in product.tpl

 


{if (!$allow_oosp && $product->quantity <= 0) OR !$product->available_for_order OR (isset($restricted_country_mode) AND $restricted_country_mode) OR $PS_CATALOG_MODE}
<span class="exclusive">
 <span></span>
 {l s='Add to cart'}
			</span>
		{else}
			<p id="add_to_cart" class="buttons_bottom_block">
				<span></span>
				<input type="submit" name="Submit" value="{l s='Add to cart'}" class="exclusive" />
			</p>
		{/if}

 

 

The question is this action may cause some consequence at some future mechanism Site? Or not, since the files. Tpl are independent?

 

P. S

 

Apologies for my English literal - not mastered the language well.

Link to comment
Share on other sites

I solved my problem (following his appointment, of course) by removing the following lines in product.tpl

 


{if (!$allow_oosp && $product->quantity <= 0) OR !$product->available_for_order OR (isset($restricted_country_mode) AND $restricted_country_mode) OR $PS_CATALOG_MODE}
<span class="exclusive">
 <span></span>
 {l s='Add to cart'}
			</span>
		{else}
			<p id="add_to_cart" class="buttons_bottom_block">
				<span></span>
				<input type="submit" name="Submit" value="{l s='Add to cart'}" class="exclusive" />
			</p>
		{/if}

 

 

The question is this action may cause some consequence at some future mechanism Site? Or not, since the files. Tpl are independent?

 

P. S

 

Apologies for my English literal - not mastered the language well.

 

Because you now check if catalog mode, there should be no problem later if you decide to turn off catalog mode in your back office....you can turn off catalog mode to test that the add to cart button appears just to be sure

Link to comment
Share on other sites

  • 5 months later...

I don't know if this will help you, but I am posting my solution everywhere on these forums where I see people pulling their hair out for such a simple solution to a massive problem...

 

I MUST have my customers choosing product attributes before they click the "ADD TO CART" button.

Yes I know you can set in admin to hide the "ADD TO CART" button if there are product attributes, but when viewing product lists, non-attributed products will have an "ADD TO CART" button and attributed products will have nothing at all.

 

This is confusing as hell to clients and looks horribly messy. They will not know to click the product image to take them to the product screen, and will leave the store.

 

So what I did was - when viewing product lists, I swopped the "ADD TO CART" button for the "VIEW" button. The text and functionality work.

 

Running PS 1.5.6 I edited "product-list.tpl" on lines 49-52

 

Like so:

                                                          <a class="button exclusive view_button" href="{$product.link|escape:'htmlall':'UTF-8'}" title="{l s='View'}"><i class="icon-eye-2 icon-1x icon-mar-lr2"></i><span>{l s='View'}</span></a>
        						{*<a class="button ajax_add_to_cart_button exclusive" 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'}"><i class="icon-basket icon-1x icon-mar-lr2"></i><span>{l s='Add to Cart'}</span></a>*}
        					{else}
        						{*//<a class="button ajax_add_to_cart_button exclusive" 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'}"><i class="icon-basket icon-1x icon-mar-lr2"></i><span>{l s='Add to Cart'}</span></a>*}
Link to comment
Share on other sites

  • 2 months later...

 

I don't know if this will help you, but I am posting my solution everywhere on these forums where I see people pulling their hair out for such a simple solution to a massive problem...

 

I MUST have my customers choosing product attributes before they click the "ADD TO CART" button.

Yes I know you can set in admin to hide the "ADD TO CART" button if there are product attributes, but when viewing product lists, non-attributed products will have an "ADD TO CART" button and attributed products will have nothing at all.

 

This is confusing as hell to clients and looks horribly messy. They will not know to click the product image to take them to the product screen, and will leave the store.

 

So what I did was - when viewing product lists, I swopped the "ADD TO CART" button for the "VIEW" button. The text and functionality work.

 

Running PS 1.5.6 I edited "product-list.tpl" on lines 49-52

 

Like so:

                                                          <a class="button exclusive view_button" href="{$product.link|escape:'htmlall':'UTF-8'}" title="{l s='View'}"><i class="icon-eye-2 icon-1x icon-mar-lr2"></i><span>{l s='View'}</span></a>
        						{*<a class="button ajax_add_to_cart_button exclusive" 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'}"><i class="icon-basket icon-1x icon-mar-lr2"></i><span>{l s='Add to Cart'}</span></a>*}
        					{else}
        						{*//<a class="button ajax_add_to_cart_button exclusive" 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'}"><i class="icon-basket icon-1x icon-mar-lr2"></i><span>{l s='Add to Cart'}</span></a>*}

I was messing with this a bit today and am having a hell of a time. I'm using Leo's Shoe theme, and messed with this 'product-list.tpl' file. I've tried putting in your code in the place I think it should since the file is slightly different with 1.5.6.2.

 

Here is what looks like the relevant code, but no amount of modification has changed this.

{if ($product.id_product_attribute == 1 || (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="button btn ajax_add_to_cart_button exclusive" 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="button btn ajax_add_to_cart_button exclusive" 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}
							<span class="exclusive btn">{l s='Out of stock'}</span>
						{/if}
					{/if}

Even with this code commented out the Add to Cart option is still being dislayed on my Home page (with a Catalog Block).

 

MGbjWfm.png

Link to comment
Share on other sites

×
×
  • Create New...