diff --git a/includes/abstracts/abstract-wc-order.php b/includes/abstracts/abstract-wc-order.php index c0c4951cb94..5922b475e03 100644 --- a/includes/abstracts/abstract-wc-order.php +++ b/includes/abstracts/abstract-wc-order.php @@ -890,17 +890,21 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order { * Apply a coupon to the order and recalculate totals. * * @since 3.2.0 - * @param string|WC_Coupon $coupon Coupon code or object. + * @param string|WC_Coupon $raw_coupon Coupon code or object. * @return true|WP_Error True if applied, error if not. */ - public function apply_coupon( $coupon ) { - if ( ! is_a( $coupon, 'WC_Coupon' ) ) { - $code = wc_format_coupon_code( $coupon ); + public function apply_coupon( $raw_coupon ) { + if ( is_a( $raw_coupon, 'WC_Coupon' ) ) { + $coupon = $raw_coupon; + } elseif ( is_string( $raw_coupon ) ) { + $code = wc_format_coupon_code( $raw_coupon ); $coupon = new WC_Coupon( $code ); if ( $coupon->get_code() !== $code || ! $coupon->is_valid() ) { return new WP_Error( 'invalid_coupon', __( 'Invalid coupon code', 'woocommerce' ) ); } + } else { + return new WP_Error( 'invalid_coupon', __( 'Invalid coupon', 'woocommerce' ) ); } // Check to make sure coupon is not already applied. @@ -1017,7 +1021,6 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order { $coupons = $this->get_items( 'coupon' ); $coupon_code_to_id = wc_list_pluck( $coupons, 'get_id', 'get_code' ); $all_discounts = $discounts->get_discounts(); - $item_discounts = $discounts->get_discounts_by_item(); $coupon_discounts = $discounts->get_discounts_by_coupon(); if ( $coupon_discounts ) { diff --git a/includes/abstracts/abstract-wc-product.php b/includes/abstracts/abstract-wc-product.php index d754c752630..138c3735608 100644 --- a/includes/abstracts/abstract-wc-product.php +++ b/includes/abstracts/abstract-wc-product.php @@ -1190,7 +1190,7 @@ class WC_Product extends WC_Abstract_Legacy_Product { * Set download limit. * * @since 3.0.0 - * @param int $download_limit + * @param int|string $download_limit */ public function set_download_limit( $download_limit ) { $this->set_prop( 'download_limit', -1 === (int) $download_limit || '' === $download_limit ? -1 : absint( $download_limit ) ); @@ -1200,7 +1200,7 @@ class WC_Product extends WC_Abstract_Legacy_Product { * Set download expiry. * * @since 3.0.0 - * @param int $download_expiry + * @param int|string $download_limit */ public function set_download_expiry( $download_expiry ) { $this->set_prop( 'download_expiry', -1 === (int) $download_expiry || '' === $download_expiry ? -1 : absint( $download_expiry ) ); diff --git a/includes/abstracts/abstract-wc-rest-controller.php b/includes/abstracts/abstract-wc-rest-controller.php index b06f5bddaec..b32f0c055d3 100644 --- a/includes/abstracts/abstract-wc-rest-controller.php +++ b/includes/abstracts/abstract-wc-rest-controller.php @@ -205,7 +205,6 @@ abstract class WC_REST_Controller extends WP_REST_Controller { public function validate_setting_text_field( $value, $setting ) { $value = is_null( $value ) ? '' : $value; return wp_kses_post( trim( stripslashes( $value ) ) ); - return $value; } /** diff --git a/includes/abstracts/abstract-wc-rest-crud-controller.php b/includes/abstracts/abstract-wc-rest-crud-controller.php index 05ef6317c39..ed4d5376d7f 100644 --- a/includes/abstracts/abstract-wc-rest-crud-controller.php +++ b/includes/abstracts/abstract-wc-rest-crud-controller.php @@ -37,7 +37,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller { * Get object. * * @param int $id Object ID. - * @return WP_Error|WC_Data + * @return object WC_Data object or WP_Error object. */ protected function get_object( $id ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) ); @@ -376,7 +376,6 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller { * @return WP_REST_Response|WP_Error */ public function delete_item( $request ) { - $id = (int) $request['id']; $force = (bool) $request['force']; $object = $this->get_object( (int) $request['id'] ); $result = false; diff --git a/includes/admin/class-wc-admin-addons.php b/includes/admin/class-wc-admin-addons.php index 43562bbf94a..347ea1c1820 100644 --- a/includes/admin/class-wc-admin-addons.php +++ b/includes/admin/class-wc-admin-addons.php @@ -477,6 +477,15 @@ class WC_Admin_Addons { $theme = wp_get_theme(); $section_keys = array_keys( $sections ); $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); + + /** + * Addon page view. + * + * @uses $sections + * @uses $theme + * @uses $section_keys + * @uses $current_section + */ include_once( dirname( __FILE__ ) . '/views/html-admin-page-addons.php' ); } diff --git a/includes/admin/helper/class-wc-helper-api.php b/includes/admin/helper/class-wc-helper-api.php index 646c814c724..014b693d4b3 100644 --- a/includes/admin/helper/class-wc-helper-api.php +++ b/includes/admin/helper/class-wc-helper-api.php @@ -66,7 +66,7 @@ class WC_Helper_API { $request_uri = parse_url( $url, PHP_URL_PATH ); $query_string = parse_url( $url, PHP_URL_QUERY ); - if ( $query_string ) { + if ( is_string( $query_string ) ) { $request_uri .= '?' . $query_string; } diff --git a/includes/admin/helper/class-wc-helper-plugin-info.php b/includes/admin/helper/class-wc-helper-plugin-info.php index 033ec8c0b3e..351c92c54d5 100644 --- a/includes/admin/helper/class-wc-helper-plugin-info.php +++ b/includes/admin/helper/class-wc-helper-plugin-info.php @@ -40,7 +40,6 @@ class WC_Helper_Plugin_Info { // Look through local Woo plugins by slugs. foreach ( WC_Helper::get_local_woo_plugins() as $plugin ) { - $slug = dirname( $plugin['_filename'] ); if ( dirname( $plugin['_filename'] ) === $args->slug ) { $plugin['_slug'] = $args->slug; $found_plugin = $plugin; diff --git a/includes/admin/helper/class-wc-helper.php b/includes/admin/helper/class-wc-helper.php index 8a997353dc3..e5f8c6e626e 100644 --- a/includes/admin/helper/class-wc-helper.php +++ b/includes/admin/helper/class-wc-helper.php @@ -615,7 +615,7 @@ class WC_Helper { 'wc-helper-status' => 'helper-disconnected', ), admin_url( 'admin.php' ) ); - $result = WC_Helper_API::post( 'oauth/invalidate_token', array( + WC_Helper_API::post( 'oauth/invalidate_token', array( 'authenticated' => true, ) );