As an advanced WooCommerce developer, at some stage you’re really going to need this PHP function, the same way you often browse through Business Bloomer’s WooCommerce visual hook guides or the product / order / cart getters.
This time we go study how to “get” the shipping zones and rates, because it’s likely that you will need to loop through them when you need to display shipping rates somewhere, or for other custom functionalities. Enjoy!
Continue reading WooCommerce: Get All Shipping Zones & Rates
When you work with WooCommerce PHP snippets, you often need to “get” stuff off your WordPress database in order to make some calculations and return the result on the screen. And if there is something I often google is “How do I get all my store’s product IDs?“.
Thankfully the get_posts WordPress function gives us the answer. In the next weeks we’ll also see how we can get other information, such as all SKUs, all product categories, etc.
So, here’s the quick snippet to return all product IDs on the Cart page (“woocommerce_before_cart” hook) – you can change that if you want to use them somewhere else. Enjoy 🙂
Continue reading WooCommerce: Get Product IDs (All, by Tag, by Category)
When coding in PHP for WooCommerce, sometimes you’ll need to know what’s inside the “Order Array”, so that you can use its elements to print some custom message on the thank you page, or maybe modify its default behaviour.
There is a great PHP function that helps a lot – it’s called print_r() and you can use this to “see” what’s inside the order array 🙂 Continue reading WooCommerce: See What’s Inside the Order Array (print_r)