I am making a payment method for opencart4, and while setting the validations for min/max order total and country, I hit a wall.
The situation is the following:
When clicking the "payment method" choose button in the checkout page, it calls the getMethods() function inside my extension, but the argument for $address is empty, so is $total.
I went and step-debugged for the example payment method that comes with opencart 4 and its $address is also empty (note that i did register a consumer user and filled in the address)
I expected the $address and $total arguments to be passed automaticaly like in opencart 3, am I missing something?
Here is an excerpt of the opencar 4 example payment extension for reference (the $address variable should be passed in line 4 of this excerpt):
Code: Select all
<?php
namespace Opencart\Catalog\Model\Extension\OcPaymentExample\Payment;
class CreditCard extends \Opencart\System\Engine\Model {
public function getMethods(array $address): array {
$this->load->language('extension/oc_payment_example/payment/credit_card');
if (!$this->config->get('config_checkout_payment_address')) {
$status = true;
} elseif (!$this->config->get('payment_credit_card_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_credit_card_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;
}
}