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_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 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_canadapost_request','wf_canadapost_label_request_callback', 10, 2 ); | |
function wf_canadapost_label_request_callback($request,$order){ | |
$custom_product_description = 'My product description'; // This text might not exceed 35 characters | |
$xml = new SimpleXMLElement($request); | |
if($xml->{'delivery-spec'}->{'destination'}->{'address-details'}->{'country-code'} != 'CA'){ //if international | |
$ref_no = $xml->{'delivery-spec'}->{'references'}->{'customer-ref-1'}; | |
$custom_text = $ref_no.", ".$custom_product_description; | |
$xml->{'delivery-spec'}->{'references'}->{'customer-ref-1'} = substr($custom_text,0,35); |
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_fedex_request','wf_fedex_label_request_callback', 10, 2 ); | |
function wf_fedex_label_request_callback($request,$order){ | |
$custom_product_description = 'My Product Description'; | |
$commodities = !empty( $request['RequestedShipment']['CustomsClearanceDetail']['Commodities'] ) ? $request['RequestedShipment']['CustomsClearanceDetail']['Commodities']: array() ; | |
foreach ($commodities as $product_id => $value) { | |
$request['RequestedShipment']['CustomsClearanceDetail']['Commodities'][$product_id]['Description'] = $custom_product_description; | |
} | |
return $request; | |
} |
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_fedex_request','wf_fedex_label_request_callback', 10, 2 ); | |
function wf_fedex_label_request_callback($request,$order){ | |
$custom_product_description = 'My Product Description'; | |
$request['CustomerReferences'][] = array('CustomerReferenceType' => 'CUSTOMER_REFERENCE', 'Value' => $custom_product_description ); | |
$RequestedPackageLineItems = !empty( $request['RequestedShipment']['RequestedPackageLineItems'] ) ? $request['RequestedShipment']['RequestedPackageLineItems'] : array() ; | |
$flag = 0; |
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
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 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_adjust_shipping_rate', 10, 2 ); | |
function wf_adjust_shipping_rate( $available_shipping_methods, $packages ){ | |
// Total quantity is total unit | |
$unit = 0; | |
$apply_final_filter = TRUE; | |
foreach ( $packages['contents'] as $item ) { | |
$unit+=$item['quantity']; | |
} | |
// if unit less than 3 , show D_FIRST_CLASS only |
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
// Exclude the services First-Class Mail Postcards, First-Class Mail Large Envelope and First-Class Mail Stamped Letter | |
add_filter('usps_disable_first_class_rate_first-class-mail-postcards', 'disable_first_class_rate_for_this_service',10,3); | |
add_filter('usps_disable_first_class_rate_first-class-mail-large-envelope', 'disable_first_class_rate_for_this_service',10,3); | |
add_filter('usps_disable_first_class_rate_first-class-mail-stamped-letter', 'disable_first_class_rate_for_this_service',10,3); | |
function disable_first_class_rate_for_this_service() { | |
return true; | |
} | |
// Include First-Class Mail Parcel ( Default Behaviour) | |
add_filter('usps_disable_first_class_rate_first-class-mail-parcel', 'disable_first_class_rate_for_parcel_service',10,3); |
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_fedex_request','my_call_back', 10, 2 ); | |
function my_call_back($request,$order){ | |
$request['RequestedShipment']['Recipient']['Contact']['PhoneNumber']='123-123-1234'; | |
return $request; | |
} |
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_auspost_method_when_shipping_class_product_is_in_cart', 10, 2); | |
function hide_auspost_method_when_shipping_class_product_is_in_cart($available_shipping_methods, $package) | |
{ | |
$shipping_class_ids = array( | |
16 | |
); | |
$shipping_services_to_hide = array( | |
'wf_australia_post:AUS_PARCEL_REGULAR', | |
'wf_australia_post:AUS_PARCEL_EXPRESS', |
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_if_particular_product_available_in_cart', 10, 2); | |
function hide_shipping_method_if_particular_product_available_in_cart($available_shipping_methods) | |
{ | |
global $woocommerce; | |
// products_array should be filled with all the products ids | |
// for which shipping method (stamps) to be restricted. | |
$products_array = array( |