Skip to content

Commit 7057f2a

Browse files
authored
Merge release/23.6 into trunk (#16315)
2 parents 0e41dac + b1af68f commit 7057f2a

File tree

36 files changed

+1723
-5579
lines changed

36 files changed

+1723
-5579
lines changed

Modules/Sources/Networking/Model/Product/Product.swift

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -766,12 +766,9 @@ public struct Product: Codable, GeneratedCopiable, Equatable, GeneratedFakeable
766766
try container.encode(password, forKey: .password)
767767

768768
// Metadata
769-
var metaDataValuePairs = buildMetaDataValuePairs()
770-
771-
// Add custom fields to metadata
772-
let customFields = buildCustomFields()
773-
metaDataValuePairs.append(contentsOf: customFields)
774-
769+
let metaDataValuePairs = buildMetaDataValuePairs()
770+
// Custom fields will not be included in metadata - when updating products.
771+
// They are saved separately with `MetaDataStore`.
775772
// Encode metadata if it's not empty
776773
if metaDataValuePairs.isEmpty == false {
777774
try container.encode(metaDataValuePairs, forKey: .metadata)
@@ -785,16 +782,6 @@ public struct Product: Codable, GeneratedCopiable, Equatable, GeneratedFakeable
785782
}
786783
return metaDataArray
787784
}
788-
789-
// Function to get the custom fields
790-
private func buildCustomFields() -> [[String: String]] {
791-
var customFieldsArray: [[String: String]] = []
792-
for customField in customFields {
793-
customFieldsArray.append(["id": "\(customField.metadataID)", "key": customField.key, "value": customField.value.stringValue])
794-
}
795-
return customFieldsArray
796-
}
797-
798785
}
799786

800787
/// Defines all of the Product CodingKeys

Modules/Tests/NetworkingTests/Mapper/ProductMapperTests.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ final class ProductMapperTests: XCTestCase {
489489
XCTAssertEqual(product.customFields.first?.value.stringValue, "10")
490490
}
491491

492-
/// Test that metadata and subscription are properly encoded.
492+
/// Test that only subscription details are encoded for metadata.
493493
///
494494
func test_metadata_and_subscription_are_properly_encoded() throws {
495495
// Given
@@ -524,7 +524,7 @@ final class ProductMapperTests: XCTestCase {
524524
// Then
525525
XCTAssertNotNil(encodedJSON)
526526
let encodedMetadata = encodedJSON?["meta_data"] as? [[String: Any]]
527-
XCTAssertEqual(encodedMetadata?.count, customFields.count + subscription.toKeyValuePairs().count) // Including subscription metadata
527+
XCTAssertEqual(encodedMetadata?.count, subscription.toKeyValuePairs().count) // Including only subscription metadata
528528
XCTAssertEqual(encodedMetadata?[0]["key"] as? String, "_subscription_length")
529529
XCTAssertEqual(encodedMetadata?[0]["value"] as? String, subscription.length)
530530
XCTAssertEqual(encodedMetadata?[1]["key"] as? String, "_subscription_period")
@@ -541,12 +541,6 @@ final class ProductMapperTests: XCTestCase {
541541
XCTAssertEqual(encodedMetadata?[6]["value"] as? String, subscription.trialPeriod.rawValue)
542542
XCTAssertEqual(encodedMetadata?[7]["key"] as? String, "_subscription_one_time_shipping")
543543
XCTAssertEqual(encodedMetadata?[7]["value"] as? String, subscription.oneTimeShipping ? "yes" : "no")
544-
XCTAssertEqual(Int64(encodedMetadata?[8]["id"] as? String ?? ""), customFields[0].metadataID)
545-
XCTAssertEqual(encodedMetadata?[8]["key"] as? String, customFields[0].key)
546-
XCTAssertEqual(encodedMetadata?[8]["value"] as? String, customFields[0].value.stringValue)
547-
XCTAssertEqual(Int64(encodedMetadata?[9]["id"] as? String ?? ""), customFields[1].metadataID)
548-
XCTAssertEqual(encodedMetadata?[9]["key"] as? String, customFields[1].key)
549-
XCTAssertEqual(encodedMetadata?[9]["value"] as? String, customFields[1].value.stringValue)
550544
}
551545

552546
/// Test that attributes are properly encoded.

WooCommerce/Resources/ar.lproj/Localizable.strings

Lines changed: 106 additions & 346 deletions
Large diffs are not rendered by default.

WooCommerce/Resources/de.lproj/Localizable.strings

Lines changed: 106 additions & 346 deletions
Large diffs are not rendered by default.

WooCommerce/Resources/es.lproj/Localizable.strings

Lines changed: 106 additions & 346 deletions
Large diffs are not rendered by default.

WooCommerce/Resources/fr.lproj/Localizable.strings

Lines changed: 106 additions & 346 deletions
Large diffs are not rendered by default.

WooCommerce/Resources/he.lproj/Localizable.strings

Lines changed: 106 additions & 346 deletions
Large diffs are not rendered by default.

WooCommerce/Resources/id.lproj/Localizable.strings

Lines changed: 106 additions & 346 deletions
Large diffs are not rendered by default.

WooCommerce/Resources/it.lproj/Localizable.strings

Lines changed: 106 additions & 346 deletions
Large diffs are not rendered by default.

WooCommerce/Resources/ja.lproj/Localizable.strings

Lines changed: 106 additions & 346 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)