Changeset 2517898
- Timestamp:
- 04/19/2021 09:46:34 PM (5 years ago)
- File:
-
- 1 edited
-
voucherify/trunk/src/functions.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
voucherify/trunk/src/functions.php
r2504530 r2517898 42 42 $block_vouchers = is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX 43 43 && ! ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] === "woocommerce_refund_line_items" ) ); 44 44 45 return apply_filters( 'voucherify_validation_service_block_validation', $block_vouchers ); 45 46 } … … 61 62 * Collects information about order and prepares portion of context data 62 63 * to be consumed by API. 63 *64 * @param WC_Order $order64 * 65 * @param WC_Order $order 65 66 * 66 67 * @return array order data in form of array accepted by API's context. … … 68 69 function vcrf_get_order_data( WC_Order $order = null ) { 69 70 $is_pending = ! empty( $order ) && $order->get_status() === 'pending'; 70 if ( ! vcrf_is_rest_request() && ! $is_pending 71 && ( ! is_admin() || ( defined( 'VCRF_FETCH_PROMOTIONS' ) && VCRF_FETCH_PROMOTIONS ) ) ) { 71 if ( ! $is_pending && vcrf_is_wc_object_available() ) { 72 72 $cart_decorator = new Voucherify_Cart_Decorator( WC()->cart ); 73 73 … … 167 167 */ 168 168 function vcrf_get_customer_data() { 169 if ( ! vcrf_is_rest_request() && ( ! is_admin() || ( defined( 'VCRF_FETCH_PROMOTIONS' ) && VCRF_FETCH_PROMOTIONS )) ) {169 if ( vcrf_is_wc_object_available() ) { 170 170 $customer_decorator = new Voucherify_Customer_Decorator( WC()->customer ); 171 171 … … 206 206 } 207 207 } 208 209 if ( ! function_exists('vcrf_is_wc_object_available') ) { 210 /** 211 * Checks if the default WC() object is available 212 * 213 * @return bool 214 */ 215 function vcrf_is_wc_object_available() { 216 if ( defined( 'VCRF_FETCH_PROMOTIONS' ) && VCRF_FETCH_PROMOTIONS ) { 217 return true; 218 } 219 220 if ( vcrf_is_rest_request() || is_admin() || isset( $GLOBALS['wp']->query_vars['wc-api'] ) ) { 221 return false; 222 } 223 224 return true; 225 } 226 }
Note: See TracChangeset
for help on using the changeset viewer.