This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('template_redirect', 'woocommerce_custom_redirections'); | |
function woocommerce_custom_redirections() { | |
// Kunde nicht angemeldet oder registriert. | |
if ( !is_user_logged_in() && is_checkout() ) | |
wp_redirect( get_permalink( get_option('woocommerce_myaccount_page_id') ) ); | |
// Kunde registriert und angemeldet | |
if( is_user_logged_in() && ! WC()->cart->is_empty() && is_account_page() ) | |
wp_redirect( get_permalink( get_option('woocommerce_checkout_page_id') ) ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'woocommerce_product_categories_widget_args', 'wdm_edit_product_cat_widget_args' ); | |
function wdm_edit_product_cat_widget_args( $cat_args ) { | |
$cat_args['exclude'] = array('20'); // Produkt ID (20) austauschen | |
return $cat_args; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'woocommerce_get_price_html', 'wpglorify_price_free_zero_empty', 100, 2 ); | |
function wpglorify_price_free_zero_empty( $price, $product ){ | |
if ( '' === $product->get_price() || 0 == $product->get_price() ) { | |
$price = 'kostenlos!'; // Text anpassen | |
} | |
return $price; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_add_cart_item_data', function( $cart_item_data, $product_id ) { | |
// ID austauschen. Wenn Produkt A mit ID 54 im Warenkorb liegt, kommt Produkt B mit ID 56 automatisch im Warenkorb hinzu. | |
if ( 54 == $product_id ) { | |
WC()->cart->add_to_cart( 56 ); | |
} | |
}, 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* WooCommerce Stückzahl - Mindeststückzahl - Höchststückzahl - Mengenschritte | |
*/ | |
add_filter( 'woocommerce_quantity_input_args', 'jk_woocommerce_quantity_input_args', 10, 2 ); // Einfache Produkte | |
function jk_woocommerce_quantity_input_args( $args, $product ) { | |
if ( is_singular( 'product' ) ) { | |
$args['input_value'] = 2; // Start Stückzahl | |
} | |
$args['max_value'] = 20; // Höchststückzahl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Bestellmenge auf der WooCommerce Archivseite | |
*/ | |
add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_woocommerce_loop_add_to_cart_link', 10, 2 ); | |
function quantity_inputs_for_woocommerce_loop_add_to_cart_link( $html, $product ) { | |
if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) { | |
$html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">'; | |
$html .= woocommerce_quantity_input( array(), $product, false ); | |
$html .= '<button type="submit" class="button alt">' . esc_html( $product->add_to_cart_text() ) . '</button>'; | |
$html .= '</form>'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Informationen vor Anmeldung und Registrierung eines Kundenkontos bei "Mein Konto" | |
* Informationen gegen eigene Texte austauschen | |
*/ | |
add_action( 'woocommerce_before_customer_login_form', 'jk_login_message' ); | |
function jk_login_message() { | |
if ( get_option( 'woocommerce_enable_myaccount_registration' ) == 'yes' ) { | |
?> | |
<div class="woocommerce-info"> | |
<p><?php _e( 'Viele Vorteile durch ein Kundenkonto:' ); ?></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( !function_exists( 'evolution_custom_sales_price' ) ) : | |
/** | |
* Zeigt dem Kunden Prozente, die durch ein Songerangebot gespart werden | |
* | |
* @add filter to products | |
* | |
* @return filter | |
*/ | |
function evolution_custom_sales_price( $price, $regular_price, $sale_price ) { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add_checkout_fee() { | |
global $woocommerce; | |
$woocommerce->cart->add_fee( __('Gebühr', 'woocommerce'), 5 ); // Text im Warenkorb und Gebühr anpassen | |
} | |
add_action( 'woocommerce_cart_calculate_fees', 'add_checkout_fee' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* WooCommerce Bestellung immer den Status "Fertiggestellt" | |
*/ | |
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' ); | |
function custom_woocommerce_auto_complete_order( $order_id ) { | |
if ( ! $order_id ) { | |
return; | |
} | |
$order = wc_get_order( $order_id ); |