This file contains hidden or 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( 'wf_dhl_conversion_rate', 'alter_conversion_rate',10,2); | |
function alter_conversion_rate($rate, $dhl_currency){ | |
if( !function_exists('get_woocommerce_currency')){ | |
return; | |
} | |
$from_currency = urlencode($dhl_currency); | |
$to_currency = urlencode(get_woocommerce_currency()); | |
try { |
This file contains hidden or 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( 'wf_woocommerce_shipping_pro_shipping_costs', 'wf_hide_base_cost_for_non_westcost'); | |
function wf_hide_base_cost_for_non_westcost( $costs ) { | |
$shipping_state = WC()->customer->shipping_state; | |
$states_requires_price_adjustment = array('CA'); | |
$shippingclass_requires_price_adjustment = array('shipping-class-a'); | |
if(!empty($shipping_state) && in_array($shipping_state,$states_requires_price_adjustment)){ | |
foreach ($costs as $method_group => $method_cost) { | |
if(isset($method_cost['shipping_name']) && isset($method_cost['cost'])){ |
This file contains hidden or 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('wf_stamps_request','filter_stamps_request',10,2); | |
function filter_stamps_request($request, $order){ | |
if(isset($request['To'])){ | |
if(isset($request['To']['ZIPCode'])){ | |
// ignore values after '-' | |
$request['To']['ZIPCode'] = current(explode('-',$request['To']['ZIPCode'])); | |
} | |
} |
This file contains hidden or 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('wf_rate_for_package','ignore_invalid_box_rates',10,2); | |
function ignore_invalid_box_rates($response, $package_request){ | |
// stamps package types and sizes | |
$stamps_box_sizes = array( | |
// Domestic | |
'US-FC' => array( | |
// Name of the service shown to the user | |
'name' => 'First-Class Mail®', | |
'package_types' => array( | |
'Package' => array( |
This file contains hidden or 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( 'wf_rate_for_service', 'wf_force_rate_on_weight', 10, 2 ); | |
function wf_force_rate_on_weight($rates, $packages){ | |
$weight_less_than[] = array('weight'=>1, 'service_code'=>'US-EMI', 'package_type'=>'USPS flat rate envelope'); //Enter proper values or remove this line | |
$weight_greater_than[] = array('weight'=>1, 'service_code'=>'US-EMI', 'package_type'=>'Package'); //Enter proper values or remove this line | |
$weight_equal_to[] = array('weight'=>1, 'service_code'=>'US-EMI', 'package_type'=>'USPS flat rate envelope'); //Enter proper values or remove this line | |
$weight_less_than[] = array('weight'=>1, 'service_code'=>'US-XM', 'package_type'=>'USPS Legal Flat Rate Envelope'); //Enter proper values or remove this line | |
$weight_greater_than[] = array('weight'=>1, 'service_code'=>'US-XM', 'package_type'=>'Package'); //Enter proper values or remove this line | |
$weight_equal_to[] = array('weight'=>1, 'service_code'=>'US-XM', 'package_type'=>'USPS Legal Flat Rate Envelope'); //Enter proper values or remove th |
This file contains hidden or 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('woocommerce_package_rates', 'wf_hide_shipping_method_based_on_shipping_class', 10, 2); | |
function wf_hide_shipping_method_based_on_shipping_class($available_shipping_methods, $package) | |
{ | |
$hide_when_shipping_class_exist = array( | |
42 => array( | |
'free_shipping' | |
) | |
); | |
This file contains hidden or 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 | |
/* | |
Plugin Name: My Custom Shipping | |
Description: Plugin to calculate My Custom Shipping Cost | |
Version: 1.0.0 | |
Author: WooForce | |
Author URI: http://www.wooforce.com | |
*/ | |
function my_custom_shipping_init() { |
This file contains hidden or 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( 'woocommerce_package_rates', 'wf_rate_adjustment_if_cart_total_exceed', 10, 2 ); | |
function wf_rate_adjustment_if_cart_total_exceed( $available_shipping_methods, $package ) { | |
$minimum_cart_price_to_adjust = 30; //give value here | |
$shipping_services_with_price = array( | |
'wf_shipping_ups:01' => 0, //give shipping service with adjustment price in percent. | |
'wf_shipping_ups:02' => 0 | |
); | |
$cart_total = WC()->cart->cart_contents_total; | |
This file contains hidden or 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('woocommerce_package_rates', 'hide_shipping_method_when_shipping_class_product_is_not_in_cart', 10, 2); | |
function hide_shipping_method_when_shipping_class_product_is_not_in_cart($available_shipping_methods, $package) | |
{ | |
// Shipping class IDs that need the method removed | |
$shipping_class_ids = array( | |
27, | |
); |
This file contains hidden or 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('woocommerce_package_rates', 'wf_remove_shipping_options_for_particular_zip_codes', 10, 2); | |
function wf_remove_shipping_options_for_particular_zip_codes($rates, $package) | |
{ | |
global $woocommerce; | |
$zip_array = array( | |
'30031' | |
); | |
if ( in_array( $woocommerce->customer->get_shipping_postcode() , $zip_array) ) { | |
unset($rates['wf_fedex_woocommerce_shipping:FEDEX_GROUND']); |