在计算订单总额时调用,这可用于操纵最终总额。
参数
变量 | 类型 | 注意 |
---|---|---|
products | array | 购物车中产品的索引数组。键包括pid 、domain 、billingcycle 、configoptions 、customfields 、addons 、server 、hostname |
domains | array | 购物车中的域注册和转移的索引数组。键包括 type 、 domain 、 regperiod |
响应
返回一个由调整 description
、 amount
和 taxed
组成的数组(布尔)
示例代码
<?php
add_hook('CartTotalAdjustment', 1, function($vars) {
$cart_adjustments = array();
$products = $tlds = [];
foreach ($vars['products'] as $product) {
$products[] = $product['pid'];
}
foreach ($vars['domains'] as $domain) {
if ($domain['type'] == 'register') {
$domainParts = explode('.', $domain['domain'], 2);
$tlds[] = $domainParts[1];
}
}
if (in_array(1, $products) && in_array('co.uk', $tlds)) {
$cart_adjustments = [
"description" => "Custom discount for buying product 1 and a co.uk domain",
"amount" => "-18.00",
"taxed" => false,
];
}
return $cart_adjustments;
});
相关用法
- PHP WHMCS CartSubdomainValidation用法及代码示例
- PHP WHMCS CartItemsTax用法及代码示例
- PHP CachingIterator __construct()用法及代码示例
- PHP CachingIterator getCache()用法及代码示例
- PHP CachingIterator current()用法及代码示例
- PHP WHMCS CalcAffiliateCommission用法及代码示例
- PHP CachingIterator key()用法及代码示例
- PHP CachingIterator setFlags()用法及代码示例
- PHP WHMCS CapturePayment用法及代码示例
- PHP CachingIterator next()用法及代码示例
- PHP CachingIterator rewind()用法及代码示例
- PHP WHMCS CancellationRequest用法及代码示例
- PHP CachingIterator getFlags()用法及代码示例
- PHP CachingIterator getInnerIterator()用法及代码示例
- PHP WHMCS CancelOrder用法及代码示例
- PHP WHMCS CancelAndRefundOrder用法及代码示例
- PHP WHMCS ClientAreaPageDownloads用法及代码示例
- PHP WHMCS ClientAreaHeaderOutput用法及代码示例
- PHP WHMCS CreateProject用法及代码示例
- PHP WHMCS ClientAreaPageSupportTickets用法及代码示例
- PHP WHMCS ClientAreaPageDomainDNSManagement用法及代码示例
- PHP WHMCS ClientAreaPageAffiliates用法及代码示例
- PHP WHMCS ClientAreaPageViewInvoice用法及代码示例
- PHP WHMCS ClientAreaPageProductsServices用法及代码示例
- PHP WHMCS CustomFieldSave用法及代码示例
注:本文由纯净天空筛选整理自whmcs.com大神的英文原创作品 CartTotalAdjustment。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。