Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ecommerce: recording multiple purchase items with the same sku but different values #10896

Closed
wants to merge 7 commits into from

Conversation

Slowlearneruk
Copy link

Please issue pull request against the 3.x-dev branch only.

Piwik 2 is in LTS mode. This means we do not accept any pull request for 2.x except critical security bugs and major data loss bugs.

If you need to create a pull request for 2.x, then please also create the pull request against the 3.x-dev so we can merge both.

Happy hacking!

@Slowlearneruk
Copy link
Author

Hmm.. not very familiar with the submission procedure on Github.

In summary we are recording multiple purchase items with the same sku but different values on our site (these represent bets with different stakes on the same event). Consequently we need to permit an ecommerce request with multiple entries. As you can see, using an object with the sku as a key does not really work with this model but as it happens we can easily switch ecommerceItems to an array as the sku is also held in the item member.

if (!isDefined(ecommerceItems[sku][1])) {
ecommerceItems[sku][1] = "";
if (ecommerceItems.length) {
ecommerceItems.forEach(function(ecommerceItem) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.forEach might not be supported in all browsers, the tracker is supposed to work even in older browsers. Can you maybe rewrite it to use a plain for loop?

@Slowlearneruk
Copy link
Author

Done, what are your guidelines for browser support? Array.prototype.foreach seems to be covered by everything: http://kangax.github.io/compat-table/es5/#test-Array.prototype.forEach what am I missing?

Cheers, for feedback.

@tsteur
Copy link
Member

tsteur commented Nov 22, 2016

We also support IE 8, IE7, IE6 ,...

@mattab
Copy link
Member

mattab commented Nov 22, 2016

I also gave this a try few months ago in https://github.com/piwik/piwik/pull/10297/files but then realised it is not that simple because At the moment in Piwik the Tracking API backend does expect at most one product with a given SKU, as there is a PRIMARY KEY(idvisit, idorder, idaction_sku), on log_ecommerce_item table...

@mattab mattab added this to the 3.0.0 milestone Nov 30, 2016
@mattab mattab changed the title 3.x dev Ecommerce: recording multiple purchase items with the same sku but different values Dec 1, 2016
@mattab mattab added the Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. label Dec 1, 2016
@mattab
Copy link
Member

mattab commented Jan 21, 2017

If someone ever wants to work on this please re-create the PR and we can help with reviews etc. For us it's not a priority at this time

@mattab mattab closed this Jan 21, 2017
@mattab mattab added the answered For when a question was asked and we referred to forum or answered it. label Jan 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it. Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants