Jump to content

[Solved] Display "download now" on products that have 0 price


Recommended Posts

3 hours ago, hdhazard said:

Thx but i need add only some codes to to product.tpl to solve this :

i add this to the product button :


{if $product->price <= 0}{l s='download now'}{/if}

but text button changed to this :

download now Add to cart

 

@hdhazard

Not sure if that is behavior you want. even if you just change text it would behave like add to cart button, no ?

But if you are making changes  use else statement

{if $product->price <= 0}
    {l s='Download now'}
{else}
    {l s='Add to cart' d='Shop.Theme.Actions'}
{/if}

 

  • Thanks 1
Link to comment
Share on other sites

 

not worked

for both free product and non-free product  , button changed to : Download now

here is code that i used :

        <div class="add">
          <button
            class="btn btn-primary add-to-cart"
            data-button-action="add-to-cart"
            type="submit"
            {if !$product.add_to_cart_url}
              disabled
            {/if}
          >
            <i class="material-icons shopping-cart">&#xE547;</i>
			
			{if $product->price <= 0}
			{l s='Download now'}
			{else}
			{l s='Add to cart' d='Shop.Theme.Actions'}
			{/if}
			
			</button>
        </div>

 

Link to comment
Share on other sites

Yeah that code was untested, sorry about that.

Try this

        <div class="add">
          <button
            class="btn btn-primary add-to-cart"
            data-button-action="add-to-cart"
            type="submit"
            {if !$product.add_to_cart_url}
              disabled
            {/if}
          >
            <i class="material-icons shopping-cart">&#xE547;</i>
            {if $product.price_amount <= 0}
              {l s='Download now'}
            {else}
              {l s='Add to cart' d='Shop.Theme.Actions'}
            {/if}
          </button>
        </div>

 

  • Thanks 1
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...