Skip to content

Commit 722cf8d

Browse files
committed
[#76] Add get_cancel_order_url_raw() compat method
see also #56
1 parent c99f4ac commit 722cf8d

File tree

3 files changed

+50
-9
lines changed

3 files changed

+50
-9
lines changed

woocommerce/changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
*** SkyVerge WooCommerce Plugin Framework Changelog ***
22

3+
2015.nn.nn - version 3.1.0-1
4+
* Tweak - Add `get_cancel_order_url_raw()` compatibility method
5+
36
2015.02.09 - version 3.1.0
47
* Refund/Void support for the payment gateway framework, huzzah!
58
* Misc - WooCommerce 2.3 compatibility

woocommerce/class-sv-wc-plugin-compatibility.php

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ public static function wc_get_order( $the_order = false ) {
8686

8787

8888
/**
89-
* Get all order statuses
90-
*
91-
* Introduced in WC 2.2
92-
*
93-
* @since 3.0.0
94-
* @return array
95-
*/
89+
* Get all order statuses
90+
*
91+
* Introduced in WC 2.2
92+
*
93+
* @since 3.0.0
94+
* @return array
95+
*/
9696
public static function wc_get_order_statuses() {
9797

9898
if ( self::is_wc_version_gte_2_2() ) {
@@ -247,6 +247,44 @@ public static function get_order_user( WC_Order $order ) {
247247
}
248248

249249

250+
/**
251+
* Get the raw (unescaped) cancel-order URL
252+
*
253+
* Introduced in WC 2.3.6
254+
*
255+
* @since 3.1.0-1
256+
* @param \WC_Order $order
257+
* @return string The unescaped cancel-order URL
258+
*/
259+
public static function get_cancel_order_url_raw( WC_Order $order, $redirect = '' ) {
260+
261+
if ( self::is_wc_version_gt( '2.3.5' ) ) {
262+
263+
return $order->get_cancel_order_url_raw( $redirect );
264+
265+
} else {
266+
267+
// Get cancel endpoint
268+
$cancel_endpoint = get_permalink( wc_get_page_id( 'cart' ) );
269+
if ( ! $cancel_endpoint ) {
270+
$cancel_endpoint = home_url();
271+
}
272+
273+
if ( false === strpos( $cancel_endpoint, '?' ) ) {
274+
$cancel_endpoint = trailingslashit( $cancel_endpoint );
275+
}
276+
277+
return apply_filters( 'woocommerce_get_cancel_order_url_raw', add_query_arg( array(
278+
'cancel_order' => 'true',
279+
'order' => $order->order_key,
280+
'order_id' => $order->id,
281+
'redirect' => $redirect,
282+
'_wpnonce' => wp_create_nonce( 'woocommerce-cancel_order' )
283+
), $cancel_endpoint ) );
284+
}
285+
}
286+
287+
250288
/**
251289
* Get the WC Product instance for a given product ID or post
252290
*

woocommerce/class-sv-wc-plugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@
8484
* Use the standard WordPress/WooCommerce `is_*` methods when adding the notice
8585
* to control which pages it does (or does not) display on.
8686
*
87-
* @version 3.1.0
87+
* @version 3.1.0-1
8888
*/
8989
abstract class SV_WC_Plugin {
9090

9191
/** Plugin Framework Version */
92-
const VERSION = '3.1.0';
92+
const VERSION = '3.1.0-1';
9393

9494
/** @var object single instance of plugin */
9595
protected static $instance;

0 commit comments

Comments
 (0)