Payment Method

Ask the community for help and support.
Post Reply
KenSO
Posts: 40
Joined: Fri Mar 05, 2021 12:01 pm
Has thanked: 35 times
Been thanked: 4 times

Payment Method

Post by KenSO »

Hello,

I find that when my customers use a 100% discount code to pay for items, the payment method stored with order is the default payment method I use. I was wondering how I'd change the value of the payment method to something like "Discount Code - Free Item" and save that to the database instead.

I believe this is handled on the checkout_confirmation.php page with something like:

<p class="w-100 mb-1">' . $order->info['payment_method'] . '</p>

So, how would I change this to insert a custom entry in database? I already have this code checking if item is zero rated or not, and it work on my checkout page:

$total_amount = preg_replace('/[^0-9-.]+/ ', '', $currencies->format($order->info['total']));
if ($total_amount > 1.00) {
echo '<p class="w-100 mb-1">' . $order->info['payment_method'] . '</p>';
} else {
echo '<p class="w-100 mb-1">Free Product</p>'; // I want this in database if item is free
}

Thank you for help in advance.
heatherbell
VIP Member
VIP Member
Posts: 1996
Joined: Mon Oct 07, 2019 4:39 am
Has thanked: 26 times
Been thanked: 175 times

Re: Payment Method

Post by heatherbell »

KenSO wrote: Wed Apr 06, 2022 1:03 am I find that when my customers use a 100% discount code to pay for items, the payment method stored with order is the default payment method I use.
Maybe a different solution like this - app.php/addons/free_addon/stripe_paymen ... 1185#p1185
KenSO
Posts: 40
Joined: Fri Mar 05, 2021 12:01 pm
Has thanked: 35 times
Been thanked: 4 times

Re: Payment Method

Post by KenSO »

heatherbell wrote: Wed Apr 06, 2022 5:28 am Maybe a different solution like this - app.php/addons/free_addon/stripe_paymen ... 1185#p1185
I'd like to explore this method you suggested but I need some help with how to do it. Unfortunately, the topic is locked and I can't post to ask author.
heatherbell
VIP Member
VIP Member
Posts: 1996
Joined: Mon Oct 07, 2019 4:39 am
Has thanked: 26 times
Been thanked: 175 times

Re: Payment Method

Post by heatherbell »

KenSO wrote: Wed Apr 06, 2022 7:21 pm Unfortunately, the topic is locked and I can't post to ask author.
Your question has nothing to do with support for that addon so post questions for help here.
heatherbell
VIP Member
VIP Member
Posts: 1996
Joined: Mon Oct 07, 2019 4:39 am
Has thanked: 26 times
Been thanked: 175 times

Re: Payment Method

Post by heatherbell »

KenSO wrote: Wed Apr 06, 2022 7:21 pm I'd like to explore this method you suggested but I need some help with how to do it.
Have you tried with the advice shown in the link?
I am just following the advice "have a look into the cod module how it is done for virtual orders."
I look there and see https://github.com/CE-PhoenixCart/Phoen ... hp#L28-L32
So, as advised in the link, changing the line https://github.com/CE-PhoenixCart/Phoen ... od.php#L29 to

Code: Select all

      if ($GLOBALS['order']->info['total'] > 0) {
would disable that if order>0 so it only shows if order is 0.
Similarly for your "default payment method", as advised in the link,

Code: Select all

if ($GLOBALS['order']->info['total'] == 0) {
would disable that if order=0 so it only shows if order>0
Of course, you do not say how shipping is handled so presuming shipping is also free because this would not make sense if a payment is taken for shipping.
KenSO
Posts: 40
Joined: Fri Mar 05, 2021 12:01 pm
Has thanked: 35 times
Been thanked: 4 times

Re: Payment Method

Post by KenSO »

@heatherbell Thank you very much. I appreciate your help with this.
Post Reply