0

我浏览了 Broadleaf commerce v2.2 文档/教程,特别是自定义添加项目工作流程和动态定价模块。

我想在将产品添加到购物车时对其进行动态定价。

我的想法是否正确 - 当必须重新定价产品时,可以有两种方法吗?

这可以说明:

方法一:

class DynamicPricingActivity extends BaseActivity{

....
@Override
public ProcessContext execute(ProcessContext context) throws Exception {
CartOperationRequest request = ((CartOperationContext) context).getSeedData();

updatePhonePrice(request.getOrder());

return context;
}
....
}

方法二:

有关于动态定价配置中的说明的问题。

  • 该方法是如何MyDynamicSkuPricingServiceImpl # getSkuPrices()被调用的?

    (在文档中提到MyDynamicSkuPricingServiceImpl#getSkuPrices()将在调用 getPrice() 方法时调用,我配置了文档中提到的所有内容,但 getSkuPrices() 永远不会被隐式调用)

更新-我发现如果 HashMap 定价考虑为空DynamicPricingFilterDynamicPricingService#getSkuPrices()则不会调用。因此,要使 dynamicPricingService 工作,必须有一个非空的 HashMap 并且它将被隐式调用。不确定为什么需要它......

如何更新添加到购物车的产品的定价而不将此值保留在数据库中?

更新

我能够添加动态定价,而无需将值保留在数据库中

  DiscreteOrderItem orderItem = orderItemService.createDynamicPriceDiscreteOrderItem(orderRequest,          pricingConsiderations);
    orderItem.setRetailPrice(new Money("623.34"));
    orderItem.setSalePrice(new Money("888.888"));
    orderItem.setPrice(orderItem.getSalePrice());
    cart.addOrderItem(orderItem);

    cart = orderService.save(cart, true);

但是,购物车总数设置为零售价:623.34。如何获得正确的总数(888.888)

4

1 回答 1

1

For your last question about overriding the price. Broadleaf provides methods for overriding the price (orderItem.setOverrideRetailPrice(), orderItem.setOverrideSalePrice()).

Without using these methods, the pricing service will reset to the current price on the SKU (or dynamic pricing implementation).

In all cases, a salePrice that is greater than the retailPrice will be ignored.

Often when overriding prices, you also want to bypass the discount engine. You can use the orderItem.setDiscountingAllowed(false).

Since this is typical behavior, a convenience method is also provided [orderItem.setPrice()] which will override both the sale and retail prices as well as set discounting allowed to false.

Brian Polster -- Broadleaf Commerce

于 2013-07-03T21:07:18.167 回答