Skip to content

Commit

Permalink
#1955 Added "Shipping by Total" functionality to "Shipping by Weight…
Browse files Browse the repository at this point in the history
…" plugin

Upgrade instructions: do not forget to manually delete
"/Plugins/Shipping.FixedOrByWeight" directory (it's not used anymore) and replace the plugin
«Shipping.FixedOrByWeight» by the plugin
«Shipping.FixedByWeightByTotal» in the App_Data/installedPlugins.json file.
  • Loading branch information
skoshelev committed Mar 23, 2018
1 parent f89d639 commit 1de4b26
Show file tree
Hide file tree
Showing 35 changed files with 775 additions and 401 deletions.
Expand Up @@ -4493,7 +4493,7 @@ protected virtual void InstallOrders()
ShippingStatus = ShippingStatus.NotYetShipped,
ShippingMethod = "Ground",
PickUpInStore = false,
ShippingRateComputationMethodSystemName = "Shipping.FixedOrByWeight",
ShippingRateComputationMethodSystemName = "Shipping.FixedByWeightByTotal",
CustomValuesXml = string.Empty,
VatNumber = string.Empty,
CreatedOnUtc = DateTime.UtcNow,
Expand Down Expand Up @@ -4660,7 +4660,7 @@ protected virtual void InstallOrders()
ShippingStatus = ShippingStatus.NotYetShipped,
ShippingMethod = "Next Day Air",
PickUpInStore = false,
ShippingRateComputationMethodSystemName = "Shipping.FixedOrByWeight",
ShippingRateComputationMethodSystemName = "Shipping.FixedByWeightByTotal",
CustomValuesXml = string.Empty,
VatNumber = string.Empty,
CreatedOnUtc = DateTime.UtcNow,
Expand Down Expand Up @@ -5132,7 +5132,7 @@ protected virtual void InstallOrders()
ShippingStatus = ShippingStatus.Delivered,
ShippingMethod = "Ground",
PickUpInStore = false,
ShippingRateComputationMethodSystemName = "Shipping.FixedOrByWeight",
ShippingRateComputationMethodSystemName = "Shipping.FixedByWeightByTotal",
CustomValuesXml = string.Empty,
VatNumber = string.Empty,
CreatedOnUtc = DateTime.UtcNow,
Expand Down Expand Up @@ -6336,7 +6336,7 @@ protected virtual void InstallSettings(bool installSampleData)

settingService.SaveSetting(new ShippingSettings
{
ActiveShippingRateComputationMethodSystemNames = new List<string> { "Shipping.FixedOrByWeight" },
ActiveShippingRateComputationMethodSystemNames = new List<string> { "Shipping.FixedByWeightByTotal" },
ActivePickupPointProviderSystemNames = new List<string> { "Pickup.PickupInStore" },
ShipToSameAddress = true,
AllowPickUpInStore = true,
Expand Down
2 changes: 1 addition & 1 deletion src/NopCommerce.sln
Expand Up @@ -53,7 +53,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nop.Plugin.ExchangeRate.Ecb
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nop.Plugin.Pickup.PickupInStore", "Plugins\Nop.Plugin.Pickup.PickupInStore\Nop.Plugin.Pickup.PickupInStore.csproj", "{06C88D0B-A276-4D3D-8BE5-7C58BF3072E3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nop.Plugin.Shipping.FixedOrByWeight", "Plugins\Nop.Plugin.Shipping.FixedOrByWeight\Nop.Plugin.Shipping.FixedOrByWeight.csproj", "{560768D4-7E1D-4431-99F0-CC14C255E167}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nop.Plugin.Shipping.FixedByWeightByTotal", "Plugins\Nop.Plugin.Shipping.FixedByWeightByTotal\Nop.Plugin.Shipping.FixedByWeightByTotal.csproj", "{560768D4-7E1D-4431-99F0-CC14C255E167}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nop.Plugin.Tax.FixedOrByCountryStateZip", "Plugins\Nop.Plugin.Tax.FixedOrByCountryStateZip\Nop.Plugin.Tax.FixedOrByCountryStateZip.csproj", "{493761CB-5190-4283-8C6C-A8CEB5450CAB}"
EndProject
Expand Down

Large diffs are not rendered by default.

@@ -1,15 +1,15 @@
using System.Data.Entity;
using Nop.Core.Infrastructure;

namespace Nop.Plugin.Shipping.FixedOrByWeight.Data
namespace Nop.Plugin.Shipping.FixedByWeightByTotal.Data
{
public class EfStartUpTask : IStartupTask
{
public void Execute()
{
//It's required to set initializer to null (for SQL Server Compact).
//otherwise, you'll get something like "The model backing the 'your context name' context has changed since the database was created. Consider using Code First Migrations to update the database"
Database.SetInitializer<ShippingByWeightObjectContext>(null);
Database.SetInitializer<ShippingByWeightByTotalObjectContext>(null);
}

public int Order
Expand Down
Expand Up @@ -4,18 +4,18 @@
using System.Data.Entity.Infrastructure;
using Nop.Core;
using Nop.Data;
using Nop.Plugin.Shipping.FixedOrByWeight.Domain;
using Nop.Plugin.Shipping.FixedByWeightByTotal.Domain;

namespace Nop.Plugin.Shipping.FixedOrByWeight.Data
namespace Nop.Plugin.Shipping.FixedByWeightByTotal.Data
{
/// <summary>
/// Object context
/// </summary>
public class ShippingByWeightObjectContext : DbContext, IDbContext
public class ShippingByWeightByTotalObjectContext : DbContext, IDbContext
{
#region Ctor

public ShippingByWeightObjectContext(string nameOrConnectionString)
public ShippingByWeightByTotalObjectContext(string nameOrConnectionString)
: base(nameOrConnectionString)
{
//((IObjectContextAdapter) this).ObjectContext.ContextOptions.LazyLoadingEnabled = true;
Expand All @@ -27,11 +27,11 @@ public ShippingByWeightObjectContext(string nameOrConnectionString)

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Configurations.Add(new ShippingByWeightRecordMap());
modelBuilder.Configurations.Add(new ShippingByWeightByTotalRecordMap());

//disable EdmMetadata generation
//modelBuilder.Conventions.Remove<IncludeMetadataConvention>();
base.OnModelCreating(modelBuilder);
base.OnModelCreating(modelBuilder);
}

#endregion
Expand Down Expand Up @@ -65,7 +65,7 @@ public void Install()
public void Uninstall()
{
//drop the table
var tableName = this.GetTableName<ShippingByWeightRecord>();
var tableName = this.GetTableName<ShippingByWeightByTotalRecord>();
//var tableName = "ShippingByWeight";
this.DropPluginTable(tableName);
}
Expand Down Expand Up @@ -130,11 +130,11 @@ public virtual bool ProxyCreationEnabled
{
get
{
return this.Configuration.ProxyCreationEnabled;
return Configuration.ProxyCreationEnabled;
}
set
{
this.Configuration.ProxyCreationEnabled = value;
Configuration.ProxyCreationEnabled = value;
}
}

Expand All @@ -145,11 +145,11 @@ public virtual bool AutoDetectChangesEnabled
{
get
{
return this.Configuration.AutoDetectChangesEnabled;
return Configuration.AutoDetectChangesEnabled;
}
set
{
this.Configuration.AutoDetectChangesEnabled = value;
Configuration.AutoDetectChangesEnabled = value;
}
}

Expand Down
@@ -0,0 +1,16 @@
using Nop.Data.Mapping;
using Nop.Plugin.Shipping.FixedByWeightByTotal.Domain;

namespace Nop.Plugin.Shipping.FixedByWeightByTotal.Data
{
public partial class ShippingByWeightByTotalRecordMap : NopEntityTypeConfiguration<ShippingByWeightByTotalRecord>
{
public ShippingByWeightByTotalRecordMap()
{
this.ToTable("ShippingByWeightByTotal");
this.HasKey(x => x.Id);

this.Property(x => x.Zip).HasMaxLength(400);
}
}
}
@@ -1,11 +1,11 @@
using Nop.Core;

namespace Nop.Plugin.Shipping.FixedOrByWeight.Domain
namespace Nop.Plugin.Shipping.FixedByWeightByTotal.Domain
{
/// <summary>
/// Represents a shipping by weight record
/// </summary>
public partial class ShippingByWeightRecord : BaseEntity
public partial class ShippingByWeightByTotalRecord : BaseEntity
{
/// <summary>
/// Gets or sets the store identifier
Expand Down Expand Up @@ -38,14 +38,24 @@ public partial class ShippingByWeightRecord : BaseEntity
public int ShippingMethodId { get; set; }

/// <summary>
/// Gets or sets the "from" value
/// Gets or sets the "Weight from" value
/// </summary>
public decimal From { get; set; }
public decimal WeightFrom { get; set; }

/// <summary>
/// Gets or sets the "to" value
/// Gets or sets the "Weight to" value
/// </summary>
public decimal To { get; set; }
public decimal WeightTo { get; set; }

/// <summary>
/// Gets or sets the "Order subtotal from" value
/// </summary>
public decimal OrderSubtotalFrom { get; set; }

/// <summary>
/// Gets or sets the "Order subtotal to" value
/// </summary>
public decimal OrderSubtotalTo { get; set; }

/// <summary>
/// Gets or sets the additional fixed cost
Expand Down

0 comments on commit 1de4b26

Please sign in to comment.