//REMOVE PRODUCT MAIN EDITOR - CONTENT EDITOR
function remove_product_editor() {
remove_post_type_support( 'product', 'editor' );
}
add_action( 'init', 'remove_product_editor' );
Free
Change number of products displayed per page
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
function new_loop_shop_per_page( $cols ) {
// $cols contains the current number of products per page based on the value stored on Options -> Reading
// Return the number of products you wanna show per page.
$cols = 60;
return $cols;
}
WooCommerce add text to the thank you page order number
//WooCommerce add text to the thank you page order number - rendelésszám
add_action( 'woocommerce_thankyou_order_received_text', 'weitzterez_add_content_thankyou' );
function weitzterez_add_content_thankyou() {
echo '<h2 class="h2thanks">Banki átutalásnál a <strong>rendelés számot</strong> kérlek, írd bele a megjegyzés rovatba!</h2><p class="pthanks"></p>';
}
Add support to zoom gallery
add_action( 'after_setup_theme', 'yourtheme_setup' );
function yourtheme_setup() {
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
}
Remove Zoom, Gallery on Single Product Page
add_action( 'after_setup_theme', 'bbloomer_remove_zoom_lightbox_theme_support', 99 );
function bbloomer_remove_zoom_lightbox_theme_support() {
remove_theme_support( 'wc-product-gallery-zoom' );
remove_theme_support( 'wc-product-gallery-lightbox' );
remove_theme_support( 'wc-product-gallery-slider' );
}
Change add to cart button to view product
/*STEP 1 - REMOVE ADD TO CART BUTTON ON PRODUCT ARCHIVE (SHOP) */
function remove_loop_button(){
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
}
add_action('init','remove_loop_button');
/*STEP 2 -ADD NEW BUTTON THAT LINKS TO PRODUCT PAGE FOR EACH PRODUCT */
add_action('woocommerce_after_shop_loop_item','replace_add_to_cart');
function replace_add_to_cart() {
global $product;
$link = $product->get_permalink();
echo do_shortcode('<a href="'.$link.'" class="button addtocartbutton">Megtekintés</a>');
}
Add Tabs after Add to cart button
//Add Tabs after Add to cart button
add_action( 'woocommerce_single_product_summary', 'wc_custom_show_attributes_outside_tabs', 35 );
function wc_custom_show_attributes_outside_tabs() {
global $product;
$product->list_attributes();
}
Remove Additional informations
//Remove Additional informations
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
}
Send customer directly to the checkout
//send customer directly to the checkout
add_filter('add_to_cart_redirect', 'theme_prefix_add_to_cart_redirect');
function theme_prefix_add_to_cart_redirect() {
global $woocommerce;
$checkout_url = $woocommerce->cart->get_checkout_url();
return $checkout_url;
}
Remove quantity field
//REMOVE QUANTITY FIELD
add_filter( 'woocommerce_is_sold_individually', 'wc_remove_all_quantity_fields', 10, 2 );
function wc_remove_all_quantity_fields( $return, $product ) {
return( true );
}
Change add to cart button text
//CHANGE ADD TO CART BUTTON TEXT
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_single_add_to_cart_text' ); // 2.1 +
function woo_custom_single_add_to_cart_text() {
return __( 'Kosárba teszem', 'woocommerce' );
}
Add post category to body class
// =========================================================================
// ADD POST CATEGORY TO BODY CLASS
// =========================================================================
function add_category_to_body_class( $classes ) {
if ( !is_single() )
return $classes;
$post_categories = get_the_category();
foreach( $post_categories as $current_category ) {
$classes[] = 'category-' . $current_category->slug;
}
return $classes;
}
add_filter( 'body_class', 'add_category_to_body_class' );
Add product category to body class
//ADD PRODUCT CATEGORY TO BODY CLASS
add_filter( 'body_class', 'bbloomer_wc_product_cats_css_body_class' );
function bbloomer_wc_product_cats_css_body_class( $classes ){
if( is_singular( 'product' ) )
{
$custom_terms = get_the_terms(0, 'product_cat');
if ($custom_terms) {
foreach ($custom_terms as $custom_term) {
$classes[] = 'product_cat_' . $custom_term->slug;
}
}
}
return $classes;
}
Add text to specific product category
Version 1
// =========================================================================
// ADD TEXT TO SPECIFIC PRODUCT CATEGORY
// =========================================================================
function function_name( $attr ) {
global $product;
if ( has_term( 'category_name', 'product_cat', $product->get_id() ) ) {
echo 'TESZT';
}
return $attr;
}
add_filter( 'woocommerce_share', 'function_name' );
Version 2
// =========================================================================
// ADD TEXT TO SPECIFIC PRODUCT CATEGORY
// =========================================================================
function add_text_to_spec_cat() {
global $post;
$terms = wp_get_post_terms( $post->ID, 'product_cat' );
foreach ( $terms as $term ) $categories[] = $term->slug;
if ( in_array( 'szivar', $categories ) ) {
echo 'TESZT';
}
}
add_filter( 'woocommerce_after_single_product', 'add_text_to_spec_cat' );
Change position of add-to-cart on single product
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 30 );
Hook revslider in Storefront
//HOOK REVSLIDER
add_filter( 'storefront_before_content', 'add_revslider' );
function add_revslider( $rev_slider ) {
if ( is_front_page() ) {
echo do_shortcode('[rev_slider alias="revslider"]');
}
return $rev_slider;
}
Fix collapsed related products
//FIX COLLAPSED RELATED PRODUCTS
add_filter( 'woocommerce_after_single_product_summary', 'add_clear_both' );
function add_clear_both( $clear_both ) {
echo '<div class="clear"></div>';
return $clear_both;
}
Add text with function
//ADD TEXT VIA FUNCTION
add_filter( 'ultimatum_print_footer', 'add_barion_banner' );
function add_barion_banner( $barion_banner ) {
echo 'TESZT';
return $barion_banner;
}
Product category shortcode
[product_category category=”” per_page=”40″ columns=”3″ orderby=”rand”]
New order e-mail custom text if coupon is used
// New order e-mail custom text if coupon is used
add_filter( 'woocommerce_email_after_order_table', 'add_custom_email_text' );
function add_custom_email_text($order) {
if ($order->get_used_coupons()){
echo '';
}
else{
echo '';
}
}