PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.12.2
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.12.2
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
wpfunnels / includes / core / gateways / class-wpfnl-gateway-bacs.php

class-wpfnl-gateway-bacs.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.12.2, at includes/core/gateways/class-wpfnl-gateway-bacs.php

97 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace WPFunnels\Gateway;
3
4 use WPFunnels\Wpfnl_functions;
5
6 /**
7 * @author [WPFunnels Team]
8 * @email [[email protected]]
9 * @create date 2022-06-09 16:28:09
10 * @modify date 2022-06-09 16:28:09
11 * @desc [Supporting Direct Bank Transfer with WPFunnels one-click offer]
12 */
13
14 class Wpfnl_Gateway_Bacs {
15
16 /**
17 * @var string
18 * @since 1.6.7
19 */
20 public $key = 'bacs';
21
22 /**
23 * @var bool
24 * @since 1.6.7
25 */
26 public $refund_support;
27
28 /**
29 * @var bool
30 * @since 1.6.7
31 */
32 private $token = false;
33
34
35 function __construct()
36 {
37 $this->token = true;
38 add_filter('woocommerce_bacs_process_payment_order_status', array($this, 'maybe_setup_offer_for_bacs'), 10, 2);
39 }
40
41
42 /**
43 * Try and get the payment token saved by the gateway
44 *
45 * @param WC_Order $order
46 *
47 * @return true
48 * @since 1.6.7
49 */
50 public function has_token( $order ) {
51 return $this->token;
52 }
53
54 /**
55 * Possibly sets a custom order status for BACS payment method based on funnel settings.
56 *
57 * If the 'offer_orders' setting is set to 'main-order' and a valid funnel ID exists
58 * for the given order, the order status will be overridden with 'wc-wpfnl-main-order'.
59 * Otherwise, the original order status will be returned unchanged.
60 *
61 * @param string $order_status The current order status.
62 * @param WC_Order $order The WooCommerce order object.
63 *
64 * @return string The modified or original order status.
65 * @since 2.5.10
66 */
67 public function maybe_setup_offer_for_bacs($order_status, $order){
68 $funnel_id = Wpfnl_functions::get_funnel_id_from_order($order->get_id());
69 $offer_settings = Wpfnl_functions::get_offer_settings();
70 if ($offer_settings['offer_orders'] == 'main-order' && $funnel_id) {
71 return 'wc-wpfnl-main-order';
72 }
73
74 return $order_status;
75 }
76
77
78 /**
79 * Process payment for one-click offer product
80 *
81 * @param mixed $order
82 *
83 * @return array
84 * @since 1.6.7
85 */
86 public function process_payment( $order ) {
87
88 if($this->key === $order->get_payment_method() && $this->has_token($order)){
89 return array(
90 'is_success' => true,
91 'message' => 'Success'
92 );
93 }
94
95 }
96
97 }