From 5c288d007a90b3a8c412256446426dccc2c40b7f Mon Sep 17 00:00:00 2001 From: Tim Jackleus Date: Sat, 16 Dec 2023 08:16:25 +0100 Subject: [PATCH] fix: center iframe on success screen (#95) --- .nvmrc | 1 + .../scss/ledyer-checkout-for-woocommerce.scss | 16 ++++----- classes/class-ledyer-lco-gateway.php | 33 ++++++++----------- 3 files changed, 23 insertions(+), 27 deletions(-) create mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..c85fa1b --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +16.17.1 diff --git a/assets/scss/ledyer-checkout-for-woocommerce.scss b/assets/scss/ledyer-checkout-for-woocommerce.scss index 6ca4063..97eb397 100644 --- a/assets/scss/ledyer-checkout-for-woocommerce.scss +++ b/assets/scss/ledyer-checkout-for-woocommerce.scss @@ -2,14 +2,14 @@ display: flex; flex-direction: column; align-items: center; +} - #lco-order-review, - #lco-iframe { - width: 100%; - } +#lco-order-review, +#lco-iframe { + width: 100%; +} - #lco-iframe { - display: flex; - justify-content: center; - } +#lco-iframe { + display: flex; + justify-content: center; } diff --git a/classes/class-ledyer-lco-gateway.php b/classes/class-ledyer-lco-gateway.php index 8391e98..8cd3c2f 100644 --- a/classes/class-ledyer-lco-gateway.php +++ b/classes/class-ledyer-lco-gateway.php @@ -104,11 +104,19 @@ public function enqueue_scripts() { return; } + // Load the Ledyer Checkout for WooCommerce stylesheet. + wp_register_style( + 'lco', + plugins_url('build/ledyer-checkout-for-woocommerce.css', LCO_WC_MAIN_FILE), + array(), + filemtime(plugin_dir_path(LCO_WC_MAIN_FILE) . ('build/ledyer-checkout-for-woocommerce.css')) + ); + wp_enqueue_style('lco'); + if ( ! is_checkout() ) { return; } - $scriptSrcUrl = 'https://checkout.live.ledyer.com/bootstrap.js'; if ( $this->testmode ) { @@ -120,7 +128,7 @@ public function enqueue_scripts() { case 'development': $scriptSrcUrl = 'https://checkout.dev.ledyer.com/bootstrap.js'; break; - default: + default: $scriptSrcUrl = 'https://checkout.sandbox.ledyer.com/bootstrap.js'; break; } @@ -155,13 +163,6 @@ public function enqueue_scripts() { true ); - wp_register_style( - 'lco', - plugins_url( 'build/ledyer-checkout-for-woocommerce.css', LCO_WC_MAIN_FILE ), - array(), - filemtime( plugin_dir_path( LCO_WC_MAIN_FILE ) . ( 'build/ledyer-checkout-for-woocommerce.css' ) ) - ); - $email_exists = 'no'; if ( null !== WC()->customer && method_exists( WC()->customer, 'get_billing_email' ) && ! empty( WC()->customer->get_billing_email() ) ) { @@ -220,18 +221,11 @@ public function enqueue_scripts() { 'no_shipping_message' => apply_filters( 'woocommerce_no_shipping_available_html', __( 'There are no shipping options available. Please ensure that your address has been entered correctly, or contact us if you need any help.', 'woocommerce' ) ), ); - if ( version_compare( WC_VERSION, '3.9', '>=' ) ) { - $checkout_localize_params['force_update'] = true; - } - wp_localize_script( 'lco', 'lco_params', $checkout_localize_params ); + $checkout_localize_params['force_update'] = true; + wp_localize_script( 'lco', 'lco_params', $checkout_localize_params ); wp_enqueue_script( 'lco-iframe' ); - wp_enqueue_script( 'lco' ); - - if ( ! $pay_for_order ) { - wp_enqueue_style( 'lco' ); - } } /** @@ -680,7 +674,7 @@ public function lom_allow_editing($order) { if ( $order->has_status( array( 'completed', 'refunded', 'cancelled' ) ) ) { return false; } - + return true; } @@ -692,3 +686,4 @@ public function lom_order_placed_with_ledyer($payment_method) { } } } +