@@ -41,13 +41,13 @@ import WordPressShared
4141 /// - siteID: id of the current site
4242 /// - products: an array of products to be added to the newly created cart
4343 /// - temporary: true if the card is temporary, false otherwise
44- public func createShoppingCart( siteID: Int ,
44+ public func createShoppingCart( siteID: Int ? ,
4545 products: [ TransactionsServiceProduct ] ,
4646 temporary: Bool ,
4747 success: @escaping ( CartResponse ) -> Void ,
4848 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 ) "
5151 let urlPath = path ( forEndpoint: endPoint, withVersion: . _1_1)
5252
5353 var productsDictionary : [ [ String : AnyObject ] ] = [ ]
@@ -151,12 +151,12 @@ public enum TransactionsServiceProduct {
151151
152152public struct CartResponse {
153153 let blogID : Int
154- let cartKey : Int
154+ let cartKey : Any // cart key can be either Int or String
155155 let products : [ Product ]
156156
157157 init ? ( jsonDictionary: [ String : AnyObject ] ) {
158158 guard
159- let cartKey = jsonDictionary [ " cart_key " ] as? Int ,
159+ let cartKey = jsonDictionary [ " cart_key " ] ,
160160 let blogID = jsonDictionary [ " blog_id " ] as? Int ,
161161 let products = jsonDictionary [ " products " ] as? [ [ String : AnyObject ] ]
162162 else {
0 commit comments