我想在Virto Commerce的购物车上做一个促销活动。在我的例子中,我想用200瑞典克朗打折购物车,如果客户购买至少800瑞典克朗,我的例子中的增值税/商品及服务税是25%。
这就是我想要的效果:
Cart
subTotal: 640
subTotalWithTax: 800
discountAmount: 160
discountTotalWithTax: 200
total: 480
totalWithTax: 600据我所知,营销模块只支持在税前应用折扣的促销活动。storefront代码中的Se注释:
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)因此,要么我错过了促销的配置,要么我在促销的storefront代码的实现在某种程度上缺乏。
发布于 2017-09-18 21:22:17
目前VC仅对订单小计政策执行一次折扣:
当折扣应用于购物车小计时,已应用计税,并反映在税小计中。因此,适用于购物车小计的折扣将在税后发生。例如,如果购物车小计是100美元,而15美元是税小计,那么10%的购物车折扣将产生总计105美元( $100小计- $10折扣+原始$100的$15税)。
但我们正在努力更改总计计算,以使此过程更加灵活和可扩展,以支持任何计算策略。
您可以通过在扩展模块中进行一些自定义来实现您想要的功能:
public class ShopingCart2: ShoppingCart {扩展ShopingCart类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; } } }
CustomerOrder类型,其代码与在AbstractTypeFactory
中ShoppingCart above
ShoopingCart2
CustomerOrder2的代码相同 `AbstractTypeFactory<ShoppingCart>.OverrideType<ShoppingCart, ShoppingCart2>(); AbstractTypeFactory<CustomerOrder>.OverrideType<CustomerOrder, CustomerOrder2>();` ShopingCart类所必需的-添加与您之前在新ShoppingCart2类型中所做的相同更改。获取所需的行为

https://stackoverflow.com/questions/46238480
复制相似问题