Changeset 3269477
- Timestamp:
- 04/09/2025 08:31:52 AM (11 months ago)
- Location:
- imoje/trunk
- Files:
-
- 3 edited
-
includes/gateway_block/WC_Gateway_Imoje_RestApi_Blocks.php (modified) (12 diffs)
-
readme.txt (modified) (2 diffs)
-
woocommerce-imoje.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
imoje/trunk/includes/gateway_block/WC_Gateway_Imoje_RestApi_Blocks.php
r3268688 r3269477 8 8 * Class WC_Gateway_Imoje_RestApi_Blocks 9 9 */ 10 class WC_Gateway_Imoje_RestApi_Blocks extends AbstractPaymentMethodType 11 { 10 class WC_Gateway_Imoje_RestApi_Blocks extends AbstractPaymentMethodType { 12 11 /** 13 12 * @var string … … 23 22 * @return void 24 23 */ 25 public function initialize() 26 { 24 public function initialize() { 27 25 $locale = get_locale(); 28 26 29 $locale = ( $locale === 'pl_PL' || $locale === 'pl')27 $locale = ( $locale === 'pl_PL' || $locale === 'pl' ) 30 28 ? Util::LANG_PL 31 29 : Util::LANG_EN; 32 30 33 $this->regulation = Util::getDocUrl( $locale, Util::REGULATION);34 $this->iodo = Util::getDocUrl($locale, Util::IODO);35 36 add_action( 'wp_enqueue_scripts', [31 $this->regulation = Util::getDocUrl( $locale, Util::REGULATION ); 32 $this->iodo = Util::getDocUrl( $locale, Util::IODO ); 33 34 add_action( 'wp_enqueue_scripts', [ 37 35 $this, 38 36 'enqueue_payment_scripts', 39 ]); 40 } 41 42 /** 43 * @return void 44 */ 45 public function enqueue_payment_scripts() 46 { 47 if (is_checkout() && CartCheckoutUtils::is_checkout_block_default()) { 37 ] ); 38 } 39 40 /** 41 * @return void 42 */ 43 public function enqueue_payment_scripts() { 44 if ( is_checkout() && CartCheckoutUtils::is_checkout_block_default() ) { 48 45 49 46 $this->enqueue_common_payment_script(); … … 61 58 * @return void 62 59 */ 63 private function enqueue_common_payment_script() 64 { 60 private function enqueue_common_payment_script() { 65 61 wp_enqueue_script( 66 62 'imoje-common-payment-block', 67 plugins_url( '../../assets/js/checkout/imoje-common-block.min.js', __FILE__),68 [ 'wc-blocks-registry'],63 plugins_url( '../../assets/js/checkout/imoje-common-block.min.js', __FILE__ ), 64 [ 'wc-blocks-registry' ], 69 65 '1.0.0', 70 66 true … … 75 71 'imoje_common_js_object', 76 72 [ 77 'legal_copy' => [78 'regulation_url' => esc_url( $this->regulation),79 'iodo_url' => esc_url( $this->iodo),80 'regulation_text' => esc_html__( 'Regulations of imoje', 'imoje'),81 'iodo_text' => esc_html__( 'Information on personal data imoje', 'imoje'),82 'consent_text' => esc_html__( 'I declare that I have read and accept {regulation} and {iodo}.', 'imoje'),73 'legal_copy' => [ 74 'regulation_url' => esc_url( $this->regulation ), 75 'iodo_url' => esc_url( $this->iodo ), 76 'regulation_text' => esc_html__( 'Regulations of imoje', 'imoje' ), 77 'iodo_text' => esc_html__( 'Information on personal data imoje', 'imoje' ), 78 'consent_text' => esc_html__( 'I declare that I have read and accept {regulation} and {iodo}.', 'imoje' ), 83 79 ], 84 'choose_payment_method' => __('Choose payment channel if is available. In other way choose another payment method', 'imoje'), 85 ] 86 ); 87 } 88 89 /** 90 * @return void 91 */ 92 private function enqueue_imoje_blik_payment_script() 93 { 80 'choose_payment_method' => __( 'Choose payment channel if is available. In other way choose another payment method', 'imoje' ), 81 ] 82 ); 83 } 84 85 /** 86 * @return void 87 */ 88 private function enqueue_imoje_blik_payment_script() { 94 89 wp_enqueue_script( 95 90 'imoje-blik-payment-block', 96 plugins_url('../../assets/js/checkout/imoje-blik-block.min.js', __FILE__), 97 [ 98 'wp-element', 99 'wc-blocks-registry', 100 ], 101 '1.0.0', 102 true 103 ); 104 105 $settings = get_option('woocommerce_imoje_blik_settings', []); 91 plugins_url( '../../assets/js/checkout/imoje-blik-block.min.js', __FILE__ ), 92 [ 93 'wp-element', 94 'wc-blocks-registry', 95 ], 96 '1.0.0', 97 true 98 ); 106 99 107 100 $imojeBlik = new WC_Gateway_ImojeBlik(); 108 $payment_methods = $this->get_block_checkout_tooltip( $imojeBlik->get_payment_channels());109 101 110 102 wp_localize_script( … … 113 105 [ 114 106 'name_blik' => 'imoje_blik', 115 'logo_blik' => plugins_url( '../../assets/images/imoje_blik.png', __FILE__),107 'logo_blik' => plugins_url( '../../assets/images/imoje_blik.png', __FILE__ ), 116 108 'logo_blik_oneclick' => '', 117 'settings_blik' => $settings, 118 'blik_text' => __('Enter the correct 6-digit BLIK code.', 'imoje'), 119 'payment_methods_blik' => $payment_methods, 120 121 ] 122 ); 123 } 124 125 /** 126 * @return void 127 */ 128 private function enqueue_imoje_payment_script() 129 { 109 'settings_blik' => get_option( 'woocommerce_imoje_blik_settings', [] ), 110 'blik_text' => __( 'Enter the correct 6-digit BLIK code.', 'imoje' ), 111 'payment_methods_blik' => $this->get_block_checkout_tooltip( $imojeBlik->get_payment_channels() ), 112 113 ] 114 ); 115 } 116 117 /** 118 * @return void 119 */ 120 private function enqueue_imoje_payment_script() { 130 121 wp_enqueue_script( 131 122 'imoje-payment-block', 132 plugins_url('../../assets/js/checkout/imoje-block.min.js', __FILE__), 133 [ 134 'wp-element', 135 'wc-blocks-registry', 136 ], 137 '1.0.0', 138 true 139 ); 140 141 $settings = get_option('woocommerce_imoje_settings', []); 123 plugins_url( '../../assets/js/checkout/imoje-block.min.js', __FILE__ ), 124 [ 125 'wp-element', 126 'wc-blocks-registry', 127 ], 128 '1.0.0', 129 true 130 ); 142 131 143 132 wp_localize_script( … … 146 135 [ 147 136 'name_imoje' => 'imoje', 148 'logo_imoje' => plugins_url('../../assets/images/imoje.png', __FILE__), 149 'settings_imoje' => $settings, 150 ] 151 ); 152 } 153 154 /** 155 * @return void 156 */ 157 private function enqueue_imoje_paylater_payment_script() 158 { 137 'logo_imoje' => plugins_url( '../../assets/images/imoje.png', __FILE__ ), 138 'settings_imoje' => get_option( 'woocommerce_imoje_settings', [] ), 139 ] 140 ); 141 } 142 143 /** 144 * @return void 145 */ 146 private function enqueue_imoje_paylater_payment_script() { 159 147 wp_enqueue_script( 160 148 'imoje-paylater-payment-block', 161 plugins_url('../../assets/js/checkout/imoje-paylater-block.min.js', __FILE__), 162 [ 163 'wp-element', 164 'wc-blocks-registry', 165 ], 166 '1.0.0', 167 true 168 ); 169 170 $settings = get_option('woocommerce_imoje_paylater_settings', []); 171 $imojePaylater = new WC_Gateway_ImojePaylater(); 172 $payment_methods = $this->get_block_checkout_tooltip($imojePaylater->get_payment_channels()); 149 plugins_url( '../../assets/js/checkout/imoje-paylater-block.min.js', __FILE__ ), 150 [ 151 'wp-element', 152 'wc-blocks-registry', 153 ], 154 '1.0.0', 155 true 156 ); 157 158 $imojePaylater = new WC_Gateway_ImojePaylater(); 173 159 174 160 wp_localize_script( … … 177 163 [ 178 164 'name_paylater' => 'imoje_paylater', 179 'logo_paylater' => plugins_url('../../assets/images/imoje_paylater.png', __FILE__), 180 'settings_paylater' => $settings, 181 'payment_methods_paylater' => $payment_methods, 182 'twisto_legal' => __('I agree to provide Twisto S.A. with my transaction details in the imoje payment gateway in order to make an offer to finance my purchases.', 'imoje'), 183 ] 184 ); 185 } 186 187 /** 188 * @return void 189 */ 190 private function enqueue_imoje_cards_payment_script() 191 { 165 'logo_paylater' => plugins_url( '../../assets/images/imoje_paylater.png', __FILE__ ), 166 'settings_paylater' => get_option( 'woocommerce_imoje_paylater_settings', [] ), 167 'payment_methods_paylater' => $this->get_block_checkout_tooltip( $imojePaylater->get_payment_channels() ), 168 'twisto_legal' => __( 'I agree to provide Twisto S.A. with my transaction details in the imoje payment gateway in order to make an offer to finance my purchases.', 'imoje' ), 169 ] 170 ); 171 } 172 173 /** 174 * @return void 175 */ 176 private function enqueue_imoje_cards_payment_script() { 192 177 wp_enqueue_script( 193 178 'imoje-cards-payment-block', 194 plugins_url('../../assets/js/checkout/imoje-cards-block.min.js', __FILE__), 195 [ 196 'wp-element', 197 'wc-blocks-registry', 198 ], 199 '1.0.0', 200 true 201 ); 202 203 $settings = get_option('woocommerce_imoje_cards_settings', []); 179 plugins_url( '../../assets/js/checkout/imoje-cards-block.min.js', __FILE__ ), 180 [ 181 'wp-element', 182 'wc-blocks-registry', 183 ], 184 '1.0.0', 185 true 186 ); 204 187 205 188 wp_localize_script( … … 208 191 [ 209 192 'name_cards' => 'imoje_cards', 210 'logo_cards' => plugins_url('../../assets/images/imoje_cards.png', __FILE__), 211 'settings_cards' => $settings, 212 ] 213 ); 214 } 215 216 /** 217 * @return void 218 */ 219 private function enqueue_imoje_pbl_payment_script() 220 { 193 'logo_cards' => plugins_url( '../../assets/images/imoje_cards.png', __FILE__ ), 194 'settings_cards' => get_option( 'woocommerce_imoje_cards_settings', [] ), 195 ] 196 ); 197 } 198 199 /** 200 * @return void 201 */ 202 private function enqueue_imoje_pbl_payment_script() { 221 203 wp_enqueue_script( 222 204 'imoje-pbl-payment-block', 223 plugins_url('../../assets/js/checkout/imoje-pbl-block.min.js', __FILE__), 224 [ 225 'wp-element', 226 'wc-blocks-registry', 227 ], 228 '1.0.0', 229 true 230 ); 231 232 $settings = get_option('woocommerce_imoje_pbl_settings', []); 233 $imojePbl = new WC_Gateway_ImojePbl; 234 $payment_methods = $this->get_block_checkout_tooltip($imojePbl->get_payment_channels()); 235 205 plugins_url( '../../assets/js/checkout/imoje-pbl-block.min.js', __FILE__ ), 206 [ 207 'wp-element', 208 'wc-blocks-registry', 209 ], 210 '1.0.0', 211 true 212 ); 213 214 $imojePbl = new WC_Gateway_ImojePbl; 236 215 237 216 wp_localize_script( … … 240 219 [ 241 220 'name_pbl' => 'imoje_pbl', 242 'logo_pbl' => plugins_url('../../assets/images/imoje_pbl.png', __FILE__), 243 'settings_pbl' => $settings, 244 'payment_methods_pbl' => $payment_methods, 245 ] 246 ); 247 } 248 249 /** 250 * @return void 251 */ 252 private function enqueue_imoje_visa_payment_script() 253 { 221 'logo_pbl' => plugins_url( '../../assets/images/imoje_pbl.png', __FILE__ ), 222 'settings_pbl' => get_option( 'woocommerce_imoje_pbl_settings', [] ), 223 'payment_methods_pbl' => $this->get_block_checkout_tooltip( $imojePbl->get_payment_channels() ), 224 ] 225 ); 226 } 227 228 /** 229 * @return void 230 */ 231 private function enqueue_imoje_visa_payment_script() { 254 232 wp_enqueue_script( 255 233 'imoje-visa-payment-block', 256 plugins_url('../../assets/js/checkout/imoje-visa-block.min.js', __FILE__), 257 [ 258 'wp-element', 259 'wc-blocks-registry', 260 ], 261 '1.0.0', 262 true 263 ); 264 265 $settings = get_option('woocommerce_imoje_visa_settings', []); 234 plugins_url( '../../assets/js/checkout/imoje-visa-block.min.js', __FILE__ ), 235 [ 236 'wp-element', 237 'wc-blocks-registry', 238 ], 239 '1.0.0', 240 true 241 ); 266 242 267 243 wp_localize_script( … … 270 246 [ 271 247 'name_visa' => 'imoje_visa', 272 'logo_visa' => plugins_url('../../assets/images/imoje_visa.png', __FILE__), 273 'settings_visa' => $settings, 274 ] 275 ); 276 } 277 278 /** 279 * @return void 280 */ 281 private function enqueue_imoje_installments_payment_script() 282 { 248 'logo_visa' => plugins_url( '../../assets/images/imoje_visa.png', __FILE__ ), 249 'settings_visa' => get_option( 'woocommerce_imoje_visa_settings', [] ), 250 ] 251 ); 252 } 253 254 /** 255 * @return void 256 */ 257 private function enqueue_imoje_installments_payment_script() { 283 258 wp_enqueue_script( 284 259 'imoje-installments-payment-block', 285 plugins_url('../../assets/js/checkout/imoje-installments-block.min.js', __FILE__), 286 [ 287 'wp-element', 288 'wc-blocks-registry', 289 ], 290 '1.0.0', 291 true 292 ); 293 294 $settings = get_option('woocommerce_imoje_installments_settings', []); 260 plugins_url( '../../assets/js/checkout/imoje-installments-block.min.js', __FILE__ ), 261 [ 262 'wp-element', 263 'wc-blocks-registry', 264 ], 265 '1.0.0', 266 true 267 ); 295 268 296 269 $imojeInstallments = new WC_Gateway_ImojeInstallments(); 297 298 $calculator_data = $imojeInstallments->get_calculator_data();299 270 300 271 wp_localize_script( … … 303 274 [ 304 275 'name_installments' => 'imoje_installments', 305 'logo_installments' => plugins_url( '../../assets/images/imoje_installments.png', __FILE__),306 'settings_installments' => $settings,307 'calculator_data' => $ calculator_data,276 'logo_installments' => plugins_url( '../../assets/images/imoje_installments.png', __FILE__ ), 277 'settings_installments' => get_option( 'woocommerce_imoje_installments_settings', [] ), 278 'calculator_data' => $imojeInstallments->get_calculator_data(), 308 279 ] 309 280 ); … … 315 286 * @return array 316 287 */ 317 private function get_block_checkout_tooltip( $payment_method){318 return array_values( array_map(function ($method) {319 if ( isset($method['limit'])) {320 $method['tooltip'] = Helper::get_tooltip_payment_channel( $method);288 private function get_block_checkout_tooltip( $payment_method ) { 289 return array_values( array_map( function ( $method ) { 290 if ( isset( $method['limit'] ) ) { 291 $method['tooltip'] = Helper::get_tooltip_payment_channel( $method ); 321 292 } 293 322 294 return $method; 323 }, $payment_method ));295 }, $payment_method ) ); 324 296 } 325 297 } -
imoje/trunk/readme.txt
r3268688 r3269477 5 5 Requires PHP: 5.6.0 6 6 License: GPLv2 7 Stable tag: 4.8. 07 Stable tag: 4.8.1 8 8 9 9 Add payment via imoje to WooCommerce … … 73 73 74 74 == Changelog == 75 = 4.8.1 = 76 * minor fixes for WooCommerce block checkout 75 77 = 4.8.0 = 76 78 * added support for WooCommerce block checkout -
imoje/trunk/woocommerce-imoje.php
r3268688 r3269477 4 4 Plugin URI: https://imoje.pl 5 5 Description: Add payment via imoje to WooCommerce 6 Version: 4.8. 06 Version: 4.8.1 7 7 Author: imoje <kontakt.tech@imoje.pl> 8 8 Author URI: https://imoje.pl … … 36 36 require_once( 'includes/gateway/WC_Gateway_Imoje_Abstract.php' ); 37 37 require_once( 'includes/gateway/WC_Gateway_Imoje_Api_Abstract.php' ); 38 require_once( 'includes/gateway_block/WC_Gateway_Imoje_RestApi_Blocks.php');38 require_once( 'includes/gateway_block/WC_Gateway_Imoje_RestApi_Blocks.php' ); 39 39 40 40 foreach ( imoje_get_gateways() as $method ) { … … 42 42 } 43 43 44 add_action( 'before_woocommerce_init', function () {44 add_action( 'before_woocommerce_init', function () { 45 45 if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) { 46 46 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, true ); … … 50 50 add_filter( 'woocommerce_payment_gateways', 'imoje_add_gateways' ); 51 51 52 if (CartCheckoutUtils::is_checkout_block_default() ) { 53 add_action('woocommerce_blocks_payment_method_type_registration', function($payment_method_registry) { 54 $payment_method_registry->register(new WC_Gateway_Imoje_RestApi_Blocks()); 55 }); 56 } 57 58 59 52 if ( class_exists( '\Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils' ) && CartCheckoutUtils::is_checkout_block_default() ) { 53 add_action( 'woocommerce_blocks_payment_method_type_registration', function ( $payment_method_registry ) { 54 $payment_method_registry->register( new WC_Gateway_Imoje_RestApi_Blocks() ); 55 } ); 56 } 60 57 } 61 58
Note: See TracChangeset
for help on using the changeset viewer.