Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't change a Promotion Asset from "Money Amount Off" to "Percent Off". #490

Open
jstoeffler opened this issue Apr 9, 2024 · 0 comments

Comments

@jstoeffler
Copy link

jstoeffler commented Apr 9, 2024

Hi,

Thanks for maintaining this super helpful library!

I am facing a new issue: It doesn't seem possible to change a Promotion Asset from "Money Amount Off" to "Percent Off".

I have created a repo with a minimal example to reproduce the problem.

I have tried 3 approaches:

  1. Setting money_amount_off to null
await customer.assets.update([
      {
        resource_name: resourceName,
        promotion_asset: {
          percent_off: toMicros(0.2),
          money_amount_off: null,
        },
      },
    ]);

=> this raises this error:

{
  "errors": [
    {
      "error_code": {
        "asset_error": "PROMOTION_CANNOT_SET_PERCENT_OFF_AND_MONEY_AMOUNT_OFF"
      },
      "message": "Cannot set both percent off and money amount off fields of promotion asset.",
      "location": {
        "field_path_elements": [
          {
            "field_name": "operations",
            "index": 0
          },
          {
            "field_name": "update"
          },
          {
            "field_name": "promotion_asset"
          },
          {
            "field_name": "percent_off"
          }
        ]
      }
    }
  ],
}
  1. Not setting money_amount_off

=> Same error

  1. Setting money_amount_off to {currency_code: "USD",amount_micros:0}
await customer.assets.update([
      {
        resource_name: resourceName,
        promotion_asset: {
          percent_off: toMicros(0.2),
          money_amount_off: { currency_code: "USD", amount_micros: 0 },
        },
      },
    ]);

=> this raises this error:

{
  "errors": [
    {
      "error_code": {
        "range_error": "TOO_LOW"
      },
      "message": "Too low.",
      "trigger": {
        "int64_value": "0"
      },
      "location": {
        "field_path_elements": [
          {
            "field_name": "operations",
            "index": 0
          },
          {
            "field_name": "update"
          },
          {
            "field_name": "promotion_asset"
          },
          {
            "field_name": "money_amount_off"
          },
          {
            "field_name": "amount_micros"
          }
        ]
      }
    }
  ],
}

What makes me think this could be a bug, is that switching from "Percent Off" to "Money Amount Off" is possible by setting the percent_off property to 0 (my sample code does that). It's the opposite that's not possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant