OpenCart订阅模型(x个月) [英] OpenCart subscription model (x months)

查看:108
本文介绍了OpenCart订阅模型(x个月)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用OpenCart建立一个电子商务网站,我想提供订阅.特别是3/6/12个月的订阅.我对定期计费不感兴趣(我知道有PayPal和Authorize.net的模块).我希望用户提前付款一次.从配置的角度来看,这会转化为3个伪产品吗?到目前为止,我认为这仅在产品配置上是可行的. 3个产品,每一个价格.

I am setting up an e-commerce site using OpenCart and I want to offer subscriptions. Specifically 3/6/12 months subscriptions. I am NOT interested in recurring billing (I am aware that there are modules for PayPal and Authorize.net). I want users to pay once in advance. Does this translate to 3 pseudo-products from a configuration point of view? I guess this is feasible, so far, just with product configuration. 3 products, each with one price.

这是棘手的部分.用户每月在其计费周期"内付费一次就可以订购产品,而每月一次.因此,如果用户在23/5上支付了3个月的订阅费用:

Here comes the tricky part. For every month the users have paid they have access to order a product, only once a month, within their "billing cycle". So, if a user pays for a 3 month subscription on 23/5:

  • 他可以在23/5-22/6期间获得一种产品,
  • 23/6-22/7中的一个,和
  • 23/7-22/8中的一个

用户除非每月续订,否则每月不应订购超过一种产品,并且也不应在22/8之后获得任何产品.而且,如果我可以进行Cron工作,检查用户是否在当月使用了他的订阅,并发送嘿,请在本月获得您的产品"提醒电子邮件,那将是很棒的.

A user should not be able to order more than one products per month, and he should not also be able to get any products after 22/8, unless he renews his subscription. Moreover, it would be awesome if I could have a cron job, checking if a user has utilized his subscription for the current month, and send a "Hey, get your product for this month" kind of reminder email.

这是我的第一个OpenCart项目,我遍历了文档并进行了很多Google搜索工作,我参与了本地安装,并且我试图弄清楚我所问的内容是否可行而无需修改核心代码,我希望避免这种情况.但是,如果没有其他方法,我知道OpenCart是MVC(+ L(anguage))框架,但是我没有找到任何有关如何自定义其功能的可靠文档,仅能满足特定需求.

This is my first OpenCart project, I have gone through the documentation and Googled a lot, I have played with a local installation, and I am trying to figure out if what I am asking is feasible without modifying the core code, I would like to avoid that. However, if there is no other way, I understand that OpenCart is an MVC(+L(anguage)) framework, but I haven't found any solid documentation on how to customize its functionality, only bit ans pieces for specific requirements.

如果可以的话,我想写下我的想法,请告知是否听起来可以:

If I may, I would like to write down, what I have in mind, please, advise if this sounds OK:

  • 我想再添加一个实体(对象/模型)来存储 订阅,订阅所属的用户,开始日期和结束日期以及 是否已被利用.基本上,订阅是正常的 订单,我希望将其存储为一个,我只需要 坚持几个领域.正如我所说,我需要运行两项检查:
  • 用户在当月是否使用了他的订阅?为了 这是我在考虑使用标志"isUsed"字段,该字段可以是 每次用户达到帐单日期时,使用cron作业重置. (在 我们的示例23/6、23/7).或者,我可以添加3个条目,其中一个用于 每个结算周期并进行相应的更新.
  • 订阅是否已过期?我可以检查一下到期日 订阅.
  • I would like to add one more entity (object/model) for storing the subscription, the user to which it belongs, start and end date and whether it has been utilized. Basically, a subscription is a normal order and I would like it to be stored like one, I just need to persist a few more fields. As I said, I need to run two checks:
  • Has the user utilized his subscription for the current month? For this I was thinking about having a flag "isUsed" field, which can be reset with a cron job, everytime a user reaches his billing date. (in our example 23/6, 23/7). Alternatively I could add 3 entries, one for each billing cycle and update them accordingly.
  • Has the subscription expired? I could check against the expiry date of the subscription.

我不知道如何在结帐时插入此功能,或者如何开始实施此功能.

I have no idea how to plug this functionality in, during checkout, or how to start implementing this.

我已经浏览了该论坛,并且在Google上进行了大量搜索,但是我还没有找到答案.我是一位经验丰富的Grails/Java EE开发人员,所以我很精通技术,以防这篇文章变得太技术过:-)

I have gone through the forum and Googled heavily, but I didn't find an answer yet. I am an experienced Grails/Java EE developer, so I am pretty technical in case this post gets too techie :-)

以上听起来可行吗,我在正确的轨道上吗?

Does the above sound feasible, and am I on the right track?

干杯,
伊拉克里斯

Cheers,
Iraklis

推荐答案

此功能超出了Opencart的功能范围,但是,如果您对PHP/CodeIgniter有所了解,则应该能够完成大部分/全部模组了解SQL也将是一件好事,但是如果您还不了解SQL,那么它的学习就会很快.

This functionality is way outside what Opencart is built for, but if you have some familiarity with PHP/CodeIgniter then you should be able to do most/all of the mods. SQL will be good to know as well, but if you don't already it is fast to learn.

我想说你的mod分为两个部分,每个部分都有自己的难度.

I would say your mods come in 2 parts each with it's own level of difficulty.

我正在使用OpenCart建立一个电子商务网站,我想提供 订阅.特别是3/6/12个月的订阅.我不是 对定期结算感兴趣(我知道有一些模块可用于 PayPal和Authorize.net).我希望用户提前付款一次.做 从一个配置点将其转换为3个伪产品 看法?我想到目前为止,这仅与产品有关是可行的 配置. 3种产品,每种都有一个价格.

I am setting up an e-commerce site using OpenCart and I want to offer subscriptions. Specifically 3/6/12 months subscriptions. I am NOT interested in recurring billing (I am aware that there are modules for PayPal and Authorize.net). I want users to pay once in advance. Does this translate to 3 pseudo-products from a configuration point of view? I guess this is feasible, so far, just with product configuration. 3 products, each with one price.

这是棘手的部分.用户每月支付的费用 每月只能一次在他们的范围内订购产品 结算周期".因此,如果用户支付了3个月的订阅费用 23/5:

Here comes the tricky part. For every month the users have paid they have access to order a product, only once a month, within their "billing cycle". So, if a user pays for a 3 month subscription on 23/5:

he can get one product in the period 23/5-22/6,
one in 23/6-22/7, and
one in 23/7-22/8

我认为我要做的是为每个订阅期添加一个产品,并且向每个产品发放相应的帐户信用额度,并使此信用额度达到每月购买一个产品的理想额度.

I think what I would do for this is add a product for each subscription length, and each product with issue them the appropriate account credit, and have this credit the perfect amount to buy one product per month for the subscription length.

为此,我建议添加一个函数以将资金添加到文件目录>模型>结帐> order.php(或您选择的任何模型)的数据库的customer_transaction字段中,然后调用它并在目录中添加数据controller> checkout> success.php.

To do this I recommend adding a function to add the funds into the customer_transaction field in the database in the file catalog>model>checkout>order.php (or any model you choose) then call it and add data in catalog>controller>checkout>success.php.

我认为验证客户已购买了适当的订阅产品并验证该购买是否尚未获得信用是很明智的.

I think it would be smart to verify that the customer has purchased the appropriate subscription product and to verify that there has not been a credit for that purchase already.

要确保他们每个月只获得一种产品,您将需要在script> controller> checkout> checkout.php的开头写一个脚本,如果他们尝试过多地获得产品,则会将它们重定向到错误消息.

To ensure they get only 1 product per month you will need to write a script to the beginning of catalog>controller>checkout>checkout.php to redirect them to an error message if they try to get products too often.

用户每月不能订购超过一种产品, 并且他应该也不能在22/8之后获得任何产品,除非 他续订了.而且,如果我能 进行cron工作,检查用户是否已将其订阅用于 当前月份,并发送嘿,获取本月的产品" 一种提醒电子邮件.

A user should not be able to order more than one products per month, and he should not also be able to get any products after 22/8, unless he renews his subscription. Moreover, it would be awesome if I could have a cron job, checking if a user has utilized his subscription for the current month, and send a "Hey, get your product for this month" kind of reminder email.

我什至不知道从何处开始,但是如果您愿意付费,可以发帖寻求帮助,并可能以较高的价格添加此功能.

I don't even know where to start on this one, but if you are willing to pay you could post for help and probably add this function for a good price.

这是我的第一个OpenCart项目,我已经完成了 文档和Google搜索很多,我曾经在当地玩过 安装,我试图找出我要问的是 在不修改核心代码的情况下可行,我想避免这种情况. 但是,如果没有其他方法,我知道OpenCart是 MVC(+ L(anguage))框架,但我还没有找到任何可靠的工具 关于如何自定义其功能的文档,只有一点点 满足特定要求的零件.

This is my first OpenCart project, I have gone through the documentation and Googled a lot, I have played with a local installation, and I am trying to figure out if what I am asking is feasible without modifying the core code, I would like to avoid that. However, if there is no other way, I understand that OpenCart is an MVC(+L(anguage)) framework, but I haven't found any solid documentation on how to customize its functionality, only bit ans pieces for specific requirements.

同样,这是Opencart要做的事情之外的方法,将需要进行一些修改.至于有关如何使用Opencart脚本以及如何对其进行自定义的文档,我也没有找到任何文档.学习过去两个月的经历对我来说是一个艰苦的努力,但是如果您的问题很短,通常可以在需要时让人们帮助您.

Again, this is way outside of what Opencart is built to do and will take several modifications. As for documentation on how to Opencart scripting works and how to customize it, I haven't found any either. It's been quite a struggle for me to learn what I have over the last 2 months, but if your questions are short you can usually get people to help you along the way when you need it.

如果可以的话,请写下我的想法, 告知听起来是否正确:

If I may, I would like to write down, what I have in mind, please, advise if this sounds OK:

I would like to add one more entity (object/model) for storing the subscription, the user to which it belongs, start and end date and

是否已被利用.基本上,订阅是正常的 订单,我希望将其存储为一个,我只需要 保留更多字段.

whether it has been utilized. Basically, a subscription is a normal order and I would like it to be stored like one, I just need to persist a few more fields.

我将这些属性添加为属性,您可以在属性标签中的网站catalog> attributes,catalog> attribute group和catalog> products后端的管理中执行此操作.

I would add these as attributes, you can do this in the administration on the back end of the website catalog>attributes, catalog>attribute groups, and catalog>products in the attributes tab.

正如我所说,我需要进行两项检查: 用户在当月是否使用了他的订阅?为此,我正在考虑拥有一个标志"isUsed"字段,该字段可以是 每次用户达到帐单日期时,使用cron作业重置. (在 我们的示例23/6、23/7).或者,我可以添加3个条目,其中一个用于 每个结算周期并进行相应的更新. 订阅是否已过期?我可以检查订阅的到期日期.

As I said, I need to run two checks: Has the user utilized his subscription for the current month? For this I was thinking about having a flag "isUsed" field, which can be reset with a cron job, everytime a user reaches his billing date. (in our example 23/6, 23/7). Alternatively I could add 3 entries, one for each billing cycle and update them accordingly. Has the subscription expired? I could check against the expiry date of the subscription.

我不知道该如何执行cron作业,但如果您能确定可以在数据库中搜索属性名称和值,然后在值在您的范围内时应用cron作业.

I don't know how to do this cron job but if you can figure that out you could search the database for the attribute name(s) and values then apply your cron job if the values are within your range.

希望这可以帮助您达到期望!

Hope this helps you with your expectations!

更新

要将数据插入数据库,您可以在admin/model/sale/customer.php中复制诸如addTransaction()函数之类的内容

To insert data into the database you could replicate something like the addTransaction () function in the admin/model/sale/customer.php

public function addTransaction($customer_id, $description = '', $amount = '', $order_id = 0) {
    $customer_info = $this->getCustomer($customer_id);

    if ($customer_info) { 
      $this->db->query("INSERT INTO " . DB_PREFIX . "customer_transaction
              SET customer_id = '" . (int)$customer_id . "',
              order_id = '" . (int)$order_id . "',
              description = '" . $this->db->escape($description) . "',
              amount = '" . (float)$amount . "',
              date_added = NOW()");
}

这在admin/controller/sale/customer.php中

And this in admin/controller/sale/customer.php

$this->load->model('sale/customer');

if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->user->hasPermission('modify', 'sale/customer')) { 

  $this->model_sale_customer->addTransaction($this->request->get['customer_id'], 
  $this->request->post['description'], $this->request->post['amount']);

  $this->data['success'] = $this->language->get('text_success');
} else {
  $this->data['success'] = '';
}

这篇关于OpenCart订阅模型(x个月)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆