How to get the fixed cost from flat rate programmatically?

Top WooCommerce & WordPress Plugins Forums Cost of Goods for WooCommerce How to get the fixed cost from flat rate programmatically?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #89672
    Park
    Guest

    Hi, is it possible to get extra cost using the get_post_meta() ?

    For instance, I want to get the Extra Shipping Method Costs > Flat Rate > Fixed Cost

    #89673
    Zohaib
    Participant

    Hi,

    Yes, it is possible. In the Orders tab in the plugin’s settings you will find Extra Costs: From Meta option. You can add the Meta keys in that section.

    #89674
    Park
    Guest

    Sorry, what I mean is reading the value set in “Extra Shipping Method Costs > Flat Rate > Fixed Cost” in functions?

    For example I want to do some calculation, so I could get the value like:
    $shipping_cost = get_post_meta( $order_id, ‘_alg_wc_cog_shipping_fixed’, true );

    #89675
    Zohaib
    Participant

    Hi Park,

    You can get a flat rate value using the below function:

    get_option( 'alg_wc_cog_shipping_costs_fixed', array() );
    #91082
    Pablo
    Moderator
    Plugin Support

    This would be a way of getting the flat rate cost from the general “Shipping method” section:

    $fixed_costs = get_option( 'alg_wc_cog_shipping_costs_fixed' );
    $flat_rate   = isset( $fixed_costs['flat_rate'] ) ? $fixed_costs['flat_rate'] : '';
    

    To get all the shipping costs from a specific order, this would be the code:

    $shipping_cost = get_post_meta( $order_id, '_alg_wc_cog_order_shipping_cost', true );
    
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.