Skip to content

Commit 5e5cfe8

Browse files
committed
Transform the template auto-draft product into a new product ready to be used
1 parent fc4f068 commit 5e5cfe8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductCoordinator.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ private extension AddProductCoordinator {
152152

153153
switch result {
154154
case .success(let product):
155-
self.presentProduct(product, formType: .edit) // We need to strongly capture `self` because no one is retaining `AddProductCoordinator`.
155+
let newProduct = ProductFactory().newProduct(from: product) // Transforms the auto-draft product into a new product ready to be used.
156+
self.presentProduct(newProduct) // We need to strongly capture `self` because no one is retaining `AddProductCoordinator`.
156157

157158
case .failure(let error):
158159
// Log error and inform the user
@@ -177,12 +178,12 @@ private extension AddProductCoordinator {
177178
assertionFailure("Unable to create product of type: \(bottomSheetProductType)")
178179
return
179180
}
180-
presentProduct(product, formType: .add)
181+
presentProduct(product)
181182
}
182183

183184
/// Presents a product onto the current navigation stack.
184185
///
185-
func presentProduct(_ product: Product, formType: ProductFormType) {
186+
func presentProduct(_ product: Product) {
186187
let model = EditableProductModel(product: product)
187188
let currencyCode = ServiceLocator.currencySettings.currencyCode
188189
let currency = ServiceLocator.currencySettings.symbol(from: currencyCode)
@@ -192,7 +193,7 @@ private extension AddProductCoordinator {
192193
isLocalID: true),
193194
originalStatuses: model.imageStatuses)
194195
let viewModel = ProductFormViewModel(product: model,
195-
formType: formType,
196+
formType: .add,
196197
productImageActionHandler: productImageActionHandler)
197198
let viewController = ProductFormViewController(viewModel: viewModel,
198199
eventLogger: ProductFormEventLogger(),

0 commit comments

Comments
 (0)