Title: variable type casting causes error
Last modified: January 17, 2023

---

# variable type casting causes error

 *  Resolved [whatspauldoing](https://wordpress.org/support/users/whatspauldoing/)
 * (@whatspauldoing)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/variable-type-casting-causes-error/)
 * Good morning! My client (who runs a airBnB style photographic locations company)
   contacted me today with an problem that was causing payments to not be accepted.
   We have a fairly complex system involving woocommerce and jet engine (don’t ask,
   it was an inherited project and has been a nightmare) so I’ve created several
   bridging functions that are called via woo hooks.
 * The problem this morning was with the action hook woocommerce_thankyou, the function
   I’ve written updates the jet booking with the woo order ID, so that once the 
   host of the property accepts the booking stripe are notified to capture the charge.
 * After some digging around in the logs I found the error in (Woocommerce Payments)
   class-wc-payments-order-success-page.php with the following 2 functions:
 *     ```wp-block-code
       	/**
       	 * Add the notice to the thank you page in case a recent order with the same content has already paid.
       	 *
       	 * @param string $text  the default thank you text.
       	 *
       	 * @return string
       	 */
       	public function add_notice_previous_paid_order( string $text ) {
       		if ( isset( $_GET[ WC_Payment_Gateway_WCPay::FLAG_PREVIOUS_ORDER_PAID ] ) ) { // phpcs:disable WordPress.Security.NonceVerification.Recommended
       			$text .= sprintf(
       				'<div class="woocommerce-info">%s</div>',
       				esc_attr__( 'We detected and prevented an attempt to pay for a duplicate order. If this was a mistake and you wish to try again, please create a new order.', 'woocommerce-payments' )
       			);
       		}
   
       		return $text;
       	}
   
       	/**
       	 * Add the notice to the thank you page in case an existing intention was successful for the order.
       	 *
       	 * @param string $text  the default thank you text.
       	 *
       	 * @return string
       	 */
       	public function add_notice_previous_successful_intent( string $text ) {
       		if ( isset( $_GET[ WC_Payment_Gateway_WCPay::FLAG_PREVIOUS_SUCCESSFUL_INTENT ] ) ) { // phpcs:disable WordPress.Security.NonceVerification.Recommended
       			$text .= sprintf(
       				'<div class="woocommerce-info">%s</div>',
       				esc_attr__( 'We prevented multiple payments for the same order. If this was a mistake and you wish to try again, please create a new order.', 'woocommerce-payments' )
       			);
       		}
   
       		return $text;
       	}
       ```
   
 * My system doesn’t appear to have any direction contact with these functions, 
   but the logs showed the system was failing because the variable $text was coming
   through as null rather than as a string.
 * I’ve removed the casting “string” from the functions inputs and the system works
   again, so I will be taking off auto-updates for now but I wanted to let you know
   in case this was in error, or if there’s some string I need to send somewhere?
 * Cheers,
 * Paul

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [xue28 (woo-hc)](https://wordpress.org/support/users/xue28/)
 * (@xue28)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/variable-type-casting-causes-error/#post-16387709)
 * Hi [@whatspauldoing](https://wordpress.org/support/users/whatspauldoing/)
 * Thanks for reaching out!
 * This is a fairly complex development topic. These forums are meant for general
   support with the core functionality of WooCommerce itself. What you want to achieve
   is a bit complex and would require customization to do it. Since custom coding
   is outside our scope of support, I am leaving this thread open for a bit to see
   if anyone can chime in to help you out.
 * For questions related to development and custom coding, your best bet is to ask
   on any of these channels for support. We’re lucky to have a great community of
   open-source developers for WooCommerce, and many of our developers hang out there,
   too.
    - [WooCommerce Developer Resources Portal](https://developer.woocommerce.com/)
    - [WooCommerce Advanced Facebook group](https://www.facebook.com/groups/advanced.woocommerce/)
    - [WooCommerce Community Forum](https://wordpress.org/support/plugin/woocommerce/)
    - [WooCommerce Developer Slack Channel](https://woocommerce.com/community-slack/)
    - Hire a [WooCommerce Expert](https://woocommerce.com/experts/)
 * Hope this helps!
 *  Thread Starter [whatspauldoing](https://wordpress.org/support/users/whatspauldoing/)
 * (@whatspauldoing)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/variable-type-casting-causes-error/#post-16429673)
 * Thanks for your reply. I’m actually just pointing out a problem with the code.
   And I’m not sure how to get it to a developer over at woo.
 * Is this something you could flag with a developer?
 * Cheers,
 * Paul
 *  [Roxy](https://wordpress.org/support/users/roxannestoltz/)
 * (@roxannestoltz)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/variable-type-casting-causes-error/#post-16435936)
 * Hi [@whatspauldoing](https://wordpress.org/support/users/whatspauldoing/) ,
 * Thanks for clarifying!
 * I’d suggest submitting a GitHub issue about this, as it would be viewed by the
   developers of the plugin.
 * Feel free to submit one, [here](https://github.com/woocommerce/woocommerce/issues/new/choose).
 * I will go ahead and mark this thread as resolved then, however, feel free to 
   create a new ticket should you need any further help!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘variable type casting causes error’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [Roxy](https://wordpress.org/support/users/roxannestoltz/)
 * Last activity: [3 years, 4 months ago](https://wordpress.org/support/topic/variable-type-casting-causes-error/#post-16435936)
 * Status: resolved