Announcement

Collapse
No announcement yet.

'YouSave' works in Swift Search not in Smart search

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

    'YouSave' works in Swift Search not in Smart search

    I use Normans 'YouSave' scripting:

    https://community.sellerdeck.com/for...-results-v18-1

    But have recently found that whilst it works on both Smart and Swift on Product Pages, on Search Results the scripting works in Swift but not now in Smart

    Both sites have identical code:
    Added to JS Header Functions:

    Code:
    <script type="text/javascript">
    function setrrp(){
    $( "span.sryousave" ).each(function(){
    var rrp = $(this).attr('data-rrp') - 0;
    var rawprice = $(this).attr('data-rawprice') / $(this).attr('data-scale');
    if ( (rrp > 0) && (rawprice > 0) && (rrp > rawprice) )
    {
    var saving = (rrp - rawprice).toFixed(2);
    $(this).html('<h5 class="rrp">RRP £' + rrp.toFixed(2) + ' You save £' + saving + '</h5>');
    }
    });
    $( "span.sryousavepc" ).each(function(){
    var rrp = $(this).attr('data-rrp') - 0;
    var rawprice = $(this).attr('data-rawprice') / $(this).attr('data-scale');
    if ( (rrp > 0) && (rawprice > 0) && (rrp > rawprice) )
    {
    var savingsrpc = (((rrp - rawprice) / rrp) * 100).toFixed(0);
    $(this).html('<h5 class="rrp">RRP £' + rrp.toFixed(2) + ' You save' + savingsrpc + '%</h5>');
    }
    });
    $( "span.rrpsplash" ).each(function(){
    var rrp = $(this).attr('data-rrp') - 0;
    var rawprice = $(this).attr('data-rawprice') / $(this).attr('data-scale');
    if ( (rrp > 0) && (rawprice > 0) && (rrp > rawprice) )
    {
    var saving = (rrp - rawprice).toFixed(0);
    $(this).html('Save<br />£' + saving);
    }
    });
    $( "span.rrpsplashpc" ).each(function(){
    var rrp = $(this).attr('data-rrp') - 0;
    var rawprice = $(this).attr('data-rawprice') / $(this).attr('data-scale');
    if ( (rrp > 0) && (rawprice > 0) && (rrp > rawprice) )
    {
    var savingpc = (((rrp - rawprice) / rrp) * 100).toFixed(0);
    $(this).html('Save<br />' + savingpc + '%');
    }
    });
    }
    
    // deal with RRP on Search Results and Product Layouts
    $(document).ready(function(){setrrp();});
    
    // deal with RRP on filtered pages
    var oldHideLoadingDialog = HideLoadingDialog; // save SD routine that runs after filtering finishes
    HideLoadingDialog = function(){
    oldHideLoadingDialog(); // execute SD routine
    setrrp(); // and display any RRP's
    }
    </script>

    Added to Product Page Product Layout:
    Code:
    <actinic:block if="%3cactinic%3avariable%20name%3d%22RRP%22%20%2f%3e%20%21%3d%20%22%22%20AND%20%3cactinic%3avariable%20name%3d%22RRP%22%20%2f%3e%20%21%3d%200%20and%20%3cactinic%3avariable%20name%3d%22RRPShowSaveSplash%22%20%2f%3e" ><Actinic:NOTINB2B><span class="rrpsplash"
    data-rrp="<actinic:variable name="RRP" />"
    data-rawprice="<actinic:variable name="ProductPriceRaw" />"
    data-scale="1">
    </span>
    </Actinic:NOTINB2B><Actinic:NOTINB2B><div style="display:none;position:relative;"></Actinic:NOTINB2B><span class="rrpsplashpc"
    data-rrp="<actinic:variable name="RRP" />"
    data-rawprice="<actinic:variable name="ProductPriceRaw" />"
    data-scale="1">
    </span><Actinic:NOTINB2B></div></Actinic:NOTINB2B></actinic:block>
    Added to both Standard Price Layout and Dynamic Price Layouts:
    Code:
    <actinic:block if="%3cactinic%3avariable%20name%3d%22RRP%22%20%2f%3e%20%21%3d%20%22%22%20AND%20%3cactinic%3avariable%20name%3d%22RRP%22%20%2f%3e%20%21%3d%200">
    <Actinic:NOTINB2B><span class="sryousave"
    data-rrp="<actinic:variable name="RRP" />"
    data-rawprice="<actinic:variable name="ProductPriceRaw" />"
    data-scale="1">
    </span>
    </Actinic:NOTINB2B><Actinic:NOTINB2B><div style="display:none;position:relative;"></Actinic:NOTINB2B><span class="sryousavepc"
    data-rrp="<actinic:variable name="RRP" />"
    data-rawprice="<actinic:variable name="ProductPriceRaw" />"
    data-scale="1">
    </span><Actinic:NOTINB2B></div></Actinic:NOTINB2B>
    </actinic:block>
    Added to Standard Search Result for image:
    Code:
    <span class="rrpsplash"
    data-rrp="<actinic:variable searchresultvariable="true" name="RRP" />"
    data-rawprice="<actinic:variable name="SearchResultProductPriceRaw" />"
    data-scale="100">
    </span>
    </Actinic:NOTINB2B><Actinic:NOTINB2B><div style="display:none;position:relative;"></Actinic:NOTINB2B>
    <span class="rrpsplashpc"
    data-rrp="<actinic:variable searchresultvariable="true" name="RRP" />"
    data-rawprice="<actinic:variable name="SearchResultProductPriceRaw" />"
    data-scale="100">
    </span><Actinic:NOTINB2B></div></Actinic:NOTINB2B>
    and Added to Standard Search Result for price:
    Code:
    <p class="text-center">
    <Actinic:NOTINB2B>
    <span class="sryousave"
    data-rrp="<actinic:variable searchresultvariable="true" name="RRP" />"
    data-rawprice="<actinic:variable name="SearchResultProductPriceRaw" />"
    data-scale="100">
    </span>
    </Actinic:NOTINB2B><Actinic:NOTINB2B><div style="display:none;position:relative;"></Actinic:NOTINB2B>
    <span class="sryousavepc"
    data-rrp="<actinic:variable searchresultvariable="true" name="RRP" />"
    data-rawprice="<actinic:variable name="SearchResultProductPriceRaw" />"
    data-scale="100">
    </span><Actinic:NOTINB2B></div></Actinic:NOTINB2B>
    </p>
    Go to: https://www.gpxdev.co.uk/SwiftV2_Sli...t-Ring-47.html and https://www.gpxdev.co.uk/rrpsmart/acatalog/Engagement-Ring-47.html and in both Swift and Smart the YouSave image box and price suffix is displayed.

    Inspect element and you get this:
    Code:
    <span class="sryousave" data-rrp="259.99" data-rawprice="240" data-scale="1"><h5 class="rrp">RRP £259.99 You save £19.99</h5></span>
    Now from the Home Page search for 'ring' in both.
    In https://www.gpxdev.co.uk/SwiftV2_Sli...=&ACTION=Go%21 (Swift)
    The YouSave stuff is displayed:

    Inspect element and you get this:
    Code:
    <p class="text-center">
    <actinic:notinb2b><span class="sryousave" data-rrp="144" data-rawprice="10833" data-scale="100"><h5 class="rrp">RRP £144.00 You save £35.67</h5></span>
    </actinic:notinb2b><actinic:notinb2b></actinic:notinb2b></p>
    However in Smart: https://www.gpxdev.co.uk/rrpsmart/cg...O&ACTION=Go%21
    The YouSave stuff is not displayed and inspect element and you get this:
    Code:
    <p class="text-center">
    <span class="sryousave" data-rrp="259.99" data-rawprice="28800" data-scale="100">
    </span>
    </p>
    I have added this to the Header Function code to show the javascript is executing and it is (Shows 'ready!' in console.)

    Code:
    // Shorthand for $( document ).ready()
    $(function() {
    console.log( "ready!" );
    });
    Also Console shows nothing.

    Something is stopping

    Code:
    $(this).html
    executing in the search results page in Smart but not in Swift

    I am at a complete loss. Please can anyone see the wood for the trees?

    Thank you


    Jonathan Chappell
    Website Designer
    SellerDeck Website Designer
    Actinic to SellerDeck upgrades
    Graphicz Limited - www.graphicz.co.uk

    #2
    Something is odd with your code in Smart.

    It shouldn't really show a 'You save' at all on the product page because you've set the RRP to £259 and the product price to £288!

    In other words it looks as if the code is working properly on the Smart search page.
    -----------------------------------------

    First Tackle - Fly Fishing and Game Angling

    -----------------------------------------

    Comment


      #3
      Thanks Mike - you have solved the problem - the default Smart I used had prices entered exclusive of vat. Norman's calculations relate to vat inclusive prices so that is why the website got a headache! Needless to say Swift had them vat inclusive so worked!

      Now to make it work with vat exclusive prices!

      Thank you!
      Jonathan Chappell
      Website Designer
      SellerDeck Website Designer
      Actinic to SellerDeck upgrades
      Graphicz Limited - www.graphicz.co.uk

      Comment


        #4
        I am homing in on this now thanks to Mike's prompt.

        Where Business Settings specify prices entered Ex vat,

        it seems that <actinic:variable name="SearchResultProductPriceRaw" /> still displays the price including vat

        wheareas <actinic:variable name="ProductPriceRaw" /> displays it ex vat.

        Click image for larger version

Name:	yesitdoesnoitdoesnt.jpg
Views:	48
Size:	26.8 KB
ID:	557255

        SearchResultProductPriceRaw is 6998
        ProductPriceRaw is 58.32

        If in Settings I select product price layout as Exc Vat the
        data-rawprice is still inc vat

        What manner of mystery is this?
        Jonathan Chappell
        Website Designer
        SellerDeck Website Designer
        Actinic to SellerDeck upgrades
        Graphicz Limited - www.graphicz.co.uk

        Comment


          #5
          Further Note - Revised 280624

          I didn't know this (!) but you have to change the Settings | Site Options | General | Use Tax Inclusive Prices for Online Search to false

          What follows is now for interest only...


          Sorted:

          Click image for larger version  Name:	sorted.jpg Views:	0 Size:	35.2 KB ID:	557257


          Product page code unaltered, Search results code changed:

          Code:
          <script type="text/template">
          <Actinic:NOTINB2B><span class="srrrpsplash"
          data-rrp="<actinic:variable searchresultvariable="true" name="RRP" />"
          data-rawprice="<actinic:variable name="SearchResultProductPriceRaw" />"
          data-scale="100">
          </span>
          </Actinic:NOTINB2B><Actinic:NOTINB2B><div style="display:none;position:relative;"></Actinic:NOTINB2B><span class="srrrpsplashpc"
          data-rrp="<actinic:variable searchresultvariable="true" name="RRP" />"
          data-rawprice="<actinic:variable name="SearchResultProductPriceRaw" />"
          data-scale="100">
          </span><Actinic:NOTINB2B></div></Actinic:NOTINB2B>
          AND

          Code:
          <actinic:block if="%3cactinic%3avariable%20name%3d%22SearchResultShowsPrice%22%20%2f%3e">
          <div class="price"><Actinic:Variable Name="SearchResultPrice"/></div>
          <p class="text-center">
          <Actinic:NOTINB2B><span class="srsryousave"
          data-rrp="<actinic:variable searchresultvariable="true" name="RRP" />"
          data-rawprice="<actinic:variable name="SearchResultProductPriceRaw" />"
          data-scale="100">
          </span>
          </Actinic:NOTINB2B><Actinic:NOTINB2B><div style="display:none;position:relative;"></Actinic:NOTINB2B><span class="srsryousavepc"
          data-rrp="<actinic:variable searchresultvariable="true" name="RRP" />"
          data-rawprice="<actinic:variable name="SearchResultProductPriceRaw" />"
          data-scale="100">
          </span><Actinic:NOTINB2B></div></Actinic:NOTINB2B>
          </p>
          </actinic:block>
          CSS:

          Code:
          .rrpsplash, .srrrpsplash, .srrrpsplashpc, .rrpsplashpc {
          position: absolute;
          top: 0;
          left: 0;
          z-index: 99;
          border: 2px solid #B50015;
          padding: 5px;
          border-radius: 5px;
          background: #fff;
          margin: 5px 0 0 5px;
          }
          .product-price {font-weight:bold;font-size: larger;}
          p.product-image.set-right, .product-image.set-right {
          position:relative;
          }
          .product-image {
          position:relative;
          }
          
          .rrp{
          padding: 10px 0;
          font-size: 15px;
          }
          .imageOnRightTextWrappedAround .rrp, h5.rrp {
          padding: 0;
          padding-bottom: 10px;
          color: rgba(255, 0, 0, .9);
          }
          
          imageOnRightTextWrappedAround.product-listing .rrp {
          text-align: center;
          margin-top: 5px;
          }
          
          <actinic:block if="%3cactinic%3avariable%20name%3d%22UseDynamicPrices%22%20%2f%3e">
          .imageOnLeftTextWrappedAround [id$="StaticPrice"] .rrp {
          visibility: hidden;
          display: none;
          }
          </actinic:block>
          .imageOnLeftTextWrappedAround .rrp {
          padding: 0;
          padding-bottom: 10px;
          color: rgba(255, 0, 0, .9);
          }
          
          imageOnLeftTextWrappedAround.product-listing .rrp {
          text-align: center;
          margin-top: 5px;
          }
          .imageOnLeftTextWrappedAround [id$="StaticPrice"] .rrp {
          visibility: hidden;
          display: none;
          }

          So this header function works in Search Results with prices entered ex vat:
          This assumes that RRP is also entered ex vat

          Code:
          <script type="text/javascript">
          function setrrp(){
          tr = 20;
          db = 100;
          ttt = (tr / db);
          //1. product
          $( "span.sryousave" ).each(function(){
          var rrp = $(this).attr('data-rrp') - 0;
          var rrpplus = (rrp * ttt) + rrp;
          var rawprice = $(this).attr('data-rawprice') / $(this).attr('data-scale');
          var rawpriceplus = (rawprice * ttt) + rawprice;
          
          if ( (rrp > 0) && (rawprice > 0) && (rrpplus > rawpriceplus) )
          {
          var saving = (rrpplus - rawpriceplus).toFixed(2);
          $(this).html('<h5 class="rrp"> RRP £' + rrpplus.toFixed(2) + ' (inc.vat)' + ' You save £' + saving + '</h5>');
          }
          });
          //2. search result product
          $( "span.srsryousave" ).each(function(){
          var rrp = $(this).attr('data-rrp') - 0;
          var rrpplus = (rrp * ttt) + rrp;
          var rawprice = $(this).attr('data-rawprice') / $(this).attr('data-scale');
          var rawpriceplus = (rrpplus * ttt) + rrpplus;
          
          if ( (rrp > 0) && (rawprice > 0) && (rrpplus > rawprice) )
          {
          var saving = (rrpplus - rawprice).toFixed(2);
          $(this).html('<h5 class="rrp"> RRP £' + rrpplus.toFixed(2) + ' (inc.vat)' + ' You save £' + saving + '</h5>');
          }
          });
          
          //3. image
          $( "span.rrpsplash" ).each(function(){
          var rrp = $(this).attr('data-rrp') - 0;
          var rrpplus = (rrp * ttt) + rrp;
          var rawprice = $(this).attr('data-rawprice') / $(this).attr('data-scale');
          var rawpriceplus = (rawprice * ttt) + rawprice;
          
          if ( (rrp > 0) && (rawprice > 0) && (rrp > rawprice) )
          {
          var saving = (rrpplus - rawpriceplus).toFixed(2);
          $(this).html('Save<br />£' + saving);
          }
          });
          
          
          //6. product logged in
          $( "span.sryousavepc" ).each(function(){
          var rrp = $(this).attr('data-rrp') - 0;
          var rrpplus = (rrp * ttt) + rrp;
          var rawprice = $(this).attr('data-rawprice') / $(this).attr('data-scale');
          var rawpriceplus = (rawprice * ttt) + rawprice;
          
          if ( (rrp > 0) && (rawprice > 0) && (rrp > rawprice) )
          {
          var savingsrpc = (((rrpplus - rawpriceplus) / rrpplus) * 100).toFixed(0);
          $(this).html('<h5 class="rrp">RRP £' + rrpplus.toFixed(2) +' (inc.vat)' + ' You save' + savingsrpc + '%</h5>');
          }
          });
          //7. image logged in
          $( "span.rrpsplashpc" ).each(function(){
          var rrp = $(this).attr('data-rrp') - 0;
          var rrpplus = (rrp * ttt) + rrp;
          var rawprice = $(this).attr('data-rawprice') / $(this).attr('data-scale');
          var rawpriceplus = (rawprice * ttt) + rawprice;
          
          if ( (rrp > 0) && (rawprice > 0) && (rrp > rawprice) )
          {
          var savingpc = (((rrpplus - rawpriceplus) / rrpplus) * 100).toFixed(0);
          $(this).html('Save<br />' + savingpc + '%');
          }
          });
          //5. search result image logged in
          $( "span.srrrpsplashpc" ).each(function(){
          var rrp = $(this).attr('data-rrp') - 0;
          var rrpplus = (rrp * ttt) + rrp;
          var rawprice = $(this).attr('data-rawprice') / $(this).attr('data-scale');
          
          if ( (rrp > 0) && (rawprice > 0) && (rrpplus > rawprice) )
          {
          var saving = (rrpplus - rawprice).toFixed(2);
          $(this).html('Save<br />£' + saving);
          }
          });
          //4. search result image
          $( "span.srrrpsplash" ).each(function(){
          var rrp = $(this).attr('data-rrp') - 0;
          var rrpplus = (rrp * ttt) + rrp;
          var rawprice = $(this).attr('data-rawprice') / $(this).attr('data-scale');
          
          if ( (rrp > 0) && (rawprice > 0) && (rrpplus > rawprice) )
          {
          var saving = (rrpplus - rawprice).toFixed(2);
          $(this).html('Save<br />£' + saving);
          }
          });
          //8. search result product logged in
          $( "span.srsryousavepc" ).each(function(){
          var rrp = $(this).attr('data-rrp') - 0;
          var rrpplus = (rrp * ttt) + rrp;
          var rawprice = $(this).attr('data-rawprice') / $(this).attr('data-scale');
          
          if ( (rrp > 0) && (rawprice > 0) && (rrpplus > rawprice) )
          {
          var savingsrpc = (((rrpplus - rawprice) / rrpplus) * 100).toFixed(0);
          $(this).html('<h5 class="rrp">RRP £' + rrpplus.toFixed(2) +' (inc.vat)' + ' You save' + savingsrpc + '%</h5>');
          }
          });
          
          }
          
          // deal with RRP on Search Results and Product Layouts
          $(document).ready(function(){setrrp();});
          
          // deal with RRP on filtered pages
          var oldHideLoadingDialog = HideLoadingDialog; // save SD routine that runs after filtering finishes
          HideLoadingDialog = function(){
          oldHideLoadingDialog(); // execute SD routine
          setrrp(); // and display any RRP's
          }
          
          
          </script>
          • Why is there not a Tax Exclusive price version of ‘SearchResultProductPriceRaw’?
          • Is there a variable for whether the Price is entered ex vat or inc vat (Business Settings) or do I need to make one?

          Thanks!
          Last edited by graphicz; 28-Jun-2024, 08:54 AM. Reason: Further Note - Revised 280624
          Jonathan Chappell
          Website Designer
          SellerDeck Website Designer
          Actinic to SellerDeck upgrades
          Graphicz Limited - www.graphicz.co.uk

          Comment

          Working...
          X