Announcement

Collapse
No announcement yet.

Need help with conditional on result of custom order field

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

    Need help with conditional on result of custom order field

    Hello forum:
    I have a custom order field "invoicedate" that I am reading with this:
    <mvt:item name="customfields" param="Read_Order(l.settings:order:id, 'invoicedate',l.settings:invoice_date )" />
    in my shipment notification email. This conditional:
    <mvt:if expr="NOT ISNULL l.settings:invoice_date">
    is returning true when the custom field is empty.

    Why?

    Thanks, Larry
    Larry
    Luce Kanun Web Design
    www.facebook.com/wajake41
    www.plus.google.com/116415026668025242914/posts?hl=en



    #2
    Re: Need help with conditional on result of custom order field

    Found the problem. The custom order variable that was read was not null. Appears that it contains one or more spaces even thjough nothing was keyed into it. Used trim() function: <mvt:assign name="l.settings:invoicedate value="trim(l.settings:invoicedate" />
    to remove spaces and now the variable tests true for null.
    Nasty bug?
    Larry
    Last edited by wajake41; 06-25-15, 09:11 PM.
    Larry
    Luce Kanun Web Design
    www.facebook.com/wajake41
    www.plus.google.com/116415026668025242914/posts?hl=en


    Comment


      #3
      Re: Need help with conditional on result of custom order field

      hmm.. I though that should work. Is it possible there is a space in the value that is being saved?

      Instead of NOT ISNULL try checking to see if it is empty string by using two single quotes

      Code:
      <mvt:if expr="l.settings:invoice_date NE '' ">
      
      </mvt:if>
      Brennan Heyde
      VP Product
      Miva, Inc.
      [email protected]
      https://www.miva.com

      Comment


        #4
        Re: Need help with conditional on result of custom order field

        Hi Brennan: I'm puzzled too. The custom fields in question are being displayed/updated in the custom field link on the shipping confirmation email template. We have several custom order fields, but on that page we are only updating some of them, the others are left unchanged or blank. The update button on the dialog processes all of the custom fields, updating all those that have been changed I believe.
        Last night, using the dashboard, I viewed the custom fields on one of the orders having the problem, expecting to possibly see that some rows had been added with only spaces in the value. Not so, only the custom fields having a value were there.

        When reading a order custom field that has no value (.i.e doesn't exist on the OrderValues table), when I dump the variables on the page, I see that the variable isn't defined. How does a check for ISNULL operate if used against a variable that isn't defined?

        Anyway the trim() function solves the problem so on to other things.
        Larry
        Last edited by wajake41; 06-26-15, 07:13 AM.
        Larry
        Luce Kanun Web Design
        www.facebook.com/wajake41
        www.plus.google.com/116415026668025242914/posts?hl=en


        Comment


          #5
          Re: Need help with conditional on result of custom order field

          band aids come off and the cut gets infected. always best to fix the problem. what Brennan is suggesting is that you might have something like <input type="text" name="customField" value=" " /> which will give g.customField a value of 'space' instead of null.
          Bruce Golub
          Phosphor Media - "Your Success is our Business"

          Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
          phosphormedia.com

          Comment

          Working...
          X