@@ -41,13 +41,13 @@ import WordPressShared
41
41
/// - siteID: id of the current site
42
42
/// - products: an array of products to be added to the newly created cart
43
43
/// - temporary: true if the card is temporary, false otherwise
44
- public func createShoppingCart( siteID: Int ,
44
+ public func createShoppingCart( siteID: Int ? ,
45
45
products: [ TransactionsServiceProduct ] ,
46
46
temporary: Bool ,
47
47
success: @escaping ( CartResponse ) -> Void ,
48
48
failure: @escaping ( Error ) -> Void ) {
49
-
50
- let endPoint = " me/shopping-cart/ \( siteID ) "
49
+ let siteIDString = siteID != nil ? " \( siteID ?? 0 ) " : " no-site "
50
+ let endPoint = " me/shopping-cart/ \( siteIDString ) "
51
51
let urlPath = path ( forEndpoint: endPoint, withVersion: . _1_1)
52
52
53
53
var productsDictionary : [ [ String : AnyObject ] ] = [ ]
@@ -151,12 +151,12 @@ public enum TransactionsServiceProduct {
151
151
152
152
public struct CartResponse {
153
153
let blogID : Int
154
- let cartKey : Int
154
+ let cartKey : Any // cart key can be either Int or String
155
155
let products : [ Product ]
156
156
157
157
init ? ( jsonDictionary: [ String : AnyObject ] ) {
158
158
guard
159
- let cartKey = jsonDictionary [ " cart_key " ] as? Int ,
159
+ let cartKey = jsonDictionary [ " cart_key " ] ,
160
160
let blogID = jsonDictionary [ " blog_id " ] as? Int ,
161
161
let products = jsonDictionary [ " products " ] as? [ [ String : AnyObject ] ]
162
162
else {
0 commit comments