Post by dlew » Thu Mar 22, 2012 12:41 pm

I am trying to test displaying a message depending on the product's stock_status_id but just when I do a <?php echo $product['stock_status_id'];?> , it doesn't return a value. How can I have this info shown?

Thanks

New member

Posts

Joined
Sun Feb 26, 2012 1:56 pm

Post by dlew » Thu Mar 22, 2012 2:16 pm

I think I am close, how do I get the stock_status_id using system/library/cart.php ?

New member

Posts

Joined
Sun Feb 26, 2012 1:56 pm

Post by dlew » Fri Mar 23, 2012 6:54 am

anyone? i am so close to getting this figured out...

New member

Posts

Joined
Sun Feb 26, 2012 1:56 pm

Post by Johnathan » Fri Mar 23, 2012 11:17 pm

You can't get the stock_status_id, but you can get the text by using:

$product['stock']
$stock

You can then use the text for comparison, for example:

if ($product['stock'] == 'In Stock')
if ($stock == 'In Stock')

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by dlew » Sat Mar 24, 2012 12:05 am

Thank you, I'll give that a try!

Johnathan wrote:You can't get the stock_status_id, but you can get the text by using:

$product['stock']

You can then use the text for comparison, for example:

if ($product['stock'] == 'In Stock')

New member

Posts

Joined
Sun Feb 26, 2012 1:56 pm

Post by dlew » Sat Mar 24, 2012 12:58 am

My goal is to assign some product options with different stock statuses. Some would be pre-order, others avail in 7-14 days, and I'd let them still order them despite having 0 quantity. Some items that sell out, stay out of stock and wouldn't be order-able.

New member

Posts

Joined
Sun Feb 26, 2012 1:56 pm

Post by Avvici » Sat Mar 24, 2012 1:12 am

Then take his suggestion a little further and set up either a switch statement or set up some else if's.

Code: Select all


switch($product['stock']){

case "In Stock":

//place your actions here

break;

case "2-3 Days":

//place your actions here

break;

//so on and so forth.

}

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by dlew » Sat Mar 24, 2012 5:23 am

Thanks all, I think I got it now :D

New member

Posts

Joined
Sun Feb 26, 2012 1:56 pm

Post by dlew » Sat Mar 24, 2012 2:29 pm

OK I need a little more help

How do I get the $product['stock'] to show me the stock_status name like In Stock or Pre-Order
<?php echo ($product['stock']) ;?> shows a 1

When I tried to use a switch($product['stock']){ with different cases, it defaulted to the first case.

New member

Posts

Joined
Sun Feb 26, 2012 1:56 pm

Post by Johnathan » Sat Mar 24, 2012 9:53 pm

Sorry, I was a little bit off...if you're on the product page, then:

<?php echo $stock; ?>

will get the stock status text if "Display Stock" is set to "No", and will get the product quantity if it's set to "Yes".

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by dlew » Sat Mar 24, 2012 10:45 pm

thanks you! How does it get handled on the cart page?
I have DIsplay Stock set to No.

Johnathan wrote:Sorry, I was a little bit off...if you're on the product page, then:

<?php echo $stock; ?>

will get the stock status text if "Display Stock" is set to "No", and will get the product quantity if it's set to "Yes".

New member

Posts

Joined
Sun Feb 26, 2012 1:56 pm

Post by dimko » Sat Mar 24, 2012 10:56 pm

dlew wrote:thanks you! How does it get handled on the cart page?
I have DIsplay Stock set to No.
You are talking about: http://demo.opencart.com/index.php?route=checkout/cart right?

If so, I'm after this one, too :)

Using OpenCart v1.5.1.3


Active Member

Posts

Joined
Sun Sep 25, 2011 2:10 am

Post by dlew » Sat Mar 24, 2012 11:27 pm

On the product page I want products with option value of 0 to show the out of stock message (2-3 days, pre-order, etc) in the pull down

On the cart page I want to show the same messages based on the product's option's out of stock message
dimko wrote:
dlew wrote:thanks you! How does it get handled on the cart page?
I have DIsplay Stock set to No.
You are talking about: http://demo.opencart.com/index.php?route=checkout/cart right?

If so, I'm after this one, too :)

New member

Posts

Joined
Sun Feb 26, 2012 1:56 pm
Who is online

Users browsing this forum: No registered users and 49 guests