thelia / creditaccount-module
Requires
- thelia/installer: ~1.1
README
信用账户
此模块是创建类似赞助或资产管理模块的基础。
##安装
$ cd local/modules
$ git clone https://github.com/thelia-modules/CreditAccount
您也可以从github下载zip文件。
之后,您只需在后台办公室激活该模块。
如何使用它
在您的后台办公室,在每个客户版本页面上,您可以添加一个新的信用账户。
集成
在后台办公室中,该模块放置在account.bottom
钩子中,该钩子位于客户详情页。
此模块提供两个循环。一个用于信用账户历史记录,另一个用于当前信用账户。
存在一个路由,允许客户在其订单总金额的范围内使用其信用账户,不包括运费。您只需调用/creditAccount/use
,控制器将找到当前客户的信用账户并将可用金额放入折扣金额中。
要取消使用信用账户,请使用/creditAccount/cancel
路由。
调用这些路由将把客户重定向到order.invoice
路由。
该模块创建了一个钩子order-invoice.before-discount
,其中插入允许您的客户使用其信用的代码。您必须在order-invoice.html
模板文件中放置此钩子,例如在“折扣”块之前。
要在模板中的order-invoice.html
文件中插入的代码
{hook name='order-invoice.before-discount'}
过期
从本模块的1.3.0版本开始,您可以启用信用的过期。
只需进入CreditAccount配置并启用它(默认情况下是禁用的),然后您可以选择过期延迟(以月为单位)。
过期日期是使用信用最后一次日期加上您的过期延迟计算得出的。
过期在每个客户添加购物车中的项目时都会检查,但如果您想,您可以设置一个命令作为cron来强制过期检查php Thelia creditaccount:expiration:check
。
钩子
该模块使用前台account.bottom
钩子来在客户“我的账户”页面显示账户历史记录。
它还使用以下后台办公室钩子
account.bottom
以在客户详情中显示客户账户历史记录。order-edit.after-order-product-list
以在订单详情中显示通过订单添加到信用账户的条目。
它创建了一个order-invoice.before-discount
,必须将其插入到order-invoice.html
模板文件中。
循环
credit_account_history循环
列出特定信用账户的信用账户历史记录。
输入参数
- credit_account : 信用账户ID,这是一个必填参数。
- order : 订单ID,仅获取与此订单相关的条目。
输出变量
$CREDIT_AMOUNT
条目金额,无论是正数还是负数,都是默认货币$ORDER_ID
相关的订单ID,其中获得了或使用了金额。0表示此条目是手动操作$HAS_ORDER_ID
对于手动操作为false,如果与订单相关则为true$WHO_DID_IT
执行手动操作的管理员名称$CREATE_DATE
$UPDATE_DATE
示例
{loop type="order" name="order-account-order" id=$order_id customer="*"} {loop type="credit_account" name="credit_account" customer=$CUSTOMER} {loop type="credit_account_history" name="credit_account_history" credit_account=$ID order=$order_id} {if $CREDIT_AMOUNT < 0} {$class='class="text-danger"'} {else} {$class=''} {/if} <li>{intl l="New entry in customer credit account : <span %class>%amount</span>" class=$class amount={format_money number=$CREDIT_AMOUNT symbol=$currencySymbol}}</li> {/loop} {/loop} {elseloop rel="order-account-order"} <li>{intl l="No new entry in customer credit account for this order."}</li> {/elseloop} {/loop}
credit_account循环
检索指定客户的当前信用账户
输入参数
- 客户:客户ID。如果没有指定,则返回所有信用账户。
输出变量
- $ID:信用账户ID
- $CREDIT_AMOUNT:默认货币中的当前余额
- $CREATE_DATE
- $UPDATE_DATE
示例用法
{loop type="credit_account" name="credit_account" customer={customer attr="id"}} {if $CREDIT_AMOUNT > 0} <tr> <th colspan="2" class="discount"> <a class="btn btn-success" href="{url path="/creditAccount/use"}"> {intl l="Use my credit account (%amount available)" amount={format_money number=$CREDIT_AMOUNT symbol=$currencySymbol}} </a> </th> </tr> {/if} {/loop}
credit_account_usage 循环
返回当前客户当前订单使用的信用金额,如果没有使用信用金额则返回空。
输入参数
无。
输出变量
$AMOUNT_USED
`在当前订单中使用的信用账户金额(默认货币)。
示例用法
{loop type="credit_account_usage" name="credit-used"} {intl l="You're using %amount from your credit account." amount={format_money number=$AMOUNT_USED symbol=$currencySymbol}} <a class="btn btn-xs btn-warning" href="{url path="/creditAccount/cancel"}">{intl l='Cancel'}</a> {/loop}
监听器
此模块是创建类似赞助或资产管理模块的基础。因此,一些监听器预先配置用于在其他模块中使用。
creditAccount.addAccount
此监听器用于向客户的信用账户添加金额。您必须分发一个CreditAccount\Event\CreditAccountEvent
类
示例
//retrieve the dispatcher for using it after. I put it in $dispatcher
// retrieve a customer. For the example I retrieve a random customer, obviously not do that in your application
$customer = \Thelia\Model\CustomerQuery::create()->findOne();
//the amount I want to add to the current customer's credit account
$amount = 10;
// Create the event to dispatch
$event = new \CreditAccount\Event\CreditAccountEvent($customer, $amount)
//dispatch the event
$dispatcher->dispatch(\CreditAccount\CreditAccount::CREDIT_ACCOUNT_ADD_AMOUNT, $event);
法语说明
客户信用
此模块允许为每位客户添加信用。它对于像忠诚度或资产管理这样的模块也是必要的。
##安装
$ cd local/modules
$ git clone https://github.com/thelia-modules/CreditAccount
您也可以从GitHub下载zip文件。
然后您只需在您的后台激活模块。
使用
在您的后台,您可以为每位客户添加忠诚度信用。要这样做,请转到客户账户编辑页面。
集成
此模块有三个循环可用:一个用于信用账户历史记录,一个用于获取账户余额,一个用于了解当前订单中账户的使用情况。
要允许客户使用其信用,只需调用路由/creditAccount/use
。控制器将自动找到相关客户的信用,并将其添加到折扣金额中。要取消信用使用,请使用路由/creditAccount/cancel
此模块创建了一个新的钩子,order-invoice.before-discount
,其中可以插入允许客户使用其忠诚度信用的代码。将此钩子的代码放置在您的模板的order-invoice.html
文件中,例如在折扣块之前。
要在模板中的order-invoice.html
文件中插入的代码
要在模板的order-invoice.html
文件中插入的钩子代码
{hook name='order-invoice.before-discount'}
循环
credit_account_history 循环
列出特定账户的操作历史记录
参数
- credit_account:信用账户ID,账户标识符,必填参数
结果
- $CREDIT_AMOUNT
- $ORDER_ID 关联订单的ID,如果是手动操作则为0
- $HAS_ORDER_ID 手动操作为false,否则为true。
- $WHO_DID_IT 手动操作的管理员姓名。
- $CREATE_DATE
- $UPDATE_DATE
使用示例
{loop type="order" name="order-account-order" id=$order_id customer="*"} {loop type="credit_account" name="credit_account" customer=$CUSTOMER} {loop type="credit_account_history" name="credit_account_history" credit_account=$ID order=$order_id} {if $CREDIT_AMOUNT < 0} {$class='class="text-danger"'} {else} {$class=''} {/if} <li>{intl l="New entry in customer credit account : <span %class>%amount</span>" class=$class amount={format_money number=$CREDIT_AMOUNT symbol=$currencySymbol}}</li> {/loop} {/loop} {elseloop rel="order-account-order"} <li>{intl l="No new entry in customer credit account for this order."}</li> {/elseloop} {/loop}
信用账户循环
获取给定客户的当前信用
参数
- 客户:客户ID。如果不存在,则返回所有账户的信息。
结果
- $ID:信用账户ID,账户标识符
- $CUSTIMER_ID:客户标识符
- $CREDIT_AMOUNT:账户余额
- $CREATE_DATE
- $UPDATE_DATE
使用示例
{loop type="credit_account" name="credit_account" customer={customer attr="id"}} {if $CREDIT_AMOUNT > 0} <tr> <th colspan="2" class="discount"> <a class="btn btn-success" href="{url path="/creditAccount/use"}"> {intl l="Use my credit account (%amount available)" amount={format_money number=$CREDIT_AMOUNT symbol=$currencySymbol}} </a> </th> </tr> {/if} {/loop}
credit_account_usage 循环
此循环返回当前客户当前订单使用的信用,如果账户未在订单中使用则返回空。
参数
无。
结果
$AMOUNT_USED
`在当前订单中使用的信用账户金额(默认货币)。
使用示例
{loop type="credit_account_usage" name="credit-used"} {intl l="You're using %amount from your credit account." amount={format_money number=$AMOUNT_USED symbol=$currencySymbol}} <a class="btn btn-xs btn-warning" href="{url path="/creditAccount/cancel"}">{intl l='Cancel'}</a> {/loop}
监听器
此模块是创建类似忠诚度或资产管理模块的基础。一些“监听器”预先配置用于在其他模块中使用。
creditAccount.addAccount
此监听器用于向信用账户添加金额。您必须分发一个CreditAccount\Event\CreditAccountEvent
实例的事件。
使用示例
//retrieve the dispatcher for using it after. I put it in $dispatcher
// retrieve a customer. For the example I retrieve a random customer, obviously not do that in your application
$customer = \Thelia\Model\CustomerQuery::create()->findOne();
//the amount I want to add to the current customer's credit account
$amount = 10;
// Create the event to dispatch
$event = new \CreditAccount\Event\CreditAccountEvent($customer, $amount)
//dispatch the event
$dispatcher->dispatch(\CreditAccount\CreditAccount::CREDIT_ACCOUNT_ADD_AMOUNT, $event);