Skip to content

Instantly share code, notes, and snippets.

@renjith-ph
renjith-ph / functions.php
Created December 4, 2018 10:23
Snippet to change product price to custom declared value for international shipping.
/**
* Snippet to change product price to custom declared value for international shipping.
* Created at : 21 Nov 2018
* Updated on : 29 Nov 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
*/
add_filter( 'wf_ups_shipment_confirm_request_product_details', 'wf_ups_shipment_confirm_request_product_details', 10, 2 );
if( ! function_exists('wf_ups_shipment_confirm_request_product_details') ) {
@renjith-ph
renjith-ph / functions.php
Created December 4, 2018 10:28
Snippet to change product price to custom declared value and change unit of measurement for international shipping.PluginHive Plugins : https://www.pluginhive.com/plugins/
/**
* Snippet to change product price to custom declared value and change unit of measurement for international shipping.
* Created at : 26 Nov 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
*/
add_filter( 'wf_ups_shipment_confirm_request_product_details', 'wf_ups_shipment_confirm_request_product_details', 10, 2 );
if( ! function_exists('wf_ups_shipment_confirm_request_product_details') ) {
function wf_ups_shipment_confirm_request_product_details( $product_details, $product_data ) {
if(!empty($product_data))
@renjith-ph
renjith-ph / functions.php
Created December 4, 2018 10:28
Snippet to change fedex shipping date if it is saturday or sunday. PluginHive Plugins : https://www.pluginhive.com/plugins/
**
* Snippet to change fedex shipping date if it is saturday or sunday.
* Created at : 21 Nov 2018
* Updated on : 22 Nov 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
*/
add_filter( 'wf_fedex_request', 'wf_fedex_request', 10, 3 );
if( ! function_exists('wf_fedex_request') ) {
function wf_fedex_request( $request, $order, $parcel ) {
if(date('l',strtotime($request['RequestedShipment']['ShipTimestamp']))=='Saturday')
@renjith-ph
renjith-ph / functions.php
Last active January 4, 2019 12:37
Snippet to adjust Date Range Estimated delivery based on shipping method.PluginHive Plugins : https://www.pluginhive.com/plugins/
/**
* Snippet to adjust Date Range Estimated delivery based on shipping method.
* Created at : 28 Nov 2018
* Updated on : 04 Jan 2019
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/xadapter/983ecf750115b2c0471f55a35a57f8ef
*/
// Adjustment on Cart and Checkout page.
add_filter( 'xa_estimated_delivery_cart_checkout_page_html_formatted_date', 'xa_modify_cart_page_text', 10, 2 );
@renjith-ph
renjith-ph / functions.php
Last active January 14, 2019 07:15
Snippet to change cutoff time based on shipping method.PluginHive Plugins : https://www.pluginhive.com/plugins/
/**
* Snippet to change cutoff time based on shipping method.
* Created at : 28 Nov 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
*/
add_filter( 'ph_estimated_delivery_get_cutoff_time', 'ph_estimated_delivery_get_custom_cutoff_time', 10, 2 );
if( ! function_exists('ph_estimated_delivery_get_custom_cutoff_time') ) {
function ph_estimated_delivery_get_custom_cutoff_time( $cutoff, $cur_day ) {
$adjustment = array(
'table_rate:2:1'=>array( 'mon'=>"18:00", 'tue'=>"18:00", 'wed'=>"18:00", 'thu'=>"18:00", 'fri'=>"18:00", 'sat'=>"18:00", 'sun'=>"18:00" )
@renjith-ph
renjith-ph / functions.php
Last active January 21, 2019 05:52
Snippet to change estimate delivery if product is in back order.
/**
* Snippet to change estimate delivery if product is in back order.
* Created at : 08 Dec 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/renjith-ph/7ea21e6c60af0bab989ed2a57e98477e
*/
add_filter( 'woocommerce_get_availability', 'woocommerce_get_availability',12,2 );
function woocommerce_get_availability( $stock_arr ,$item) {
/**
* Snippet to adjust rates based on package dimension.
* Created at : 14 Dec 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
*/
add_filter('wf_ups_rate', 'wf_modify_ups_rate', 10, 2);
function wf_modify_ups_rate($xml, $packages){
if(empty($packages))
{
@renjith-ph
renjith-ph / functions.php
Last active December 19, 2018 11:51
Split cart packages based on product category. PluginHive Plugins : https://www.pluginhive.com/plugins/
/**
* Split cart packages based on product category.
* Created at : 17 Dec 2018
* Updated at : 19 Dec 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
*/
add_filter( 'woocommerce_cart_shipping_packages', 'wf_split_cart_by_shipping_class_group' );
function wf_split_cart_by_shipping_class_group($package){
@renjith-ph
renjith-ph / functions.php
Created December 18, 2018 14:55
Show hide accesspoint location based on chosen shipping methods.
/**
* Show hide accesspoint location based on chosen shipping methods.
* Created at : 18 Dec 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
*/
add_action( 'wp_footer', 'conditionally_hidding_billing_custom_field' );
function conditionally_hidding_billing_custom_field(){
// Only on checkout page
@renjith-ph
renjith-ph / functions.php
Last active December 28, 2018 08:17
Snippet to support Addon_Plugin_dividing_single_product.
/**
* Snippet to support Addon_Plugin_dividing_single_product.
* Created at : 24 Dec 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
*/
add_filter( 'wf_fedex_commodities', 'wf_fedex_request_update_commodity', 10, 3);
function wf_fedex_request_update_commodity($commodities,$request,$fedex_packages)
{
$final_product=array();
if(!empty($commodities))