Skip to content

Instantly share code, notes, and snippets.

View fschmittlein's full-sized avatar

Frank Schmittlein fschmittlein

View GitHub Profile
@manuelhudec
manuelhudec / woocommerce-reviews-as-shortcode.php
Created June 1, 2021 19:08
WooCommerce - Reviews as shortcode
add_shortcode( 'wpse_comments_template', function( $atts = array(), $content = '' )
{ if( is_singular() && post_type_supports( get_post_type(), 'comments' ) )
{
ob_start();
comments_template();
return ob_get_clean();
}
return '';
}, 10, 2 );
@manuelhudec
manuelhudec / woocommerce-hide-category-product-count-in-product-archives.php
Created June 1, 2021 19:08
WooCommerce - Hide category product count in product archives
add_filter( 'woocommerce_subcategory_count_html', '__return_false' );
@manuelhudec
manuelhudec / woocommerce-customer-account-shop-recently-purchased-products.php
Created June 1, 2021 19:07
WooCommerce - Customer account: Show recently purchased products
add_filter ( 'woocommerce_account_menu_items', 'misha_purchased_products_link', 40 );
add_action( 'init', 'misha_add_products_endpoint' );
add_action( 'woocommerce_account_purchased-products_endpoint', 'misha_populate_products_page' );
// here we hook the My Account menu links and add our custom one
function misha_purchased_products_link( $menu_links ){
// we use array_slice() because we want our link to be on the 3rd position
return array_slice( $menu_links, 0, 2, true )
+ array( 'purchased-products' => 'Purchased Products' )
@manuelhudec
manuelhudec / woocommerce-customer-account-enable-label-for-billing-and-shipping-adress.php
Last active February 24, 2022 12:51
WooCommerce - Customer account: Enable "Label" for billing and shipping address
// Billing Fields.
add_filter( 'woocommerce_billing_fields', 'custom_woocommerce_billing_fields' );
function custom_woocommerce_billing_fields( $fields ) {
$fields['billing_address_2']['label'] = 'Address 2';
$fields['billing_address_2']['label_class'] = '';
return $fields;
}
// Shipping Fields.
@manuelhudec
manuelhudec / woocommerce-disable-downloadable-virtual-products.php
Created June 1, 2021 19:00
WooCommerce - disable downloadable & virtual products
function my_remove_product_type_options( $options ) {
// uncomment this if you want to remove virtual too.
if ( isset( $options['virtual'] ) ) {
unset( $options['virtual'] );
}
if ( isset( $options['downloadable'] ) ) {
unset( $options['downloadable'] );
}
return $options;
}
@manuelhudec
manuelhudec / german-market-hide-tax-details-delivery-time-products-archive.php
Created June 1, 2021 18:58
German Market WP Plugin - Hide tax details & delivery time in products archive
add_action( 'after_setup_theme', function() {
remove_action( 'woocommerce_after_shop_loop_item_title', array( 'WGM_Template', 'woocommerce_de_price_with_tax_hint_loop' ), 5 );
});
@manuelhudec
manuelhudec / german-market-hide-tax-details-delivery-time-products.php
Created June 1, 2021 18:57
German Market WP Plugin - Hide tax details & delivery time in products
add_action( 'after_setup_theme', function() {
remove_action( 'woocommerce_single_product_summary', array( 'WGM_Template', 'woocommerce_de_price_with_tax_hint_single' ), 7 );
});
@manuelhudec
manuelhudec / client-portal-portal-role.php
Created June 1, 2021 18:54
Client-Portal WP Plugin - Admin and store customers also as customer portal role
function my_leco_cp_client_roles( $roles ) {
$roles = array_merge( $roles, array( 'administrator', 'customer' ) );
return $roles;
}
add_filter( 'leco_cp_client_roles', 'my_leco_cp_client_roles' );
@manuelhudec
manuelhudec / client-portal-logout-redirect.php
Created June 1, 2021 18:53
Client-Portal.io - Logout Redirect
function my_leco_cp_logout_url() {
// return the preferred URL.
return home_url();
}
add_filter( 'leco_cp_logout_url', 'my_leco_cp_logout_url' );
function my_leco_cp_client_portal_archive() {
return 'Ihre Projekte';
}
add_filter( 'leco_cp_client_portal_archive', 'my_leco_cp_client_portal_archive' );
@manuelhudec
manuelhudec / blocksy-theme-preload-fonts.php
Created June 1, 2021 18:42
Blocksy Theme - Preload Fonts
add_action( 'wp_head', function () {
?>
<link rel="preload" href="/wp-content/uploads/blocksy/local-google-fonts/s/opensans/v20/mem8YaGs126MiZpBA-UFVZ0bf8pkAg.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/wp-content/uploads/blocksy/local-google-fonts/s/opensans/v20/mem5YaGs126MiZpBA-UNirkOUuhpKKSTjw.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/wp-content/uploads/blocksy/local-google-fonts/s/poppins/v15/pxiByp8kv8JHgFVrLCz7Z1xlFd2JQEk.woff2" as="font" type="font/woff2" crossorigin>
<?php } );