From 7b6b08fd26983c50c830780a0dab42c73e5bde48 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Tue, 13 Mar 2018 13:51:10 -0700 Subject: [PATCH] Upgrade specific edition --- .../qml/hifi/commerce/checkout/Checkout.qml | 5 +++++ scripts/system/html/js/marketplacesInject.js | 12 ++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml index fc47aea337..15a11cf0d7 100644 --- a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml +++ b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml @@ -35,6 +35,7 @@ Rectangle { property string itemId; property string itemHref; property string itemAuthor; + property int itemEdition: -1; property string certificateId; property double balanceAfterPurchase; property bool alreadyOwned: false; @@ -143,6 +144,9 @@ Rectangle { // OR the ID of an "updated" item, we're updating. if (root.itemId === result.data.updates[i].item_id || root.itemId === result.data.updates[i].updated_item_id) { + if (root.itemEdition !== -1 && root.itemEdition !== result.data.updates[i].edition_number) { + continue; + } root.isUpdating = true; // This CertID is the one corresponding to the base item CertID that the user already owns root.certificateId = result.data.updates[i].certificate_id; @@ -1059,6 +1063,7 @@ Rectangle { root.itemHref = message.params.itemHref; root.referrer = message.params.referrer; root.itemAuthor = message.params.itemAuthor; + root.itemEdition = message.params.itemEdition; refreshBuyUI(); break; default: diff --git a/scripts/system/html/js/marketplacesInject.js b/scripts/system/html/js/marketplacesInject.js index 46b0b6c971..2565a998f1 100644 --- a/scripts/system/html/js/marketplacesInject.js +++ b/scripts/system/html/js/marketplacesInject.js @@ -243,7 +243,7 @@ }); } - function buyButtonClicked(id, name, author, price, href, referrer) { + function buyButtonClicked(id, name, author, price, href, referrer, edition) { EventBridge.emitWebEvent(JSON.stringify({ type: "CHECKOUT", itemId: id, @@ -251,7 +251,8 @@ itemPrice: price ? parseInt(price, 10) : 0, itemHref: href, referrer: referrer, - itemAuthor: author + itemAuthor: author, + itemEdition: edition })); } @@ -319,7 +320,8 @@ $(this).closest('.grid-item').find('.creator').find('.value').text(), $(this).closest('.grid-item').find('.item-cost').text(), $(this).attr('data-href'), - "mainPage"); + "mainPage", + -1); }); } @@ -411,6 +413,7 @@ var cost = $('.item-cost').text(); var isUpdating = window.location.href.indexOf('edition=') > -1; + var urlParams = new URLSearchParams(window.location.search); if (isUpdating) { purchaseButton.html('UPDATE FOR FREE'); } else if (availability !== 'available') { @@ -427,7 +430,8 @@ $('#creator').find('.value').text(), cost, href, - "itemPage"); + "itemPage", + urlParams.get('edition')); } }); maybeAddPurchasesButton();