Announcement

Collapse
No announcement yet.

You save in Filtered Search Results v18.1.*

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

    You save in Filtered Search Results v18.1.*

    Try as I may and following the KB and 'Sellerdeck Help' documentation I am not able to create a calculation for 'You save' in the Filtered Search Results in v18.1.*

    The normal dynamic price works well:

    Code:
    $rrp<actinic:variable name="ProductID" /> = <actinic:variable name="RRP" />;
    $rawprice<actinic:variable name="ProductID" /> = <actinic:variable name="ProductPriceRaw" selectable="false" />;
    <actinic:block if="%21%3cactinic%3avariable%20name%3d%22IsTaxInclusiveMode%22%20%2f%3e" >
    if($g_bShowDynamicTaxInclusivePrice)
    {
    $rrp<actinic:variable name="ProductID" /> += (<actinic:variable name="TaxRate1" /> / 100) * $rrp<actinic:variable name="ProductID" />;
    $rawprice<actinic:variable name="ProductID" /> += (<actinic:variable name="TaxRate1" /> / 100) * $rawprice<actinic:variable name="ProductID" />;
    }
    </actinic:block>
    <actinic:block if="%3cactinic%3avariable%20name%3d%22IsTaxInclusiveMode%22%20%2f%3e" >
    if(!$g_bShowDynamicTaxInclusivePrice)
    {
    $rrp<actinic:variable name="ProductID" /> = $rrp<actinic:variable name="ProductID" /> / ((<actinic:variable name="TaxRate1" /> + 100) / 100);
    $rawprice<actinic:variable name="ProductID" /> = $rawprice<actinic:variable name="ProductID" /> / ((<actinic:variable name="TaxRate1" /> + 100) / 100);
    }
    </actinic:block>
    
    // only display if we have an RRP and there's a saving to show
    if ( ($rrp != 0) && ($rrp > $rawprice) )
    {
    $savepercent<actinic:variable name="ProductID" /> = round((($rrp<actinic:variable name="ProductID" /> - $rawprice<actinic:variable name="ProductID" />) / $rrp) * 100);
    $savehowmuch<actinic:variable name="ProductID" /> = round($rrp<actinic:variable name="ProductID" /> - $rawprice<actinic:variable name="ProductID" />);
    echo "<h5 class='rrp'>RRP <s>".number_format((float)$rrp<actinic:variable name="ProductID" /> , 2, '.', '')."</s> You Save ".$savepercent<actinic:variable name="ProductID" />."%</h5>";
    echo "<h5 class='rrp'>RRP <s>".number_format((float)$rrp<actinic:variable name="ProductID" /> , 2, '.', '')."</s> You Save ".$savehowmuch<actinic:variable name="ProductID" />."</h5>";
    }
    But I cannot get the Raw Price or ProductID into the Search Result Layout to do the calculation.

    An earlier solution for v2013 no longer works in this current version.

    Is there a way to calculate the difference between RawPrice and RRP and display it in the Search Result Layout?

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

    #2
    Hi Jonathan

    To use the raw price in search results you would have to use the variable:
    Code:
    <actinic:variable name="SearchResultProductPriceRaw" />
    And for the RRP use:
    Code:
    <actinic:variable searchresultvariable="true" name="RRP" />
    That code works for displaying the raw values in the search results. AFAIK it should also allow you to manipulate them. But be careful of the fact that RRP is decimalised, the raw product price is not.
    Bruce Townsend
    Ecommerce Product Manager
    Sellerdeck Ecommerce Solutions

    Comment


      #3
      All these years and I never knew that! Probably worth updating 58449? and the Respective Help entries?

      In fact I find that if you click to insert a variable and "'List names containing' SearchResult" there are several to play with!

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

      Comment


        #4
        Sadly no good for php calculation as PHP does not like 'SearchResultProductPriceRaw'


        Click image for larger version

Name:	srpprnotwork.jpg
Views:	50
Size:	58.1 KB
ID:	554921
        Attached Files
        Jonathan Chappell
        Website Designer
        SellerDeck Website Designer
        Actinic to SellerDeck upgrades
        Graphicz Limited - www.graphicz.co.uk

        Comment


          #5
          Once again, you cannot use SellerDeck's built-in PHP for making a calculation that is dependent on a customer choosing the products that display. SD's PHP only runs once when building the HTML template that is used for every search result. It has no effect on a live page.


          You need to put such items within SPAN tags with a unique classname. Then use JavaScript to loop through all such items, make the calculation and update the result.

          Here's code that will work on Search Results, Product Layouts and Filtered products.

          In your standard product layouts and Filtered Product Summary:
          Code:
          <span class="sryousave"
          	data-rrp="<actinic:variable name="RRP" />"
          	data-rawprice="<actinic:variable name="ProductPriceRaw" />"
          	data-scale="1">
          </span>
          In Standard Search Result:
          Code:
          <span class="sryousave"
          	data-rrp="<actinic:variable searchresultvariable="true" name="RRP" />"
          	data-rawprice="<actinic:variable name="SearchResultProductPriceRaw" />"
          	data-scale="100">
          </span>
          At bottom of Standard JavaScript 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('RRP ' + rrp.toFixed(2) + ' You save ' + saving);
          			}
          	});
          }
          
          // 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>
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment


            #6
            Thank you Norman. I had tried some js calculations but ran into problems with script tags within script tags! I will try your fix and report back.
            Jonathan Chappell
            Website Designer
            SellerDeck Website Designer
            Actinic to SellerDeck upgrades
            Graphicz Limited - www.graphicz.co.uk

            Comment


              #7
              I've amended my post #5 to be a fully working demo. And extended it to work on Search Results, Filtered products and normal Product Layouts.
              Norman - www.drillpine.biz
              Edinburgh, U K / Bitez, Turkey

              Comment


                #8
                That is an excellent piece of work, functions perfectly and will be invaluable hopefully to many. Thank you so much.
                Jonathan Chappell
                Website Designer
                SellerDeck Website Designer
                Actinic to SellerDeck upgrades
                Graphicz Limited - www.graphicz.co.uk

                Comment


                  #9
                  I am trying to adapt the above for tax inclusive and tax exclusive pricing but I am getting in rather a pickle.

                  I am trying to take the php from dynamic price layout and adapt it so that php echos the Span according to tax inc or tax exc but have so far failed

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

                  Comment


                    #10
                    This is what seems to work for me:

                    Code:
                    <Actinic:NOTINB2B>
                    <span class="rrpsplash"
                    data-rrp=" <actinic:block php="true">echo (<actinic:variable encoding="perl" name="RRP" selectable="false" /> * <actinic:variable encoding="perl" name="TaxRate1" selectable="false" /> /100) + <actinic:variable encoding="perl" name="RRP" selectable="false" />; </actinic:block>"
                    data-rawprice=" <actinic:block php="true">echo (<actinic:variable encoding="perl" name="ProductPriceRaw" selectable="false" /> * <actinic:variable encoding="perl" name="TaxRate1" selectable="false" /> /100) + <actinic:variable encoding="perl" name="ProductPriceRaw" selectable="false" />; </actinic:block>"
                    data-scale="1">
                    </span>
                    </Actinic:NOTINB2B>
                    Jonathan Chappell
                    Website Designer
                    SellerDeck Website Designer
                    Actinic to SellerDeck upgrades
                    Graphicz Limited - www.graphicz.co.uk

                    Comment


                      #11
                      Your post #10 relies on PHP to make a calculation. This won't work on the Standard Search Result as that layout is used to create a single template that is is then applied to all search results. Any calculations made in that PHP will not be on a per-product basis.

                      Best thing to try would be to go back to my post #5 code and use unadulterated RRP and ProductPriceRaw.
                      Add an attribute data-tr1="<actinic:variable name="TaxRate1">" to the code added to your standard product layouts and Filtered Product Summary.
                      Then make the appropriate math changes in the bit of JavaScript to use the value in data-tr1 as part of the calculation.
                      A further complication is that Tax Rate 1 won't work in the Standard Search Result so you may have to hard-code it to the data-tr1 attribute there and hope it's the same for all products you sell.

                      Remember that any changes made need to work on Section Pages, Product Pages, Filtered Products (with / without filtering applied) and Search Results so a lot of testing is required.
                      Norman - www.drillpine.biz
                      Edinburgh, U K / Bitez, Turkey

                      Comment


                        #12
                        Thank you Norman. This current site uses inc vat for non account and exc vat for account so I can use a separate class for Notin2B: I have styled rrpsplash so have added a display none if RRP is empty/0.

                        Code:
                        $( "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);
                        }
                        else {
                        this.style.display = 'none';
                        }
                        });
                        $( "span.rrpsplashtic" ).each(function(){
                        var rrp = $(this).attr('data-rrp') - 0;
                        var rrptic = (rrp * 20 /100) + rrp;
                        var rawprice = $(this).attr('data-rawprice') / $(this).attr('data-scale');
                        var rawpricetic = (rawprice * 20 /100) + rawprice;
                        if ( (rrp > 0) && (rawprice > 0) && (rrp > rawprice) )
                        {
                        var saving = (rrptic - rawpricetic).toFixed(0);
                        $(this).html('Save<br />' + saving);
                        }
                        else {
                        this.style.display = 'none';
                        }
                        I will later work it out using the dynamic price layout [ eg ($g_bShowDynamicTaxInclusivePrice) and (!$g_bShowDynamicTaxInclusivePrice) ] as a guide for general use.

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

                        Comment


                          #13
                          Something like this to accomodate settings in buysiness settings entering prices as inc vat or exc vat
                          Code:
                          <script type="text/javascript">
                          function setrrp(){
                          $( "span.sryousave" ).each(function(){
                          var rrp = $(this).attr('data-rrp') - 0;
                          var rrptic = (rrp * 20 /100) + rrp;
                          var rawprice = $(this).attr('data-rawprice') / $(this).attr('data-scale');
                          var rawpricetic = (rawprice * 20 /100) + rawprice;
                          if ( (rrp > 0) && (rawprice > 0) && (rrp > rawprice) )
                          {
                          <actinic:block if="%21%3cactinic%3avariable%20name%3d%22IsTaxInclusiveMode%22%20%2f%3e" >
                          var saving = (rrp - rawprice).toFixed(0);
                          </actinic:block>
                          <actinic:block if="%3cactinic%3avariable%20name%3d%22IsTaxInclusiveMode%22%20%2f%3e" >
                          var saving = (rrptic - rawpricetic).toFixed(0);
                          </actinic:block>
                          $(this).html('RRP ' + rrp.toFixed(2) + ' You save ' + saving);
                          }
                          else {
                          this.style.display = 'none';
                          }
                          });
                          }
                          
                          // 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>
                          Jonathan Chappell
                          Website Designer
                          SellerDeck Website Designer
                          Actinic to SellerDeck upgrades
                          Graphicz Limited - www.graphicz.co.uk

                          Comment

                          Working...
                          X