payment_method !== 'innovext_allpay_aio' ) return; $order_id = $order->id; $return_code = get_post_meta( $order_id, '_RtnCode', true ); $payment_type = get_post_meta( $order_id, '_PaymentType', true ); $payment_type_label = WC_innovext_allpay_aio::parse_payment_type( $payment_type ); $merchant_trade_no = get_post_meta( $order_id, '_MerchantTradeNo', true ); $label = WC_innovext_allpay_aio::get_allpay_ecpay_label( $order_id ); if( $return_code === '1' ){ ?>

金流資訊

訂單編號
付款方式
付款狀態已收到付款
status !== 'cancelled' ){ ?>

金流資訊

訂單編號
付款方式
付款狀態尚未付款
payment_method !== 'innovext_allpay_aio' ) { return; } // Get order instructions $allpay_aio_settings = get_option( 'woocommerce_innovext_allpay_aio_settings' ); if( $allpay_aio_settings ) { $allpay_instruction_succ = $allpay_aio_settings['instruction_succ']; $allpay_instruction_on_hold = $allpay_aio_settings['instruction_on_hold']; $return_code = get_post_meta( $order_id, '_RtnCode', true ); } else { return; } if( $return_code === '1' && $order->status == 'processing' ) { if( $allpay_instruction_succ ) { echo '
'; echo wpautop( wptexturize( $allpay_instruction_succ ) ); echo '
'; } } elseif( ( $return_code === '2' || $return_code === '10100073' ) && $order->status == 'on-hold' ) { if ( $allpay_instruction_on_hold ) { echo '
'; echo wpautop( wptexturize( $allpay_instruction_on_hold ) ); echo '
'; } } } /** * Check the orders if their Allpay AIO orderstatus payment deadline is expired, * * @return void */ function cancel_unpaid_orders() { $args = array( 'post_type' => 'shop_order', 'post_status' => array( 'wc-on-hold' ), 'order' => 'ASC', // make sure update from the oldest order 'orderby' => 'date', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => '_payment_method', 'value' => array( 'innovext_allpay_aio', ), 'compare' => 'IN' ), ) ); $posts = get_posts( $args ); if( empty( $posts ) ) { return; } foreach( $posts as $post ) { $order_id = $post->ID; $expiredate = get_post_meta( $order_id, '_ExpireDate', true ); if( empty( $expiredate ) ) { continue; } $order = new WC_Order( $order_id ); $parse_date = date_parse( $expiredate ); // the format of ATM expire date is YYYY-mm-dd, which doesn't contain time. // so we need to +1 day to make sure the order is expired at the end of the given day if( isset( $parse_date['hour'] ) && $parse_date['hour'] === false ) { $expiredate = $expiredate . '+1 day'; } $deadline_timestamp = strtotime( $expiredate ); $now_timestamp = strtotime( 'now' ); // if expired, cancel the WC order if( $now_timestamp > $deadline_timestamp ) { $order->update_status( 'cancelled', '訂單超過繳費期限' ); } } // die(); // use die to get the output } /** * Add cron schedules interval */ function add_cancel_order_schedule( $schedules ) { $allpay_aio_settings = get_option( 'woocommerce_innovext_allpay_aio_settings' ); if( isset( $allpay_aio_settings['cron_frequency_min'] ) && ! empty( $allpay_aio_settings['cron_frequency_min'] ) ) { $cron_frequency_min = $allpay_aio_settings['cron_frequency_min']; } else { $cron_frequency_min = 360; } $schedules['woocommerce_allpay_aio_cron_frequency'] = array( 'interval' => $cron_frequency_min * 60, // X minutes * 60 seconds, default is 1 hour 'display' => __( '歐付寶/綠界全方位金流檢查過期訂單') ); return $schedules; } /* schedule the event */ function auto_update_order_schedule() { $allpay_aio_settings = get_option( 'woocommerce_innovext_allpay_aio_settings' ); if( isset( $allpay_aio_settings['cron_frequency_min'] ) && $allpay_aio_settings['cron_frequency_min'] > 0 ) { $enable_cron = 'yes'; } else { $enable_cron = 'no'; } if( $enable_cron != 'yes' ) { return; } if( function_exists('wp_next_scheduled') && function_exists('wp_schedule_event') ) { $now_timestmp = strtotime( 'now' ); if( !wp_next_scheduled( 'allpay_aio_auto_update_order' ) ) { wp_schedule_event( $now_timestmp, 'woocommerce_allpay_aio_cron_frequency', 'allpay_aio_auto_update_order' ); } } } } Innvext_Allpay_AIO_Addon::init(); }