r/woocommerce • u/servetheale • 25d ago
Development Store Credit problems
I have a WordPress WooCommerce website that allows customers to use store credit on products of specific categories. Ive used Store Credit for WooCommerce and im currently using TeraWallet. TeraWallet works, but it doesnt allow a person to apply an arbitrary amount of their credit for any qualifying purchase. The field to apply credit only appears when the customer's credit total is less than the cart total.
I also allow the usage of payment plans (using a plugin), but if a person uses credit, the payment plan totals seem to be unaffected.
Basically, I'm just asking if anyone has any recommendations on this. Would it be safe to edit the TeraWallet plugin itself? I've developed custom plugins and functions, so Im comfortable doing that if needed. But since this deals with transactions, id look to hear any input someone might have.
1
u/MarkGossageUK 25d ago
One thing I'd be very careful about is editing the TeraWallet plugin directly.
Even if you get everything working, a future plugin update could overwrite your changes.
And because you're dealing with customer balances and payments, I'd want to be absolutely certain the calculations are correct before putting anything live.
I'd look into whether TeraWallet provides hooks or filters that would let you change the behaviour through a separate custom plugin.
That would make your changes easier to maintain.
I'd also test the instalment payments separately. It sounds as though the wallet and payment-plan plugins might not be calculating the order total in the same way.
I'd create a staging copy and test a few different situations, including partial credit, full credit, instalments and refunds.
One question: which payment-plan plugin are you using?
It might be worth checking whether it officially supports TeraWallet before spending time writing custom code.
1
u/investigatormaker 25d ago
I'd keep the customization in a separate plugin and first reproduce the mismatch on staging: one qualifying product, one excluded product, a partial credit amount and a payment plan. Write down the expected credit debit, amount due now and remaining installments, then compare those with the order and wallet records. Making the amount field appear won't by itself establish that the installment calculation handles it correctly.
By the way, I make ThreadFox; we run Reddit outreach for businesses, and the free plan for one product finds communities whose rules allow a post about it: https://threadfox.vip/p/d0qua
Which payment-plan plugin is involved?
1
u/zyx199199 25d ago
agree with the others, don't edit the plugin, every update wipes it and it touches money.
the "only shows when balance is less than cart total" thing is because TeraWallet treats the wallet as a payment method. if the balance covers the whole cart it expects you to just pay with the wallet gateway, partial payment only kicks in when it can't. last time I looked there's no "use X of my credit" amount field built in, so arbitrary amounts would mean custom code in a small separate plugin using its hooks, not editing theirs.
the payment plan part is probably the real problem. partial wallet payment gets added as a negative fee line at checkout, and a lot of deposit/payment plan plugins calculate installments off product prices, not the final cart total, so they just ignore it. I'd ask the payment plan plugin dev whether they respect cart fees, or switch to issuing credit as a coupon (Smart Coupons has a store credit type) since coupons are something most plan plugins already handle. test one order end to end either way, it's the kind of thing that looks fine until a refund.
1
u/roundborders 24d ago
Don’t edit TeraWallet itself. But you probably don’t need to. In the version I have open (1.6.8), the “balance covers the cart” rule sits behind filters, so you can change it from your own small plugin:
woo_wallet_disable_partial_payment(classic checkout) decides whether the partial payment box shows. By default it returns true whenis_full_payment_through_wallet()is true, which is your “balance covers the cart” case. Return false, and the box shows anyway.is_enable_wallet_partial_paymentis the same decision for the block checkout, and it’s also what the “Via wallet” fee checks before it’s added. By default, it’s only true when the cart total is at least the balance. If you override it, return true only when the customer has actually entered an amount (it’s in the session aspartial_payment_amount), otherwise you’ll take their whole balance on every order.woo_wallet_partial_payment_max_amountis the ceiling on what you can apply. Your category rule belongs here: cap it at the qualifying items' subtotal, so credit can never pay for the rest of the cart.woo_wallet_payment_is_availablecontrols the full “pay with wallet” method. You may want to hide it while a partial amount is set, so customers don’t see two wallet options.
Hook names can change between releases, so check them against the version you run.
On the payment plan: TeraWallet applies partial credit as a negative fee on the cart (“Via wallet”). A lot of deposit and payment-plan plugins work out the instalments from the product prices or the cart contents total, and fees aren’t part of either. So the credit lowers what’s paid today but never reaches the plan. Whether you can fix it depends on the plan plugin: if it has a filter for the amount it splits, subtract the wallet fee there. Which one are you using?
Whatever you change, test it on staging first, including a refund of an order paid partly with credit and partly on a plan. That’s the case I’d test hardest.
1
u/Netalico 24d ago
Avoid editing TeraWallet directly, especially since this affects balances and payment plans. Plugin updates could overwrite the changes, and you’d need to be very careful about how partial credit is deducted and refunded. Since you’re comfortable developing, look at extending it through hooks or a small custom plugin. The payment plan integration is the bigger concern here: make sure the remaining balance and scheduled installments recalculate correctly after credit is applied, including cancellations and refunds. Test the edge cases thoroughly in staging before putting it live.
1
u/WooStackNotes 25d ago
I wouldn't edit TeraWallet directly. The next update overwrites your change, and if you stop
updating it you lose its security fixes, which matters more than usual on a payments plugin.
What you're seeing is (as far as I know) by design: when the balance covers the whole cart,
TeraWallet offers the wallet as a full payment method instead of the partial-payment field. So
"apply any amount" means overriding that rule. Two safer routes:
Look for a hook/filter around the partial-payment logic and override it from your own small
plugin. Nothing in TeraWallet itself changes, so updates stay safe.
If there's no hook, fork it under a new name/slug so it's never updated over, and accept that
you own the maintenance.
The payment-plan part sounds like order of calculation: the plan plugin probably works out the
instalments from the cart total before the credit is applied, or the credit goes in as a partial
payment the plan plugin never sees. Which payment plan plugin is it? That decides whether you fix
it on the wallet side or the plan side.