Skip to content

Instantly share code, notes, and snippets.

@xadapter
xadapter / functions.php
Last active September 19, 2019 12:32
Snippet to show WooCommerce Estimated Delivery after Email text you have received an order(default) in New Order Email sent to admin. All Text Format( simple, simple_range and date_range ) supported. Estimated Delivery Date Plugin for WooCommerce - https://www.pluginhive.com/product/estimated-delivery-date-plugin-woocommerce/
/**
* Snippet to show woocommerce estimated delivery after email text you have received an order (default) in New Order Email sent to admin. All Text Format( simple, simple_range and date_range ) supported
* Created at : 19 July 2018
* Updated at : 19 July 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/xadapter/dc915ec735c5aba2d8d191d7563e563d/
*/
add_action( 'woocommerce_email_order_details', 'ph_add_estimated_delivery_after_heading', 1, 4 );
@xadapter
xadapter / functions.php
Last active September 20, 2019 09:48
Snippet to adjust Date Range Estimated delivery based on shipping class on Product, Cart, Checkout and Thank you page. Estimated Delivery Date Plugin for WooCommerce by PluginHive - https://www.pluginhive.com/product/estimated-delivery-date-plugin-woocommerce/
/**
* Snippet to adjust woocommerce estimated delivery based on shipping class on Product, Cart, Checkout and Thank you Page.
* Created at : 18 July 2018
* Updated at : 18 July 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/xadapter/6c428a24a9f2eb7355a1ed1d04e8c5f7
*/
// Cart and Checkout Page
/**
* Snippet to hide woocommerce shipping methods based on days, based on cutoff time. Drawback - If Calculated before Cutoff time and placed order after cutoff then it won't work.
* Created at : 16 July 2018
* Updated at : 02 Aug 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/xadapter/d8caee4845bb41c0d3da1a9b2a3ba897
*/
add_filter( 'woocommerce_package_rates', function( $shipping_rates) {
// To hide shipping methods based on days
@xadapter
xadapter / functions.php
Last active September 20, 2019 13:58
Snippet to remove recipient's email address in WooCommerce UPS shipment request. WooCommerce UPS Shipping Plugin with Print Label - https://www.pluginhive.com/product/woocommerce-ups-shipping-plugin-with-print-label/
/**
* Snippet to remove recipient's email address in Woocommerce UPS shipment request.
* Created at : 16 July 2018
* Updated at : 16 July 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/xadapter/d572fe8d690605118c76d8f1ee23df94
*/
add_filter( 'wf_ups_shipment_confirm_request_data', function($request_arr){
unset($request_arr['Shipment']['ShipTo']['EMailAddress']);
return $request_arr;
@xadapter
xadapter / functions.php
Last active September 20, 2019 13:58
Snippet to display estimated delivery in different format (simple and date range, settings should be in date range ) on product page based on shipping class. Estimated Delivery Date Plugin for WooCommerce - https://www.pluginhive.com/product/estimated-delivery-date-plugin-woocommerce/
/**
* Snippet to display estimated delivery in different format (simple and date range, settings should be in date range ) on product page based on shipping class.
* Created at : 13 July 2018
* Updated at : 13 July 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/xadapter/a3aebdd786e553056b49617cfea0cc8b
*/
add_filter( 'woocommerce_get_availability', 'ph_change_estimated_delivery_style_based_on_shipping_class', 11, 2 );
if( ! function_exists('ph_change_estimated_delivery_style_based_on_shipping_class') ) {
@xadapter
xadapter / functions.php
Last active September 16, 2020 16:56
Snippet to add extra cost per package to the WooCommerce UPS rate. WooCommerce UPS Shipping Plugin with Print Label - https://www.pluginhive.com/product/woocommerce-ups-shipping-plugin-with-print-label/
/**
* 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
@xadapter
xadapter / functions.php
Last active September 20, 2019 14:08
Snippet to allow automatic label generation based on order status. WooCommerce UPS Shipping Plugin with Print Label - https://www.pluginhive.com/product/woocommerce-ups-shipping-plugin-with-print-label/ AddOns for Automatic Label Generation https://elextensions.com/product-category/add-ons/
/**
* Snippet to allow automatic label generation based on order status.
* Created at : 10 July 2018
* Updated at : 10 July 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/xadapter/b19d10709f51d38092cb604364c7cde5
*/
add_filter( 'xa_automatic_label_generation_allowed_order_status', 'xa_allow_automatic_label_generation_based_on_order_status', 10, 3 );
@xadapter
xadapter / functions.php
Last active September 20, 2019 14:10
Snippet to add handling charge in percent to WooCommerce Shipping Cost based on WooCommerce Shipping method and WooCommerce Shipping Zone. PluginHive Plugins supported - https://www.pluginhive.com/product/multiple-carrier-shipping-plugin-woocommerce/, https://www.pluginhive.com/product/woocommerce-ups-shipping-plugin-with-print-label/, https://w…
/**
* Snippet to add handling charge in percent to to shiiping cost based on shipping method and shipping zone. Use * to define for all the remaining zone.
* Created at : 09 July 2018
* Updated at : 18 July 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/xadapter/b52eae8ba6d8f8d60513f31bb4cbc630
*/
add_filter( 'woocommerce_package_rates',function( $shipping_rates ){
@xadapter
xadapter / custom_code.php
Last active September 20, 2019 14:11
Template to attach shipment tracking number in WooCommerce Email Customizer with Drag and Drop Email Builder. WooCommerce Shipment Tracking Pro - https://www.pluginhive.com/product/woocommerce-shipment-tracking-pro/
<?php
/**
* Custom code shortcode
*
* This template can be overridden by copying it to yourtheme/woocommerce_email_cuztomizer_with_drag_and_drop_builder/woo_mail/custom_code.php.
* @var $order WooCommerce order
* @var $email_id WooCommerce email id (new_order, cancelled_order)
* @var $sent_to_admin WooCommerce email send to admin
* @var $plain_text WooCommerce email format
* @var $email WooCommerce email object
@xadapter
xadapter / functions.php
Last active September 20, 2019 14:12
Snippet to Hide WooCommerce Shipping method. Useful in case of Local Pickup plus. In case of Local pickup plus add a flat rate or free shipping in every zone, and hide it using below snippet. UPS or Fedex rate will get displayed. PluginHive Plugins - https://www.pluginhive.com/product/woocommerce-ups-shipping-plugin-with-print-label/, https://ww…
/**
* Snippet to hide shipping method. Useful in case of Local Pickup plus. In case of Local pickup plus add a flat rate or free shipping in every zone, and hide it using below snippet. UPS or Fedex rate will get displayed.
* Created at : 04 July 2018
* Updated at : 04 July 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/xadapter/2db2a904b2ba5b0fcf533345c86d67f3
*/
add_filter( 'woocommerce_package_rates',function( $shipping_rates ){
$shipping_methods_to_unset = array( 'flat_rate:6' ); // Shipping method id