Change Add To Cart Button Name For Out Of Stock Products

Hi guys,

i want to make Add To Cart button keep visible when my stock is 0 and change it text

is there any way for doing this?

Thanks

Settings -> General -> Allow negative amount in inventory

As for the label, it is required to change the following file:

design/themes/YOUR_THEME/templates/common/product_data.tpl

The following code

{include file="buttons/add_to_cart.tpl" but_id="button_cart_`$obj_prefix``$obj_id`" but_name="dispatch[checkout.add..`$obj_id`]" but_role=$but_role block_width=$block_width obj_id=$obj_id product=$product but_meta=$add_to_cart_meta}

should be replaced with

{if $product_amount <= 0}
{include file="buttons/add_to_cart.tpl" but_id="button_cart_`$obj_prefix``$obj_id`" but_name="dispatch[checkout.add..`$obj_id`]" but_role=$but_role block_width=$block_width obj_id=$obj_id product=$product but_meta=$add_to_cart_meta but_text=__('your_language_variable')}
{else}
{include file="buttons/add_to_cart.tpl" but_id="button_cart_`$obj_prefix``$obj_id`" but_name="dispatch[checkout.add..`$obj_id`]" but_role=$but_role block_width=$block_width obj_id=$obj_id product=$product but_meta=$add_to_cart_meta}
{/if}

Then add new language variable and clear cache

(!) Not tested

Hey man, I work fine, but how can be done, that

{if $product_amount <= 0} 

show special text, not "In stock"?

Thank you

Frank

Hey man, I work fine, but how can be done, that

{if $product_amount <= 0} 

show special text, not "In stock"?

Thank you

Frank

Frank, your question is not quite clear. Please clarify

Settings -> General -> Allow negative amount in inventory

As for the label, it is required to change the following file:

design/themes/YOUR_THEME/templates/common/product_data.tpl

The following code

{include file="buttons/add_to_cart.tpl" but_id="button_cart_`$obj_prefix``$obj_id`" but_name="dispatch[checkout.add..`$obj_id`]" but_role=$but_role block_width=$block_width obj_id=$obj_id product=$product but_meta=$add_to_cart_meta}

should be replaced with

{if $product_amount <= 0}
{include file="buttons/add_to_cart.tpl" but_id="button_cart_`$obj_prefix``$obj_id`" but_name="dispatch[checkout.add..`$obj_id`]" but_role=$but_role block_width=$block_width obj_id=$obj_id product=$product but_meta=$add_to_cart_meta but_text=__('your_language_variable')}
{else}
{include file="buttons/add_to_cart.tpl" but_id="button_cart_`$obj_prefix``$obj_id`" but_name="dispatch[checkout.add..`$obj_id`]" but_role=$but_role block_width=$block_width obj_id=$obj_id product=$product but_meta=$add_to_cart_meta}
{/if}

Then add new language variable and clear cache

(!) Not tested

Hi thanks for your reply,

i've test this and my button still not shown when my stock is 0

when i test using echo, my echo is stop shown after this condition

{capture name="buttons_product"}

how to fix this?

Frank, your question is not quite clear. Please clarify

Dear eComLabs

{if $product_amount <= 0}

if I use your code to show custom button as you advice in post#2 show that item is "In stock"

I want

{if $product_amount <= 0}

to show some other text, maybe "On request" or any other ....

Thank you for your very useful advices.

Frank

Dear eComLabs

{if $product_amount <= 0}

if I use your code to show custom button as you advice in post#2 show that item is "In stock"

I want

{if $product_amount <= 0}

to show some other text, maybe "On request" or any other ....

Thank you for your very useful advices.

Frank

In the product_data.tpl file find where the in_stock language variable is used and add new check to the code


Hi thanks for your reply,

i've test this and my button still not shown when my stock is 0

when i test using echo, my echo is stop shown after this condition

{capture name="buttons_product"}

how to fix this?

Did you check the corresponding setting at first? Please check first line of our post

In the product_data.tpl file find where the in_stock language variable is used and add new check to the code

Can you help me with the code, I didn't understand you.

Thank you in advance

Frank

Can you help me with the code, I didn't understand you.

Thank you in advance

Frank

For example, replace

{__("in_stock")}

with

{if $product_amount <= 0}{__("my_custom_lang_var")}{else}{__("in_stock")}{/if}

Then just add new language variable

For example, replace

{__("in_stock")}

with

{if $product_amount <= 0}{__("my_custom_lang_var")}{else}{__("in_stock")}{/if}

Then just add new language variable

Wauuuu, works fineeee!

Only great men can share their knowledge.

Thank you sooo much.

Frank

You are welcome! :)

Wauuuu, works fineeee!

Only great men can share their knowledge.

Thank you sooo much.

Frank

Hi EcomLabs

As I said works fine, but if I have active:

Show number of available products: in Settings/Appearance in doesnt show anything.

any help, please?

Frank

You can find the {__("in_stock")} code in several strings in the file. Try to replace it in all places

In the product_data.tpl file find where the in_stock language variable is used and add new check to the code


Did you check the corresponding setting at first? Please check first line of our post

Hi eComLabs,

after i show this to my team, they said that we only need show "Add to Cart" for 0 stock (which in this case, it will become like pre order) for some product

i've been thinking for make a product category for product that will be able to pre order

is this possible do it like this?

Thanks

For only 0 in stock you can use the {if $product_amount == 0} condition. I do not think that you need to create separate category for these products

For only 0 in stock you can use the {if $product_amount == 0} condition. I do not think that you need to create separate category for these products

well i don't want to all of my product can have "Pre Order", and just some product

that's why i think i will make a category for product that can pre order, so if product is belong on this category, even if my stock is below 0, my "Add To Cart" button will be shown up as "Pre Order" and for product that's not in this category, i will not show "Add To Cart" button

Thank you clarification. The product category can be checked with the following code:

{if $product.main_category == 123}
    ....
{/if}

where 123 - is the ID of the required category

Thank you clarification. The product category can be checked with the following code:

{if $product.main_category == 123}
    ....
{/if}

where 123 - is the ID of the required category

Hi eComLabs,

i've tried that and it work, thanks

can i ask where is qty picker too?

because i've tried to looking around product.tpl but i'm not found it

EvnLNUk.png

because i think for product that can't pre order this picker is useless, so i want to hide it

Thanks

Search in the same file by "qty"

Search in the same file by "qty"

Thanks, i found it :)