Fix download links and post_status checks. Closes #1903.
This commit is contained in:
parent
a14889e857
commit
8f0fce893e
|
@ -293,6 +293,7 @@ abstract class WC_Product {
|
|||
function get_file_download_path( $download_id ) {
|
||||
|
||||
$file_paths = isset( $this->product_custom_fields['_file_paths'][0] ) ? $this->product_custom_fields['_file_paths'][0] : '';
|
||||
$file_paths = maybe_unserialize( $file_paths );
|
||||
$file_paths = apply_filters( 'woocommerce_file_download_paths', $file_paths, $this->id, null, null );
|
||||
|
||||
if ( ! $download_id && count( $file_paths ) == 1 ) {
|
||||
|
|
|
@ -589,7 +589,7 @@ class WC_Customer {
|
|||
}
|
||||
|
||||
// order exists and downloads permitted?
|
||||
if ( ! $order->id || ! $order->is_download_permitted() || $order->status != 'publish' ) continue;
|
||||
if ( ! $order->id || ! $order->is_download_permitted() || $order->post_status != 'publish' ) continue;
|
||||
|
||||
if ( ! $_product || $_product->id != $result->product_id ) :
|
||||
// new product
|
||||
|
|
|
@ -146,6 +146,9 @@ class WC_Order {
|
|||
/** @var string */
|
||||
var $formatted_shipping_address;
|
||||
|
||||
/** @var string */
|
||||
var $post_status;
|
||||
|
||||
/**
|
||||
* Get the order if ID is passed, otherwise the order is new and empty.
|
||||
*
|
||||
|
@ -196,6 +199,7 @@ class WC_Order {
|
|||
$this->order_date = $result->post_date;
|
||||
$this->modified_date = $result->post_modified;
|
||||
$this->customer_note = $result->post_excerpt;
|
||||
$this->post_status = $result->post_status;
|
||||
$this->order_custom_fields = get_post_custom( $this->id );
|
||||
|
||||
// Define the data we're going to load: Key => Default value
|
||||
|
|
|
@ -822,7 +822,7 @@ function woocommerce_cancel_order() {
|
|||
|
||||
$order = new WC_Order( $order_id );
|
||||
|
||||
if ($order->id == $order_id && $order->order_key == $order_key && in_array($order->status, array('pending', 'failed')) && $woocommerce->verify_nonce('cancel_order', '_GET')) :
|
||||
if ( $order->id == $order_id && $order->order_key == $order_key && in_array( $order->status, array( 'pending', 'failed' ) ) && $woocommerce->verify_nonce( 'cancel_order', '_GET' ) ) :
|
||||
|
||||
// Cancel the order + restore stock
|
||||
$order->cancel_order( __('Order cancelled by customer.', 'woocommerce' ) );
|
||||
|
@ -832,7 +832,7 @@ function woocommerce_cancel_order() {
|
|||
|
||||
do_action( 'woocommerce_cancelled_order', $order->id );
|
||||
|
||||
elseif ($order->status!='pending') :
|
||||
elseif ( $order->status != 'pending' ) :
|
||||
|
||||
$woocommerce->add_error( __( 'Your order is no longer pending and could not be cancelled. Please contact us if you need assistance.', 'woocommerce' ) );
|
||||
|
||||
|
@ -915,7 +915,7 @@ function woocommerce_download_product() {
|
|||
if ( $order_id ) {
|
||||
$order = new WC_Order( $order_id );
|
||||
|
||||
if ( ! $order->is_download_permitted() || $order->status != 'publish' )
|
||||
if ( ! $order->is_download_permitted() || $order->post_status != 'publish' )
|
||||
wp_die( __( 'Invalid order.', 'woocommerce' ) . ' <a href="' . home_url() . '">' . __( 'Go to homepage →', 'woocommerce' ) . '</a>' );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue