PHP error when processing a subscription using PayPal Standard, PHP 8, and taxes included in the price.
Uncaught TypeError: Unsupported operand types: string + string in /data/www/gamekings.tv/public_html/wp-content/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-request.php:290
This issue is reproducible under:
PHP 8
Having WooCommerce's built-in PayPal Standard enabled (instructions below)
Having taxes and shipping enabled
To Reproduce
Setting things up
Set up a site using PHP 8
Enable PayPal Standard in WooCommerce by adding the following to your theme's function.php add_filter( 'woocommerce_should_load_paypal_standard', '__return_true' );
Go to WooCommerce -> Payments -> PayPal Standard
Enter the details of your Business sandbox account (Find the creds of a sandbox account in the SS under the ID 10622, that should do the trick. Or create a developer account. Or ping me)
Go to WooCommerce -> Settings -> General -> Enable taxes, and check off "Enable tax rates and calculations"
Go to WooCommerce -> Settings -> Tax -> Tax options -> Prices entered with tax, select "Yes, I will enter prices inclusive of tax"
Go to WooCommerce -> Settings -> Tax -> Standard rates, and add a rate for the US
Go to WooCommerce -> Settings -> Shipping, and add a Zone for the US with a price
Create a subscription product
Triggering the error
As a shopper, add the subscription product to the cart
Go to the checkout
Select PayPal as the payment method
Use a PayPal Personal sandbox account (Find the creds of a sandbox account in the SS under the ID 7042)
Complete the checkout
Notice the error in the logs
Renewing a subscription purchased under these settings should also trigger the error.
Expected behavior
No error must be triggered when purchasing a subscription with PayPal Standard.
Actual behavior
A PHP error is triggered when purchasing a subscription with PayPal Standard.
Product impact
[ ] Does this issue affect WooCommerce Subscriptions? yes/no/tbc, add issue ref
[ ] Does this issue affect WooCommerce Payments? yes/no/tbc, add issue ref
Additional context
Reported in 6430307-zd-woothemes
Conversation in Slack p1687286369795599-slack-C7U3Y3VMY
Describe the bug
PHP error when processing a subscription using PayPal Standard, PHP 8, and taxes included in the price.
This issue is reproducible under:
To Reproduce
Setting things up
add_filter( 'woocommerce_should_load_paypal_standard', '__return_true' );
Triggering the error
Renewing a subscription purchased under these settings should also trigger the error.
Expected behavior
No error must be triggered when purchasing a subscription with PayPal Standard.
Actual behavior
A PHP error is triggered when purchasing a subscription with PayPal Standard.
Product impact
Additional context