From ebca8ba1becd6943e06b2e7537b40e02cb8d3752 Mon Sep 17 00:00:00 2001 From: ratulhasan Date: Thu, 21 Oct 2021 20:43:40 +0600 Subject: [PATCH 1/8] Fix Uncaught TypeError: Unsupported operand types: string * float --- .../woocommerce/includes/admin/class-wc-admin-post-types.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php b/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php index 2eaef024a14..511c07faea7 100644 --- a/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php +++ b/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php @@ -928,7 +928,7 @@ class WC_Admin_Post_Types { return false; } - $old_price = $product->{"get_{$price_type}_price"}(); + $old_price = doubleval( $product->{"get_{$price_type}_price"}() ); $price_changed = false; $change_price = absint( $request_data[ "change_{$price_type}_price" ] ); From d9016b5dc0bbb508258e090caa88b8af091adfe5 Mon Sep 17 00:00:00 2001 From: ratulhasan Date: Fri, 22 Oct 2021 10:56:11 +0600 Subject: [PATCH 2/8] Fix Uncaught TypeError: Unsupported operand types: string * float --- .../woocommerce/includes/admin/class-wc-admin-post-types.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php b/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php index 511c07faea7..5b16daafb19 100644 --- a/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php +++ b/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php @@ -928,7 +928,7 @@ class WC_Admin_Post_Types { return false; } - $old_price = doubleval( $product->{"get_{$price_type}_price"}() ); + $old_price = ( $product->{"get_{$price_type}_price"}() === '' ) ? 0 : $product->{"get_{$price_type}_price"}(); $price_changed = false; $change_price = absint( $request_data[ "change_{$price_type}_price" ] ); From a22c347902bad9398670014dbcd7e903445e7fc3 Mon Sep 17 00:00:00 2001 From: ratulhasan Date: Fri, 22 Oct 2021 11:01:39 +0600 Subject: [PATCH 3/8] empty check --- .../woocommerce/includes/admin/class-wc-admin-post-types.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php b/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php index 5b16daafb19..4749aaa6023 100644 --- a/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php +++ b/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php @@ -928,7 +928,7 @@ class WC_Admin_Post_Types { return false; } - $old_price = ( $product->{"get_{$price_type}_price"}() === '' ) ? 0 : $product->{"get_{$price_type}_price"}(); + $old_price = empty( $product->{"get_{$price_type}_price"}() ) ? 0 : $product->{"get_{$price_type}_price"}(); $price_changed = false; $change_price = absint( $request_data[ "change_{$price_type}_price" ] ); From 59adcb26b84acbee279f70e563fcdb209ce495ef Mon Sep 17 00:00:00 2001 From: ratulhasan Date: Thu, 21 Oct 2021 20:43:40 +0600 Subject: [PATCH 4/8] Fix Uncaught TypeError: Unsupported operand types: string * float --- .../woocommerce/includes/admin/class-wc-admin-post-types.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php b/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php index 2eaef024a14..511c07faea7 100644 --- a/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php +++ b/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php @@ -928,7 +928,7 @@ class WC_Admin_Post_Types { return false; } - $old_price = $product->{"get_{$price_type}_price"}(); + $old_price = doubleval( $product->{"get_{$price_type}_price"}() ); $price_changed = false; $change_price = absint( $request_data[ "change_{$price_type}_price" ] ); From 3b4168dcbccc0fc91745382b68fe8f95fc30a65d Mon Sep 17 00:00:00 2001 From: ratulhasan Date: Fri, 22 Oct 2021 10:56:11 +0600 Subject: [PATCH 5/8] Fix Uncaught TypeError: Unsupported operand types: string * float --- .../woocommerce/includes/admin/class-wc-admin-post-types.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php b/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php index 511c07faea7..5b16daafb19 100644 --- a/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php +++ b/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php @@ -928,7 +928,7 @@ class WC_Admin_Post_Types { return false; } - $old_price = doubleval( $product->{"get_{$price_type}_price"}() ); + $old_price = ( $product->{"get_{$price_type}_price"}() === '' ) ? 0 : $product->{"get_{$price_type}_price"}(); $price_changed = false; $change_price = absint( $request_data[ "change_{$price_type}_price" ] ); From 12719616d9c17e1b55fad538ae08b5729754c498 Mon Sep 17 00:00:00 2001 From: ratulhasan Date: Fri, 22 Oct 2021 11:01:39 +0600 Subject: [PATCH 6/8] empty check --- .../woocommerce/includes/admin/class-wc-admin-post-types.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php b/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php index 5b16daafb19..4749aaa6023 100644 --- a/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php +++ b/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php @@ -928,7 +928,7 @@ class WC_Admin_Post_Types { return false; } - $old_price = ( $product->{"get_{$price_type}_price"}() === '' ) ? 0 : $product->{"get_{$price_type}_price"}(); + $old_price = empty( $product->{"get_{$price_type}_price"}() ) ? 0 : $product->{"get_{$price_type}_price"}(); $price_changed = false; $change_price = absint( $request_data[ "change_{$price_type}_price" ] ); From f593a2435c9a7c0e89d246f6f0dd2aa27e7bd553 Mon Sep 17 00:00:00 2001 From: barryhughes <3594411+barryhughes@users.noreply.github.com> Date: Wed, 13 Apr 2022 12:46:52 -0700 Subject: [PATCH 7/8] Use a cast to float instead of ternary. --- plugins/woocommerce/changelog/fix-unsupported-operand-types | 4 ++++ .../woocommerce/includes/admin/class-wc-admin-post-types.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 plugins/woocommerce/changelog/fix-unsupported-operand-types diff --git a/plugins/woocommerce/changelog/fix-unsupported-operand-types b/plugins/woocommerce/changelog/fix-unsupported-operand-types new file mode 100644 index 00000000000..ce5ecc73871 --- /dev/null +++ b/plugins/woocommerce/changelog/fix-unsupported-operand-types @@ -0,0 +1,4 @@ +Significance: patch +Type: tweak + +Avoid unsupported operand type errors from within `WC_Admin_Post_Types::set_new_price()`. diff --git a/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php b/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php index 4749aaa6023..2a5ca1281f0 100644 --- a/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php +++ b/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php @@ -928,7 +928,7 @@ class WC_Admin_Post_Types { return false; } - $old_price = empty( $product->{"get_{$price_type}_price"}() ) ? 0 : $product->{"get_{$price_type}_price"}(); + $old_price = (float) $product->{"get_{$price_type}_price"}(); $price_changed = false; $change_price = absint( $request_data[ "change_{$price_type}_price" ] ); From 7ca042d270fa3515e57ac2a26fe2629f1c6b6c80 Mon Sep 17 00:00:00 2001 From: ratulhasan Date: Thu, 14 Apr 2022 02:47:16 +0600 Subject: [PATCH 8/8] Use a cast to float instead of ternary. --- .../woocommerce/includes/admin/class-wc-admin-post-types.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php b/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php index 4749aaa6023..2a5ca1281f0 100644 --- a/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php +++ b/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php @@ -928,7 +928,7 @@ class WC_Admin_Post_Types { return false; } - $old_price = empty( $product->{"get_{$price_type}_price"}() ) ? 0 : $product->{"get_{$price_type}_price"}(); + $old_price = (float) $product->{"get_{$price_type}_price"}(); $price_changed = false; $change_price = absint( $request_data[ "change_{$price_type}_price" ] );