Plugin Directory

Changeset 2979934


Ignore:
Timestamp:
10/17/2023 08:38:32 AM (2 years ago)
Author:
wpbrewer
Message:

Update to version 1.1.3 from GitHub

Location:
wpbr-linepay-tw
Files:
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wpbr-linepay-tw/tags/1.1.3/includes/admin/meta-boxes/class-linepay-tw-order-meta-boxes.php

    r2964807 r2979934  
    77
    88defined( 'ABSPATH' ) || exit;
     9
     10use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController;
     11use Automattic\WooCommerce\Utilities\OrderUtil;
    912
    1013/**
     
    3841     * @return void
    3942     */
    40     public function linepay_add_meta_boxes( $post ) {
     43    public function linepay_add_meta_boxes() {
    4144
    42         global $post;
     45        //NOTE: 這邊拿不到 global $post
     46        $screen = wc_get_container()->get( CustomOrdersTableController::class )->custom_orders_table_usage_is_enabled()
     47        ? wc_get_page_screen_id( 'shop-order' )
     48        : 'shop_order';
    4349
    44         if ( array_key_exists( get_post_meta( $post->ID, '_payment_method', true ), LINEPay_TW::$allowed_payments ) ) {
     50        // if ( array_key_exists( $order->get_meta( '_payment_method' ), LINEPay_TW::$allowed_payments ) ) {
    4551            add_meta_box(
    4652                'woocommerce-linepay-meta-boxes',
     
    5056                    'linepay_admin_meta',
    5157                ),
    52                 'shop_order',
     58                $screen,
    5359                'side',
    5460                'default'
    5561            );
    56         }
     62        // }
    5763
    5864    }
     
    6571     * @return void
    6672     */
    67     public function linepay_admin_meta( $post ) {
     73    public function linepay_admin_meta( $post_or_order_object ) {
    6874
    69         global $theorder;
     75        $order = ( $post_or_order_object instanceof WP_Post ) ? wc_get_order( $post_or_order_object->ID ) : $post_or_order_object;
    7076
    71         if ( ! is_object( $theorder ) ) {
    72             $theorder = wc_get_order( $post->ID );
    73         }
    74 
    75         if ( array_key_exists( get_post_meta( $post->ID, '_payment_method', true ), LINEPay_TW::$allowed_payments ) ) {
     77        if ( array_key_exists( $order->get_payment_method(), LINEPay_TW::$allowed_payments ) ) {
    7678
    7779            echo '<table>';
    78             echo '<tr><th><div id="order-id" data-order-id="' . esc_html( $post->ID ) . '">' . esc_html__( 'Transaction ID', 'wpbr-linepay-tw' ) . '</div></th><td>' . esc_html( $theorder->get_meta( '_linepay_reserved_transaction_id' ) ) . '</td></tr>';
    79             echo '<tr><th><div>' . esc_html__( 'Payment Status', 'wpbr-linepay-tw' ) . '</div></th><td>' . esc_html( $theorder->get_meta( '_linepay_payment_status' ) ) . '</td></tr>';
     80            echo '<tr><th><div id="order-id" data-order-id="' . esc_html( $order->get_id() ) . '">' . esc_html__( 'Transaction ID', 'wpbr-linepay-tw' ) . '</div></th><td>' . esc_html( $order->get_meta( '_linepay_reserved_transaction_id' ) ) . '</td></tr>';
     81            echo '<tr><th><div>' . esc_html__( 'Payment Status', 'wpbr-linepay-tw' ) . '</div></th><td>' . esc_html( $order->get_meta( '_linepay_payment_status' ) ) . '</td></tr>';
    8082
    81             // if ( $theorder->get_meta( '_linepay_payment_status' ) === WPBR_LINEPay_Const::PAYMENT_STATUS_AUTHED ) {
    82                 echo '<tr id="linepay-action"><th>' . esc_html__( 'Payment Action', 'wpbr-linepay-tw' ) . '</th><td><button class="button linepay-confirm-btn" data-id=' . esc_html( $post->ID ) . '>' . esc_html__( 'Confirm Payment', 'wpbr-linepay-tw' ) . '</button></tr>';
    83             // }
     83            if ( $order->get_meta( '_linepay_payment_status' ) === WPBR_LINEPay_Const::PAYMENT_STATUS_AUTHED ) {
     84                echo '<tr id="linepay-action"><th>' . esc_html__( 'Payment Action', 'wpbr-linepay-tw' ) . '</th><td><button class="button linepay-confirm-btn" data-id=' . esc_html( $order->get_id() ) . '>' . esc_html__( 'Confirm Payment', 'wpbr-linepay-tw' ) . '</button></tr>';
     85            }
    8486
    8587            echo '</table>';
  • wpbr-linepay-tw/tags/1.1.3/includes/gateways/class-linepay-tw-payment.php

    r2964807 r2979934  
    181181
    182182            if ( $order->get_status() === 'on-hold' ) {
    183                 $text = '<span class="linepay-order-onhold">' . esc_html__( 'We have received your order, but the payment status need to be confirmed. Please contact the support.', 'wpbr-linepay-tw' ) . '</span>';
     183                $text = esc_html__( 'We have received your order, but the payment status need to be confirmed. Please contact the support.', 'wpbr-linepay-tw' );
    184184            }
    185185
    186186            if ( $order->get_status() === 'pending' ) {
    187                 $text = '<span class="linepay-order-onhold">' . esc_html__( 'We have received your order, but the order is awaiting payment. Please pay again.', 'wpbr-linepay-tw' ) . '</span>';
     187                $text = esc_html__( 'We have received your order, but the order is awaiting payment. Please pay again.', 'wpbr-linepay-tw' );
    188188            }
    189189        }
     
    207207
    208208        if ( $order->get_status() === 'on-hold' ) {
    209             echo '<div class="linepay-order-onhold">' . esc_html__( 'We have received your order, but the payment status need to be confirmed. Please contact the support.', 'wpbr-linepay-tw' ) . '</div>';
     209            echo esc_html__( 'We have received your order, but the payment status need to be confirmed. Please contact the support.', 'wpbr-linepay-tw' );
    210210        }
    211211
    212212        if ( $order->get_status() === 'pending' ) {
    213             echo '<div class="linepay-order-onhold">' . esc_html__( 'We have received your order, but the order is awaiting payment. Please pay again.', 'wpbr-linepay-tw' ) . '</div>';
     213            echo esc_html__( 'We have received your order, but the order is awaiting payment. Please pay again.', 'wpbr-linepay-tw' ) . '</div>';
    214214        }
    215215
  • wpbr-linepay-tw/tags/1.1.3/includes/gateways/class-linepay-tw-request.php

    r2976149 r2979934  
    178178
    179179            // Direct access to DB to check whether order price information is altered.
    180             $reserved_std_amount = $this->get_standardized( get_post_meta( $order_id, '_order_total', true ), $currency );
     180            $reserved_std_amount = $this->get_standardized( $order->get_total(), $currency );
    181181            $std_amount          = $this->get_standardized( $amount );
    182182
  • wpbr-linepay-tw/tags/1.1.3/includes/gateways/class-linepay-tw-response.php

    r2964807 r2979934  
    5555            $order_id = ( isset( $_GET['order_id'] ) ) ? sanitize_text_field( wp_unslash( $_GET['order_id'] ) ) : '';
    5656
    57             if ( empty( $order_id ) ) {
     57            $order = wc_get_order( $order_id );
     58
     59            if ( ! $order ) {
    5860                throw new Exception( sprintf( WPBR_LINEPay_Const::LOG_TEMPLATE_HANDLE_CALLBANK_NOT_FOUND_ORDER_ID, $order_id, __( 'Unable to process callback.', 'wpbr-linepay-tw' ) ) );
    5961            }
    6062
    6163            $request_type   = ( isset( $_GET['request_type'] ) ) ? sanitize_text_field( wp_unslash( $_GET['request_type'] ) ) : '';
    62             $payment_status = get_post_meta( $order_id, '_linepay_payment_status', true );
     64            $payment_status = $order->get_meta( '_linepay_payment_status' );
    6365
    6466            $gateway = new LINEPay_TW_Payment();
  • wpbr-linepay-tw/tags/1.1.3/readme.md

    r2977332 r2979934  
    1010
    1111## Changlog ##
     12
     13= 1.1.3 =
     14*Release Date - 18 October 2023*
     15
     16* Update: Compatible with HPOS
     17* Update: Increase Requires PHP to 7.4
    1218
    1319= 1.1.2 =
  • wpbr-linepay-tw/tags/1.1.3/readme.txt

    r2977332 r2979934  
    33Tags: WooCommerce, payment, LINE Pay, LINE, taiwan, payment, payment gateway
    44Requires at least: 5.9
    5 Tested up to: 6.2
    6 Requires PHP: 7.0
    7 Stable tag: 1.1.2
     5Tested up to: 6.3.2
     6Requires PHP: 7.4
     7Stable tag: 1.1.3
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    2323
    2424== Changelog ==
     25
     26= 1.1.3 - 2023-10-18 =
     27
     28* Update: Compatible with HPOS
     29* Update: Increase Requires PHP version to 7.4
    2530
    2631= 1.1.2 - 2023-10-11 =
  • wpbr-linepay-tw/tags/1.1.3/wpbr-linepay-tw.php

    r2977332 r2979934  
    66 * Author: WPBrewer
    77 * Author URI: https://wpbrewer.com
    8  * Version: 1.1.2
     8 * Version: 1.1.3
    99 * Text Domain: wpbr-linepay-tw
    1010 * Domain Path: /languages
    1111 *
    1212 * WC requires at least: 3.0.0
    13  * WC tested up to: 7.6.0
     13 * WC tested up to: 8.2.1
    1414 *
    1515 *
     
    3535define( 'WPBR_LINEPAY_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    3636define( 'WPBR_LINEPAY_BASENAME', plugin_basename( __FILE__ ) );
    37 define( 'WPBR_LINEPAY_VERSION', '1.1.2' );
     37define( 'WPBR_LINEPAY_VERSION', '1.1.3' );
    3838
    3939/**
     
    5555    echo '</div>';
    5656}
     57
     58add_action( 'before_woocommerce_init', function() {
     59    if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
     60        \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
     61    }
     62} );
    5763
    5864/**
  • wpbr-linepay-tw/trunk/includes/admin/meta-boxes/class-linepay-tw-order-meta-boxes.php

    r2964807 r2979934  
    77
    88defined( 'ABSPATH' ) || exit;
     9
     10use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController;
     11use Automattic\WooCommerce\Utilities\OrderUtil;
    912
    1013/**
     
    3841     * @return void
    3942     */
    40     public function linepay_add_meta_boxes( $post ) {
     43    public function linepay_add_meta_boxes() {
    4144
    42         global $post;
     45        //NOTE: 這邊拿不到 global $post
     46        $screen = wc_get_container()->get( CustomOrdersTableController::class )->custom_orders_table_usage_is_enabled()
     47        ? wc_get_page_screen_id( 'shop-order' )
     48        : 'shop_order';
    4349
    44         if ( array_key_exists( get_post_meta( $post->ID, '_payment_method', true ), LINEPay_TW::$allowed_payments ) ) {
     50        // if ( array_key_exists( $order->get_meta( '_payment_method' ), LINEPay_TW::$allowed_payments ) ) {
    4551            add_meta_box(
    4652                'woocommerce-linepay-meta-boxes',
     
    5056                    'linepay_admin_meta',
    5157                ),
    52                 'shop_order',
     58                $screen,
    5359                'side',
    5460                'default'
    5561            );
    56         }
     62        // }
    5763
    5864    }
     
    6571     * @return void
    6672     */
    67     public function linepay_admin_meta( $post ) {
     73    public function linepay_admin_meta( $post_or_order_object ) {
    6874
    69         global $theorder;
     75        $order = ( $post_or_order_object instanceof WP_Post ) ? wc_get_order( $post_or_order_object->ID ) : $post_or_order_object;
    7076
    71         if ( ! is_object( $theorder ) ) {
    72             $theorder = wc_get_order( $post->ID );
    73         }
    74 
    75         if ( array_key_exists( get_post_meta( $post->ID, '_payment_method', true ), LINEPay_TW::$allowed_payments ) ) {
     77        if ( array_key_exists( $order->get_payment_method(), LINEPay_TW::$allowed_payments ) ) {
    7678
    7779            echo '<table>';
    78             echo '<tr><th><div id="order-id" data-order-id="' . esc_html( $post->ID ) . '">' . esc_html__( 'Transaction ID', 'wpbr-linepay-tw' ) . '</div></th><td>' . esc_html( $theorder->get_meta( '_linepay_reserved_transaction_id' ) ) . '</td></tr>';
    79             echo '<tr><th><div>' . esc_html__( 'Payment Status', 'wpbr-linepay-tw' ) . '</div></th><td>' . esc_html( $theorder->get_meta( '_linepay_payment_status' ) ) . '</td></tr>';
     80            echo '<tr><th><div id="order-id" data-order-id="' . esc_html( $order->get_id() ) . '">' . esc_html__( 'Transaction ID', 'wpbr-linepay-tw' ) . '</div></th><td>' . esc_html( $order->get_meta( '_linepay_reserved_transaction_id' ) ) . '</td></tr>';
     81            echo '<tr><th><div>' . esc_html__( 'Payment Status', 'wpbr-linepay-tw' ) . '</div></th><td>' . esc_html( $order->get_meta( '_linepay_payment_status' ) ) . '</td></tr>';
    8082
    81             // if ( $theorder->get_meta( '_linepay_payment_status' ) === WPBR_LINEPay_Const::PAYMENT_STATUS_AUTHED ) {
    82                 echo '<tr id="linepay-action"><th>' . esc_html__( 'Payment Action', 'wpbr-linepay-tw' ) . '</th><td><button class="button linepay-confirm-btn" data-id=' . esc_html( $post->ID ) . '>' . esc_html__( 'Confirm Payment', 'wpbr-linepay-tw' ) . '</button></tr>';
    83             // }
     83            if ( $order->get_meta( '_linepay_payment_status' ) === WPBR_LINEPay_Const::PAYMENT_STATUS_AUTHED ) {
     84                echo '<tr id="linepay-action"><th>' . esc_html__( 'Payment Action', 'wpbr-linepay-tw' ) . '</th><td><button class="button linepay-confirm-btn" data-id=' . esc_html( $order->get_id() ) . '>' . esc_html__( 'Confirm Payment', 'wpbr-linepay-tw' ) . '</button></tr>';
     85            }
    8486
    8587            echo '</table>';
  • wpbr-linepay-tw/trunk/includes/gateways/class-linepay-tw-payment.php

    r2964807 r2979934  
    181181
    182182            if ( $order->get_status() === 'on-hold' ) {
    183                 $text = '<span class="linepay-order-onhold">' . esc_html__( 'We have received your order, but the payment status need to be confirmed. Please contact the support.', 'wpbr-linepay-tw' ) . '</span>';
     183                $text = esc_html__( 'We have received your order, but the payment status need to be confirmed. Please contact the support.', 'wpbr-linepay-tw' );
    184184            }
    185185
    186186            if ( $order->get_status() === 'pending' ) {
    187                 $text = '<span class="linepay-order-onhold">' . esc_html__( 'We have received your order, but the order is awaiting payment. Please pay again.', 'wpbr-linepay-tw' ) . '</span>';
     187                $text = esc_html__( 'We have received your order, but the order is awaiting payment. Please pay again.', 'wpbr-linepay-tw' );
    188188            }
    189189        }
     
    207207
    208208        if ( $order->get_status() === 'on-hold' ) {
    209             echo '<div class="linepay-order-onhold">' . esc_html__( 'We have received your order, but the payment status need to be confirmed. Please contact the support.', 'wpbr-linepay-tw' ) . '</div>';
     209            echo esc_html__( 'We have received your order, but the payment status need to be confirmed. Please contact the support.', 'wpbr-linepay-tw' );
    210210        }
    211211
    212212        if ( $order->get_status() === 'pending' ) {
    213             echo '<div class="linepay-order-onhold">' . esc_html__( 'We have received your order, but the order is awaiting payment. Please pay again.', 'wpbr-linepay-tw' ) . '</div>';
     213            echo esc_html__( 'We have received your order, but the order is awaiting payment. Please pay again.', 'wpbr-linepay-tw' ) . '</div>';
    214214        }
    215215
  • wpbr-linepay-tw/trunk/includes/gateways/class-linepay-tw-request.php

    r2976149 r2979934  
    178178
    179179            // Direct access to DB to check whether order price information is altered.
    180             $reserved_std_amount = $this->get_standardized( get_post_meta( $order_id, '_order_total', true ), $currency );
     180            $reserved_std_amount = $this->get_standardized( $order->get_total(), $currency );
    181181            $std_amount          = $this->get_standardized( $amount );
    182182
  • wpbr-linepay-tw/trunk/includes/gateways/class-linepay-tw-response.php

    r2964807 r2979934  
    5555            $order_id = ( isset( $_GET['order_id'] ) ) ? sanitize_text_field( wp_unslash( $_GET['order_id'] ) ) : '';
    5656
    57             if ( empty( $order_id ) ) {
     57            $order = wc_get_order( $order_id );
     58
     59            if ( ! $order ) {
    5860                throw new Exception( sprintf( WPBR_LINEPay_Const::LOG_TEMPLATE_HANDLE_CALLBANK_NOT_FOUND_ORDER_ID, $order_id, __( 'Unable to process callback.', 'wpbr-linepay-tw' ) ) );
    5961            }
    6062
    6163            $request_type   = ( isset( $_GET['request_type'] ) ) ? sanitize_text_field( wp_unslash( $_GET['request_type'] ) ) : '';
    62             $payment_status = get_post_meta( $order_id, '_linepay_payment_status', true );
     64            $payment_status = $order->get_meta( '_linepay_payment_status' );
    6365
    6466            $gateway = new LINEPay_TW_Payment();
  • wpbr-linepay-tw/trunk/readme.md

    r2977332 r2979934  
    1010
    1111## Changlog ##
     12
     13= 1.1.3 =
     14*Release Date - 18 October 2023*
     15
     16* Update: Compatible with HPOS
     17* Update: Increase Requires PHP to 7.4
    1218
    1319= 1.1.2 =
  • wpbr-linepay-tw/trunk/readme.txt

    r2977332 r2979934  
    33Tags: WooCommerce, payment, LINE Pay, LINE, taiwan, payment, payment gateway
    44Requires at least: 5.9
    5 Tested up to: 6.2
    6 Requires PHP: 7.0
    7 Stable tag: 1.1.2
     5Tested up to: 6.3.2
     6Requires PHP: 7.4
     7Stable tag: 1.1.3
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    2323
    2424== Changelog ==
     25
     26= 1.1.3 - 2023-10-18 =
     27
     28* Update: Compatible with HPOS
     29* Update: Increase Requires PHP version to 7.4
    2530
    2631= 1.1.2 - 2023-10-11 =
  • wpbr-linepay-tw/trunk/wpbr-linepay-tw.php

    r2977332 r2979934  
    66 * Author: WPBrewer
    77 * Author URI: https://wpbrewer.com
    8  * Version: 1.1.2
     8 * Version: 1.1.3
    99 * Text Domain: wpbr-linepay-tw
    1010 * Domain Path: /languages
    1111 *
    1212 * WC requires at least: 3.0.0
    13  * WC tested up to: 7.6.0
     13 * WC tested up to: 8.2.1
    1414 *
    1515 *
     
    3535define( 'WPBR_LINEPAY_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    3636define( 'WPBR_LINEPAY_BASENAME', plugin_basename( __FILE__ ) );
    37 define( 'WPBR_LINEPAY_VERSION', '1.1.2' );
     37define( 'WPBR_LINEPAY_VERSION', '1.1.3' );
    3838
    3939/**
     
    5555    echo '</div>';
    5656}
     57
     58add_action( 'before_woocommerce_init', function() {
     59    if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
     60        \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
     61    }
     62} );
    5763
    5864/**
Note: See TracChangeset for help on using the changeset viewer.