Announcement

Collapse
No announcement yet.

Display "Prices from £X" in Section

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

    Display "Prices from £X" in Section

    Hi All,

    I had a search around but couldn't find what I'm trying to do, wonder if anyone could offer some help please.

    I wanted to show a price from in the section link, so for example on the following page: https://www.hookandloopfasteners.co....-on-rolls.html have each section box show the image, title and text bit as it does now but also then under that show the lowest price product inside that section as a "prices start at £"

    Any one got a trick to make that happen please?

    Thanks very much.
    Many Thanks
    Lee
    www.mdnsupplies.co.uk
    www.hookandloopfasteners.co.uk

    #2
    The only way I've found to do this kind of thing is to use an external script to run through the products in a section (or in this case several sections) and then write the lowest price to either a dummy product or a variable so it can be displayed.

    There has previously been some PHP code on the forum that can work with the database so that could be another way.

    Either way it's not an easy thing to do so it would be good to know if anyone knows of an easier way.

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

    First Tackle - Fly Fishing and Game Angling

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

    Comment


      #3
      Here's a bit of code I posted over 10 years ago. Updated below to deal with the possibility of paginated products.
      Code:
      <actinic:block php="true">
      	$min = 0;
      	$max = 0;
      	<actinic:block type="SectionEntireProductList">
      		if ( <actinic:variable name="ProductType" selectable="false" /> != 2 )
      			{
      			$prc = <actinic:variable name="ProductPriceRaw"/>;
      			if ( ($prc < $min) || ($min == 0) ) $min = $prc;
      			if ( $prc > $max ) $max = $prc;
      			}
      	</actinic:block>	
      	if ( $min != $max )
      		{
      		echo sprintf("From £%01.2f to £%01.2f", $min, $max);
      		}
      	elseif ( $min != 0 )
      		{
      		echo sprintf("£%01.2f", $min);
      		}
      </actinic:block>
      Amend to suit your requirements.
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment


        #4
        Norman, you are a star. thanks very much, drink on the way!
        Many Thanks
        Lee
        www.mdnsupplies.co.uk
        www.hookandloopfasteners.co.uk

        Comment


          #5
          Lee, many thanks for the "drink".

          Note that this tweak is for "simple" products only. I.e. those with a single price (or a list of quantity dependent prices)
          If you use quantity dependent prices then the following alternative code will deal with that:
          Code:
          <actinic:block php="true">
          	$min = 0;
          	$max = 0;
          	<actinic:block type="SectionEntireProductList">
          		if ( <actinic:variable name="ProductType" selectable="false" /> != 2 )
          			{
          			<actinic:block type="PriceList">
          				// use TaxInclusivePrice or TaxExclusivePrice because ProductPriceRaw fails in duplicates
          				$prc = preg_replace('/[^\d\.]/', '', '<actinic:variable name="TaxInclusivePrice" selectable="false" />');
          				if ( ($prc < $min) || ($min == 0) ) $min = $prc;
          				if ( $prc > $max ) $max = $prc;
          			</actinic:block>
          			}
          	</actinic:block>	
          	if ( $min != $max )
          		{
          		echo sprintf("From £%01.2f to £%01.2f", $min, $max);
          		}
          	elseif ( $min != 0 )
          		{
          		echo sprintf("£%01.2f", $min);
          		}
          </actinic:block>
          Note that you can change TaxInclusivePrice above to TaxExclusivePrice if you prefer ex VAT pricing.

          It won't deal with products where the price depends on selections being made.
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment


            #6
            Thank you Norman, perfect!
            Many Thanks
            Lee
            www.mdnsupplies.co.uk
            www.hookandloopfasteners.co.uk

            Comment

            Working...
            X