Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Victor Bjørholm 58 posts 180 karma points
    Jan 20, 2021 @ 10:33
    Victor Bjørholm
    0

    Retrieve States from Model.Order or Model.Country

    Hi Matt, I am currently in the process of fixing my shipping email. I noticed quickly that I did not have a filed of the state of the buyer, in case the buyer was located in the US.

    However I could not find any info about where I can get the State from the Model.Order or Model.Country.. I tried searching for it in the documentation to no avail. I also tried some things like what can be seen below. Everything is working, except the "State".

    @Model.Order.Properties[info + "City"]<br />
    @Model.Order.Properties[info + "ZipCode"]<br />
    @Model.Order.Properties[info + "State"]<br />
    @Model.Country.Name<br />
    

    Thanks in advance

    Victor

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jan 20, 2021 @ 10:39
    Matt Brailsford
    0

    Hi Victor,

    For "States" you'll want to use the Region feature of Vendr. Regions are defined within a Country in the back office and can be retrieved from the ICountryService along with the countries. You'll want to render the Region dropdown much the same way as the country dropdown and then store it's value in the shipping infos RegionId property.

    Hope this helps

    Matt

  • Victor Bjørholm 58 posts 180 karma points
    Jan 20, 2021 @ 10:56
    Victor Bjørholm
    0

    Hi Matt, Im not sure if I understand what you are suggesting.

    When using the Vendr Checkout Package I am now able to select a state when choosing the US as country. I just need to be able to retrieve the selected state when sending the email. I am already able to retrieve all the other data in the form, but I am having some difficulties retrieving this one

    As can be seen on the picture. Picture of layout

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jan 20, 2021 @ 11:01
    Matt Brailsford
    100

    Hi Victor,

    Sure, and the Vendr Checkout uses Vendr Regions for State handling. So both shipping and billing info on the order object have a CountryId and a RegionId, where in the US the RegionId relates to a State.

    To get the state in your email template, you'll need to get the region from the Vendr API

    var region = VendrApi.Instance.GetRegion(Model.ShippingInfo.RegionId.Value);
    

    then render it's name like you do the country

    @region.Name
    

    Matt

  • Victor Bjørholm 58 posts 180 karma points
    Jan 20, 2021 @ 21:17
    Victor Bjørholm
    1

    Hi Matt, Thanks a lot. Got it fixed now :D

Please Sign in or register to post replies

Write your reply to:

Draft