You must be logged in to post


Register? | Lost Your Password?

Search Forums:


 






Wildcard Usage:
*    matches any number of characters
%    matches exactly one character

Disable items from frontpage or search if out of stock

UserPost

5:12 am
April 14, 2010


classicjoes.com

Member

posts 17

1

Post edited 9:13 am – April 14, 2010 by classicjoes.com
Post edited 9:17 am – April 14, 2010 by classicjoes.com
Post edited 9:23 am – April 14, 2010 by classicjoes.com


I figured out how to do this with a easy amount of time. I hope this will help anyone else. This should hopefully be a good way to approach this with minimal effort. I'm sure theres another way to do it, but it does work, and it's not bad at all!

So the idea here is to make items out of stock not display on main page/search.

I have my main page as a frontdoor page (Just items displayed, no news), But I would think it would be the same in the main index file for the default template. But for my changes:

Open up Frontdoor.php and search.php in the mk3 theme directory.

FIND IN BOTH FILES (Or any other file you want to do this with):

while ($wp_query->have_posts()) : $wp_query->the_post(); // check for product large image
$pli = get_post_meta($post->ID, 'pli', $single = true); // check for item price
$price = get_post_meta($post->ID, 'price', $single = true);?>

CHANGE TO:

while ($wp_query->have_posts()) : $wp_query->the_post(); // check for product large image
$pli = get_post_meta($post->ID, 'pli', $single = true); // check for item price
$price = get_post_meta($post->ID, 'price', $single = true);
$quantity = get_post_meta($post->ID, 'mkt_stock_quantity', $single = true);
$oversell = get_post_meta($post->ID, 'mkt_stock_oversell_ok', $single = true);
$outstock = get_post_meta($post->ID, 'outstock', $single = true);
if (($quantity == 0 && $oversell != 1) || $outstock == 1) continue; ?>

====

What the new coding means:

$quantity: Item amount of quantity left

$oversell : If you can keep selling after quantity is 0.

$outstock: Manual out of stock enable/disable.

So the if check is if quantity is empty, but oversell is not enabled, OR if manual out of stock is enabled, bypass this item (continue; skips though the php while loop, so it bypasses the item!) These are all meta tag variables that markettheme already handles so you don't need any additional changes.

Pretty simple I think :)

1:00 pm
April 14, 2010


Market Admin

Admin

posts 4756

2

Thanks for sharing!

10:14 pm
June 27, 2010


Cory

Member

posts 14

3

I can't make this work. Any guesses as to why? I'm almost positive I'm replacing the right check of code with the appropriate chunk of code.

12:31 pm
June 28, 2010


Market Admin

Admin

posts 4756

4

I never tested it personally…  Just took CJ's word for it. 

Maybe you can send him a private message.

1:31 pm
July 23, 2010


Cory

Member

posts 14

5

Never heard back from CJ.

Anyone have success with this?



 

Market takes e-commerce to the next level with an easy to use, quick setup platform. Learn more or take the tour.