FEATURE: Skip product listing if only one product is present (#160)

At the moment, paying for a product typically involves first clicking
the subscribe link added to the navigation bar, selecting a product and
then adding card details to to make the purchase.

This change skips the product selection step if the site has only one
product.
This commit is contained in:
Selase Krakani
2023-05-04 13:52:04 +00:00
committed by GitHub
parent 9aa4a44b2a
commit 2babb43ffb
2 changed files with 41 additions and 0 deletions
@@ -5,4 +5,19 @@ export default Route.extend({
model() {
return Product.findAll();
},
afterModel(products) {
if (products.length === 1) {
const product = products[0];
if (this.currentUser && product.subscribed && !product.repurchaseable) {
this.transitionTo(
"user.billing.subscriptions",
this.currentUser.username
);
} else {
this.transitionTo("subscribe.show", product.id);
}
}
},
});