function date_format_php_to_js( $php_date_format ) { $formats_php_to_js = array( 'F j, Y' => 'MM dd, yy', 'Y/m/d' => 'yy/mm/dd', 'm/d/Y' => 'mm/dd/yy', 'd/m/Y' => 'dd/mm/yy', ); return isset( $formats_php_to_js[ $php_date_format ] ) ? $formats_php_to_js[ $php_date_format ] : 'MM dd, yy'; }
Hide all other shipping methods when free shipping is available in WooCommerce
add_filter( 'woocommerce_package_rates', 'hide_shipping_when_free_is_available', 10, 2 ); function hide_shipping_when_free_is_available( $rates, $package ) { // Only modify rates if free_shipping is present if ( isset( $rates['free_shipping'] ) ) { // To unset a single rate/method, do the following. This example unsets flat_rate shipping unset( $rates['flat_rate'] ); // To unset all methods except for free_shipping, do the following $free_shipping = $rates['free_shipping']; $rates = array(); $rates['free_shipping'] = $free_shipping; } return $rates; }
Hide all WooCommerce breadcrumbs
add_action( 'init', 'hide_woocommerce_breadcrumbs' ); function hide_woocommerce_breadcrumbs() { remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 ); }
Hide the coupon form on the cart or checkout page in WooCommerce
// hide coupon form everywhere function hide_coupon_field( $enabled ) { if ( is_cart() || is_checkout() ) { $enabled = false; } return $enabled; } add_filter( 'woocommerce_coupons_enabled', 'hide_coupon_field' );
Change the ‘add to cart’ text in WooCommerce
add_filter( 'woocommerce_product_add_to_cart_text', 'custom_add_to_cart_text' ); // category (archives) add_filter( 'woocommerce_product_single_add_to_cart_text', 'custom_add_to_cart_text' ); // single function custom_add_to_cart_text() { return 'My add to cart text'; }