Commits

Michael Sumerano  committed 26b2ca8

Fixed HTML decoding issue with service names. Removing 1-Day and 2-Day text from service names.

  • Participants
  • Parent commits 741e7ee
  • Tags 1.0.3-nop.2.65

Comments (0)

Files changed (7)

File Nop.Plugin.Shipping.SeeSharpShipUsps/Controllers/ShippingSeeSharpShipUspsController.cs

 using System;
 using System.Collections.Generic;
+using System.Globalization;
 using System.Linq;
+using System.Web;
 using System.Web.Mvc;
 using Nop.Plugin.Shipping.SeeSharpShipUsps.Models;
 using Nop.Services.Configuration;
                 model.InternationalServices.Add(new USPSSelectableService
                 {
                     Id = int.Parse(service.Id),
-                    Name = service.FullName
+                    Name = GetModifiedServiceName(service.FullName)
                 });
             }
 
                 model.DomesticServices.Add(new USPSSelectableService
                 {
                     Id = int.Parse(service.Id),
-                    Name = service.FullName
+                    Name = GetModifiedServiceName(service.FullName)
                 });
             }
 
             SelectEnabledServices(enabledServicesCsv, model.DomesticServices);
         }
 
+        private static string GetModifiedServiceName(string service)
+        {
+            string serviceName = HttpUtility.HtmlDecode(service);
+            const char reg = (char)174;
+            const char trade = (char)8482;
+            serviceName = serviceName.Replace("<sup>®</sup>", reg.ToString(CultureInfo.InvariantCulture));
+            serviceName = serviceName.Replace("<sup>™</sup>", trade.ToString(CultureInfo.InvariantCulture));
+            serviceName = serviceName.Replace(" 1-Day", string.Empty);
+            serviceName = serviceName.Replace(" 2-Day", string.Empty);
+            return serviceName;
+        }
+
         private static void SelectEnabledServices(string enabledServicesCsv, IEnumerable<USPSSelectableService> availableServices)
         {
             enabledServicesCsv.Split(',')

File Nop.Plugin.Shipping.SeeSharpShipUsps/Description.txt

 Group: Shipping rate computation
 FriendlyName: SeeSharpShip USPS (US Postal Service)
 SystemName: Shipping.SeeSharpShipUsps
-Version: 1.02
+Version: 1.03
 SupportedVersions: 2.65
 Author: Michael J. Sumerano
 DisplayOrder: 1

File Nop.Plugin.Shipping.SeeSharpShipUsps/Nop.Plugin.Shipping.SeeSharpShipUsps.csproj

   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
-    <OutputPath>..\!CopyToPlugin\Nop.Plugin.Shipping.SeeSharpShipUsps\</OutputPath>
+    <OutputPath>..\!CopyToPlugin\Shipping.SeeSharpShipUsps\</OutputPath>
     <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
       <Private>False</Private>
     </Reference>
     <Reference Include="SeeSharpShip">
-      <HintPath>..\packages\SeeSharpShip.0.1.6.0\lib\net40\SeeSharpShip.dll</HintPath>
+      <HintPath>..\packages\SeeSharpShip.0.1.7.0\lib\net40\SeeSharpShip.dll</HintPath>
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />

File Nop.Plugin.Shipping.SeeSharpShipUsps/Properties/AssemblyInfo.cs

 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.2.*")]
-[assembly: AssemblyFileVersion("1.0.2.0")]
+[assembly: AssemblyVersion("1.0.3.*")]
+[assembly: AssemblyFileVersion("1.0.3.0")]
+[assembly: AssemblyInformationalVersion("1.0.3 nop-2.65")]

File Nop.Plugin.Shipping.SeeSharpShipUsps/USPSComputationMethod.cs

                         continue;
                     }
 
-                    string serviceName = GetDecodedServiceName(postage.MailService);
+                    string serviceName = GetModifiedServiceName(postage.MailService);
 
                     SpecialService insurance = postage.SpecialServices == null
                                                    ? null
                         continue;
                     }
 
-                    string serviceName = GetDecodedServiceName(service.SvcDescription);
+                    string serviceName = GetModifiedServiceName(service.SvcDescription);
 
                     ExtraService insurance = service.ExtraServices == null ? null : service.ExtraServices.FirstOrDefault(s => s.ServiceId == "1");
                     decimal rate = service.Postage + (insurance == null ? 0 : insurance.Price) + additionalHandlingCharge;
             return options;
         }
 
-        private static string GetDecodedServiceName(string service)
+        private static string GetModifiedServiceName(string service)
         {
             string serviceName = HttpUtility.HtmlDecode(service);
             const char reg = (char) 174;
             const char trade = (char) 8482;
-            serviceName = serviceName.Replace("<sup>&reg;</sup>", reg.ToString(CultureInfo.InvariantCulture));
-            serviceName = serviceName.Replace("<sup>&trade;</sup>", trade.ToString(CultureInfo.InvariantCulture));
+            serviceName = serviceName.Replace("<sup>®</sup>", reg.ToString(CultureInfo.InvariantCulture));
+            serviceName = serviceName.Replace("<sup>™</sup>", trade.ToString(CultureInfo.InvariantCulture));
+            serviceName = serviceName.Replace(" 1-Day", string.Empty);
+            serviceName = serviceName.Replace(" 2-Day", string.Empty);
             return serviceName;
         }
 

File Nop.Plugin.Shipping.SeeSharpShipUsps/Views/ShippingSeeSharpShipUsps/Configure.cshtml

                 @Html.NopLabelFor(model => model.BaseDomesticServices):
             </td>
             <td class="adminData">
-                <div style="height: 250px; width: 300px; overflow: auto; border: solid 1px #bbb;">
+                <div style="height: 250px; width: 200px; overflow: auto; border: solid 1px #bbb;">
                     @foreach (var service in Model.BaseDomesticServices)
                     {
                         <input type="checkbox" name="CheckedBaseDomesticServices" value="@(service.Id)" @(service.IsChecked ? Html.Raw(" checked=\"checked\"") : null) />
                 @Html.NopLabelFor(model => model.DomesticServices):
             </td>
             <td class="adminData">
-                <div style="height: 250px; width: 300px; overflow: auto; border: solid 1px #bbb;">
+                <div style="height: 250px; width: 440px; overflow: auto; border: solid 1px #bbb;">
                     @foreach (var service in Model.DomesticServices)
                     {
                         <input type="checkbox" name="CheckedDomesticServices" value="@(service.Id)" @(service.IsChecked ? Html.Raw(" checked=\"checked\"") : null) />
                 @Html.NopLabelFor(model => model.BaseInternationalServices):
             </td>
             <td class="adminData">
-                <div style="height: 250px; width: 300px; overflow: auto; border: solid 1px #bbb;">
+                <div style="height: 250px; width: 200px; overflow: auto; border: solid 1px #bbb;">
                     @foreach (var service in Model.BaseInternationalServices)
                     {
                         <input type="checkbox" name="CheckedBaseInternationalServices" value="@(service.Id)" @(service.IsChecked ? Html.Raw(" checked=\"checked\"") : null) />
                 @Html.NopLabelFor(model => model.InternationalServices):
             </td>
             <td class="adminData">
-                <div style="height: 250px; width: 300px; overflow: auto; border: solid 1px #bbb;">
+                <div style="height: 250px; width: 400px; overflow: auto; border: solid 1px #bbb;">
                     @foreach (var service in Model.InternationalServices)
                     {
                         <input type="checkbox" name="CheckedInternationalServices" value="@(service.Id)" @(service.IsChecked ? Html.Raw(" checked=\"checked\"") : null) />

File Nop.Plugin.Shipping.SeeSharpShipUsps/packages.config

 <?xml version="1.0" encoding="utf-8"?>
 <packages>
-  <package id="SeeSharpShip" version="0.1.6.0" targetFramework="net40" />
+  <package id="SeeSharpShip" version="0.1.7.0" targetFramework="net40" />
 </packages>