Announcement

Collapse
No announcement yet.

I need help to write a mvt:if statement please

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

    I need help to write a mvt:if statement please

    1. Please look at: http://perthsms.com.au/mm5/merchant.mvc?
    2. click on DANGER
    3. click on Add To Cart
    4. make a selection (just one please)
    5. click on Continue

    You will see that all the materials you did not select are listed in the basket contents (BASK) and display "NOT-SELECTED" next to the Attribute code.

    I think I need to write a <MVT:if ...> statement along the lines that if the value of the Attribute code is "NOT-SELECTED" then don't print the line - or - perhpas there is some other way of doing this?

    I would appreciate your help and advice.

    Many thanks, James

    PS, I think I tidied up the CSS formatting for this page quite nicely, don't you? (the textarea was hughe, width:100%, and the drop down boxes were all different sizes).

    #2
    Re: I need help to write a mvt:if statement please

    Try something like this?

    Code:
    <mvt:if expr="NOT('NOT-SELECTED' CIN l.settings:option:opt_code">
    <mvt:if expr="l.settings:option:option_id">
    &mvt:option:attr_code;: &mvt:option:opt_code;
    <mvt:elseif expr="NOT ISNULL l.settings:option:data">
    &mvt:option:attr_code;: &mvt:option:data;
    <mvt:elseif expr="NOT ISNULL l.settings:option:data_logn">
    &mvt:option:attr_code;: &mvt:option:data_logn;
    <mvt:else>
    &mvt:option:attr_code;
    </mvt:if>
    </mvt:if>

    Comment


      #3
      Re: I need help to write a mvt:if statement please

      In BASK > Basket contents, I put your code here:

      <mvt:foreach iterator="option" array="item:options">
      <tr class="item-options">
      <td class="item-remove">&nbsp;</td>
      <td class="item-description">
      <mvt:if expr="NOT('NOT-SELECTED' CIN l.settings:option:opt_code">
      <mvt:if expr="l.settings:option:option_id">
      &mvt:option:attr_code;: &mvt:option:opt_code;
      <mvt:elseif expr="NOT ISNULL l.settings:option:data">
      &mvt:option:attr_code;: &mvt:option:data;
      <mvt:elseif expr="NOT ISNULL l.settings:option:data_logn">
      &mvt:option:attr_code;: &mvt:option:data_logn;
      <mvt:else>
      &mvt:option:attr_code;
      </mvt:if>
      </mvt:if>
      </td>
      <td class="item-quantity">&nbsp;</td>
      <td class="item-price">
      <mvt:if expr="l.settings:option:price">
      &mvt:option:formatted_price;
      <mvt:else>
      &nbsp;
      </mvt:if>
      </td>

      and when I ran my page it produced this error message:

      Fatal error in /mm5/5.00/templates/s01/bask-basket.mvc @ [00000002:00000444]: Line 51: Stack underflow

      I have obvioulsy put it in the wrong place.

      James

      Comment


        #4
        Re: I need help to write a mvt:if statement please

        Sorry about the smileys - the "o"s and ":"s got converted to faces

        Comment


          #5
          Re: I need help to write a mvt:if statement please

          Stand by ... I think Imight have sorted it. I think there might be a typo in your code. Please see the ends of lines 6&7 where you have typed "data_logn" ... I think it should be "data_long".

          I will try it and let you know

          James

          Comment


            #6
            Re: I need help to write a mvt:if statement please

            Unfortunately I still get and error:

            Fatal error in /mm5/5.00/templates/s01/bask-basket.mvc @ [00000002:00000444]: Line 52: Stack underflow

            James

            Comment


              #7
              Re: I need help to write a mvt:if statement please

              I have done it! - you wonderful person!!!

              Apart from the typo: "logn" instead of "long", there was a bracket missing from the first line of your code, immediately before "CIN":

              <mvt:if expr="NOT('NOT-SELECTED' CIN l.settings|ption|pt_code">

              (can't find where to turn smileys off in a "quick reply" so I have repaced ":" with "|")

              "Basket contents" now only shows the details selected ... however... it still includes a blank line where the details would otherwise be. Please have a look at:

              http://perthsms.com.au/mm5/merchant....tore_Code=PSMS

              >DANGER
              >Add to Cart
              >Select one (suggest one from Luminous Materials)
              >Type in the words you want on the sign in textarea at bottom of list
              >Click the Continue button

              You will also notice, as i just did, that the WORDS attribute is now missing - the words the customer wanted put on this blank sign used to appear as the last item in the Basket Contents. Whether I make WORDS an ATTRIBUTE or and Attribute TEMPLATE, since it uses textarea for its input I cannot include "NOT-SELECTED" in it ... how can we get your IF statement to allow WORDS to be included in the basket?

              Many thanks, James
              Last edited by James Elliott; 11-20-09, 04:36 PM. Reason: getting rid of smileys

              Comment


                #8
                Re: I need help to write a mvt:if statement please

                Originally posted by Leanne View Post
                Try something like this?

                Code:
                <mvt:if expr="NOT('NOT-SELECTED' CIN l.settings:option:opt_code">
                <mvt:if expr="l.settings:option:option_id">
                &mvt:option:attr_code;: &mvt:option:opt_code;
                <mvt:elseif expr="NOT ISNULL l.settings:option:data">
                &mvt:option:attr_code;: &mvt:option:data;
                <mvt:elseif expr="NOT ISNULL l.settings:option:data_logn">
                &mvt:option:attr_code;: &mvt:option:data_logn;
                <mvt:else>
                &mvt:option:attr_code;
                </mvt:if>
                </mvt:if>
                To Summarise:
                Now you have helped me with the above code and, after correcting a couple of typos, that code to works, I now need to:

                1. get rid of all the blank lines (see earlier post)
                2. get my WORDS attribute to display again.


                If you can help again, I will be most grateful.

                Many thanks, James

                Comment


                  #9
                  Re: I need help to write a mvt:if statement please

                  Sorry for the typo. I'm good at that. Please post your full current code for the page. To post it without smilies, click Go Advanced below and uncheck the box that says to enable smilies, or post it between code tags.

                  Comment


                    #10
                    Re: I need help to write a mvt:if statement please

                    Originally posted by Leanne View Post
                    Sorry for the typo. I'm good at that. Please post your full current code for the page. To post it without smilies, click Go Advanced below and uncheck the box that says to enable smilies, or post it between code tags.
                    Hi Leanne,

                    Here is the code you requested

                    Code:
                    <div id="basket-contents" class="editable">
                        <mvt:if expr="l.settings:basket:empty">
                        Your shopping basket is currently empty.<br /><br />
                        <a href="&mvt:global:sessionurl;Screen=SFNT&amp;Store_Code=&mvte:store:code;">Home</a>
                        <mvt:exit />
                        </mvt:if>
                        <table>
                            <tr id="basket-heading">
                                <td class="item-remove">&nbsp;</td>
                                <td class="item-description">Product Code</td>
                                <td class="item-quantity">Qty.</td>
                                <td class="item-price">Unit Price</td>
                                <td class="item-total">Total Price</td>
                            </tr>
                        <mvt:foreach iterator="item" array="basket:items">
                            <tr>
                                <td class="item-remove">
                                    <form method="post" action="&mvt:global:sessionurl;">
                                        <div>
                                            <input type="hidden" name="Screen" value="BASK" />
                                            <input type="hidden" name="Action" value="RPRD" />
                                            <input type="hidden" name="Store_Code" value="&mvte:global:Store_Code;" />
                                            <input type="hidden" name="Basket_Line" value="&mvte:item:line_id;" />
                                            <mvt:item name="buttons" param="Remove" />
                                        </div>
                                    </form>
                                </td>
                                <td class="item-description">
                                    <div class="item-name">&mvt:item:name; <mvt:if expr="l.settings:item:upsold">(Special Offer)</mvt:if></div>
                                    <div class="item-code"><a href="&mvt:global:sessionurl;Screen=PROD&amp;Store_Code=&mvta:global:Store_Code;&amp;Product_Code=&mvta:item:code;">&mvt:item:code;</a></div>
                                </td>
                                <td class="item-quantity">
                                    <form method="post" action="&mvt:global:sessionurl;">
                                        <div>
                                            <input type="hidden" name="Screen" value="BASK" />
                                            <input type="hidden" name="Action" value="QNTY" />
                                            <input type="hidden" name="Store_Code" value="&mvte:global:Store_Code;" />
                                            <input type="hidden" name="Basket_Line" value="&mvte:item:line_id;" />
                                            <input type="text" name="Quantity" class="shadow_input basket-qty-input small" value="&mvt:item:quantity;" />
                                            <mvt:item name="buttons" param="Update" />
                                        </div>
                                    </form>
                                </td>
                                <td class="item-price">&mvt:item:formatted_price;</td>
                                <td class="item-total">&mvt:item:formatted_subtotal;</td>
                            </tr>
                            <mvt:foreach iterator="option" array="item:options">
                            <tr class="item-options">
                                <td class="item-remove">&nbsp;</td>
                                <td class="item-description">
                                    <mvt:if expr="NOT('NOT-SELECTED') CIN     
                                        l.settings:option:opt_code">
                                    <mvt:if expr="l.settings:option:option_id">
                                    &mvt:option:attr_code;: &mvt:option:opt_code;
                                    <mvt:elseif expr="NOT ISNULL l.settings:option:data">
                                    &mvt:option:attr_code;: &mvt:option:data;
                                    <mvt:elseif expr="NOT ISNULL l.settings:option:data_long">
                                    &mvt:option:attr_code;: &mvt:option:data_long;
                                    <mvt:else>
                                    &mvt:option:attr_code;
                                    </mvt:if>
                                    </mvt:if>
                                </td>
                                <td class="item-quantity">&nbsp;</td>
                                <td class="item-price">
                                    <mvt:if expr="l.settings:option:price">
                                    &mvt:option:formatted_price;
                                    <mvt:else>
                                    &nbsp;
                                    </mvt:if>
                                </td>
                                <td class="item-total">
                                    <mvt:if expr="l.settings:option:price">
                                    &mvt:option:formatted_subtotal;
                                    <mvt:else>
                                    &nbsp;
                                    </mvt:if>
                                </td>
                            </tr>
                            </mvt:foreach>
                        </mvt:foreach>
                        <mvt:foreach iterator="charge" array="basket:charges">
                            <tr class="basket-charges">
                                <td colspan="3">&nbsp;</td>
                                <td class="charge-description">
                                    &mvt:charge:descrip;:
                                </td>
                                <td class="formatted-charge">
                                    &mvt:charge:formatted_disp_amt;
                                </td>
                            </tr>
                        </mvt:foreach>
                            <tr    id="basket-totals">
                                <td colspan="3">&nbsp;</td>
                                <td class="total-prompt">
                                    Total:
                                </td>
                                <td class="formatted-total">
                                    &mvt:basket:formatted_total;
                                </td>
                            </tr>
                        </table>
                        <div class="checkout-button"><input type="button" value="Checkout" onclick="window.location = '&mvt:global:secure_sessionurl;Screen=OINF&amp;Store_Code=&mvta:store:code;';" class="shadow_button" /></div>
                    </div>
                    Many thanks for your interest and help,
                    James

                    Comment


                      #11
                      Re: I need help to write a mvt:if statement please

                      All right. I moved the conditional to wrap the entire row, and adjusted it a little. When you fixed my typo, you placed the closing parenthesis in the wrong place. If that still doesn't work, let me know. Just as a side note, you've done a very nice job of clean coding, but I'd be cautious about using javascript on your checkout button. Not everyone will have javascript enabled, and you don't want to prevent people from checking out. You'd be better to use a plain text link and fancy it up with some css.

                      Code:
                      <div id="basket-contents" class="editable">
                          <mvt:if expr="l.settings:basket:empty">
                          Your shopping basket is currently empty.<br /><br />
                          <a href="&mvt:global:sessionurl;Screen=SFNT&amp;Store_Code=&mvte:store:code;">Home</a>
                          <mvt:exit />
                          </mvt:if>
                          <table>
                              <tr id="basket-heading">
                                  <td class="item-remove">&nbsp;</td>
                                  <td class="item-description">Product Code</td>
                                  <td class="item-quantity">Qty.</td>
                                  <td class="item-price">Unit Price</td>
                                  <td class="item-total">Total Price</td>
                              </tr>
                          <mvt:foreach iterator="item" array="basket:items">
                              <tr>
                                  <td class="item-remove">
                                      <form method="post" action="&mvt:global:sessionurl;">
                                          <div>
                                              <input type="hidden" name="Screen" value="BASK" />
                                              <input type="hidden" name="Action" value="RPRD" />
                                              <input type="hidden" name="Store_Code" value="&mvte:global:Store_Code;" />
                                              <input type="hidden" name="Basket_Line" value="&mvte:item:line_id;" />
                                              <mvt:item name="buttons" param="Remove" />
                                          </div>
                                      </form>
                                  </td>
                                  <td class="item-description">
                                      <div class="item-name">&mvt:item:name; <mvt:if expr="l.settings:item:upsold">(Special Offer)</mvt:if></div>
                                      <div class="item-code"><a href="&mvt:global:sessionurl;Screen=PROD&amp;Store_Code=&mvta:global:Store_Code;&amp;Product_Code=&mvta:item:code;">&mvt:item:code;</a></div>
                                  </td>
                                  <td class="item-quantity">
                                      <form method="post" action="&mvt:global:sessionurl;">
                                          <div>
                                              <input type="hidden" name="Screen" value="BASK" />
                                              <input type="hidden" name="Action" value="QNTY" />
                                              <input type="hidden" name="Store_Code" value="&mvte:global:Store_Code;" />
                                              <input type="hidden" name="Basket_Line" value="&mvte:item:line_id;" />
                                              <input type="text" name="Quantity" class="shadow_input basket-qty-input small" value="&mvt:item:quantity;" />
                                              <mvt:item name="buttons" param="Update" />
                                          </div>
                                      </form>
                                  </td>
                                  <td class="item-price">&mvt:item:formatted_price;</td>
                                  <td class="item-total">&mvt:item:formatted_subtotal;</td>
                              </tr>
                              <mvt:foreach iterator="option" array="item:options">
                      		  
                      		  <mvt:comment>Don't show options if the code is 'not-selected'</mvt:comment>
                      		  <mvt:if expr="NOT('NOT-SELECTED' CIN l.settings:option:opt_code)">
                              <tr class="item-options">
                                  <td class="item-remove">&nbsp;</td>
                                  <td class="item-description">
                                      <mvt:if expr="l.settings:option:option_id">
                                      &mvt:option:attr_code;: &mvt:option:opt_code;
                                      <mvt:elseif expr="NOT ISNULL l.settings:option:data">
                                      &mvt:option:attr_code;: &mvt:option:data;
                                      <mvt:elseif expr="NOT ISNULL l.settings:option:data_long">
                                      &mvt:option:attr_code;: &mvt:option:data_long;
                                      <mvt:else>
                                      &mvt:option:attr_code;
                                      </mvt:if>
                                  </td>
                                  <td class="item-quantity">&nbsp;</td>
                                  <td class="item-price">
                                      <mvt:if expr="l.settings:option:price">
                                      &mvt:option:formatted_price;
                                      <mvt:else>
                                      &nbsp;
                                      </mvt:if>
                                  </td>
                                  <td class="item-total">
                                      <mvt:if expr="l.settings:option:price">
                                      &mvt:option:formatted_subtotal;
                                      <mvt:else>
                                      &nbsp;
                                      </mvt:if>
                                  </td>
                              </tr>
                      		  </mvt:if> <mvt:comment> End don't show not-selected options</mvt:comment>
                              </mvt:foreach>
                          </mvt:foreach>
                          <mvt:foreach iterator="charge" array="basket:charges">
                              <tr class="basket-charges">
                                  <td colspan="3">&nbsp;</td>
                                  <td class="charge-description">
                                      &mvt:charge:descrip;:
                                  </td>
                                  <td class="formatted-charge">
                                      &mvt:charge:formatted_disp_amt;
                                  </td>
                              </tr>
                          </mvt:foreach>
                              <tr    id="basket-totals">
                                  <td colspan="3">&nbsp;</td>
                                  <td class="total-prompt">
                                      Total:
                                  </td>
                                  <td class="formatted-total">
                                      &mvt:basket:formatted_total;
                                  </td>
                              </tr>
                          </table>
                          <div class="checkout-button"><input type="button" value="Checkout" onclick="window.location = '&mvt:global:secure_sessionurl;Screen=OINF&amp;Store_Code=&mvta:store:code;';" class="shadow_button" /></div>
                      </div>

                      Comment


                        #12
                        Re: I need help to write a mvt:if statement please

                        Originally posted by Leanne View Post
                        Sorry for the typo. I'm good at that. Please post your full current code for the page. To post it without smilies, click Go Advanced below and uncheck the box that says to enable smilies, or post it between code tags.
                        I posted the code for the full page some time ago now, as requested. Is it a bigger problem than you first thought?

                        Regards, James

                        Comment


                          #13
                          Re: I need help to write a mvt:if statement please

                          Look above this post for my response.

                          Comment


                            #14
                            Re: I need help to write a mvt:if statement please

                            Originally posted by Leanne View Post
                            Look above this post for my response.
                            Thanks for that. I'm sorry I missed it the first time you sent it. I was away for a while and then, when I checked, must have thought it was code from previous exchanges.

                            I have copied it into the BASK contents page and it works a treat - thank you.

                            I still have zero dollars and zero cents showing, the base price of each sign (prices are in the Attributes). I presume i would e easy to have the price not print if Price=0? ... but I am not sure how to code that.

                            My checkout page still shows "NOT-SELECTED" for all of the Attributes, other than the one selected. However, I will study your BASK code and see if I can adapt it to the Checkout page, assuming I can find the Checkout page, that is.

                            Many thanks for all your help.

                            James

                            Comment


                              #15
                              Re: I need help to write a mvt:if statement please

                              Hi again Leanne

                              You wrote: "I'd be cautious about using JavaScript on your checkout button. Not everyone will have JavaScript enabled, and you don't want to prevent people from checking out. You'd be better to use a plain text link and fancy it up with some css".

                              Actually, I did not add any JavaScript to the code. It must have been there in the cssfw module I was sent by Chuck Lasker. I have not used JavaScript since my uni days (graduated in 2003). I have been meaning to revise JS and start using it again, but from wha tyou say, perhaps it is not such a bad thing not to?

                              Perhaps if you would be kind enough to point out where the JavaScript is, I can do something about removing or replacing it.

                              Once again, many thanks

                              James

                              Comment

                              Working...
                              X