1

私は noCommerce 1.9 を使用しており、コードの「HasOneOfTheseProductVarientsInTheCart」部分を次のように変更しました。

case DiscountRequirementEnum.HasOneOfTheseProductVariantsInTheCart:
    {
        if (customer != null)
        {
            CustomerSession customerSession = IoC.Resolve<ICustomerService>().GetCustomerSessionByCustomerId(customer.CustomerId);
            if (customerSession != null)
            {
                var restrictedProductVariants = IoC.Resolve<IProductService>().GetProductVariantsRestrictedByDiscountId(discount.DiscountId);
                var cart = IoC.Resolve<IShoppingCartService>().GetShoppingCartByCustomerSessionGuid(ShoppingCartTypeEnum.ShoppingCart, customerSession.CustomerSessionGuid);

                bool found = false;
                int totalfound = 0;
                foreach (ProductVariant restrictedPv in restrictedProductVariants)
                {
                    foreach (ShoppingCartItem sci in cart)
                    {
                        if (restrictedPv.ProductVariantId == sci.ProductVariantId)
                        {
                           // found = true;
                            totalfound++;
                            if (sci.Quantity > 1)
                            {
                                totalfound++;
                            }
                            break;
                        }
                    }

                    /*if (found)
                    {
                        break;
                    }*/
                }

                if (totalfound>1)
                    return true;
            }
        }
    }
    break;

システムで製品バリアントIDを定義し、それにのみ割引を適用するため、うまく機能します。

20 ポンドで 2 つの商品と、定価 (11.99 ポンド) で 1 つの商品を購入できるようにしたいと考えています。

したがって、基本的にすべての奇数は全額です。

私の問題は、私の現在のコードがホームページの価格も変更することです..そのため、割引は他の場所にも適用されているようです..

何か案は?

4

0 に答える 0