File tree Expand file tree Collapse file tree 2 files changed +14
-9
lines changed
Samples/ShopifyAcceleratedCheckoutsApp/ShopifyAcceleratedCheckoutsApp/Views Expand file tree Collapse file tree 2 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,8 @@ struct CartBuilderView: View {
66
66
67
67
ButtonSet (
68
68
cart: $cart,
69
- firstVariantQuantity: cart. lines. nodes. first? . quantity ?? 1
69
+ firstVariantQuantity: cart. lines. nodes. first? . quantity ?? 1 ,
70
+ onComplete: clearCart
70
71
)
71
72
}
72
73
@@ -103,14 +104,7 @@ struct CartBuilderView: View {
103
104
isLoadingProducts: isLoadingProducts,
104
105
hasProducts: !allProducts. isEmpty,
105
106
onCreateCart: createCustomCart,
106
- onClearCart: {
107
- withAnimation {
108
- cart = nil
109
- selectedVariants. removeAll ( )
110
- }
111
- // Trigger scroll using state change
112
- scrollToTop = true
113
- }
107
+ onClearCart: clearCart
114
108
)
115
109
. padding ( . vertical, 12 )
116
110
. background ( Color ( UIColor . systemBackground) )
@@ -139,6 +133,15 @@ struct CartBuilderView: View {
139
133
}
140
134
}
141
135
136
+ private func clearCart( ) {
137
+ withAnimation {
138
+ cart = nil
139
+ selectedVariants. removeAll ( )
140
+ }
141
+ // Trigger scroll using state change
142
+ scrollToTop = true
143
+ }
144
+
142
145
func onLoad( ) async {
143
146
// Prevent multiple simultaneous loads
144
147
guard !isLoadingProducts else {
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import SwiftUI
28
28
struct ButtonSet : View {
29
29
@Binding var cart : Cart ?
30
30
let firstVariantQuantity : Int
31
+ let onComplete : ( ) -> Void
31
32
32
33
var body : some View {
33
34
VStack ( spacing: 16 ) {
@@ -37,6 +38,7 @@ struct ButtonSet: View {
37
38
AcceleratedCheckoutButtons ( cartID: cartID)
38
39
. onComplete {
39
40
print ( " ✅ Checkout completed successfully " )
41
+ onComplete ( )
40
42
}
41
43
. onFail {
42
44
print ( " ❌ Checkout failed " )
You can’t perform that action at this time.
0 commit comments