Skip to content

Instantly share code, notes, and snippets.

View varun-pluginhive's full-sized avatar

varun-pluginhive

View GitHub Profile
@varun-pluginhive
varun-pluginhive / functions.php
Created November 7, 2018 09:33
Snippet to hide specified shipping methods with zero cost. PluginHive Plugins : https://www.pluginhive.com/plugins/
/**
* Snippet to hide specified shipping methods with zero cost.
* Created at : 07 Nov 2018
* Updated at : 07 Nov 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/varun-pluginhive/a7b88d265b5ecb89d823ffe9d06daf7c
*/
add_filter( 'woocommerce_package_rates', function( $shipping_rates ){
$shipping_methods = array( 'wf_woocommerce_shipping_pro:1shipping-pro-1'); // Array of Shipping method ids
@varun-pluginhive
varun-pluginhive / functions.php
Created November 2, 2018 14:38
Snippet to get Shipping method of third party plugin (Flexible Shipping) from Order. Estimated Delivery Date Plugin For WooCommerce - https://www.pluginhive.com/product/estimated-delivery-date-plugin-woocommerce/
/**
* Snippet to get Shipping method of third party plugin (Flexible Shipping) from Order.
* Created at : 02 Nov 2018
* Updated at : 02 Nov 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/varun-pluginhive/eb754c8b478c901d8cc45b7d226dc93f
*/
add_filter( 'ph_estimated_delivery_selected_shipping_method_on_order', 'ph_retreive_shipping_method_id', 10, 2 );
if( ! function_exists('ph_retreive_shipping_method_id') ) {
@varun-pluginhive
varun-pluginhive / functions.php
Last active November 2, 2018 10:45
Snippet to add number of days to the estimated delivery, if it falls on specified day in date range case. Estimated Delivery Date Plugin For WooCommerce - https://www.pluginhive.com/product/estimated-delivery-date-plugin-woocommerce/
/**
* Snippet to add number of days to the estimated delivery if it falls on specified day.
* Created at : 02 Nov 2018
* Updated at : 02 Nov 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/varun-pluginhive/19a921ce09be7b017d7b5819c2896cdf
*/
add_filter( 'xa_estimated_delivery_cart_checkout_page_html_formatted_date', 'xa_modify_cart_page_text', 10, 2 );
function xa_modify_cart_page_text( $text, $test ) {
@varun-pluginhive
varun-pluginhive / functions.php
Last active June 28, 2023 09:40
Mark Person as Booking For given product Id. WooCommerce Bookings And Appointments - https://www.pluginhive.com/product/woocommerce-booking-and-appointments/
/**
* Mark Person as Booking For given product Id.
* Created at : 24th Oct 2018
* Updated at : 24th Oct 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
*/
if( ! function_exists('ph_bookings_get_assets_availability') ) {
function ph_bookings_get_assets_availability( $asset_availability, $asset_id, $booking_count, $max_quantity, $from, $to ) {
@varun-pluginhive
varun-pluginhive / functions.php
Created October 17, 2018 12:26
Snippet to hide all other shipping methods when specific shipping method is available. PluginHive Plugins : https://www.pluginhive.com/plugins/
/**
* Snippet to hide all other shipping methods when specific shipping method is available.
* Created at : 17 Oct 2018
* Updated at : 17 Oct 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/varun-pluginhive/fc7ebbf35377eefae41112893cf5455b
*/
add_filter( 'woocommerce_package_rates', function( $shipping_costs ){
$if_available = array( 'free_shipping' ); // If available then hide the below shipping methods
@varun-pluginhive
varun-pluginhive / functions.php
Created October 11, 2018 05:48
Snippet to replace character and convert charset while creating label. WOOCOMMERCE UPS SHIPPING PLUGIN WITH PRINT LABEL - https://www.pluginhive.com/product/woocommerce-ups-shipping-plugin-with-print-label/
/**
* Snippet to replace character and convert charset while creating label.
* Created at : 11 Oct 2018
* Updated at : 11 Oct 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link :
*/
add_filter('wf_ups_shipment_confirm_request', function( $request ) {
$request = str_replace( array('ę', 'Ę', 'ó', 'Ó', 'ą', 'Ą', 'ś', 'Ś', 'ł', 'Ł', 'ż', 'Ż', 'ź', 'Ź', 'ć', 'Ć', 'ń', 'Ń','ś', 'Ś'), array('e', 'E', 'o', 'O', 'a', 'A', 's', 'S', 'l', 'L', 'z', 'Z', 'z', 'Z', 'c', 'C', 'n', 'N','s', 'S'), $request);
@varun-pluginhive
varun-pluginhive / functions.php
Created October 5, 2018 09:46
Snippet to convert WooCommerce Shipping Currency dynamically. PluginHive Plugins : https://www.pluginhive.com/plugins/
/**
* Snippet to convert Woocommerce Shipping Currency .
* Created at : 05 Oct 2018
* Updated at : 05 Oct 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/varun-pluginhive/8e2082c2d1ee9a08ecf48e649b6efd1e
*/
add_filter('woocommerce_package_rates','xa_convert_canada_post_shipping_cost' );
if( ! function_exists('xa_convert_canada_post_shipping_cost') ) {
@varun-pluginhive
varun-pluginhive / functions.php
Last active October 5, 2018 06:09
Snippet to display the Simple Date in Cart, Checkout and Thank you page and Date Range in Product Page. ESTIMATED DELIVERY DATE PLUGIN FOR WOOCOMMERCE - https://www.pluginhive.com/product/estimated-delivery-date-plugin-woocommerce/
/**
* Snippet to display the Simple Date in Cart, Checkout and Thankyou page and Date Range in Product Page.
* Created at : 05 Oct 2018
* Updated at : 05 Oct 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/varun-pluginhive/f8b76ab1d1b1e07b6a7fe26d993f1e4c
*/
// Cart and Checkout Page
add_filter( 'xa_estimated_delivery_cart_checkout_page_html_formatted_date', function($html_date){
@varun-pluginhive
varun-pluginhive / functions.php
Created October 4, 2018 10:41
Snippet to sort the WooCommerce Shipping Rates in ascending order. PluginHive Plugins : https://www.pluginhive.com/plugins/
/**
* Snippet to sort the WooCommerce Shipping Rates in ascending order.
* Created at : 04 Oct 2018
* Updated at : 04 Oct 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/varun-pluginhive/683bb169341200d59c4d3058d5ca06eb
*/
add_filter( 'woocommerce_package_rates', function( $rates ){
if( empty($rates) ) return $rates;
@varun-pluginhive
varun-pluginhive / functions.php
Last active September 28, 2018 08:00
Snippet to hide Flat rate if cart amount is more than specified amount else hide Free Shipping. If the product comes with other products add the flat rate to ups and hide other rates. PluginHive Plugins - https://www.pluginhive.com/plugins/
/**
* Snippet to hide Flat rate if cart amount is more than specified amount else hide Free Shipping. If the product comes with other products add the flat rate to ups and hide other rates.
* Created at : 20 Sep 2018
* Updated at : 28 Sep 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/varun-pluginhive/2cea63276a98c1869328c1743993e4ee
*/
if( ! empty('ph_skip_shipping_method_based_on_shipping_class') ) {
function ph_skip_shipping_method_based_on_shipping_class( $shipping_costs, $package ) {