Skip to content

Instantly share code, notes, and snippets.

View fschmittlein's full-sized avatar

Frank Schmittlein fschmittlein

View GitHub Profile
@Zodiac1978
Zodiac1978 / toolbox.md
Last active June 29, 2023 12:48
List of useful online tools for website QA
@manuelhudec
manuelhudec / woocommerce-custom-tabs-per-product.php
Last active January 5, 2023 02:03
WooCommerce custom tabs per product
// Use the following code and paste it into the Code Snippets plugin or functions.php of your child theme.
// After that you will find a new meta box in the WooCommerce products.
// Everything you enter there will appear in the single product as a new tab.
// In line 17 you can give your meta box a title
// In line 88 you can give your tab a title
// Adding a custom Meta container to admin products pages
add_action( 'add_meta_boxes', 'create_custom_meta_box' );
@manuelhudec
manuelhudec / woocommerce-display-cross-selling-products-in-single-product-summary.php
Last active February 14, 2023 22:52
WooCommerce - Display Cross-Selling Products in Single Product Summary
add_action('blocksy:woocommerce:product-single:excerpt:after', 'show_cross_sell_in_single_product', 30);
function show_cross_sell_in_single_product(){
$crosssells = get_post_meta( get_the_ID(), '_crosssell_ids',true);
if(empty($crosssells)){
return;
}
$args = array(
'post_type' => 'product',
@manuelhudec
manuelhudec / woocommerce-product-subtitle.php
Created June 12, 2021 18:21
WooCommerce - Product Subtitle under Product Title
//Register the product custom field
add_action( 'woocommerce_product_options_inventory_product_data', 'my_woocommerce_product_subheading' );
function my_woocommerce_product_subheading() {
$args = array(
'label' => 'Produkt-Untertitel', // Text in Label
'placeholder' => 'Produkt-Untertitel',
'id' => 'product_subheading', // required
'name' => 'product_subheading',
'desc_tip' => 'Produkt-Untertitel eingeben',
@manuelhudec
manuelhudec / disable-wordpress-admin-bar-for-all-users-except-administrators.php
Created June 6, 2021 14:22
Disable WordPress Admin Bar for All Users Except Administrators
add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
@manuelhudec
manuelhudec / woocommerce-remove-tabs-in-single-product.php
Created June 1, 2021 19:17
WooCommerce - Remove Tabs in single product
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
// unset( $tabs['description'] ); // Remove the description tab
// unset( $tabs['reviews'] ); // Remove the reviews tab
// unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
}
@manuelhudec
manuelhudec / woocommerce-hide-checkout-fields-in-the-checkout-page.php
Created June 1, 2021 19:14
WooCommerce - Hide checkout fields in the checkout page
// Remove checkout fields
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
// remove billing fields
// unset($fields['billing']['billing_first_name']); // Billing First name
// unset($fields['billing']['billing_last_name']); // Billing Last name
// unset($fields['billing']['billing_company']); // Billing company
// unset($fields['billing']['billing_address_1']); // Billing Address 1
// unset($fields['billing']['billing_address_2']); // Billing Address 2
@manuelhudec
manuelhudec / woocommerce-enable-gutenberg-support-for-products.php
Created June 1, 2021 19:11
WooCommerce - Enable Gutenberg support for products
function activate_gutenberg_product( $can_edit, $post_type ) {
if ( $post_type == 'product' ) {
$can_edit = true;
}
return $can_edit;
}
add_filter( 'use_block_editor_for_post_type', 'activate_gutenberg_product', 10, 2 );
// enable taxonomy fields for woocommerce with gutenberg on
function enable_taxonomy_rest( $args ) {
@manuelhudec
manuelhudec / woocommerce-shopping-cart-redirect-to-checkout.php
Created June 1, 2021 19:10
WooCommerce - Shopping cart redirect to checkout
add_action( 'template_redirect', function() {
// Replace "cart" and "checkout" with cart and checkout page slug if needed
if ( is_page( 'cart' ) ) {
wp_redirect( '/checkout/' );
die();
}
} );
add_action( 'template_redirect', 'redirect_empty_checkout' );
@manuelhudec
manuelhudec / woocommerce-display-out-of-stock-products-in-archives-last.php
Created June 1, 2021 19:10
WooCommerce - Show out of stock products in archives last
add_action( 'woocommerce_product_query', 'out_of_stock_last', 999 );
function out_of_stock_last( $query ) {
if ( is_admin() ) return;
$query->set( 'meta_key', '_stock_status' );
$query->set( 'orderby', array( 'meta_value' => 'ASC' ) );
}