Shipping Costs / Shipping Fees - Filter Hook References

Modified on Mon, 19 Sep 2022 at 07:59 AM

This is simply a list of shipping costs/fees related filter hooks found within the WooCommerce Table Rate Shipping files. This list also includes the supported parameters and example codes.


wtars_shipped_admin/get-cost-type-groups

  • Parameters:
  • $group_types array()
  • $args array()


Example Codes:

function custom_get_cost_type_groups( $group_types, $args ) {

    //add your custom code here
    return $group_types;
}

add_filter( 'wtars_shipped_admin/get-cost-type-groups', 'custom_get_cost_type_groups', 10, 2 );

wtars_shipped_admin/get-cost-group-types-{group_type_id}

  • Parameters:
  • $cost_types array()
  • $args array()


Example Codes:

function custom_get_cost_types( $cost_types, $args ) {

    //add your custom code here
    return $cost_types;
}

add_filter( 'wtars_shipped_admin/get-cost-group-types-custom_group_id', 'custom_get_cost_types', 10, 2 );

wtars_shipped_admin/get-cost-type-{cost_type_id}-fields

  • Parameters:
  • $in_fields array()
  • $args array()


Example Codes:

function custom_get_cost_type_fields( $in_fields, $args ) {

    //add your custom code here
    return $in_fields;
}

add_filter( 'wtars_shipped_admin/get-cost-type-custom_cost_type_id-fields', 'custom_get_cost_type_fields', 10, 2 );

wtars_shipped_admin/get-cost-type-fields

  • Parameters:
  • $in_fields array()
  • $args array()


Example Codes:

function custom_get_cost_type_fields( $in_fields, $args ) {

    //add your custom code here
    return $in_fields;
}

add_filter( 'wtars_shipped_admin/get-cost-type-fields', 'custom_get_cost_type_fields', 10, 2 );

wtars_shipped_admin/get-cost-add-methods

  • Parameters:
  • $add_methods array()
  • $args array()


Example Codes:

function custom_get_cost_add_methods( $add_methods, $args ) {

    //add your custom code here
    return $add_methods;
}

add_filter( 'wtars_shipped_admin/get-cost-add-methods', 'custom_get_cost_add_methods', 10, 2 );

wtars_shipped_admin/get-cost-box-fields

  • Parameters:
  • $in_fields array()
  • $args array()


Example Codes:

function custom_get_cost_box_fields( $in_fields, $args ) {

    //add your custom code here
    return $in_fields;
}

add_filter( 'wtars_shipped_admin/get-cost-box-fields', 'custom_get_cost_box_fields', 10, 2 );

wtars_shipped_admin/process-cost-options

  • Parameters:
  • $cost_option array()
  • $raw_cost array()
  • $args array()


Example Codes:

function custom_process_cost_options( $cost_option, $raw_cost, $args ) {

    //add your custom code here
    return $cost_option;
}

add_filter( 'wtars_shipped_admin/process-cost-options', 'custom_process_cost_options', 10, 3 );

wtars_shipped_admin/process-cost-type-{cost_type_id}-options

  • Parameters:
  • $cost_option array()
  • $raw_cost array()
  • $args array()


Example Codes:

function custom_process_cost_options( $cost_option, $raw_cost, $args ) {

    //add your custom code here
    return $cost_option;
}

add_filter( 'wtars_shipped_admin/process-cost-type-cost_type_id-options', 'custom_process_cost_options', 10, 3 );

wtars_shipped_admin/get-based-on-required-ids

  • Parameters:
  • $cost_type_ids array()
  • $args array()


Example Codes:

function custom_get_based_on_required_ids( $cost_type_ids, $args ) {

    //add your custom code here
    return $cost_type_ids;
}

add_filter( 'wtars_shipped_admin/get-based-on-required-ids', 'custom_get_based_on_required_ids', 10, 2 );

wtars_shipped_admin/get-item-based-on-required-ids

  • Parameters:
  • $cost_type_ids array()
  • $args array()


Example Codes:

function custom_get_item_based_on_required_ids( $cost_type_ids, $args ) {

    //add your custom code here
    return $cost_type_ids;
}

add_filter( 'wtars_shipped_admin/get-item-based-on-required-ids', 'custom_get_item_based_on_required_ids', 10, 2 );

wtars_shipped_admin/get-round-required-ids

  • Parameters:
  • $cost_type_ids array()
  • $args array()


Example Codes:

function custom_get_round_required_ids( $cost_type_ids, $args ) {

    //add your custom code here
    return $cost_type_ids;
}

add_filter( 'wtars_shipped_admin/get-round-required-ids', 'custom_get_round_required_ids', 10, 2 );

wtars_shipped_admin/{module}/get-products-required-ids

  • Parameters:
  • $cost_type_ids array()
  • $args array()


Example Codes:

function custom_get_products_required_ids( $cost_type_ids, $args ) {

    //add your custom code here
    return $cost_type_ids;
}

add_filter( 'wtars_shipped_admin/shipping-rates/get-products-required-ids', 'custom_get_products_required_ids', 10, 2 );

wtars_shipped_admin/get-products-required-ids

  • Parameters:
  • $cost_type_ids array()
  • $args array()


Example Codes:

function custom_get_products_required_ids( $cost_type_ids, $args ) {

    //add your custom code here
    return $cost_type_ids;
}

add_filter( 'wtars_shipped_admin/get-products-required-ids', 'custom_get_products_required_ids', 10, 2 );

wtars_shipped_admin/get-package-grouping-types

  • Parameter:
  • $package_grouping_types array()
  • $args array()


Example Codes:

function custom_get_package_grouping_types( $package_grouping_types, $args ) {

    //add your custom code here
    return $package_grouping_types;
}

add_filter( 'wtars_shipped_admin/get-package-grouping-types', 'custom_get_package_grouping_types', 10, 2 );

wtars_shipped/calculate-{cost_type_id}-cost

  • Parameters:
  • $cost array()
  • $cost_args array()
  • $data array()


Example Codes:

function custom_calculate_cost_type_id_cost( $cost, $cost_args, $data ) {

    //add your custom code here
    return WC_Shipped_Cost_Types::prepare_cost( $cost, 10, $cost_args );
}

add_filter( 'wtars_shipped/calculate-cost_type_id-cost', 'custom_calculate_cost_type_id_cost', 10, 3 );


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article