shortcode_wrapper( array( __CLASS__, 'output' ), $atts ); } /** * Output the shortcode. * * @access public * @param array $atts * @return void */ public static function output( $atts ) { global $woocommerce; $woocommerce->nocache(); do_action( 'before_woocommerce_pay' ); $woocommerce->show_messages(); if ( isset( $_GET['pay_for_order'] ) && isset( $_GET['order'] ) && isset( $_GET['order_id'] ) ) { // Pay for existing order $order_key = urldecode( $_GET['order'] ); $order_id = absint( $_GET['order_id'] ); $order = new WC_Order( $order_id ); if ( $order->id == $order_id && $order->order_key == $order_key && in_array( $order->status, array( 'pending', 'failed' ) ) ) { // Set customer location to order location if ( $order->billing_country ) $woocommerce->customer->set_country( $order->billing_country ); if ( $order->billing_state ) $woocommerce->customer->set_state( $order->billing_state ); if ( $order->billing_postcode ) $woocommerce->customer->set_postcode( $order->billing_postcode ); // Show form woocommerce_get_template( 'checkout/form-pay.php', array( 'order' => $order ) ); } elseif ( ! in_array( $order->status, array( 'pending', 'failed' ) ) ) { $woocommerce->add_error( __( 'Your order has already been paid for. Please contact us if you need assistance.', 'woocommerce' ) ); $woocommerce->show_messages(); } else { $woocommerce->add_error( __( 'Invalid order.', 'woocommerce' ) ); $woocommerce->show_messages(); } } else { // Pay for order after checkout step $order_id = isset( $_GET['order'] ) ? absint( $_GET['order'] ) : 0; $order_key = isset( $_GET['key'] ) ? woocommerce_clean( $_GET['key'] ) : ''; if ( $order_id > 0 ) { $order = new WC_Order( $order_id ); if ( $order->order_key == $order_key && in_array( $order->status, array( 'pending', 'failed' ) ) ) { ?> payment_method, $order_id ); ?>
status, array( 'pending', 'failed' ) ) ) { $woocommerce->add_error( __( 'Your order has already been paid for. Please contact us if you need assistance.', 'woocommerce' ) ); $woocommerce->show_messages(); } } else { $woocommerce->add_error( __( 'Invalid order.', 'woocommerce' ) ); $woocommerce->show_messages(); } } do_action( 'after_woocommerce_pay' ); } }