Remove Add to cart button from product listings

Open to all! Ask other shopowners for help.
bestmate
Member
Posts: 27
Joined: Wed Mar 08, 2023 1:23 am
Phoenix Version:
Has thanked: 22 times
Been thanked: 4 times

Remove Add to cart button from product listings

Post by bestmate »

Hi, please can you guide me on how to remove the add to cart button from product listings pages(s) except on the product_info.php page? Also, how do I extend the view button to fill space after removing the add to cart part?
Phoenix.jpg
Thanks for assistance.
You do not have the required permissions to view the files attached to this post.


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 »

You could use css:
display: none;

I don't remember the exact classes, but something like:

Code: Select all

.is-product.btn-buy {
  display: none;
}
might be close enough?

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Remove Add to cart button from product listings

Post by burt »

Depending on Phoenix version, you could be looking to take this file;

/templates/default/includes/components/product_card.php

And place a COPY of it into whatever template you are using. Eg if using the override template, it would go into;

/templates/override/includes/components/product_card.php

Now you can change that new file to suit your needs.
I am not here to build for you.
I am here to build with you. Let's help each other.
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 »

bestmate wrote: Sun Jul 02, 2023 5:24 pm how to remove the add to cart button from product listings pages(s) except on the product_info.php page?
As in previous answer, this is a good case for using a template so make a copy as described in that answer.
Edit the copied file.
It is good to 'comment out' code instead of deleting it so comment out the code that displays the Buy Button.
The code for that is Lines 17-24 inclusive. (All references to line numbers are in an unchanged file).
It is PHP code so to comment out, add /* before Line 17 and add */ after Line 24.
Save the changes and the Buy Button disappears.
bestmate wrote: Sun Jul 02, 2023 5:24 pmhow do I extend the view button to fill space after removing the add to cart part?
With the Buy Button gone, there is now a div element that is not required, that is the btn-group on Line 13 (remember referring to line numbers in an unchanged file).
To make the View Button full width, that needs to go, so comment that out.
It is HTML code so to comment out the opening of the div, add <!-- before Line 13 and add --> after Line 13.
The closing of the div on Line 26 must also be commented out so add <!-- before Line 26 and add --> after Line 26.
With that div now gone, the View Button can be made full width.
The code for the that button is on Line 15.
Add w-100 to the button class, so after btn-view, add a space and then w-100.
Save the changes and you will now see this:
Screenshot 2023-07-03 062357.png
If this has helped develop your store, buy me a beverage.
If you are unable to DIY, we can do it for you.
You do not have the required permissions to view the files attached to this post.
14Steve14
Senior Contributor
Posts: 922
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Has thanked: 17 times
Been thanked: 103 times

Re: Remove Add to cart button from product listings

Post by 14Steve14 »

We removed the BUY button from our site. We wanted people to actually click on the product to be sent to the product info page so they can read the product description, which is quite detailed. It has stopped people buying the wrong items, which is good.

We also centred all the text which just made everything look better.
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 with this. I carefully followed the instructions by @burt to copy the product_card as follows:

from here /templates/default/includes/components/product_card.php

to here /templates/override/includes/components/product_card.php

And made the changes suggested by @heatherbell

I saved my file, cleared my cache and reloaded my page but there is not change to the button

Here's what I have in my file now:

Code: Select all

<a href="<?= $product->get('link') ?>"><?= tep_image('images/' . $product->get('image'), htmlspecialchars($product->get('seo_title')), '', '', '', true, 'card-img-top') ?></a>
  <div class="card-body">
    <h5 class="card-title"><a href="<?= $product->get('link') ?>"><?= $product->get('name') ?></a></h5>
    <h6 class="card-subtitle mb-2 text-muted"><?= $product->hype_price() ?></h6>
    <?= $card['extra'] ?? '' ?>
  </div>

<?php
  if ($card['show_buttons'] ?? false) {
?>

  <div class="card-footer bg-white pt-0 border-0">
<!--    <div class="btn-group" role="group"> -->
      <?php
    echo tep_draw_button(IS_PRODUCT_BUTTON_VIEW, '', $product->get('link'), null, null, 'btn-info btn-product-listing btn-view w-100');

/**    
if (!$product->get('has_attributes')) {
      echo PHP_EOL, tep_draw_button(
        IS_PRODUCT_BUTTON_BUY,
        '',
        tep_href_link(basename($GLOBALS['PHP_SELF']), tep_get_all_get_params(['action', 'products_id']) . 'action=buy_now&products_id=' . (int)$product->get('id')),
        null,
        ['params' => 'data-has-attributes="0" data-in-stock="' . (int)$product->get('in_stock') . '" data-product-id="' . (int)$product->get('id') . '"'],
        'btn-light btn-product-listing btn-buy');
    }
**/
?>
<!--    </div> -->
  </div>

<?php
  }
?>
What might I be doing wrong?

Thanks
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 »

bestmate wrote: Mon Jul 03, 2023 4:56 pm

Code: Select all

/**    
**/
What might I be doing wrong?
Not double checking your work!
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 »

heatherbell wrote: Mon Jul 03, 2023 5:22 pm
bestmate wrote: Mon Jul 03, 2023 4:56 pm

Code: Select all

/**    
**/
What might I be doing wrong?
Not double checking your work!
@heatherbell

My apologies, please bear with me. I am a bit of a newbie and can't see what I've missed as I have changed the lines you quoted to
/*
*/

And there's no change to the button.
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 »

bestmate wrote: Mon Jul 03, 2023 5:28 pm And there's no change to the button.
Have you the correct template selected in Configuration>My Store
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 »

@heatherbell

Yes, I do
template.jpg
You do not have the required permissions to view the files attached to this post.


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