@@ -1215,7 +1215,7 @@ export default function Identity(mpInstance) {
12151215 mpInstance . Logger . warning (
12161216 'Deprecated function Identity.getCurrentUser().getCart() will be removed in future releases'
12171217 ) ;
1218- return self . mParticleUserCart ( mpid ) ;
1218+ return self . mParticleUserCart ( ) ;
12191219 } ,
12201220
12211221 /**
@@ -1286,133 +1286,37 @@ export default function Identity(mpInstance) {
12861286 * @class mParticle.Identity.getCurrentUser().getCart()
12871287 * @deprecated
12881288 */
1289- this . mParticleUserCart = function ( mpid ) {
1289+ this . mParticleUserCart = function ( ) {
12901290 return {
12911291 /**
12921292 * Adds a cart product to the user cart
12931293 * @method add
1294- * @param {Object } product the product
1295- * @param {Boolean } [logEvent] a boolean to log adding of the cart object. If blank, no logging occurs.
12961294 * @deprecated
12971295 */
1298- add : function ( product , logEvent ) {
1296+ add : function ( ) {
12991297 mpInstance . Logger . warning (
1300- 'Deprecated function Identity.getCurrentUser().getCart().add() will be removed in future releases'
1298+ generateDeprecationMessage (
1299+ 'Identity.getCurrentUser().getCart().add()' ,
1300+ true ,
1301+ 'eCommerce.logProductAction()' ,
1302+ 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
1303+ )
13011304 ) ;
1302- var allProducts , userProducts , arrayCopy ;
1303-
1304- arrayCopy = Array . isArray ( product )
1305- ? product . slice ( )
1306- : [ product ] ;
1307- arrayCopy . forEach ( function ( product ) {
1308- product . Attributes = mpInstance . _Helpers . sanitizeAttributes (
1309- product . Attributes
1310- ) ;
1311- } ) ;
1312-
1313- if ( mpInstance . _Store . webviewBridgeEnabled ) {
1314- mpInstance . _NativeSdkHelpers . sendToNative (
1315- Constants . NativeSdkPaths . AddToCart ,
1316- JSON . stringify ( arrayCopy )
1317- ) ;
1318- } else {
1319- mpInstance . _SessionManager . resetSessionTimer ( ) ;
1320-
1321- userProducts = mpInstance . _Persistence . getUserProductsFromLS (
1322- mpid
1323- ) ;
1324-
1325- userProducts = userProducts . concat ( arrayCopy ) ;
1326-
1327- if ( logEvent === true ) {
1328- mpInstance . _Events . logProductActionEvent (
1329- Types . ProductActionType . AddToCart ,
1330- arrayCopy
1331- ) ;
1332- }
1333-
1334- var productsForMemory = { } ;
1335- productsForMemory [ mpid ] = { cp : userProducts } ;
1336-
1337- if (
1338- userProducts . length >
1339- mpInstance . _Store . SDKConfig . maxProducts
1340- ) {
1341- mpInstance . Logger . verbose (
1342- 'The cart contains ' +
1343- userProducts . length +
1344- ' items. Only ' +
1345- mpInstance . _Store . SDKConfig . maxProducts +
1346- ' can currently be saved in cookies.'
1347- ) ;
1348- userProducts = userProducts . slice (
1349- - mpInstance . _Store . SDKConfig . maxProducts
1350- ) ;
1351- }
1352-
1353- allProducts = mpInstance . _Persistence . getAllUserProductsFromLS ( ) ;
1354- allProducts [ mpid ] . cp = userProducts ;
1355-
1356- mpInstance . _Persistence . setCartProducts ( allProducts ) ;
1357- }
13581305 } ,
13591306 /**
13601307 * Removes a cart product from the current user cart
13611308 * @method remove
1362- * @param {Object } product the product
1363- * @param {Boolean } [logEvent] a boolean to log adding of the cart object. If blank, no logging occurs.
13641309 * @deprecated
13651310 */
1366- remove : function ( product , logEvent ) {
1311+ remove : function ( ) {
13671312 mpInstance . Logger . warning (
1368- 'Deprecated function Identity.getCurrentUser().getCart().remove() will be removed in future releases'
1313+ generateDeprecationMessage (
1314+ 'Identity.getCurrentUser().getCart().remove()' ,
1315+ true ,
1316+ 'eCommerce.logProductAction()' ,
1317+ 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
1318+ )
13691319 ) ;
1370- var allProducts ,
1371- userProducts ,
1372- cartIndex = - 1 ,
1373- cartItem = null ;
1374-
1375- if ( mpInstance . _Store . webviewBridgeEnabled ) {
1376- mpInstance . _NativeSdkHelpers . sendToNative (
1377- Constants . NativeSdkPaths . RemoveFromCart ,
1378- JSON . stringify ( product )
1379- ) ;
1380- } else {
1381- mpInstance . _SessionManager . resetSessionTimer ( ) ;
1382-
1383- userProducts = mpInstance . _Persistence . getUserProductsFromLS (
1384- mpid
1385- ) ;
1386-
1387- if ( userProducts ) {
1388- userProducts . forEach ( function ( cartProduct , i ) {
1389- if ( cartProduct . Sku === product . Sku ) {
1390- cartIndex = i ;
1391- cartItem = cartProduct ;
1392- }
1393- } ) ;
1394-
1395- if ( cartIndex > - 1 ) {
1396- userProducts . splice ( cartIndex , 1 ) ;
1397-
1398- if ( logEvent === true ) {
1399- mpInstance . _Events . logProductActionEvent (
1400- Types . ProductActionType . RemoveFromCart ,
1401- cartItem
1402- ) ;
1403- }
1404- }
1405- }
1406-
1407- var productsForMemory = { } ;
1408- productsForMemory [ mpid ] = { cp : userProducts } ;
1409-
1410- allProducts = mpInstance . _Persistence . getAllUserProductsFromLS ( ) ;
1411-
1412- allProducts [ mpid ] . cp = userProducts ;
1413-
1414- mpInstance . _Persistence . setCartProducts ( allProducts ) ;
1415- }
14161320 } ,
14171321 /**
14181322 * Clears the user's cart
@@ -1421,31 +1325,13 @@ export default function Identity(mpInstance) {
14211325 */
14221326 clear : function ( ) {
14231327 mpInstance . Logger . warning (
1424- 'Deprecated function Identity.getCurrentUser().getCart().clear() will be removed in future releases'
1328+ generateDeprecationMessage (
1329+ 'Identity.getCurrentUser().getCart().clear()' ,
1330+ true ,
1331+ '' ,
1332+ 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
1333+ )
14251334 ) ;
1426-
1427- var allProducts ;
1428-
1429- if ( mpInstance . _Store . webviewBridgeEnabled ) {
1430- mpInstance . _NativeSdkHelpers . sendToNative (
1431- Constants . NativeSdkPaths . ClearCart
1432- ) ;
1433- } else {
1434- mpInstance . _SessionManager . resetSessionTimer ( ) ;
1435- allProducts = mpInstance . _Persistence . getAllUserProductsFromLS ( ) ;
1436-
1437- if (
1438- allProducts &&
1439- allProducts [ mpid ] &&
1440- allProducts [ mpid ] . cp
1441- ) {
1442- allProducts [ mpid ] . cp = [ ] ;
1443-
1444- allProducts [ mpid ] . cp = [ ] ;
1445-
1446- mpInstance . _Persistence . setCartProducts ( allProducts ) ;
1447- }
1448- }
14491335 } ,
14501336 /**
14511337 * Returns all cart products
@@ -1455,9 +1341,14 @@ export default function Identity(mpInstance) {
14551341 */
14561342 getCartProducts : function ( ) {
14571343 mpInstance . Logger . warning (
1458- 'Deprecated function Identity.getCurrentUser().getCart().getCartProducts() will be removed in future releases'
1344+ generateDeprecationMessage (
1345+ 'Identity.getCurrentUser().getCart().getCartProducts()' ,
1346+ true ,
1347+ 'eCommerce.logProductAction()' ,
1348+ 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
1349+ )
14591350 ) ;
1460- return mpInstance . _Persistence . getCartProducts ( mpid ) ;
1351+ return [ ] ;
14611352 } ,
14621353 } ;
14631354 } ;
0 commit comments