Jump to content

Out of Stock php code


Guest Wasay

Recommended Posts

Hello everyone

I have made a link to my clients OUT OF STOCK , which now shows LOW Stock - Check Availability, and in the viewProd.ini file

$view_prod->assign("TXT_OUTOFSTOCK",$lang['front']['viewProd']['out_of_stock']="<a href=\"mailto: [email protected]\">LOW STOCK - Check Availability</a> ");

It should be mailed to clients asking about the stock availability, but the main issue is, how do i change the color of the html hyperlink, which is a default blue.. how can i or what can i input in the php that it could change the color there... thanks

please help

Wasay

Link to comment
Share on other sites

Guest CartGarden

Ideally you would add a class to the specific link, and then style that in the css:

1) add a class to your link:

 $view_prod->assign("TXT_OUTOFSTOCK",$lang['front']['viewProd']['out_of_stock']="<a href=\"mailto: [email protected]\" class="lowStock">LOW STOCK - Check Availability</a> ");




2) Add the class to style.css (maybe at the end to be safe):




a.lowStock {

	color: #cc0000;

}

That is a slightly darker red. You can go from there...

Hope that helps.

Link to comment
Share on other sites

For any newbies reading this, please note that html formatting can be included in the php assignments, but watch out for the double quotes, they will break the code. You must escape the double quotes used in the class assignment, or change them to single quotes. Examples:

class=\"lowStock\" good

class='lowStock' good

class="lowStock" bad

Link to comment
Share on other sites

Hi

thanks for your help

But I am afraid it does work as it gives syntax error...

help

Wasay

Hi Mark

I used that what you said

$view_prod->assign("TXT_OUTOFSTOCK",$lang['front']['viewProd']['out_of_stock']="<a href=\"mailto: [email protected]\" class=\"lowStock\" >LOW STOCK - Check Availability</a>");

But doesnt work

I did try class='lowstock' but doesnt work... maybe the style sheet is not attached to the file coz the file I am talking about is viewProd.ini.php ...

thanks

Wasay

Link to comment
Share on other sites

Well sorry, I noticed his error but was not looking at the whole code :o

Try this:

$view_prod->assign("TXT_OUTOFSTOCK","<a href=\"mailto: [email protected]\" class=\"lowStock\" >LOW STOCK - Check Availability");

You must have defined a class .lowStock in one of your stylesheets for the class to have an effect. If you get a parse error or syntax error, post the error message here.

Link to comment
Share on other sites

Hi Mark

Now its showing the LOW STOCK - Check Availability right next to IN StOCK.

It was fine before, I just wanted to change the font color from blue to black, as all hyper links automatically turn blue... so its just the font color to be honest...

cheers

Wasay

Link to comment
Share on other sites

OK I'll make it simple, here is stock CubeCart code:

	if($prodArray[0]['stock_level']<1 && $prodArray[0]['useStockLevel']==1 && $prodArray[0]['digital']==0){

	

		$view_prod->assign("TXT_OUTOFSTOCK",$lang['front']['viewProd']['out_of_stock']);

		

	} else {

	

		$view_prod->assign("TXT_OUTOFSTOCK"," ");

	

	}




Code you need:


	if($prodArray[0]['stock_level']<1 && $prodArray[0]['useStockLevel']==1 && $prodArray[0]['digital']==0){

	

		$view_prod->assign("TXT_OUTOFSTOCK","<a href=\"mailto: [email protected]\" style='color: #000000; text-decoration: none;' >LOW STOCK - Check Availability</a>");

		

	} else {

	

		$view_prod->assign("TXT_OUTOFSTOCK"," ");

	

	}

I notice in the code I posted last I left out the closing anchor tag </a>

This code will change the text when the stock is depleted. If you have added original code that is triggered when quantity is low, say last 5 widgets, then you need to also write thee corollary to program "IN STOCK" not to show when down to last 5 widgets. Otherwise, your out-of-stock message will show next to an in stock message.

Link to comment
Share on other sites

Hi Mark

Thanks for that code....

I think it was the anchor issue, and also it did work, but stable color, not any hover or rollover color change so I tried using the "CLASS" and I used the one that its in my style sheet.

$view_prod->assign("TXT_OUTOFSTOCK","<a href=\"mailto: [email protected]\" class='txtButton' >LOW STOCK - Check Availability</a>");

It works absolutely great now...

Much Much appreciate your help mate...

thanks again...

cheers

Wasay

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...