Post by SXGuy » Tue Nov 10, 2009 12:04 am

This is something ive just written for a client and thought id share it with you.

Its a simple mod, but just in case you need it, then here it is.

This mod will replace the price of an item with the words "Out of stock" if the quanity of the product is 0.

You can adapt it so it includes the price as well as the status if you wish, however as that wasnt needed for me, ill just list what i did to achieve what i needed.

First we need to be able to add the stock quanity into the array that is generated for the product pages under the categories.

locate catalog/controller/product/category.php and find:

Code: Select all

$this->data['products'][] = array(
insert Below:

Code: Select all

'quantity' => $result['quantity'],
now locate catalog/view/theme/default/template/product/category.tpl and find:

Code: Select all

<?php if (!$products[$j]['special']) { ?>
        <span style="color: #900; font-weight: bold;"><?php echo $products[$j]['price']; ?></span><br />
        <?php } else { ?>
        <span style="color: #900; font-weight: bold; text-decoration: line-through;"><?php echo $products[$j]['price']; ?></span> <span style="color: #F00;"><?php echo $products[$j]['special']; ?></span>
        <?php } ?>
Replace with:

Code: Select all

 <?php if (!$products[$j]['special']) { ?>
        <span style="color: #900; font-weight: bold;">
		<?php if ($products[$j]['quantity'] <= 0) { 
		echo 'Out of Stock';
		} else {
		echo $products[$j]['price'];
		} ?></span><br />
        <?php } else { ?>
        <span style="color: #900; font-weight: bold; text-decoration: line-through;"><?php if ($products[$j]['quantity'] <= 0) { 
		echo 'Out of Stock';
		} else {
		echo $products[$j]['price'];
		} ?></span> <span style="color: #F00;"><?php echo $products[$j]['special']; ?></span>
        <?php } ?>
Optional

If you wish to keep the price of the product and also list whether it is out of stock then replace with this instead:

Code: Select all

  <?php if (!$products[$j]['special']) { ?>
        <span style="color: #900; font-weight: bold;">
		<?php if ($products[$j]['quantity'] <= 0) { 
		echo 'Out of Stock';
		} ?></span><br />
		<?php echo $products[$j]['price']; ?></span><br />
        <?php } else { ?>
        <span style="color: #900; font-weight: bold; text-decoration: line-through;"><?php if ($products[$j]['quantity'] <= 0) { 
		echo 'Out of Stock';
		} ?></span><br />
		<?php echo $products[$j]['price']; ?></span> <span style="color: #F00;"><?php echo $products[$j]['special']; ?></span>
        <?php } ?>

Hope this helps some of you guys,

Remember, you can also add this technique to any module, all you need to do, is repeat the same process but instead of editing the files listed under the product folders, just edit the files under "module" instead.

I.E catalog/controller/module/bestseller.php and catalog/view/theme/default/template/module/bestseller.tpl

Ive included this mod for use with the slideshow module also.
Last edited by SXGuy on Sat Aug 13, 2011 11:51 pm, edited 1 time in total.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by Qphoria » Tue Nov 10, 2009 3:10 am

I think I've shared this too somewhere.. but good to have another point of reference for it

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by xl5 » Sat Aug 13, 2011 10:26 pm

Hi
I know its an old post but can you clarify as to 'insert code', is that in place of, below or next to. :-\

xl5
New member

Posts

Joined
Mon Jul 18, 2011 3:45 pm


Post by SXGuy » Sat Aug 13, 2011 11:50 pm

Below.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by MatthewB » Fri Aug 19, 2011 9:19 pm

Hi

how do you do this in v 1.5.1

i can't find section in category.tpl to replace?

Matthew


Active Member

Posts

Joined
Sat Jul 23, 2011 5:18 am
Location - Sunderland Tyne and Wear

Post by SXGuy » Sat Aug 20, 2011 12:37 am

should work in 1.5.1 also.

And as far as i know, the code in category.tpl stayed the same between 1.5.0 and 1.5.1 so look a little deeper.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by MatthewB » Sat Aug 20, 2011 1:13 am

Is still can't seem to find the code in category.tpl

i've attached file

Matthew


Active Member

Posts

Joined
Sat Jul 23, 2011 5:18 am
Location - Sunderland Tyne and Wear

Post by SXGuy » Sat Aug 20, 2011 6:41 am

1.5.1

Code: Select all

        <?php if (!$product['special']) { ?>
        <?php echo $product['price']; ?>
        <?php } else { ?>
        <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
        <?php } ?>
thats the code in 1.5.1 but i think the replacement made need a little tweeking.

Its late at the moment, so i cant think straigjt, gimmie 8 hours or so to have a sleep and ill reply with the modified code for you.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by MatthewB » Thu Aug 25, 2011 10:57 pm

any luck with this code?

Matthew


Active Member

Posts

Joined
Sat Jul 23, 2011 5:18 am
Location - Sunderland Tyne and Wear

Post by GoGo OpenCart » Tue Dec 20, 2011 9:44 pm

I just released a module that disables the "Add to Cart" button, and replaces the button's default "Add to Cart" text with Out Of Stock, 2 - 3 Days, etc. i.e. whatever text you want to be shown, for products that have 0 (zero) quantity.

Take a look at here (just see the pictures, and you'll get the idea):

http://www.opencart.com/index.php?route ... on_id=4358

See all my extensions: https://www.opencart.com/index.php?rout ... 20OpenCart


User avatar
Active Member

Posts

Joined
Mon Nov 14, 2011 11:30 pm

Post by straightlight » Sat Dec 24, 2011 3:03 am

GoGo OpenCart wrote:I just released a module that disables the "Add to Cart" button, and replaces the button's default "Add to Cart" text with Out Of Stock, 2 - 3 Days, etc. i.e. whatever text you want to be shown, for products that have 0 (zero) quantity.

Take a look at here (just see the pictures, and you'll get the idea):

http://www.opencart.com/index.php?route ... on_id=4358
Does this look-up also includes the products already included in the cart and about to proceed to checkout but specific products that may no longer be in stock ?

The most generated errors being found on Opencart forum originates from contributed programming. The increased counters are caused by posted redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member

Posts

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

Post by GoGo OpenCart » Sat Dec 24, 2011 3:15 am

What you are asking, is the following: If some product is already in the Cart, and if by any chance in the meantime becomes unavailable (got 0 stock), it should be popped-up from the Cart, and not allowed to be processed further on with the checkout, right? Is so, then no, it doesn't do that, it only disables the "Add to Cart" button everywhere within the site where the button is shown.

See all my extensions: https://www.opencart.com/index.php?rout ... 20OpenCart


User avatar
Active Member

Posts

Joined
Mon Nov 14, 2011 11:30 pm

Post by straightlight » Sat Dec 24, 2011 3:20 am

While your original idea is well thought regarding the add to cart event, a module added on the top should be integrated as well to state from the checkout/checkout route that one or more specific products could not be processed through checkout due to stock reasons or even multiple reasons that may or may not be implied. This event should even be added once the checkout button has been used and forwarded as first action from checkout/checkout page. ;)

The most generated errors being found on Opencart forum originates from contributed programming. The increased counters are caused by posted redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member

Posts

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

Post by GoGo OpenCart » Sat Dec 24, 2011 3:49 am

Well, OpenCart already does that check :)

Just put some product in your Shopping Cart, and then go to your Admin panel, and put 0 Quantity for that product you've already put in your Shopping Cart, then click on Checkout, and you'll get the following warning message: Products marked with *** are not available in the desired quantity or not in stock! ;)

Although, it doesn't check at the final checkout step, i.e. when pressing the "Confirm Order" button, so it might be a bug.

See all my extensions: https://www.opencart.com/index.php?rout ... 20OpenCart


User avatar
Active Member

Posts

Joined
Mon Nov 14, 2011 11:30 pm

Post by straightlight » Sat Dec 24, 2011 4:54 am

It may already check the product quantity but it does not check per item the stock status ID of each stores which shipping specifically depends on and reliable on geo zones. See, the stock status ID doesn't really have to depend on the quantity but also based on the zones. ;)

The most generated errors being found on Opencart forum originates from contributed programming. The increased counters are caused by posted redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member

Posts

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

Post by zishan » Sun Apr 22, 2012 5:00 am

Please can someone sticky this as it is a great method.

Thanks

New member

Posts

Joined
Wed Jan 11, 2012 5:40 am

Post by tresj » Sat Mar 16, 2013 10:12 am

Hi,

It's a long time ago but I was searching for the same thing: change price to 'out of stock' when the products status = o.
Couldn't find any mods and tried the code above but it didn't work for me in OS 1.5.5.1. I've modified the code but it still doesn't work.
Of course I will keep on trying but I've been working on my site almost 18 hours a day the last 7 weeks to figure things out myself (and most of the issues I've solved myself by reading the forum) but I'm getting tired now!
So now I'm thinking: waarom het wiel opnieuw uitvinden! (as we in the Netherlands say)
Explanation: why spend a lot of time to figure out something that another one has already figured out! So....
Who can and will help me?

Probably it's a small thing I'm forgetting to change. Does anybody know? How to change the code above to make this work in OS 1.5.5.1?

Hope for a lot of responces ;-)
Thanx already,

With regards
Angelique.

Newbie

Posts

Joined
Fri Jan 25, 2013 8:49 am

Post by alibroon » Thu Sep 26, 2013 11:37 am

I am also looking for this. We really want the cart to function as a catalogue so we have already disabled the Add to Cart functions. So to be able to change the price to Sold would be ideal for us. Did you get any further with a solution for 1.5.5.1

Newbie

Posts

Joined
Fri Oct 26, 2012 5:32 pm

Post by sheridangraphics » Sat Jul 28, 2018 9:43 am

Hi All,

I bought a plugin a while back which replaces 00.00 with pick options. All my 0 priced options required the customer to select specific options to calculate the overall price. The problem I have is in checkout I dont want it to say pick options in tax, delivery or other areas where 00.00 may come up. how can i get passed this issue?

New member

Posts

Joined
Fri Feb 20, 2015 12:47 am
Who is online

Users browsing this forum: No registered users and 6 guests