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_add_to_cart_validation', 'check_if_product_exists_in_cart', 10, 2 ); | |
function check_if_product_exists_in_cart( $is_valid, $product_id ) { | |
$product = wc_get_product( $product_id ); | |
if ( $product->is_sold_individually() ) { | |
$cart_contents = WC()->cart->get_cart_contents(); |
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
/** | |
* Remove the "Congratulations on the sale." string from admin New Order emails | |
*/ | |
add_filter( 'gettext', 'sk_translate_woocommerce_strings_emails', 999 ); | |
function sk_translate_woocommerce_strings_emails( $translated ) { | |
// Get the string and translate it to an empty string | |
$translated = str_ireplace( 'Congratulations on the sale.', '', $translated ); | |
return $translated; |
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
//Remove title hook and add in a new one with the product categories added | |
remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 ); | |
add_action( 'woocommerce_shop_loop_item_title', 'sk_category_loop_product_title', 10 ); | |
function sk_category_loop_product_title() { | |
echo '<h3>' . get_the_title() . '</h3>'; | |
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_shipping_fields', 'sk_require_shipping_state_field'); | |
function sk_require_shipping_state_field( $fields ) { | |
$fields['shipping_state']['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_localisation_address_formats', 'sk_use_full_us_state_names', 20, 2 ); | |
function sk_use_full_us_state_names( $address_formats ){ | |
$address_formats['US'] = "{name}\n{company}\n{address_1}\n{address_2}\n{city}, {state} {postcode}\n{country}"; | |
return $address_formats; | |
} |
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 term and conditions checkbox on cart page, based on the code from LoicTheAztec | |
add_action( 'woocommerce_proceed_to_checkout', 'add_terms_and_conditions_to_cart_page', 5 ); | |
function add_terms_and_conditions_to_cart_page() { | |
if ( wc_get_page_id( 'terms' ) > 0 && is_cart() ) { | |
?> | |
<p class="form-row terms wc-terms-and-conditions"> | |
<label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox"> | |
<input type="checkbox" class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" name="terms" <?php checked( apply_filters( 'woocommerce_terms_is_checked_default', isset( $_POST['terms'] ) ), true ); ?> id="terms" /> <span><?php printf( __( 'I’ve read and accept the <a href="%s" target="_blank" class="woocommerce-terms-and-conditions-link">terms & conditions</a>', 'woocommerce' ), esc_url( wc_get_page_permalink( 'terms' ) ) ); ?></span> <span class="required">*</span> | |
</label> |
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
/** | |
* Fix the path of Woo script. | |
* | |
* @param string $url The URL to the file. | |
* @param string $min_path The minified path. | |
* @param string $non_min_path The non-minified path. | |
*/ | |
function jetpackcom_fix_woo_script_path( $url, $min_path, $non_min_path ) { | |
if ( wp_startswith( $min_path, 'https://stats.wp.com/s-' ) ) { | |
return $min_path; |
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
/** | |
* Remove USPS Flat Rate packages from the available options | |
* Only the Large Box (d22), Medium Box (d17b), and Legal Envelope (d44) will be used | |
*/ | |
add_filter( 'usps_flat_rate_boxes', 'custom_usps_flat_rate_boxes' ); | |
function custom_usps_flat_rate_boxes( $flat_rate_boxes ) { | |
unset($flat_rate_boxes["d29"]); | |
unset($flat_rate_boxes["d63"]); | |
unset($flat_rate_boxes["d16"]); |
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
/** | |
* Never load Jetpack's WooCommerce Analytics tool. | |
* | |
* @param array $tools Array of additional tools loaded by Jetpack without any UI to turn them off. | |
*/ | |
function jetpackcom_no_woo_analytics( $tools ) { | |
$index = array_search( 'woocommerce-analytics/wp-woocommerce-analytics.php', $tools ); | |
if ( false !== $index ) { | |
unset( $tools[ $index ] ); | |
} |
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
.site-header-cart.menu { | |
display: none; | |
} |
NewerOlder