Error creating new shipping method

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 years ago
I created a new shipping method, and it keeps throwing an error in ShippingManager.cs at

IShippingRateComputationMethod iShippingRateComputationMethod = Activator.CreateInstance(Type.GetType(activeShippingRateComputationMethod.ClassName)) as IShippingRateComputationMethod;


I have verified that activeShippingRateComputationMethod.ClassName is set to "Nop.Shipping.MGGShip.ShippingByMGG, Nop.Shipping.MGGShip"

Which I believe is the proper setting. In an effort to eliminate something in the code itself, I copied the Freeshipping module. Below is the code I am using, this is in a new project called Nop.Shipping.MGGShip


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NopSolutions.NopCommerce.Common;
using NopSolutions.NopCommerce.Common.Shipping;

namespace Nop.Shipping.MGGShip
{
    public class ShippingByMGG : IShippingRateComputationMethod
    {
        #region Methods

        /// <summary>
        ///  Gets available shipping options
        /// </summary>
        /// <param name="ShipmentPackage">Shipment package</param>
        /// <param name="Error">Error</param>
        /// <returns>Shipping options</returns>
        public ShippingOptionCollection GetShippingOptions(ShipmentPackage ShipmentPackage, ref string Error)
        {
            ShippingOptionCollection shippingOptions = new ShippingOptionCollection();

            if (ShipmentPackage == null)
                throw new ArgumentNullException("ShipmentPackage");
            if (ShipmentPackage.Items == null)
                throw new NopException("No shipment items");

            ShippingMethodCollection shippingMethods = ShippingMethodManager.GetAllShippingMethods();
            foreach (ShippingMethod shippingMethod in shippingMethods)
            {
                ShippingOption shippingOption = new ShippingOption();
                shippingOption.Name = shippingMethod.Name;
                shippingOption.Description = shippingMethod.Description;
                shippingOption.Rate = decimal.Zero;
                shippingOptions.Add(shippingOption);
            }

            return shippingOptions;
        }

        /// <summary>
        /// Gets fixed shipping rate (if shipping rate computation method allows it and the rate can be calculated before checkout).
        /// </summary>
        /// <param name="ShipmentPackage">Shipment package</param>
        /// <returns>Fixed shipping rate; or null if shipping rate could not be calculated before checkout</returns>
        public decimal? GetFixedRate(ShipmentPackage ShipmentPackage)
        {
            return decimal.Zero;
        }
        #endregion
    }
}



If anyone can possibly help me out with this, it would be a HUGE help.

Thanks
JR
14 years ago
OK, after spending plenty of time banging my head against the wall, it occurred to me that I didn't add the reference in the NopCommerceStore project. It is now working as intended. and yes I feel like an idiot. :)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.