Skip to content

Commit

Permalink
Add method to get ecommerce items to tracker (matomo-org#14028)
Browse files Browse the repository at this point in the history
* Add getEcommerceItems() method to tracker so users can see what was added/removed.

* doc twea

* Update minified JS.

* Fix test.
  • Loading branch information
diosmosis committed Jan 27, 2019
1 parent 7e89540 commit 1419621
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 18 deletions.
15 changes: 14 additions & 1 deletion js/piwik.js
Expand Up @@ -999,7 +999,7 @@ if (typeof JSON_PIWIK !== 'object' && typeof window.JSON === 'object' && window.
enableHeartBeatTimer, disableHeartBeatTimer, killFrame, redirectFile, setCountPreRendered,
trackGoal, trackLink, trackPageView, getNumTrackedPageViews, trackRequest, queueRequest, trackSiteSearch, trackEvent,
requests, timeout, sendRequests, queueRequest,
setEcommerceView, addEcommerceItem, removeEcommerceItem, clearEcommerceCart, trackEcommerceOrder, trackEcommerceCartUpdate,
setEcommerceView, getEcommerceItems, addEcommerceItem, removeEcommerceItem, clearEcommerceCart, trackEcommerceOrder, trackEcommerceCartUpdate,
deleteCookie, deleteCookies, offsetTop, offsetLeft, offsetHeight, offsetWidth, nodeType, defaultView,
innerHTML, scrollLeft, scrollTop, currentStyle, getComputedStyle, querySelectorAll, splice,
getAttribute, hasAttribute, attributes, nodeName, findContentNodes, findContentNodes, findContentNodesWithinNode,
Expand Down Expand Up @@ -7245,6 +7245,19 @@ if (typeof window.Piwik !== 'object') {
customVariablesPage[4] = ['_pkn', name];
};

/**
* Returns the list of ecommerce items that will be sent when a cart update or order is tracked.
* The returned value is read-only, modifications will not change what will be tracked. Use
* addEcommerceItem/removeEcommerceItem/clearEcommerceCart to modify what items will be tracked.
*
* Note: the cart will be cleared after an order.
*
* @returns array
*/
this.getEcommerceItems = function () {
return JSON.parse(JSON.stringify(ecommerceItems));
};

/**
* Adds an item (product) that is in the current Cart or in the Ecommerce order.
* This function is called for every item (product) in the Cart or the Order.
Expand Down
10 changes: 5 additions & 5 deletions js/piwik.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1419621

Please sign in to comment.