Skip to content

Instantly share code, notes, and snippets.

@kozzmen
kozzmen / wc-hide-all-shipping-if-free-shipping-is-available.php
Created May 14, 2024 12:47 — forked from woogists/wc-hide-all-shipping-if-free-shipping-is-available.php
[General Snippets][Hide other shipping methods when “Free Shipping” is available] Hides all other shipping methods but free_shipping if it’s available. Compatible with Shipping zones.
/**
* Hide shipping rates when free shipping is available.
* Updated to support WooCommerce 2.6 Shipping Zones.
*
* @param array $rates Array of rates found for the package.
* @return array
*/
function my_hide_shipping_when_free_is_available( $rates ) {
$free = array();
foreach ( $rates as $rate_id => $rate ) {
@kozzmen
kozzmen / Embed Gists with a URL
Created October 2, 2015 09:58 — forked from bhwebworks/Embed Gists with a URL
Add to functions.php or a mu-plugin
/**
* Embed Gists with a URL
*
* Usage:
* Paste a gist link into a blog post or page and it will be embedded eg:
* https://gist.github.com/2926827
*
* If a gist has multiple files you can select one using a url in the following format:
* https://gist.github.com/2926827?file=embed-gist.php
*
@kozzmen
kozzmen / functions.php
Last active November 12, 2020 12:18
Add BGN support for PayPal
// allow BGN for WooCommerce and PayPal
add_filter( 'woocommerce_paypal_supported_currencies', 'add_bgn_paypal_valid_currency' );
function add_bgn_paypal_valid_currency( $currencies ) {
array_push ( $currencies , 'BGN' );
return $currencies;
}
// Convert BGN to EUR for PayPal payments
add_filter('woocommerce_paypal_args', 'convert_bgn_to_eur');