Announcement

Collapse
No announcement yet.

Building a sum of product prices in a section

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

    Building a sum of product prices in a section

    I have section that contains Fragment, Product, Product, Product.

    Within this section is it possible, maybe through php, to pull each product price and total them for calling back in the fragment?
    Dave

    #2
    Assuming your products have a single price then try something like this in the Fragment Description.
    Code:
    !!<
    <actinic:block php="true">
    	$rtot = 0;
    	<actinic:block type="ProductList">
    		$rtot += <actinic:variable name="ProductPriceRaw" />;
    	</actinic:block>
    	$rtot *= 1.2;		// omit this line to display VAT exclusive prices
    	printf ('£%01.2f', $rtot);
    </actinic:block>
    >!!
    Your Fragment comes first so the code loops through all products.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      That's great Norman, thank you.

      Coincidentally part of this ties in with something else you helped me with. I use php to calculate the tax-rate based on the <actinic:variable name="TaxExclusivePrice" /> <actinic:variable name="TaxInclusivePrice" /> difference. Which is then used to change component prices to be inc VAT. The idea being that changing the overall tax-rate would see all the component prices update automatically. So in your above solution I have called that taxrate variable.

      I guess double thanks are in order!
      Dave

      Comment


        #4
        Hi again Norman,

        Can a similar method be used to return the product reference for each product on the page? I have tried a few variants but have failed to achieve anything but parse errors!

        --------EDIT BELOW---------

        Came up with this in the end

        HTML Code:
        <actinic:block php="true" >
        	<actinic:block type="ProductList" >
        	$refs = "<actinic:variable name="ProductReference" />";
        		if (is_numeric($refs))
        		{
        		echo "<br />";
        		}
        		else
        		{
        		echo ($refs . "<br />");
        		}
        	</actinic:block>
        </actinic:block>
        No being well versed in PHP if anyone has any suggestions for a cleaner code, it would be appreciated. The is_numeric statement is to remove fragments from the possible list.
        Dave

        Comment

        Working...
        X