Announcement

Collapse
No announcement yet.

Show "out of stock" in search results

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

    Show "out of stock" in search results

    Is this possible, have looked around and it seems a most obvious thing to have as an option in the Search Settings, but have not been able to find an option or a script change to enable this to be included. Have had several requests from customers over Xmas irritated that they had to go down another level to find I was out of stock of the item they wanted.
    Martin
    Modelmotorracing.com : Web services : Twitter

    #2
    It's possible but isn't trivial. Here's how I'd go about it.

    Displaying OUT OF STOCK warning on search results.

    In layout Search Results Page Bulk Area, at the very top, add:
    Code:
    <actinic:block php="true">
    	$slhtml = <<<ENDOFCODE
    var ns = new Object();	
    <actinic:block type="EntireSectionList"><actinic:block type="ProductList"><actinic:block if="%28%3cactinic%3avariable%20name%3d%22ProductType%22%20%2f%3e%20%21%3d%202%29%20AND%20%3cactinic%3avariable%20name%3d%22IsOutOfStockShown%22%20%2f%3e" >
    ns["<actinic:variable name="EncodedProductAnchor" encoding="perl" selectable="false" />"]=1;</actinic:block></actinic:block></actinic:block>
    function searchstock(slink){
    	if ( ns[slink.replace(/.*#(.*)".*/, '$1')] ) document.write('<strong><span class="actrequired"><actinic:variable name="OutOfStock" encoding="perl" selectable="false" /></span></strong>');
    }
    ENDOFCODE;
    	$sl = fopen('outofstock.js', 'w');
    	fwrite($sl, $slhtml);
    	fclose($sl);
    </actinic:block>
    <script type="text/javascript" src="outofstock.js"></script>

    In layout Standard Search Result, where you want to display the stock warning (just above the final </p> line is a good place) insert:
    Code:
    <script type="text/javascript">searchstock('<Actinic:Variable Name="SearchResultLink"/>');</script>
    That's it.

    The code works by creating a JavaScript helper file "outofstock.js" that contains a list of product ID's for the out of stock entries only.

    This should make the file fairly small as it's likely that in stock products are in the majority.

    The file is only created once per upload when the Seach Results page is being parsed.

    JavaScript on the Standard Search Results layout, looks in the out of stock list for the current product ID and displays a warning if an entry is found.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Beautiful and relatively simple. Thanks Norman, you're a star as ever. That's now working at http://www.slotcarcentre.co.uk/acatalog/search.html, if you change the top radio button for digital plug cars to "YES" the message comes up for a fair few of them. Hopefully this will be useful for some other Actinic users too.
      Martin
      Modelmotorracing.com : Web services : Twitter

      Comment


        #4
        Related to the above, is there any way of excluding items with zero stock levels from appearing in the search results list?

        Thanks,

        Laura
        http://www.lembrassa.com
        Designs for the Fuller Bust

        Comment


          #5
          I can't think of a way of excluding them. You could probably adapt the above code to output code that hides the entire item. E.g. output for out-of-stock items

          <span style="display:none;">

          or for in-stock

          <span>

          Generate this at the start of each search item and put a </span> at the end.

          The full results lists HTML will then be used us usual but the out of stock items won't show on-screen as they're between <span style="display:none;"> and </span>.

          One quirk is that you will get sequence numbers with gaps (e.g. 1,2,4,5). And pages with all items out of stock won't show anything.
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment


            #6
            Thanks, Norman, I might just give that a try.

            Laura
            Last edited by laura; 10-Jan-2010, 02:57 PM. Reason: correcting mistypes
            http://www.lembrassa.com
            Designs for the Fuller Bust

            Comment


              #7
              Nice idea, but this doesn't work on my site. I think its to do with the way the different size combinations have had to be set up. The stock level on the main product description is what the search sees not the stock level at the individual size level.

              Thanks anyway - I hope others have better success with this.

              Laura
              http://www.lembrassa.com
              Designs for the Fuller Bust

              Comment


                #8
                Can the life of me find where the " Search Results Bulk Area" is??

                Please point me in the right direction in novice terms
                Thanks in advance for any remarks

                Dan

                www.toolman.co.uk
                www.joblottools.co.uk
                www.toolmanonline.co.uk
                www.quality-tools.co.uk

                Comment


                  #9
                  It's actually "Search Results Page Bulk Area" (I've amended my post above). Go to Design / Library / Layouts, right-click and use Find.
                  Norman - www.drillpine.biz
                  Edinburgh, U K / Bitez, Turkey

                  Comment


                    #10
                    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!
                    Thanks in advance for any remarks

                    Dan

                    www.toolman.co.uk
                    www.joblottools.co.uk
                    www.toolmanonline.co.uk
                    www.quality-tools.co.uk

                    Comment


                      #11
                      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.
                      Norman - www.drillpine.biz
                      Edinburgh, U K / Bitez, Turkey

                      Comment


                        #12
                        Cheers Norman,

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

                        Cheers Mate
                        Thanks in advance for any remarks

                        Dan

                        www.toolman.co.uk
                        www.joblottools.co.uk
                        www.toolmanonline.co.uk
                        www.quality-tools.co.uk

                        Comment


                          #13
                          How can this be modified to work in v18/Swift please?
                          The Standard search result is already wrapped in script tags...
                          Thank you
                          Jonathan Chappell
                          Website Designer
                          SellerDeck Website Designer
                          Actinic to SellerDeck upgrades
                          Graphicz Limited - www.graphicz.co.uk

                          Comment


                            #14
                            Forget all that 10 year old stuff. Nowadays use:

                            <actinic:variable name="SearchResultStock" />
                            Norman - www.drillpine.biz
                            Edinburgh, U K / Bitez, Turkey

                            Comment


                              #15
                              Cracking stuff. Thank you Norman.
                              Jonathan Chappell
                              Website Designer
                              SellerDeck Website Designer
                              Actinic to SellerDeck upgrades
                              Graphicz Limited - www.graphicz.co.uk

                              Comment

                              Working...
                              X