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 surcharge for every item where this dimensions equation exceeds 3m | |
* Code snippets should be added to the functions.php file of your child theme | |
* | |
* @return array | |
*/ | |
function add_surcharge_for_large_items( $rates, $package ) { | |
// information used in calculations that can be edited | |
$shipping_method = 'betrs_shipping; | |
$fee = 4.99; |
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 surcharge for every item where this dimensions equation exceeds 3m | |
* Code snippets should be added to the functions.php file of your child theme | |
* | |
* @return array | |
*/ | |
function add_surcharge_for_large_items( $rates, $package ) { | |
// information used in calculations that can be edited | |
$shipping_method = 'betrs_shipping; | |
$fee = 4.99; |
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', 'add_shipping_option_base_fee', 10, 2 ); | |
function add_shipping_option_base_fee( $rates, $package ) { | |
foreach( $rates as $key => $rate ) { | |
// reset defaults | |
$class_c_items = 0; | |
// Do not apply base fee if not the right option | |
if( $rate->id !== 'betrs_shipping:1-1' ) continue; |
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', 'add_shipping_option_base_fee', 10, 2 ); | |
function add_shipping_option_base_fee( $rates, $package ) { | |
foreach( $rates as $key => $rate ) { | |
// reset defaults | |
$highest_length = 0; | |
// Do not apply base fee if not the right option | |
if( $rate->id !== 'betrs_shipping:1-1' ) continue; |
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_based_on_subtotal', 10, 2 ); | |
function hide_shipping_based_on_subtotal( $rates, $package ) { | |
// Retrieve cart subtotal | |
$cart_subtotal = $package['contents_cost']; | |
// Shipping rate to be excluded | |
$shipping_id = 'betrs-shipping:3-1'; | |
if( $cart_subtotal >= 500 ) | |
unset( $rates[ $shipping_id ] ); |
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', 'add_shipping_option_base_fee', 10, 2 ); | |
function add_shipping_option_base_fee( $rates, $package ) { | |
foreach( $rates as $key => $rate ) { | |
// reset defaults | |
$highest_priority = $highest_class = 0; | |
// Do not apply base fee if not the right option | |
if( $rate->id !== 'betrs_shipping:1-1' ) continue; |
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
/** | |
* Hide the PayPal payment option when the customer selects a specific Table Rate option | |
* Code snippets should be added to the functions.php file of your child theme | |
* | |
* @return array | |
*/ | |
function alter_payment_gateways( $list ){ | |
// Retrieve chosen shipping options from all possible packages | |
$chosen_rates = ( isset( WC()->session ) ) ? WC()->session->get( 'chosen_shipping_methods' ) : array(); | |
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
<?php | |
/** | |
* Plugin Name: WooCommerce Remove Billing Fields for Free Virtual Products | |
* Plugin URI: https://gist.github.com/bolderelements/caf09b527e1d42b3992c5a118729f0d7 | |
* Description: Remove the billing address fields for free virtual orders, with the exception of email addresses | |
* Author: Erica Dion | |
* Author URI: http://bolderelements.net/ | |
* Version: 1.0 | |
* | |
* This program is free software: you can redistribute it and/or modify |
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
/** | |
* Hide all free shipping options when the given shipping class is in the cart | |
* Code snippets should be added to the functions.php file of your child theme | |
* | |
* @return array | |
*/ | |
function hide_shipping_when_class_is_in_cart( $rates, $package ) { | |
// shipping class IDs that need the method removed | |
$shipping_classes = array('bulky-items'); | |
$if_exists = false; |
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
/** | |
* Hide a free shipping option (instance #7) when the given shipping class is in the cart | |
* Code snippets should be added to the functions.php file of your child theme | |
* | |
* @return array | |
*/ | |
function hide_shipping_when_class_is_in_cart( $rates, $package ) { | |
// shipping class IDs that need the method removed | |
$shipping_classes = array('bulky-items'); | |
$if_exists = false; |