Exemplo n.º 1
0
function addRoyaltyPoint($order_id)
{
    if (!get_current_user_id()) {
        return false;
    }
    $order = new WC_Order($order_id);
    $subtotal = $order->get_subtotal();
    $pointsAdjustment = $subtotal - $order->cart_discount;
    $cardNo = get_cimyFieldValue(get_current_user_id(), 'CARD_NO');
    $userInfo = array("CARD_NO" => $cardNo, "PLUS_POINT" => number_format($pointsAdjustment, 2));
    $royaltyCardAPI = new royaltyCardAPI();
    $rtnIncrementPoints = $royaltyCardAPI->incrementPoints($userInfo);
    if ($rtnIncrementPoints == 'SUCCESS') {
        //echo 'aaaa';
    } else {
        return new WP_Error(444, $rtnIncrementPoints);
    }
}