Announcement

Collapse
No announcement yet.

Block If an productGroupID

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

    Block If an productGroupID

    Hi,
    I am trying to add am image next to the price of some products, but not others. This is to show which products are included in the “order total discount”. I need the image to appear next to items that belong to Product Group A but not Product Group B or unallocated products. I have tried to do this with a “Block If” but I am not sure how to apply this to a Product Group.

    I’ve tried productGroupID == “A” etc... but it’s clearly not as simple as that.
    ("A" is the name given in Marketing > Product Groups under Group Name)

    Code:
    <actinic:block if="%3cactinic%3avariable%20name%3d%22productGroupID%22%20%2f%3e%20%20%3d%3d%20%22A%22" >
    
    	<span class="actxxsmall">(<img alt="Info" title="Price with 15% discount applied" src="info.jpg">
    
    	<actinic:block php="true">
    	
    		$rawprice = <actinic:variable name="ProductPriceRaw" selectable="false" />;
    
    		{
    		  $savepercent = ROUND(($rawprice - $rawprice * 0.15), 2);
    		  echo " £$savepercent)";
    		  }
      
    		</actinic:block>
    
    	</span>
    
    </actinic:block>
    The attached image shows what I am trying to achieve.

    Thanks for any help.

    Lee
    Attached Files

    #2
    Using the GroupID variable would be my first port of call if trying this.

    Comment


      #3
      Block If and productGroupID

      Thanks leehack,

      I know the values assigned to productGroupID, but how do I find the value of GroupID to use in the block if?

      I’ve tried using productGroupID == “groupname” but this doesn’t allow the block to show for any groupname.

      If I use productGroupID == “” it shows for all product groups.

      I have got the image and the discounted price showing on the page as I want it – I just can’t stop it displaying for product where it is not relevant.

      Thanks

      Lee

      Comment


        #4
        Just add the variable GroupID into your product layout first and then on a product that you know is in the group in question, note the number that shows. You then remove it and do your evaluations using that number.

        Comment


          #5
          That sorted it.

          Thanks for the help leehack.

          Lee

          Comment


            #6
            Cool, nice lateral thinking too, think it's a great idea.

            For other uses of this, I'm thinking of 3 types of promotion on a site, let's say red, amber and green and each product is coloured to show in which offer it can be bought. That sounds pretty nifty to me.

            Comment


              #7
              If anyone else does use this...

              Improvement (I think) to the above code.

              replace

              PHP Code:
              $savepercent ROUND(($rawprice $rawprice 0.15), 2); 
              ...this drops any trailing zeros, so that £1.50 becomes £1.5

              with

              PHP Code:
              $savepercent number_format(($rawprice $rawprice 0.15), 2"."" "); 
              ...this shows all values to 2 decimal places

              I have very limited experience at coding , so please put me right if there are any problems with this.

              Cheers
              Lee

              Comment

              Working...
              X