Post by salehjoon » Tue Nov 29, 2011 4:51 am

Instead of change core files, I've made changes to my template files, removing the button when stock = 0. For example:

/opencart/catalog/view/theme/mytheme/template/product/product.tpl (~line 180):

Code: Select all
<?php if ($product_info['quantity']) { ?>
<div class="cart">
<div><?php echo $text_qty; ?>
<input type="text" name="quantity" size="2" value="<?php echo $minimum; ?>" />
<input type="hidden" name="product_id" size="2" value="<?php echo $product_id; ?>" />&nbsp;<a id="button-cart" class="button"><span><?php echo $button_cart; ?></span></a>
</div>
<?php if ($minimum > 1) { ?>
<div class="minimum"><?php echo $text_minimum; ?></div>
<?php } ?>
</div>
<?php } ?>


I've added the first if statement. That's it.
This method doesn't work.

New member

Posts

Joined
Sun Nov 20, 2011 12:17 pm

Post by DOzric » Tue Jan 03, 2012 10:34 pm

I am researching a shop for someone selling antiques. This is going to be 1 item each and wondered if this is an option yet without a hack or on the road map. I don't like changing code and worry about updates messing with this setting.

There must be a good percentage of people selling single items and could use this option.

Thank you

Newbie

Posts

Joined
Tue Jan 03, 2012 10:29 pm

Post by fido-x » Tue Jan 03, 2012 10:47 pm


Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by slik » Fri Jan 20, 2012 12:53 am

+1 who need such option ) mb if there will be a lot of ppl needed it developers will add it?

Newbie

Posts

Joined
Mon Jan 09, 2012 10:11 pm

Post by Chris! » Thu Feb 16, 2012 9:41 am

I would also love to see that products are not being listed when they are not in stock.
Setting them inactive manually would be a pain-staking process for those who have big stores with thousands of products listed in them.

New member

Posts

Joined
Tue Feb 07, 2012 12:23 pm

Post by Mike Guenther » Wed Mar 21, 2012 8:22 pm

I agree, I am shocked this isn't an option. It is a pain to manually have to do this, but if you are not on top of it you could easily oversell product that you don't have in stock. Then you would have to offer refunds. yuck.

Active Member

Posts

Joined
Thu Oct 13, 2011 12:00 am

Post by esponi » Thu Aug 23, 2012 11:25 pm

We have developed something like that in our store:
Products with stock = 0, you will be able to:
- Hide product
or
- Hide "add to cart" button
or
- Change "add to cart" button behavior, to redirect to "Contact to get a quote" or a custom text.

We plan to convert this into an extension.
Any more ideas to add?

New member

Posts

Joined
Fri Jul 20, 2012 2:05 am

Post by brain » Tue Sep 04, 2012 12:53 am

Thanks for the mod Qphoria. Works great except for one problem that I am seeing. It doesn't hide the product on the category page. I don't think there were categories yet in the version this was intended for, however it does work for every page but that one. Not sure what code I would need to edit to ensure it is hidden on this page as well. Any ideas?

For esponi: Any news on this mod you are referring?

Newbie

Posts

Joined
Tue Sep 04, 2012 12:48 am

Post by esponi » Mon Sep 10, 2012 10:32 pm

Yes, we will port to an extension in a few days:
Included features in each product form:
If stock = 0:
[ x ] Hide this product.
[ x ] Hide only "add to cart" button.
[ x ] Change text "add to cart" to new text: ..........................
[ x ] Change "add to cart" button behavior, redirect to ................................?product_id={this}

What do you think.

New member

Posts

Joined
Fri Jul 20, 2012 2:05 am

Post by Minimera » Thu Sep 27, 2012 3:39 am

@Esponi: Sounds really good. Where can I find the extention?

/Linda

Newbie

Posts

Joined
Sat Jan 07, 2012 8:49 pm

Post by esponi » Tue Oct 16, 2012 6:08 pm

Minimera: Release is stopped due low interest.

New member

Posts

Joined
Fri Jul 20, 2012 2:05 am

Post by mr.bacan » Wed Nov 27, 2013 1:48 am

Qphoria wrote:1. Edit: catalog/model/catalog/product.php
2. All places you find:

Code: Select all

p.status = '1'
3. Replace with:

Code: Select all

p.status = '1' AND p.quantity > '0'
Thanks a lot. This solution worked like a charm on Version 1.5.5.1.

Newbie

Posts

Joined
Sun Nov 10, 2013 1:35 am

Post by stelian99 » Fri Jan 29, 2016 7:59 pm

Hello guys,

I know that it's an old thread. I run a shop based on OC 1.5.1.3. I've tried few extensions for hide products that are out of stock, but not one keep the product url valid. Any tips?

Thank you!

Newbie

Posts

Joined
Wed May 20, 2015 5:44 am

Post by esponi » Tue Sep 06, 2016 4:31 am

What do you mean With valid url?

New member

Posts

Joined
Fri Jul 20, 2012 2:05 am

Post by opencart-solutions » Mon Jan 22, 2018 3:48 am

Hello
InStock Only for all page when show products: category, special, search, manufacturer
https://www.opencart.com/index.php?rout ... n_id=33009

Opencart Solutions | opencart-solutions.com


New member

Posts

Joined
Fri Jan 19, 2018 1:55 am

Post by masterross » Thu May 02, 2019 11:18 pm

It's not good for SEO to remove products.

Go to /opencart/catalog/view/theme/mytheme/template/product/product.tpl
and change:

Code: Select all

<button type="button" id="button-cart" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-primary btn-lg btn-block"><?php echo $button_cart; ?></button>
To:

Code: Select all

        <?php if ($stockqty) { ?>
        <button type="button" id="button-cart" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-primary btn-lg btn-block"><?php echo $button_cart; ?></button>
       <?php } else {?>
       <span class="btn btn-primary btn-lg btn-block">Out of Stock</span>
        <?php } ?>

Pottery Glaze shop


New member

Posts

Joined
Mon Jan 02, 2017 7:07 pm

Post by straightlight » Thu May 02, 2019 11:21 pm

<?php if ($stockqty) { ?>
I wonder where this variable is coming from . . .

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 119 guests