Announcement

Collapse
No announcement yet.

Display Savings

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

    Display Savings

    Hi

    On one of my sites we list the RRP and our sales price and would like to display the difference of the two to illustrate savings. Obviously I can manually calculate it and put it in as a Custom Property for each product but it would be nice (and much much quicker) to be able to calculate it. Is it possible to create a small script to do this. We display this information at section level where the price and rrp are both custom properties and also on the product page where the rrp is a custom property and the price is input as normal less the VAT.

    Is this possible???

    Thanks in advance
    Steve
    www.laurenrose.co.uk
    www.shelovesdiamonds.co.uk
    www.gentsstuff.co.uk

    #2
    Hi Steve,

    I'm afraid that we cannot calculate the difference between the RRP and sale price automatically.You need to manually calculate the difference between the two and display it using the CUSTOMVAR.

    Regards,
    Sumiya

    Comment


      #3
      A bit of JavaScript can probably do that. Can you point me to an example page?
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment


        #4
        This is a page I have manually calculated.

        http://www.shelovesdiamonds.co.uk/ac...ire_Rings.html

        if this is possible it would save me a huge amount of work.

        Thanks
        Steve
        www.laurenrose.co.uk
        www.shelovesdiamonds.co.uk
        www.gentsstuff.co.uk

        Comment


          #5
          I presume the RRP comes from a CUSTOMVAR. What do you have in these Customvar's? E.g. just 123.45, £123.45 or RRP £123.45, etc.
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment


            #6
            I have a CUSTOMVAR called RRP and put £65.00 into the field including the £ sign. The text that says RRP is hard coded into the template.
            Steve
            www.laurenrose.co.uk
            www.shelovesdiamonds.co.uk
            www.gentsstuff.co.uk

            Comment


              #7
              Try this
              Code:
              Displaying the Saving between Product price and CUSTOMVAR:RRP
              
              
              INSTALLATION
              
              
              Go to Advanced / Custom Properties and create a Custom Property called RRP
              
              
              
              Put the following into Act_ProductPrice.html - below the top comments
              
              
              <script language=JavaScript>
              <!--
              setcost('NETQUOTEVAR:COST'); 
              // -->
              </script>
              
              
              
              Put the following into Act_Primary.html just above the </HEAD> line
              
              
              <script language=JavaScript>
              <!--
              var cost = 0;
              
              function to2digits(num){					// return 2 decimal digits string of number
                var whole = Math.floor(num);                			// no of pounds
                var fraction = Math.round((num - whole) * 100);  		// Number of Fraction (2 decimal places)
                if ( fraction > 99 ) fraction = 99;
                var res = (fraction < 10) ? "0" + fraction.toString() : fraction.toString();  // make 2 digits
                return(whole.toString() + '.' + res);
              }
              
              function makenum(value){
                value = value.replace(/&#38;#44;/g, "");                  	// strip url encoded commas
                value = value.replace(/,/g, "");                      	// strip vanilla flavour commas
                var val = value.match(/(\d*&#38;#46;\d\d)/);			// deal with multi-currency (look for 1st number only)
                if ( val == null ) return 0;					// no match so return zero
                value = val[1].replace(/&#38;#46;/,".") - 0;			// the valid first number, restore decimal point
                return value;
              }
              
              function setcost(prodcost){					// save main product price
                cost = makenum(prodcost);
              }
              
              function showsaving(rrprice){
                var rrp = rrprice.replace(/£/,'');				// remove any £ sign
                if ( (rrp == '') || ( cost == 0) || cost >= rrp ) return;	// exit if no Cost or RRP or Saving
                var saving = rrp - cost;					// and calculate saving
                document.write('<font color=red><b>Save £' + to2digits(saving) + '</b></font>');	// display saving
              }
              // -->
              </script>
              
              
              
              
              Put this in your Product Template where you want the saving displayed
              (however it must be placed somewhere after NETQUOTEVAR:PRODUCTPRICE)
              
              
              
              <script language=JavaScript>
              <!--
              showsaving('CUSTOMVAR:RRP'); 
              // -->
              </script>
              Norman - www.drillpine.biz
              Edinburgh, U K / Bitez, Turkey

              Comment


                #8
                Thanks Norman, its not quiet calculating correctly though, I am not sure but I think its a decimal point out but I have had a play and cant get it correct.

                You can see it on this page:

                http://www.shelovesdiamonds.co.uk/ac...ng__010ct.html
                Steve
                www.laurenrose.co.uk
                www.shelovesdiamonds.co.uk
                www.gentsstuff.co.uk

                Comment


                  #9
                  Norman
                  Did you get chance to look at this as its so close to the solution I need.

                  Thanks
                  Steve
                  www.laurenrose.co.uk
                  www.shelovesdiamonds.co.uk
                  www.gentsstuff.co.uk

                  Comment


                    #10
                    Hi, Steve

                    The code worked here, but the forum mungied the JavaScript I'd posted (even though it's inside [ code ] and [ /code ] tags. I've amended post #7 above. It's the bit that goes into Act_Primary.html that's been fixed.
                    Norman - www.drillpine.biz
                    Edinburgh, U K / Bitez, Turkey

                    Comment


                      #11
                      That works great, thanks. Is it possible to also use this at section level where I store the Price and RRP as CUSTOMVAR's ? This is an example page

                      http://www.shelovesdiamonds.co.uk/ac...ond_Rings.html
                      Steve
                      www.laurenrose.co.uk
                      www.shelovesdiamonds.co.uk
                      www.gentsstuff.co.uk

                      Comment


                        #12
                        Jam on it, eh!

                        Add this (untested) function into the Act_Primary code (just above the //--> line)
                        Code:
                        function sectsaving(rrprice, sellprice){
                          var cost = sellprice.replace(/£/,'');				// remove any £ sign
                          var rrp = rrprice.replace(/£/,'');				// remove any £ sign
                          if ( (rrp == '') || (cost == '') || cost >= rrp ) return;	// exit if no Cost or RRP or Saving
                          var saving = rrp - cost;					// and calculate saving
                          document.write('<font color=red><b>Save £' + to2digits(saving) + '</b></font>');	// display saving
                        }
                        Put this into your Section Template where you want the saving displayed.
                        Code:
                        <script language=JavaScript>
                        <!--
                        sectsaving('CUSTOMVAR:RRP', 'CUSTOMVAR:SELLPRICE'); 
                        // -->
                        </script>
                        and change CUSTOMVAR:SELLPRICE to the name you use.
                        Norman - www.drillpine.biz
                        Edinburgh, U K / Bitez, Turkey

                        Comment


                          #13
                          This works great, the only problem is if the RRP is greater that £1000 or the sale price is less than £100. Is there any way around this?

                          Examples here:

                          http://www.shelovesdiamonds.co.uk/ac..._Pendants.html

                          http://www.shelovesdiamonds.co.uk/ac...ity_Rings.html

                          Thanks for your time
                          Steve
                          www.laurenrose.co.uk
                          www.shelovesdiamonds.co.uk
                          www.gentsstuff.co.uk

                          Comment


                            #14
                            Sorry. This has taken up several hours of my time. I've no more free time to work on this.
                            Norman - www.drillpine.biz
                            Edinburgh, U K / Bitez, Turkey

                            Comment

                            Working...
                            X