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
/** | |
* Snippet to hide shipping methods based on Order Subtotal cost. | |
* Created at : 07 May 2018 | |
* Updated at : 07 May 2018 | |
* PluginHive Plugins : https://www.pluginhive.com/product-category/woocommerce-plugin/ | |
* Gist Link : https://gist.github.com/xadapter/a477c0ec1334e69426674b21f4b033c9 | |
*/ | |
add_filter( 'woocommerce_package_rates', 'xa_show_hide_shipping_based_on_order_subtotal', 10, 2 ); |
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_if_weght_exceeds', 10, 1 ); | |
// For Checkout page | |
add_filter( 'woocommerce_cart_no_shipping_available_html', 'wf_customize_default_message_if_weght_exceeds', 10, 1 ); | |
function wf_customize_default_message_if_weght_exceeds( $default_msg ) { | |
$weight_limit = 50; | |
$custom_msg = "Call us for quotation - 1-800-XXX-XXXX"; | |
global $woocommerce; | |
$cart_weight = $woocommerce->cart->get_cart_contents_weight(); |
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
//Change the color of text "pick Please a booking period" here. | |
.callender-msg{ | |
color:white; | |
} | |
//Change the color of the calendar here. | |
.ph-calendar-month{ | |
background:red; | |
} |
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
/** | |
* Snippet to set default weight and Dimension if it's not set for any product. | |
* Created at : 14 May 2018 | |
* Updated at : 16 May 2018 | |
* PluginHive Plugins : https://www.pluginhive.com/product-category/woocommerce-plugin/ | |
* Gist Link : https://gist.github.com/xadapter/4fb8dbfc6c025630558e43488775eb7d | |
*/ | |
// To set Default Length | |
add_filter( 'woocommerce_product_get_length', 'xa_product_default_length' ); |
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_fedex_packages', 'wf_fedex_weight_round_off'); | |
if( ! function_exists('wf_fedex_weight_round_off') ) { | |
function wf_fedex_weight_round_off($packages) { | |
foreach( $packages as $key => $package) { | |
$package['Weight']['Value'] = $package['Weight']['Value'] + 0.05; //For rounding up to higher | |
$weight = round( $package['Weight']['Value'], 1 ); | |
$packages[$key]['Weight']['Value'] = !empty($weight) ? $weight : 0.1; | |
} | |
return $packages; |
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_default_shipping_method( $method ) { | |
$the_cheapest_cost = 1000000; | |
$packages = WC()->shipping()->get_packages()[0]['rates']; | |
foreach ( array_keys( $packages ) as $key ) { | |
if ( ( $packages[$key]->cost > 0 ) && ( $packages[$key]->cost < $the_cheapest_cost ) ) { | |
$the_cheapest_cost = $packages[$key]->cost; | |
$method_id = $packages[$key]->id; | |
} | |
} |
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
/** | |
* Title : Snippet to add Fixed amount of weight to the order. | |
* Created at : 25 June 2018 | |
* Updated at : 25 June 2018 | |
* PlugiHive Plugins : https://www.pluginhive.com/product-category/woocommerce-plugin/ | |
* Gist Link : https://gist.github.com/xadapter/f330a6f529dfa9199a30ec2fa9fca3ef | |
*/ | |
add_filter( 'wf_customize_package_on_cart_and_checkout', function( $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
/** | |
* Snippet to add extra cost per package to the Woocommerce UPS rate. | |
* Created at : 12 July 2018 | |
* Updated at : 12 July 2018 | |
* PluginHive Plugins : https://www.pluginhive.com/plugins/ | |
* Gist Link : https://gist.github.com/xadapter/5a6404c130dbc61883bda20c392933a4 | |
*/ | |
add_filter( 'wf_ups_rate', function( $response ) { | |
$cost_to_add_per_package = 10; // Add fixed cost to shipping rate per 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
// To test this code, open a private/incognito window, add an item to the cart and then go to cart page. | |
// Once an option is choosen, it will be the default option from that moment onwards. | |
// Code to clear default shipping option. | |
add_filter( 'woocommerce_shipping_chosen_method', '__return_false', 99); | |
// Code to clear default payment option. | |
add_filter( 'pre_option_woocommerce_default_gateway' . '__return_false', 99 ); |
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_fedex_estimated_delivery', 'wf_add_delivery_time', 15, 20 ); | |
function wf_add_delivery_time( $est_delivery_html, $est_delivery ) { | |
$days_to_add = 1; | |
if( isset($est_delivery['fedex_delivery_time']) ){ | |
$new_date = strtotime( "+$days_to_add day", strtotime($est_delivery['fedex_delivery_time']) ); | |
$new_date = date( apply_filters('wf_estimate_delivery_date_format', 'd-m-Y' ), $new_date ); | |
$est_delivery_html = "<br /><small>".__('Est delivery: ', 'wf-shipping-fedex'). $new_date.'</small>'; | |
} | |
return $est_delivery_html; |
NewerOlder