• Resolved jinsley8

    (@jinsley8)


    When wallet total is less than Cart total, the checkout order summary says “Via Wallet” to show the wallet deduction?

    How can I overwrite this?

    I see in class-woo-wallet-frontend.php there is this function but I’m not sure how to make a filter to change ‘name’ in the array.

    /**
        * Sets partial payment amount to cart as negative fee
        * @since 1.2.1
      */
      public function woo_wallet_add_partial_payment_fee() {
          $parial_payment_amount = apply_filters('woo_wallet_partial_payment_amount', woo_wallet()->wallet->get_wallet_balance(get_current_user_id(), 'edit'));
            if ($parial_payment_amount > 0) {
                $fee = array(
                    'id' => '_via_wallet_partial_payment',
                    'name' => __('Via Wallet', 'woo-wallet'),
                    'amount' => (float) -1 * $parial_payment_amount,
                    'taxable' => false,
                    'tax_class' => '',
                );
            if (is_enable_wallet_partial_payment() && $parial_payment_amount) {
                wc()->cart->fees_api()->add_fee($fee);
            } else {
               $all_fees = wc()->cart->fees_api()->get_fees();
               if (isset($all_fees['_via_partial_payment_wallet'])) {
                   unset($all_fees['_via_partial_payment_wallet']);
                   wc()->cart->fees_api()->set_fees($all_fees);
               }
            }
         }
      }
    • This topic was modified 4 years, 4 months ago by jinsley8.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter jinsley8

    (@jinsley8)

    I’m currently doing this to change the fee name but there surely has to be a better solution?

    // Edit woo-wallet partial payment name
    function remove_woo_wallet_add_partial_payment_fee(){
      remove_action('woocommerce_cart_calculate_fees', array(Woo_Wallet_Frontend::instance(), 'woo_wallet_add_partial_payment_fee'));
    }
    add_action('init','remove_woo_wallet_add_partial_payment_fee');
    
    function new_woo_wallet_add_partial_payment_fee() {
      $parial_payment_amount = apply_filters('woo_wallet_partial_payment_amount', woo_wallet()->wallet->get_wallet_balance(get_current_user_id(), 'edit'));
      if ($parial_payment_amount > 0) {
        $fee = array(
          'id' => '_via_wallet_partial_payment',
          'name' => __('HR $ Used', 'woo-wallet'),
          'amount' => (float) -1 * $parial_payment_amount,
          'taxable' => false,
          'tax_class' => '',
        );
        if (is_enable_wallet_partial_payment() && $parial_payment_amount) {
          wc()->cart->fees_api()->add_fee($fee);
        } else {
          $all_fees = wc()->cart->fees_api()->get_fees();
          if (isset($all_fees['_via_partial_payment_wallet'])) {
            unset($all_fees['_via_partial_payment_wallet']);
            wc()->cart->fees_api()->set_fees($all_fees);
          }
        }
      }
    }
    add_action('woocommerce_cart_calculate_fees', 'new_woo_wallet_add_partial_payment_fee');
    Plugin Author Subrata Mal

    (@subratamal)

    @jinsley8 yes we will add a filter to change the fee name in our next update.

    Thread Starter jinsley8

    (@jinsley8)

    Awesome, thanks!

    I want to disable deducting balance from the wallet, for the cashback product.
    Is it possible?

    Please help!
    I want to disable customers from using wallet balance when they ordering cashback products.
    Is it possible?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Edit “Via Wallet” label when partial payment on checkout’ is closed to new replies.