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( 'woocommerce_cart_shipping_packages', 'wf_split_cart_by_shipping_class_group' ); | |
function wf_split_cart_by_shipping_class_group($packages){ | |
//Reset packages | |
$packages = array(); | |
//Init splitted package | |
$splitted_packages = array(); | |
// Group of shipping class ids | |
$class_groups = array( |
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
define("PV_ATTRIBUTE", "vendor"); | |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly | |
/** | |
* Check if WooCommerce is active | |
*/ | |
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { | |
if ( ! class_exists( 'TH_Shipping_Options' ) ) { | |
class TH_Shipping_Options { | |
/** |
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
// For Cart Page. | |
add_filter( 'woocommerce_no_shipping_available_html', 'wf_customize_default_message', 10, 1 ); | |
// For Checkout page | |
add_filter( 'woocommerce_cart_no_shipping_available_html', 'wf_customize_default_message', 10, 1 ); | |
function wf_customize_default_message( $default_msg ) { | |
$zip_array = array( | |
'30031', | |
); | |
if ( in_array( WC()->customer->get_shipping_postcode() , $zip_array) ) { |
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 | |
/* | |
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 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 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 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', 'adjustment_in_rates_of_product_with_shipping_class', 10, 2 ); | |
function adjustment_in_rates_of_product_with_shipping_class( $available_shipping_methods, $package ) { | |
// Shipping class IDs that need to add extra cost | |
$shipping_class_ids = array( | |
0, | |
1, | |
); | |
// Give here extra cost you want add |
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( 'woocommerce_cart_no_shipping_available_html', 'change_msg_no_available_shipping_methods', 10, 1 ); | |
add_filter( 'woocommerce_no_shipping_available_html', 'change_msg_no_available_shipping_methods', 10, 1 ); | |
function change_msg_no_available_shipping_methods( $default_msg ) { | |
$custom_msg = "Call us for quotation - 1-800-XXX-XXXX"; | |
if( empty( $custom_msg ) ) { | |
return $default_msg; | |
} | |
return $custom_msg; | |
} |
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
function wf_remove_puerto_rico_country( $country ) { | |
if(array_key_exists('PR', $country)) | |
{ | |
unset($country['PR']); | |
} | |
return $country; | |
} | |
add_filter( 'woocommerce_countries', 'wf_remove_puerto_rico_country', 10, 1 ); | |
function wf_add_puerto_to_us_states( $states ) { |
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('woocommerce_package_rates', 'wf_hide_shipping_methods_based_on_zipcode', 10, 2); | |
function wf_hide_shipping_methods_based_on_zipcode($available_shipping_methods, $package){ | |
$destination = $package['destination']; | |
$postcode = $destination['postcode']; | |
// Array of zipcodes with shipping methods to hide | |
$hide_methods = array( | |
'90002' => array( | |
'free_shipping', |
NewerOlder