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
/** | |
* Check the cart for specific products, remove Free Shipping if they are present | |
* | |
* Free Shipping method must be enabled | |
* | |
* Add the code to your theme functions.php file | |
*/ | |
add_filter( 'woocommerce_available_shipping_methods', 'free_shipping_when_product_in_cart' , 10, 1 ); | |
function free_shipping_when_product_in_cart( $available_methods ) { |
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
/** | |
* Deactivate USPS Shipping if products with specific shipping | |
* classes are in the cart | |
* | |
* Add the shipping class slugs to the $shippingclass_array array | |
*/ | |
add_filter( 'woocommerce_shipping_usps_is_available', 'unset_woocommerce_shipping_methods_usps', 10 ,2 ); | |
function unset_woocommerce_shipping_methods_usps ( $return, $package ) { | |
// Setup an array of shipping classes that do not allow USPS Shipping |
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
/** | |
* Check the cart for specific products, remove specific USPS Shipping methods if they are present | |
* | |
* Add the code to your theme functions.php file | |
*/ | |
add_filter( 'woocommerce_package_rates', 'unset_usps_shipping_methods' , 10, 2 ); | |
function unset_usps_shipping_methods( $rates, $package ) { | |
/** | |
* Setup an array or products |
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
/** | |
* Set the store base city and postcode / zipcode | |
*/ | |
add_filter( 'woocommerce_countries_base_city' , 'set_woocommerce_countries_base_city' ); | |
function set_woocommerce_countries_base_city() { | |
// Replace with your store town/city | |
return 'Townland'; | |
} | |
add_filter( 'woocommerce_countries_base_postcode' , 'set_woocommerce_countries_base_postcode' ); |
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
/** | |
* Round Shipping in the event of PayPal errors | |
*/ | |
add_filter( 'woocommerce_package_rates', 'fix_shipping_rounding_errors' , 10, 2 ); | |
/** | |
* | |
*/ | |
function fix_shipping_rounding_errors( $rates, $package ) { | |
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
/** | |
* Remove USPS Flat rate envelopes from the available options | |
* Once added the customer will not see any rates for envelopes | |
*/ | |
add_filter( 'usps_flat_rate_boxes', 'custom_usps_flat_rate_boxes' ); | |
function custom_usps_flat_rate_boxes( $flat_rate_boxes ) { | |
unset($flat_rate_boxes["d29"]); | |
unset($flat_rate_boxes["d30"]); | |
unset($flat_rate_boxes["d63"]); |
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
/** | |
* USPS 4.0 introduced the ability for envelopes to be flexible you can disable this with this function | |
* Simply set the type to 'envelope' instead of 'package' for any of the flat rate services that USPS lists as envelopes | |
*/ | |
add_filter( 'usps_flat_rate_boxes', 'custom_usps_flat_rate_boxes' ); | |
function custom_usps_flat_rate_boxes( $flat_rate_boxes ) { | |
// Priority Mail Express Envelopes | |
$flat_rate_boxes["d13"]["type"] = 'envelope'; |
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
/** | |
* Set maximum shipping cost depending on delivery country in WooCommerce | |
*/ | |
add_filter( 'woocommerce_package_rates' , 'woocommerce_set_maximum_shipping_cost', 10, 2 ); | |
function woocommerce_set_maximum_shipping_cost( $rates, $package ) { | |
/** | |
* Create an array of countries for a maximum shipping cost | |
* eg array('US','CA'); | |
* for US and Canada. |
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
/** | |
* Set maximum shipping cost for specific Table Rate shipping methods | |
*/ | |
add_filter( 'woocommerce_package_rates' , 'woocommerce_set_maximum_shipping_cost', 10, 2 ); | |
function woocommerce_set_maximum_shipping_cost( $rates, $package ) { | |
foreach( $rates as $rate ) { | |
/** | |
* Change 10 to your maximum shipping cost and the label to match your Method Title | |
* shown here https://dl.dropboxusercontent.com/s/5q9hfei3hgnbnt9/2014-10-13%20at%2001.25%20%281%29.png?dl=0 |
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
add_filter('usps_disable_first_class_rate_first-class-mail-parcel', '__return_true'); | |
add_filter('usps_disable_first_class_rate_first-class-mail-large-envelope', '__return_true'); | |
add_filter('usps_disable_first_class_rate_first-class-mail-stamped-letter', '__return_true'); | |
add_filter('usps_disable_first_class_rate_first-class-mail-postcards', '__return_true'); |
OlderNewer