在購物車中計算插件價格時執行。
參數
變量 | 類型 | 注意 |
---|---|---|
key | int | 購物車會話中產品的 key |
pid | int | 產品編號 |
addonid | int | 插件標識 |
proddata | array | 購買新產品的插件的產品數據 |
serviceid | int | 為現有服務購買插件時的服務 ID |
響應
插件定價可以被覆蓋。接受 key ‘setup’ and ‘recurring’ 的返回。
示例代碼
<?php
use WHMCS\Service\Service;
add_hook('OrderAddonPricingOverride', 1, function($vars) {
$return = [];
if (array_key_exists('proddata', $vars)) {
/**
* This is a product and addon purchase
*/
if ($vars['addonid'] == 1 && $vars['proddata']['pid'] == 1) {
$return = ['setup' => '1.00', 'recurring' => '5.00',];
}
} else {
/**
* This is an addon only purchase for existing service
*/
$serviceData = Service::find($vars['serviceid']);
if ($serviceData && $vars['addonid'] == 1 && $serviceData->packageId == 1) {
$return = ['setup' => '1.00', 'recurring' => '5.00',];
}
}
return $return;
});
相關用法
- PHP WHMCS OrderPaid用法及代碼示例
- PHP WHMCS OrderProductUpgradeOverride用法及代碼示例
- PHP WHMCS OrderDomainPricingOverride用法及代碼示例
- PHP WHMCS OrderFraudCheck用法及代碼示例
- PHP WHMCS OrderProductPricingOverride用法及代碼示例
- PHP WHMCS OpenTicket用法及代碼示例
- PHP WHMCS OverrideModuleUsernameGeneration用法及代碼示例
- PHP WHMCS OverrideOrderNumberGeneration用法及代碼示例
- PHP WHMCS ClientAreaPageDownloads用法及代碼示例
- PHP Ds\Map isEmpty()用法及代碼示例
- PHP PHPUnit assertIsNotFloat()用法及代碼示例
- PHP disk_total_space()用法及代碼示例
- PHP ReflectionClass getTraitAliases()用法及代碼示例
- PHP hash_hmac()用法及代碼示例
- PHP String wordwrap()用法及代碼示例
- PHP XMLWriter endPi()用法及代碼示例
- PHP SimpleXMLElement children()用法及代碼示例
- PHP IntlCalendar getTimeZone()用法及代碼示例
- PHP SplPriorityQueue isCorrupted()用法及代碼示例
- PHP XMLReader::getParserProperty()用法及代碼示例
- PHP imagegif()用法及代碼示例
- PHP imageresolution()用法及代碼示例
- PHP array_reverse()用法及代碼示例
- PHP IntlCalendar getActualMinimum()用法及代碼示例
- PHP WHMCS DomainGetWhoisInfo用法及代碼示例
注:本文由純淨天空篩選整理自whmcs.com大神的英文原創作品 OrderAddonPricingOverride。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。