/**
 * Updates the Gift Card and the order information when the order is processed
 *
 */
function rpgc_update_card($order_id)
{
    global $woocommerce;
    $giftCard_id = WC()->session->giftcard_post;
    if ($giftCard_id != '') {
        //Decrease Ballance of card
        $giftcard = new WPR_Giftcard();
        $payment = $giftcard->wpr_get_payment_amount();
        $giftcard->wpr_decrease_balance($giftCard_id);
        $giftCard_IDs = get_post_meta($giftCard_id, 'wpr_existingOrders_id', true);
        $giftCard_IDs[] = $order_id;
        $newBalance = wpr_get_giftcard_balance($giftCard_id);
        update_post_meta($giftCard_id, 'rpgc_balance', $newBalance);
        // Update balance of Giftcard
        update_post_meta($giftCard_id, 'wpr_existingOrders_id', $giftCard_IDs);
        // Saves order id to gifctard post
        update_post_meta($order_id, 'rpgc_id', $giftCard_id);
        update_post_meta($order_id, 'rpgc_payment', $payment);
        update_post_meta($order_id, 'rpgc_balance', $newBalance);
        WC()->session->idForEmail = $order_id;
        unset(WC()->session->giftcard_payment, WC()->session->giftcard_post);
    }
    if (isset(WC()->session->giftcard_data)) {
        update_post_meta($order_id, 'rpgc_data', WC()->session->giftcard_data);
        unset(WC()->session->giftcard_data);
    }
}
 public static function wpr_discount_total($total, $cart)
 {
     $giftcard = new WPR_Giftcard();
     $discount = $giftcard->wpr_get_payment_amount();
     $total -= $discount;
     //WC()->session->discount_cart = $discount;
     return $total;
 }