Announcement

Collapse
No announcement yet.

Adding RRP & % saving

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

    Adding RRP & % saving

    I have searched this forum and found the below code to add rrp and the % saving.

    1) The problem I am getting an error message

    A PHP error has been found on the page ('Parse error: parse error in main on line 3') The error is coming from the 'Product Price Including Tax' layout. Click here to go to the code (2 places)

    When I click here it just highlights to block.

    What do I do to correct this error?


    2) I want to change the colour and size of the rrp (price) and Save xx% How do I do that? i figured that this would need to be changed in the CSS but I wouldn't know where.



    <actinic:block php="true">

    $rrp = <actinic:variable name="RRP" selectable="false" />;

    $rawprice = <actinic:variable name="ProductPriceRaw" selectable="false" />;

    $rawprice = $rawprice * 1.0; // add in vat if showing VAT inc prices

    // only display is we have an RRP and there's a saving to show if ( ($rrp != 0) && ($rrp > $rawprice) )
    {

    $savepercent = round((($rrp - $rawprice) / $rrp) * 100);

    echo "<strike>RRP: £$rrp</strike> | Save $savepercent%!";

    }

    </actinic:block>

    #2
    Originally posted by tristam View Post

    Code:
    <actinic:block php="true">
    
    $rrp = <actinic:variable name="RRP" selectable="false" />;
    
    $rawprice = <actinic:variable name="ProductPriceRaw" selectable="false" />;
    
    $rawprice = $rawprice * 1.0; // add in vat if showing VAT inc prices
    
    // only display is we have an RRP and there's a saving to show if ( ($rrp != 0) && ($rrp > $rawprice) )
    {
    
    $savepercent = round((($rrp - $rawprice) / $rrp) * 100);
    
    echo "<strike>RRP: £$rrp</strike> | Save $savepercent%!";
    
    }
    
    </actinic:block>
    If you are displaying the code correctly then the error is in the line
    Code:
    // only display is we have an RRP and there's a saving to show if ( ($rrp != 0) && ($rrp > $rawprice) )
    This needs to be split into two lines as currently the code that is required is commented out

    Code:
    // only display is we have an RRP and there's a saving to show 
    
    if ( ($rrp != 0) && ($rrp > $rawprice) )
    Split the line into two as shown.


    As for the css you need to look for the <div> enclosing this code and find out if it has a class then use the css for that class

    Alternatively you could put a span around the output from the PHP and add a style to the <span>

    Code:
    echo "<span style=\"color: red;\"><strike>RRP: £$rrp</strike> | Save $savepercent%!</span>";
    Note the escape characters inside the echo statement to prevent quotation marks of the style upsetting the PHP code.

    Malcolm

    SellerDeck Accredited Partner,
    SellerDeck 2016 Extensions, and
    Custom Packages

    Comment


      #3
      Thanks Malcolm

      Just sussed the error. In the instructions I had followed it said set the variable to text type and it should have been number and this now works.

      Thanks for the help with the CSS

      Comment


        #4
        Just one more thing now that this is working.

        I would also like to put the rrp and save xx% on the product filter pages. I have added this code but it just tells me

        ProductPriceRaw won't work on Standard Search Results layout.

        Also a Parse error on line 5 which is </p>

        Comment


          #5
          Search Results are generated from a template layout and a set of JavaScript data. This data only contains a subset of all the product fields and ProductPriceRaw isn't one of them.

          While it is possible to display user vars - check Upload in their definition and use e.g:
          Code:
          <actinic:variable searchresultvariable="true" name="RRP" />
          To get at the price, you could use JavaScript / jQuery to scan each search result DIV and extract the displayed price (put a span with a class-name around the price). You could use a similar span around the RRP and a dummy place-holder span to hold the computed result. Run the jQuery on document ready as these results are loaded dynamically and inline JavaScript may not work.
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment

          Working...
          X