Jump to content

Remove buy now button when price is 0


Recommended Posts

Hi all

Can anyone help me with removing the buy now button for products when the price is = 0 or if there is another way to do this that would be great.
This is for products that I do not sell directly and offer a link to an outside source.

I am using version 1.3.1.1 maybe this is already something offered in the latest version?

Thank you
Xtaz

Link to comment
Share on other sites

Yes that is a great idea.

Could you help me with the coding to do the following:

Where location is the destination URL
and EAN13 is the image name to replace the buy now button.
The price should still be displayed.

if location is not empty then replace the buy now button with:


Thank you in advance for your time and reply

Link to comment
Share on other sites

Trying changing line 319 of product.tpl (in PrestaShop v1.3.2) from:


quantity == 0} style="display:none;"{/if} id="add_to_cart" class="buttons_bottom_block"><input type="submit" name="Submit" value="{l s='Add to cart'}" class="exclusive" /></p>



to:


quantity == 0} style="display:none;"{/if} id="add_to_cart" class="buttons_bottom_block">
  {if $product->location}
     <a href="{$product->location}" target="_blank"><img src="{$product->ean13}.png" alt="">
  {else}
     <input type="submit" name="Submit" value="{l s='Add to cart'}" class="exclusive" />
  {/if}

Link to comment
Share on other sites

Thank you!

I actually did not realize my suggestion was incomplete.

Would it be possible to do the same:
Use 'Location' for the URL
and 'Supplier Reference' for the text that will display on the same button type as the add to cart button
(EAN13 doesn't accept spaces)

So I would have the same button as add to cart but the text would simply be the one put in the supplier reference field.
And this again would only apply when location is not empty.

Sorry for all the trouble, you are helping me a lot with this and many others as well I am sure.

Link to comment
Share on other sites

Try:


quantity == 0} style="display:none;"{/if} id="add_to_cart" class="buttons_bottom_block">
  {if $product->location}
     <a href="{$product->location}" target="_blank"><img src="{$product->ean13}.png" alt="">
  {else}
     <input type="submit" name="Submit" value="{$product->supplier_reference}" class="exclusive" />
  {/if}

Link to comment
Share on other sites

So I tweaked it a little but get a blank page so I must have added something wrong, what do you think?
My code was a little different than yours, I just updated to Version 1.3.2.3.

By the way thank you very much for your help with this.


quantity > $last_qties || $product->quantity == 0) || $allow_oosp} style="display:none;"{/if} >{l s='Warning: Last items in stock!'}
quantity == 0} style="display:none;"{/if} id="add_to_cart" class="buttons_bottom_block">
{if $product->location}
<input type="button" name="Submit" value="{$product->supplier_reference}" class="exclusive" onClick="document.location = '{$product->location}'" />
  {else}
        <input type="submit" name="Submit" value="{l s='Add to cart'}" class="exclusive" />
           {/if}

Link to comment
Share on other sites

Hi rocky

Sorry but I am still having issues with this code. I have tried a few things but it always ends up with a blank page...

Here is a recap of what I am hoping to do:

If location is empty then display existing button saying "Add to cart" (existing setup)

If location is not empty the display existing button saying {Reference_Supplier} and make the button go to the url added into {location}

I took out the part of adding a different image for the button and find it easier to use the existing one.

This is my current code:


quantity > $last_qties || $product->quantity == 0) || $allow_oosp} style="display:none;"{/if} >{l s='Warning: Last items in stock!'}
quantity == 0} style="display:none;"{/if} id="add_to_cart" class="buttons_bottom_block">
<input type="submit" name="Submit" value="{l s='Add to cart'}" class="exclusive" /></p>



Thank you again for your time and help

Link to comment
Share on other sites

I've had another look at the code and this time, I've tested it. Try using the following:


quantity == 0} style="display:none;"{/if} id="add_to_cart" class="buttons_bottom_block">
  {if $product->location}
     <a href="{$product->location}" class="exclusive" target="_blank"><img src="{$img_dir}{$product->ean13}.png" alt="">{$product->supplier_reference}
  {else}
     <input type="submit" name="Submit" value="{l s='Add to cart'}" class="exclusive" />
  {/if}

Link to comment
Share on other sites

Hi rocky

I created the images in the theme img dir.
When I apply your code to product.tpl I loose then entire product display

here is the code :


quantity > $last_qties || $product->quantity == 0) || $allow_oosp} style="display:none;"{/if} >{l s='Warning: Last items in stock!'}


quantity == 0} style="display:none;"{/if} id="add_to_cart" class="buttons_bottom_block">
  {if $product->location}
location}" class="exclusive" target="_blank">ean13}.png" alt="">{$product->supplier_reference}
  {else}
     <input type="submit" name="Submit" value="{l s='Add to cart'}" class="exclusive" />
  {/if}
 




see screenshot attached:
The first is with the new code - the second is what the normal display looks like


Thank you again for your time and help with this.

31701_OgUEDrJlsc0refVw5nLc_t

31702_lA71CqaLAVCWErqOoSU4_t

Link to comment
Share on other sites

It works!!
There is only one thing that is a little off. The text is not displayed on the actual button but bellow it.
I added a screen clip for you to see what I mean.

Any idea how to get the text to show on the button?

Thank you again for all the time you spent on this.

31878_lpPzAGOoFrrNmEgXCaVS_t

Link to comment
Share on other sites

It worked!!
You are the man! Thank you!

Last and final question, would I just apply the same code to the product-list.tpl to have the same thing work on that page?

Or

How can I simply not display the add to cart button if location is not empty.
This would only display the view button.

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