| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Wpfnl_Pro_Gateway_Cod |
| 5 |
*/ |
| 6 |
|
| 7 |
namespace WPFunnels\Gateway; |
| 8 |
|
| 9 |
use WPFunnels\Traits\SingletonTrait; |
| 10 |
use WPFunnels\Wpfnl_functions; |
| 11 |
use WPFunnels\Gateway\API\Wpfnl_Gateway; |
| 12 |
|
| 13 |
|
| 14 |
/** |
| 15 |
* Class Wpfnl_Pro_Gateway_Cod |
| 16 |
* @package WPFunnelsPro\Frontend\Gateways |
| 17 |
*/ |
| 18 |
class Wpfnl_Gateway_Cod extends Wpfnl_Gateway { |
| 19 |
|
| 20 |
use SingletonTrait; |
| 21 |
|
| 22 |
public $key = 'cod'; |
| 23 |
|
| 24 |
|
| 25 |
/** |
| 26 |
* @var bool $refund_support |
| 27 |
*/ |
| 28 |
public $refund_support; |
| 29 |
|
| 30 |
|
| 31 |
public function __construct() { |
| 32 |
$this->refund_support = false; |
| 33 |
add_filter( 'woocommerce_cod_process_payment_order_status', array( $this, 'maybe_setup_offer_for_cod' ), 9999, 2 ); |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
/** |
| 38 |
* set new status for orders based on offer |
| 39 |
* |
| 40 |
* @param $order_status |
| 41 |
* @param $order |
| 42 |
* @return string |
| 43 |
*/ |
| 44 |
public function maybe_setup_offer_for_cod( $order_status, $order ) { |
| 45 |
|
| 46 |
$payment_method = $order->get_payment_method(); |
| 47 |
$funnel_id = Wpfnl_functions::get_funnel_id_from_order( $order->get_id() ); |
| 48 |
$offer_settings = Wpfnl_functions::get_offer_settings(); |
| 49 |
if ( $offer_settings['offer_orders'] == 'main-order' && $funnel_id ) { |
| 50 |
return 'wc-wpfnl-main-order'; |
| 51 |
} |
| 52 |
|
| 53 |
return $order_status; |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
/** |
| 58 |
* process payment for offer |
| 59 |
* |
| 60 |
* @param $order |
| 61 |
* @param $offer_product |
| 62 |
* @return bool |
| 63 |
*/ |
| 64 |
public function process_payment( $order, $offer_product ) { |
| 65 |
$result['is_success'] = true; |
| 66 |
return $result; |
| 67 |
} |
| 68 |
} |