| 1 |
<?php |
| 2 |
|
| 3 |
namespace Sellkit\Elementor\Modules\Checkout\Integrations; |
| 4 |
|
| 5 |
defined( 'ABSPATH' ) || die(); |
| 6 |
|
| 7 |
use Sellkit\Elementor\Modules\Checkout\Integrations\Integration; |
| 8 |
|
| 9 |
/** |
| 10 |
* Integration class to integrate paypal for WooCommerce gateway with sellkit checkout widget. |
| 11 |
* |
| 12 |
* @since 1.1.0 |
| 13 |
*/ |
| 14 |
class Paypal_For_Woocommerce extends Integration { |
| 15 |
/** |
| 16 |
* Integrated gateway instance. |
| 17 |
* |
| 18 |
* @var \AngellEYE_PayPal_PPCP_Smart_Button |
| 19 |
* @since 1.8.9 |
| 20 |
*/ |
| 21 |
public $parent; |
| 22 |
|
| 23 |
/** |
| 24 |
* Check requirement to enable gateway in sellkit checkout widget. |
| 25 |
* |
| 26 |
* @return bool |
| 27 |
* @since 1.1.0 |
| 28 |
*/ |
| 29 |
protected function requirements() { |
| 30 |
// Plugin is not installed. |
| 31 |
if ( ! class_exists( 'AngellEYE_PayPal_PPCP_Smart_Button' ) ) { |
| 32 |
return false; |
| 33 |
} |
| 34 |
|
| 35 |
$this->parent = \AngellEYE_PayPal_PPCP_Smart_Button::instance(); |
| 36 |
|
| 37 |
// Gateway is not active. |
| 38 |
if ( 'no' === $this->parent->enabled ) { |
| 39 |
return false; |
| 40 |
} |
| 41 |
|
| 42 |
return true; |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Content of express checkout methods. |
| 47 |
* |
| 48 |
* @return void |
| 49 |
* @since 1.1.0 |
| 50 |
*/ |
| 51 |
public function content() { |
| 52 |
$this->parent->display_paypal_button_top_checkout_page(); |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Angelleye button wrapper |
| 57 |
* |
| 58 |
* @since 1.8.9 |
| 59 |
*/ |
| 60 |
public function customized_buttons() { |
| 61 |
ob_start(); |
| 62 |
?> |
| 63 |
<div class="wc_ppcp_express_checkout_gateways angelleye-integrated-by-sellkit"> |
| 64 |
<div class="angelleye_ppcp-gateway express_payment_method_ppcp"> |
| 65 |
<div class="angelleye_ppcp-button-container angelleye_ppcp_<?php echo esc_attr( $this->parent->style_layout ); ?>_<?php echo esc_attr( $this->parent->style_size ); ?>"> |
| 66 |
<div id="angelleye_ppcp_checkout_top"></div> |
| 67 |
<div id="angelleye_ppcp_checkout_top_apple_pay"></div> |
| 68 |
</div> |
| 69 |
</div> |
| 70 |
</div> |
| 71 |
<?php |
| 72 |
return ob_get_clean(); |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* Hooks to integrate current gateway with sellkit checkout widget. |
| 77 |
* |
| 78 |
* @return void |
| 79 |
* @since 1.1.0 |
| 80 |
*/ |
| 81 |
public function hooks() { |
| 82 |
add_filter( 'angelleye_ppcp_checkout_top_html', [ $this, 'customized_buttons' ], 10, 1 ); |
| 83 |
remove_action( 'woocommerce_checkout_before_customer_details', [ $this->parent, 'display_paypal_button_top_checkout_page' ], 1 ); |
| 84 |
} |
| 85 |
} |
| 86 |
|