Try our conversational search powered by Generative AI!

[12.10] ILineItem.PlacedPrice based on shipping country?


OK, so my previous questions has led me to this question, hopefully my last...

On the checkout page, I need to show the price for each ILineItem based on the selected shipping country. For instance, if a customer buys a subscription for something, it costs $100 if the customer lives in Sweden, but $120 if they live in Finland due to various administrative costs not really referred to as shipping costs (which is why I don't want to display the added cost there).

How would you go about implementing this? Make each country in the world a different market, and then add a price for each market for each variant?

The 7.5 version of the site asked an external system for each line item and then stored the price in PlacedPrice, however in 12.10 (and probably earlier versions) the DefaultPlacedPriceProcessor restores this price to the configured price in Commerce. I'd like to avoid involving occult magic with that part of Commerce, because I'd like to avoid possible conflicts with the new marketing system and discounts...

Nov 01, 2018 14:43

It should not (be conflicting with marketing system). You are free to implement IPlacedPriceProcessor as you like 

Nov 01, 2018 15:21

If I set the PlacedPrice property of a ILineItem (using SerializableCarts), won't that override any discounts? Or are they applied on cart level, and not lineitem level? Or possibly after IPlacedPriceProcessor has run? I will definately do (even more) tests! :)

The question then is - if I implement this in IPlacedPriceProcessor - how do I get the shipping address if the customerContact parameter is always null (since customers don't log in)?

Nov 01, 2018 15:28

PlacedPrice is basically price before any discounts, so it will be set before the promotion engine runs.

For your second question, can't you use Geo-location for that? They haven't logged in so you don't have to have exact address, just approximate one should be enough 

Nov 01, 2018 15:40

Unfortunately, no. There are customers who live in one country, and wants to ship it to a different country as a Christmas gift. An example could be a grandmother (living in Sweden) sending their grandchild (living in Finland) a subscription for something as a Christmas gift.

I know it's possible when using the old cart system, to get the cart from a lineitem, and then get the shipping address from the carts OrderAddresses collection. Is it possible to do this with SerializableCart via an ILineItem somehow, without using reflection? I've been browsing through the Serializable* classes, but can't find a way :/

Nov 01, 2018 16:20

Technically you can just serialize the order address into a string and store it in Properties property of ILineItem. 

Nov 01, 2018 18:12

Yeah, I think this is the way I'll go, but only the shipping country is needed. So when the customer changes shipping country from default (Sweden).

  1. Loop through all line items.
    1. Set the ShippingCountryCode property to the selected country code.
    2. Call IPlacedPriceProcessor.UpdatePlacedPrice
      1. Set the fetch the price from the external system and update lineItem.PlacedPrice.
  2. Save the cart.

Thanks again!! :)

Nov 01, 2018 18:36
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.