Post by ArtGallery » Wed May 27, 2020 2:05 am

First off, unfortunately I have no funds to pay for the "Restrict Payment Methods" extension that appears to offer this function and more.

I have found some posts that describe how to do this in older versions of OpenCart, but I was not able to find where to do the same thing in OC 3.0.x as the paypal.php file contents in the closest looking subdirectory was not the same.

Any help on how and if this can be done with a simple php file edit would be appreciated.

New member

Posts

Joined
Sat Apr 21, 2018 7:54 am

Post by xxvirusxx » Wed May 27, 2020 2:33 am

ArtGallery wrote:
Wed May 27, 2020 2:05 am
I have found some posts that describe how to do this in older versions of OpenCart,
You should post..

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by ArtGallery » Wed May 27, 2020 2:49 am

Here is one for OC version 1.5

viewtopic.php?t=123593

I looked at the paypal.php file in this directory catalog/model/extension/payment, but it wasn't at all like the one in the post and I couldn't figure out if it was perhaps a different paypal.php file somewhere else or if the OC 3.0.x version was just different now.

New member

Posts

Joined
Sat Apr 21, 2018 7:54 am

Post by letxobnav » Wed May 27, 2020 10:55 am

in pp standard minimum check is done via

Code: Select all

		if ($this->config->get('payment_pp_standard_total') > $total) {
			$status = false;
meaning: if minimum total in settings is greater than the total, disable this module.

in catalog/model/extension/payment/pp_standard.php

you could change it to

Code: Select all

		if ($total == 0 || $this->config->get('payment_pp_standard_total') < $total) {
			$status = false;
meaning: if total is zero or total in settings is less than the total, disable this module.

that would make that field max iso min.



you can also change this:

Code: Select all

		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payment_pp_standard_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");

		if ($this->config->get('payment_pp_standard_total') > $total) {
			$status = false;
		} elseif (!$this->config->get('payment_pp_standard_geo_zone_id')) {
			$status = true;
		} elseif ($query->num_rows) {
			$status = true;
		} else {
			$status = false;
		}

to this:

Code: Select all

		if ($this->config->get('payment_pp_standard_total') > $total) {
			$status = false;
		} elseif (!$this->config->get('payment_pp_standard_geo_zone_id')) {
			$status = true;
		} else {
			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payment_pp_standard_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");
			if ($query->num_rows) {
				$status = true;
			} else {
				$status = false;
			}
		}

as it is silly to always execute a query on the zones if it is not needed.

in your case:

Code: Select all

		if ($total == 0 || $this->config->get('payment_pp_standard_total') < $total) {
			$status = false;
		} elseif (!$this->config->get('payment_pp_standard_geo_zone_id')) {
			$status = true;
		} else {
			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payment_pp_standard_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");
			if ($query->num_rows) {
				$status = true;
			} else {
				$status = false;
			}
		}

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by letxobnav » Wed May 27, 2020 1:41 pm

If you want to change the minimum field into a range field like min-max you can change

Code: Select all

		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payment_pp_standard_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");

		if ($this->config->get('payment_pp_standard_total') > $total) {
			$status = false;
		} elseif (!$this->config->get('payment_pp_standard_geo_zone_id')) {
			$status = true;
		} elseif ($query->num_rows) {
			$status = true;
		} else {
			$status = false;
		}

to

Code: Select all

		// defaults
		$status = true;
		$limit_min = 1;
		$limit_max = 1000000;
		
		// process total limits separated by dash
		if (strstr($this->config->get('payment_pp_standard_total'),'-')) {
			$min_max_totals = explode('-',$this->config->get('payment_pp_standard_total'));
			if (is_numeric($min_max_totals[0])) $limit_min = (float)$min_max_totals[0];
			if (is_numeric($min_max_totals[1])) $limit_max = (float)$min_max_totals[1];
		}
		
		// determine whether to disable
		if ($total < $limit_min || $total > $limit_max) {
			$status = false;
		} elseif ($this->config->get('payment_pp_standard_geo_zone_id')) {
			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payment_pp_standard_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");
			if (!$query->num_rows) {
				$status = false;
			}
		}

then you can input 1-500 in that field as in min-max total limits

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by ArtGallery » Wed May 27, 2020 3:02 pm

Thanks for the suggestions. It will take me quite a while to figure all that out. Hopefully I can get it to work. The min/max is the most attractive. There are very few items that I want them to be able to use PayPal for the payment and they are within $10 of each other.

There is no file with that name in that directory. Only pp_braintree.php and paypal.php. I don't want to use the braintree version so I am assuming I should use the one named paypal.php

New member

Posts

Joined
Sat Apr 21, 2018 7:54 am

Post by letxobnav » Wed May 27, 2020 4:12 pm

then you are probably using 3.0.3.3 where they removed a lot of payment methods.
Use paypal.php, similar code.

just replace

Code: Select all

$this->config->get('payment_pp_standard_total')
with

Code: Select all

$this->config->get('payment_paypal_total')
and replace

Code: Select all

$this->config->get('payment_pp_standard_geo_zone_id')
with

Code: Select all

$this->config->get('payment_paypal_geo_zone_id')

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan
Who is online

Users browsing this forum: Semrush [Bot] and 215 guests