Skip to content

Instantly share code, notes, and snippets.

@yokada
yokada / gist:2f61d953cf4952e6cb8f8b1de69bf714
Created December 30, 2016 18:37
Add extra charges for cash on delivery.
class My_Wc_Cart
{
protected $logger;
public function __construct()
{
$this->logger = new WC_Logger();
add_action('woocommerce_cart_calculate_fees', [$this, 'check_fees'], 10, 1);
}
@mikejolley
mikejolley / gist:11171530
Last active May 16, 2019 06:42 — forked from woogist/gist:6065863
Hide all/some shipping options when free shipping is available
/**
* woocommerce_package_rates is a 2.1+ hook
*/
add_filter( 'woocommerce_package_rates', 'hide_shipping_when_free_is_available', 10, 2 );
/**
* Hide shipping rates when free shipping is available
*
* @param array $rates Array of rates found for the package
* @param array $package The package array/object being shipped