The template we have uses the same font color for stock availability. People are not noticing if the item is in stock or out of stock. I would like to have "In Stock" be green and "Out of Stock" to be red. I looked in the listing_0.html and see the code block [availability_itemprop]. Does anyone know how to change the color of the displayed font based on availability?
Announcement
Collapse
No announcement yet.
How to Change the Color of Product Availability "In Stock" and "Out of Stock"?
Collapse
X
-
Marty
I do not use the [availability] tag, so this won't be exact for you, but it should get you started.
HTML Code:<style> .FONT1[catalogid] { color:green; } .FONT2[catalogid] { color:red; display:none; } </style>
HTML Code:<div class="FONT1[catalogid]" id="Available[catalogid]"> <!--START: product_availability--> <span class="availability">[stock]</span> <!--END: product_availability--> </div> <div class="FONT2[catalogid]" id="NOTAVAILABLE[catalogid]"> <!--START: product_availability--> <span class="availability">[stock]</span> <!--END: product_availability--> </div>
HTML Code:<script> if ([stock]==0) {document.getElementById('Available[catalogid]').style.display = "none";} </script> <script type="text/javascript"> if ([stock]==0) {document.getElementById('NOTAVAILABLE[catalogid]').style.display = "block";} </script>
Hope this is enough to get you started. If you just want to use the code as is, it will display the actual number of items on hand. This helps my customers to not add more than we have and getting an error. Good luck.
Last edited by Toocutebeads; 01-30-2020, 01:30 PM. Reason: Edited to add opening script tag to alleviate any confusion.
- 1 like
-
Originally posted by Toocutebeads View PostMarty
I do not use the [availability] tag, so this won't be exact for you, but it should get you started.
HTML Code:<style> .FONT1[catalogid] { color:green; } .FONT2[catalogid] { color:red; display:none; } </style>
HTML Code:<div class="FONT1[catalogid]" id="Available[catalogid]"> <!--START: product_availability--> <span class="availability">[stock]</span> <!--END: product_availability--> </div> <div class="FONT2[catalogid]" id="NOTAVAILABLE[catalogid]"> <!--START: product_availability--> <span class="availability">[stock]</span> <!--END: product_availability--> </div>
HTML Code:if ([stock]==0) {document.getElementById('Available[catalogid]').style.display = "none";} </script> <script type="text/javascript"> if ([stock]==0) {document.getElementById('NOTAVAILABLE[catalogid]').style.display = "block";} </script>
Hope this is enough to get you started. If you just want to use the code as is, it will display the actual number of items on hand. This helps my customers to not add more than we have and getting an error. Good luck.
Clarification for People trying to figure this out:
HTML Code:<style> .FONT1[catalogid] { color:green; } .FONT2[catalogid] { color:red; display:none; } </style>
Replace your [availability_itemprop] in your listing template with the 2 code blocks Toocutebeads listed. You can change [stock] to [availability_itemprop] if you don't want to list number of units remaining and just want to list "In Stock" or "Out of Stock".
You can put the javascript block Toocutebeads listed at the very bottom of your listing template. NOTE: Make sure you have a javascript opening tag.
Comment
-
Marty
Glad to hear it works the same with or without [availability]. I've been working on going 1 step further, and changing my add to cart block to a waiting list button when [stock]==0. You can see what I mean here.
https://www.toocutebeads.com/Holiday-Jewelry-Kits
That prevents customers from getting an error when adding multiple items that would be at 0. Trying to get the waiting list into a Modal has been my challenge so far, but Im confident I can get it to work with the 3dcart system,.
Comment
-
Originally posted by Toocutebeads View PostMarty
Glad to hear it works the same with or without [availability]. I've been working on going 1 step further, and changing my add to cart block to a waiting list button when [stock]==0. You can see what I mean here.
https://www.toocutebeads.com/Holiday-Jewelry-Kits
That prevents customers from getting an error when adding multiple items that would be at 0. Trying to get the waiting list into a Modal has been my challenge so far, but Im confident I can get it to work with the 3dcart system,.
Comment
-
-
Originally posted by JoeBTI View PostI'm sure text can be easily shown over the image based on the availability text of "In Stock" or "Out Of Stock". Have you contacted one of the 3dCart experts?
Comment
Comment