Search code examples
phpmysqlwordpresswoocommerceshipping-method

Where are stored the settings of each shipping method in WooCommerce?


I have two separate e-commerce platforms.

  1. A large, old system that drives all the orders and dispatch.
  2. An online store powered by WordPress / WooCommerce.

So far, we've managed to automate a lot of simple things like pulling orders from WP, and pushing updated stock levels to it.

One thing I cannot fathom, however, is when I create free_shipping method and set a minimum spend. Where is that stored in the DB?


Solution

  • You can ask to yourself: Where do Wordpress plugins store their settings?

    The answer is simply the wp_options table.

    If your "Free shipping" Shipping method ID is free_shipping:10 you can use:

    $free_shipping = get_option( 'woocommerce_free_shipping_10_settings' ); 
    $min_amount    = $free_shipping['min_amount'];
    

    To retrieve the array of data, where woocommerce_free_shipping_10_settings is the option_name.

    The following SQL search query will retrieve all your "Free shipping" methods settings:

    SELECT * FROM `wp_options` WHERE `option_name` LIKE 'woocommerce_free_shipping%'