Remove Add to cart button from product listings

Open to all! Ask other shopowners for help.
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: Remove Add to cart button from product listings

Post by heatherbell »

Cannot immediately see why it does not work for you.
Can only suggest you start again, checking that the changes work in your shop after each step.


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Remove Add to cart button from product listings

Post by Kofod95 »

Your version and any changes you may have in that area might influence the outcome.
In general: viewtopic.php?f=10&t=27
Following those guidelines makes it easier for others to help :)

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
bestmate
Member
Posts: 27
Joined: Wed Mar 08, 2023 1:23 am
Phoenix Version:
Has thanked: 22 times
Been thanked: 4 times

Re: Remove Add to cart button from product listings

Post by bestmate »

My version is CE-Phoenix-1.0.7.18 and I'd not many any changes relating to this other than follow instructions above. Unfortunately, this did not work so I reversed changes. I then searched for <div class="btn-group" role="group"> to locate every possible instance of that button I needed to remove as instructed.

I found 25 instances of <div class="btn-group" role="group"> in the phoenix code, two of which did not need any change. I made changes as instructed by others above and finally got the results I wanted.
beerbee
Member
Posts: 48
Joined: Mon Oct 26, 2020 4:56 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 5 times

Re: Remove Add to cart button from product listings

Post by beerbee »

Hi, as far as I understand the products_card.php is used by the boxes and not for the product listing which was in question.

So i would guess components/product_listing.php would be the right file to edit. Maybe commenting out like this:

Code: Select all

 //if ($has_attributes == 0) $prod_list_contents .= tep_draw_button(IS_PRODUCT_BUTTON_BUY, '', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . (int)$listing['products_id']), NULL, array('params' => 'data-has-attributes="' . $has_attributes . '" data-in-stock="' . (int)$listing['in_stock'] . '" data-product-id="' . (int)$listing['products_id'] . '"'), 'btn-light btn-product-listing btn-buy') . PHP_EOL;
Kind regards
Christoph
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Remove Add to cart button from product listings

Post by Kofod95 »

bestmate wrote: Tue Jul 04, 2023 12:36 pm My version is CE-Phoenix-1.0.7.18 [...]
beerbee wrote: Tue Jul 04, 2023 1:49 pm Hi, as far as I understand the products_card.php is used by the boxes and not for the product listing which was in question.
Since 1.0.8.4 (I think) the cards in the listings are controlled by the product_card.php. So in this case, that is why it didn't work, while it will work on newer versions.

I'm glad you got what you wanted, that is what matters most. I hope you were able to do it with new files, which will make updating a lot easier, compared to altering the core. If you did change core and would like to get help in achieving the result with new files instead, feel free to ask ;)

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
bestmate
Member
Posts: 27
Joined: Wed Mar 08, 2023 1:23 am
Phoenix Version:
Has thanked: 22 times
Been thanked: 4 times

Re: Remove Add to cart button from product listings

Post by bestmate »

Thank you all for your help and guidance with this.

I don't know much but I'm always ready to learn and ask for help to get the knowledge I need so I can do things myself whenever possible.
nehakakar
Posts: 3
Joined: Tue Jul 04, 2023 12:40 pm
Phoenix Version:
Has thanked: 1 time

Re: Remove Add to cart button from product listings

Post by nehakakar »

beerbee wrote: Tue Jul 04, 2023 1:49 pm Hi, as far as I understand the products_card.php is used by the boxes and not for the product listing which was in question.

So i would guess components/product_listing.php would be the right file to edit. Maybe commenting out like this:

Code: Select all

 //if ($has_attributes == 0) $prod_list_contents .= tep_draw_button(IS_PRODUCT_BUTTON_BUY, '', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . (int)$listing['products_id']), NULL, array('params' => 'data-has-attributes="' . $has_attributes . '" data-in-stock="' . (int)$listing['in_stock'] . '" data-product-id="' . (int)$listing['products_id'] . '"'), 'btn-light btn-product-listing btn-buy') . PHP_EOL;
Kind regards
Christoph

The suggestion provided seems to be aimed at removing the "Add to Cart" button from the product listings. The code snippet you shared is an example of how you can comment out the code responsible for displaying the button in the components/product_listing.php file.

To implement this change, locate the components/product_listing.php file in your shop's file structure. Inside that file, find the section of code that generates the "Add to Cart" button. It may resemble the code snippet you provided.

To remove the button, you can comment out that section of code by adding // at the beginning of the line or by wrapping the code with /* at the start and */ at the end.

Code: Select all

// if ($has_attributes == 0) $prod_list_contents .= tep_draw_button(IS_PRODUCT_BUTTON_BUY, '', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . (int)$listing['products_id']), NULL, array('params' => 'data-has-attributes="' . $has_attributes . '" data-in-stock="' . (int)$listing['in_stock'] . '" data-product-id="' . (int)$listing['products_id'] . '"'), 'btn-light btn-product-listing btn-buy') . PHP_EOL;
ave the file and test your shop to see if the "Add to Cart" button is no longer displayed in the product listings.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply