Announcement

Collapse
No announcement yet.

Show "out of stock" in search results

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • graphicz
    replied
    I am afraid I do not know, hopefully someone else can help

    Leave a comment:


  • rookers
    replied
    I am loving this tweak. I have been looking for a way of doing this for a while. SO - how can we make it so that we can SORT on stock amount? Eg. show products with most items in stock first. etc ?

    Also - with other stock things we have the tweak to say "More than 5 in stock" if stock > 5 - so as to not show all our cards to everyone. Can this tweak be added to this tweak, as currently displays the entire stock figure.

    It would be really good to be able to do that.

    Leave a comment:


  • graphicz
    replied
    I have found that you can add the icons:

    Code:
    <script type="text/javascript">
    function setsrstock(){
    $( "p.srstock" ).each(function(){
    $(this).css('color', ($(this).attr('data-srstock') - 0) > 0 ? 'green' : 'red');
    $(this).css('background', ($(this).attr('data-srstock') - 0) > 0 ? 'url("in-stock.png")' : 'url("out-stock.png")');
    });
    }
    // redefine actinicsearch.js HideLoadingDialog to recheck stock after filtering is applied
    function HideLoadingDialog()
    {
    var loadingDialog = document.getElementById('loading-dialog');
    if (loadingDialog)
    {
    loadingDialog.style.display = "none"; // hide the dialog
    }
    setsrstock(); // Norman patch to check stock
    }
    $(document).ready(function(){
    setsrstock();
    });
    </script>
    This needs to go at the bottom of the stylesheet:

    Code:
    .srstock {
    background-repeat: no-repeat!Important;
    padding-left: 1.8em;
    font-weight:bold;
    }

    Leave a comment:


  • NormanRouxel
    replied
    And for normal pages use plain StockLevel and BlockIf's:
    Code:
    <p style="color:<actinic:block if="%3cactinic%3avariable%20name%3d%22StockLevel%22%20%2f%3e%20%3e%200">green</actinic:block><actinic:block if="%3cactinic%3avariable%20name%3d%22StockLevel%22%20%2f%3e%20%3c%3d%200">red</actinic:block>"><actinic:variable name="StockLevel" /> in stock</p>

    Leave a comment:


  • graphicz
    replied
    Brilliant. Thank you Norman.

    Leave a comment:


  • NormanRouxel
    replied
    BlockIf's are evaluated when the page is being built on your back office system. They're no use for dynamic content served to users like e.g. the search results.

    You need code that will operate when the page is being loaded by the users browser. E.g.:
    In layout Standard Search Results:
    Code:
    <p data-srstock="<actinic:variable name="SearchResultStock" />" class="srstock"><actinic:variable name="SearchResultStock" /> in stock</p>
    This will add the stock count as a data-srstock attribute to the tag around the stock level.

    Then the following added to the bottom of layout Standard JavaScript Header Functions will run once the page has loaded to set the colour as required:
    Code:
    <script type="text/javascript">
    function setsrstock(){
    	$( "p.srstock" ).each(function(){
    		$(this).css('color', ($(this).attr('data-srstock') - 0) > 0 ? 'green' : 'red'); 
    		});
    }
    // redefine actinicsearch.js HideLoadingDialog to recheck stock after filtering is applied		
    function HideLoadingDialog()
    	{
    	var loadingDialog = document.getElementById('loading-dialog');
    	if (loadingDialog)
    		{
    		loadingDialog.style.display = "none";		// hide the dialog
    		}
    	setsrstock();			// norman patch to check stock
    	}
    $(document).ready(function(){
    	setsrstock();
    });
    </script>
    Note: If you use filtering then Standard Search Results is used when a filter is applied so the above code also runs whenever a filter selection completes.

    Leave a comment:


  • graphicz
    replied
    I tried to do this:

    Code:
    <p<actinic:block if="%3cactinic%3avariable%20name%3d%22SearchResultStock%22%20%2f%3e%20%3d%3d%200"> style="color:red"</actinic:block><actinic:block if="%3cactinic%3avariable%20name%3d%22SearchResultStock%22%20%2f%3e%20%3e%3d%201"> style="color:green;"</actinic:block>><actinic:variable name="SearchResultStock" /> in stock</p>
    But the BlockIf is ignored and the colour is red regardless of the value of <actinic:variable name="SearchResultStock" />

    Is there a way of changing the style if stock is zero?

    https://www.webeg.uk/willit/acatalog...Jewellery.html

    Thank you

    Leave a comment:


  • NormanRouxel
    replied
    Is there a variable to use that shows when the Stock Control / Monitoring box is ticked at product level?
    Variable IsStockMonitored does that but it's not available in the search results. Significant Perl patching would be required or a variation on my post #2 might help.
    [code]


    Leave a comment:


  • graphicz
    replied
    This displays a message when stock is Zero whether the Stock Control / Monitoring box is ticked at product level or not.

    Code:
    <actinic:block if="%3cactinic%3avariable%20name%3d%22SearchResultStock%22%20%2f%3e%20%3d%3d%200" >
    <span id="EnableIfOutOfStock_<actinic:variable name="SearchResultProductReference" />" class="ActinicRTS"><Actinic:Variable Name="OutOfStock"/></span>
    </actinic:block>
    Some clients will have Online Stock Control Enabled

    Click image for larger version

Name:	47119-01.jpg
Views:	191
Size:	46.6 KB
ID:	553202

    And product by product either show the instock message by default

    Click image for larger version

Name:	47119-02.jpg
Views:	141
Size:	29.5 KB
ID:	553203

    Or choose to show the out of stock message

    Click image for larger version

Name:	47119-03.jpg
Views:	150
Size:	31.6 KB
ID:	553204

    Is there a variable to use that shows when the Stock Control / Monitoring box is ticked at product level?

    This would allow the message above to only display when <actinic:variable name="SearchResultStock" /> is Zero AND the the Stock Control / Monitoring box is ticked at product level.

    i have searched but not yet found.

    Thank you...

    Leave a comment:


  • graphicz
    replied
    Cracking stuff. Thank you Norman.

    Leave a comment:


  • NormanRouxel
    replied
    Forget all that 10 year old stuff. Nowadays use:

    <actinic:variable name="SearchResultStock" />

    Leave a comment:


  • graphicz
    replied
    How can this be modified to work in v18/Swift please?
    The Standard search result is already wrapped in script tags...
    Thank you

    Leave a comment:


  • toolman.co.uk
    replied
    Cheers Norman,

    I dont know what I didnt do last night but I got it working now

    Cheers Mate

    Leave a comment:


  • NormanRouxel
    replied
    Daniel. It's very likely that you've simply failed to copy / paste the entire bit of code above, or you've overwritten some part of the Search Results Page Bulk Area instad of adding the code at the top.

    You can do the two bits of code one at a time. There should be no effect if you do the first bit alone. The results should display as before. Once you get that, do the second bit and test again.

    Leave a comment:


  • toolman.co.uk
    replied
    God knows what Im doing, I just presummed you could just copy and paste the html, did that and uploaded, but when I tested it, it said ie: 1 of 12 products found, but only one product was showing.

    So tried inserting it as a block and it just keeps crashing actinic.

    Told you I was a novice!
    I'll have to live without it!

    Leave a comment:

Working...
X