-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix QIT errors reported by PHPStan #8845
Changes from all commits
faefc81
e7aaf6c
541f663
a31fcc4
53a8480
f0c8120
21917c5
f96fc04
88c928c
0686b33
c96082c
d26ae4b
ceff2ed
a628eda
bbae881
9a12f98
1bd87b0
e0f96bf
5a62032
760e0e5
888b7de
6eee3a6
cec51f7
a606708
50b6290
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: dev | ||
|
||
Fix PHPStan warnings. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,8 +125,10 @@ public function get_item_data( $addon_data, $addon, $cart_item ): array { | |
// Quantity/multiplier add on needs to be split, calculated, then multiplied by input value. | ||
$price = $this->multi_currency->get_price( $addon['price'] / $addon['value'], 'product' ) * $addon['value']; | ||
} | ||
$price = \WC_Product_Addons_Helper::get_product_addon_price_for_display( $price, $cart_item['data'] ); | ||
$name .= ' (' . wc_price( $price ) . ')'; | ||
if ( class_exists( '\WC_Product_Addons_Helper' ) ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check makes sense since we were assuming the Product Addons plugin would always have the helper class when it may not. |
||
$price = \WC_Product_Addons_Helper::get_product_addon_price_for_display( $price, $cart_item['data'] ); | ||
$name .= ' (' . wc_price( $price ) . ')'; | ||
} | ||
} else { | ||
// Get the percentage cost in the currency in use, and set the meta data on the product that the value was converted. | ||
$_product = wc_get_product( $cart_item['product_id'] ); | ||
|
@@ -245,12 +247,14 @@ public function order_line_item_meta( array $meta_data, array $addon, \WC_Order_ | |
// Convert all others. | ||
$addon_price = $this->multi_currency->get_price( $addon['price'], 'product' ); | ||
} | ||
$price = html_entity_decode( | ||
wp_strip_all_tags( wc_price( \WC_Product_Addons_Helper::get_product_addon_price_for_display( $addon_price, $values['data'] ) ) ), | ||
ENT_QUOTES, | ||
get_bloginfo( 'charset' ) | ||
); | ||
$addon['name'] .= ' (' . $price . ')'; | ||
if ( class_exists( '\WC_Product_Addons_Helper' ) ) { | ||
$price = html_entity_decode( | ||
wp_strip_all_tags( wc_price( \WC_Product_Addons_Helper::get_product_addon_price_for_display( $addon_price, $values['data'] ) ) ), | ||
ENT_QUOTES, | ||
get_bloginfo( 'charset' ) | ||
); | ||
$addon['name'] .= ' (' . $price . ')'; | ||
} | ||
} | ||
|
||
if ( 'custom_price' === $addon['field_type'] ) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,7 @@ public function get_args() { | |
* @psalm-suppress UndefinedMethod | ||
*/ | ||
public function get_cart_token() { | ||
// @phpstan-ignore-next-line. | ||
return parent::get_cart_token(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems fine to ignore 👍. LGTM. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @ricardo ✅ |
||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check makes sense since we were assuming the Name Your Price plugin would always have the helper class when it may not.