nop ver 1.90: I implemented a "Minimum Shipping Fee":Works Great except that it defeates the Free Shipping Option set in the Product Varant record!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
I originally posted this in the General Support Forum; but JonEvans thought that I should try it here for truly technical support!

ORIGINAL POSTING LINKS:
https://www.nopcommerce.com/boards/t/17450/nop-ver-190-i-implemented-a-minimum-shipping-fee-but-have-2-side-effects-i-need-help-to-fix.aspx
https://www.nopcommerce.com/boards/t/17554/nop-ver-190-i-implemented-a-minimum-shipping-fee-fixed-display-problem-only-free-shipping-remains.aspx

I tested all possible states and it is rock solid - except my implementation so far defeates the Free Shipping Option set in the Product Varant record!

_______________________________________________________________________________
//  OrderServices.cs                //shipping total
                //sets Min Shipping Fee var to $7,95 USD  JTD
                decimal? orderShippingMinFee = 7.95m;

                    orderShippingTotalInclTax = shippingService.GetShoppingCartShippingTotal(cart, customer, true, out taxRate, out shippingTotalDiscount, ref shippingTotalError1);
                    //sets Min Shipping Fee if under $7.95 USD  JTD
                    orderShippingTotalExclTax = shippingService.GetShoppingCartShippingTotal(cart, customer, false, ref shippingTotalError2);
                    if (orderShippingTotalExclTax < orderShippingMinFee)
                        orderShippingTotalExclTax = orderShippingMinFee;
                    if (!orderShippingTotalInclTax.HasValue || !orderShippingTotalExclTax.HasValue)
                        throw new NopException("Shipping total couldn't be calculated");
                    if (shippingTotalDiscount != null && !appliedDiscounts.ContainsDiscount(shippingTotalDiscount.Name))
                        appliedDiscounts.Add(shippingTotalDiscount);

                    //in customer currency
                    orderShippingInclTaxInCustomerCurrency = currencyService.ConvertCurrency(orderShippingTotalInclTax.Value, currencyService.PrimaryStoreCurrency, paymentInfo.CustomerCurrency);
                    orderShippingExclTaxInCustomerCurrency = currencyService.ConvertCurrency(orderShippingTotalExclTax.Value, currencyService.PrimaryStoreCurrency, paymentInfo.CustomerCurrency);

_______________________________________________________________________________  
//  ShoppingCartServices.cs -- gets SC shipping & use Resulttemp to add to tax reduce by discount and create OrderToTal  

            decimal? shoppingCartShipping = IoC.Resolve<IShippingService>().GetShoppingCartShippingTotal(cart, customer, false, ref shippingError);
            //sets Min Shipping Fee var to $7,95 USD  JTD
            decimal? orderShippingMinFee = 7.95m;
            if (shoppingCartShipping < orderShippingMinFee)
                shoppingCartShipping = orderShippingMinFee;
_______________________________________________________________________________


// CheckoutShippingMethod.ascx.cs

      //sets Min Shipping Fee var to $7,95 USD  JTD
            decimal orderShippingMinFee = 7.95m;
            if (shippingTotalWithDiscount < orderShippingMinFee)
                shippingTotalWithDiscount = (decimal)orderShippingMinFee;


_______________________________________________________________________________
//  OrderTotals.ascx.cs

decimal? shoppingCartShippingBase = this.ShippingService.GetShoppingCartShippingTotal(cart, NopContext.Current.User);
                    // SET MIN SHIPPING FEE AT THIS POINT JTD
                    decimal orderShippingMinFee = 7.95m;
                    if (shoppingCartShippingBase < orderShippingMinFee)
                        shoppingCartShippingBase = (decimal)orderShippingMinFee;

                    if (shoppingCartShippingBase.HasValue)
                    {
                        decimal shoppingCartShipping = this.CurrencyService.ConvertCurrency(shoppingCartShippingBase.Value, this.CurrencyService.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                        lblShippingAmount.Text = PriceHelper.FormatShippingPrice(shoppingCartShipping, true);
                        lblShippingAmount.CssClass = "productPrice";
_______________________________________________________________________________



The limited implementation defeats the "Free Shipping Option" set in  the Product Varant record. A compound IF statement may be able to correct this problem but I can not find the right interface?

I have found at path (SEE BELOW) to explore to get the Free Shipping Bool Flag to use in a compound IF to defeats the Min Ship Fee Code if the Flag is true; BUT without even a System Diagram it is really a shot the dark; I noticed that in response to AM post a programmer pointed him to a page the  has System Details for Ver 2.00 an up! -- Anybody know if the is such a great page for Ver 1.90 users???

_______________________________________________________________________________
//  OrderSummary.ascx.cs

//   public string GetProductVariantName(ShoppingCartItem shoppingCartItem)
       // {
       //     var productVariant = shoppingCartItem.ProductVariant;
       //     if (productVariant != null)
       //         return productVariant.LocalizedFullProductName;
       //     return "Not available";
       // }
_______________________________________________________________________________

WARNING: BEFORE ANYBODY TRIES TO IMPLEMENT THE MIN SHIPPING FEE; I HAVE THE STOREMAX WEB SITE SET TO USA LOCATIONS ONLY AND ONLY USD CURRENCY -- OTHER SETTINGS MAY AFFECT THE IMPLEMENTATION IN CODE!

I hope that someone has implementated a "Minimum Shipping Fee" before in ver 1.90 and will see a likeness in the code modification shown above, because I think they are correct in so for as they go.

I don't know if it if OK to post a small reward to induce a user with knowledge to help me out on a tough one like this?
11 years ago
I am not able to help, but have you by any chance done something similar with nop 2.x? I have been looking for minimum shipping fee for quite some time.
11 years ago
NO! I AM SORRY AND I AM WEB FORMS GUY - DON'T HAVE WEB MATRIX KNOWHOW!
11 years ago
So, do you want a minimal fee for every shiiping, Is it true?
11 years ago
Solved?
11 years ago
Works?
11 years ago
There is an enhancement (comming in 2.7) in 'Shipping by weight' that provides a minimum cost
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.