简体   繁体   English

Drupal Commerce:续订角色/订阅

[英]Drupal Commerce: renew role / subscription

We are selling a product using Drupal Commerce that will renew yearly, but not automatically (expensive, users will likely use POs). 我们正在使用Drupal Commerce销售产品,该产品将每年更新一次,但不会自动更新(价格昂贵,用户可能会使用PO)。 Right now, after purchase, they will receive the appropriate role based on their purchase for 1 year. 现在,购买后,他们将根据购买的1年时间获得适当的角色。

If they pay before the end date, I would like them to get an additional, non-overlapping year. 如果他们在结束日期之前付款,我希望他们再获得一个不重叠的年份。

I would like a solution that is independent of payment type because some things will be done manually. 我想要一个独立于付款方式的解决方案,因为有些事情会手动完成。

I had implemented such a solution before. 我以前已经实施过这样的解决方案。 There was a subscription for a year,two years & three years. 订阅了一年,两年和三年。 The problem was how to maintain the subscription limit & how to extend it. 问题是如何维护订阅限制以及如何扩展它。

The solution was creating a hidden field within for every user. 解决方案是为每个用户创建一个隐藏字段。 When a user first buys a package for a year we programatically make a entry of the end timestamp in the end field. 当用户首次购买套餐时,我们会以编程方式在“结束”字段中输入结束时间戳记。 When he buys one more package the current timestamp value of the field is added by additional timestamp 当他再购买一个软件包时,该字段的当前时间戳值将与其他时间戳相加

timestamp = timestamp + 1years timestamp

or 要么

timestamp = timestamp + 2years timestamp

Hope this helps you 希望这对您有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM