using Nop.Core.Domain.Shipping; using Nop.Services.Plugins; using Nop.Services.Shipping; using Nop.Services.Shipping.Tracking; namespace Nop.Tests.Nop.Services.Tests.Shipping; public class FixedRateTestShippingRateComputationMethod : BasePlugin, IShippingRateComputationMethod { private decimal GetRate() { var rate = 10M; return rate; } /// /// Gets available shipping options /// /// A request for getting shipping options /// Represents a response of getting shipping rate options public Task GetShippingOptionsAsync(GetShippingOptionRequest getShippingOptionRequest) { ArgumentNullException.ThrowIfNull(getShippingOptionRequest); var response = new GetShippingOptionResponse(); response.ShippingOptions.Add(new ShippingOption { Name = "Shipping option 1", Description = string.Empty, Rate = GetRate() }); response.ShippingOptions.Add(new ShippingOption { Name = "Shipping option 2", Description = string.Empty, Rate = GetRate() }); return Task.FromResult(response); } /// /// Gets fixed shipping rate (if shipping rate computation method allows it and the rate can be calculated before checkout). /// /// A request for getting shipping options /// Fixed shipping rate; or null in case there's no fixed shipping rate public Task GetFixedRateAsync(GetShippingOptionRequest getShippingOptionRequest) { ArgumentNullException.ThrowIfNull(getShippingOptionRequest); return Task.FromResult(GetRate()); } /// /// Get associated shipment tracker /// /// /// A task that represents the asynchronous operation /// The task result contains the shipment tracker /// public Task GetShipmentTrackerAsync() { return Task.FromResult(null); } }