|
1 | 1 | @using System.Text.Json |
| 2 | +@using Umbraco.Commerce.Checkout.Extensions |
2 | 3 | @inherits UmbracoViewPage |
3 | 4 | @{ |
4 | 5 | Layout = "UmbracoCommerceCheckoutLayout.cshtml"; |
5 | 6 |
|
6 | 7 | var store = Model.GetStore(); |
7 | 8 |
|
8 | 9 | var currentOrder = await UmbracoCommerceApi.Instance.GetCurrentOrderAsync(store.Id); |
| 10 | + var orderPropertyConfig = await UmbracoCommerceApi.Instance.GetOrderPropertyConfigAsync(store.Alias); |
| 11 | + |
| 12 | + var customer = currentOrder.GetCustomer(orderPropertyConfig); |
| 13 | + var billingAddress = currentOrder.GetBillingAddress(orderPropertyConfig); |
9 | 14 |
|
10 | 15 | var countries = await UmbracoCommerceApi.Instance.GetCountriesAsync(store.Id); |
11 | 16 |
|
|
43 | 48 |
|
44 | 49 | <h3 class="text-xl font-medium mb-4">@Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.ContactInformation", "Contact Information")</h3> |
45 | 50 | <input name="email" type="email" placeholder="@Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.Email", "Email")" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 w-full" |
46 | | - value="@(currentOrder.CustomerInfo.Email)" required /> |
| 51 | + value="@(currentOrder.CustomerInfo.Email.ValueOrFallback(customer.Email))" required /> |
47 | 52 | <label class="flex items-center mb-2 cursor-pointer"> |
48 | 53 | <input name="marketingOptIn" type="checkbox" value="true" class="mr-2" @Html.Raw(currentOrder.Properties["marketingOptIn"] == "1" ? "checked=\"checked\"" : "") /> @Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.MarketingOptIn", "Keep me up to date on news and exclusive offers") |
49 | 54 | </label> |
|
52 | 57 |
|
53 | 58 | <div class="flex -mx-1"> |
54 | 59 | <input name="billingAddress.Firstname" type="text" placeholder="@Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.FirstName", "First Name")" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 mx-1 w-full" |
55 | | - value="@(currentOrder.CustomerInfo.FirstName)" required /> |
| 60 | + value="@(currentOrder.CustomerInfo.FirstName.ValueOrFallback(customer.FirstName))" required /> |
56 | 61 | <input name="billingAddress.Lastname" type="text" placeholder="@Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.LastName", "Last Name")" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 mx-1 w-full" |
57 | | - value="@(currentOrder.CustomerInfo.LastName)" required /> |
| 62 | + value="@(currentOrder.CustomerInfo.LastName.ValueOrFallback(customer.LastName))" required /> |
58 | 63 | </div> |
59 | 64 |
|
60 | 65 | <input name="billingAddress.Line1" type="text" placeholder="@Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.Address1", "Address (Line 1)")" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 w-full" |
61 | | - value="@(currentOrder.Properties["billingAddressLine1"])" required /> |
| 66 | + value="@(currentOrder.Properties.ValueOrFallback("billingAddressLine1", billingAddress.AddressLine1))" required /> |
62 | 67 | <input name="billingAddress.Line2" type="text" placeholder="@Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.Address2", "Address (Line 2)")" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 w-full" |
63 | | - value="@(currentOrder.Properties["billingAddressLine2"])" /> |
| 68 | + value="@(currentOrder.Properties.ValueOrFallback("billingAddressLine2", billingAddress.AddressLine2))" /> |
64 | 69 | <input name="billingAddress.City" type="text" placeholder="@Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.City", "City")" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 w-full" |
65 | | - value="@(currentOrder.Properties["billingCity"])" required /> |
| 70 | + value="@(currentOrder.Properties.ValueOrFallback("billingCity", billingAddress.City))" required /> |
66 | 71 |
|
67 | 72 | <div class="flex -mx-1"> |
68 | 73 | <select name="billingAddress.Country" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 mx-1 w-full" required> |
|
82 | 87 | <select name="billingAddress.Region" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 mx-1 w-full disabled:hidden" |
83 | 88 | data-value="@currentOrder.PaymentInfo.RegionId" data-placeholder="@Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.SelectRegion", "-- Select a Region --")" required disabled></select> |
84 | 89 | <input name="billingAddress.ZipCode" type="text" placeholder="@Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.ZipCode", "Postcode")" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 mx-1 w-full" |
85 | | - value="@(currentOrder.Properties["billingZipCode"])" required /> |
| 90 | + value="@(currentOrder.Properties.ValueOrFallback("billingZipCode", billingAddress.ZipCode))" required /> |
86 | 91 | </div> |
87 | 92 | <input name="billingAddress.Telephone" type="text" placeholder="@Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.Telephone", "Phone")" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 w-full" |
88 | | - value="@(currentOrder.Properties["billingTelephone"])" /> |
89 | | - |
90 | | - if (checkoutPage.Value<bool>("uccCollectShippingInfo")) |
91 | | - { |
92 | | - <label class="flex items-center mb-2 cursor-pointer"> |
93 | | - <input name="shippingSameAsBilling" type="checkbox" class="mr-2" value="true" @Html.Raw(currentOrder.Properties["shippingSameAsBilling"] == "1" || !currentOrder.Properties.ContainsKey("shippingSameAsBilling") ? "checked=\"checked\"" : "") /> @Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.ShippingSameAsBilling", "Shipping address is same as billing address") |
| 93 | + value="@(currentOrder.Properties.ValueOrFallback("billingTelephone", customer.Telephone))" /> |
| 94 | + |
| 95 | + if (checkoutPage.Value<bool>("uccCollectShippingInfo")) |
| 96 | + { |
| 97 | + var shippingAddress = currentOrder.GetShippingAddress(orderPropertyConfig); |
| 98 | + |
| 99 | + <label class="flex items-center mb-2 cursor-pointer"> |
| 100 | + <input name="shippingSameAsBilling" type="checkbox" class="mr-2" value="true" @Html.Raw(currentOrder.Properties["shippingSameAsBilling"] == "1" || !currentOrder.Properties.ContainsKey("shippingSameAsBilling") ? "checked=\"checked\"" : "") /> @Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.ShippingSameAsBilling", "Shipping address is same as billing address") |
94 | 101 | </label> |
95 | 102 |
|
96 | 103 | <div id="shipping-info" class="hidden"> |
|
99 | 106 |
|
100 | 107 | <div class="flex -mx-1"> |
101 | 108 | <input name="shippingAddress.Firstname" type="text" placeholder="@Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.FirstName", "First Name")" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 mx-1 w-full" |
102 | | - value="@(currentOrder.Properties["shippingFirstName"])" required /> |
| 109 | + value="@(currentOrder.Properties.ValueOrFallback("shippingFirstName", customer.FirstName))" required /> |
103 | 110 | <input name="shippingAddress.Lastname" type="text" placeholder="@Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.LastName", "Last Name")" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 mx-1 w-full" |
104 | | - value="@(currentOrder.Properties["shippingLastName"])" required /> |
| 111 | + value="@(currentOrder.Properties.ValueOrFallback("shippingLastName", customer.LastName))" required /> |
105 | 112 | </div> |
106 | 113 |
|
107 | 114 | <input name="shippingAddress.Line1" type="text" placeholder="@Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.Address1", "Address (Line 1)")" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 w-full" |
108 | | - value="@(currentOrder.Properties["shippingAddressLine1"])" required /> |
| 115 | + value="@(currentOrder.Properties.ValueOrFallback("shippingAddressLine1", shippingAddress.AddressLine1))" required /> |
109 | 116 | <input name="shippingAddress.Line2" type="text" placeholder="@Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.Address2", "Address (Line 2)")" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 w-full" |
110 | | - value="@(currentOrder.Properties["shippingAddressLine2"])" /> |
| 117 | + value="@(currentOrder.Properties.ValueOrFallback("shippingAddressLine2", shippingAddress.AddressLine2))" /> |
111 | 118 | <input name="shippingAddress.City" type="text" placeholder="@Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.City", "City")" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 w-full" |
112 | | - value="@(currentOrder.Properties["shippingCity"])" required /> |
| 119 | + value="@(currentOrder.Properties.ValueOrFallback("shippingAddressLine2", shippingAddress.City))" required /> |
113 | 120 |
|
114 | 121 | <div class="flex -mx-1"> |
115 | 122 | <select name="shippingAddress.Country" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 mx-1 w-full" required> |
|
129 | 136 | <select name="shippingAddress.Region" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 mx-1 w-full disabled:hidden" |
130 | 137 | data-value="@currentOrder.ShippingInfo.RegionId" data-placeholder="@Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.SelectRegion", "-- Select a Region --")" required disabled></select> |
131 | 138 | <input name="shippingAddress.ZipCode" type="text" placeholder="@Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.ZipCode", "Postcode")" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 mx-1 w-full" |
132 | | - value="@(currentOrder.Properties["shippingZipCode"])" required /> |
| 139 | + value="@(currentOrder.Properties.ValueOrFallback("shippingZipCode", shippingAddress.ZipCode))" required /> |
133 | 140 | </div> |
134 | 141 | <input name="shippingAddress.Telephone" type="text" placeholder="@Umbraco.GetDictionaryValueOrDefault("UmbracoCommerceCheckout.Information.Telephone", "Phone")" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 w-full" |
135 | | - value="@(currentOrder.Properties["shippingTelephone"])" /> |
| 142 | + value="@(currentOrder.Properties.ValueOrFallback("shippingTelephone", customer.Telephone))" /> |
136 | 143 |
|
137 | 144 | </div> |
138 | 145 | } |
|
0 commit comments