Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 13 of 13

Thread: Carrier HTML Link

  1. #1
    flammaaeterna is offline Member
    Join Date
    Sep 2006
    Posts
    58

    Default Carrier HTML Link

    I noticed after switching to 7.0.2.1 that sometimes the tracking number that we put in the tracking number field for orders became HTML links. However, it looks like not all of them are doing it. Is there a certain way they need to be formatted? What are the conditions for a link being generated for the tracking number?

    MJ

  2. #2
    msprague is offline Member
    Join Date
    Nov 2005
    Posts
    37

    Default

    The link is generated based on the ShippingTracking* AppConfigs.

    AppConfig ShippingTrackingCarriers lists the carriers to try and each carrier has a regular expression to match the entered tracking number and a corresponding URL in ShippingTrackingRegEx.* and ShippingTrackingURL.* respectively.

    You can take out the carriers you don't use from the ShippingTrackingCarriers list. You can add new carriers also by creating the corresponding regex and URL appconfigs and then adding the name to ShippingTrackingCarriers.

    The carrier for the URL is determined entirely be the RegEx match on the tracking number and does not use the value entered in the Carrier field for the order.

    If some of your tracking numbers are not getting turned in to links then the RegEx will need to be modified to catch those numbers. Feel free to share your new RegEx or ask for help with a sample tracking number to match and the carrier it goes with.
    / michael sprague /

  3. #3
    flammaaeterna is offline Member
    Join Date
    Sep 2006
    Posts
    58

    Default

    It seems that UPS is working ok, but the USPS Priority tracking numbers aren't. It appears that Express and International might be. Unfortunately, I'm not adept at translating the regular expression it is looking for:

    ^\d{22}|[0-9A-Z]{11}US$

    And if a USPS Priority TN is something like:

    0103 8555 7491 1503 1043

    The [0-9A-Z] would seem to cover it. So, ^[0-9A-Z]

    For Express, you would need to grab an 'EO' at the beginning, and for that and international, the 'US' at the end (or just get the US for both, and skip EO).

    I think that USPS Priority is not working, because it is looking for 'US' at the end? How would I change it to not require that?

    Perhaps: ^\d{22}|[0-9A-Z]{11}|US$

    Of course, that would seem to allow any alphanumeric tracking number.

    What do the \d, {22}, and {11} do?

    Thanks for the information.

    MJ

  4. #4
    msprague is offline Member
    Join Date
    Nov 2005
    Posts
    37

    Default

    To match "0103 8555 7491 1503 1043" as a USPS number you can add a match for 20 digits to the USPS regex, which would now become: ^\d{20}|\d{22}|[0-9A-Z]{11}US$
    This will match 20 digits, 22 digits, or 11 alphanumerics followed by US.

    Note: Spaces and hyphens are stripped from the tracking number before the regex is tested, so having spaces does not affect the resulting match.
    / michael sprague /

  5. #5
    flammaaeterna is offline Member
    Join Date
    Sep 2006
    Posts
    58

    Default

    Awesome. Thanks a lot for helping me out!

    MJ

  6. #6
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    Default

    These links are being created perfectly in the account page for the customer & in the admin, but they're not sent in the 'order shipped' email.

    Is there a simple modification to the xmlpackage to enable this?


    TTFN

    BFG

  7. #7
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    Default

    I was able to find the following code snippet in orderframe.aspx.cs (it's repreated in account.aspx.cs)

    C#/VB.NET Code:
                         String TrackURL Shipping.GetTrackingURL(DB.RSField(rs"ShippingTrackingNumber"));
                                        if (
    TrackURL.Length != 0)
                                        {
                                            
    ShippingStatus += "<a href=\"" TrackURL "\" target=\"_blank\">" DB.RSField(rs"ShippingTrackingNumber") + "</a>";
                                        } 
    I guess I need to figure out how to include this in an xmlpackage......

    Any help would be appreciated.


    TTFN

    BFG

  8. #8
    Jesse is offline Banned
    Join Date
    May 2008
    Posts
    1,329

    Default

    You can either add a method to the XSLTExtensionBase to gather that information (not recommended) or create a custom class to drop in the App_Code folder that calls that method and returns the result. After referencing the namespace and updating your web.config to point to it, you should be able to access it in your XMLPackages.

  9. #9
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    Default

    Hi Jesse,

    I'm not quite sure I understand?
    I need to create a custom class (which is a duplicate of an existing class) so I can use it within an xmlpackage?


    TTFN

    BFG

  10. #10
    Rex is offline Banned
    Join Date
    Nov 2007
    Posts
    561

    Default

    Check out this post on how to extend xml packages with your own class functions.

    http://forums.aspdotnetstorefront.co...ead.php?t=6907

  11. #11
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    Default

    Thanks Rex,

    I'd already read through that...
    I guess I'm just a little unsure (I'm not a C# or VB developer).

    It seems to me that the function already exists - it's used in the account page & the admin order page - is there no way of accessing an existing function from an xmlpackage?


    TTFN

    BFG

  12. #12
    jspatt2 is offline Junior Member
    Join Date
    Sep 2008
    Posts
    27

    Default Adding Tracking Link to Ship Confirmation Email

    I am just curious if anyone has done this and do you have to modify the XML file and if so where does this information come from?
    It adds the link when you review the order so it would make since
    that this should also be included in the ship confirmation email.
    Currently my ship confimation emails go out with the tracking number but not a link to the carriers tracking URL.

    Thank you,
    Joel Patterson

  13. #13
    akeller is offline Member
    Join Date
    Dec 2008
    Posts
    78

    Default

    @jspatt2

    I have done exactly what you are looking to do. First you will need to create your own extension function. I followed this tutorial to cannibalize the GetTrackingURL() function from the source. (http://forums.aspdotnetstorefront.co...ead.php?t=6907)

    Basically you will make your own extension function that the xml packages can use and throw it in the AppCode folder. Then you will get that tracking number that your xslt uses and pass it to the function you have created. Example

    Code:
     
    <xsl:variable name="tracknum" select="/root/Order/OrderInfo/ShippingTrackingNumber" />
    
    <xsl:variable name="trackingURL" select="myFunctions:GetTrackingURL($tracknum)" />
    My function outputs the tracking URL like it should, only does not handle multiple tracking numbers, which I am still trying to figure out if anyone would like to assist me.

    Just follow the tutorial. Make an extension function, add a reference in the web.config and use it in the notification.shipped.xml.config file.