Plugin Directory

Changeset 3269477


Ignore:
Timestamp:
04/09/2025 08:31:52 AM (11 months ago)
Author:
imoje
Message:

v4.8.1

Location:
imoje/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • imoje/trunk/includes/gateway_block/WC_Gateway_Imoje_RestApi_Blocks.php

    r3268688 r3269477  
    88 * Class WC_Gateway_Imoje_RestApi_Blocks
    99 */
    10 class WC_Gateway_Imoje_RestApi_Blocks extends AbstractPaymentMethodType
    11 {
     10class WC_Gateway_Imoje_RestApi_Blocks extends AbstractPaymentMethodType {
    1211    /**
    1312     * @var string
     
    2322     * @return void
    2423     */
    25     public function initialize()
    26     {
     24    public function initialize() {
    2725        $locale = get_locale();
    2826
    29         $locale = ($locale === 'pl_PL' || $locale === 'pl')
     27        $locale = ( $locale === 'pl_PL' || $locale === 'pl' )
    3028            ? Util::LANG_PL
    3129            : Util::LANG_EN;
    3230
    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', [
    3735            $this,
    3836            '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() ) {
    4845
    4946            $this->enqueue_common_payment_script();
     
    6158     * @return void
    6259     */
    63     private function enqueue_common_payment_script()
    64     {
     60    private function enqueue_common_payment_script() {
    6561        wp_enqueue_script(
    6662            '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' ],
    6965            '1.0.0',
    7066            true
     
    7571            'imoje_common_js_object',
    7672            [
    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' ),
    8379                ],
    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() {
    9489        wp_enqueue_script(
    9590            '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        );
    10699
    107100        $imojeBlik = new WC_Gateway_ImojeBlik();
    108         $payment_methods = $this->get_block_checkout_tooltip( $imojeBlik->get_payment_channels());
    109101
    110102        wp_localize_script(
     
    113105            [
    114106                '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__ ),
    116108                '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() {
    130121        wp_enqueue_script(
    131122            '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        );
    142131
    143132        wp_localize_script(
     
    146135            [
    147136                '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() {
    159147        wp_enqueue_script(
    160148            '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();
    173159
    174160        wp_localize_script(
     
    177163            [
    178164                '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() {
    192177        wp_enqueue_script(
    193178            '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        );
    204187
    205188        wp_localize_script(
     
    208191            [
    209192                '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() {
    221203        wp_enqueue_script(
    222204            '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;
    236215
    237216        wp_localize_script(
     
    240219            [
    241220                '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() {
    254232        wp_enqueue_script(
    255233            '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        );
    266242
    267243        wp_localize_script(
     
    270246            [
    271247                '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() {
    283258        wp_enqueue_script(
    284259            '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        );
    295268
    296269        $imojeInstallments = new WC_Gateway_ImojeInstallments();
    297 
    298         $calculator_data = $imojeInstallments->get_calculator_data();
    299270
    300271        wp_localize_script(
     
    303274            [
    304275                '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(),
    308279            ]
    309280        );
     
    315286     * @return array
    316287     */
    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 );
    321292            }
     293
    322294            return $method;
    323         }, $payment_method));
     295        }, $payment_method ) );
    324296    }
    325297}
  • imoje/trunk/readme.txt

    r3268688 r3269477  
    55Requires PHP: 5.6.0
    66License: GPLv2
    7 Stable tag: 4.8.0
     7Stable tag: 4.8.1
    88
    99Add payment via imoje to WooCommerce
     
    7373
    7474== Changelog ==
     75= 4.8.1 =
     76* minor fixes for WooCommerce block checkout
    7577= 4.8.0 =
    7678* added support for WooCommerce block checkout
  • imoje/trunk/woocommerce-imoje.php

    r3268688 r3269477  
    44Plugin URI: https://imoje.pl
    55Description: Add payment via imoje to WooCommerce
    6 Version: 4.8.0
     6Version: 4.8.1
    77Author: imoje <kontakt.tech@imoje.pl>
    88Author URI: https://imoje.pl
     
    3636    require_once( 'includes/gateway/WC_Gateway_Imoje_Abstract.php' );
    3737    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' );
    3939
    4040    foreach ( imoje_get_gateways() as $method ) {
     
    4242    }
    4343
    44     add_action( 'before_woocommerce_init', function() {
     44    add_action( 'before_woocommerce_init', function () {
    4545        if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
    4646            \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, true );
     
    5050    add_filter( 'woocommerce_payment_gateways', 'imoje_add_gateways' );
    5151
    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    }
    6057}
    6158
Note: See TracChangeset for help on using the changeset viewer.