Skip to content

Instantly share code, notes, and snippets.

/**
* Hides the product's weight and dimension in the single product page.
*/
add_filter( 'wc_product_enable_dimensions_display', '__return_false' );
@SirDarcanos
SirDarcanos / functions.php
Created May 16, 2017 05:26
functions.php
add_filter( 'woocommerce_is_attribute_in_product_name', '__return_false' );
@SirDarcanos
SirDarcanos / functions.php
Last active May 16, 2017 05:30
functions.php
/**
* Removes the attribute from the product title, in the cart.
*
* @return string
*/
function remove_variation_from_product_title( $title, $cart_item, $cart_item_key ) {
$_product = $cart_item['data'];
$product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key );
if ( $_product->is_type( 'variation' ) ) {
@SirDarcanos
SirDarcanos / functions.php
Created May 16, 2017 05:49
functions.php
add_filter( 'woocommerce_min_password_strength', create_function( '', 'return 2;' ) );
@SirDarcanos
SirDarcanos / functions.php
Created May 16, 2017 05:51
functions.php
function wc_ninja_remove_password_strength() {
if ( wp_script_is( 'wc-password-strength-meter', 'enqueued' ) ) {
wp_dequeue_script( 'wc-password-strength-meter' );
}
}
add_action( 'wp_print_scripts', 'wc_ninja_remove_password_strength', 100 );
<?php
/**
* Load a custom template for vendor taxonomy
*/
function load_custom_vendor_template( $located, $template_name ) {
if( is_tax( WC_PRODUCT_VENDORS_TAXONOMY ) && 'archive-product.php' == $template_name ) {
return get_stylesheet_directory() . '/woocommerce/taxonomy-shop_vendor.php';
}
return $located;
@SirDarcanos
SirDarcanos / functions.php
Created July 18, 2017 08:30
functions.php
/**
* Checks if the customer is a reseller and
* returns false if they are trying to purchase from a specific category.
*
* @param bool $is_purchasable If the product is purchasable or not.
* @return bool
*/
function limit_purchases_by_role( $is_purchasable, $product ) {
$categories = $product->get_category_ids();
@SirDarcanos
SirDarcanos / functions.php
Created July 28, 2017 06:00
functions.php
add_action( 'woocommerce_no_products_found', 'show_products_on_no_products_found', 20 );
function show_products_on_no_products_found() {
echo '<h2>' . __( 'You may be interested in...', 'domain' ) . '</h2>';
echo do_shortcode( '[recent_products per_page="4"]' );
}
add_filter( 'booking_form_params', 'change_booking_form_params' );
function change_booking_form_params( $params ) {
$params['i18n_date_unavailable' = 'This date is unavailable';
$params['i18n_date_fully_booked'] = 'This date is fully booked and unavailable';
$params['i18n_date_partially_booked'] = 'This date is partially booked - but bookings still remain';
$params['i18n_date_available'] = 'This date is available';
$params['i18n_start_date'] = 'Choose a Start Date';
$params['i18n_end_date'] = 'Choose an End Date';
$params['i18n_dates'] = 'Dates';
$params['i18n_choose_options'] = 'Please select the options for your booking above first';
add_action( 'init', 'remove_footer_checkout' );
function remove_footer_checkout() {
if ( is_checkout() ) {
remove_action( 'storefront_footer', 'storefront_handheld_footer_bar', 999 );
}
}