Category: WordPress

  • Freshened up this site…

    In response to the recent PHP vulnerability issue, I spent some time here in this blog site to upgrade my WordPress theme, plugins, WordPress installation itself, and finally, the PHP version.

    One minor issue was encountered after upgrading plugins — Head, Footer and Page Injection plugin began showing parts of some code that I inserted, as plain text in my blog site!! I noticed that the plugin had a notice stating that “php is not allowed in your code (disabled by your theme or a plugin)”. The fix that worked was to head over to the plugin’s settings page (Settings -> Head and Footer) and then go to the ‘Advanced’ tab, and then toggle on the setting labeled as “Enable PHP execution”.

    The PHP version I was using was quite outdated T_T and so upgrading to version 8.0 broke my blog site with the error “there has been a critical error on this website.” Fortunately, the thing that I deactivated first was the exact cause of error: my old, outdated theme! It was “Sparkling” theme, which I hadn’t touched for years. I changed into the Twenty Twenty-Five theme for a fresh look and updated WP code. Thank you, Colorlib for the Sparkling theme — it served me well for several years!

    I feel good after taking the time to update this site. I’ve had this for over a decade now.

  • Get “order” object/details from Thank You page of WooCommerce (WordPress)

    It’s been a long while since I last posted anything related to coding. I haven’t really stopped, but from Android app development, I switched back to PHP. Life has become occupied with other things, but when I do code, it’s in WordPress with WooCommerce. It’s for my online shop.

    In my opinion, WordPress is not the most pleasant platform to use if you’re a developer (after years of MVC coding for Android I find WordPress quite messy), but it’s what I already know. I don’t have time to learn another.

    Today’s code snippet is for customizing the Thank You page (post-checkout) by retrieving the “order” object.

    The $order_id is what we’ll start with. Then we get the order object with the help of the wc_get_order($order_id) method. Once you’re able to successfully call the order object, you may use its methods such as get_billing_first_name() to get the order details.

    You may refer to the WC_Order class page for a list of available methods.

    I originally got this code from Order Received (Thank you) page in WooCommerce and modified it to suit my needs. Check his blog out, as he has many helpful posts on how to customize WooCommerce!