Hide Variation List Item from Product Page

Modules, Add-ons and custom code that's more than just a quick hack or Mod.
mozack
Posts: 27
Joined: Tue Mar 30, 2010 2:32 pm

Hide Variation List Item from Product Page

Post by mozack »

Hi to all,

Some days ago i ask in forum how to hide variations from list if stock is 0.

Well i found the solution working hard finding the code, and a litle piece of code do that automatic.

Ex.: If you sell t-shirts and the XS size is unavailable, the size appear in list and when client click on it the message out of stock appear. The correct, in my opinion is hide the unavailable size from list (without making any changes in admin), by this way, if the product goes to stock again it simple show the sizes available or hide it. I found the code that do that!

To make this change, go to includes/classes/class.product.php around line 297 and find the code:

Code: Select all

			$query = "
				SELECT
					vcoptionids
				FROM
					[|PREFIX|]product_variation_combinations
				WHERE
					vcenabled = 1 AND
					vcvariationid  = " . $this->_prodvariationid . " AND
					vcproductid = " . $this->_prodid;
Now, change this to:

Code: Select all

			$query = "
				SELECT
					vcoptionids
				FROM
					[|PREFIX|]product_variation_combinations
				WHERE
					vcenabled = 1 AND
					vcvariationid  = " . $this->_prodvariationid . " AND
					vcstock > 0 AND
					vcproductid = " . $this->_prodid;
The change is verify if vcstock is more than 1.

I've working on this but now, i saw one problem that i want your help to resolve.

Ex. You're using the code but all variations of product become unavailable, so in product page you will not see any variation.

The question is: How to hide the add to cart button and after the title of variation put the text Unavailable?

If someone know how to do that, please post here.

Best Regards

Mozack
Tony Barnes
Posts: 744
Joined: Thu Jun 18, 2009 8:59 am

Re: Hide Variation List Item from Product Page

Post by Tony Barnes »

This should happen automatically if no variations are available?

If you want to add in another specific "sold out" message (again, you should have sold out text come up??), open up includes/display/productdetails.php, find:

Code: Select all

		if($productInStock == true) {
			$GLOBALS['SNIPPETS']['SideAddItemSoldOut'] = '';
			$GLOBALS['DisplayAdd'] = "";
		}
change it to:
$GLOBALS['NoStock'] = "";
if($productInStock == true) {
$GLOBALS['SNIPPETS']['SideAddItemSoldOut'] = '';
$GLOBALS['DisplayAdd'] = "";
$GLOBALS['NoStock'] = "none";
}
Copy templates/_master/productdetails.html to templates/YOUR TEMPLATE/productdetails.html, open it up, and stick this in wherever you want the out of stock message to appear:

Code: Select all

<span class="NoStock" style="display:%%GLOBAL_NoStock%%">Out of Stock</span>
Then style .NoStock in your CSS

Should work, may need some tweaking, but will be the ball park
Snooper
Posts: 264
Joined: Sat Jun 26, 2010 9:22 pm

Re: Hide Variation List Item from Product Page

Post by Snooper »

Great code change..

Only I can not see productdetails.html where you said to look -- /templates/__master/

As for the .NoStock.. What style sheet are you refering to ?
ISC 5.5.4 Ultimate : Being used here -- http://www.kdklondon.com
mozack
Posts: 27
Joined: Tue Mar 30, 2010 2:32 pm

Re: Hide Variation List Item from Product Page

Post by mozack »

Thanks for your answers...

I'll try this piece of code to change this...

I'll be posting here my store changes... Hopes it help.

Regards

Mozack
mozack
Posts: 27
Joined: Tue Mar 30, 2010 2:32 pm

Re: Hide Variation List Item from Product Page

Post by mozack »

Hi Tony,

Well i have my store changing product quantities with cron job. Sometimes the products come out of stock in some sizes and it still appear in product details page. But all the other sizes are available. My point is show the unavailable message when no optinions to choose.

I made this little mod to pass only the sizes that have vcstock with more than 0 in MySql table. When no sizes with more than 1, it shows the message AND maybe, if possible, hide the button to add to cart.

I'm facing this problem because it isnt made by hand. If a product variation become unavailable you unmark this variation in product administration panel and everything works fine, but if you have 1 stock in more than 1 website and with so many itens in sale, this is a hard work...

I'll try your code now, maybe i'll try here the solution.

Regards

Mozack
mozack
Posts: 27
Joined: Tue Mar 30, 2010 2:32 pm

Re: Hide Variation List Item from Product Page

Post by mozack »

Hi Snoper,

The productdetails.html is in _master/panels (or something like that), and you must create the css style with nostock to formatting and place the code in. You must put it in yourtemplatename.css in your template folder/Styles

Best Regards

Mozack
Snooper
Posts: 264
Joined: Sat Jun 26, 2010 9:22 pm

Re: Hide Variation List Item from Product Page

Post by Snooper »

Hi Mozack..

Brill for replying so quick.. And yes, found the file where you said I would (ty).. I have located a sectiono of code that might be where the line <span class="NoStock" style="display:%%GLOBAL_NoStock%%">Out of Stock</span> might go.. What do you think? A queston of where if I'm right...

<div class="DetailRow InventoryLevel" style="%%GLOBAL_HideCurrentStock%%">
<div class="Label">%%LNG_CurrentStock%%:</div>
<div class="Value">
<span class="VariationProductInventory">
%%GLOBAL_InventoryList%%
</span>
</div>
</div>

Sorry if I am sounding thick, but the moment you mention css and my eyes defocused.. Sorry. But can you spell out what I need to do.. In the guy is dumb levelled language !!
ISC 5.5.4 Ultimate : Being used here -- http://www.kdklondon.com
mozack
Posts: 27
Joined: Tue Mar 30, 2010 2:32 pm

Re: Hide Variation List Item from Product Page

Post by mozack »

Hi Snooper,

Well, it becomes a problem and i dont want how to resolve the problem of out of stock message.

There is one problem:

Once it is made without the untick the out of stock size or variation in admin panel the message out of stock dont appear or just appear if you select a size that dont have in stock, after the javascript show the out of stock message. My point is do this automated!

I've changed the code to show only variations if vcstock table have more than 0 quantities. The problem is:

When no variations to display, the out of stock message still dont appear and it happens beacause we dont unmark the variation in admin panel or beacause we hide the variation unvailable and in this case, you dont have the javascript feature to show the unavailable message...

I'm facing this problem and i think the solution is in PHP file... In my opinion (and i will happy if some expert can help me) is create a new statment in Products related php files... There is only 2 that are if is in stock or if the purshase available but this is in global produtct and dont work in variation focus...

Well, i will try your code to try help you placing the message... I'll be posting here.

I'm sorry for the late answer but i'm not notified when someone post here....

Regards

Mozack
Snooper
Posts: 264
Joined: Sat Jun 26, 2010 9:22 pm

Re: Hide Variation List Item from Product Page

Post by Snooper »

Hi Mozack

Its not until you read it does the point make sense. If no stock clearly no message to say so, since the placement for that stock was removed *doh* !!

What if we got the code to show (say) ‘limited stock remaining’ or 'x itmes remaining' if the count was at 2 or 5 ? And then at 0 remove the image as you had originally ?

Snooper
ISC 5.5.4 Ultimate : Being used here -- http://www.kdklondon.com
mozack
Posts: 27
Joined: Tue Mar 30, 2010 2:32 pm

Re: Hide Variation List Item from Product Page

Post by mozack »

Hi,

Maybe it can be the point to do it right.... Well, i'll try asap.

Regards

Mozack
Post Reply