Here’s a sample SQL query that demonstrates this approach:
SELECT
MONTH(p.post_date) AS month,
pm.meta_value AS shipping_method,
COUNT(*) AS order_count
FROM
wp_posts p
JOIN
wp_postmeta pm ON p.ID = pm.post_id
JOIN
wp_woocommerce_order_items oi ON p.ID = oi.order_id
WHERE
p.post_type="shop_order"
AND pm.meta_key = '_shipping_method'
AND p.post_date >= '2021-01-01'
AND p.post_date < '2022-01-01'
GROUP BY
month,
shipping_method
Replace wp_
with the appropriate table prefix used in your WooCommerce setup. Adjust the date range in the WHERE
clause (>= '2021-01-01'
and < '2022-01-01'
) to match your desired timeframe.
Related Posts:
- Get stock by custom meta field on all Woocommerce variable products
- Run a sql (update) after 12 hours after the user login. Woocommerce users
- Woocommerce – get daily sales meta
- Woocommerce get selected shipping zone id for the current user
- How to change “Shipping Calculator “field label on Cart Page – woocommerce? [closed]
- How to Join two tables from separate databases within WordPress
- Cleanest/Fastest way to avoid calling and retrieving data from the database multiple times?
- How to show order data by multiple ID?
- Problem with Woocommerce REST API Authentication
- Remove General Tab and Plugin Tab in Settings in Woocommerce
- WooCommerce – Display variation custom field value [closed]
- Woocommerce HTML email option unavailable
- How to add SVG icon above product tab title
- How does WooCommerce ensure that a product doesn’t run out of stock during payment? [closed]
- How to change / delete product short description in Woocommerce
- register_activation_hook isn’t adding table to DB
- How to trash multiple post/product programmatically
- How to generate page content from database the right way?
- OrderItem get_total() returns lower value than $order_item->get_product()->get_price() * quantity
- phpMyAdmin displays error when importing database
- Preferred Method of debugging a wordpress SQL calls?
- Setting up 2 SMTP accounts: 1 for wordpress and 1 for woocommerce
- WooCommerce – Reset quantity input field when variation changes
- Custom Text in WooCommerce Order Processing Email Based on Products
- Automatically remove a canceled order in Woocommerce
- Woocommerce hook run after an Order been created through REST API
- How can I apply_filters from inside a function?
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Different Minimum Order Amounts based on Shipping Zone [closed]
- Displaying Woocommerce Product Category in WordPress
- Displaying custom taxonomy on WooCommerce product page
- Change “add to cart” button color based on Woocommerce product category [closed]
- Add to cart function not working for first product when cart is empty [closed]
- Woocommerce : Can’t get product info in loop
- WordPress Woocommerce – Product Type [closed]
- Is there a way to hook or call a custom woocomerce template that is not part of the default templates of woocommerce?
- get taxonomy thumbnail and use it as a variable in code
- Single Quotes in .php file doesn’t load website
- get_total () returns 0 – woocommerce [closed]
- How to upload WP user avatar on woocommerce account page [closed]
- How to relocate paypal button gateway on checkout page in woocommerce
- Only show size attributes in product box woocommerce when available
- How do I run code every 24 hours?
- Woocommerce Product_cat for current category page
- Pull MySQL data from multiple tables and merge into 1 PHP array
- After disabling WPML multi currency, the currency is still handled by the WPML
- How do i wrap woocomerce attribute in list?
- Removing files programmatically
- WooCommerce “Checkout Now” button [closed]
- quotes problem in very simple sql
- How can i programmatically change the SKU of a product based on product variation?
- Execute PHP code only with specific user role
- Add a custom WooCommerce settings tab with sections
- Checking page before applying image restrictions while uploading
- Woocommerce. Get a list of products in the current category on the archive page and product page
- get_terms with specific id order
- How can I enter on the Thank you page in woocommerce the discount code I assigned to the product category?
- Woocommerce append shipping method form
- PHP function for horizontal Woocommerce thumbnails and badges
- How do I check if a product is in two categories?
- php code for outputting a custom page in my account
- Hide specific shipping methode depending on day and time of day
- Adding custom field to product category and show it to shop/category shop page
- How to hide a div section when user is logged in, in single product woocommerce
- WooCommerce display price before add to cart [closed]
- Get the same SKU from woocommerce itself for simple and variable products
- Remove span tags from WooCommerce Downloads page
- Global variable doesnt’t pass to another function
- Exclude category from woocommerce product category list
- Edit woocommerce_product_archive_description using hook
- How to empty price of simple and variable product when product changed into out off stock
- Make WooCommerce product categories only show images on homepage
- How to create loop inside wordpress function?
- How do I get data from my database into my Custom Export Field
- How to auto-generate random numbers in username?
- Remove generated category and tag class names from woocommerce product & blog listings markup
- WooCommerce Quantity in Dropdown menu instead of clasic [closed]
- How to echo a PHP code into WooCommerce variation product?
- Get Billing Email from WooCommece Checkout and Pass to Fullstory JS
- Woocommerce custom attributes list help
- Global filter not working
- Plugin Modification Change Functionality For Logged User Only
- WooCommerce remove_action and add_action [closed]
- WordPress using get_term to retreive slug not working as expected
- Conditional statement within WP SQL query
- How can I order metaboxes in my posts in WordPress?
- How to add margin underneath woocommerce total price amount -> productpages
- Order woo products, but first products must be with acf fields
- How to find the value of the user password in wordpress and send it to another server via rest api
- Change Checkout “Place Order” text if cart has a specific product
- WCFM Custom form
- Hide child of parent categories already hidden with “get_terms_args” – Woocommerce
- Why does WordPress not send the user the email to add a password?
- Removing the add to cart button from specific product pages
- WooCommerce Modal Fly cart on add to cart – With AJAX
- Add Woocommerce Customers link to custom admin menu
- PayPal button not showing and cannot retrieve order error in PayPal
- Add text below WooCommerce short description if metabox value is true
- Woocomerce custom add to cart button edit functionality [closed]
- Assembly Options at checkout