This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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'); |
OlderNewer