FEATURE: Give option to repurchase products multiple times (#46)
Feature requested here: https://meta.discourse.org/t/subscriptions-allow-users-to-purchase-one-time-products-multiple-times/173732/ There may be cases where a site admin wants to allow the repurchasing of a product. This implements the functionality by adding a repurchaseable toggle in the admin screen when creating a product. This saves an attribute to the Stripe product metadata. When a user has already purchased an item with this toggle enabled, they will be able to purchase it again when browsing to `/s`.
This commit is contained in:
@@ -93,7 +93,10 @@ module DiscourseSubscriptions
|
||||
name: params[:name],
|
||||
active: params[:active],
|
||||
statement_descriptor: params[:statement_descriptor],
|
||||
metadata: { description: params.dig(:metadata, :description) }
|
||||
metadata: {
|
||||
description: params.dig(:metadata, :description),
|
||||
repurchaseable: params.dig(:metadata, :repurchaseable)
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -136,7 +136,8 @@ module DiscourseSubscriptions
|
||||
id: product[:id],
|
||||
name: product[:name],
|
||||
description: PrettyText.cook(product[:metadata][:description]),
|
||||
subscribed: current_user_products.include?(product[:id])
|
||||
subscribed: current_user_products.include?(product[:id]),
|
||||
repurchaseable: product[:metadata][:repurchaseable]
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user