Post by Karen » Sun Jun 13, 2010 12:39 pm

It just looks strange to me to have an add to cart button for something that is clearly listed as not in stock.

Can someone give me the code mods to make to hide it when an item is not in stock? Am using 1.4.8.

Thanks!

User avatar
Active Member

Posts

Joined
Thu Jun 10, 2010 2:51 pm
Location - WA State, USA

Post by Karen » Thu Jun 17, 2010 6:34 pm

I found this info, which is similar:

http://forum.opencart.com/viewtopic.php ... 3633#p3645

But it's from an older version.

Can anyone help me update it for 1.4.8, with the variable being number in stock = 0 rather than price being $0.0?

Using OC version 1.4.8b
http://catandcaboodle.com/


User avatar
Active Member

Posts

Joined
Thu Jun 10, 2010 2:51 pm
Location - WA State, USA

Post by icareless » Wed Jun 30, 2010 1:00 pm

I'd like to know too.

Newbie

Posts

Joined
Thu Jan 14, 2010 4:00 pm

Post by i2Paq » Wed Jun 30, 2010 2:28 pm

There is a recent topic about this question + a solution here on these forums. I suggest you use the search.

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by Karen » Wed Jun 30, 2010 2:40 pm

Hi Norman,

As I always do, I did do a search for this before I posted it. Care to give us a link? We would certainly appreciate it.

Using OC version 1.4.8b
http://catandcaboodle.com/


User avatar
Active Member

Posts

Joined
Thu Jun 10, 2010 2:51 pm
Location - WA State, USA

Post by JAY6390 » Wed Jun 30, 2010 7:05 pm

Have to say I couldn't find this myself, but here's how I would do it
find this in your product.tpl file

Code: Select all

              <div class="content">
                <?php echo $text_qty; ?>
                <input type="text" name="quantity" size="3" value="<?php echo $minimum; ?>" />
                <a onclick="$('#product').submit();" id="add_to_cart" class="button"><span><?php echo $button_add_to_cart; ?></span></a>                
                <?php if ($minimum > 1) { ?><br/><small><?php echo $text_minimum; ?></small><?php } ?>
              </div>
and change it to this (the first and last lines are the only additions)

Code: Select all

              <?php if($stock == $this->language->get('text_instock') || $stock > 0): ?>
              <div class="content">
                <?php echo $text_qty; ?>
                <input type="text" name="quantity" size="3" value="<?php echo $minimum; ?>" />
                <a onclick="$('#product').submit();" id="add_to_cart" class="button"><span><?php echo $button_add_to_cart; ?></span></a>                
                <?php if ($minimum > 1) { ?><br/><small><?php echo $text_minimum; ?></small><?php } ?>
              </div>
              <?php endif; ?>
That should do it

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by i2Paq » Wed Jun 30, 2010 7:26 pm

Karen wrote:Hi Norman,

As I always do, I did do a search for this before I posted it. Care to give us a link? We would certainly appreciate it.
My bad.

The topic was hiding under a differend name: [MOD] Out of stock status change automatic?

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by JasonSGN » Wed Jun 30, 2010 8:01 pm

Thanks Jay. Simple and works perfectly!!!

New member

Posts

Joined
Fri Jan 01, 2010 12:15 am

Post by JAY6390 » Wed Jun 30, 2010 8:05 pm

No problem :)

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by FFJim » Thu Jul 29, 2010 11:11 am

Works great, but what about all the places where the item is listed with the [+] icon, such as Bestsellers, Featured, Search results, Category listings, etc.? Do each of these require separate edits or is there a function somewhere that can be edited?
Last edited by FFJim on Mon Sep 13, 2010 1:42 am, edited 1 time in total.

User avatar
New member

Posts

Joined
Wed Jul 21, 2010 6:44 am

Post by JAY6390 » Thu Jul 29, 2010 4:10 pm

separate edits required

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by YEWEI123SG » Thu Sep 02, 2010 2:48 pm

Where can i find "product.tpl" ?

Is it equivalent to "product.php" ?

I am using opencart_v1.4.9 version.

Newbie

Posts

Joined
Tue Aug 31, 2010 7:15 am

Post by Qphoria » Thu Sep 02, 2010 9:46 pm

YEWEI123SG wrote:Where can i find "product.tpl" ?

Is it equivalent to "product.php" ?
YES! They are exactly the same, that is why we included both for fun ;)
This should help
http://forum.opencart.com/viewtopic.php?f=20&t=4113

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by dyl4n3 » Sun Sep 12, 2010 11:33 pm

how do you remove the [+] icon next to out of stock items?

Newbie

Posts

Joined
Sat Sep 11, 2010 2:13 pm

Post by EricP » Sun Nov 07, 2010 9:15 am

I also need to know how to remove the Add to Cart button [+] for items in the category, specials, etc. due to the contract with the vendor, stating that the item can be on the site but cannot be put into a shopping cart. I have the button hidden on the item page, but I still need to remove it within the listing templates based on stock status. When I try to check the $stock variable it doesn't exist at that level.

Newbie

Posts

Joined
Tue Oct 19, 2010 9:34 am

Post by i2Paq » Fri Nov 12, 2010 2:17 am

JAY6390 wrote:Have to say I couldn't find this myself, but here's how I would do it
find this in your product.tpl file

Code: Select all

              <div class="content">
                <?php echo $text_qty; ?>
                <input type="text" name="quantity" size="3" value="<?php echo $minimum; ?>" />
                <a onclick="$('#product').submit();" id="add_to_cart" class="button"><span><?php echo $button_add_to_cart; ?></span></a>                
                <?php if ($minimum > 1) { ?><br/><small><?php echo $text_minimum; ?></small><?php } ?>
              </div>
and change it to this (the first and last lines are the only additions)

Code: Select all

              <?php if($stock == $this->language->get('text_instock') || $stock > 0): ?>
              <div class="content">
                <?php echo $text_qty; ?>
                <input type="text" name="quantity" size="3" value="<?php echo $minimum; ?>" />
                <a onclick="$('#product').submit();" id="add_to_cart" class="button"><span><?php echo $button_add_to_cart; ?></span></a>                
                <?php if ($minimum > 1) { ?><br/><small><?php echo $text_minimum; ?></small><?php } ?>
              </div>
              <?php endif; ?>
That should do it
I've tried your code in 1.4.9.2 but it does not work.

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by i2Paq » Thu Nov 18, 2010 2:35 am

OK, so I asked JAY6390 to help me on this, thanks JAY!

new code (and working)

Code: Select all

              <?php echo '<!-- STOCK: '.$this->language->get('text_instock').' -->'; ?>
              <?php if($stock === $this->language->get('text_instock') || (strlen($stock) == strlen((int)$stock) && $stock > 0)): ?>
              <div class="content">
                <?php echo $text_qty; ?>
                <input type="text" name="quantity" size="3" value="<?php echo $minimum; ?>" />
                <a onclick="$('#product').submit();" id="add_to_cart" class="button"><span><?php echo $button_add_to_cart; ?></span></a>
                <?php if ($minimum > 1) { ?><br/><small><?php echo $text_minimum; ?></small><?php } ?>
              </div>
              <?php endif; ?>
If you want to show this only when a fixt amount of stock is used, use: <?php if($stock == -999): ?>

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by i2Paq » Fri Nov 26, 2010 2:44 pm

To hide the + see below:
SXGuy wrote:in catalog/controller/product/category.php

find

Code: Select all

'price'   => $price,
add underneath

Code: Select all

'quantity' => $result['quantity'],
in catalog/view/theme/default/template/product/category.tpl

find

Code: Select all

<a class="button_add_small" href="<?php echo $products[$j]['add']; ?>" title="<?php echo $button_add_to_cart; ?>" >&nbsp;</a>
replace with

Code: Select all

<?php if ($products[$j]['quantity'] > 0 ) { ?>
          <a class="button_add_small" href="<?php echo $products[$j]['add']; ?>" title="<?php echo $button_add_to_cart; ?>" >&nbsp;</a>
		  <?php } ?>

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by i2Paq » Wed Jan 05, 2011 3:07 am

Ok, so the next code works OK when the stock gets below 0.
I need (please) this code to work with a fixt amount, lets say -10.

Code: Select all

              <?php echo '<!-- STOCK: '.$this->language->get('text_instock').' -->'; ?>
              <?php if($stock === $this->language->get('text_instock') || (strlen($stock) == strlen((int)$stock) && $stock > 0)): ?>
              <div class="content">
                <?php echo $text_qty; ?>
                <input type="text" name="quantity" size="3" value="<?php echo $minimum; ?>" />
                <a onclick="$('#product').submit();" id="add_to_cart" class="button"><span><?php echo $button_add_to_cart; ?></span></a>
                <?php if ($minimum > 1) { ?><br/><small><?php echo $text_minimum; ?></small><?php } ?>
              </div>
              <?php endif; ?>
I was told that I could use then

Code: Select all

<?php if($stock == -10): ?>
but whatever I try, it does not work.

I hope that JAY6390 will stop by and help me out ::)

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by JAY6390 » Wed Jan 05, 2011 7:43 pm

If you want it to show whenever the stock level isn't -999 you can just simply use
<?php if($stock != -999): ?>

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom
Who is online

Users browsing this forum: No registered users and 39 guests