@@ -70,66 +70,61 @@ export const getFormattedCart = (data) => {
70
70
product . price = convertedCurrency / product . qty ;
71
71
product . totalPrice = givenProducts [ parseInt ( i , 10 ) ] . total ;
72
72
// Ensure we can add products without images to the cart
73
- if ( givenProduct . image ) {
74
- product . image = {
75
- sourceUrl : givenProduct . image . sourceUrl ,
76
- srcSet : givenProduct . image . srcSet ,
77
- title : givenProduct . image . title ,
78
- } ;
79
- } else {
80
- product . image = {
81
- sourceUrl : WOO_CONFIG . PLACEHOLDER_SMALL_IMAGE_URL ,
82
- srcSet : WOO_CONFIG . PLACEHOLDER_SMALL_IMAGE_URL ,
83
- title : givenProduct . name ,
84
- } ;
85
- }
73
+ product . image = givenProduct . image
74
+ ? {
75
+ sourceUrl : givenProduct . image . sourceUrl ,
76
+ srcSet : givenProduct . image . srcSet ,
77
+ title : givenProduct . image . title ,
78
+ }
79
+ : {
80
+ sourceUrl : WOO_CONFIG . PLACEHOLDER_SMALL_IMAGE_URL ,
81
+ srcSet : WOO_CONFIG . PLACEHOLDER_SMALL_IMAGE_URL ,
82
+ title : givenProduct . name ,
83
+ } ;
86
84
87
85
totalProductsCount += givenProducts [ parseInt ( i , 10 ) ] . quantity ;
88
86
// Push each item into the products array.
89
87
formattedCart . products . push ( product ) ;
90
88
i ++ ;
91
89
} ) ;
92
-
93
90
formattedCart . totalProductsCount = totalProductsCount ;
94
91
formattedCart . totalProductsPrice = data . cart . total ;
95
92
return formattedCart ;
96
93
} ;
97
94
98
- export const createCheckoutData = ( order ) => {
99
- return {
100
- clientMutationId : uuidv4 ( ) ,
101
- billing : {
102
- firstName : order . firstName ,
103
- lastName : order . lastName ,
104
- address1 : order . address1 ,
105
- address2 : order . address2 ,
106
- city : order . city ,
107
- country : order . country ,
108
- state : order . state ,
109
- postcode : order . postcode ,
110
- email : order . email ,
111
- phone : order . phone ,
112
- company : order . company ,
113
- } ,
114
- shipping : {
115
- firstName : order . firstName ,
116
- lastName : order . lastName ,
117
- address1 : order . address1 ,
118
- address2 : order . address2 ,
119
- city : order . city ,
120
- country : order . country ,
121
- state : order . state ,
122
- postcode : order . postcode ,
123
- email : order . email ,
124
- phone : order . phone ,
125
- company : order . company ,
126
- } ,
127
- shipToDifferentAddress : false ,
128
- paymentMethod : order . paymentMethod ,
129
- isPaid : false ,
130
- transactionId : 'hjkhjkhsdsdiui' ,
131
- } ;
132
- } ;
95
+ export const createCheckoutData = ( order ) => ( {
96
+ clientMutationId : uuidv4 ( ) ,
97
+ billing : {
98
+ firstName : order . firstName ,
99
+ lastName : order . lastName ,
100
+ address1 : order . address1 ,
101
+ address2 : order . address2 ,
102
+ city : order . city ,
103
+ country : order . country ,
104
+ state : order . state ,
105
+ postcode : order . postcode ,
106
+ email : order . email ,
107
+ phone : order . phone ,
108
+ company : order . company ,
109
+ } ,
110
+ shipping : {
111
+ firstName : order . firstName ,
112
+ lastName : order . lastName ,
113
+ address1 : order . address1 ,
114
+ address2 : order . address2 ,
115
+ city : order . city ,
116
+ country : order . country ,
117
+ state : order . state ,
118
+ postcode : order . postcode ,
119
+ email : order . email ,
120
+ phone : order . phone ,
121
+ company : order . company ,
122
+ } ,
123
+ shipToDifferentAddress : false ,
124
+ paymentMethod : order . paymentMethod ,
125
+ isPaid : false ,
126
+ transactionId : 'hjkhjkhsdsdiui' ,
127
+ } ) ;
133
128
134
129
/**
135
130
* Get the updated items in the below format required for mutation input.
0 commit comments