Skip to content

Commit 01278a7

Browse files
committed
Merge branch 'trunk' into feat/WOOMOB-687-fix-ios-screenshots-gen-ci
2 parents 602c99c + aa345ab commit 01278a7

File tree

139 files changed

+2883
-1710
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+2883
-1710
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<!--
22
Contains editorialized release notes. Raw release notes should go into `RELEASE-NOTES.txt`.
33
-->
4+
## 22.7
5+
Say hello to smoother shipping and sales! 🎉 We’ve enhanced Shipping Labels with UPS extras and smarter forms, fixed price and display glitches, and made shipment management easier. Plus, Point of Sale now has its own tab for eligible stores, barcode scanning, and smoother product refresh for faster checkout.
6+
47
## 22.6
58
Shipping just got a major upgrade! Our revamped flow makes it easier than ever to create and manage shipping labels for stores using WooCommerce Shipping. We've also improved some icons and fixed a display issue with the order list's last updated time. This release includes some behind-the-scenes performance improvements too.
69

Modules/Package.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,13 @@ let package = Package(
166166
name: "TestKit",
167167
dependencies: ["Difference", "Nimble"]
168168
),
169+
.target(
170+
name: "UITestsFoundation",
171+
dependencies: [
172+
.product(name: "ScreenObject", package: "ScreenObject"),
173+
.product(name: "XCUITestHelpers", package: "ScreenObject"),
174+
]
175+
),
169176
.target(
170177
name: "WooFoundation",
171178
dependencies: ["WooFoundationCore"]
@@ -305,7 +312,6 @@ enum XcodeTargetNames {
305312
static let fakes = "Fakes"
306313
static let notificationExtension = "NotificationExtension"
307314
static let storeWidgetsExtension = "StoreWidgetsExtension"
308-
static let uiTestsFoundation = "UITestsFoundation"
309315
static let wooCommerce = "WooCommerce"
310316
static let wooCommerceScreenshots = "WooCommerceScreenshots"
311317
static let wooCommerceTests = "WooCommerceTests"
@@ -320,7 +326,6 @@ enum XcodeSupport {
320326
[
321327
XcodeTargetNames.notificationExtension,
322328
XcodeTargetNames.storeWidgetsExtension,
323-
XcodeTargetNames.uiTestsFoundation,
324329
XcodeTargetNames.wooCommerce,
325330
XcodeTargetNames.wooCommerceScreenshots,
326331
XcodeTargetNames.wooCommerceTests,
@@ -351,13 +356,6 @@ enum XcodeSupport {
351356
.product(name: "KeychainAccess", package: "KeychainAccess"),
352357
]
353358
),
354-
.xcodeTarget(
355-
XcodeTargetNames.uiTestsFoundation,
356-
dependencies: [
357-
.product(name: "ScreenObject", package: "ScreenObject"),
358-
.product(name: "XCUITestHelpers", package: "ScreenObject"),
359-
]
360-
),
361359
.xcodeTarget(
362360
XcodeTargetNames.wooCommerce,
363361
dependencies: [
@@ -395,6 +393,7 @@ enum XcodeSupport {
395393
.xcodeTarget(
396394
XcodeTargetNames.wooCommerceScreenshots,
397395
dependencies: [
396+
"UITestsFoundation",
398397
.product(name: "Embassy", package: "Embassy"),
399398
.product(name: "ScreenObject", package: "ScreenObject"),
400399
XcodeTargetNames.wooCommerce.asDependency
@@ -418,6 +417,7 @@ enum XcodeSupport {
418417
.xcodeTarget(
419418
XcodeTargetNames.wooCommerceUITests,
420419
dependencies: [
420+
"UITestsFoundation",
421421
.product(name: "ScreenObject", package: "ScreenObject"),
422422
XcodeTargetNames.wooCommerce.asDependency
423423
]

Modules/Sources/Fakes/Networking.generated.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2406,7 +2406,7 @@ extension Networking.WooShippingPackagePurchase {
24062406
.init(
24072407
shipmentID: .fake(),
24082408
package: .fake(),
2409-
rate: .fake(),
2409+
selectedRate: .fake(),
24102410
productIDs: .fake()
24112411
)
24122412
}
@@ -2469,6 +2469,20 @@ extension Networking.WooShippingSavedPredefinedPackage {
24692469
)
24702470
}
24712471
}
2472+
extension Networking.WooShippingSelectedRate {
2473+
/// Returns a "ready to use" type filled with fake values.
2474+
///
2475+
public static func fake() -> Networking.WooShippingSelectedRate {
2476+
.init(
2477+
rate: .fake(),
2478+
signatureRate: .fake(),
2479+
adultSignatureRate: .fake(),
2480+
carbonNeutralRate: .fake(),
2481+
saturdayDeliveryRate: .fake(),
2482+
additionalHandlingRate: .fake()
2483+
)
2484+
}
2485+
}
24722486
extension Networking.WooShippingShipmentItem {
24732487
/// Returns a "ready to use" type filled with fake values.
24742488
///

Modules/Sources/Networking/Mapper/ShippingLabelCarriersAndRatesMapper.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ private struct ShippingLabelDefaultBoxEnvelope: Decodable {
4949
return ShippingLabelCarriersAndRates(packageID: key,
5050
defaultRates: value.defaultRates,
5151
signatureRequired: value.signatureRequired,
52-
adultSignatureRequired: value.adultSignatureRequired)
52+
adultSignatureRequired: value.adultSignatureRequired,
53+
carbonNeutral: value.carbonNeutral,
54+
saturdayDelivery: value.saturdayDelivery,
55+
additionalHandling: value.additionalHandling)
5356
}
5457
}
5558
}

Modules/Sources/Networking/Mapper/WooShippingLabelRatesMapper.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ private struct ShippingLabelDefaultBoxEnvelope: Decodable {
4141
return ShippingLabelCarriersAndRates(packageID: key,
4242
defaultRates: value.defaultRates,
4343
signatureRequired: value.signatureRequired,
44-
adultSignatureRequired: value.adultSignatureRequired)
44+
adultSignatureRequired: value.adultSignatureRequired,
45+
carbonNeutral: value.carbonNeutral,
46+
saturdayDelivery: value.saturdayDelivery,
47+
additionalHandling: value.additionalHandling)
4548
}
4649
}
4750
}

Modules/Sources/Networking/Model/Copiable/Models+Copiable.generated.swift

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2458,6 +2458,54 @@ extension Networking.ShippingLabelAccountSettings {
24582458
}
24592459
}
24602460

2461+
extension Networking.ShippingLabelCarrierRate {
2462+
public func copy(
2463+
title: CopiableProp<String> = .copy,
2464+
insurance: CopiableProp<String> = .copy,
2465+
retailRate: CopiableProp<Double> = .copy,
2466+
rate: CopiableProp<Double> = .copy,
2467+
rateID: CopiableProp<String> = .copy,
2468+
serviceID: CopiableProp<String> = .copy,
2469+
carrierID: CopiableProp<String> = .copy,
2470+
shipmentID: CopiableProp<String> = .copy,
2471+
hasTracking: CopiableProp<Bool> = .copy,
2472+
isSelected: CopiableProp<Bool> = .copy,
2473+
isPickupFree: CopiableProp<Bool> = .copy,
2474+
deliveryDays: NullableCopiableProp<Int64> = .copy,
2475+
deliveryDateGuaranteed: CopiableProp<Bool> = .copy
2476+
) -> Networking.ShippingLabelCarrierRate {
2477+
let title = title ?? self.title
2478+
let insurance = insurance ?? self.insurance
2479+
let retailRate = retailRate ?? self.retailRate
2480+
let rate = rate ?? self.rate
2481+
let rateID = rateID ?? self.rateID
2482+
let serviceID = serviceID ?? self.serviceID
2483+
let carrierID = carrierID ?? self.carrierID
2484+
let shipmentID = shipmentID ?? self.shipmentID
2485+
let hasTracking = hasTracking ?? self.hasTracking
2486+
let isSelected = isSelected ?? self.isSelected
2487+
let isPickupFree = isPickupFree ?? self.isPickupFree
2488+
let deliveryDays = deliveryDays ?? self.deliveryDays
2489+
let deliveryDateGuaranteed = deliveryDateGuaranteed ?? self.deliveryDateGuaranteed
2490+
2491+
return Networking.ShippingLabelCarrierRate(
2492+
title: title,
2493+
insurance: insurance,
2494+
retailRate: retailRate,
2495+
rate: rate,
2496+
rateID: rateID,
2497+
serviceID: serviceID,
2498+
carrierID: carrierID,
2499+
shipmentID: shipmentID,
2500+
hasTracking: hasTracking,
2501+
isSelected: isSelected,
2502+
isPickupFree: isPickupFree,
2503+
deliveryDays: deliveryDays,
2504+
deliveryDateGuaranteed: deliveryDateGuaranteed
2505+
)
2506+
}
2507+
}
2508+
24612509
extension Networking.ShippingLabelCustomsForm {
24622510
public func copy(
24632511
packageID: CopiableProp<String> = .copy,
@@ -3638,18 +3686,18 @@ extension Networking.WooShippingPackagePurchase {
36383686
public func copy(
36393687
shipmentID: CopiableProp<String> = .copy,
36403688
package: CopiableProp<ShippingLabelPackageSelected> = .copy,
3641-
rate: CopiableProp<ShippingLabelCarrierRate> = .copy,
3689+
selectedRate: CopiableProp<WooShippingSelectedRate> = .copy,
36423690
productIDs: CopiableProp<[Int64]> = .copy
36433691
) -> Networking.WooShippingPackagePurchase {
36443692
let shipmentID = shipmentID ?? self.shipmentID
36453693
let package = package ?? self.package
3646-
let rate = rate ?? self.rate
3694+
let selectedRate = selectedRate ?? self.selectedRate
36473695
let productIDs = productIDs ?? self.productIDs
36483696

36493697
return Networking.WooShippingPackagePurchase(
36503698
shipmentID: shipmentID,
36513699
package: package,
3652-
rate: rate,
3700+
selectedRate: selectedRate,
36533701
productIDs: productIDs
36543702
)
36553703
}

Modules/Sources/Networking/Model/ShippingLabel/Packages/CarriersAndRates/ShippingLabelCarrierRate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Codegen
33

44
/// Represents the rate for a specific shipping carrier
55
///
6-
public struct ShippingLabelCarrierRate: Equatable, GeneratedFakeable {
6+
public struct ShippingLabelCarrierRate: Equatable, GeneratedFakeable, GeneratedCopiable {
77

88
public let title: String
99
public let insurance: String

Modules/Sources/Networking/Model/ShippingLabel/Packages/CarriersAndRates/ShippingLabelCarriersAndRates.swift

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,24 @@ public struct ShippingLabelCarriersAndRates: Equatable {
88
public let defaultRates: [ShippingLabelCarrierRate]
99
public let signatureRequired: [ShippingLabelCarrierRate]
1010
public let adultSignatureRequired: [ShippingLabelCarrierRate]
11+
public let carbonNeutral: [ShippingLabelCarrierRate]
12+
public let saturdayDelivery: [ShippingLabelCarrierRate]
13+
public let additionalHandling: [ShippingLabelCarrierRate]
1114

1215
public init(packageID: String?,
1316
defaultRates: [ShippingLabelCarrierRate],
1417
signatureRequired: [ShippingLabelCarrierRate],
15-
adultSignatureRequired: [ShippingLabelCarrierRate]) {
18+
adultSignatureRequired: [ShippingLabelCarrierRate],
19+
carbonNeutral: [ShippingLabelCarrierRate],
20+
saturdayDelivery: [ShippingLabelCarrierRate],
21+
additionalHandling: [ShippingLabelCarrierRate]) {
1622
self.packageID = packageID
1723
self.defaultRates = defaultRates
1824
self.signatureRequired = signatureRequired
1925
self.adultSignatureRequired = adultSignatureRequired
26+
self.carbonNeutral = carbonNeutral
27+
self.saturdayDelivery = saturdayDelivery
28+
self.additionalHandling = additionalHandling
2029
}
2130
}
2231

@@ -30,12 +39,17 @@ extension ShippingLabelCarriersAndRates: Decodable {
3039
let defaultRates = try container.decode(ShippingLabelRatesEnvelope.self, forKey: .defaultRates).rates
3140
let signatureRequired = try container.decode(ShippingLabelRatesEnvelope.self, forKey: .signatureRequired).rates
3241
let adultSignatureRequired = try container.decode(ShippingLabelRatesEnvelope.self, forKey: .adultSignatureRequired).rates
33-
42+
let carbonNeutral = try container.decodeIfPresent(ShippingLabelRatesEnvelope.self, forKey: .carbonNeutral)?.rates ?? []
43+
let saturdayDelivery = try container.decodeIfPresent(ShippingLabelRatesEnvelope.self, forKey: .saturdayDelivery)?.rates ?? []
44+
let additionalHandling = try container.decodeIfPresent(ShippingLabelRatesEnvelope.self, forKey: .additionalHandling)?.rates ?? []
3445

3546
self.init(packageID: packageID,
3647
defaultRates: defaultRates,
3748
signatureRequired: signatureRequired,
38-
adultSignatureRequired: adultSignatureRequired)
49+
adultSignatureRequired: adultSignatureRequired,
50+
carbonNeutral: carbonNeutral,
51+
saturdayDelivery: saturdayDelivery,
52+
additionalHandling: additionalHandling)
3953
}
4054

4155

@@ -44,6 +58,9 @@ extension ShippingLabelCarriersAndRates: Decodable {
4458
case defaultRates = "default"
4559
case signatureRequired
4660
case adultSignatureRequired
61+
case carbonNeutral
62+
case saturdayDelivery
63+
case additionalHandling
4764
}
4865
}
4966

Modules/Sources/Networking/Model/ShippingLabel/Packages/CarriersAndRates/ShippingLabelPackageSelected.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ extension ShippingLabelPackageSelected: Encodable {
4646
try container.encode(boxID.isEmpty ? "0" : boxID, forKey: .boxID)
4747
try container.encode(length, forKey: .length)
4848
try container.encode(width, forKey: .width)
49-
try container.encode(height, forKey: .height)
49+
50+
// workaround because 0 would cause an error for the API request
51+
try container.encode(height > 0 ? height : 0.25, forKey: .height)
52+
5053
try container.encode(weight, forKey: .weight)
5154
try container.encode(isLetter, forKey: .isLetter)
5255
try container.encodeIfPresent(hazmatCategory, forKey: .hazmatCategory)
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import Codegen
2+
3+
/// Represents a selected shipping rate with the Woo Shipping extension.
4+
public struct WooShippingSelectedRate: Equatable, GeneratedFakeable {
5+
6+
/// Basic rate for the selected carrier without additional service.
7+
public let rate: ShippingLabelCarrierRate
8+
9+
/// Rate for shipping with signature, if selected.
10+
public let signatureRate: ShippingLabelCarrierRate?
11+
12+
/// Rate for shipping with adult signature, if selected.
13+
public let adultSignatureRate: ShippingLabelCarrierRate?
14+
15+
/// Rate for shipping with carbon neutral, if selected.
16+
public let carbonNeutralRate: ShippingLabelCarrierRate?
17+
18+
/// Rate for shipping with Saturday delivery, if selected.
19+
public let saturdayDeliveryRate: ShippingLabelCarrierRate?
20+
21+
/// Rate for shipping with additional handling, if selected.
22+
public let additionalHandlingRate: ShippingLabelCarrierRate?
23+
24+
public init(rate: ShippingLabelCarrierRate,
25+
signatureRate: ShippingLabelCarrierRate? = nil,
26+
adultSignatureRate: ShippingLabelCarrierRate? = nil,
27+
carbonNeutralRate: ShippingLabelCarrierRate? = nil,
28+
saturdayDeliveryRate: ShippingLabelCarrierRate? = nil,
29+
additionalHandlingRate: ShippingLabelCarrierRate? = nil) {
30+
self.rate = rate
31+
self.signatureRate = signatureRate
32+
self.adultSignatureRate = adultSignatureRate
33+
self.carbonNeutralRate = carbonNeutralRate
34+
self.saturdayDeliveryRate = saturdayDeliveryRate
35+
self.additionalHandlingRate = additionalHandlingRate
36+
}
37+
}
38+
39+
public extension WooShippingSelectedRate {
40+
var purchaseRate: ShippingLabelCarrierRate {
41+
if let signatureRate = signatureRate {
42+
return signatureRate
43+
} else if let adultSignatureRate = adultSignatureRate {
44+
return adultSignatureRate
45+
}
46+
return rate
47+
}
48+
49+
var totalRate: Double {
50+
let totalRateExcludingExtraServices: Double = {
51+
if let signatureRate {
52+
return signatureRate.rate
53+
} else if let adultSignatureRate {
54+
return adultSignatureRate.rate
55+
}
56+
return rate.rate
57+
}()
58+
59+
let allCharges = [totalRateExcludingExtraServices,
60+
surchargeForCarbonNeutralRate,
61+
surchargeForSaturdayDeliveryRate,
62+
surchargeForAdditionalHandlingRate]
63+
64+
return allCharges.reduce(0, +)
65+
}
66+
}
67+
68+
extension WooShippingSelectedRate {
69+
var surchargeForSignatureRequirement: Double {
70+
guard let signatureRate else {
71+
return 0
72+
}
73+
return signatureRate.rate - rate.rate
74+
}
75+
76+
var surchargeForAdultSignatureRequirement: Double {
77+
guard let adultSignatureRate else {
78+
return 0
79+
}
80+
return adultSignatureRate.rate - rate.rate
81+
}
82+
83+
var surchargeForCarbonNeutralRate: Double {
84+
guard let carbonNeutralRate else {
85+
return 0
86+
}
87+
return carbonNeutralRate.rate - rate.rate
88+
}
89+
90+
var surchargeForSaturdayDeliveryRate: Double {
91+
guard let saturdayDeliveryRate else {
92+
return 0
93+
}
94+
return saturdayDeliveryRate.rate - rate.rate
95+
}
96+
97+
var surchargeForAdditionalHandlingRate: Double {
98+
guard let additionalHandlingRate else {
99+
return 0
100+
}
101+
return additionalHandlingRate.rate - rate.rate
102+
}
103+
}

0 commit comments

Comments
 (0)