Delete a shipping method from a zone.
public delete_shipping_method ( integer $instance_id ) : True | ||
$instance_id | integer | |
return | True | on success, false on failure |
/** * shipping_zone_methods function. * * @access public * @return void */ function shipping_zone_methods($zone_id) { global $woocommerce, $wpdb; $zone = new WC_Shipping_Zone($zone_id); if (!$zone->exists()) { wp_redirect(remove_query_arg('zone')); exit; } if (!empty($_GET['add_method']) && !empty($_GET['method_type']) && !empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'woocommerce_add_method')) { $type = strtolower(trim($_GET['method_type'])); if ($method_id = $zone->add_shipping_method($type)) { wp_redirect(add_query_arg('method', $method_id, add_query_arg('zone', $zone_id, admin_url('admin.php?page=shipping_zones')))); exit; //echo '<div class="updated success"><p>' . __( 'Shipping method successfully added', 'wc_table_rate' ) . ' <a href="' . add_query_arg( 'method', $method_id, add_query_arg( 'zone', $zone_id, admin_url( 'admin.php?page=shipping_zones' ) ) ) . '" class="button" style="margin-left: 10px;">' . __( 'Configure method', 'wc_table_rate' ) . '</a></p></div>'; } } if (!empty($_GET['delete_method']) && !empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'woocommerce_delete_method')) { $method_id = absint($_GET['delete_method']); if ($zone->delete_shipping_method($method_id)) { echo '<div class="updated success"><p>' . __('Shipping method successfully deleted', 'wc_table_rate') . '</p></div>'; } } if (!empty($_GET['method']) && $_GET['method'] > 0) { $method_id = (int) $_GET['method']; $this->shipping_zone_method_settings($zone, $method_id); return; } ?> <div class="wrap woocommerce"> <div class="icon32 icon32-woocommerce-delivery" id="icon-woocommerce"><br /></div> <h2><a href="<?php echo admin_url('admin.php?page=shipping_zones'); ?> "><?php _e('Shipping Zones', 'wc_table_rate'); ?> </a> > <?php echo $zone->zone_name; ?> <a href="<?php echo wp_nonce_url(add_query_arg('method_type', 'table_rate', add_query_arg('add_method', 'true')), 'woocommerce_add_method'); ?> " class="add-new-h2"><?php _e('Add Shipping Method', 'wc_table_rate'); ?> </a></h2> <?php $this->list_shipping_zone_methods(); ?> </div> <?php $woocommerce->add_inline_js("\n\t\t\t// Delete\n\t\t\tjQuery('a.submitdelete').click( function(){\n\t\t\t\tvar answer = confirm('" . __('Are you sure you want to delete this method?', 'wc_table_rate') . "');\n\t\t\t\tif ( answer ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t});\n\t\t"); }