2017-09-15 131 views
0

我想在购物车上的Virto Commerce中进行促销。在我的例子中,如果客户购买至少800瑞典克朗,我想用200 SEK折扣购物车,在我的例子中,增值税/消费税是25%。Virto Commerce营销模块上的购物车折扣

这是我在寻找的效果:

Cart 
subTotal:    640 
subTotalWithTax:  800 

discountAmount:  160 
discountTotalWithTax: 200 

total:    480 
totalWithTax:   600 

至于我可以告诉营销模块只支持其中折扣税前加促销活动。在店面代码硒评论:

ShoppingCart.cs#L390

 foreach (var reward in cartRewards) 
     { 
      //When a discount is applied to the cart subtotal, the tax calculation has already been applied, and is reflected in the tax subtotal. 
      //Therefore, a discount applying to the cart subtotal will occur after tax. 
      //For instance, if the cart subtotal is $100, and $15 is the tax subtotal, a cart - wide discount of 10 % will yield a total of $105($100 subtotal – $10 discount + $15 tax on the original $100). 
      if (reward.IsValid) 
      { 
       var discount = reward.ToDiscountModel(ExtendedPriceTotal); 
       Discounts.Add(discount); 
       DiscountAmount = discount.Amount; 
      } 
     } 

我想这是在某些市场的普遍做法。但是,这是瑞典的B2C解决方案。在800瑞典克朗的推车上宣传200瑞典克朗的折扣应该使面向顾客的总价格为600瑞典克朗,包括税费。


This is an img of my promotion in the Marketing Module

这给我上车JSON

Cart 
subTotal:    640 
subTotalWithTax:  800 

discountAmount:  160 
discountTotal:  160 
discountTotalWithTax: 160 

subTotalDiscount:  0 
subTotalDiscountWithTax:0 
discountTotalWithTax: 160 

taxTotal:    160 

total:    640 
totalWithTax:   800 (Calculated. Not in standard JSON response) 

下列因此,无论我已经错过配置的促销或我实施促销店面代码是缺乏某种方式。

回答

0

目前,VC只实现了一个折扣,订单小计政策:

当折扣应用于车小计,计税 已经得到了应用,并反映在税收分类汇总。 因此,适用于购物车小计的折扣将在 税后发生。例如,如果购物车小计为$ 100,并且$ 15为税额 小计,则购物车范围内的折扣为10%将产生总计$ 105($ 100 小计 - $ 10折扣+原价$ 100的$ 15税)。

但是我们正在努力改变总计算,以使此过程更加灵活和可扩展,以支持任何计算策略。

您可以将您的扩展模块中实现你想要通过少量的自定义:

  1. 扩展ShopingCart类下面的代码 public class ShopingCart2: ShoppingCart {
    public decimal DiscountAmountWithTax { get { return DiscountAmount + DiscountAmount * TaxPercentRate; } }
    public override decimal TaxTotal { get { var result = base.TaxTotal; result -= DiscountAmountWithTax - DiscountAmount; return result; } }
    public override decimal DiscountTotalWithTax { get { var result = base.DiscountTotalWithTax; result += DiscountAmountWithTax - DiscountAmount; return result; } } }

  2. 扩展域CustomerOrder类型,具有相同的代码为ShoppingCart以上

  3. 在中注册您的ShoopingCart2

AbstractTypeFactory<ShoppingCart>.OverrideType<ShoppingCart, ShoppingCart2>(); AbstractTypeFactory<CustomerOrder>.OverrideType<CustomerOrder, CustomerOrder2>();

  • 更新您的店面从开发最新版本(此提交所需的正常工作https://github.com/VirtoCommerce/vc-storefront/commit/2464548c171c811a9d63edba0bdf6af93e8c902b

  • 修改ShopingCart类店面 - 添加与您在之前的新ShoppingCart2类型中所做的更改相同的更改。

  • 获得所需的行为 Checkout