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:
@@ -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);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user