Forum

The forum is a free service supported by community members. Please consider opening a support ticket if you need timely help.

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 14 Feb 2023 03:42 AM by  Michael Tyson
Attribute Exclude Role
 3 Replies
Sort:
You are not authorized to post a reply.
Author Messages


New Member


Posts:49
New Member


--
13 Feb 2023 09:31 PM

    We are currently using this code to include a role in shipping availability and it works ok
    in/user/roles[role = 'Trade'] 

    We cannot get the code to work excluding a role for the same shipping availability.
    in/user/roles[role != 'Trade']

    Is this not possible or does the not equal option != not work in this situation.

    Thank you

    0


    Veteran Member


    Posts:2951
    Veteran Member


    --
    13 Feb 2023 09:37 PM

    If you're trying to test if the user does NOT have a particular role, you can use:

    not(in/user/roles/role = 'Trade')

    0


    New Member


    Posts:49
    New Member


    --
    13 Feb 2023 11:14 PM

    Thank you Steve

    I just tried this and it did not exlude trade users. We have 2 customer types Everyday customers and Trade customers.

    We have given trade the Trade role

    We do not want our everydau customers to see the Shipping methods that are for Trade

    Here is the full Availability code to exclude Trade Customers.   It it still showing for reguiar and trade. 

    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
      <xsl:template match="/">
        <out>
          <allowed>
            <xsl:choose>
              <!--                                                                                                   Test if Australia
                                                                                                      -->
              <xsl:when test="not(in/user/roles/role = 'Trade') and in/salesOrder/subTotalAmount &gt; 27.27 and in/salesOrder/shippingCountryCode = 'AU' and in/salesOrder/shippingSubdivisionCode = 'AU-SA' and (in/salesOrder/shippingPostalCode = '5000' or in/salesOrder/shippingPostalCode = '5006')">true</xsl:when>
              <xsl:otherwise>false</xsl:otherwise>
            </xsl:choose>
          </allowed>
        </out>
      </xsl:template>
    </xsl:transform>

    0


    New Member


    Posts:49
    New Member


    --
    14 Feb 2023 03:42 AM

    Hi Steve

    I have it working  not(in/user/roles[role  = 'Trade'])   I had to add the [] Brackets like the original.

    Thank you your sugguestion got me to the right solution

    0
    You are not authorized to post a reply.