Announcement

Collapse
No announcement yet.

Display "Price 'from':" when more than 1 choice for a given product...

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

    Display "Price 'from':" when more than 1 choice for a given product...

    Hi,

    We have our products set up like this:


    Product:
    Component (Permutations point to Hidden Products below)
    Attribute
    Choice #1
    Choice #2
    [Hidden Product #1]
    [Hidden Product #2]


    Some products [only] have 1 hidden product. We also have products without Components/Attributes...

    What I'm trying to achieve is this:

    Products with NO components/Choices to say:

    Price: £1.00

    Products with a single Choice to say:

    Price: £1.00

    Products with [multiple] choices to say:

    Price from: £1.00

    So, what I am doing, in the Standard Tax Inclusive Price template, is looping through the AttributeList/ChoicesList counting up the number of choices... The code works fine and successfully displays the correct text. However, I then get a 'Coding Error' on the selector 'Product Price Including Tax' saying the 'variables won't work there' and don't get to see the price!

    This is the complete code from 'Standard Tax Inclusive Price':

    <actinic:block PHP='true' SELECTABLE='false'>
    $g_bShowDynamicTaxInclusivePrice = true;
    $g_bShowDynamicTaxMessage = true;
    $g_bShowDynamicTaxExclusivePrice = false;
    </actinic:block>
    <h3 class="productPrice">
    <actinic:block if="%3cactinic%3avariable%20name%3d%22PriceIsEnabled%22%20%2f%3e%20AND%20%28%3cactinic%3avariable%20name%3d%22ProductPriceRaw%22%20%2f%3e%20%21%3d%200%29" >

    <!-- START: My new code -->
    <!-- If Count of 'Choices' greater than 1 - display "Price from:"... -->
    <actinic:block php="true" type="ComponentList" if="%3cactinic%3avariable%20name%3d%22ProductComponentCount%22%20%2f%3e%3e0" >
    $nAttributeCount = 0;
    $priceText = '<actinic:variable name="ProductPriceDescription" />';
    <actinic:block type="AttributeList" >
    <actinic:block type="ChoiceList" >
    $nAttributeCount++;
    </actinic:block>
    </actinic:block>
    if ($nAttributeCount > 1) $priceText = $priceText.' from';
    $priceText = $priceText.': ';
    echo $priceText;
    </actinic:block>
    <actinic:block if="%3cactinic%3avariable%20name%3d%22ProductComponentCount%22%20%2f%3e%3d%3d0" ><actinic:variable name="ProductPriceDescription" />: </actinic:block>
    <!-- END: My new code -->

    <actinic:block if="%3cactinic%3avariable%20name%3d%22IsFirstQuantityBreak%22%20%2f%3e">
    <actinic:block if="%3cactinic%3avariable%20Name%3d%22QuantityDescMax%22%2f%3e%20%3d%3d%201">
    (<actinic:variable Name="QuantityDescMax"/> item)
    </actinic:block>
    <actinic:block if="%3cactinic%3avariable%20Name%3d%22QuantityDescMax%22%2f%3e%20%3e%201">
    (<actinic:variable Name="QuantityDescMax"/> or fewer items)
    </actinic:block>
    </actinic:block>
    <actinic:block if="%3cactinic%3avariable%20name%3d%22IsMiddleQuantityBreak%22%20%2f%3e">
    (<actinic:variable Name="QuantityDescMin"/> to <actinic:variable Name="QuantityDescMax"/> items)
    </actinic:block>
    <actinic:block if="%3cactinic%3avariable%20name%3d%22IsLastQuantityBreak%22%20%2f%3e">
    (<Actinic:Variable Name="QuantityDescMin"/> or more items)
    </actinic:block>

    <actinic:variable name="PreFormattedPrice" value="Product Price Including Tax" />

    </h3>
    <actinic:block if="%3cactinic%3avariable%20name%3d%22IsTaxMessageShown%22%20%2f%3e">
    <span class="actxxsmall">
    (Including&nbsp;<actinic:block if="%3cactinic%3avariable%20name%3d%22IsTax1Used%22%20%2f%3e"><actinic:variable name="TaxName1"/> at <actinic:variable name="TaxRate1"/>%</actinic:block><actinic:block if="%3cactinic%3avariable%20name%3d%22IsTax1AndTax2Used%22%20%2f%3e"> and </actinic:block><actinic:block if="%3cactinic%3avariable%20name%3d%22IsTax2Used%22%20%2f%3e"><actinic:variable name="TaxName2"/> at <actinic:variable Name="TaxRate2"/>%</actinic:block>)<br/>
    </span>
    </actinic:block>
    </actinic:block>


    If I move the PHP block which displays 'Price From' to [after] the price it works without error but then of course, I don't want to see "£1.00 Price From"...

    Also, the code works 100% OK at section level, just not at product level..

    Just cannot work this out... or maybe I am using wrong Lists/wrong code?

    Any ideas?

    Cheers...

    KR

    Bill
    Bill

    HTML Code:
    <a href="www.spicesofindia.co.uk">www.spicesofindia.co.uk</a>

    #2
    The way I would attempt to this would be to create a new variable, say "Price From" which I would allow to have a blank value at product level.

    On the price layout, after the text "Price" I would add the word "From" wrapped in a blockif to check if the contents of the variable "Price From" had an input at product level.

    No input would not display the word From, if an input has been made then it will show the word From.

    Then at product level just enter the text yes (or anything) as there is an input in the box it will force the word From to be displayed.

    I am however sure someone will give you an easier code version, this is just how I would tackle it.
    Regards

    Jason

    Titan Jewellery (Swift Design)
    Zirconium Rings
    Damascus Steel Rings

    Comment


      #3
      Thanks Buzby for your reply- much appreciated.

      However, your solution is a 'manual' one and fraught with danger if users forget to set the Price Prompt for individual products. We also have 5,000+ products which makes the initial implementation a very time consuming task.

      What I am looking for is a 'Dynamic' solution...one based on real-time data...
      Bill

      HTML Code:
      <a href="www.spicesofindia.co.uk">www.spicesofindia.co.uk</a>

      Comment


        #4
        I've taken a look but to be honest I absolutely hate trying to debug code other people have written because there's just so much work involved. It's much more effort than writing your own bit of code because you have to understand the code they've written, why they've used certain variables, how they're trying to fit it into the rest of the system and then figure out why it's not working.

        If the error warning depends on where the code is placed then the first thing I'd try is placing the code in the template before the standard price layout is called.

        Mike
        -----------------------------------------

        First Tackle - Fly Fishing and Game Angling

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

        Comment


          #5
          Thanks for taking a look Mike. Yes, I understand, debugging someone elses code is never nice! ;-)

          I've got the *problem* down to something even simpler:

          Why would adding this 2-line BlockIf statement to 'Standard Tax Inclusive Price' cause 'Coding Errors' in 'Product Price Including Tax'??

          HTML Code:
          	<actinic:block php="true" type="ComponentList" if="%3cactinic%3avariable%20name%3d%22ProductComponentCount%22%20%2f%3e%3e0" > 
          	</actinic:block>
          If these two lines are added AFTER the 'Product Price Including Tax' Layout - no problem! But I need to have these two lines BEFORE that Layout...

          Or, am I being completely *thick*?! (Go on, be blunt! ;-)
          Bill

          HTML Code:
          <a href="www.spicesofindia.co.uk">www.spicesofindia.co.uk</a>

          Comment


            #6
            Try replacing the compound statement above with 3 separate nested blocks. With the PHP as the inner block.
            Norman - www.drillpine.biz
            Edinburgh, U K / Bitez, Turkey

            Comment


              #7
              Thanks Norman for your thoughts... appreciated :-)

              I broke it out into 3 separate Blocks, as suggested, but the 'Coding Errors' still appear.

              In fact the coding errors appear when i simplify the block to just this:

              HTML Code:
              <actinic:block type="ComponentList" ></actinic:block>
              Perhaps ComponentList is not accessible within 'Standard Tax Inclusive Price'??

              Although I can successfully Loop through and PHP 'Echo' debug information...

              Now, if i change the list 'type' to AttributeList or other - I do not get any coding errors (although it doesn't help me achieve my purpose! ;-)
              Bill

              HTML Code:
              <a href="www.spicesofindia.co.uk">www.spicesofindia.co.uk</a>

              Comment


                #8
                Perhaps ComponentList is not accessible within 'Standard Tax Inclusive Price'??
                It wouldn't surprise me which is why I suggested you try putting the code outside of the standard price layout.

                Mike

                PS. It's probably not so much that ComponentList isn't accessible, more that whoever decides these things didn't mark the price list layouts as someplace where it should be used. Hence the error warning.
                -----------------------------------------

                First Tackle - Fly Fishing and Game Angling

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

                Comment


                  #9
                  Indeed! You are quite correct Mike! THANKS :-)

                  How bloody ludicrous! Why can't the lists be available at the point where one requires use of them?!

                  Thanks again...
                  Bill

                  HTML Code:
                  <a href="www.spicesofindia.co.uk">www.spicesofindia.co.uk</a>

                  Comment

                  Working...
                  X