2017-09-15 132 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