@@ -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 *
0 commit comments