This file contains 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
function no_coupon_checkout_function() { | |
if ( !is_user_logged_in() ) { | |
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 ); | |
} | |
} | |
add_action('init', 'no_coupon_checkout_function'); |
This file contains 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_countries', 'rs_edit_pk_country' ); | |
function rs_edit_pk_country ( $countries ) { | |
$new_countries = array( | |
'PK' => __( 'Pakistan', 'woocommerce' ), | |
); | |
return array_merge( $countries, $new_countries ); | |
} | |
add_filter( 'woocommerce_continents', 'rs_add_new_pk_country_to_continents' ); |
This file contains 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
function wc_max_qty_scripts() { | |
wp_add_inline_script( 'woocommerce', 'window.onload = function(){ | |
function onBlurHandler( event ) { | |
var max = this.getAttribute( "max" ); | |
if ( this.validity.rangeOverflow ) { | |
message = this.value + " is too much! Please contact us to order more than " + max + "."; | |
this.setCustomValidity( message ); |
This file contains 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_checkout_fields', 'custom_override_default_address_fields' ); | |
function custom_override_default_address_fields($fields){ | |
global $woocommerce; | |
$country = $woocommerce->customer->get_billing_country(); | |
if($country == 'IE'){ | |
$fields['billing']['billing_postcode']['required'] = true; | |
$fields['shipping']['shipping_postcode']['required'] = true; | |
} | |
return $fields; | |
} |
This file contains 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_maxmind_geolocation_database_path', 'woocommerce_new_maxmind_geolocation_database_path' ); | |
function woocommerce_new_maxmind_geolocation_database_path( $database_path ) { | |
$upload_dir = wp_upload_dir(); | |
$database_path = trailingslashit( $upload_dir['basedir'] ) . 'my-new-folder/dbfile.ext'; | |
return $database_path; | |
} | |
// Did this help? Donate me some BTC: 1BEsm8VMkYhSFJ92cvUYwxCtsfsB2rBfiG |
This file contains 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_cart_tax_totals', 'show_zero_rate_taxes' ); | |
function show_zero_rate_taxes( $tax_totals ) { | |
if ( empty( $tax_totals ) && WC()->customer->is_vat_exempt() ) { | |
$tax_totals['zero-rated'] = (object) array( | |
'label' => 'Zero Rated Tax', | |
'amount' => 0, | |
'formatted_amount' => wc_price( 0 ), | |
'name' => 'Zero Rated Tax', |
This file contains 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
function rs_woo_cart_attributes($cart_item, $cart_item_key) { | |
global $product; | |
if (is_cart()){ | |
echo "<style>#checkout_thumbnail{visibility:hidden;}</style>"; | |
} | |
$item_data = $cart_item_key['data']; | |
$post = get_post($item_data->get_id()); | |
$thumb = get_the_post_thumbnail($item_data->get_id(), array( 32, 50)); | |
echo '<div id="checkout_thumbnail" style="float: left; padding-right: 8px">' . $thumb . '</div> ' . $post->post_title; | |
} |
This file contains 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
function hide_free_when_pp_method_available( $rates ) { | |
$pp = array(); | |
foreach ( $rates as $rate_id => $rate ) { | |
if ( 'per_product' === $rate->method_id ) { | |
$pp[ $rate_id ] = $rate; | |
break; | |
} | |
} | |
return ! empty( $pp ) ? $pp: $rates; | |
} |
This file contains 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_eu_vat_number_country_codes', 'woo_custom_eu_vat_number_country_codes' ); | |
function woo_custom_eu_vat_number_country_codes( $vat_countries ) { | |
// only show field for users in BE | |
return array( 'BE' ); | |
} |
This file contains 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
// disable woocommerce sorting | |
add_filter( 'woocommerce_sort_countries', '__return_false' ); | |
add_filter( 'woocommerce_countries', 'wc_custom_countries_order', 10, 1 ); | |
function wc_custom_countries_order( $countries ) { | |
// replace with iso code of the country (example: US or GB) | |
unset($countries['country_1_iso_code']); | |
unset($countries['country_2_iso_code']); | |
unset($countries['country_3_iso_code']); | |
// replace with iso code of country AND country name (example: US | United States or GB | United Kingdom (UK) |
NewerOlder