labd / terraform-provider-commercetools

Terraform provider for commercetools
https://registry.terraform.io/providers/labd/commercetools/latest/docs
Mozilla Public License 2.0
64 stars 67 forks source link

Request for support for cart discount target #469

Closed hchan01 closed 8 months ago

hchan01 commented 8 months ago

Hello team. I am trying to add the following cart discount with target type "totalPrice":

resource "commercetools_cart_discount" "discount" { name = { en = "Discount" } description = { en = "Discount" } value { type = "relative" permyriad = 10000 } predicate = "custom.orderHeaderKey is defined" target { type = "totalPrice" } sort_order = "0.5" }

I get this error when deploying:

Error: "totalPrice" not a valid value for "target.0.type"

I'm not sure if it is a recent addition but according to the CommerceTools docs https://docs.commercetools.com/api/projects/cartDiscounts#cartdiscounttarget, cart totalPrice is a supported target. I also tried manually creating this cart discount in the CommerceTools UI then queried for it, and the target is returned as:

"target": { "type": "totalPrice" },

Thanks in advance

demeyerthom commented 8 months ago

Hi @hchan01

We are indeed missing the totalPrice as a target in the code. This should not be a difficult change, I will look into it

hchan01 commented 8 months ago

Awesome, thanks @demeyerthom for the quick response!