Skip to content

Commit

Permalink
Merge pull request #76 from val92130/develop
Browse files Browse the repository at this point in the history
2.9.1 - Fix cart page redirecting to checkout even if autocheckout is disabled
  • Loading branch information
Valentin Chatelain authored Nov 2, 2017
2 parents 6fffcbd + e487b94 commit c5c1dda
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bot/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Supreme Auto-Checkout bot",
"description": "Supreme Open-Source add to cart bot",
"version": "2.9",
"version": "2.9.1",
"background": {
"scripts": ["background.js"]
},
Expand Down
2 changes: 1 addition & 1 deletion bot/src/app/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default '2.9';
export default '2.9.1';
8 changes: 4 additions & 4 deletions bot/src/extension/content/supreme/processors/atcProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class AtcProcessor extends BaseProcessor {
}));
}

static async handleRetry(atcId, maxRetry, currentRetryCount) {
async handleRetry(atcId, maxRetry, currentRetryCount) {
if (maxRetry === 'inf') {
Helpers.timeout(() => window.location.reload(), 500, 'Product is not available, refreshing...', true);
return;
Expand All @@ -45,7 +45,7 @@ export default class AtcProcessor extends BaseProcessor {
if (nextProduct) {
window.location.href = AtcService.getAtcUrl(nextProduct, true);
} else {
window.location.href = '/checkout';
window.location.href = this.preferences.autoCheckout ? '/checkout' : '/shop/cart';
}
}

Expand Down Expand Up @@ -78,15 +78,15 @@ export default class AtcProcessor extends BaseProcessor {
const atcRunAll = Helpers.getQueryStringValue('atc-run-all');
if (!match) {
if (!isNaN(atcId) && atcRunAll) {
return await AtcProcessor.handleRetry(atcId, maxRetryCount, atcRetryCount);
return await this.handleRetry(atcId, maxRetryCount, atcRetryCount);
}
setTimeout(() => {
window.location.reload();
}, 600);
} else if (match.soldOut) {
if (!isNaN(atcId) && atcRunAll) {
const soldOutAction = atcProduct.product.soldOutAction;
return await AtcProcessor.handleRetry(atcId, soldOutAction, atcRetryCount);
return await this.handleRetry(atcId, soldOutAction, atcRetryCount);
}
setTimeout(() => {
window.location.reload();
Expand Down
3 changes: 3 additions & 0 deletions bot/src/extension/content/supreme/processors/cartProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export default class CartProcessor extends BaseProcessor {
* to the checkout page after the delay configured in the options
*/
processCart() {
if (!this.preferences.autoCheckout) {
return;
}
const outOfStockItems = document.querySelectorAll('.out_of_stock');
const outOfStockAction = this.preferences.onCartSoldOut;
if (!outOfStockItems.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export default class ProductProcessor extends BaseProcessor {

if (!atcProduct) return notify('Invalid Autocop Product Id');

let nextUrl = '/checkout';
let nextUrl = this.preferences.autoCheckout ? '/checkout' : '/shop/cart';
if (atcRunAll) {
const nextProduct = await AtcService.getNextAtcMonitorProduct(atcId);
if (nextProduct) {
Expand Down Expand Up @@ -255,7 +255,10 @@ export default class ProductProcessor extends BaseProcessor {
if (!isNaN(atcId) && atcMonitor) {
return await this.processProductMonitor();
}
let nextUrl = atcRunAll ? '/checkout' : null;
let nextUrl = null;
if (atcRunAll) {
nextUrl = this.preferences.autoCheckout ? '/checkout' : '/shop/cart';
}
if (!isNaN(atcId) && atcRunAll) {
const nextProduct = await AtcService.getNextEnabledAtcProduct(atcId);
if (nextProduct) {
Expand Down Expand Up @@ -287,7 +290,7 @@ export default class ProductProcessor extends BaseProcessor {
return false;
}

this.addToCart(nextUrl || '/checkout');
this.addToCart(nextUrl || (this.preferences.autoCheckout ? '/checkout' : '/shop/cart'));
return true;
}
}

0 comments on commit c5c1dda

Please sign in to comment.