Skip to content

Instantly share code, notes, and snippets.

View mcwe's full-sized avatar

MCWE mcwe

  • Morris Cerullo World Evangelism
View GitHub Profile
@rynaldos-zz
rynaldos-zz / wc-show-free.php
Last active September 6, 2017 18:00
[WooCommerce 3.0+] Re-instate "Free" instead of 0 value
function my_wc_custom_get_price_html( $price, $product ) {
if ( $product->get_price() == 0 ) {
if ( $product->is_on_sale() && $product->get_regular_price() ) {
$regular_price = wc_get_price_to_display( $product, array( 'qty' => 1, 'price' => $product->get_regular_price() ) );
$price = wc_format_price_range( $regular_price, __( 'Free!', 'woocommerce' ) );
} else {
$price = '<span class="amount">' . __( 'Free!', 'woocommerce' ) . '</span>';
}
}
add_filter( 'wc_anti_fraud_rules', 'wc_remove_antifraud_rules');
/**
* Remove unwanted anti-fraud rules
*
* @return array
*/
function wc_remove_antifraud_rules( $rules ) {
foreach ( $rules as $key => $rule ) {