Skip to content

Commit 737681a

Browse files
authored
Order creation: Prevent subscription products to be added to an order (#15960)
2 parents 772ab3f + 04fab3b commit 737681a

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- [*] Increased decimal sensitivity in order creation to mitigate tax rounding issues [https://github.com/woocommerce/woocommerce-ios/pull/15957]
77
- [*] Fix initialization of authenticator to avoid crashes during login [https://github.com/woocommerce/woocommerce-ios/pull/15953]
88
- [*] Shipping Labels: Made HS tariff number field required in customs form for EU destinations [https://github.com/woocommerce/woocommerce-ios/pull/15946]
9+
- [*] Order Creation: Prevent subscription products to be added to an order [https://github.com/woocommerce/woocommerce-ios/pull/15960]
910
- [internal] Replace COTS_DEVICE reader model name with TAP_TO_PAY_DEVICE. [https://github.com/woocommerce/woocommerce-ios/pull/15961]
1011

1112
22.9

WooCommerce/Classes/ViewRelated/Products/ProductSelector/ProductSelectorView.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,21 @@ struct ProductSelectorView: View {
216216
ProductRow(multipleSelectionsEnabled: true,
217217
viewModel: rowViewModel,
218218
onCheckboxSelected: {
219-
viewModel.variationCheckboxTapped(for: rowViewModel.productOrVariationID)
219+
if rowViewModel.selectionEnabled {
220+
viewModel.variationCheckboxTapped(for: rowViewModel.productOrVariationID)
221+
}
220222
})
221223
.frame(maxWidth: .infinity, alignment: .leading)
222224
.onTapGesture {
223-
viewModel.variationRowTapped(for: rowViewModel.productOrVariationID)
225+
if rowViewModel.selectionEnabled {
226+
viewModel.variationRowTapped(for: rowViewModel.productOrVariationID)
227+
}
224228
}
225229
.redacted(reason: viewModel.showPlaceholders ? .placeholder : [])
226230
.disabled(viewModel.selectionDisabled)
227231

228232
DisclosureIndicator()
233+
.renderedIf(rowViewModel.selectionEnabled)
229234
}
230235
.accessibilityHint(configuration.variableProductRowAccessibilityHint)
231236
} else {

WooCommerce/Classes/ViewRelated/Products/ProductSelector/ProductSelectorViewModel.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,8 @@ private extension ProductSelectorViewModel {
848848
switch (source, product.productType, product.variations) {
849849
case (.orderForm, .booking, _):
850850
return .unsupported(reason: Localization.bookableProductUnsupportedReason)
851+
case (.orderForm, .subscription, _), (.orderForm, .variableSubscription, _):
852+
return .unsupported(reason: Localization.subscriptionProductUnsupportedReason)
851853
case (_, _, let variations) where variations.isEmpty:
852854
return selectedItemsIDs.contains(product.productID) ? .selected : .notSelected
853855
default:
@@ -981,6 +983,11 @@ private extension ProductSelectorViewModel {
981983
value: "Bookable products are not supported for order creation",
982984
comment: "Message explaining unsupported bookable products for order creation"
983985
)
986+
static let subscriptionProductUnsupportedReason = NSLocalizedString(
987+
"productSelectorViewModel.subscriptionProductUnsupportedReason",
988+
value: "Subscription products are not supported for order creation",
989+
comment: "Message explaining unsupported subscription products for order creation"
990+
)
984991
}
985992
}
986993

0 commit comments

Comments
 (0)