PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 2.7.0
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v2.7.0
2.7.0 2.6.0 trunk 1.1.0 1.1.4 1.2.1 1.2.2 1.2.3 1.2.5 1.2.9 1.3.1 1.3.2 1.5.0 1.5.1 1.5.4 1.5.7 1.5.8 1.5.9 1.6.2 1.6.5 1.6.8 1.7.2 1.7.4 1.7.5 1.7.9 All 43 releases
sellkit / includes / elementor / modules / checkout / integrations / stripe-woocommerce-official.php

stripe-woocommerce-official.php in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster 2.7.0, at includes/elementor/modules/checkout/integrations/stripe-woocommerce-official.php

117 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 stripe woocommerce official with sellkit checkout widget.
11 *
12 * @since 1.1.0
13 */
14 class Stripe_Woocommerce_Official extends Integration {
15 /**
16 * Original plugin class holder.
17 *
18 * @since 1.1.0
19 * @var object
20 */
21 private $parent;
22
23 /**
24 * Stripe express integration type.
25 *
26 * @since 1.1.0
27 * @var string
28 */
29 private $integration_type = '';
30
31 /**
32 * Check requirement to enable gateway in sellkit checkout widget.
33 *
34 * @return bool
35 * @since 1.1.0
36 */
37 protected function requirements() {
38 // Plugin not installed.
39 if ( ! defined( 'WC_STRIPE_PLUGIN_PATH' ) ) {
40 return false;
41 }
42
43 if ( class_exists( 'WC_Stripe_Express_Checkout_Element' ) ) {
44 $this->parent = \WC_Stripe_Express_Checkout_Element::instance();
45 $this->integration_type = 'express_checkout_element';
46
47 return true;
48 }
49
50 if ( class_exists( 'WC_Stripe_Payment_Request' ) ) {
51 $this->parent = \WC_Stripe_Payment_Request::instance();
52 $this->integration_type = 'payment_request';
53
54 return true;
55 }
56
57 return false;
58 }
59
60 /**
61 * Content of express checkout methods.
62 *
63 * @return void
64 * @since 1.1.0
65 */
66 public function content() {
67 ?>
68 <div class="sellkit-stripe-woocommerce-official-integration" >
69 <?php
70 if ( method_exists( $this->parent, 'display_express_checkout_button_html' ) ) {
71 ob_start();
72 $this->parent->display_express_checkout_button_html();
73 $button_html = ob_get_clean();
74 $button_html = preg_replace( '/<p id="wc-stripe-express-checkout-button-separator"[^>]*>.*?<\/p>/is', '', $button_html );
75 echo wp_kses_post( $button_html );
76 } elseif ( method_exists( $this->parent, 'display_payment_request_button_html' ) ) {
77 $this->parent->display_payment_request_button_html();
78 }
79 ?>
80 </div>
81 <?php
82 }
83
84 /**
85 * Hooks to integrate current gateway with sellkit checkout widget.
86 *
87 * @return void
88 * @since 1.1.0
89 */
90 public function hooks() {
91 $callbacks = [];
92
93 if ( 'express_checkout_element' === $this->integration_type ) {
94 $callbacks = [
95 [ $this->parent, 'display_express_checkout_button_html' ],
96 [ $this->parent, 'display_express_checkout_button_separator_html' ],
97 [ 'WC_Stripe_Express_Checkout_Element', 'display_express_checkout_button_html' ],
98 [ 'WC_Stripe_Express_Checkout_Element', 'display_express_checkout_button_separator_html' ],
99 ];
100 }
101
102 if ( 'payment_request' === $this->integration_type ) {
103 $callbacks = [
104 [ $this->parent, 'display_payment_request_button_html' ],
105 [ $this->parent, 'display_payment_request_button_separator_html' ],
106 [ 'WC_Stripe_Payment_Request', 'display_payment_request_button_html' ],
107 [ 'WC_Stripe_Payment_Request', 'display_payment_request_button_separator_html' ],
108 ];
109 }
110
111 foreach ( $callbacks as $callback ) {
112 remove_action( 'woocommerce_checkout_before_customer_details', $callback, 1 );
113 remove_action( 'woocommerce_checkout_before_customer_details', $callback, 2 );
114 }
115 }
116 }
117