Post by supak111 » Sat Mar 23, 2024 4:21 am

Hi I am testing using an extension called "Payment Discount Lite" to add a 25% OFF discount to "Cash on Delivery" payments. Issue I have is that in checkout the "Cash on Delivery" does show a 25% discount correctly but its missing a - negative sign in front of it.

I was wondering what I would need to edit to add a - negative sign in front?

I've look through OC "Cash On Delivery" extension and "Payment Discount Lite" extension and can't seem to figure out where to add the - negative sign

Image
Last edited by supak111 on Tue Mar 26, 2024 2:14 am, edited 1 time in total.

~ OC 3.0.3.2 and OCmods only ~


User avatar
Active Member

Posts

Joined
Fri Feb 13, 2015 12:09 pm

Post by Johnathan » Sat Mar 23, 2024 5:51 am

This would be a bug in the extension you're using. The internal value of the line item is separate from the textual display of the line item, so it sounds like it gets the value right, but the text wrong. Look for the 'value' parameter in the front-end file:

/catalog/model/extension/total/YOUREXTENSION.php

That's the one where you'd want to add the "-" if it's a negative value. The developer would be the best one to talk to though.

If you can't get it working, I have an extension called Simple Payment Fee that definitely doesn't have this problem. ;D

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by supak111 » Sat Mar 23, 2024 6:30 am

Extension is old, debt the developer cares much about it so many years later

Fontend total field only has this in it, I don't see anything here about text. I need to add the "-" between $ and 104.33

Code: Select all

<?php 
/**
 * 
 */
class ModelExtensionTotalPaymentDiscount extends Controller
{
	
	public function getTotal($total)
	{
		if ($this->config->get('total_payment_discount_status') && isset($this->session->data['payment_method']['code']) && $this->cart->getSubTotal()) {
			$discount_payment_method = $this->config->get('total_payment_discount_payment_type');

			if ($discount_payment_method == $this->session->data['payment_method']['code']) {
				$desc_text = $this->config->get('total_payment_discount_description');
				$discount = $this->config->get('total_payment_discount_percentage');
				$sort_order = $this->config->get('total_payment_discount_sort_order');
				
				$total['totals'][] = array(
					'code' => 'payment_discount',
					'title' => $desc_text,
					'value' => (($discount / 100) * $total['total']),
					'sort_order' => $sort_order,
				);

				$total['total'] -= (($discount / 100) * $total['total']);
			}
		}
	}
}

~ OC 3.0.3.2 and OCmods only ~


User avatar
Active Member

Posts

Joined
Fri Feb 13, 2015 12:09 pm

Post by ADD Creative » Sat Mar 23, 2024 5:42 pm

Try changing.

Code: Select all

'value' => (($discount / 100) * $total['total']),
To.

Code: Select all

'value' => -(($discount / 100) * $total['total']),

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by supak111 » Sun Mar 24, 2024 12:26 am

ADD Creative wrote:
Sat Mar 23, 2024 5:42 pm
Try changing.

Code: Select all

'value' => (($discount / 100) * $total['total']),
To.

Code: Select all

'value' => -(($discount / 100) * $total['total']),
That actually worked ツ, thank a bunch. I was actually afraid to mess with it since I don't know much about PHP and didn't want to mess up my checkout.

~ OC 3.0.3.2 and OCmods only ~


User avatar
Active Member

Posts

Joined
Fri Feb 13, 2015 12:09 pm

Post by paulfeakins » Mon Mar 25, 2024 8:41 pm

supak111 wrote:
Sun Mar 24, 2024 12:26 am
That actually worked ツ
Great, so please add [SOLVED] to the start of this topic title.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom
Who is online

Users browsing this forum: No registered users and 20 guests