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: How can I get orders with a custom ID in order meta data object?
- wordpress + woocommerce display product with additional information [closed]
- how to fix error “called incorrectly, should not be accessed directly”?
- Function works when I don’t login to WordPress but when I login then it doesn’t work
- How to auto fetch customer details in Woocommerce in checkout page
- Displaying custom taxonomy on WooCommerce product page
- Sum the total amount of a specific product purchased per user and display in table
- Change “add to cart” button color based on Woocommerce product category [closed]
- How can I get the values of my WordPress $wpdb query in Jquery?
- How can I pass a custom/dynamic product to the Woocommerce cart?
- Add to cart function not working for first product when cart is empty [closed]
- I want to add custom add to cart link [closed]
- How to make products with no cost in WooCommerce
- Woocommerce : Can’t get product info in loop
- WooCommerce custom product dimensions
- Trouble checking if custom woocommerce checkout field is empty or not
- Incorrect amount of posts returned when filtering related Woo products by custom taxonomy
- Validation algorithm in checkout field
- Archive post by meta value + 24hours
- How do I remove the product thumbnail link from a specific div in Woocommerce? [closed]
- My new button is in the wrong place
- WordPress Woocommerce – Product Type [closed]
- Genesis framework comments broken?
- $wpdb->insert() does not Insert record in a table
- Databases – Submitting data from inputs to database [closed]
- Pagination for custom shop loop woocommerce
- How to add specific meta tags to head of cart and checkout pages in woocommerce?
- How to remove woocommerce_breadcrumb() from do_action( ‘woocommerce_before_main_content’ ); [closed]
- Woocommerce change prices for a certain country [closed]
- How to get private property in parent class into extended class?
- echo something inside a shortcode
- Replace Woocommerce “add to cart” to be “Download” button [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
- Woocommerce Email attachments not working – file not being attached
- Function returns text instead of html [closed]
- Is it best to avoid using $wpdb for security issues?
- Extend Woocommerce Widget Class – WC_Widget_Product_Categories
- Single Quotes in .php file doesn’t load website
- Add post with approval by the admin
- get_total () returns 0 – woocommerce [closed]
- How to remove coupon dropdown feature
- Woocommerce display one random product via php
- dynamic page using php from sql database
- Change product_base programmatically
- Add html link in functions.php files of the theme
- require_once() if a product in woocommerce contains a tag [closed]
- How to optimize update_post_meta?
- How to upload WP user avatar on woocommerce account page [closed]
- Use $wpdb or other PHP script method to find/replace in WP database
- Add product to cart for user – WC()->cart->add_to_cart [closed]
- Remove item in Checkout
- email alert for product availability
- How to Update post_modified of all wordpress post
- Correct PHP to output a single result of a Function with SQL Query
- How to relocate paypal button gateway on checkout page in woocommerce
- How can I add a new row in a separate database when someone registers via WordPress?
- How to rename woocommerce-billing-fields
- Can a plugin redirect product page based on IF condition?
- Seo Friendly Filter URLs
- How to display SQL query that ran in WC_Order_Query?
- WooCommerce pages looks unstyled
- customize woocommerce templates and display store on home
- Woocommerce Backend Search by Title and SKU
- How to disable delivery on certain date at checkout page in WooCommerce?
- WC_Customer delete function returns error
- Only show size attributes in product box woocommerce when available
- How do I change this function from two returns to one string to show sku and dimensions in WooCommerce cart?
- Remove page title in product page using a function
- woocommerce specific quantities for product
- how can i add class or span tag at sprintf?
- Call WC_Product get_price()?
- How to display a custom product field value of a specific category on a Woo Commerce checkout page?
- Personalize checkout text
- Display attribute on shop page after the title
- CSS change in woo commerce Place Order Text [closed]
- Woocommerce – get_items() returns empty array
- How do I run code every 24 hours?
- Disable if there are no children – Woocommerce
- WooCommerce – Moving Product Price to the Left of Add to Cart Button [closed]
- Woocommerce Product_cat for current category page
- Exclude product attributes from taxonomy terms loop
- WP All Import / Update stock quantity from multiple XML files
- PHP -> SQL Query with Summing
- woocommerce related product title length
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- woocommerce wc_create_order(); is creating multiple orders instead of one?
- Lost in trying to create user database system
- Create a package of products as one Item in woocommerce?
- Pull MySQL data from multiple tables and merge into 1 PHP array
- Woocommerce: remove total sum from new order’s email [closed]
- Include js script ONLY on woocommerce product category pages? [closed]
- WP_Query multiple post results
- Convert Featured products loop into Recent products loop?
- fetch woocommerce product with custom taxonomy
- WordPress WP_Query without query GET parameters
- Filter results from a serialized string to use on statistics