首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Virto Commerce营销模块上的购物车折扣

Virto Commerce营销模块上的购物车折扣
EN

Stack Overflow用户
提问于 2017-09-15 19:26:37
回答 1查看 97关注 0票数 0

我想在Virto Commerce的购物车上做一个促销活动。在我的例子中,我想用200瑞典克朗打折购物车,如果客户购买至少800瑞典克朗,我的例子中的增值税/商品及服务税是25%。

这就是我想要的效果:

代码语言:javascript
复制
Cart
subTotal:             640
subTotalWithTax:      800

discountAmount:       160
discountTotalWithTax: 200

total:                480
totalWithTax:         600

据我所知,营销模块只支持在税前应用折扣的促销活动。storefront代码中的Se注释:

ShoppingCart.cs#L390

代码语言:javascript
复制
        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

代码语言:javascript
复制
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代码的实现在某种程度上缺乏。

EN

回答 1

Stack Overflow用户

发布于 2017-09-18 21:22:17

目前VC仅对订单小计政策执行一次折扣:

当折扣应用于购物车小计时,已应用计税,并反映在税小计中。因此,适用于购物车小计的折扣将在税后发生。例如,如果购物车小计是100美元,而15美元是税小计,那么10%的购物车折扣将产生总计105美元( $100小计- $10折扣+原始$100的$15税)。

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

您可以通过在扩展模块中进行一些自定义来实现您想要的功能:

  1. 使用以下代码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

  • Register ShoopingCart2

  • CustomerOrder2的代码相同

代码语言:javascript
复制
 `AbstractTypeFactory<ShoppingCart>.OverrideType<ShoppingCart, ShoppingCart2>();     AbstractTypeFactory<CustomerOrder>.OverrideType<CustomerOrder, CustomerOrder2>();` 

  1. 将您的storefront从开发更新到最新版本(此提交是storefront中正常工作的https://github.com/VirtoCommerce/vc-storefront/commit/2464548c171c811a9d63edba0bdf6af93e8c902b)
  2. Modify ShopingCart类所必需的-添加与您之前在新ShoppingCart2类型中所做的相同更改。

获取所需的行为

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46238480

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档