Created
August 25, 2015 12:56
-
-
Save mikejolley/3539aae177438a0097d4 to your computer and use it in GitHub Desktop.
woocommerce_flat_rate_shipping_add_rate example for theme functions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'woocommerce_flat_rate_shipping_add_rate', 'add_another_custom_flat_rate', 10, 2 ); | |
function add_another_custom_flat_rate( $method, $rate ) { | |
$new_rate = $rate; | |
$new_rate['id'] .= ':' . 'next_day'; // Append a custom ID | |
$new_rate['label'] = 'Next Day'; // Rename to 'Rushed Shipping' | |
$new_rate['cost'] += 2; // Add $2 to the cost | |
// Add it to WC | |
$method->add_rate( $new_rate ); | |
} |
Do you need to write separate functions for every custom flat rate?
Do you need to write separate functions for every custom flat rate?
ever got it figured out?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So I have to hire a programmer to update my site? I don't understand how this code should be used for overnight and 2 day air. It was easy before, but now I feel annoyed because I can't select this through a menu.