@@ -8,18 +8,18 @@ class Btcpay extends \Opencart\System\Engine\Model
88 public function addOrder (array $ data ): bool
99 {
1010 return $ this ->db ->query (
11- "INSERT INTO ` " . DB_PREFIX . "btcpay_order` SET `order_id` = ' " . (int )$ data ['order_id ' ] . "', `token` = ' " . $ this ->db ->escape (
12- $ data ['token ' ]
13- ) . "', `invoice_id` = ' " . $ this ->db ->escape (
14- $ data ['invoice_id ' ]
15- ) . "' "
11+ "INSERT INTO ` " . DB_PREFIX . "btcpay_order` SET `order_id` = ' " . (int )$ data ['order_id ' ] . "', `token` = ' " . $ this ->db ->escape (
12+ $ data ['token ' ]
13+ ) . "', `invoice_id` = ' " . $ this ->db ->escape (
14+ $ data ['invoice_id ' ]
15+ ) . "' "
1616 );
1717 }
1818
1919 public function getOrder (int $ order_id ): array
2020 {
2121 $ query = $ this ->db ->query (
22- "SELECT * FROM ` " . DB_PREFIX . "btcpay_order` WHERE `order_id` = ' " . $ order_id . "' ORDER BY btcpay_order_id DESC LIMIT 1 "
22+ "SELECT * FROM ` " . DB_PREFIX . "btcpay_order` WHERE `order_id` = ' " . $ order_id . "' ORDER BY btcpay_order_id DESC LIMIT 1 "
2323 );
2424
2525 return $ query ->row ;
@@ -28,21 +28,28 @@ public function getOrder(int $order_id): array
2828 public function getOrderByInvoiceId (string $ invoice_id ): array
2929 {
3030 $ query = $ this ->db ->query (
31- "SELECT * FROM ` " . DB_PREFIX . "btcpay_order` WHERE `invoice_id` = ' " . $ invoice_id . "' LIMIT 1 "
31+ "SELECT * FROM ` " . DB_PREFIX . "btcpay_order` WHERE `invoice_id` = ' " . $ invoice_id . "' LIMIT 1 "
3232 );
3333
3434 return $ query ->row ;
3535 }
3636
37- public function getMethod (array $ address ): array
37+ public function getMethods (array $ address = [] ): array
3838 {
3939 $ this ->load ->language ('extension/btcpay/payment/btcpay ' );
4040
41- $ query = $ this ->db ->query (
42- "SELECT * FROM ` " . DB_PREFIX . "zone_to_geo_zone` WHERE `geo_zone_id` = ' " . (int )$ this ->config ->get (
43- 'payment_btcpay_geo_zone_id '
44- ) . "' AND `country_id` = ' " . (int )$ address ['country_id ' ] . "' AND (`zone_id` = ' " . (int )$ address ['zone_id ' ] . "' OR `zone_id` = '0') "
45- );
41+ $ qStr = "SELECT * FROM ` " . DB_PREFIX . "zone_to_geo_zone` WHERE `geo_zone_id` = ' " . (int )$ this ->config ->get (
42+ 'payment_btcpay_geo_zone_id '
43+ ) . "' " ;
44+
45+ if (isset ($ address ['country_id ' ])) {
46+ $ qStr .= " AND `country_id` = ' " . (int )$ address ['country_id ' ] ."' " ;
47+ }
48+ if (isset ($ address ['zone_id ' ])) {
49+ $ qStr .= " AND (`zone_id` = ' " . (int )$ address ['zone_id ' ] . "' OR `zone_id` = '0') " ;
50+ }
51+
52+ $ query = $ this ->db ->query ($ qStr );
4653
4754 if (!$ this ->config ->get ('payment_btcpay_geo_zone_id ' )) {
4855 $ status = true ;
@@ -55,10 +62,16 @@ public function getMethod(array $address): array
5562 $ method_data = [];
5663
5764 if ($ status ) {
65+ $ option_data ['btcpay ' ] = [
66+ 'code ' => 'btcpay.btcpay ' ,
67+ 'name ' => $ this ->language ->get ('text_title ' )
68+ ];
69+
5870 $ method_data = [
59- 'code ' => 'btcpay ' ,
60- 'title ' => $ this ->language ->get ('text_title ' ),
61- 'sort_order ' => $ this ->config ->get ('payment_btcpay_sort_order ' ),
71+ 'code ' => 'btcpay ' ,
72+ 'name ' => $ this ->language ->get ('text_title ' ),
73+ 'option ' => $ option_data ,
74+ 'sort_order ' => $ this ->config ->get ('payment_btcpay_sort_order ' )
6275 ];
6376 }
6477
0 commit comments