Jump to content

Changing Last items in stock to Available items


Recommended Posts

Hi to all,

I wanted to change the default message  "Last items in stock" to information about how many items are left in stock, so first I changed the message in Translations in Admin from "Last items in stock" to "Available items: ", and then in product-add-to-cart.tpl I changed this bit:

    {block name='product_availability'}
      <span id="product-availability">
        {if $product.show_availability && $product.availability_message}
          {if $product.availability == 'available'}
            <i class="material-icons rtl-no-flip product-available">&#xE5CA;</i>
          {elseif $product.availability == 'last_remaining_items'}
            <i class="material-icons product-last-items">&#xE002;</i>
          {else}
            <i class="material-icons product-unavailable">&#xE14B;</i>
          {/if}
          {$product.availability_message}
        {/if}
      </span>
    {/block}

... to this - removed <i class="material-icons product-last-items">&#xE002;</i>, as it did not fit, and then added {$product->quantity}:

    {block name='product_availability'}
      <span id="product-availability">
        {if $product.show_availability && $product.availability_message}
          {if $product.availability == 'available'}
            <i class="material-icons rtl-no-flip product-available">&#xE5CA;</i>
          {elseif $product.availability == 'last_remaining_items'} {$product->quantity}
          {else}
            <i class="material-icons product-unavailable">&#xE14B;</i>
          {/if}
          {$product.availability_message}
        {/if}
      </span>
    {/block}

I have no idea why on the page I see "1 Available items:" instead of "Available items: 1" - the number is in front of the message, not behind.

Where is the problem? How should I fix it?

I would appreciate any tips.

Adam

Share this post


Link to post
Share on other sites

Hi jetway,

This is the rest of this particular .tpl file (product-add-to-cart.tpl):

    {hook h='displayTtWishlistButton' product=$product}
    {block name='product_minimal_quantity'}
      <p class="product-minimal-quantity">
        {if $product.minimal_quantity > 1}
          {l
          s='The minimum purchase order quantity for the product is %quantity%.'
          d='Shop.Theme.Checkout'
          sprintf=['%quantity%' => $product.minimal_quantity]
          }
        {/if}
      </p>
    {/block}

I am not sure what should I change in this last bit, so the output is "Available items: 1" (not reversed to "1 Available items:"). Can you help me and suggest what to do?

Share this post


Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More