當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


PHP WHMCS OrderProductUpgradeOverride用法及代碼示例

在計算產品升級訂單時執行。

參數

變量 類型 注意
oldproductid int
oldproductname string
newproductid int
newproductname string
days int
totaldays int
newproductbillingcycle string
price float
discount float
promoqualifies bool

響應

返回要覆蓋的參數的任何鍵 -> 值對。例如返回數組(‘discount’ => 10.00,);

示例代碼

<?php

use WHMCS\Carbon;

add_hook('OrderProductUpgradeOverride', 1, function($vars) {
    $return = [];

    if ($vars['newproductid'] == 15) {
        /**
         * No promotion should be applied to product 15
         */
        $return['promoqualifies'] = false;
    }
    if (Carbon::now()->toDateString() == '2016-12-25') {
        /**
         * Offer half price upgrade on Christmas Day
         * This can also be done by halving the $vars['price'] and returning that.
         */
        $return['totaldays'] = round($vars['totaldays'] / 2);
    }
    return $return;
});

相關用法


注:本文由純淨天空篩選整理自whmcs.com大神的英文原創作品 OrderProductUpgradeOverride。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。