在計算訂單總額時調用,這可用於操縱最終總額。
參數
變量 | 類型 | 注意 |
---|---|---|
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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。