add_action('woocommerce_email_after_order_table', 'add_email_shipping_text');
function add_email_shipping_text(){
echo '';
}
WooCommerce
Removing BACS instructions from email notifications in WooCommerce
add_action( 'woocommerce_email_before_order_table', function(){
if ( ! class_exists( 'WC_Payment_Gateways' ) ) return;
$gateways = WC_Payment_Gateways::instance(); // gateway instance
$available_gateways = $gateways->get_available_payment_gateways();
if ( isset( $available_gateways['bacs'] ) )
remove_action( 'woocommerce_email_before_order_table', array( $available_gateways['bacs'], 'email_instructions' ), 10, 3 );
}, 1 );
Add instructions to the email, based on the payment method
add_action( 'woocommerce_before_email_order', 'add_order_instruction_email', 10, 2 );
function add_order_instruction_email( $order, $sent_to_admin ) {
if ( ! $sent_to_admin ) {
if ( 'cod' == $order->payment_method ) {
// cash on delivery method
echo '<p><strong>Instructions:</strong> Full payment is due immediately upon delivery: <em>cash only, no exceptions</em>.</p>';
} else {
// other methods (ie credit card)
echo '<p><strong>Instructions:</strong> Please look for "Madrigal Electromotive GmbH" on your next credit card statement.</p>';
}
}
}
How to change WooCommerce email subject
{order_date} keltezésű {site_title} rendelés visszaigazolása
WooCommerce emails based on payment method
function add_content_specific_email( $order, $sent_to_admin, $plain_text, $email ) {
$payment_method = $order->payment_method;
if ( $payment_method == 'bacs' ) {
echo 'Your text';
}
}
add_action( 'woocommerce_email_before_order_table', 'add_content_specific_email', 20, 4 );
Order date-time in customer processing order email notification
//Order date-time in customer processing order email notification
add_action( 'woocommerce_email_order_details', 'custom_processing_order_notification', 1, 4 );
function custom_processing_order_notification( $order, $sent_to_admin, $plain_text, $email ) {
// Only for processing email notifications to customer
if( ! 'customer_processing_order' == $email->id ) return;
$date_modified = $order->get_date_modified();
$date_paid = $order->get_date_paid();
$date = empty( $date_paid ) ? $date_modified : $date_paid;
echo sprintf( '<p>A rendelés száma: %s <br>A rendelés dátuma: <time>%s</time>)</p>',
$order->get_order_number( ),
$date->date("Y.m.j.")
);
}
Shipping method – Show only the selected description
function syslab_update_order_review_fragments( $array ) {
// make filter magic happen here...
$array['.woocommerce-checkout-review-order-table'] = $array['.woocommerce-checkout-review-order-table'].'<script>jQuery(".shipping_method:checked").parent("li").find(".shipping-desc").stop().show();</script>';
return $array;
};
// add the filter
add_filter( 'woocommerce_update_order_review_fragments', 'syslab_update_order_review_fragments', 10, 1 );
Fix broken lightbox on product single page
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 product main content editor
//REMOVE PRODUCT MAIN EDITOR - CONTENT EDITOR
function remove_product_editor() {
remove_post_type_support( 'product', 'editor' );
}
add_action( 'init', 'remove_product_editor' );
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>');
}
Disable Payment Method for Specific Category
add_filter('woocommerce_available_payment_gateways','bbloomer_unset_gateway_by_category');
function bbloomer_unset_gateway_by_category($available_gateways){
global $woocommerce;
$category_IDs = array(38,39);
foreach ($woocommerce->cart->cart_contents as $key => $values ) {
$terms = get_the_terms( $values['product_id'], 'product_cat' );
foreach ($terms as $term) {
if(in_array($term->term_id, $category_IDs)){
unset( $available_gateways['cod'] );
break;
}
break;
}
}
return $available_gateways;
}
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' );
}