Post by outdoorsiness » Thu Jul 16, 2020 8:02 am

How do I go about removing the Availability: In stock on the product page? I have linked my themes product.twig. I think the script that needs edited is below, but I wasn't sure if just removing would affect other functionality as I was having issues with my google merchant feed and page design after I deleted it. Any suggestions?


<div class="description">
....
<span><?php echo $text_stock; ?></span> <?php echo $stock; ?> -->
<br/><br/>

https://drive.google.com/file/d/1AenEyr ... sp=sharing

New member

Posts

Joined
Wed Jan 30, 2019 3:45 am

Post by paulfeakins » Thu Jul 16, 2020 4:39 pm

bassinmatt wrote:
Thu Jul 16, 2020 8:02 am
I was having issues with my google merchant feed and page design after I deleted it.
Probably unrelated.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by outdoorsiness » Sun Aug 09, 2020 11:09 pm

Anyone have any insight on this? Still trying to remove the Availability: in stock. Can someone please assist with which line to remove?

Thank you.

New member

Posts

Joined
Wed Jan 30, 2019 3:45 am

Post by JNeuhoff » Sun Aug 09, 2020 11:58 pm

You are not giving us enough details. I assume you are using OpenCart 2.3.0.2, and your own web theme in which case you could just edit your

catalog/view/theme/your-theme/template/product/product.tpl

as follows:

Code: Select all

...
<!--<span><?php echo $text_stock; ?></span> <?php echo $stock; ?> -->
...

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by patjuh » Tue Aug 11, 2020 12:08 am

its a twig file so the answer above doesnt work, what you could do is

select this part of the code (original file)

Code: Select all

<li>{{ text_stock }} {{ stock }}</li>
or your code

Code: Select all

 <span><?php echo $text_stock; ?></span> <?php echo $stock; ?>
and replace it with

Code: Select all

{% if stock <= 1 %}
			<li> </li>
			{% else  %}
             <li>{{ text_stock }} {{ stock }}</li>
			 {% endif %}
when the product isnt in stock the line ''Availability: Out Of Stock" will be shown

dont forget in your admin panel to at dashboard to refresh the theme and sass
its that blue 'gear' symbol right corner otherwise your new twig wont be loaded

hope this helps :)

...edit just downloaded your twig, what theme are you having
why use php code in a twig file when all the data is in your controller, not the best way to practice coding
Last edited by patjuh on Tue Aug 11, 2020 6:36 am, edited 3 times in total.

New member

Posts

Joined
Sat Feb 11, 2017 7:22 pm

Post by JNeuhoff » Tue Aug 11, 2020 12:25 am

I think the OP uses a OpenCart 2.x release, with *.tpl instead of *.twig files.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by patjuh » Tue Aug 11, 2020 12:28 am

JNeuhoff wrote:
Tue Aug 11, 2020 12:25 am
I think the OP uses a OpenCart 2.x release, with *.tpl instead of *.twig files.
when you download the file you see twig file extension and even the use of twig language

New member

Posts

Joined
Sat Feb 11, 2017 7:22 pm

Post by JNeuhoff » Tue Aug 11, 2020 12:50 am

Well, I see. In that case, he shouldn't use PHP in his template file.

So, instead of

Code: Select all

   <span><?php echo $text_stock; ?></span> <?php echo $stock; ?>  -->
  <br/><br/>
  <!-- Start Additional Info -->
  <?php if ($attribute_groups) { ?>
    <?php foreach ($attribute_groups as $attribute_group) { ?>
      <?php if ($attribute_group['name'] == 'Product Specifications') { ?>
        <?php foreach ($attribute_group['attribute'] as $attribute) { ?>
          <span><?php echo $attribute['name']; ?></span> <?php echo html_entity_decode($attribute['text']); ?><br />
        <?php } ?>
      <?php } ?>
    <?php } ?>
  <?php } ?>
it should be something like this:

Code: Select all

  <!-- <span>{{ text_stock }}</span> {{ stock }}  -->
  <br/><br/>
  <!-- Start Additional Info -->
  {% if (attribute_groups) %}
    {% for attribute_group in attribute_groups %}
      {% if (attribute_group['name'] == 'Product Specifications') %}
        {% for attribute in attribute_group['attribute'] %}
          <span>{{ attribute['name'] }}</span> {{ attribute['text']|html_entity_decode }}<br />
        {% endfor %}
      {% endif %}
    {% endfor %}
  {% endif %}
This assumes the usage of a html_entity_decode plugin filter for twig.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by outdoorsiness » Fri Aug 14, 2020 3:12 am

JNeuhoff wrote:
Tue Aug 11, 2020 12:25 am
I think the OP uses a OpenCart 2.x release, with *.tpl instead of *.twig files.
Im sorry...Im using 3.0.3.2

New member

Posts

Joined
Wed Jan 30, 2019 3:45 am

Post by outdoorsiness » Fri Aug 14, 2020 3:14 am

patjuh wrote:
Tue Aug 11, 2020 12:08 am
its a twig file so the answer above doesnt work, what you could do is

select this part of the code (original file)

Code: Select all

<li>{{ text_stock }} {{ stock }}</li>
or your code

Code: Select all

 <span><?php echo $text_stock; ?></span> <?php echo $stock; ?>
and replace it with

Code: Select all

{% if stock <= 1 %}
			<li> </li>
			{% else  %}
             <li>{{ text_stock }} {{ stock }}</li>
			 {% endif %}
when the product isnt in stock the line ''Availability: Out Of Stock" will be shown

dont forget in your admin panel to at dashboard to refresh the theme and sass
its that blue 'gear' symbol right corner otherwise your new twig wont be loaded

hope this helps :)

...edit just downloaded your twig, what theme are you having
why use php code in a twig file when all the data is in your controller, not the best way to practice coding

Im using Maxshop and running 3.0.3.2. I still cant get it to go away even with the above. I do appreciate your assistance though.

New member

Posts

Joined
Wed Jan 30, 2019 3:45 am

Post by by mona » Fri Aug 14, 2020 7:09 am

Well something is not right with this post

You post

Code: Select all

<span><?php echo $text_stock; ?></span> <?php echo $stock; ?> -->
so I will have to assume that is copied and pasted - but that does not mean you copied and pasted from the correct file

The odd thing here is you also have a trailing --> where is the <!-- ?

comment out is <!-- what you want to comment out -->

You want to remove
Availability: In stock

That would be done simply by

Code: Select all

<!-- <span><?php echo $text_stock; ?></span> <?php echo $stock; ?> -->
or in OC3 it would look like this

Code: Select all

<span><{{ text_stock }}</span> {{ $stock }}
and would be changed to

Code: Select all

{# <span><{{ text_stock }}</span> {{ $stock }} #}
and having just done a quick test
both

Code: Select all

<!-- <?php echo $text_stock; ?></span> <?php echo $stock; ?> -->
and

Code: Select all

{#  <?php echo $text_stock; ?></span> <?php echo $stock; ?> #} 
will remove the text

The file you have to change is
in OC2
catalog/view/theme/YOUR THEME i.e. MAXSHOP/template/product/product.tpl
or in OC3
catalog/view/theme/YOUR THEME i.e. MAXSHOP/template/product/product.twig

You then go into your MODIFICATIONS and refresh using the top blue button
and also in DASHBOARD top right cog.

If you still can not get this to work
1. Post a screenshot of your admin ensuring the OC version listed at the bottom can be seen.

and I am completely lost as to why the Availability: Out of stock has come into this ?

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am
Who is online

Users browsing this forum: Baidu [Spider] and 219 guests