Merge pull request #9054 from khag7/khag7-patch-2

use the needs_payment function
This commit is contained in:
Mike Jolley 2015-09-07 14:19:48 +01:00
commit ae849c7adb
3 changed files with 6 additions and 10 deletions

View File

@ -266,9 +266,7 @@ class WC_Form_Handler {
$order_id = absint( $wp->query_vars['order-pay'] ); $order_id = absint( $wp->query_vars['order-pay'] );
$order = wc_get_order( $order_id ); $order = wc_get_order( $order_id );
$valid_order_statuses = apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'failed' ), $order ); if ( $order->id == $order_id && $order->order_key == $order_key && $order->needs_payment() ) {
if ( $order->id == $order_id && $order->order_key == $order_key && $order->has_status( $valid_order_statuses ) ) {
// Set customer location to order location // Set customer location to order location
if ( $order->billing_country ) { if ( $order->billing_country ) {

View File

@ -84,7 +84,6 @@ class WC_Shortcode_Checkout {
// Pay for existing order // Pay for existing order
$order_key = $_GET[ 'key' ]; $order_key = $_GET[ 'key' ];
$order = wc_get_order( $order_id ); $order = wc_get_order( $order_id );
$valid_order_statuses = apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'failed' ), $order );
if ( ! current_user_can( 'pay_for_order', $order_id ) ) { if ( ! current_user_can( 'pay_for_order', $order_id ) ) {
echo '<div class="woocommerce-error">' . __( 'Invalid order. If you have an account please log in and try again.', 'woocommerce' ) . ' <a href="' . wc_get_page_permalink( 'myaccount' ) . '" class="wc-forward">' . __( 'My Account', 'woocommerce' ) . '</a>' . '</div>'; echo '<div class="woocommerce-error">' . __( 'Invalid order. If you have an account please log in and try again.', 'woocommerce' ) . ' <a href="' . wc_get_page_permalink( 'myaccount' ) . '" class="wc-forward">' . __( 'My Account', 'woocommerce' ) . '</a>' . '</div>';
@ -93,7 +92,7 @@ class WC_Shortcode_Checkout {
if ( $order->id == $order_id && $order->order_key == $order_key ) { if ( $order->id == $order_id && $order->order_key == $order_key ) {
if ( $order->has_status( $valid_order_statuses ) ) { if ( $order->needs_payment() ) {
// Set customer location to order location // Set customer location to order location
if ( $order->billing_country ) if ( $order->billing_country )
@ -118,11 +117,10 @@ class WC_Shortcode_Checkout {
// Pay for order after checkout step // Pay for order after checkout step
$order_key = isset( $_GET['key'] ) ? wc_clean( $_GET['key'] ) : ''; $order_key = isset( $_GET['key'] ) ? wc_clean( $_GET['key'] ) : '';
$order = wc_get_order( $order_id ); $order = wc_get_order( $order_id );
$valid_order_statuses = apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'failed' ), $order );
if ( $order->id == $order_id && $order->order_key == $order_key ) { if ( $order->id == $order_id && $order->order_key == $order_key ) {
if ( $order->has_status( $valid_order_statuses ) ) { if ( $order->needs_payment() ) {
?> ?>
<ul class="order_details"> <ul class="order_details">

View File

@ -62,7 +62,7 @@ if ( $customer_orders ) : ?>
<?php <?php
$actions = array(); $actions = array();
if ( in_array( $order->get_status(), apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'failed' ), $order ) ) ) { if ( $order->needs_payment() ) {
$actions['pay'] = array( $actions['pay'] = array(
'url' => $order->get_checkout_payment_url(), 'url' => $order->get_checkout_payment_url(),
'name' => __( 'Pay', 'woocommerce' ) 'name' => __( 'Pay', 'woocommerce' )