Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ public boolean isRepeatCustomer() {
public static class Product extends ValueMap {

private static final String ID_KEY = "id";
private static final String PRODUCT_ID_KEY = "product_id";
private static final String SKU_KEY = "sku";
private static final String NAME_KEY = "name";
private static final String PRICE_KEY = "price";
Expand Down Expand Up @@ -422,7 +423,7 @@ public String name() {
}

public String id() {
return getString(ID_KEY);
return getString(ID_KEY) != null ? getString(ID_KEY) : getString(PRODUCT_ID_KEY);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: do u think we should give first preference to product_id and then fall back to id or vice versa?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking was to give preference to id over product_id. This should not introduce any changes if a customer is sending both id and product_id. If a customer is sending both values you'd expect those values to be the same but you never know!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good

}

public String sku() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,9 @@ class PropertiesTest {
assertThat(product.name()).isNull()
product.putName("name")
assertThat(product.name()).isEqualTo("name")

product.remove("id")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

product.putValue("product_id", "id")
assertThat(product.id()).isEqualTo("id")
}
}