Announcement

Collapse
No announcement yet.

Using RTS in Javascript

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

    Using RTS in Javascript

    My first real forray into Javascript.

    I want to put a wrapper around a Product Layout to check the real time stock level. If it is <= Suspend Level then I want it to write a DIV with display:none. i.e if real time stock level is at or below suspend level then I want to hide the product from the customer.

    I've got this far :

    Code:
     
    <script language=Javascript1.2>
    if ( <actinic:variable name="StockLevel" /> <= <actinic:variable name="StockSuspendLevel" /> ) // out of stock
      {
      document.write('<div style="display:none;">');
      }
    else
      {
      document.write('<div>');
      }
    </script>
    which seems to work.

    But I'm not sure it's checking the real time stock level.

    I'm beginning to think I'm being a bit simplistic. Am I going in the right direction?

    thanks

    Goz.
    Elysium:Online - Official Accredited SellerDeck Partner
    SellerDeck Design, Build, Hosting & Promotion
    Based in rural Northants

    #2
    Originally posted by Goz View Post
    My first real forray into Javascript.

    I want to put a wrapper around a Product Layout to check the real time stock level. If it is <= Suspend Level then I want it to write a DIV with display:none. i.e if real time stock level is at or below suspend level then I want to hide the product from the customer.

    I'm beginning to think I'm being a bit simplistic. Am I going in the right direction?

    thanks

    Goz.
    Not I am afraid for a live web page. Actinic uses two methods to display the stock level, on preview it uses the values in the local Actinic Database, however once you upload to the site it switches to using AJAX calls to perl scripts on the host server. Take a look in actinicextras.js, to see the code or you could just use my plug in for extra RTS features.

    Malcolm

    SellerDeck Accredited Partner,
    SellerDeck 2016 Extensions, and
    Custom Packages

    Comment


      #3
      Looks like the wrong direction to me, i think you are using the stock level variable within your JS, but that only gets updated via an upload, you'd need to be using the stock level used by RTS (if indeed i have it correct).

      When a product goes out of stock, actinic auto hides the add to cart button, so the function and code to do what you want would appear to be already created. I'd take the much simpler route and investigate the code around the cart button and look to see if you move that to surround the whole product layout instead. You'll need to bear in mind the list layout as it will end up with an empty cell, but that'd be my first level of attack on this.

      Comment


        #4
        I knew it was too simple to be true!!

        Thanks Mal - I'll take a look at both.

        Lee - I'll take a look at the add to cart code. I used display:none as that doesn't reserve space on the page for the product - from what I've seen so far in testing it doesn't leave spaces on the page.
        Elysium:Online - Official Accredited SellerDeck Partner
        SellerDeck Design, Build, Hosting & Promotion
        Based in rural Northants

        Comment


          #5
          Originally posted by Goz View Post
          I knew it was too simple to be true!!
          Hi

          here is the code I promised, also sent by pm.

          The code change is very simple

          1/ Wrap the product layout with
          <span id="HideIfOutOfStock_<actinic:variable name="ProductReference" selectable="false" />" class="ActinicRTS" >
          original code is here
          </span>

          2/ add this code to ActinicExtras.js
          Code:
                      if  (sIDStart == 'HideIfOutOfStock') {
                          if (mapStockByRef[sProdRef] <= 0) {
                              arrStockElems[nIndex].style.visibility = "hidden";
                              arrStockElems[nIndex].style.display = "none";
                          } else {
                              arrStockElems[nIndex].style.visibility = "visible";
                              arrStockElems[nIndex].style.display = "inline";
                          }
                      }
          Immediately after the comment
          //
          // Out ofStock
          //
          and before
          if (sIDStart == 'EnableIfOutOfStock')

          Now manipulate the stock figures to see the product disappear.

          Malcolm

          SellerDeck Accredited Partner,
          SellerDeck 2016 Extensions, and
          Custom Packages

          Comment

          Working...
          X